Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot bind variables with let #3

Closed
angerman opened this issue Oct 17, 2016 · 5 comments
Closed

Cannot bind variables with let #3

angerman opened this issue Oct 17, 2016 · 5 comments

Comments

@angerman
Copy link

let x = 5

results in

<hint>:3:23: error: parse error on input ‘}’

Using just

x = 5

results in the very helpful message:

<hint>:2:3: error:
    parse error on input ‘=’
    Perhaps you need a 'let' in a 'do' block?
    e.g. 'let x = 5' instead of 'x = 5'

:)

@homam
Copy link

homam commented Oct 17, 2016

Try

let x = 5 in
show x
let 
  f = (* 2)
  x = 5
in
  show $ f x

@angerman
Copy link
Author

Sure! That does work. However, x = 5 or let x = 5 would be what would work in ghci, and I probably foolishly expected it to work in HyperHaskell as well.

@HeinrichApfelmus
Copy link
Owner

Sorry about the confusion. At the moment, only Haskell expressions (as opposed to statements) can be parsed and evaluated. Statements (e.g. let x = …, x <- someIO etc) are planned for Level β.

@HeinrichApfelmus HeinrichApfelmus changed the title Cannot let Cannot bind variables with let Oct 20, 2016
@HeinrichApfelmus
Copy link
Owner

As of commit 83d4963 , you can execute monadic statements. In particular, you can introduce new variables with <-, e.g.

test <- return "haskell"

The let statement is not supported just yet.

@HeinrichApfelmus
Copy link
Owner

The let statement is now supported in version 0.2.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants