HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebasement-0.0.16Haskell2010

Basement.Sized.List

A Nat-sized list abstraction

Using this module is limited to GHC 7.10 and above.

  • 1 type
  • 50 values
  • Packagebasement-0.0.16
  • Exports51
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceList.hs
newtypenewtype ListN (n :: Nat) a
#

A Typed-level sized List equivalent to [a]

Instances6Eq, Ord, Show, Generic, NormalForm, Rep
valuetoListN_
  1. :: (HasCallStack, NatWithinBound Int n, KnownNat n)
  2. => [a]
  3. -> ListN n a
#

Create a ListN from a List, expecting a given length

If this list contains more or less than the expected length of the resulting type, then an asynchronous error is raised. use toListN for a more friendly functions

valueuncons :: 1 <= n => ListN n a -> (a, ListN (n - 1) a)
#

Decompose a list into its head and tail.

valuecons :: a -> ListN n a -> ListN (n + 1) a
#

prepend an element to the list

valueunsnoc :: 1 <= n => ListN n a -> (ListN (n - 1) a, a)
#

Decompose a list into its first elements and the last.

valuesnoc :: ListN n a -> a -> ListN (n + 1) a
#

append an element to the list

valuemap :: (a -> b) -> ListN n a -> ListN n b
#

Map all elements in a list

valuemapi :: (Natural -> a -> b) -> ListN n a -> ListN n b
#

Map all elements in a list with an additional index

valueelem :: Eq a => a -> ListN n a -> Bool
#

Check if a list contains the element a

valuefoldl :: (b -> a -> b) -> b -> ListN n a -> b
#

Fold all elements from left

valuefoldl' :: (b -> a -> b) -> b -> ListN n a -> b
#

Fold all elements from left strictly

valuefoldl1' :: 1 <= n => (a -> a -> a) -> ListN n a -> a
#

Fold all elements from left strictly with a first element as the accumulator

valuescanl' :: (b -> a -> b) -> b -> ListN n a -> ListN (n + 1) b
#

scanl is similar to foldl, but returns a list of successive reduced values from the left

scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
valuescanl1' :: (a -> a -> a) -> ListN n a -> ListN n a
#

scanl1 is a variant of scanl that has no starting value argument:

scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
valuefoldr :: (a -> b -> b) -> b -> ListN n a -> b
#

Fold all elements from right

valuefoldr1 :: 1 <= n => (a -> a -> a) -> ListN n a -> a
#

Fold all elements from right assuming at least one element is in the list.

valuehead :: 1 <= n => ListN n a -> a
#

Get the head element of a list

valueinit :: 1 <= n => ListN n a -> ListN (n - 1) a
#

Get the list with the last element missing

valuezip :: ListN n a -> ListN n b -> ListN n (a, b)
#

Zip 2 lists of the same size, returning a new list of the tuple of each elements

valueunzip :: ListN n (a, b) -> (ListN n a, ListN n b)
#

Unzip a list of tuple, to 2 List of the deconstructed tuples

Applicative And Monadic

5 declarations
valuesequence :: Monad m => ListN n (m a) -> m (ListN n a)
#

Evaluate each monadic action in the list sequentially, and collect the results.

valuesequence_ :: Monad m => ListN n (m a) -> m ()
#

Evaluate each monadic action in the list sequentially, and ignore the results.

valuemapM :: Monad m => (a -> m b) -> ListN n a -> m (ListN n b)
#

Map each element of a List to a monadic action, evaluate these actions sequentially and collect the results

valuemapM_ :: Monad m => (a -> m b) -> ListN n a -> m ()
#

Map each element of a List to a monadic action, evaluate these actions sequentially and ignore the results