CurryInfo: base-3.4.0 / Data.Functor.Identity

classes: Info
 
documentation: Info
 
--------------------------------------------------------------------------
This simple module defines the identify functor and monad and
has been adapted from the same Haskell module (by Andy Gill).
It defines a a trivial type constructor `Identity` which
can be used with functions parameterized by functor or monad classes
or as a simple base to specialize monad transformers.
--------------------------------------------------------------------------
name: Info
 Data.Functor.Identity
operations: Info
 
sourcecode: Info
 

module Data.Functor.Identity where

--- The `Identity` type constructor with `Functor`, `Applicative`,
--- and `Monad` instances.
newtype Identity a = Identity { runIdentity :: a }
  deriving (Eq, Ord, Read, Show)

instance Functor Identity where
  fmap f (Identity a) = Identity $ f a

instance Applicative Identity where
  pure = Identity
  Identity f <*> Identity a = Identity (f a)

instance Monad Identity where
  m >>= k = k (runIdentity m)
  return a = Identity a
types: Info
 Identity
unsafe: Info
 safe