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

Repl doesn't return any output? #16

Open
Kreijstal opened this issue Oct 30, 2023 · 6 comments
Open

Repl doesn't return any output? #16

Kreijstal opened this issue Oct 30, 2023 · 6 comments

Comments

@Kreijstal
Copy link

I am trying to use the repl, I have no idea how is it supposed to work but I receive no output

> lake exe repl
{ "cmd" : "def f := 2" }
{ "cmd" : "example : f = 2 := rfl", "env" : 1 }
{ "cmd" : "#eval 1+1"} 
{ "cmd" : "IO.println \"hey\""} 

after ctr+c
I get

uncaught exception: {"message": "offset 34: expected end of input"}

am I doing something wrong?

@digama0
Copy link
Member

digama0 commented Oct 30, 2023

I had to insert two newlines between each command (or press enter twice after each line) to receive a response. If you only use one newline you get the expected end of input error message.

@Kreijstal
Copy link
Author

meanwhile in my machine

> lake exe repl
{ "cmd" : "#eval 1+1"}








\r\n



(doesn't seem to work)

@digama0
Copy link
Member

digama0 commented Oct 30, 2023

what OS and terminal are you using? Most terminals submit the result after each line. Ctrl-D should work to close the input stream and push everything, but it's obviously not optimal since you can't write anything after that.

@digama0
Copy link
Member

digama0 commented Oct 30, 2023

It seems like this code:

/-- Get lines from stdin until a blank line is entered. -/
partial def getLines : IO String := do
  match (← (← IO.getStdin).getLine) with
  | "" => pure ""
  | "\n" => pure "\n"
  | line => pure <| line ++ (← getLines)

may fail on windows and cause it to keep asking for lines forever if a blank line is sent as "\r\n" rather than "\n". cc: @semorrison

@Kreijstal
Copy link
Author

I am using vscode under windows

@kim-em
Copy link
Contributor

kim-em commented Nov 1, 2023

@Kreijstal, would you mind checking if the problem has been resolved now?

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

No branches or pull requests

3 participants