-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A command-line interface for user input, written in Haskell.
°5u
°5uHaskeline provides a user interface for line input in command-line
°5uprograms. This library is similar in purpose to readline, but since it
°5uis written in Haskell it is (hopefully) more easily used in other
°5uHaskell programs.
°5u
°5uHaskeline runs both on POSIX-compatible systems and on Windows.
@package haskeline
@version 0.7.4.0


-- | This module redefines some of the functions in
°5u<a>Control.Exception</a> to work for more general monads built on top
°5uof <a>IO</a>.
module System.Console.Haskeline.MonadException

-- | An instance of <a>MonadException</a> is generally made up of monad
°5utransformers layered on top of the IO monad.
°5u
°5uThe <a>controlIO</a> method enables us to "lift" a function that
°5umanages IO actions (such as <a>bracket</a> or <a>catch</a>) into a
°5ufunction that wraps arbitrary monadic actions.
class MonadIO m => MonadException m
controlIO :: MonadException m => (RunIO m -> IO (m a)) -> m a
catch :: (MonadException m, Exception e) => m a -> (e -> m a) -> m a
handle :: (MonadException m, Exception e) => (e -> m a) -> m a -> m a
catches :: (MonadException m) => m a -> [Handler m a] -> m a
data Handler m a
Handler :: (e -> m a) -> Handler m a
finally :: MonadException m => m a -> m b -> m a
throwIO :: (MonadIO m, Exception e) => e -> m a
throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m ()
bracket :: MonadException m => m a -> (a -> m b) -> (a -> m c) -> m c

-- | Lift a IO operation
°5u
°5u<pre>
°5uwrap :: (a -&gt; IO b) -&gt; IO b
°5u</pre>
°5u
°5uto a more general monadic operation
°5u
°5u<pre>
°5uliftIOOp wrap :: MonadException m =&gt; (a -&gt; m b) -&gt; m b
°5u</pre>
°5u
°5uFor example:
°5u
°5u<pre>
°5u<a>liftIOOp</a> (<a>withFile</a> f m) :: MonadException m =&gt; (Handle -&gt; m r) -&gt; m r
°5u<a>liftIOOp</a> <a>alloca</a> :: (MonadException m, Storable a) =&gt; (Ptr a -&gt; m b) -&gt; m b
°5u<a>liftIOOp</a> (<a>withForeignPtr</a> fp) :: MonadException m =&gt; (Ptr a -&gt; m b) -&gt; m b
°5u</pre>
liftIOOp :: MonadException m => ((a -> IO (m b)) -> IO (m c)) -> (a -> m b) -> m c

-- | Lift an IO operation
°5u
°5u<pre>
°5uwrap :: IO a -&gt; IO a
°5u</pre>
°5u
°5uto a more general monadic operation
°5u
°5u<pre>
°5uliftIOOp_ wrap :: MonadException m =&gt; m a -&gt; m a
°5u</pre>
liftIOOp_ :: MonadException m => (IO (m a) -> IO (m a)) -> m a -> m a

-- | A <a>RunIO</a> function takes a monadic action <tt>m</tt> as input,
°5uand outputs an IO action which performs the underlying impure part of
°5u<tt>m</tt> and returns the '<tt>pure'</tt> part of <tt>m</tt>.
°5u
°5uNote that <tt>(RunIO return)</tt> is an incorrect implementation,
°5usince it does not separate the pure and impure parts of the monadic
°5uaction. This module defines implementations for several common monad
°5utransformers.
newtype RunIO m
RunIO :: (forall b. m b -> IO (m b)) -> RunIO m

