0

Suppose I wish to define Bool as a type, I would write:

data Bool : Type where

I don't quite understand why I must keep 'where' at the end, what purpose does it play in the Syntax? Why was the above preferred over say:

data Bool : Type

Was this arbitrary or is there some deep logic underlying?

By the way, I am a total noob at programming, so please explain using most simple words.

Drew
  • 29,895
  • 7
  • 74
  • 104
  • 3
    What you are asking is the *concrete syntax*. Concrete syntax is always arbitrary. So apart from looking good and feeling good there is essentially no reason something is this way or that. – Trebor Jul 08 '22 at 16:07
  • To be idiomatic. It's good to have a keyword that separates the type and the clause defining the judgements. – Pandemonium Oct 05 '22 at 21:01

1 Answers1

3

With the where keyword, we can write the following:

data Bool : Set where true false : Bool

Without the where keyword, this would be

data Bool : Set true false : Bool

but this would be ambiguous: true could be defined to be an element of type Level, in which case this would be defining a datatype at sort Set true with a single constructor false.

Jesper
  • 2,781
  • 13
  • 14