-
Notifications
You must be signed in to change notification settings - Fork 242
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
Standardisation of folds #278
Comments
I'd suggest also adding: induction : ∀ {a b} {A : Set a} (B : (n : ℕ) → Vec A n -> Set b) →
(∀ {n} x xs → B n xs → B (suc n) (x ∷ xs)) → B zero [] →
∀ {m} (xs : Vec A m) → B m xs |
My instincts for naming (in Agda) goes in the opposite direction for 1 vs 2. The standard library is quite a mixed bag in this respect, but for simpler types (sums, products), the basic operations are all deeply dependent but use the 'classical' name anyways. Then there is often a non-dependent synonym. Because the context is dependently typed, it feels that the simpler names should be attached to the dependently typed version. As for 'non-empty', any chance of using subscript 'ne' instead? I do a lot of stuff with rigs, and in that setting using a |
The difference is that the dependent version of
Okay, no problem, we can find a different name. Hmm |
I agree, The rest was really 'my feeling'. Hopefully people with more experience will chyme in. |
I occasionally use names like |
I still haven't put much thought into these namings and its quite a big backwards non-compatible change. I think this isn't going to get fixed for v1.0. |
Given that we use |
I'm coming back to this issue as I'm trying to add a non-empty fold over lists. @gallais your suggestion of My current set of suggestions is as follows:
@JacquesCarette, to reiterate what I said above, while I see your point about many of the basic operations being dependent, I think one of the commonalities of those basic operations is that in the vast majority of cases they work equally well with dependent and non-dependent types and therefore the dependent-ness doesn't interfere with their ease of use. In contrast the dependent folds require the indexed type being passed in explicitly which means you'd never want to use it for non-dependent cases. Secondly, the dependent folds seem to be used much more rarely(?) (anecdotal I know but I've never come across the use of one in the wild). |
Then again we have a well established (in
As for the non-empty one, we could reuse the Haskell convention and call it |
I'm with @gallais on the naming. Though I don't feel too strongly about it. |
Sure, I also don't feel that strongly so I'm happy to be outvoted 😄 Also good to go with Haskell's conventions. I'll update the matrix PR before merging it in, and then will get round to fixing the names for v2.0. |
Final bikeshedding. Do people prefer |
No strong opinion on the placement of the |
And my last bit of (2022!) bikeshedding on this point: I had introduced |
Okay so we've decided on :
@gallais will try and create a PR and we'll see how many inference problems we get. |
Hmmm. Let me know how you get on with implicit Pro implicit: users can write Contra/Pro explicit: they will be forced to write |
Did we get this right in the end? Can this be closed? |
I haven't opened a PR for this yet |
Suggest that whatever else might get done, lifting out the definitions of the types of the operators (as in |
I note that PROPOSAL: we systematically do this for all the inductive |
@gallais think you'll be able to get to this in 2025? |
At the moment naming and typing conventions for folds differ quite a lot across the various different data types. As far as I can see there are three basic types of folds present in the standard library (feel free to suggest more if I missed any!):
List
,Vec
,Table
etc.)Vec
,Table
etc)Obviously 1. can be implemented in terms of 2. and 3. can be implemented in terms of 1.
The current state of play is:
foldr
foldr
foldr₁
foldr
foldr
It would be great if we could add in some of the missing ones and come up with some consistent naming scheme for these across all data types for v1.0.
foldr
should always be reserved for this "normal" fold.dfoldr
orfoldrᵈ
?foldr₊
to represent the non-emptiness (rather thanfoldr⁺
which would clash for property intoduction proofs).The text was updated successfully, but these errors were encountered: