basement-0.0.4: Foundation scrap box of array & string

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Basement.Sized.List

Contents

- Applicative And Monadic

Description

A Nat-sized list abstraction

Using this module is limited to GHC 7.10 and above.

Synopsis

- data ListN n a
- toListN :: forall n a. (KnownNat n, NatWithinBound Int n) => [a] -> Maybe (ListN n a)
- unListN :: ListN n a -> [a]
- length :: forall a n. (KnownNat n, NatWithinBound Int n) => ListN n a -> Int
- create :: forall a n. KnownNat n => (Integer -> a) -> ListN n a
- createFrom :: forall a n start. (KnownNat n, KnownNat start) => Proxy start -> (Integer -> a) -> ListN n a
- empty :: ListN 0 a
- singleton :: a -> ListN 1 a
- uncons :: CmpNat n 0 ~ GT => ListN n a -> (a, ListN (n - 1) a)
- cons :: a -> ListN n a -> ListN (n + 1) a
- index :: ListN n ty -> Offset ty -> ty
- indexStatic :: forall i n a. (KnownNat i, CmpNat i n ~ LT, Offsetable a i) => ListN n a -> a
- map :: (a -> b) -> ListN n a -> ListN n b
- elem :: Eq a => a -> ListN n a -> Bool
- foldl :: (b -> a -> b) -> b -> ListN n a -> b
- foldl' :: (b -> a -> b) -> b -> ListN n a -> b
- foldr :: (a -> b -> b) -> b -> ListN n a -> b
- append :: ListN n a -> ListN m a -> ListN (n + m) a
- minimum :: (Ord a, CmpNat n 0 ~ GT) => ListN n a -> a
- maximum :: (Ord a, CmpNat n 0 ~ GT) => ListN n a -> a
- head :: CmpNat n 0 ~ GT => ListN n a -> a
- tail :: CmpNat n 0 ~ GT => ListN n a -> ListN (n - 1) a
- take :: forall a m n. (KnownNat m, NatWithinBound Int m, m <= n) => ListN n a -> ListN m a
- drop :: forall a d m n. (KnownNat d, NatWithinBound Int d, (n - m) ~ d, m <= n) => ListN n a -> ListN m a
- splitAt :: forall a d m n. (KnownNat d, NatWithinBound Int d, (n - m) ~ d, m <= n) => ListN n a -> (ListN m a, ListN (n - m) a)
- zip :: ListN n a -> ListN n b -> ListN n (a, b)
- zip3 :: ListN n a -> ListN n b -> ListN n c -> ListN n (a, b, c)
- zip4 :: ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n (a, b, c, d)
- zip5 :: ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n e -> ListN n (a, b, c, d, e)
- zipWith :: (a -> b -> x) -> ListN n a -> ListN n b -> ListN n x
- zipWith3 :: (a -> b -> c -> x) -> ListN n a -> ListN n b -> ListN n c -> ListN n x
- zipWith4 :: (a -> b -> c -> d -> x) -> ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n x
- zipWith5 :: (a -> b -> c -> d -> e -> x) -> ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n e -> ListN n x
- replicate :: forall n a. (NatWithinBound Int n, KnownNat n) => a -> ListN n a
- replicateM :: forall n m a. (NatWithinBound Int n, Monad m, KnownNat n) => m a -> m (ListN n a)
- mapM :: Monad m => (a -> m b) -> ListN n a -> m (ListN n b)
- mapM_ :: Monad m => (a -> m b) -> ListN n a -> m ()

# Documentation

data ListN n a Source #

Instances

