Skip to content

Instantly share code, notes, and snippets.

@ivanperez-keera
Created February 8, 2018 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanperez-keera/d587598879b25f6b6a4307abf5f9f888 to your computer and use it in GitHub Desktop.
Save ivanperez-keera/d587598879b25f6b6a4307abf5f9f888 to your computer and use it in GitHub Desktop.
Isomorphism between MaybeT Identity a and Maybe a in Idris
module IsoMaybe
import Control.Isomorphism
data MaybeT : (m : Type -> Type) -> Type -> Type where
MaybeTC : { m : Type -> Type } -> m (Maybe a) -> MaybeT m a
data Identity : Type -> Type where
IdentityC : a -> Identity a
unIdentity : Identity a -> a
unIdentity (IdentityC a) = a
isoMaybeTIdentityMaybe : Iso (MaybeT Identity a) (Maybe a)
isoMaybeTIdentityMaybe = MkIso to from toFrom fromTo where
to : MaybeT Identity a -> Maybe a
to (MaybeTC x) = unIdentity x
from : Maybe a -> MaybeT Identity a
from m = MaybeTC (IdentityC m)
toFrom : (b : Maybe a) -> to (from b) = b
toFrom b = Refl
fromTo : (b : MaybeT Identity a) -> from (to b) = b
fromTo b = let (MaybeTC (IdentityC y)) = b
in Refl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment