comparison agda/laws.agda @ 112:0a3b6cb91a05

Prove left-unity-law for DeltaM
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Fri, 30 Jan 2015 21:57:31 +0900
parents a271f3ff1922
children 47f144540d51
comparison
equal deleted inserted replaced
111:9fe3d0bd1149 112:0a3b6cb91a05
2 open import Level 2 open import Level
3 open import basic 3 open import basic
4 4
5 module laws where 5 module laws where
6 6
7 record Functor {l : Level} (F : {l' : Level} -> Set l' -> Set l') : Set (suc l) where 7 record Functor {l : Level} (F : Set l -> Set l) : Set (suc l) where
8 field 8 field
9 fmap : {A B : Set l} -> (A -> B) -> (F A) -> (F B) 9 fmap : {A B : Set l} -> (A -> B) -> (F A) -> (F B)
10 field 10 field
11 preserve-id : {A : Set l} (x : F A) → fmap id x ≡ id x 11 preserve-id : {A : Set l} (x : F A) → fmap id x ≡ id x
12 covariant : {A B C : Set l} (f : A -> B) -> (g : B -> C) -> (x : F A) 12 covariant : {A B C : Set l} (f : A -> B) -> (g : B -> C) -> (x : F A)
13 -> fmap (g ∙ f) x ≡ ((fmap g) ∙ (fmap f)) x 13 -> fmap (g ∙ f) x ≡ ((fmap g) ∙ (fmap f)) x
14 14 field
15 fmap-equiv : {A B : Set l} {f g : A -> B} -> ((x : A) -> f x ≡ g x) -> (x : F A) -> fmap f x ≡ fmap g x
15 open Functor 16 open Functor
16 17
17 record NaturalTransformation {l : Level} (F G : {l' : Level} -> Set l' -> Set l') 18 record NaturalTransformation {l : Level} (F G : {l' : Level} -> Set l' -> Set l')
18 {fmapF : {A B : Set l} -> (A -> B) -> (F A) -> (F B)} 19 {fmapF : {A B : Set l} -> (A -> B) -> (F A) -> (F B)}
19 {fmapG : {A B : Set l} -> (A -> B) -> (G A) -> (G B)} 20 {fmapG : {A B : Set l} -> (A -> B) -> (G A) -> (G B)}
27 28
28 29
29 30
30 31
31 -- simple Monad definition. without NaturalTransformation (mu, eta) and monad-law with f. 32 -- simple Monad definition. without NaturalTransformation (mu, eta) and monad-law with f.
32 record Monad {l : Level} (M : {ll : Level} -> Set ll -> Set ll) 33 record Monad {l : Level} (M : Set l -> Set l)
33 (functorM : Functor {l} M) 34 (functorM : Functor M)
34 : Set (suc l) where 35 : Set (suc l) where
35 field -- category 36 field -- category
36 mu : {A : Set l} -> M (M A) -> M A 37 mu : {A : Set l} -> M (M A) -> M A
37 eta : {A : Set l} -> A -> M A 38 eta : {A : Set l} -> A -> M A
38 field -- haskell 39 field -- haskell