### changeset 29:e0ba1bf564dd

Apply level to some functions
author Yasutaka Higa Tue, 07 Oct 2014 15:09:17 +0900 6e6d646d7722 c2f40b6d4027 agda/basic.agda agda/similar.agda 2 files changed, 28 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
```--- a/agda/basic.agda	Tue Oct 07 14:55:40 2014 +0900
+++ b/agda/basic.agda	Tue Oct 07 15:09:17 2014 +0900
@@ -1,10 +1,12 @@
+open import Level
+
module basic where

-id : {A : Set} -> A -> A
+id : {l : Level} {A : Set} -> A -> A
id x = x

-_∙_ : {A B C : Set} -> (A -> B) -> (B -> C) -> (A -> C)
-f ∙ g = \x -> g (f x)
+_∙_ : {l ll lll : Level} {A : Set l} {B : Set ll} {C : Set lll} -> (B -> C) -> (A -> B) -> (A -> C)
+f ∙ g = \x -> f (g x)

postulate String : Set
postulate show   : {A : Set} -> A -> String
\ No newline at end of file```
```--- a/agda/similar.agda	Tue Oct 07 14:55:40 2014 +0900
+++ b/agda/similar.agda	Tue Oct 07 15:09:17 2014 +0900
@@ -1,17 +1,19 @@
open import list
open import basic
+
+open import Level
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning

module similar where

-data Similar (A : Set) : Set where
+data Similar {l : Level} (A : Set l) : (Set (suc l)) where
similar : List String -> A -> List String -> A -> Similar A

-fmap : {A B : Set} -> (A -> B) -> (Similar A) -> (Similar B)
+fmap : {l ll : Level} {A : Set l} {B : Set ll} -> (A -> B) -> (Similar A) -> (Similar B)
fmap f (similar xs x ys y) = similar xs (f x) ys (f y)

-mu : {A : Set} -> Similar (Similar A) -> Similar A
+mu : {l : Level} {A : Set l} -> 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
@@ -23,10 +25,23 @@
returnSS : {A : Set} -> A -> A -> Similar A
returnSS x y = similar [[ (show x) ]] x [[ (show y) ]] y

+--monad-law-1 : mu ∙ (fmap mu) ≡ mu ∙ mu

-monad-law-1 : mu ∙ (fmap mu) ≡ mu ∙ mu
+monad-law-1 : {l : Level} {A : Set l} -> (s : Similar (Similar (Similar A))) -> ((mu ∙ (fmap mu)) s) ≡ ((mu ∙ mu) s)
+    ((mu ∙ (fmap mu)) s)
+  ≡⟨⟩
+    mu (fmap mu s)
+  ≡⟨ {!!} ⟩
+     mu (mu s)
+  ≡⟨⟩
+    ((mu ∙ mu) s)
+  ∎

+
+
+
+{-
--monad-law-2 : mu ∙ fmap return ≡ mu ∙ return ≡id
monad-law-2-1 : mu ∙ fmap return ≡ mu ∙ return
@@ -35,7 +50,8 @@

monad-law-3 : ∀{f} -> return ∙ f ≡ fmap f ∙ return

monad-law-4 : ∀{f} -> mu ∙ fmap (fmap f) ≡ fmap f ∙ mu