joinlist-0.2.0: Join list - symmetric list type

Portabilityto be determined.
Stabilityhighly unstable
MaintainerStephen Tetley <>




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.


Join list datatype, opaque.

Conversion between join lists and regular lists

fromList :: [a] -> JoinList aSource

Build a join list from a regular list.

toList :: JoinList a -> [a]Source

Convert a join list to a regular list.


empty :: JoinList aSource

Create an empty join list.

singleton :: a -> JoinList aSource

Create a singleton join list.

cons :: a -> JoinList a -> JoinList aSource

Cons an element to the front of the join list.

snoc :: JoinList a -> a -> JoinList aSource

Snoc an element to the tail of the join list.

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

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

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

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

Basic functions

null :: JoinList a -> BoolSource

Test whether a join list is empty.

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

Concatenate a (join) list of (join) lists.

length :: JoinList a -> IntSource

Get the length of a join list.

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

Map a function over a join list.

Building join lists

replicate :: Int -> a -> JoinList aSource

Build a join list of n elements.

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 generalized fold, where each constructor has an operation.

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

Right-associative fold of a JoinList.

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

Left-associative fold of a JoinList.

unfoldl :: (b -> Maybe (a, b)) -> b -> JoinList aSource

unfoldl is permitted due to cheap snoc-ing.

unfoldr :: (b -> Maybe (a, b)) -> b -> JoinList aSource

unfoldr - the usual unfoldr opertation.


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.