-- | Any type that you wish to throw or catch as an exception must be an
°5uinstance of the <tt>Exception</tt> class. The simplest case is a new
°5uexception type directly below the root:
°5u
°5u<pre>
°5udata MyException = ThisException | ThatException
°5u    deriving Show
°5u
°5uinstance Exception MyException
°5u</pre>
°5u
°5uThe default method definitions in the <tt>Exception</tt> class do what
°5uwe need in this case. You can now throw and catch
°5u<tt>ThisException</tt> and <tt>ThatException</tt> as exceptions:
°5u
°5u<pre>
°5u*Main&gt; throw ThisException `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MyException))
°5uCaught ThisException
°5u</pre>
°5u
°5uIn more complicated examples, you may wish to define a whole hierarchy
°5uof exceptions:
°5u
°5u<pre>
°5u---------------------------------------------------------------------
°5u-- Make the root exception type for all the exceptions in a compiler
°5u
°5udata SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
°5u
°5uinstance Show SomeCompilerException where
°5u    show (SomeCompilerException e) = show e
°5u
°5uinstance Exception SomeCompilerException
°5u
°5ucompilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
°5ucompilerExceptionToException = toException . SomeCompilerException
°5u
°5ucompilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
°5ucompilerExceptionFromException x = do
°5u    SomeCompilerException a &lt;- fromException x
°5u    cast a
°5u
°5u---------------------------------------------------------------------
°5u-- Make a subhierarchy for exceptions in the frontend of the compiler
°5u
°5udata SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
°5u
°5uinstance Show SomeFrontendException where
°5u    show (SomeFrontendException e) = show e
°5u
°5uinstance Exception SomeFrontendException where
°5u    toException = compilerExceptionToException
°5u    fromException = compilerExceptionFromException
°5u
°5ufrontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
°5ufrontendExceptionToException = toException . SomeFrontendException
°5u
°5ufrontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
°5ufrontendExceptionFromException x = do
°5u    SomeFrontendException a &lt;- fromException x
°5u    cast a
°5u
°5u---------------------------------------------------------------------
°5u-- Make an exception type for a particular frontend compiler exception
°5u
°5udata MismatchedParentheses = MismatchedParentheses
°5u    deriving Show
°5u
°5uinstance Exception MismatchedParentheses where
°5u    toException   = frontendExceptionToException
°5u    fromException = frontendExceptionFromException
°5u</pre>
°5u
°5uWe can now catch a <tt>MismatchedParentheses</tt> exception as
°5u<tt>MismatchedParentheses</tt>, <tt>SomeFrontendException</tt> or
°5u<tt>SomeCompilerException</tt>, but not other types, e.g.
°5u<tt>IOException</tt>:
°5u
°5u<pre>
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: IOException))
°5u*** Exception: MismatchedParentheses
°5u</pre>
class (Typeable e, Show e) => Exception e

-- | The <tt>SomeException</tt> type is the root of the exception type
°5uhierarchy. When an exception of type <tt>e</tt> is thrown, behind the
°5uscenes it is encapsulated in a <tt>SomeException</tt>.
data SomeException
[SomeException] :: SomeException

-- | Exceptions that occur in the <tt>IO</tt> monad. An
°5u<tt>IOException</tt> records a more specific error type, a descriptive
°5ustring and maybe the handle that was used when the error was flagged.
data IOException
instance System.Console.Haskeline.MonadException.MonadException m => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.Identity.IdentityT m)
instance System.Console.Haskeline.MonadException.MonadException GHC.Types.IO
instance System.Console.Haskeline.MonadException.MonadException m => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.Reader.ReaderT r m)
instance System.Console.Haskeline.MonadException.MonadException m => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.State.Strict.StateT s m)
instance System.Console.Haskeline.MonadException.MonadException m => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.Maybe.MaybeT m)
instance (System.Console.Haskeline.MonadException.MonadException m, Control.Monad.Trans.Error.Error e) => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.Error.ErrorT e m)
instance System.Console.Haskeline.MonadException.MonadException m => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.List.ListT m)
instance (GHC.Base.Monoid w, System.Console.Haskeline.MonadException.MonadException m) => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, System.Console.Haskeline.MonadException.MonadException m) => System.Console.Haskeline.MonadException.MonadException (Control.Monad.Trans.RWS.Lazy.RWST r w s m)

module System.Console.Haskeline.Completion

-- | Performs completions from the given line state.
°5u
°5uThe first <a>String</a> argument is the contents of the line to the
°5uleft of the cursor, reversed. The second <a>String</a> argument is the
°5ucontents of the line to the right of the cursor.
°5u
°5uThe output <a>String</a> is the unused portion of the left half of the
°5uline, reversed.
type CompletionFunc m = (String, String) -> m (String, [Completion])
data Completion
Completion :: String -> String -> Bool -> Completion

-- | Text to insert in line.
[replacement] :: Completion -> String

-- | Text to display when listing alternatives.
[display] :: Completion -> String

-- | Whether this word should be followed by a space, end quote, etc.
[isFinished] :: Completion -> Bool

-- | Disable completion altogether.
noCompletion :: Monad m => CompletionFunc m

-- | Create a finished completion out of the given word.
simpleCompletion :: String -> Completion

-- | A custom <a>CompletionFunc</a> which completes the word immediately to
°5uthe left of the cursor.
°5u
°5uA word begins either at the start of the line or after an unescaped
°5uwhitespace character.
completeWord :: Monad m => Maybe Char -> [Char] -> (String -> m [Completion]) -> CompletionFunc m

-- | A custom <a>CompletionFunc</a> which completes the word immediately to
°5uthe left of the cursor, and takes into account the line contents to
°5uthe left of the word.
°5u
°5uA word begins either at the start of the line or after an unescaped
°5uwhitespace character.
completeWordWithPrev :: Monad m => Maybe Char -> [Char] -> (String -> String -> m [Completion]) -> CompletionFunc m
completeQuotedWord :: Monad m => Maybe Char -> [Char] -> (String -> m [Completion]) -> CompletionFunc m -> CompletionFunc m
completeFilename :: MonadIO m => CompletionFunc m

-- | List all of the files or folders beginning with this path.
listFiles :: MonadIO m => FilePath -> m [Completion]
filenameWordBreakChars :: String
instance GHC.Show.Show System.Console.Haskeline.Completion.Completion
instance GHC.Classes.Ord System.Console.Haskeline.Completion.Completion
instance GHC.Classes.Eq System.Console.Haskeline.Completion.Completion


-- | This module provides a low-level API to the line history stored in the
°5u<tt>InputT</tt> monad transformer.
°5u
°5uFor most application, it should suffice to instead use the following
°5u<tt>Settings</tt> flags:
°5u
°5u<ul>
°5u<li><tt>autoAddHistory</tt>: add nonblank lines to the command history
°5u(<a>True</a> by default).</li>
°5u<li><tt>historyFile</tt>: read/write the history to a file before and
°5uafter the line input session.</li>
°5u</ul>
°5u
°5uIf you do want custom history behavior, you may need to disable the
°5uabove default setting(s).
module System.Console.Haskeline.History
data History
emptyHistory :: History
addHistory :: String -> History -> History

-- | Add a line to the history unless it matches the previously recorded
°5uline.
addHistoryUnlessConsecutiveDupe :: String -> History -> History

-- | Add a line to the history, and remove all previous entries which are
°5uthe same as it.
addHistoryRemovingAllDupes :: String -> History -> History

-- | The input lines stored in the history (newest first)
historyLines :: History -> [String]

-- | Reads the line input history from the given file. Returns
°5u<a>emptyHistory</a> if the file does not exist or could not be read.
readHistory :: FilePath -> IO History

-- | Writes the line history to the given file. If there is an error when
°5uwriting the file, it will be ignored.
writeHistory :: FilePath -> History -> IO ()

-- | Limit the number of lines stored in the history.
stifleHistory :: Maybe Int -> History -> History

-- | The maximum number of lines stored in the history. If <a>Nothing</a>,
°5uthe history storage is unlimited.
stifleAmount :: History -> Maybe Int
instance GHC.Show.Show System.Console.Haskeline.History.History


-- | A rich user interface for line input in command-line programs.
°5uHaskeline is Unicode-aware and runs both on POSIX-compatible systems
°5uand on Windows.
°5u
°5uUsers may customize the interface with a <tt>~/.haskeline</tt> file;
°5usee <a>http://trac.haskell.org/haskeline/wiki/UserPrefs</a> for more
°5uinformation.
°5u
°5uAn example use of this library for a simple read-eval-print loop
°5u(REPL) is the following:
°5u
°5u<pre>
°5uimport System.Console.Haskeline
°5u
°5umain :: IO ()
°5umain = runInputT defaultSettings loop
°5u   where
°5u       loop :: InputT IO ()
°5u       loop = do
°5u           minput &lt;- getInputLine "% "
°5u           case minput of
°5u               Nothing -&gt; return ()
°5u               Just "quit" -&gt; return ()
°5u               Just input -&gt; do outputStrLn $ "Input was: " ++ input
°5u                                loop
°5u</pre>
module System.Console.Haskeline

-- | A monad transformer which carries all of the state and settings
°5urelevant to a line-reading application.
data InputT m a

-- | Run a line-reading application. This function should suffice for most
°5uapplications.
°5u
°5uThis function is equivalent to <tt><a>runInputTBehavior</a>
°5u<a>defaultBehavior</a></tt>. It uses terminal-style interaction if
°5u<a>stdin</a> is connected to a terminal and has echoing enabled.
°5uOtherwise (e.g., if <a>stdin</a> is a pipe), it uses file-style
°5uinteraction.
°5u
°5uIf it uses terminal-style interaction, <a>Prefs</a> will be read from
°5uthe user's <tt>~/.haskeline</tt> file (if present). If it uses
°5ufile-style interaction, <a>Prefs</a> are not relevant and will not be
°5uread.
runInputT :: MonadException m => Settings m -> InputT m a -> m a

-- | Returns <a>True</a> if the current session uses terminal-style
°5uinteraction. (See <a>Behavior</a>.)
haveTerminalUI :: Monad m => InputT m Bool

-- | Map a user interaction by modifying the base monad computation.
mapInputT :: (forall b. m b -> m b) -> InputT m a -> InputT m a

-- | Haskeline has two ways of interacting with the user:
°5u
°5u<ul>
°5u<li>"Terminal-style" interaction provides an rich user interface by
°5uconnecting to the user's terminal (which may be different than
°5u<a>stdin</a> or <a>stdout</a>).</li>
°5u<li>"File-style" interaction treats the input as a simple stream of
°5ucharacters, for example when reading from a file or pipe. Input
°5ufunctions (e.g., <tt>getInputLine</tt>) print the prompt to
°5u<a>stdout</a>.</li>
°5u</ul>
°5u
°5uA <a>Behavior</a> is a method for deciding at run-time which type of
°5uinteraction to use.
°5u
°5uFor most applications (e.g., a REPL), <a>defaultBehavior</a> should
°5uhave the correct effect.
data Behavior

-- | Run a line-reading application according to the given behavior.
°5u
°5uIf it uses terminal-style interaction, <a>Prefs</a> will be read from
°5uthe user's <tt>~/.haskeline</tt> file (if present). If it uses
°5ufile-style interaction, <a>Prefs</a> are not relevant and will not be
°5uread.
runInputTBehavior :: MonadException m => Behavior -> Settings m -> InputT m a -> m a

-- | Read input from <a>stdin</a>. Use terminal-style interaction if
°5u<a>stdin</a> is connected to a terminal and has echoing enabled.
°5uOtherwise (e.g., if <a>stdin</a> is a pipe), use file-style
°5uinteraction.
°5u
°5uThis behavior should suffice for most applications.
defaultBehavior :: Behavior

-- | Use file-style interaction, reading input from the given
°5u<a>Handle</a>.
useFileHandle :: Handle -> Behavior

-- | Use file-style interaction, reading input from the given file.
useFile :: FilePath -> Behavior

-- | Use terminal-style interaction whenever possible, even if <a>stdin</a>
°5uand/or <a>stdout</a> are not terminals.
°5u
°5uIf it cannot open the user's terminal, use file-style interaction,
°5ureading input from <a>stdin</a>.
preferTerm :: Behavior

-- | Reads one line of input. The final newline (if any) is removed. When
°5uusing terminal-style interaction, this function provides a rich
°5uline-editing user interface.
°5u
°5uIf <tt><a>autoAddHistory</a> == <a>True</a></tt> and the line input is
°5unonblank (i.e., is not all spaces), it will be automatically added to
°5uthe history.
getInputLine :: MonadException m => String -> InputT m (Maybe String)

-- | Reads one line of input and fills the insertion space with initial
°5utext. When using terminal-style interaction, this function provides a
°5urich line-editing user interface with the added ability to give the
°5uuser default values.
°5u
°5uThis function behaves in the exact same manner as <a>getInputLine</a>,
°5uexcept that it pre-populates the input area. The text that resides in
°5uthe input area is given as a 2-tuple with two <a>String</a>s. The
°5ustring on the left of the tuple (obtained by calling <a>fst</a>) is
°5uwhat will appear to the left of the cursor and the string on the right
°5u(obtained by calling <a>snd</a>) is what will appear to the right of
°5uthe cursor.
°5u
°5uSome examples of calling of this function are:
°5u
°5u<pre>
°5ugetInputLineWithInitial "prompt&gt; " ("left", "") -- The cursor starts at the end of the line.
°5ugetInputLineWithInitial "prompt&gt; " ("left ", "right") -- The cursor starts before the second word.
°5u</pre>
getInputLineWithInitial :: MonadException m => String -> (String, String) -> InputT m (Maybe String)

-- | Reads one character of input. Ignores non-printable characters.
°5u
°5uWhen using terminal-style interaction, the character will be read
°5uwithout waiting for a newline.
°5u
°5uWhen using file-style interaction, a newline will be read if it is
°5uimmediately available after the input character.
getInputChar :: MonadException m => String -> InputT m (Maybe Char)

-- | Reads one line of input, without displaying the input while it is
°5ubeing typed. When using terminal-style interaction, the masking
°5ucharacter (if given) will replace each typed character.
°5u
°5uWhen using file-style interaction, this function turns off echoing
°5uwhile reading the line of input.
°5u
°5uNote that if Haskeline is built against a version of the
°5u<tt>Win32</tt> library earlier than 2.5, <a>getPassword</a> will
°5uincorrectly echo back input on MinTTY consoles (such as Cygwin or
°5uMSYS).
getPassword :: MonadException m => Maybe Char -> String -> InputT m (Maybe String)

-- | Write a Unicode string to the user's standard output.
outputStr :: MonadIO m => String -> InputT m ()

-- | Write a string to the user's standard output, followed by a newline.
outputStrLn :: MonadIO m => String -> InputT m ()

-- | Return a printing function, which in terminal-style interactions is
°5uthread-safe and may be run concurrently with user input without
°5uaffecting the prompt.
getExternalPrint :: MonadException m => InputT m (String -> IO ())

-- | Application-specific customizations to the user interface.
data Settings m
Settings :: CompletionFunc m -> Maybe FilePath -> Bool -> Settings m

-- | Custom tab completion.
[complete] :: Settings m -> CompletionFunc m

-- | Where to read/write the history at the start and end of each line
°5uinput session.
[historyFile] :: Settings m -> Maybe FilePath

-- | If <a>True</a>, each nonblank line returned by <tt>getInputLine</tt>
°5uwill be automatically added to the history.
[autoAddHistory] :: Settings m -> Bool

-- | A useful default. In particular:
°5u
°5u<pre>
°5udefaultSettings = Settings {
°5u          complete = completeFilename,
°5u          historyFile = Nothing,
°5u          autoAddHistory = True
°5u          }
°5u</pre>
defaultSettings :: MonadIO m => Settings m

-- | Because <a>complete</a> is the only field of <a>Settings</a> depending
°5uon <tt>m</tt>, the expression <tt>defaultSettings {completionFunc =
°5uf}</tt> leads to a type error from being too general. This function
°5uworks around that issue, and may become unnecessary if another field
°5udepending on <tt>m</tt> is added.
setComplete :: CompletionFunc m -> Settings m -> Settings m

-- | <a>Prefs</a> allow the user to customize the terminal-style
°5uline-editing interface. They are read by default from
°5u<tt>~/.haskeline</tt>; to override that behavior, use <a>readPrefs</a>
°5uand <tt>runInputTWithPrefs</tt>.
°5u
°5uEach line of a <tt>.haskeline</tt> file defines one field of the
°5u<a>Prefs</a> datatype; field names are case-insensitive and
°5uunparseable lines are ignored. For example:
°5u
°5u<pre>
°5ueditMode: Vi
°5ucompletionType: MenuCompletion
°5umaxhistorysize: Just 40
°5u</pre>
data Prefs

-- | Read <a>Prefs</a> from a given file. If there is an error reading the
°5ufile, the <a>defaultPrefs</a> will be returned.
readPrefs :: FilePath -> IO Prefs

-- | The default preferences which may be overwritten in the
°5u<tt>.haskeline</tt> file.
defaultPrefs :: Prefs

-- | Run a line-reading application. Uses <a>defaultBehavior</a> to
°5udetermine the interaction behavior.
runInputTWithPrefs :: MonadException m => Prefs -> Settings m -> InputT m a -> m a

-- | Run a line-reading application.
runInputTBehaviorWithPrefs :: MonadException m => Behavior -> Prefs -> Settings m -> InputT m a -> m a

-- | Get the current line input history.
getHistory :: MonadIO m => InputT m History

-- | Set the line input history.
putHistory :: MonadIO m => History -> InputT m ()

-- | Change the current line input history.
modifyHistory :: MonadIO m => (History -> History) -> InputT m ()

-- | If Ctrl-C is pressed during the given action, throw an exception of
°5utype <a>Interrupt</a>. For example:
°5u
°5u<pre>
°5utryAction :: InputT IO ()
°5utryAction = handle (\Interrupt -&gt; outputStrLn "Cancelled.")
°5u               $ withInterrupt $ someLongAction
°5u</pre>
°5u
°5uThe action can handle the interrupt itself; a new <a>Interrupt</a>
°5uexception will be thrown every time Ctrl-C is pressed.
°5u
°5u<pre>
°5utryAction :: InputT IO ()
°5utryAction = withInterrupt loop
°5u    where loop = handle (\Interrupt -&gt; outputStrLn "Cancelled; try again." &gt;&gt; loop)
°5u                   someLongAction
°5u</pre>
°5u
°5uThis behavior differs from GHC's built-in Ctrl-C handling, which may
°5uimmediately terminate the program after the second time that the user
°5upresses Ctrl-C.
withInterrupt :: MonadException m => InputT m a -> InputT m a
data Interrupt
Interrupt :: Interrupt

-- | Catch and handle an exception of type <a>Interrupt</a>.
°5u
°5u<pre>
°5uhandleInterrupt f = handle $ \Interrupt -&gt; f
°5u</pre>
handleInterrupt :: MonadException m => m a -> m a -> m a


-- | This module provides a stateful, IO-based interface to Haskeline,
°5uwhich may be easier to integrate into some existing programs or
°5ulibraries.
°5u
°5uIt is strongly recommended to use the safer, monadic API of
°5u<a>System.Console.Haskeline</a>, if possible, rather than the explicit
°5ustate management functions of this module.
°5u
°5uThe equivalent REPL example is:
°5u
°5u<pre>
°5uimport System.Console.Haskeline
°5uimport System.Console.Haskeline.IO
°5uimport Control.Concurrent
°5u
°5umain = bracketOnError (initializeInput defaultSettings)
°5u            cancelInput -- This will only be called if an exception such
°5u                            -- as a SigINT is received.
°5u            (\hd -&gt; loop hd &gt;&gt; closeInput hd)
°5u    where
°5u        loop :: InputState -&gt; IO ()
°5u        loop hd = do
°5u            minput &lt;- queryInput hd (getInputLine "% ")
°5u            case minput of
°5u                Nothing -&gt; return ()
°5u                Just "quit" -&gt; return ()
°5u                Just input -&gt; do queryInput hd $ outputStrLn
°5u                                    $ "Input was: " ++ input
°5u                                 loop hd
°5u</pre>
module System.Console.Haskeline.IO
data InputState

-- | Initialize a session of line-oriented user interaction.
initializeInput :: Settings IO -> IO InputState

-- | Finish and clean up the line-oriented user interaction session. Blocks
°5uon an existing call to <a>queryInput</a>.
closeInput :: InputState -> IO ()

-- | Cancel and clean up the user interaction session. Does not block on an
°5uexisting call to <a>queryInput</a>.
cancelInput :: InputState -> IO ()

-- | Run one action (for example, <a>getInputLine</a>) as part of a session
°5uof user interaction.
°5u
°5uFor example, multiple calls to <a>queryInput</a> using the same
°5u<a>InputState</a> will share the same input history. In constrast,
°5umultiple calls to <a>runInputT</a> will use distinct histories unless
°5uthey share the same history file.
°5u
°5uThis function should not be called on a closed or cancelled
°5u<a>InputState</a>.
queryInput :: InputState -> InputT IO a -> IO a
