1

I have the following code in a file trial_agda.agda in emacs:

module trial_agda where

data  : Set where
 zero : 
 suc  :  → 
 _+_ :  →  → 

zero + n = n
(suc n) + n′ = suc (n + n′) 

It produces

/Users/myname/trial_agda.agda:8,1-13
Missing type signature for left hand side zero + n
when scope checking the declaration
  zero + n = n

What is the problem?

user65526
  • 685
  • 6
  • 19

1 Answers1

1

The problem was resolved by making a gap of a line after suc: → . In http://learnyouanagda.liamoc.net/pages/peano.html#fn1 where this example is mentioned, it is not mentioned where the example is discussed, that such a gap should be made.

user65526
  • 685
  • 6
  • 19
  • 3
    You need to really understand what's going on here and why this gap was needed : It was needed because `_+_` is not a constructor for natural number, but rather a function which takes 2 natural numbers as parameters. The following lines then define how this function should behave depending on the structure of its first input. I can make this comment an answer if you feel like it and if you would want some more precision. – MrO Nov 10 '19 at 15:15
  • 4
    What is important is the indentation level: the first `_` in the line `_+_ : → → ` must align vertically with the `d` in `data`, so that `_+_` is considered its own definition in the `trial_agda` module. In general the indentation level for a `where` block is determined by the first definition in it. – Saizan Nov 11 '19 at 08:28