Packages

Bootstrapped algebraic data types for Elixir, forked by doma for maintenance and testing packagesets

Current section

Files

Jump to
doma_algae lib algae tree binary_search functor.ex
Raw

lib/algae/tree/binary_search/functor.ex

alias Algae.Tree.BinarySearch.{Empty, Node}
alias Witchcraft.Functor
import TypeClass
definst Witchcraft.Functor, for: Algae.Tree.BinarySearch.Empty do
def map(_, _), do: %Empty{}
end
definst Witchcraft.Functor, for: Algae.Tree.BinarySearch.Node do
def map(%Node{node: node, left: left, right: right}, fun) do
%Node{
node: fun.(node),
left: Functor.map(left, fun),
right: Functor.map(right, fun)
}
end
end