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

  • Packageral-0.2.2
  • Exports33
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourceRAVec.hs

Random access list

1 declaration
datadata RAVec (b :: Bin) a where
#

Length indexed random access lists.

Constructors

Instances25Functor, Applicative, Foldable, Traversable, Foldable1, Arbitrary1, …

Construction

6 declarations
valuecons :: a -> RAVec b a -> RAVec (Succ b) a
#

Cons an element in front of RAVec.

Example1 expression
reifyList "xyz" (print . toList . cons 'a')"axyz"
valuehead :: RAVec ('BP b) a -> a
#

The first element of a non-empty RAVec.

Example1 expression
reifyNonEmpty ('x' :| "yz") head'x'
valuelast :: RAVec ('BP b) a -> a
#

The last element of a non-empty RAVec.

Example1 expression
reifyNonEmpty ('x' :| "yz") last'z'

Conversion

5 declarations
valuefromList :: SBinI b => [a] -> Maybe (RAVec b a)
#

Convert a list [a] to RAVec b a. Returns Nothing if lengths don't match.

Example1 expression
fromList "foo" :: Maybe (RAVec B.Bin3 Char)Just (NonEmpty (NE (Cons1 (Leaf 'f') (Last (Node (Leaf 'o') (Leaf 'o'))))))
Example1 expression
fromList "quux" :: Maybe (RAVec B.Bin3 Char)Nothing
Example1 expression
fromList "xy" :: Maybe (RAVec B.Bin3 Char)Nothing
valuereifyList :: [a] -> (forall (b :: Bin). SBinI b => RAVec b a -> r) -> r
#
Example1 expression
reifyList "foo" printNonEmpty (NE (Cons1 (Leaf 'f') (Last (Node (Leaf 'o') (Leaf 'o')))))
Example1 expression
reifyList "xyzzy" toList"xyzzy"

Indexing

2 declarations
value(!) :: RAVec b a -> Pos b -> a
#

Indexing.

Example1 expression
let ral :: RAVec B.Bin4 Char; Just ral = fromList "abcd"
Example1 expression
ral ! minBound'a'
Example1 expression
ral ! maxBound'd'
Example1 expression
ral ! pop top'b'

Folds

6 declarations
valuefoldr :: (a -> b -> b) -> b -> RAVec n a -> b
#

Special folds

1 declaration

Mapping

6 declarations

Zipping

2 declarations

Universe

2 declarations
valueuniverse :: SBinI b => RAVec b (Pos b)
#
Example1 expression
universe :: RAVec B.Bin2 (Pos B.Bin2)NonEmpty (NE (Cons0 (Last (Node (Leaf 0) (Leaf 1)))))
Example2 expressions
let u = universe :: RAVec B.Bin3 (Pos B.Bin3)uNonEmpty (NE (Cons1 (Leaf 0) (Last (Node (Leaf 1) (Leaf 2)))))
Example1 expression
P.explicitShow $ u ! Pos (PosP (Here WE))"Pos (PosP (Here WE))"
Example1 expression
let u' = universe :: RAVec B.Bin5 (Pos B.Bin5)
Example1 expression
toList u' == sort (toList u')True
valuerepeat :: SBinI b => a -> RAVec b a
#

Repeat a value.

Example1 expression
repeat 'x' :: RAVec B.Bin5 CharNonEmpty (NE (Cons1 (Leaf 'x') (Cons0 (Last (Node (Node (Leaf 'x') (Leaf 'x')) (Node (Leaf 'x') (Leaf 'x')))))))

QuickCheck

2 declarations