dlist-0.3: Differences listsSource codeContentsIndex
Data.DList
Portabilityportable (Haskell 98)
Stabilityexperimental
Maintainerdons@cse.unsw.edu.au
Contents
Construction
Basic functions
MonadPlus
Description
Difference lists: a data structure for O(1) append on lists.
Synopsis
data DList a
fromList :: [a] -> DList a
toList :: DList a -> [a]
empty :: DList a
singleton :: a -> DList a
cons :: a -> DList a -> DList a
snoc :: DList a -> a -> DList a
append :: DList a -> DList a -> DList a
concat :: [DList a] -> DList a
list :: b -> (a -> DList a -> b) -> DList a -> b
head :: DList a -> a
tail :: DList a -> DList a
unfoldr :: (b -> Maybe (a, b)) -> b -> DList a
foldr :: (a -> b -> b) -> b -> DList a -> b
map :: (a -> b) -> DList a -> DList b
maybeReturn :: MonadPlus m => Maybe a -> m a
Documentation
data DList a Source

A difference list is a function that given a list, returns the original contents of the difference list prepended at the given list

This structure supports O(1) append and snoc operations on lists.

show/hide Instances
Construction
fromList :: [a] -> DList aSource
Converting a normal list to a dlist
toList :: DList a -> [a]Source
Converting a dlist back to a normal list
Basic functions
empty :: DList aSource
Create a difference list containing no elements
singleton :: a -> DList aSource
Create difference list with given single element
cons :: a -> DList a -> DList aSource
O(1), Prepend a single element to a difference list
snoc :: DList a -> a -> DList aSource
O(1), Append a single element at a difference list
append :: DList a -> DList a -> DList aSource
O(1), Appending difference lists
concat :: [DList a] -> DList aSource
O(spine), Concatenate difference lists
list :: b -> (a -> DList a -> b) -> DList a -> bSource
O(length dl), List elimination, head, tail.
head :: DList a -> aSource
Return the head of the list
tail :: DList a -> DList aSource
Return the tail of the list
unfoldr :: (b -> Maybe (a, b)) -> b -> DList aSource
Unfoldr for difference lists
foldr :: (a -> b -> b) -> b -> DList a -> bSource
Foldr over difference lists
map :: (a -> b) -> DList a -> DList bSource
Map over difference lists.
MonadPlus
maybeReturn :: MonadPlus m => Maybe a -> m aSource
Produced by Haddock version 2.1.0