for example, ReactiveStruct (https://github.com/chgeuer/reactive_struct/blob/main/test/reactive_struct_test.exs) has a nice, concise abstractions:
defmodule KeywordTestStruct do
use ReactiveStruct
defstruct [:a, :b, :sum]
computed(:sum, fn %{a: a, b: b} ->
if a && b, do: a + b, else: nil
end)
end