| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Mikan.Utils.List2
Description
Lists of length at least 2.
This module is meant to be imported qualified ala:
import Mikan.Utils.List2 (List2(List2)) import Mikan.Utils.List2 qualified as List2
Synopsis
- data List2 a = List2 a a [a]
- fromList :: IsList l => [Item l] -> l
- toList :: IsList l => l -> [Item l]
- fromList1 :: List1 a -> List2 a
- toList1 :: List2 a -> List1 a
- fromListMaybe :: [a] -> Maybe (List2 a)
- fromList1Maybe :: List1 a -> Maybe (List2 a)
- fromList1Either :: List1 a -> Either a (List2 a)
- toList1Either :: Either a (List2 a) -> List1 a
- cons :: a -> List1 a -> List2 a
- snoc :: List1 a -> a -> List2 a
- append :: List1 a -> List1 a -> List2 a
- appendList :: List2 a -> [a] -> List2 a
- concat21 :: List2 (List1 a) -> List2 a
- head :: List2 a -> a
- tail :: List2 a -> List1 a
- init :: List2 a -> List1 a
- break :: (a -> Bool) -> List2 a -> ([a], [a])
- zip :: List2 a -> List2 b -> List2 (a, b)
- zipWith :: (a -> b -> c) -> List2 a -> List2 b -> List2 c
Documentation
Lists of length 2 or greater.
Constructors
| List2 a a [a] |
Instances
Conversions
fromList :: IsList l => [Item l] -> l #
The fromList function constructs the structure l from the given
list of Item l
toList :: IsList l => l -> [Item l] #
The toList function extracts a list of Item l from the structure l.
It should satisfy fromList . toList = id.
fromList1 :: List1 a -> List2 a Source #
\(\mathcal{O}(1)\). Convert a List1 to a List2.
This function is unsafe, and returns __IMPOSSIBLE__
on lists that have less than two elements.
fromListMaybe :: [a] -> Maybe (List2 a) Source #
\(\mathcal{O}(1)\). Try to convert a list to a List2.
toList1Either :: Either a (List2 a) -> List1 a Source #
\(\mathcal{O}(1)\). Inverse of fromList1Either.
Construction
cons :: a -> List1 a -> List2 a Source #
\(\mathcal{O}(1)\). Cons an element onto the front of a List1.
snoc :: List1 a -> a -> List2 a Source #
\(\mathcal{O}(n)\). Snoc an element onto the end of a List1.