Skip to content

Standardisation of folds #278

Description

@MatthewDaggitt

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!):

  1. Basic folds (applicable to everything List, Vec, Table etc.)
foldr :  {a b} {A : Set a} {B : Set b}  (A  B  B)  A   {n}  Vec A n  A
  1. Dependent folds (applicable to everything)
foldr :  {a b} {A : Set a} (B : Set b) {m}  
        ( {n}  A  B n  B (suc n))  B zero  Vec A m  B m
  1. Non-empty folds (applicable to Vec, Table etc)
foldr :  {a} {A : Set a}  (A  A  A)   {n}  Vec A (suc n)  A

Obviously 1. can be implemented in terms of 2. and 3. can be implemented in terms of 1.

The current state of play is:

Datatype Name for 1. Name for 2. Name for 3.
List foldr - N/A
Vec - foldr foldr₁
Table foldr - -
Product.N-ary - 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.

  1. In my opinion the name foldr should always be reserved for this "normal" fold.
  2. I don't have strong opinions or any good suggestions. Maybe something like dfoldr or foldrᵈ?
  3. I would suggest foldr₊ to represent the non-emptiness (rather than foldr⁺ which would clash for property intoduction proofs).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions