Typeclass that knows how to concatenate a Prefix chain with a Suffix chain to create a Result chain
Introduces the concat
and ++
methods on a chain when there
is an appropriate ChainConcat
instance available.
Typeclass that knows how to prepend a single value in front of a chain.
Introduces the prepend
and ~:
operations on chains when there
is an appropriate ChainPrepend instance available.
ChainConcat implementation that handles concatenation of a longer chain by finding another ChainConcat that can handle all but the last element in that chain, then simply appending the last element to that result.
ChainPrepend implementation that handles prepends to longer chains by delegating to another ChainPrepend that can handle prepends to the chain's head (this process will recurse until the head is a two-item list, at which point it will use the SimpleChainPrepend).
ChainConcat implementation that handles concatenation of a two-item chain by appending the head item, then appending the tail item.
ChainPrepend implementation that handles prepends to a two-item chain by creating a three-item chain.