Description
Readline effect for in-other-words.
Description
This library provides effects for in-other-words offering the functionality of haskeline. Please see the README on GitHub at https://github.com/lehmacdj/readline-in-other-words#readme for more details.
README.md
readline-in-other-words
This package provides a few in-other-words effects that collectively provide the full functionality of haskeline. See Haskeline's documentation for additional usage information.
Example Usage
This is all it takes to write a miniature repl using this library:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
module Main where
import Control.Effect
import Control.Effect.Readline
repl :: Effs '[Readline, HandleInterrupt] m => m ()
repl = handleInterrupt (outputStrLn "Interrupt!" *> repl) $
withInterrupt $ do
mline <- getInputLine "> "
case mline of
Nothing -> pure ()
Just line -> outputStrLn line *> repl
main :: IO ()
main = runM $ runReadline defaultSettings repl
This will echo whatever text you write, and catches interrupts announcing that they occurred and preventing the program from terminating. This example is also available as the echo-repl
target in examples/Echo.hs
.
Contributions
Bug reports and PRs are welcome.