croma v0.10.2 Croma.Monad View Source

This module defines an interface for monad.

Modules that use this module must provide concrete implementations of the following:

  • @type t(a)
  • @spec pure(a) :: t(a) when a: any
  • @spec bind(t(a), (a -> t(b))) :: t(b) when a: any, b: any

Note that the order of parameters in map/ap is different from that of Haskell counterparts, in order to leverage Elixir’s pipe operator |>. Using concrete implementations of the above interfaces, this module generates default implementations of some functions/macros. See Croma.Result for the generated functions/macros.

Croma.Monad also provides bind-less syntax similar to Haskell’s do-notation with m/1 macro.