0

I can evaluate dhall expressions with dhall --file ..., and I can evaluate 1 + 1 in the repl, but typing a let expression into dhall repl fails with "unexpected end of input."

➜  cat test.dhall
let x = 1

let y = 2

in  x + y
➜  ~ dhall --file test.dhall
3
➜  ~ dhall repl
Welcome to the Dhall v1.41.0 REPL! Type :help for more information.
⊢ let x = 1

Error: Invalid input

(input):2:1:
  |
2 | <empty line>
  | ^
unexpected end of input
expecting "→", ->, :, keyword, or whitespace

⊢ 1 + 1

2
Charlie
  • 705
  • 1
  • 5
  • 14

1 Answers1

1

let x = 1 by itself is not a valid expression. The structure of a let ... in ... expression is such that it can start with one or more let clauses, but must end with the in clause.

If you just want to set a value in the REPL, you need to use the special :let command (which is specific to the REPL and not part of the language).

⊢ :let x = 1

x : Natural

⊢ x + 1

2
chepner
  • 497,756
  • 71
  • 530
  • 681
  • thank you! I see now that there _is_ an `in` at the end of this block of code, but I didn't read the document entirely before I wanted to try expressions from it: https://learnxinyminutes.com/docs/dhall/ – Charlie Feb 23 '22 at 15:12
  • It's slightly different than in Haskell, where you would write something like `let x = 1; y = 2; in x + y` instead of `let x = 1; let y = 2; in x + y`. – chepner Feb 23 '22 at 15:15