Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 20 lines (14 sloc) 0.834 kB
681336e @batterseapower Initial commit of katas
authored
1 Section YonedaIsFunctor.
2
3 Inductive yoneda (F : Set -> Set) (A : Set) : Type :=
4 | yonedak : (forall (B : Set), (A -> B) -> F B) -> yoneda F A.
5
6 Definition fmap (F : Set -> Set) (A : Set) (B : Set) (f : A -> B) (m : yoneda F A)
7 := yonedak F B (fun (C : Set) (k : (B -> C)) => match m with
8 | yonedak m => m C (fun (x : A) => k (f x))
9 end).
10
11 Definition id (A : Set) (x : A) := x.
12
13 Theorem first_law :
14 forall (F : Set -> Set) (A : Set) (m : yoneda F A),
15 fmap F A A (id A) m = m.
16
17 Theorem second_law :
18 forall (F : Set -> Set) (A B C : Set) (f : B -> C) (g : A -> B) (m : yoneda F A),
19 fmap F B C f (fmap F A B g m) = fmap F A C (fun (x : A) => f (g x)) m.
Something went wrong with that request. Please try again.