Portability | portable |
---|---|
Maintainer | jmillikin@gmail.com |
A list-like type for lazy sequences, with a user-defined termination value.
This module uses common names and so is designed to be imported qualified:
import qualified Data.CappedList as CL
- data CappedList cap a
- = Next a (CappedList cap a)
- | Cap cap
- toList :: CappedList cap a -> (cap, [a])
- toList_ :: CappedList cap a -> [a]
- fromList :: [a] -> cap -> CappedList cap a
- null :: CappedList cap a -> Bool
- appendR :: CappedList cap1 a -> CappedList cap2 a -> (cap1, CappedList cap2 a)
- appendL :: CappedList cap1 a -> CappedList cap2 a -> (cap2, CappedList cap1 a)
- appendR_ :: CappedList cap1 a -> CappedList cap2 a -> CappedList cap2 a
- appendL_ :: CappedList cap1 a -> CappedList cap2 a -> CappedList cap1 a
- appendWith :: (c -> d -> e) -> CappedList c a -> CappedList d a -> CappedList e a
- map :: (a -> b) -> CappedList cap a -> CappedList cap b
- mapEither :: (a -> Either cap b) -> CappedList cap a -> CappedList cap b
- concatMapM :: Monoid cap => (a -> CappedList cap b) -> CappedList cap a -> CappedList cap b
- foldr :: (a -> b -> b) -> (cap -> b) -> CappedList cap a -> b
- foldl :: (b -> a -> b) -> (cap -> b) -> CappedList cap a -> b
- unfoldr :: (b -> Either cap (a, b)) -> b -> CappedList cap a
- length :: CappedList cap a -> Int
Documentation
data CappedList cap a Source
A list-like type for lazy sequences, with a user-defined termination value.
Next a (CappedList cap a) | |
Cap cap |
Typeable2 CappedList | |
Monoid cap => Monad (CappedList cap) | |
Functor (CappedList cap) | |
Monoid cap => MonadFix (CappedList cap) | |
Monoid cap => MonadPlus (CappedList cap) | |
Monoid cap => Applicative (CappedList cap) | |
Monoid cap => Foldable (CappedList cap) | |
Monoid cap => Traversable (CappedList cap) | |
Monoid cap => Alternative (CappedList cap) | |
(Eq cap, Eq a) => Eq (CappedList cap a) | |
(Data cap, Data a) => Data (CappedList cap a) | |
(Show cap, Show a) => Show (CappedList cap a) | |
Monoid cap => Monoid (CappedList cap a) |
toList :: CappedList cap a -> (cap, [a])Source
Convert a capped list to a standard list.
The cap is returned in the first value of the result tuple.
toList_ :: CappedList cap a -> [a]Source
Convert a capped list to a standard list, discarding the cap.
fromList :: [a] -> cap -> CappedList cap aSource
Convert a standard list and cap to a capped list.
null :: CappedList cap a -> BoolSource
Like the standard null
function.
appendR :: CappedList cap1 a -> CappedList cap2 a -> (cap1, CappedList cap2 a)Source
Like the standard ++
function.
appendL :: CappedList cap1 a -> CappedList cap2 a -> (cap2, CappedList cap1 a)Source
Like the standard ++
function.
appendR_ :: CappedList cap1 a -> CappedList cap2 a -> CappedList cap2 aSource
appendL_ :: CappedList cap1 a -> CappedList cap2 a -> CappedList cap1 aSource
appendWith :: (c -> d -> e) -> CappedList c a -> CappedList d a -> CappedList e aSource
Append two capped lists, merging the caps together using a user-provided function.
map :: (a -> b) -> CappedList cap a -> CappedList cap bSource
Like the standard map
function.
mapEither :: (a -> Either cap b) -> CappedList cap a -> CappedList cap bSource
Like the standard map
function, but the mapping function may
return a capping value.
concatMapM :: Monoid cap => (a -> CappedList cap b) -> CappedList cap a -> CappedList cap bSource
Like the standard concatMap
function.
foldr :: (a -> b -> b) -> (cap -> b) -> CappedList cap a -> bSource
foldl :: (b -> a -> b) -> (cap -> b) -> CappedList cap a -> bSource
unfoldr :: (b -> Either cap (a, b)) -> b -> CappedList cap aSource
Like the standard Data.List.unfoldr
function, but the step function
must return a cap to terminate the unfold.