fun_land v0.7.3 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 Reducable, auto_enumerable: false.

Summary

Types

Functions

reduce(a, combinable)
reduce(reducable, acc, fun)

Callbacks

reduce(reducable, acc, list)

Specs

reduce(reducable(a), acc, (a, acc -> acc)) :: acc when a: any, acc: any