Mercurial > hg > Members > atton > delta_monad
diff agda/deltaM.agda @ 89:5411ce26d525
Defining DeltaM in Agda...
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 19 Jan 2015 11:48:41 +0900 |
parents | |
children | 55d11ce7e223 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agda/deltaM.agda Mon Jan 19 11:48:41 2015 +0900 @@ -0,0 +1,64 @@ +open import Level + +open import delta +open import delta.functor +open import nat +open import laws + +module deltaM where + +-- DeltaM definitions + +data DeltaM {l : Level} + (M : {l' : Level} -> Set l' -> Set l') + {functorM : {l' : Level} -> Functor {l'} M} + {monadM : {l' : Level} {A : Set l'} -> Monad {l'} {A} M functorM} + (A : Set l) + : Set l where + deltaM : Delta (M A) -> DeltaM M {functorM} {monadM} A + + +-- DeltaM utils + +headDeltaM : {l : Level} {A : Set l} + {M : {l' : Level} -> Set l' -> Set l'} + {functorM : {l' : Level} -> Functor {l'} M} + {monadM : {l' : Level} {A : Set l'} -> Monad {l'} {A} M functorM} + -> DeltaM M {functorM} {monadM} A -> M A +headDeltaM (deltaM (mono x)) = x +headDeltaM (deltaM (delta x _)) = x + +tailDeltaM : {l : Level} {A : Set l} + {M : {l' : Level} -> Set l' -> Set l'} + {functorM : {l' : Level} -> Functor {l'} M} + {monadM : {l' : Level} {A : Set l'} -> Monad {l'} {A} M functorM} + -> DeltaM M {functorM} {monadM} A -> DeltaM M {functorM} {monadM} A +tailDeltaM (deltaM (mono x)) = deltaM (mono x) +tailDeltaM (deltaM (delta _ d)) = deltaM d + +appendDeltaM : {l : Level} {A : Set l} + {M : {l' : Level} -> Set l' -> Set l'} + {functorM : {l' : Level} -> Functor {l'} M} + {monadM : {l' : Level} {A : Set l'} -> Monad {l'} {A} M functorM} + -> DeltaM M {functorM} {monadM} A -> DeltaM M {functorM} {monadM} A -> DeltaM M {functorM} {monadM} A +appendDeltaM (deltaM d) (deltaM dd) = deltaM (deltaAppend d dd) + + +checkOut : {l : Level} {A : Set l} + {M : {l' : Level} -> Set l' -> Set l'} + {functorM : {l' : Level} -> Functor {l'} M} + {monadM : {l' : Level} {A : Set l'} -> Monad {l'} {A} M functorM} + -> Nat -> DeltaM M {functorM} {monadM} A -> M A +checkOut O (deltaM (mono x)) = x +checkOut O (deltaM (delta x _)) = x +checkOut (S n) (deltaM (mono x)) = x +checkOut {l} {A} {M} {functorM} {monadM} (S n) (deltaM (delta _ d)) = checkOut {l} {A} {M} {functorM} {monadM} n (deltaM d) + +{- +deltaM-fmap : {l ll : Level} {A : Set l} {B : Set ll} + {M : {l' : Level} -> Set l' -> Set l'} + {functorM : {l' : Level} -> Functor {l'} M} + {monadM : {l' : Level} {A : Set l'} -> Monad {l'} {A} M functorM} + -> (A -> B) -> DeltaM M {functorM} {monadM} A -> DeltaM M {functorM} {monadM} B +deltaM-fmap {l} {ll} {A} {B} {M} {functorM} f (deltaM d) = deltaM (Functor.fmap delta-is-functor (Functor.fmap functorM f) d) +-} \ No newline at end of file