A representation of lists with an efficient append operation.
This is particularly useful for efficient logging and pretty printing, where
repeatedly appending lists quickly becomes too expensive. Internally, DList
is a function that prepends elements to its parameter. Thus the append
operation is just function composition. Ultimately, a DList is converted to a
regular List by applying the function to the empty list.
Some limitations of the DList representation are:
We cannot ask for the length of a DList without converting it to a
regular list.
We cannot test equality on two DList structures without converting them
to regular lists.
Convert to a regular Elm List by applying the underlying function
representation.
The empty list.
Construct a list containing one element.
Prepend an element onto the front of the list.
Add an element onto the back of the list. O(1) just like append.
Concatenate two lists.
An operator for append.
Convert a regular Elm List to a difference list.
Concatenate a list of difference lists.
Iterate through a DList.
Intersperse the contents of a DList between other lists.
Apply a function to each element, accumulating the results as a DList.
A difference list containing elements of type
a.