HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Modulehaskeline-0.8.5.0Haskell98

System.Console.Haskeline.IO

This module provides a stateful, IO-based interface to Haskeline, which may be easier to integrate into some existing programs or libraries.

It is strongly recommended to use the safer, monadic API of System.Console.Haskeline, if possible, rather than the explicit state management functions of this module.

The equivalent REPL example is:

import System.Console.Haskeline
import System.Console.Haskeline.IO
import Control.Concurrent

main = bracketOnError (initializeInput defaultSettings)
            cancelInput -- This will only be called if an exception such
                            -- as a SigINT is received.
            (\hd -> loop hd >> closeInput hd)
    where
        loop :: InputState -> IO ()
        loop hd = do
            minput <- queryInput hd (getInputLine "% ")
            case minput of
                Nothing -> return ()
                Just "quit" -> return ()
                Just input -> do queryInput hd $ outputStrLn
                                    $ "Input was: " ++ input
                                 loop hd
Synopsis