| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Data.RAList
Description
Random access list.
This module is designed to imported qualifed.
Synopsis
- data RAList a
- explicitShow :: Show a => RAList a -> String
- explicitShowsPrec :: Show a => Int -> RAList a -> ShowS
- empty :: RAList a
- singleton :: a -> RAList a
- cons :: a -> RAList a -> RAList a
- (!) :: RAList a -> Int -> a
- (!?) :: RAList a -> Int -> Maybe a
- uncons :: RAList a -> Maybe (a, RAList a)
- length :: RAList a -> Int
- null :: RAList a -> Bool
- toList :: RAList a -> [a]
- fromList :: [a] -> RAList a
- ifoldMap :: Monoid m => (Int -> a -> m) -> RAList a -> m
- adjust :: forall a. Int -> (a -> a) -> RAList a -> RAList a
- map :: (a -> b) -> RAList a -> RAList b
- imap :: (Int -> a -> b) -> RAList a -> RAList b
- itraverse :: forall f a b. Applicative f => (Int -> a -> f b) -> RAList a -> f (RAList b)
Documentation
Random access list.
Instances
| Functor RAList Source # | |
| Foldable RAList Source # |
|
Defined in Data.RAList.Internal Methods fold :: Monoid m => RAList m -> m # foldMap :: Monoid m => (a -> m) -> RAList a -> m # foldr :: (a -> b -> b) -> b -> RAList a -> b # foldr' :: (a -> b -> b) -> b -> RAList a -> b # foldl :: (b -> a -> b) -> b -> RAList a -> b # foldl' :: (b -> a -> b) -> b -> RAList a -> b # foldr1 :: (a -> a -> a) -> RAList a -> a # foldl1 :: (a -> a -> a) -> RAList a -> a # elem :: Eq a => a -> RAList a -> Bool # maximum :: Ord a => RAList a -> a # minimum :: Ord a => RAList a -> a # | |
| Traversable RAList Source # | |
| Arbitrary1 RAList Source # | |
Defined in Data.RAList.Internal Methods liftArbitrary :: Gen a -> Gen (RAList a) # liftShrink :: (a -> [a]) -> RAList a -> [RAList a] # | |
| Eq a => Eq (RAList a) Source # | |
| Ord a => Ord (RAList a) Source # | |
Defined in Data.RAList.Internal | |
| Show a => Show (RAList a) Source # | |
| Semigroup (RAList a) Source # |
|
| Monoid (RAList a) Source # | |
| Function a => Function (RAList a) Source # | |
| Arbitrary a => Arbitrary (RAList a) Source # | |
| CoArbitrary a => CoArbitrary (RAList a) Source # | |
Defined in Data.RAList.Internal Methods coarbitrary :: RAList a -> Gen b -> Gen b # | |
| NFData a => NFData (RAList a) Source # | |
Defined in Data.RAList.Internal | |
| Hashable a => Hashable (RAList a) Source # | |
Defined in Data.RAList.Internal | |
Showing
Construction
Indexing
(!?) :: RAList a -> Int -> Maybe a Source #
safe list index.
>>>fromList ['a'..'f'] !? 0Just 'a'
>>>fromList ['a'..'f'] !? 5Just 'f'
>>>fromList ['a'..'f'] !? 6Nothing
uncons :: RAList a -> Maybe (a, RAList a) Source #
>>>uncons $ fromList []Nothing
>>>uncons $ fromList "abcdef"Just ('a',fromList "bcdef")
Conversions
fromList :: [a] -> RAList a Source #
>>>fromList ['a' .. 'f']fromList "abcdef"
>>>explicitShow $ fromList ['a' .. 'f']"NonEmpty (NE (Cons0 (Cons1 (Nd (Lf 'a') (Lf 'b')) (Last (Nd (Nd (Lf 'c') (Lf 'd')) (Nd (Lf 'e') (Lf 'f')))))))"
Folding
Mapping
adjust :: forall a. Int -> (a -> a) -> RAList a -> RAList a Source #
Adjust a value in the list.
>>>adjust 3 toUpper $ fromList "bcdef"fromList "bcdEf"
If index is out of bounds, the list is returned unmodified.
>>>adjust 10 toUpper $ fromList "bcdef"fromList "bcdef"
>>>adjust (-1) toUpper $ fromList "bcdef"fromList "bcdef"
map :: (a -> b) -> RAList a -> RAList b Source #
>>>map toUpper (fromList ['a'..'f'])fromList "ABCDEF"