shithub: MicroHs

ref: ed1d7d4442a02e2c31fad7f98dc7d4e545b54603
dir: /lib/Data/Identity.hs/

View raw version
module Data.Identity(Data.Identity) where
import Primitives
import Control.Applicative
import Control.Monad
import Data.Function
import Data.Functor
import Data.Int
import Data.Ord
import Text.Show

newtype Identity a = Identity a

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

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

instance Monad Identity where
  Identity a >>= f = f a

instance forall a . (Show a) => Show (Identity a) where
  showsPrec p (Identity a) = showParen (p >= 11) (showString "Identity " . showsPrec 11 a)