Giter Site home page Giter Site logo

Comments (13)

sattlerc avatar sattlerc commented on September 24, 2024 1

So, maybe,

higher data Nat : Set
...
higher data Nat : Set where  -- higher is optional here
  Z : ...

Yes (without the second : Set). Do we foresee the possibility of other data type modes that may potentially be mixed with this? If so, higher could be an annotation, e.g., data [higher, second-order, green]. Alternatively, there's always pragmas.

On a second thought, higher isn't really very specific: e.g. higher order data is such that has a constructor with a functional recursive argument. What about cubical data or homotopy data?

I agree. Since the mode is called --cubical, cubical seems an appropriate tag.

from agda.

nad avatar nad commented on September 24, 2024 1

I think data should come first, and higher/cubical after, because data is the main concept. I also think that, if possible, we should use the same style as for record (or change the notation used for record):

data Unit : Set where
  cubical
  unit : Unit
data Unit : Set
  cubical

data Unit where
  unit : Unit

Instead of higher or cubical one could perhaps use a more descriptive name which indicates that the type has an hcomp constructor, maybe simply hcomp:

data Unit : Set where
  hcomp
  unit : Unit

Here hcomp is a kind of constructor, and it is listed just before the other constructors, but without a type signature. I'm not a big fan of the name "hcomp", though, because both homogeneous and heterogeneous start with "h". Another option might be homogeneous-composition:

data Unit : Set where
  homogeneous-composition
  unit : Unit

from agda.

andreasabel avatar andreasabel commented on September 24, 2024

We could also have a declaration higher-inductive before the constructors (or maybe anywhere in the list), similar to the record flavors (like no-eta-equality).

I suppose this declaration would be optional for data types that have path constructors, right?

from agda.

sattlerc avatar sattlerc commented on September 24, 2024

We could also have a declaration higher-inductive before the constructors (or maybe anywhere in the list), similar to the record flavors (like no-eta-equality).

I suppose this declaration would be optional for data types that have path constructors, right?

Not sure.

Agda already allows splitting the signature

data Nat : Set

from the specification

data Nat where
  O : Nat
  S : Nat  Nat

And thinking long-term, there are proposals for being able to interleave constructors of a data type with other stuff (for example, constructors of other data types in an inductive-inductive definition, or auxiliary definitions). Moreover, composition for a data type can appear in the signature of its constructors.

In these cases, it may be beneficial to know from the start (i.e., the signature, but at least before constructors) if we are in the higher case or not. For example, in the case of Nat, we could have access to the reduction hcomp <false cofibration> O = O after checking the first constructor because we know we are not in the higher case.

That would mean that path constructors can only be used if "higher" is specified. This may also make it simpler in the implementation to gate cubical code and data for higher data types.

higher-inductive

Data is always inductive, so inductive here feels duplicated.

from agda.

andreasabel avatar andreasabel commented on September 24, 2024

So, maybe,

higher data Nat : Set
...
higher data Nat : Set where  -- higher is optional here
  Z : ...

On a second thought, higher isn't really very specific: e.g. higher order data is such that has a constructor with a functional recursive argument.
What about cubical data or homotopy data?

I mean, only because people are used to the initial (bad) naming of a concept, this isn't a reason to chisel this name into stone. (Thinking of the meaningless words alpha-, beta-, etc. -reduction we are stuck with...)

from agda.

AndrasKovacs avatar AndrasKovacs commented on September 24, 2024

I support this, I have it in cctt for the same reasons that @sattlerc mentioned, where both inductive Nat and higher inductive Nat are supported, with different computation rules.

from agda.

andreasabel avatar andreasabel commented on September 24, 2024

So,

cubical data Nat : Set
...
cubical data Nat where  
  -- Should we make "cubical" optional here?
  -- Would be in line with omitting the type signature, although it is just a keyword that has to be duplicated...
  ...

from agda.

sattlerc avatar sattlerc commented on September 24, 2024

If we use "cubical data" as a keyword like that, I feel we would be forced to repeat it.

I'm not a fan of repetition, so as a separate proposal, maybe the syntax for splitting signature and constructors/fields can be shortened to

data D : Set

D where
  [...]

and

record R : Set

R where
  [...]

But maybe that is not possible with the current parser.

from agda.

andreasabel avatar andreasabel commented on September 24, 2024

maybe the syntax for splitting signature and constructors/fields can be shortened

data if_then_else_ (b : Bool) (t e : Set) : Set
...
if b then t else e where
  tt : if true then t else e ≡ t
  ff : if false then t else e ≡ e

from agda.

jespercockx avatar jespercockx commented on September 24, 2024

maybe the syntax for splitting signature and constructors/fields can be shortened

data if_then_else_ (b : Bool) (t e : Set) : Set
...
if b then t else e where
  tt : if true then t else e ≡ t
  ff : if false then t else e ≡ e

That wouldn't work because you can only have higher constructors that target equalities between elements of the type you are defining, but here the equality is between elements of type Set.

But it does remind me of an old proposal (can't find the issue number right away) to have function definitions in this style, i.e.

if_then_else_ : Bool -> a -> a -> a where
  true t f -> t
  false t f -> f

from agda.

andreasabel avatar andreasabel commented on September 24, 2024

@nad: Using a directive like in records was also my first idea, but @sattlerc had objections in #7053 (comment) . How do you see these?

Does your proposal to require the directive with the data signature solve this?

(Note however, that syntax-wise the directive would fit into the list of declarations following the where of the data definition, in analogy to record directives.)

from agda.

sattlerc avatar sattlerc commented on September 24, 2024

Instead of higher or cubical one could perhaps use a more descriptive name which indicates that the type has an hcomp constructor, maybe simply hcomp:

data Unit : Set where
  hcomp
  unit : Unit

Here hcomp is a kind of constructor, and it is listed just before the other constructors, but without a type signature. I'm not a big fan of the name "hcomp", though, because both homogeneous and heterogeneous start with "h". Another option might be homogeneous-composition:

data Unit : Set where
  homogeneous-composition
  unit : Unit

Note that indexed higher inductive types also need a transport constructor (but I am not sure indexed HITs have been fully implemented yet). Would you suggest a keyword also for that constructor?

data Id : A  A  Set where
  homogeneous-composition
  transport
  refl : (a : A)  Id a a

Then indexed data types without transport would have to be rejected. And it is possible to have non-indexed HITs with transport. I guess that's consistent with my proposal.

from agda.

nad avatar nad commented on September 24, 2024

Then indexed data types without transport would have to be rejected.

Another option is perhaps to insert this automatically for indexed types with path constructors.

from agda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.