Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Nonempty lists.
Synopsis
- data NonemptyList a = (:!) {}
- toList :: NonemptyList a -> [a]
- fromList :: [a] -> Maybe (NonemptyList a)
- consNe :: a -> NonemptyList a -> NonemptyList a
- unionNe :: Eq a => NonemptyList a -> NonemptyList a -> NonemptyList a
- zipWithNe :: (a -> b -> c) -> NonemptyList a -> NonemptyList b -> NonemptyList c
- zipNe :: NonemptyList a -> NonemptyList b -> NonemptyList (a, b)
- caseListNe :: [a] -> b -> (NonemptyList a -> b) -> b
- listCaseNe :: b -> (NonemptyList a -> b) -> [a] -> b
- elemNe :: Eq a => a -> NonemptyList a -> Bool
Documentation
data NonemptyList a Source #
Instances
toList :: NonemptyList a -> [a] Source #
Implementing conversion to list manually, since Foldable.toList
might recurse over the tail and, thus, destroy sharing.
fromList :: [a] -> Maybe (NonemptyList a) Source #
Converting a list (safe).
consNe :: a -> NonemptyList a -> NonemptyList a Source #
Prepending an element.
unionNe :: Eq a => NonemptyList a -> NonemptyList a -> NonemptyList a Source #
Returns the union of the argument lists seen as sets. The order of the elements in the result is not specified. Precondition: arguments contain no duplicates.
zipWithNe :: (a -> b -> c) -> NonemptyList a -> NonemptyList b -> NonemptyList c Source #
Zip two nonempty lists.
zipNe :: NonemptyList a -> NonemptyList b -> NonemptyList (a, b) Source #
Zip two nonempty lists.
caseListNe :: [a] -> b -> (NonemptyList a -> b) -> b Source #
Case on a list, getting a nonempty list in the cons case.
listCaseNe :: b -> (NonemptyList a -> b) -> [a] -> b Source #
Case on a list, with list last.