-
Notifications
You must be signed in to change notification settings - Fork 247
Naming inversion principles for (one-constructor) data
types
#2155
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
Comments
I'm completely for consistency. And your reasoning is great. And yet, I'm not sure I really like For some odd reason, I got used to the Haskell-ish |
Re: haskell |
@JacquesCarette did you ever think up a better alternative to |
Coming up with a better one would have required actively thinking about it... which I'm only able to now. Let me "think out loud" here. I tend to conceptualize removing the tag/constructor of a one-constructor It is not wrong to see the act of removing the (useless) tag as some kind of inversion, as you are un-doing the act of tagging, i.e. inverting that tagging operation. But given just how many kinds of inverses there are, conceptualizing this one differently is most likely useful! Weirdly, that seems to argue for Googling around, 'untag' can also be called 'strip', 'drop' and 'unlabel'. There's also 'detag' - but yuck! on that one. Apparently 'ostracize' is seen as somehow being related to 'untag' ? Hmm, doesn't seem like fertile ground (except for bad jokes) down that alley! Hmm, what about riffing on 'set minus' and using a leading backslash? Removing |
Lots of food for thought! After a few days' post-Christmas (in)digestion, however, I still find myself unconvinced by the arguments in favour of the alternatives you offer... although I have in the past when teaching Knaster-Tarski etc. referred to the I suppose, notwithstanding that you don't like the suggestion, that conversely, I had been thinking about |
Feels like we need a third voice (or more) in here. We most certainly agree on the semantics of what we're talking about. We just disagree on what syntax to (ab)use. |
I'm afraid I don't have a strong opinion on this. I'm happy with |
I don't have a strong opinion |
Inversion (in Prawitz' sense) of inductive definitions is a special case of pattern-matching, corresponding to there being a unique combination of premises for an inference rule which guarantee the form of the conclusion, namely those given by the premises of the rule itself. Cf. irrefutable
with
... which corresponds to a given instance of an inductive family having a 'constructor' which gives rise to the instance. A further special case occurs when we have adata
type with only a single constructor, which somehow captures that scenario for all such instances, uniformly.In the library, there are many examples of such phenomena, but all with ad hoc names, eg:
Induction.WellFounded
, we haveacc-inverse
as the inverse of the single constructoracc
(sic);Data.Rational{.Unnormalised}.Properties
we havedrop-...
as the corresponding inversion principles for the various equality/ordering relations, to strip off the unique associated constructor, in order to expose the underlying (typicallyInteger
-based) relation instance;Data.Nat.Base
, we have, since Refactoring (inversion) properties of_<_
onNat
, plus consequences #2000 , the inversionss≤s⁻¹
ands<s⁻¹
for the (obvious) instances of the associated type families_≤_
and_<_
;Relation.Nullary.Reflects
, we haveinvert
as the inverse ofof
, where the implicitBool
ean argument ensures that we have 'unique' inversion;and there are probably several/many more to be unearthed.
PROPOSAL: that we agree on a consistent naming scheme for such things, add it to the style guide, and refactor/deprecate existing definitions in order to exploit it. Naturally, I would argue for
⁻¹
as the 'minimal-ink' uniform suffix for such names, thus:acc-inverse
acc⁻¹
drop-*≤*
*≤*⁻¹
etc.invert
of⁻¹
(this is already part of Enhancement toRelation.Nullary.Reflects
etc. #2149 , but I would also recommend choosing a better root name thanof
here)etc.
And to do so as soon as practicable, so that further incoherent/non-uniform choices do not get added elsewhere.
The text was updated successfully, but these errors were encountered: