Skip to content

Commit 6bb57fd

Browse files
author
Ian Kariniemi
committed
Preliminary scan of Build/Task/Monad.v
Type error fun prevents us from getting further. We insert universe polymorphic instances of the Monads from https://github.com/lastland/ProgramAdverbs/blob/main/GHC/Base.v
1 parent 640fd87 commit 6bb57fd

File tree

2 files changed

+93
-1
lines changed
  • examples/build-systems-ala-carte/module-edits/Build/Task/Monad

2 files changed

+93
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
skip module Control.Monad.Writer.Class
22

3-
rename type GHC.Base.Monad = GHC.Base.Monad__Dict
3+
rename type GHC.Base.Monad = Monad__Dict
4+
5+
## TODO: Writer Monad
6+
axiomatize definition Build.Task.Monad.trackPure
7+
axiomatize definition Build.Task.Monad.track
8+
9+
## TODO Type error, uncomment to see it.
10+
axiomatize definition Build.Task.Monad.computePure
11+
axiomatize definition Build.Task.Monad.compute
12+
axiomatize definition Build.Task.Monad.liftMaybe
13+
axiomatize definition Build.Task.Monad.liftEither
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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

Comments
 (0)