Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Description : Wrapper around Data.Sequence with type level length annotation.
Synopsis
- data LSeq (n :: Nat) a
- toSeq :: LSeq n a -> Seq a
- empty :: LSeq 0 a
- fromList :: Foldable f => f a -> LSeq 0 a
- fromNonEmpty :: NonEmpty a -> LSeq 1 a
- fromSeq :: Seq a -> LSeq 0 a
- toNonEmpty :: LSeq (1 + n) a -> NonEmpty a
- (<|) :: a -> LSeq n a -> LSeq (1 + n) a
- (|>) :: LSeq n a -> a -> LSeq (1 + n) a
- (><) :: LSeq n a -> LSeq m a -> LSeq (n + m) a
- eval :: forall proxy n m a. KnownNat n => proxy n -> LSeq m a -> Maybe (LSeq n a)
- index :: LSeq n a -> Int -> a
- adjust :: (a -> a) -> Int -> LSeq n a -> LSeq n a
- partition :: (a -> Bool) -> LSeq n a -> (LSeq 0 a, LSeq 0 a)
- mapWithIndex :: (Int -> a -> b) -> LSeq n a -> LSeq n b
- take :: Int -> LSeq n a -> LSeq 0 a
- drop :: Int -> LSeq n a -> LSeq 0 a
- unstableSort :: Ord a => LSeq n a -> LSeq n a
- unstableSortBy :: (a -> a -> Ordering) -> LSeq n a -> LSeq n a
- head :: LSeq (1 + n) a -> a
- last :: LSeq (1 + n) a -> a
- append :: LSeq n a -> LSeq m a -> LSeq (n + m) a
- data ViewL n a where
- viewl :: LSeq (1 + n) a -> ViewL (1 + n) a
- pattern (:<|) :: a -> LSeq n a -> LSeq (1 + n) a
- pattern (:<<) :: a -> LSeq 0 a -> LSeq n a
- pattern EmptyL :: LSeq n a
- data ViewR n a where
- viewr :: LSeq (1 + n) a -> ViewR (1 + n) a
- pattern (:|>) :: forall n a. LSeq n a -> a -> LSeq (1 + n) a
- promise :: LSeq m a -> LSeq n a
- forceLSeq :: KnownNat n => proxy n -> LSeq m a -> LSeq n a
Documentation
data LSeq (n :: Nat) a Source #
LSeq n a certifies that the sequence has *at least* n items
Instances
Functor (LSeq n) Source # | |
Foldable (LSeq n) Source # | |
Defined in Data.LSeq fold :: Monoid m => LSeq n m -> m # foldMap :: Monoid m => (a -> m) -> LSeq n a -> m # foldr :: (a -> b -> b) -> b -> LSeq n a -> b # foldr' :: (a -> b -> b) -> b -> LSeq n a -> b # foldl :: (b -> a -> b) -> b -> LSeq n a -> b # foldl' :: (b -> a -> b) -> b -> LSeq n a -> b # foldr1 :: (a -> a -> a) -> LSeq n a -> a # foldl1 :: (a -> a -> a) -> LSeq n a -> a # elem :: Eq a => a -> LSeq n a -> Bool # maximum :: Ord a => LSeq n a -> a # minimum :: Ord a => LSeq n a -> a # | |
Traversable (LSeq n) Source # | |
Eq a => Eq (LSeq n a) Source # | |
Ord a => Ord (LSeq n a) Source # | |
Read a => Read (LSeq n a) Source # | |
Show a => Show (LSeq n a) Source # | |
Generic (LSeq n a) Source # | |
Semigroup (LSeq n a) Source # | |
Monoid (LSeq 0 a) Source # | |
(KnownNat n, Arbitrary a) => Arbitrary (LSeq n a) Source # | |
NFData a => NFData (LSeq n a) Source # | |
Ixed (LSeq n a) Source # | |
type Rep (LSeq n a) Source # | |
type Index (LSeq n a) Source # | |
type IxValue (LSeq n a) Source # | |
fromNonEmpty :: NonEmpty a -> LSeq 1 a Source #
index :: LSeq n a -> Int -> a Source #
get the element with index i, counting from the left and starting at 0. O(log(min(i,n-i)))
head :: LSeq (1 + n) a -> a Source #
Gets the first element of the LSeq
>>>
head $ forceLSeq (Proxy :: Proxy 3) $ fromList [1,2,3]
1
last :: LSeq (1 + n) a -> a Source #
Get the last element of the LSeq
>>>
last $ forceLSeq (Proxy :: Proxy 3) $ fromList [1,2,3]
3
Instances
Functor (ViewL n) Source # | |
Foldable (ViewL n) Source # | |
Defined in Data.LSeq fold :: Monoid m => ViewL n m -> m # foldMap :: Monoid m => (a -> m) -> ViewL n a -> m # foldr :: (a -> b -> b) -> b -> ViewL n a -> b # foldr' :: (a -> b -> b) -> b -> ViewL n a -> b # foldl :: (b -> a -> b) -> b -> ViewL n a -> b # foldl' :: (b -> a -> b) -> b -> ViewL n a -> b # foldr1 :: (a -> a -> a) -> ViewL n a -> a # foldl1 :: (a -> a -> a) -> ViewL n a -> a # elem :: Eq a => a -> ViewL n a -> Bool # maximum :: Ord a => ViewL n a -> a # minimum :: Ord a => ViewL n a -> a # | |
Traversable (ViewL n) Source # | |
Eq a => Eq (ViewL n a) Source # | |
Ord a => Ord (ViewL n a) Source # | |
Defined in Data.LSeq | |
Show a => Show (ViewL n a) Source # | |
Semigroup (ViewL n a) Source # | |
Instances
Functor (ViewR n) Source # | |
Foldable (ViewR n) Source # | |
Defined in Data.LSeq fold :: Monoid m => ViewR n m -> m # foldMap :: Monoid m => (a -> m) -> ViewR n a -> m # foldr :: (a -> b -> b) -> b -> ViewR n a -> b # foldr' :: (a -> b -> b) -> b -> ViewR n a -> b # foldl :: (b -> a -> b) -> b -> ViewR n a -> b # foldl' :: (b -> a -> b) -> b -> ViewR n a -> b # foldr1 :: (a -> a -> a) -> ViewR n a -> a # foldl1 :: (a -> a -> a) -> ViewR n a -> a # elem :: Eq a => a -> ViewR n a -> Bool # maximum :: Ord a => ViewR n a -> a # minimum :: Ord a => ViewR n a -> a # | |
Traversable (ViewR n) Source # | |
Eq a => Eq (ViewR n a) Source # | |
Ord a => Ord (ViewR n a) Source # | |
Defined in Data.LSeq | |
Show a => Show (ViewR n a) Source # | |
Semigroup (ViewR n a) Source # | |