HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Moduleral-0.2.2Haskell2010

Data.RAList

Random access list.

This module is designed to imported qualifed.

  • 1 type
  • 17 values
  • Packageral-0.2.2
  • Exports18
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourceRAList.hs
datadata RAList a
#

Random access list.

Constructors

Instances17Functor, Foldable, Traversable, Arbitrary1, FoldableWithIndex, FunctorWithIndex, …

Showing

2 declarations

Construction

3 declarations
valueempty :: RAList a
#

Empty RAList.

Example1 expression
empty :: RAList IntfromList []

Indexing

5 declarations
value(!?) :: RAList a -> Int -> Maybe a
#

safe list index.

Example1 expression
fromList ['a'..'f'] !? 0Just 'a'
Example1 expression
fromList ['a'..'f'] !? 5Just 'f'
Example1 expression
fromList ['a'..'f'] !? 6Nothing
valueuncons :: RAList a -> Maybe (a, RAList a)
#
Example1 expression
uncons $ fromList []Nothing
Example1 expression
uncons $ fromList "abcdef"Just ('a',fromList "bcdef")

Conversions

2 declarations
valuefromList :: [a] -> RAList a
#
Example1 expression
fromList ['a' .. 'f']fromList "abcdef"
Example1 expression
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

1 declaration

Mapping

4 declarations
valueadjust :: Int -> (a -> a) -> RAList a -> RAList a
#

Adjust a value in the list.

Example1 expression
adjust 3 toUpper $ fromList "bcdef"fromList "bcdEf"

If index is out of bounds, the list is returned unmodified.

Example1 expression
adjust 10 toUpper $ fromList "bcdef"fromList "bcdef"
Example1 expression
adjust (-1) toUpper $ fromList "bcdef"fromList "bcdef"
valuemap :: (a -> b) -> RAList a -> RAList b
#
Example1 expression
map toUpper (fromList ['a'..'f'])fromList "ABCDEF"
valueimap :: (Int -> a -> b) -> RAList a -> RAList b
#
Example1 expression
imap (,) $ fromList ['a' .. 'f']fromList [(0,'a'),(1,'b'),(2,'c'),(3,'d'),(4,'e'),(5,'f')]