|
| 1 | +Polymorphic Cumulative Record Functor__Dict@{i j} (f : Type@{i} -> Type@{j}) := Functor__Dict_Build { |
| 2 | + fmap__ : forall {a b : Type@{i}}, (a -> b) -> f a -> f b ; |
| 3 | + op_zlzd____ : forall {a b : Type@{i}}, a -> f b -> f a }. |
| 4 | + |
| 5 | +Polymorphic Definition Functor@{i j k} f := |
| 6 | + forall (r__ : Type@{k}), (Functor__Dict@{i j} f -> r__) -> r__. |
| 7 | +Existing Class Functor. |
| 8 | + |
| 9 | + |
| 10 | +(* -------------- Applicative type class --------------------------- *) |
| 11 | + |
| 12 | +Polymorphic Cumulative Record Applicative__Dict@{i j} (f : Type@{i} -> Type@{j}) := Applicative__Dict_Build { |
| 13 | + liftA2__ : forall {a : Type@{i}} {b : Type@{i}} {c : Type@{i}}, (a -> b -> c) -> f a -> f b -> f c ; |
| 14 | + op_zlztzg____ : forall {a : Type@{i}} {b : Type@{i}}, f (a -> b) -> f a -> f b ; |
| 15 | + op_ztzg____ : forall {a : Type@{i}} {b : Type@{i}}, f a -> f b -> f b ; |
| 16 | + pure__ : forall {a : Type@{i}}, a -> f a }. |
| 17 | + |
| 18 | +Polymorphic Definition fmap `{g__0__ : Functor f} |
| 19 | + : forall {a} {b}, (a -> b) -> f a -> f b := |
| 20 | + g__0__ _ (fmap__ f). |
| 21 | + |
| 22 | +Polymorphic Definition op_zlzd__ `{g__0__ : Functor f} : forall {a} {b}, a -> f b -> f a := |
| 23 | + g__0__ _ (op_zlzd____ f). |
| 24 | + |
| 25 | +Notation "'_<$_'" := (op_zlzd__). |
| 26 | + |
| 27 | +Infix "<$" := (_<$_) (at level 99). |
| 28 | + |
| 29 | +Polymorphic Definition Applicative@{i j k} (f : Type@{i} -> Type@{j}) `{Functor@{i j k} f} := |
| 30 | + forall (r__ : Type@{k}), (Applicative__Dict f -> r__) -> r__. |
| 31 | +Existing Class Applicative. |
| 32 | + |
| 33 | +Polymorphic Instance Applicative__eta@{i j k a} (F : Type@{i} -> Type@{j}) |
| 34 | + `{Applicative@{i j k} F} `{Functor@{a j k} (fun A => F A)} : Applicative@{a j k} (fun A => F A). |
| 35 | +intros r k. apply k, H0. |
| 36 | +intros AF. destruct AF. |
| 37 | +constructor. |
| 38 | +- intros a b c. exact (liftA2__0 a b c). |
| 39 | +- intros a b. exact (op_zlztzg____0 a b). |
| 40 | +- intros a b. exact (op_ztzg____0 a b). |
| 41 | +- intros a. exact (pure__0 a). |
| 42 | +Defined. |
| 43 | + |
| 44 | +(* -------------- Monad type class --------------------------- *) |
| 45 | + |
| 46 | +Polymorphic Cumulative Record Monad__Dict@{i j} (m : Type@{i} -> Type@{j}) := Monad__Dict_Build { |
| 47 | + op_zgzg____ : forall {a b : Type@{i}}, m a -> m b -> m b ; |
| 48 | + op_zgzgze____ : forall {a b : Type@{i}}, m a -> (a -> m b) -> m b ; |
| 49 | + return___ : forall {a : Type@{i}}, a -> m a }. |
| 50 | + |
| 51 | +Polymorphic Definition Monad@{i j k} (m : Type@{i} -> Type@{j}) `{Applicative@{i j k} m} := |
| 52 | + forall (r__ : Type@{k}), (Monad__Dict m -> r__) -> r__. |
| 53 | +Existing Class Monad. |
| 54 | + |
| 55 | +Polymorphic Instance Monad__beta@{i j k a} (F : Type@{i} -> Type@{j}) |
| 56 | + `{Monad@{i j k} F} `{Applicative@{a j k} (fun A => F A)} : |
| 57 | + Monad@{a j k} (fun A => F A). |
| 58 | +intros r k. apply k, H1. |
| 59 | +intros MF. destruct MF. |
| 60 | +constructor. |
| 61 | +- intros a b. exact (op_zgzg____0 a b). |
| 62 | +- intros a b. exact (op_zgzgze____0 a b). |
| 63 | +- intros a. exact (return___0 a). |
| 64 | +Defined. |
| 65 | + |
| 66 | +Polymorphic Definition op_zgzg__ `{g__0__ : Monad m} : forall {a} {b}, m a -> m b -> m b := |
| 67 | + g__0__ _ (op_zgzg____ m). |
| 68 | + |
| 69 | +Polymorphic Definition op_zgzgze__ `{g__0__ : Monad m} |
| 70 | + : forall {a} {b}, m a -> (a -> m b) -> m b := |
| 71 | + g__0__ _ (op_zgzgze____ m). |
| 72 | + |
| 73 | +Polymorphic Definition return_ `{g__0__ : Monad m} : forall {a}, a -> m a := |
| 74 | + g__0__ _ (return___ m). |
| 75 | + |
| 76 | +Notation "'_>>_'" := (op_zgzg__). |
| 77 | + |
| 78 | +Infix ">>" := (_>>_) (at level 99, right associativity). |
| 79 | + |
| 80 | +Notation "'_>>=_'" := (op_zgzgze__). |
| 81 | + |
| 82 | +Infix ">>=" := (_>>=_) (at level 99, right associativity). |
0 commit comments