Copyright | (c) Alexandre Moine 2019 |
---|---|
Maintainer | alexandre@moine.me |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Tungsten.Structure.List
Description
This module defines a type isomorphic to linked lists, in terms of Fix
from
Tungsten.Fix.
A good consumer is a function that can be fused with a good producer. A good producer is a function that can be fused with a good consumer.
Synopsis
- data ListF a b
- newtype List a = List (Fix (ListF a))
- nil :: List a
- cons :: a -> List a -> List a
- foldr :: (a -> b -> b) -> b -> List a -> b
- map :: (a -> b) -> List a -> List b
- append :: List a -> List a -> List a
- elem :: Eq a => a -> List a -> Bool
- range :: Int -> Int -> List Int
- toList :: List a -> [a]
- fromList :: [a] -> List a
Lists as fixed-points
The factored-out recursive type for lists.
Instances
Eq2 ListF Source # | |
Ord2 ListF Source # | |
Defined in Tungsten.Structure.List | |
Show2 ListF Source # | |
Functor (ListF a) Source # | |
Eq a => Eq1 (ListF a) Source # | |
Ord a => Ord1 (ListF a) Source # | |
Defined in Tungsten.Structure.List | |
Show a => Show1 (ListF a) Source # | |
(Eq a, Eq b) => Eq (ListF a b) Source # | |
(Ord a, Ord b) => Ord (ListF a b) Source # | |
(Read a, Read b) => Read (ListF a b) Source # | |
(Show a, Show b) => Show (ListF a b) Source # | |
Linked lists as a fixed-point.
cons :: a -> List a -> List a Source #
The cons operator. Similar to 'Prelude.(:)' for Prelude lists.
Classical operations on lists
append :: List a -> List a -> List a Source #
Append two lists. Good consumers of both arguments and producer.
Operations on lists
range :: Int -> Int -> List Int Source #
range start end
will produce a list containing int
in ascending order from start
(inclusive) to end
(exclusive).
Good producer.