-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Moving to stdpp #267
base: master
Are you sure you want to change the base?
Conversation
:= fun _ _ k c => match c with | inl e => inl e | inr a => k a end. | ||
|
||
(* state *) | ||
Definition state (s a : Type) := s -> prod s a. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Does stdpp not have those standard monads?
- Can we take the opportunity to make this a record instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- They seem to have surprisingly little, no. We might eventually want to package things into a PR, or an independent library as @euisuny suggested at some point.
- To enforce the abstraction to only leak through an explicit
run
? That's probably wise, although the new reduction behavior already helps a little bit in this direction.
We are pushed to use stdpp with iris and it generally works well. Their monad library is pretty minimal, but we've done a lot of work at bedrock building universe polymorphic monads, traversable and applicative as well as monads like state, reader, etc. we would like to get those released at some point. |
Hey @gmalecha , |
I think we can have it out by the end of the week. Would that work? |
Most certainly yes, that would be great! |
@YaZko Here is the repository that we have right now. https://github.com/bedrocksystems/BRiCk/tree/master/coq-upoly It is currently licensed using LGPL2 with a BedRock exception, but I don't think it will be a problem to drop the exception. We would welcome contributions. |
Thanks @gmalecha . |
Thanks go to David Swasey for doing much of the development and the upstreaming work. |
Goal
This ongoing PR experiments with switching from
ext-lib
tostdpp
. The essential rational is the increasing traction that the latter has had: it is largely both used and contributed to. Potential more concrete benefits include:Ongoing issues
Reduction behaviour of
mbind (m := itree E)
Broken proof for
cat_iter
inKTreeFacts.v
at the moment. Runningcbn
unfoldsmbind
and exposes the cofix brutally.Changes and observations
Classes: Monad vs. MBind and MRet
There are already two relevant classes defined in
stdpp
, exclusively for notation purposes:MRet
andMBind
.They therefore replace the
Monad
class that used to package both. This change comes with three immediate additional side effects:Naming: the operations are called
mret
andmbind
(instead ofret
andbind
)Notations: the associated notations live at different levels than what we were used too. Furthermore, they are slightly distinct.
x <- c;; k
becomesx ← c ; k
(only one ";", and a \gets ← instead of ascii <-)x >>= k
becomesx ≫= k
(a \gg ≫ instead of ascii >>)mbind
:mbind
takes the continuation first, similar to what we usually callsubst
Reduction behaviour
Considering for instance
theories/Basics/MonadState.v
.We used to have a very aggressive unfolding behaviour over the state monad.
For instance, in:
Would completely expose the definition of
bind
, reducingbind c k
to(fun s : S => bind (c s) (fun sa : S * A => k (snd sa) (fst sa)))
.In contrast with
mbind
, it is inert.Ensembles.Ensemble vs. propset
It seems to make sense to use
propset
, for instance when it comes to the so-called Prop monad. Although it's still too early to tell really.Existing coercion:
Is_true
ERRATUM: the coercion and the tactic come from the standard library!!
stdpp
already has a coercion replacingis_true
. Its definition is however slightly different, requiring to destructb
instead of rewriting the coerced hypothesis. As far as I understand, the typical way to do so would be via thedestr_bool
tactic. However, this tactic currently loops¹ in presence of a section variable boolean, making it a little less smooth than desired.¹ See coq/coq#18858
Chaining class constraints
I discovered in the process the following syntax:
Definition foo {M} `{MRet M, MBind M, ...}
to list class constraints.
Progress