Eq a => Eq (ListN n a) Source # |
Methods (==) :: ListN n a -> ListN n a -> Bool # (/=) :: ListN n a -> ListN n a -> Bool #
Ord a => Ord (ListN n a) Source # |
Methods compare :: ListN n a -> ListN n a -> Ordering # (<) :: ListN n a -> ListN n a -> Bool # (<=) :: ListN n a -> ListN n a -> Bool # (>) :: ListN n a -> ListN n a -> Bool # (>=) :: ListN n a -> ListN n a -> Bool # max :: ListN n a -> ListN n a -> ListN n a # min :: ListN n a -> ListN n a -> ListN n a #
Show a => Show (ListN n a) Source # |
Methods showsPrec :: Int -> ListN n a -> ShowS # show :: ListN n a -> String # showList :: [ListN n a] -> ShowS #
NormalForm a => NormalForm (ListN n a) Source # |
Methods toNormalForm :: ListN n a -> () Source #

toListN :: forall n a. (KnownNat n, NatWithinBound Int n) => [a] -> Maybe (ListN n a) Source #

unListN :: ListN n a -> [a] Source #

length :: forall a n. (KnownNat n, NatWithinBound Int n) => ListN n a -> Int Source #

create :: forall a n. KnownNat n => (Integer -> a) -> ListN n a Source #

createFrom :: forall a n start. (KnownNat n, KnownNat start) => Proxy start -> (Integer -> a) -> ListN n a Source #

empty :: ListN 0 a Source #

singleton :: a -> ListN 1 a Source #

uncons :: CmpNat n 0 ~ GT => ListN n a -> (a, ListN (n - 1) a) Source #

cons :: a -> ListN n a -> ListN (n + 1) a Source #

index :: ListN n ty -> Offset ty -> ty Source #

indexStatic :: forall i n a. (KnownNat i, CmpNat i n ~ LT, Offsetable a i) => ListN n a -> a Source #

map :: (a -> b) -> ListN n a -> ListN n b Source #

elem :: Eq a => a -> ListN n a -> Bool Source #

foldl :: (b -> a -> b) -> b -> ListN n a -> b Source #

foldl' :: (b -> a -> b) -> b -> ListN n a -> b Source #

foldr :: (a -> b -> b) -> b -> ListN n a -> b Source #

append :: ListN n a -> ListN m a -> ListN (n + m) a Source #

minimum :: (Ord a, CmpNat n 0 ~ GT) => ListN n a -> a Source #

maximum :: (Ord a, CmpNat n 0 ~ GT) => ListN n a -> a Source #

head :: CmpNat n 0 ~ GT => ListN n a -> a Source #

tail :: CmpNat n 0 ~ GT => ListN n a -> ListN (n - 1) a Source #

take :: forall a m n. (KnownNat m, NatWithinBound Int m, m <= n) => ListN n a -> ListN m a Source #

drop :: forall a d m n. (KnownNat d, NatWithinBound Int d, (n - m) ~ d, m <= n) => ListN n a -> ListN m a Source #

splitAt :: forall a d m n. (KnownNat d, NatWithinBound Int d, (n - m) ~ d, m <= n) => ListN n a -> (ListN m a, ListN (n - m) a) Source #

zip :: ListN n a -> ListN n b -> ListN n (a, b) Source #

zip3 :: ListN n a -> ListN n b -> ListN n c -> ListN n (a, b, c) Source #

zip4 :: ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n (a, b, c, d) Source #

zip5 :: ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n e -> ListN n (a, b, c, d, e) Source #

zipWith :: (a -> b -> x) -> ListN n a -> ListN n b -> ListN n x Source #

zipWith3 :: (a -> b -> c -> x) -> ListN n a -> ListN n b -> ListN n c -> ListN n x Source #

zipWith4 :: (a -> b -> c -> d -> x) -> ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n x Source #

zipWith5 :: (a -> b -> c -> d -> e -> x) -> ListN n a -> ListN n b -> ListN n c -> ListN n d -> ListN n e -> ListN n x Source #

replicate :: forall n a. (NatWithinBound Int n, KnownNat n) => a -> ListN n a Source #

# Applicative And Monadic

replicateM :: forall n m a. (NatWithinBound Int n, Monad m, KnownNat n) => m a -> m (ListN n a) Source #

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

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