recursion_schemes v0.1.0 RecStruct protocol

Functions for working with recursive data structures.

Link to this section Summary

Functions

base?/1 is a predicate to test whether a recursively defined data structure is at its base case

empty/1 is a function for obtaining the base value of a recursively defined data structure

unwrap/1 describes how to access the current and remaining pieces of data in a recursively defined structure

wrap/2 is a function for adding a new element to a recursive data structure. To have the dispatch on the protocol happen correctly, the data structure must be the first argument

Link to this section Types

Link to this type t()
t() :: term

Link to this section Functions

Link to this function base?(data_structure)

base?/1 is a predicate to test whether a recursively defined data structure is at its base case.

Link to this function empty(data_structure)

empty/1 is a function for obtaining the base value of a recursively defined data structure.

Link to this function unwrap(data_structure)

unwrap/1 describes how to access the current and remaining pieces of data in a recursively defined structure.

It should return a tuple of {current value, remaining values}

Link to this function wrap(data_structure, datum)

wrap/2 is a function for adding a new element to a recursive data structure. To have the dispatch on the protocol happen correctly, the data structure must be the first argument.