fun_land v0.9.0 FunLand.Builtin.Map

Maps are Mappable, because we can map over {k, v}-tuples to create new values. ( Note that different from the Map implementation of Enum.map, the result should be a new value, and not a new {key, value}-tuple. There is no way to alter the key while mapping over a Map, as the key is part of the structure, rather than its contents! )

Maps are however not Appliable, (TODO: Explanation)

Maps are not Applicative, as there is no way to put ‘a value’ inside a map (we don’t know what key to associate it with) so we cannot define an implementation of new/1.


Maps are SemiCombinable, as we can take two key-value groups, and combine them (with duplicates being overridden by the values in the latter). Maps are also Combinable, as it is also possible to create a empty element: an empty map.

Link to this section Summary

Functions

Callback implementation for FunLand.Combinable.empty/0

A variant of reduce that accepts anything that is Combinable as second argument. This Combinable will determine what the empty value and the combining operation will be

Converts the reducable into a list, by building up a list from all elements, and in the end reversing it

Link to this section Functions

Link to this function combine(map_a, map_b)

Callback implementation for FunLand.Semicombinable.combine/2.

Callback implementation for FunLand.Combinable.empty/0.

Link to this function map(map, function)
Link to this function reduce(a, combinable)

A variant of reduce that accepts anything that is Combinable as second argument. This Combinable will determine what the empty value and the combining operation will be.

Pass in the combinable module name to start with empty as accumulator, or the combinable as struct to use that as starting accumulator.

Link to this function reduce(map, initial, folding_function)

Callback implementation for FunLand.Reducable.reduce/3.

Link to this function to_list(reducable)

Converts the reducable into a list, by building up a list from all elements, and in the end reversing it.

This is an automatic function implementation, made possible because FunLand.Builtin.Map implements the FunLand.Reducable behaviour.