fun_land v0.8.0 FunLand.Reducable behaviour

Anything that implements the Reducable behaviour, can be reduced to a single value, when given a combinable (or combining-function + base value).

This is enough information to convert any reducable to a List. It even is enough information to implement most enumerable methods.

However, what is not possible, is to stop halfway through the reduction. Therefore, Reducable is a lot simpler than the Enumerable protocol.

For convenience, though, a very basic implementation of the Enumerable protocol is automatically added when you use Reducable. This implementation first converts your Reducable to a list, and then enumerates on that.

This is very convenient, but it does mean that your whole reducable is first converted to a list. This will therefore always be slower than a full-blown custom implementation that is specific for your structure.

If you want to implement your own version of Enumerable, add Reducable with use FunLand.Reducable, auto_enumerable: false.

Link to this section Summary

Link to this section Types

Link to this type reducable(_)
reducable(_) :: FunLand.adt

Link to this section Functions

Link to this macro is_success_tuple(datatype) (macro)
Link to this function reduce(a, combinable)
Link to this function reduce(reducable, acc, fun)

Link to this section Callbacks

Link to this callback reduce(reducable, acc, function)
reduce(reducable(a), acc, (a, acc -> acc)) :: acc when a: any, acc: any