[ add ] partial elements in Effect.Monad.Partial module#2796
Conversation
|
Hi @e-mniang, thanks for the contribution! I've requested reviews from people who may be more capable of assessing this than me. However, for starters please could you make sure that your proposed new file has the same formatting as all the other files in the standard library? |
e-mniang
left a comment
There was a problem hiding this comment.
Hi! Thanks for your comment.
I made some changes and I hope the file is now in the correct format. :)
|
@MatthewDaggitt requested my review, but ahead of any such, my first thought would be: why is the record ↯ {a} (A : Set a) : Set ω where
field
ℓ : Level
Dom : Set ℓ
elt : Dom → AI realise that An alternative might be to define 'partial function from I'll try to look at the 1lab to see what's going on there (oh, some quite delicate things under the hood about a small type of propositions... and the level that such a thing should live at. Hmmm). And perhaps also go back to Eugenio Moggi's PhD thesis, and Scott's "Identity and Existence in Intuitionistic Logic" (Springer LNM 753) for a refresher course... Also: |
We indeed have e.g. https://agda.github.io/agda-stdlib/v2.2/Effect.Monad.Partiality.html |
So... that leaves some tricky design choices as to how to proceed with this PR, if we think it is worth doing so:
So... overall my conclusion (for the time being, at least) is that this PR probably shouldn't proceed, unless there are compelling answers to the above questions? |
|
Delay monads like the one in As for impredicativity, this isn't essential aside from the usual caveats about predicative order theory: see Tom de Jong's thesis for more. Finally, we could prove the monad laws, though this would require some setoid-fu that quotients away the choice of witnesses of definedness. |
|
Also, I forgot to mention that modulo proof-relevance, this is the free pointed DCPO, whereas delay-like monads are aiming to be the free omega-CPO. |
|
That level of 'documentation' would be worth putting in the PR, including adding some to the current Partiality monad. |
|
@TOTBWF wrote:
Thanks Reed for this. Does this (ie. 'free pointed DCPO') mean that only decidable domains of partial definitions are being considered (because we can distinguish the point?), or is that a misunderstanding based on Also: a propos free-ness (and #1962 #2539 etc. for @JacquesCarette 's shopping list of examples with which to explore candidate designs), are we going to add the relevant universal properties, suitably phrased, at some point downstream... ? |
|
After the recent slew of PRs based on the 'subset-as-family' idiom, I'm happy to row back on my suggestions regarding |
jamesmckinna
left a comment
There was a problem hiding this comment.
Very nice, and I look forward to seeing this land, after appropriate revisions.
Co-authored-by: jamesmckinna <31931406+jamesmckinna@users.noreply.github.com>
Co-authored-by: jamesmckinna <31931406+jamesmckinna@users.noreply.github.com>
Co-authored-by: jamesmckinna <31931406+jamesmckinna@users.noreply.github.com>
|
Re: the construction as a partial map classifier. At the moment, this only provides the 'raw' type constructor, without any additional Fine as far as that goes, as we don't even have machinery (yet) for partial functions, besides my speculative #2816 , so I'm interested in where this PR might go downstream in terms of fleshing out that, or any alternative, vision for such things. |
|
So it looks like this one might be ready after all? @jamesmckinna what is outstanding? |
I'll need to come back to this and think! Plus get more sleep than I'm currently managing to achieve. UPDATED: needs @e-mniang are you still interested in working on this, and/or able to do so? If not, I think that between @JacquesCarette and myself we can try to merge this in soon. In any case, converting back from |
I've started looking at this again, making changes previously suggested but not acted upon, and so my former review shouldn't be considered blocking any more.
|
@JacquesCarette I think this now is a minimal commit-able bunch of code, but lacking @TOTBWF 's gloss/commentary. Will add later, unless Reed, do you want to? |
|
Question for @JacquesCarette and @TOTBWF :
On its face, this typechecks correctly (at level Proposal: we park this PR unmerged, until such time as we resolve the irrelevance/ Please chime in on this, otherwise I'm not sure that this should go through even as it now is. (Reading back over my earliest comment, I did ask about what might be the consequences of dropping the |
Effect.Monad.Partial module
|
If you remove the subsingleton condition then you get a multi-map classifier instead of a partial map classifier. A → ↯ B
≅ A → Σ (Dom : Set) (Dom → B) -- by defn
≅ A → (B → Set) -- Fibre-family equivalence[1]After some thought, I think this is actually what you'd want in the stdlib. If you are working with setoids, then the right notion of subsingleton is As for I would definitely not make Dom a Prop or irrelevant though! Both will be rather ill-behaved when you want to use [^1] This step may or may not need univalence depending on the notion of isomorphism/equivalence of types you use. [^2] Modulo the bug where you get global choice lol |
|
I believe the "global choice" bug has been fixed by Jesper in current development Agda, and ought to be in 2.9. |
|
On the basis of @TOTBWF 's comments, I'd be happy to merge now. |
This PR introduces the
↯type for partial elements along with its associated functions for binding, mapping, and applying.Partial computations — such as non-terminating functions or computations undefined on some input — are represented by a domain of definition and an associated function. The type ↯ A ℓ encapsulates such partial values over a type A by:
Basic constructors:
Functions:
Source: https://1lab.dev/Data.Partial.Base.html#1132 and @TOTBWF