### view agda/similar.agda @ 30:c2f40b6d4027

author Yasutaka Higa Tue, 07 Oct 2014 15:32:11 +0900 e0ba1bf564dd 71906644d206
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)
≡⟨ cong mu {!!} ⟩
mu (mu s)
≡⟨⟩
((mu ∙ mu) s)
∎
-}

monad-law-1-sub : {l : Level} {A : Set l} -> (s : Similar (Similar (Similar A))) -> fmap mu s ≡ mu s
monad-law-1-sub (similar lx (similar llx (similar lllx x _ _) _ _) ly (similar _ _ lly (similar _ _ llly y))) = begin
similar lx (mu (similar llx (similar lllx x _ _) _ _)) ly
(mu (similar _ _ lly (similar _ _ llly y)))
≡⟨ {!!} ⟩
similar (lx ++ llx) (similar lllx x _ _) (ly ++ lly)
(similar _ _ llly y)
∎

{-
--monad-law-2 : mu ∙ fmap return ≡ mu ∙ return ≡id
monad-law-2-1 : mu ∙ fmap return ≡ mu ∙ return