Skip to content

REPL does not continue when the abort function is used #49

Description

@SeungUkLee

Thank you for creating a great library.

In docs, the abort function is said to abort and continue the REPL loop.

It works normally in the Command, but REPL does not restart in Options.

Is it intended?

Example code:
import           Control.Monad.IO.Class (liftIO)
import           Data.List              (isPrefixOf)
import           System.Console.Repline

main :: IO ()
main = mainLoop

type Repl a = HaskelineT IO a

mainLoop :: IO ()
mainLoop = evalReplOpts replopts
  where
    replopts = ReplOpts
      { banner           = const (pure ">>> ")
      , command          = cmds
      , options          = opts
      , prefix           = Just ':'
      , multilineCommand = Nothing
      , tabComplete      = Word0 completer
      , initialiser      = ini
      , finaliser        = final
      }

final :: Repl ExitDecision
final = do
  liftIO $ putStrLn "GoodBye!\n"
  return Exit

ini :: Repl ()
ini = liftIO $ putStrLn "Hello, REPL"

cmds :: String -> Repl ()
cmds str = do
  liftIO $ print str
  abort

opts :: Options (HaskelineT IO)
opts =
  [ ("foo", foo)
  ]

completer :: Monad m => WordCompleter m
completer n = do
  let opts = [":foo"]
  return $ filter (isPrefixOf n) opts

foo :: String -> Repl ()
foo args = do
  liftIO $ print args
  abort

expected:

>>> :foo hello
"hello"
>>>

actual:

>>> :foo hello
"hello"
ghci> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions