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

Add the ability to manually toggle multi-line mode #39

Open
sofia-m-a opened this issue Apr 24, 2022 · 0 comments
Open

Add the ability to manually toggle multi-line mode #39

sofia-m-a opened this issue Apr 24, 2022 · 0 comments

Comments

@sofia-m-a
Copy link

Currently, there's a way to toggle multiline mode based on matching a specific commmand:

>>> :multi
... continuation

However, it would be nice to provide a way to toggle this mode based on parsing information, to make something like the following work

>>> incomplete expression (
... so REPL enters multiline mode )

A possible API for this would be:

beginMultiline :: HaskelineT m ()
endMultiline :: HaskelineT m ()
 -- returns a list of lines since the enclosing beginMultiline
 -- alternatively, this could be managed by the caller
multilineContext :: HaskelineT m [String]

allowing something like

cmd :: Command (HaskelineT IO)
cmd s = do
  context <- multilineContext
  if Parser.isIncomplete (context ++ [s])
    then beginMultiline
    else do
      endMultiline
      -- process (context ++ [s]) as a multi-line chunk
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

1 participant