Created
February 8, 2018 01:26
-
-
Save ivanperez-keera/d587598879b25f6b6a4307abf5f9f888 to your computer and use it in GitHub Desktop.
Isomorphism between MaybeT Identity a and Maybe a in Idris
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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