Portability | to be determined. |
---|---|

Stability | highly unstable |

Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |

A Join List datatype and operations.

Join Lists are symmetric lists where joining two lists (catenation, aka (++)) is a cheap operation. This constrasts with the regular list datatype which is a cons list: while consing on a regular list (building a list by adding an elementary prefix) is by nature cheap, joining (++) is expensive.

- data JoinList a
- empty :: JoinList a
- wrap :: a -> JoinList a
- (++) :: JoinList a -> JoinList a -> JoinList a
- join :: JoinList a -> JoinList a -> JoinList a
- null :: JoinList a -> Bool
- concat :: JoinList (JoinList a) -> JoinList a
- length :: JoinList a -> Int
- map :: (a -> b) -> JoinList a -> JoinList b
- replicate :: Int -> a -> JoinList a
- repeated :: Int -> JoinList a -> JoinList a
- gfold :: b -> (a -> b) -> (b -> b -> b) -> JoinList a -> b
- xzip :: JoinList a -> [b] -> JoinList (a, b)
- xzipWith :: (a -> b -> c) -> JoinList a -> [b] -> JoinList c
- toList :: JoinList a -> [a]
- fromList :: [a] -> JoinList a

# Join list datatype

# Elementary construction

(++) :: JoinList a -> JoinList a -> JoinList aSource

Catenate two join lists. Unlike (++) on regular lists,
catenation on join lists is (relatively) cheap hence the
monicker *join list*.

join :: JoinList a -> JoinList a -> JoinList aSource

An alias for (++) that does not cause a name clash with the Prelude.

# Basic functions

# Building join lists

repeated :: Int -> JoinList a -> JoinList aSource

Repeatedly build a join list by catenating the seed list.

# Generalized fold

gfold :: b -> (a -> b) -> (b -> b -> b) -> JoinList a -> bSource

A Jeremy Gibbons style generalised fold, where each constructor has an operation.

# Zipping

xzip :: JoinList a -> [b] -> JoinList (a, b)Source

*cross zip* - zip a join list against a regular list,
maintaining the shape of the join list provided the lengths
of the lists match.

xzipWith :: (a -> b -> c) -> JoinList a -> [b] -> JoinList cSource

Generalized cross zip - c.f. zipWith on regular lists.