on 413edee help sign in
Idris-dev/lib/Control/Monad/Identity.idr
19 lines 400 B history raw
1module Control.Monad.Identity
3import Prelude.Functor
4import Prelude.Applicative
5import Prelude.Monad
7public record Identity : Type -> Type where
8 Id : (runIdentity : a) -> Identity a
10instance Functor Identity where
11 fmap fn (Id a) = Id (fn a)
13instance Applicative Identity where
14 pure x = Id x
16 (Id f) <$> (Id g) = Id (f g)
18instance Monad Identity where
19 (Id x) >>= k = k x