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.
- 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.
- 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-libtostdpp. 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_iterinKTreeFacts.vat the moment. Runningcbnunfoldsmbindand 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:MRetandMBind.They therefore replace the
Monadclass that used to package both. This change comes with three immediate additional side effects:Naming: the operations are called
mretandmbind(instead ofretandbind)Notations: the associated notations live at different levels than what we were used too. Furthermore, they are slightly distinct.
x <- c;; kbecomesx ← c ; k(only one ";", and a \gets ← instead of ascii <-)x >>= kbecomesx ≫= k(a \gg ≫ instead of ascii >>)mbind:mbindtakes the continuation first, similar to what we usually callsubstReduction 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 kto(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_trueERRATUM: the coercion and the tactic come from the standard library!!
stdppalready has a coercion replacingis_true. Its definition is however slightly different, requiring to destructbinstead of rewriting the coerced hypothesis. As far as I understand, the typical way to do so would be via thedestr_booltactic. However, this tactic currently loops¹ in presence of a section variable boolean, making it a little less smooth than desired.¹ See rocq-prover/rocq#18858
Chaining class constraints
I discovered in the process the following syntax:
Definition foo {M} `{MRet M, MBind M, ...}to list class constraints.
Progress