Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. module Id where
  2.  
  3. open import Relation.Binary.PropositionalEquality.Core
  4. open import Function
  5.  
  6. data Id : Set → Set where
  7. Itself : ∀{A} → A → Id A
  8.  
  9. fmap : ∀{A B} → (A → B) → Id A → Id B
  10. fmap f (Itself x) = Itself (f x)
  11.  
  12. pure : ∀{A} → A -> Id A
  13. pure x = Itself x
  14.  
  15. infixr 5 _>>=_
  16.  
  17. _>>=_ : ∀{A B} → Id A → (A -> Id B) -> Id B
  18. Itself x >>= f = f x
  19.  
  20. functorIdentity : ∀{A} → (x : Id A) → fmap id x ≡ x
  21. functorIdentity (Itself x) = refl
  22.  
  23. functorComposition : ∀{A B C}
  24. → (x : Id A) → (g : A → B) → (f : B → C)
  25. → fmap (f ∘ g) x ≡ fmap f (fmap g x)
  26. functorComposition (Itself x) g f = refl
  27.  
  28. pureBind : ∀{A B} → (x : A) → (f : A → Id B) → pure x >>= f ≡ f x
  29. pureBind x f = refl
  30.  
  31. bindPure : ∀{A} → (x : Id A) → x >>= pure ≡ x
  32. bindPure (Itself x) = refl
  33.  
  34. bindAssoc : ∀{A B C} → (m : Id A) → (f : A → Id B) → (g : B → Id C)
  35. → m >>= (λ x → f x >>= g) ≡ (m >>= f) >>= g
  36. bindAssoc (Itself x) f g = refl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement