module Data.Functor.Identity (Identity (..)) where import "morphisms" Control.Morphism ((.), ($)) import Control.Functor.Covariant.Extractable (Extractable (extract)) import Control.Functor.Covariant.Pointable (Pointable (point)) import Control.Functor.Covariant (Covariant ((<$>), comap)) import Control.Functor.Covariant.Applicative (Applicative ((<*>))) import Control.Functor.Covariant.Composition.Traversable (Traversable ((->>))) import Control.Functor.Covariant.Composition.Distributive (Distributive ((>>-))) import Control.Functor.Covariant.Composition.Bindable (Bindable ((>>=))) import Control.Functor.Covariant.Composition.Extendable (Extendable ((=>>))) import Control.Functor.Covariant.Composition.Adjoint (Adjoint (phi, psi)) newtype Identity a = Identity a instance Covariant Identity where f <$> Identity x = Identity $ f x instance Applicative Identity where Identity f <*> Identity x = Identity $ f x instance Pointable Identity where point = Identity instance Extractable Identity where extract (Identity x) = x instance Traversable Identity where Identity x ->> f = Identity <$> f x instance Distributive Identity where x >>- f = Identity $ extract . f <$> x instance Bindable Identity where Identity x >>= f = f x instance Extendable Identity where x =>> f = Identity . f $ x instance Adjoint Identity Identity where phi f = Identity . f . Identity psi f = extract . extract . comap f