readline-in-other-words: Readline effect for in-other-words.

[ bsd2, command-line, effect, haskeline, in-other-words, library, program, user-interfaces ] [ Propose Tags ]

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.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2 (info)
Change log ChangeLog.md
Dependencies base (>=4.13 && <4.17), haskeline (>=0.8.1 && <0.8.3), in-other-words (>=0.2.0.0 && <0.2.1.0), in-other-words-plugin (==0.1.0.0), monad-control (>=1.0 && <1.1), mtl (>=2.2 && <2.3), readline-in-other-words [details]
License BSD-2-Clause
Copyright (c) 2021 Devin Lehmacher
Author Devin Lehmacher
Maintainer Devin Lehmacher
Category User Interfaces, Effect, in-other-words, Command Line
Home page https://github.com/lehmacdj/readline-in-other-words#readme
Bug tracker https://github.com/lehmacdj/readline-in-other-words/issues
Source repo head: git clone git://github.com/lehmacdj/readline-in-other-words.git
this: git clone git://github.com/lehmacdj/readline-in-other-words.git(tag 0.1.0.2)
Uploaded by lehmacdj at 2021-11-05T06:48:06Z
Distributions
Executables echo-repl
Downloads 261 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-11-05 [all 1 reports]

Readme for readline-in-other-words-0.1.0.2

[back to package description]

readline-in-other-words

GitHub Actions Hackage

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.