### changeset 27:742e62fc63e4

Define Monad-law 1-4
author Yasutaka Higa Tue, 07 Oct 2014 14:53:56 +0900 5ba82f107a95 6e6d646d7722 agda/similar.agda 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
```--- a/agda/similar.agda	Tue Oct 07 14:43:33 2014 +0900
+++ b/agda/similar.agda	Tue Oct 07 14:53:56 2014 +0900
@@ -1,7 +1,12 @@
open import list
+open import Relation.Binary.PropositionalEquality
+open ≡-Reasoning

module similar where

+id : {A : Set} -> A -> A
+id x = x
+
postulate String : Set
postulate show   : {A : Set} -> A -> String

@@ -16,6 +21,9 @@
mu : {A : Set} -> Similar (Similar A) -> Similar A
mu (similar lx (similar llx x _ _) ly (similar _ _ lly y)) = similar (lx ++ llx) x (ly ++ lly) y

+return : {A : Set} -> A -> Similar A
+return x = similar [] x [] x
+
returnS : {A : Set} -> A -> Similar A
returnS x = similar [[ (show x) ]] x [[ (show x) ]] x

@@ -23,3 +31,21 @@
returnSS x y = similar [[ (show x) ]] x [[ (show y) ]] y

+_∙_ : {A B C : Set} -> (A -> B) -> (B -> C) -> (A -> C)
+f ∙ g = \x -> g (f x)
+
+monad-law-1 : mu ∙ (fmap mu) ≡ mu ∙ mu
+monad-law-1 = {!!}
+
+--monad-law-2 : mu ∙ fmap return ≡ mu ∙ return ≡id
+monad-law-2-1 : mu ∙ fmap return ≡ mu ∙ return
+monad-law-2-1 = {!!}
+
+monad-law-2-2 : mu ∙ return ≡ id
+monad-law-2-2 = {!!}
+
+monad-law-3 : ∀{f} -> return ∙ f ≡ fmap f ∙ return
+monad-law-3 = {!!}
+
+monad-law-4 : ∀{f} -> mu ∙ fmap (fmap f) ≡ fmap f ∙ mu
+monad-law-4 = {!!} ```