Alltid (alltid v0.1.0)

Alltid offers a simplified approach to editing deeply nested immutable data structures in Elixir. Inspired by Immer.js in JavaScript, Alltid allows a natural declarative syntax for manipulating deeply nested immutible data structures.

Link to this section Summary

Functions

Produce an update to value using the provided fun, a function of arity 1.

Link to this section Functions

Link to this macro

produce(value, fun)

(macro)
@spec produce(any(), {:fn, list(), list()}) :: any()

Produce an update to value using the provided fun, a function of arity 1.

Within the provided function, the <- operator can be used to simulate assignment of nested values within the provided argument:

iex> Alltid.produce(%{counter: 10}, fn draft ->
...> draft[:counter] <- draft[:counter] + 1
...> draft[:value] <- "some value"
...> end)

%{counter: 11, value: "some value"}

Returns a copy of value with the changes from fun applied.