joinlist-0.1.0: Join list - symmetric list type

Portabilityto be determined.
Stabilityhighly unstable
MaintainerStephen Tetley <stephen.tetley@gmail.com>

Data.JoinList

Contents

Description

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.

Synopsis

Join list datatype

Elementary construction

empty :: JoinList aSource

Create an empty join list.

wrap :: a -> JoinList aSource

Create a singleton 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 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

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 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.

Conversion between join lists and regular lists

toList :: JoinList a -> [a]Source

Convert a join list to a regular list.

fromList :: [a] -> JoinList aSource

Build a join list from a regular list.