Packages

An exploratory look into functors, applicatives, and monads for Elixir.

Current section

Files

Jump to
control lib data maybe.ex
Raw

lib/data/maybe.ex

defmodule Data.Maybe do
@type t :: %__MODULE__{
just: term,
nothing: boolean
}
defstruct just: nil,
nothing: false
def just(v), do: __MODULE__ |> struct(just: v)
def nothing, do: __MODULE__ |> struct(nothing: true)
end