### view agda/similar.agda @ 29:e0ba1bf564dd

Apply level to some functions
author Yasutaka Higa Tue, 07 Oct 2014 15:09:17 +0900 6e6d646d7722 c2f40b6d4027
line wrap: on
line source
```
open import list
open import basic

open import Level
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning

module similar where

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

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 : {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
return x = similar [] x [] x

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

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 : {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