Identity package:base

The identity functor and monad. This trivial type constructor serves two purposes:
  • It can be used with functions parameterized by functor or monad classes.
  • It can be used as a base monad to which a series of monad transformers may be applied to construct a composite monad. Most monad transformer modules include the special case of applying the transformer to Identity. For example, State s is an abbreviation for StateT s Identity.
Identity functor and monad. (a non-strict monad)

Examples

>>> fmap (+1) (Identity 0)
Identity 1
>>> Identity [1, 2, 3] <> Identity [4, 5, 6]
Identity [1,2,3,4,5,6]
>>> do
x <- Identity 10
y <- Identity (x + 5)
pure (x + y)
Identity 25