Search code examples
read-eval-print-loopdhall

"unexpected end of input" in `dhall repl`


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

Solution

  • 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