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


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

module System.Console.Haskeline.Completion

-- | Performs completions from the given line state.
--   
--   The first <a>String</a> argument is the contents of the line to the
--   left of the cursor, reversed. The second <a>String</a> argument is the
--   contents of the line to the right of the cursor.
--   
--   The output <a>String</a> is the unused portion of the left half of the
--   line, reversed.
type CompletionFunc (m :: Type -> Type) = (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

-- | If the first completer produces no suggestions, fallback to the second
--   completer's output.
fallbackCompletion :: Monad m => CompletionFunc m -> CompletionFunc m -> CompletionFunc m

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

-- | The same as <a>completeWord</a> but takes a predicate for the
--   whitespace characters
completeWord' :: Monad m => Maybe Char -> (Char -> Bool) -> (String -> m [Completion]) -> CompletionFunc m

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

-- | The same as <a>completeWordWithPrev</a> but takes a predicate for the
--   whitespace characters
completeWordWithPrev' :: Monad m => Maybe Char -> (Char -> Bool) -> (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.Internal.Classes.Eq System.Console.Haskeline.Completion.Completion
instance GHC.Internal.Classes.Ord System.Console.Haskeline.Completion.Completion
instance GHC.Internal.Show.Show System.Console.Haskeline.Completion.Completion


-- | This module provides a low-level API to the line history stored in the
--   <tt>InputT</tt> monad transformer.
--   
--   For most application, it should suffice to instead use the following
--   <tt>Settings</tt> flags:
--   
--   <ul>
--   <li><tt>autoAddHistory</tt>: add nonblank lines to the command history
--   (<a>True</a> by default).</li>
--   <li><tt>historyFile</tt>: read/write the history to a file before and
--   after the line input session.</li>
--   </ul>
--   
--   If you do want custom history behavior, you may need to disable the
--   above 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
--   line.
addHistoryUnlessConsecutiveDupe :: String -> History -> History

-- | Add a line to the history, and remove all previous entries which are
--   the 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
--   <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
--   writing 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>,
--   the history storage is unlimited.
stifleAmount :: History -> Maybe Int
instance GHC.Internal.Show.Show System.Console.Haskeline.History.History


-- | Provides an interface for <a>ReaderT</a> rather than <a>InputT</a>.
module System.Console.Haskeline.ReaderT

-- | Maps an <a>InputT</a> to a <a>ReaderT</a>. Useful for lifting
--   <a>InputT</a> functions into some other reader-like monad.
--   
--   <b>Examples:</b>
--   
--   <pre>
--   import System.Console.Haskeline qualified as H
--   
--   runApp :: ReaderT (InputTEnv IO) IO ()
--   runApp = do
--     input &lt;- toReaderT (H.getInputLine "Enter your name: ")
--     ...
--   </pre>
--   
--   <pre>
--   -- MTL-style polymorphism
--   class MonadHaskeline m where
--     getInputLine :: String -&gt; m (Maybe String)
--   
--   -- AppT is the core type over ReaderT.
--   instance MonadHaskeline (AppT m) where
--     getInputLine = lift . toReaderT . H.getInputLine
--   
--   runApp :: (MonadHaskeline m) =&gt; m ()
--   runApp = do
--     input &lt;- getInputLine "Enter your name: "
--     ...
--   </pre>
toReaderT :: InputT m a -> ReaderT (InputTEnv m) m a

-- | Maps a <a>ReaderT</a> to an <a>InputT</a>. Allows defining an
--   application in terms of <a>ReaderT</a>.
--   
--   <b>Examples:</b>
--   
--   <pre>
--   import System.Console.Haskeline qualified as H
--   
--   -- Could be generalized to MonadReader, effects libraries.
--   runApp :: ReaderT (InputTEnv IO) IO ()
--   
--   main :: IO ()
--   main = H.runInputT H.defaultSettings $ fromReaderT runApp
--   </pre>
fromReaderT :: ReaderT (InputTEnv m) m a -> InputT m a

-- | The abstract environment used by <a>InputT</a>, for <a>ReaderT</a>
--   usage.
data InputTEnv (m :: Type -> Type)

-- | Maps the environment.
mapInputTEnv :: (forall x. () => m x -> n x) -> InputTEnv m -> InputTEnv n


-- | A rich user interface for line input in command-line programs.
--   Haskeline is Unicode-aware and runs both on POSIX-compatible systems
--   and on Windows.
--   
--   Users may customize the interface with a <tt>~/.haskeline</tt> file;
--   see <a>https://github.com/judah/haskeline/wiki/UserPreferences</a> for
--   more information.
--   
--   An example use of this library for a simple read-eval-print loop
--   (REPL) is the following:
--   
--   <pre>
--   import System.Console.Haskeline
--   
--   main :: IO ()
--   main = runInputT defaultSettings loop
--      where
--          loop :: InputT IO ()
--          loop = do
--              minput &lt;- getInputLine "% "
--              case minput of
--                  Nothing -&gt; return ()
--                  Just "quit" -&gt; return ()
--                  Just input -&gt; do outputStrLn $ "Input was: " ++ input
--                                   loop
--   </pre>
module System.Console.Haskeline

-- | A monad transformer which carries all of the state and settings
--   relevant to a line-reading application.
data InputT (m :: Type -> Type) a

-- | Run a line-reading application. This function should suffice for most
--   applications.
--   
--   This function is equivalent to <tt><a>runInputTBehavior</a>
--   <a>defaultBehavior</a></tt>. It uses terminal-style interaction if
--   <a>stdin</a> is connected to a terminal and has echoing enabled.
--   Otherwise (e.g., if <a>stdin</a> is a pipe), it uses file-style
--   interaction.
--   
--   If it uses terminal-style interaction, <a>Prefs</a> will be read from
--   the user's <tt>~/.haskeline</tt> file (if present). If it uses
--   file-style interaction, <a>Prefs</a> are not relevant and will not be
--   read.
runInputT :: (MonadIO m, MonadMask m) => Settings m -> InputT m a -> m a

-- | Returns <a>True</a> if the current session uses terminal-style
--   interaction. (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:
--   
--   <ul>
--   <li>"Terminal-style" interaction provides an rich user interface by
--   connecting to the user's terminal (which may be different than
--   <a>stdin</a> or <a>stdout</a>).</li>
--   <li>"File-style" interaction treats the input as a simple stream of
--   characters, for example when reading from a file or pipe. Input
--   functions (e.g., <tt>getInputLine</tt>) print the prompt to
--   <a>stdout</a>.</li>
--   </ul>
--   
--   A <a>Behavior</a> is a method for deciding at run-time which type of
--   interaction to use.
--   
--   For most applications (e.g., a REPL), <a>defaultBehavior</a> should
--   have the correct effect.
data Behavior

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

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

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

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

-- | Use terminal-style interaction on the given input and output handles,
--   taking the terminal type from the <tt>TERM</tt> environment variable.
--   
--   This behavior is for driving Haskeline against a terminal that is not
--   the process's controlling terminal — for example, a serial console, a
--   PTY pair you opened yourself, or a socket-backed TTY. The caller is
--   responsible for closing <tt>input</tt> and <tt>output</tt> after use.
--   Not available on Windows.
--   
--   See <a>useTermHandlesWith</a> to override the terminal type.
useTermHandles :: Handle -> Handle -> Behavior

-- | Like <a>useTermHandles</a>, but with the terminal type given
--   explicitly (e.g. <tt>"xterm-256color"</tt> or <tt>"vt100"</tt>)
--   instead of read from the <tt>TERM</tt> environment variable.
--   
--   The terminal type is only consulted when haskeline is built with
--   terminfo support; in non-terminfo builds it is ignored and a dumb
--   terminal is used.
--   
--   <h4><b>Example: a Haskeline session over a WebSocket</b></h4>
--   
--   Bridge a WebSocket to the master end of a PTY pair and run Haskeline
--   against the slave end. Uses the <tt>websockets</tt> and <tt>unix</tt>
--   packages. Pair this with a browser-side terminal emulator such as
--   <a>Xterm.js</a> for an in-browser shell.
--   
--   <pre>
--   import qualified Network.WebSockets as WS
--   import System.Posix.Terminal (openPseudoTerminal)
--   import System.Posix.IO (dup, fdToHandle)
--   import Control.Applicative ((&lt;|&gt;))
--   import Control.Concurrent.Async (Concurrently(..), runConcurrently)
--   import Control.Monad (forever)
--   import qualified Data.ByteString as BS
--   import System.IO (hSetBuffering, BufferMode(..))
--   import System.Console.Haskeline
--   
--   websocketUI :: WS.Connection -&gt; IO ()
--   websocketUI conn = do
--       (master, slave) &lt;- openPseudoTerminal
--       slaveDup &lt;- dup slave
--       masterH  &lt;- fdToHandle master
--       slaveIn  &lt;- fdToHandle slave
--       slaveOut &lt;- fdToHandle slaveDup
--       hSetBuffering masterH NoBuffering
--       -- Whichever of the three actions finishes first cancels the others.
--       runConcurrently
--           $   Concurrently (forever $ WS.receiveData conn &gt;&gt;= BS.hPut masterH)
--           &lt;|&gt; Concurrently (forever $ BS.hGetSome masterH 4096 &gt;&gt;= WS.sendBinaryData conn)
--           &lt;|&gt; Concurrently (runInputTBehavior
--                                (useTermHandlesWith "vt100" slaveIn slaveOut)
--                                defaultSettings loop)
--     where
--       loop = do
--           minput &lt;- getInputLine "% "
--           case minput of
--               Nothing     -&gt; return ()
--               Just "quit" -&gt; return ()
--               Just s      -&gt; outputStrLn ("got: " ++ s) &gt;&gt; loop
--   </pre>
useTermHandlesWith :: String -> Handle -> Handle -> Behavior

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

-- | Reads one line of input. The final newline (if any) is removed. When
--   using terminal-style interaction, this function provides a rich
--   line-editing user interface.
--   
--   If <tt><a>autoAddHistory</a> == <a>True</a></tt> and the line input is
--   nonblank (i.e., is not all spaces), it will be automatically added to
--   the history.
--   
--   To include ANSI escape sequences in the input prompt, terminate them
--   by <tt>STX</tt>. See
--   <a>https://github.com/haskell/haskeline/wiki/ControlSequencesInPrompt</a>
--   for more information.
getInputLine :: (MonadIO m, MonadMask m) => String -> InputT m (Maybe String)

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

-- | Reads one character of input. Ignores non-printable characters.
--   
--   When using terminal-style interaction, the character will be read
--   without waiting for a newline.
--   
--   When using file-style interaction, a newline will be read if it is
--   immediately available after the input character.
getInputChar :: (MonadIO m, MonadMask m) => String -> InputT m (Maybe Char)

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

-- | Waits for one key to be pressed, then returns. Ignores the value of
--   the specific key.
--   
--   Returns <a>True</a> if it successfully accepted one key. Returns
--   <a>False</a> if it encountered the end of input; i.e., an <tt>EOF</tt>
--   in file-style interaction, or a <tt>Ctrl-D</tt> in terminal-style
--   interaction.
--   
--   When using file-style interaction, consumes a single character from
--   the input which may be non-printable.
waitForAnyKey :: (MonadIO m, MonadMask m) => String -> InputT m Bool

-- | 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
--   thread-safe and may be run concurrently with user input without
--   affecting the prompt.
getExternalPrint :: MonadIO m => InputT m (String -> IO ())

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

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

-- | Where to read/write the history at the start and end of each line
--   input session.
[historyFile] :: Settings (m :: Type -> Type) -> Maybe FilePath

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

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

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

-- | <a>Prefs</a> allow the user to customize the terminal-style
--   line-editing interface. They are read by default from
--   <tt>~/.haskeline</tt>; to override that behavior, use <a>readPrefs</a>
--   and <tt>runInputTWithPrefs</tt>.
--   
--   Each line of a <tt>.haskeline</tt> file defines one field of the
--   <a>Prefs</a> datatype; field names are case-insensitive and
--   unparseable lines are ignored. For example:
--   
--   <pre>
--   editMode: Vi
--   completionType: MenuCompletion
--   maxhistorysize: Just 40
--   </pre>
data Prefs

-- | After an <tt>ESC</tt> byte is read, how long to wait (in milliseconds)
--   for the rest of an escape sequence before treating the <tt>ESC</tt> as
--   a standalone keypress. Matters on slow links (e.g. low-bandwidth
--   serial), where the bytes of a sequence such as <tt>\ESC[A</tt> may not
--   arrive in a single read. Mirrors GNU Readline's
--   <tt>keyseq-timeout</tt>.
keyseqTimeoutMs :: Prefs -> Word

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

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

-- | Run a line-reading application. Uses <a>defaultBehavior</a> to
--   determine the interaction behavior.
runInputTWithPrefs :: (MonadIO m, MonadMask m) => Prefs -> Settings m -> InputT m a -> m a

-- | Run a line-reading application.
runInputTBehaviorWithPrefs :: (MonadIO m, MonadMask m) => Behavior -> Prefs -> Settings m -> InputT m a -> m a

-- | Run an action in the underlying monad, as per <a>lift</a>, passing it
--   a runner function which restores the current <a>InputT</a> context.
--   This can be used in the event that we have some function that takes an
--   action in the underlying monad as an argument (such as <a>lift</a>,
--   <tt>hoist</tt>, <tt>forkIO</tt>, etc) and we want to compose it with
--   actions in <a>InputT</a>.
withRunInBase :: Monad m => ((forall a. () => InputT m a -> m a) -> m b) -> InputT m b

-- | 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
--   type <a>Interrupt</a>. For example:
--   
--   <pre>
--   tryAction :: InputT IO ()
--   tryAction = handleInterrupt (outputStrLn "Cancelled.")
--                  $ withInterrupt $ someLongAction
--   </pre>
--   
--   The action can handle the interrupt itself; a new <a>Interrupt</a>
--   exception will be thrown every time Ctrl-C is pressed.
--   
--   <pre>
--   tryAction :: InputT IO ()
--   tryAction = withInterrupt loop
--       where loop = handleInterrupt (outputStrLn "Cancelled; try again." &gt;&gt; loop)
--                      someLongAction
--   </pre>
--   
--   This behavior differs from GHC's built-in Ctrl-C handling, which may
--   immediately terminate the program after the second time that the user
--   presses Ctrl-C.
withInterrupt :: (MonadIO m, MonadMask m) => InputT m a -> InputT m a
data Interrupt
Interrupt :: Interrupt

-- | Catch and handle an exception of type <a>Interrupt</a>. See
--   <a>withInterrupt</a> for more explanation.
--   
--   <pre>
--   handleInterrupt (outputStrLn "Ctrl+C was pressed, aborting!") someLongAction
--   </pre>
handleInterrupt :: MonadMask m => m a -> m a -> m a


-- | A module containing semi-public internals. The functions here are not
--   stable.
module System.Console.Haskeline.Internal
asks :: MonadReader r m => (r -> a) -> m a
evalStateT' :: Monad m => s -> StateT s m a -> m a
gets :: MonadState s m => (s -> a) -> m a
modify :: MonadState s m => (s -> s) -> m ()
orElse :: Monad m => MaybeT m a -> m a -> m a
runReaderT' :: r -> ReaderT r m a -> m a
update :: MonadState s m => (s -> (a, s)) -> m a

-- | Transform the computation inside a <tt>ReaderT</tt>.
--   
--   <ul>
--   <li><pre><a>runReaderT</a> (<a>mapReaderT</a> f m) = f .
--   <a>runReaderT</a> m</pre></li>
--   </ul>
mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b

-- | Map both the return value and final state of a computation using the
--   given function.
--   
--   <ul>
--   <li><pre><a>runStateT</a> (<a>mapStateT</a> f m) = f .
--   <a>runStateT</a> m</pre></li>
--   </ul>
mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
class Monad m => MonadIO (m :: Type -> Type)
liftIO :: MonadIO m => IO a -> m a
class Monad m => MonadReader r (m :: Type -> Type)
ask :: MonadReader r m => m r
class Monad m => MonadState s (m :: Type -> Type)
get :: MonadState s m => m s
put :: MonadState s m => s -> m ()

-- | The class of monad transformers. For any monad <tt>m</tt>, the result
--   <tt>t m</tt> should also be a monad, and <a>lift</a> should be a monad
--   transformation from <tt>m</tt> to <tt>t m</tt>, i.e. it should satisfy
--   the following laws:
--   
--   <ul>
--   <li><pre><a>lift</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>lift</a> (m &gt;&gt;= f) = <a>lift</a> m &gt;&gt;=
--   (<a>lift</a> . f)</pre></li>
--   </ul>
--   
--   Since 0.6.0.0 and for GHC 8.6 and later, the requirement that <tt>t
--   m</tt> be a <a>Monad</a> is enforced by the implication constraint
--   <tt>forall m. <a>Monad</a> m =&gt; <a>Monad</a> (t m)</tt> enabled by
--   the <tt>QuantifiedConstraints</tt> extension.
--   
--   <h3><b>Ambiguity error with GHC 9.0 to 9.2.2</b></h3>
--   
--   These versions of GHC have a bug
--   (<a>https://gitlab.haskell.org/ghc/ghc/-/issues/20582</a>) which
--   causes constraints like
--   
--   <pre>
--   (MonadTrans t, forall m. Monad m =&gt; Monad (t m)) =&gt; ...
--   </pre>
--   
--   to be reported as ambiguous. For transformers 0.6 and later, this can
--   be fixed by removing the second constraint, which is implied by the
--   first.
class forall m. Monad m => Monad t m => MonadTrans (t :: Type -> Type -> Type -> Type)

-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, Monad m) => m a -> t m a

-- | The parameterizable maybe monad, a strict monad obtained by composing
--   an arbitrary monad with the <a>Maybe</a> monad.
--   
--   Computations are actions that may produce a value or exit.
--   
--   The <a>return</a> function yields a computation that produces that
--   value, while <tt>&gt;&gt;=</tt> sequences two subcomputations, exiting
--   if either computation does.
newtype MaybeT (m :: Type -> Type) a
MaybeT :: m (Maybe a) -> MaybeT (m :: Type -> Type) a
[runMaybeT] :: MaybeT (m :: Type -> Type) a -> m (Maybe a)

-- | The reader monad transformer, which adds a read-only environment to
--   the given monad.
--   
--   The <a>return</a> function ignores the environment, while <tt>m
--   <a>&gt;&gt;=</a> k</tt> passes the inherited environment to both
--   subcomputations:
--   
--   
--   <tt>ReaderT r m</tt> is strict if and only if <tt>m</tt> is.
data ReaderT r (m :: Type -> Type) a

-- | A state transformer monad parameterized by:
--   
--   <ul>
--   <li><tt>s</tt> - The state.</li>
--   <li><tt>m</tt> - The inner monad.</li>
--   </ul>
--   
--   The <a>return</a> function leaves the state unchanged, while
--   <tt>&gt;&gt;=</tt> uses the final state of the first computation as
--   the initial state of the second.
data StateT s (m :: Type -> Type) a

-- | Utility function for changing a property of a terminal for the
--   duration of a computation.
bracketSet :: (MonadMask m, MonadIO m) => IO a -> (a -> IO ()) -> a -> m b -> m b
clearLine :: Term m => LineChars -> m ()
drawLine :: Term m => LineChars -> m ()
flushEventQueue :: (String -> IO ()) -> TChan Event -> IO ()
guardedEOF :: (Handle -> IO a) -> Handle -> MaybeT IO a

-- | Returns one 8-bit word. Needs to be wrapped by hWithBinaryMode.
hGetByte :: Handle -> MaybeT IO Word8

-- | Utility function to correctly get a line of input as an undecoded
--   ByteString.
hGetLocaleLine :: Handle -> MaybeT IO ByteString
hMaybeReadNewline :: Handle -> IO ()

-- | Utility function since we're not using the new IO library yet.
hWithBinaryMode :: (MonadIO m, MonadMask m) => Handle -> m a -> m a

-- | Are we using terminal-style interaction?
isTerminalStyle :: RunTerm -> Bool
keyEventLoop :: IO [Event] -> TChan Event -> IO Event
mapEvalTerm :: (forall a. () => n a -> m a) -> (forall a. () => m a -> n a) -> EvalTerm n -> EvalTerm m
matchInit :: Eq a => [a] -> [a] -> ([a], [a])
returnOnEOF :: MonadMask m => a -> m a -> m a
saveKeys :: TChan Event -> [Key] -> IO ()
class (MonadReader Prefs m, MonadReader Layout m, MonadIO m, MonadMask m) => CommandMonad (m :: Type -> Type)
runCompletion :: CommandMonad m => (String, String) -> m (String, [Completion])
data EvalTerm (m :: Type -> Type)
EvalTerm :: (forall a. () => n a -> m a) -> (forall a. () => m a -> n a) -> EvalTerm (m :: Type -> Type)
data Event
WindowResize :: Event
KeyInput :: [Key] -> Event
ErrorEvent :: SomeException -> Event
ExternalPrint :: String -> Event

-- | Operations needed for file-style interaction.
--   
--   Backends can assume that getLocaleLine, getLocaleChar and
--   maybeReadNewline are "wrapped" by wrapFileInput.
data FileOps
FileOps :: (forall m a. (MonadIO m, MonadMask m) => m a -> m a) -> (forall a. () => IO a -> IO a) -> MaybeT IO String -> MaybeT IO Char -> IO () -> FileOps

-- | Perform an action without echoing input.
[withoutInputEcho] :: FileOps -> forall m a. (MonadIO m, MonadMask m) => m a -> m a
[wrapFileInput] :: FileOps -> forall a. () => IO a -> IO a
[getLocaleLine] :: FileOps -> MaybeT IO String
[getLocaleChar] :: FileOps -> MaybeT IO Char
[maybeReadNewline] :: FileOps -> IO ()
data Interrupt
Interrupt :: Interrupt
data Layout
Layout :: Int -> Int -> Layout
[width] :: Layout -> Int
[height] :: Layout -> Int
data RunTerm
RunTerm :: (String -> IO ()) -> Either TermOps FileOps -> (forall a m. (MonadIO m, MonadMask m) => m a -> m a) -> IO () -> RunTerm

-- | Write unicode characters to stdout.
[putStrOut] :: RunTerm -> String -> IO ()
[termOps] :: RunTerm -> Either TermOps FileOps
[wrapInterrupt] :: RunTerm -> forall a m. (MonadIO m, MonadMask m) => m a -> m a
[closeTerm] :: RunTerm -> IO ()
class (MonadReader Layout m, MonadIO m, MonadMask m) => Term (m :: Type -> Type)
reposition :: Term m => Layout -> LineChars -> m ()
moveToNextLine :: Term m => LineChars -> m ()
printLines :: Term m => [String] -> m ()
drawLineDiff :: Term m => LineChars -> LineChars -> m ()
clearLayout :: Term m => m ()
ringBell :: Term m => Bool -> m ()

-- | Operations needed for terminal-style interaction.
data TermOps
TermOps :: IO Layout -> (forall m a. CommandMonad m => (m Event -> m a) -> m a) -> (forall m. CommandMonad m => EvalTerm m) -> ([Key] -> IO ()) -> (String -> IO ()) -> TermOps
[getLayout] :: TermOps -> IO Layout
[withGetEvent] :: TermOps -> forall m a. CommandMonad m => (m Event -> m a) -> m a
[evalTerm] :: TermOps -> forall m. CommandMonad m => EvalTerm m
[saveUnusedKeys] :: TermOps -> [Key] -> IO ()
[externalPrint] :: TermOps -> String -> IO ()
ctrlChar :: Char -> Key
ctrlKey :: Key -> Key
metaChar :: Char -> Key
metaKey :: Key -> Key
noModifier :: Modifier
parseKey :: String -> Maybe Key
setControlBits :: Char -> Char
simpleChar :: Char -> Key
simpleKey :: BaseKey -> Key
data BaseKey
KeyChar :: Char -> BaseKey
FunKey :: Int -> BaseKey
LeftKey :: BaseKey
RightKey :: BaseKey
DownKey :: BaseKey
UpKey :: BaseKey
KillLine :: BaseKey
Home :: BaseKey
End :: BaseKey
PageDown :: BaseKey
PageUp :: BaseKey
Backspace :: BaseKey
Delete :: BaseKey
SearchReverse :: BaseKey
SearchForward :: BaseKey
data Key
Key :: Modifier -> BaseKey -> Key
data Modifier
Modifier :: Bool -> Bool -> Bool -> Modifier
[hasControl] :: Modifier -> Bool
[hasMeta] :: Modifier -> Bool
[hasShift] :: Modifier -> Bool
addNum :: Int -> ArgMode s -> ArgMode s
addPasswordChar :: Char -> Password -> Password
afterChar :: (Char -> Bool) -> InsertMode -> Bool
appendFromCommandMode :: CommandMode -> InsertMode
applyArg :: (s -> s) -> ArgMode s -> s
applyCmdArg :: (InsertMode -> InsertMode) -> ArgMode CommandMode -> CommandMode
atEnd :: (Char -> Bool) -> InsertMode -> Bool
atStart :: (Char -> Bool) -> InsertMode -> Bool
baseChar :: Grapheme -> Char
beforeChar :: (Char -> Bool) -> InsertMode -> Bool
deleteChar :: CommandMode -> CommandMode
deleteNext :: InsertMode -> InsertMode
deletePasswordChar :: Password -> Password
deletePrev :: InsertMode -> InsertMode
emptyIM :: InsertMode
enterCommandMode :: InsertMode -> CommandMode
enterCommandModeRight :: InsertMode -> CommandMode
goLeftUntil :: (InsertMode -> Bool) -> InsertMode -> InsertMode
goRightUntil :: (InsertMode -> Bool) -> InsertMode -> InsertMode
graphemesToString :: [Grapheme] -> String

-- | Insert one character, which may be combining, to the left of the
--   cursor.
insertChar :: Char -> InsertMode -> InsertMode
insertFromCommandMode :: CommandMode -> InsertMode
insertGraphemes :: [Grapheme] -> InsertMode -> InsertMode

-- | Insert a sequence of characters to the left of the cursor.
insertString :: String -> InsertMode -> InsertMode

-- | Compute the number of characters under and to the right of the cursor.
lengthToEnd :: LineChars -> Int

-- | Accessor function for the various backends.
lineChars :: LineState s => Prefix -> s -> LineChars
listRestore :: Save s => [Grapheme] -> s
listSave :: Save s => s -> [Grapheme]
mapBaseChars :: (Char -> Char) -> [Grapheme] -> [Grapheme]
modifyBaseChar :: (Char -> Char) -> Grapheme -> Grapheme
overChar :: (Char -> Bool) -> InsertMode -> Bool
pasteGraphemesAfter :: [Grapheme] -> CommandMode -> CommandMode
pasteGraphemesBefore :: [Grapheme] -> CommandMode -> CommandMode
replaceChar :: Char -> CommandMode -> CommandMode
replaceCharIM :: Char -> InsertMode -> InsertMode
skipLeft :: (Char -> Bool) -> InsertMode -> InsertMode
skipRight :: (Char -> Bool) -> InsertMode -> InsertMode
startArg :: Int -> s -> ArgMode s

-- | Converts a string into a sequence of graphemes.
--   
--   NOTE: Drops any initial, unattached combining characters.
stringToGraphemes :: String -> [Grapheme]
transposeChars :: InsertMode -> InsertMode
withCommandMode :: (InsertMode -> InsertMode) -> CommandMode -> CommandMode

-- | Used for commands which take an integer argument.
data ArgMode s
ArgMode :: Int -> s -> ArgMode s
[arg] :: ArgMode s -> Int
[argState] :: ArgMode s -> s

-- | Used by vi mode. Considers the cursor to be located over some specific
--   character. The first list is reversed.
data CommandMode
CMode :: [Grapheme] -> Grapheme -> [Grapheme] -> CommandMode
CEmpty :: CommandMode

-- | A <a>Grapheme</a> is a fundamental unit of display for the UI. Several
--   characters in sequence can represent one grapheme; for example, an
--   <tt>a</tt> followed by the diacritic <tt>'\768'</tt> should be treated
--   as one unit.
data Grapheme

-- | The standard line state representation; considers the cursor to be
--   located between two characters. The first list is reversed.
data InsertMode
IMode :: [Grapheme] -> [Grapheme] -> InsertMode

-- | The characters in the line (with the cursor in the middle). NOT in a
--   zippered format; both lists are in the order left-&gt;right that
--   appears on the screen.
type LineChars = ([Grapheme], [Grapheme])

-- | This class abstracts away the internal representations of the line
--   state, for use by the drawing actions. Line state is generally stored
--   in a zipper format.
class LineState s
beforeCursor :: LineState s => Prefix -> s -> [Grapheme]
afterCursor :: LineState s => s -> [Grapheme]
newtype Message
Message :: String -> Message
[messageText] :: Message -> String
class Move s
goLeft :: Move s => s -> s
goRight :: Move s => s -> s
moveToStart :: Move s => s -> s
moveToEnd :: Move s => s -> s
data Password
Password :: [Char] -> Maybe Char -> Password

-- | reversed
[passwordState] :: Password -> [Char]
[passwordChar] :: Password -> Maybe Char
type Prefix = [Grapheme]
class LineState s => Result s
toResult :: Result s => s -> String
class LineState s => Save s
save :: Save s => s -> InsertMode
restore :: Save s => InsertMode -> s

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

-- | This function may be used to debug Haskeline's input.
--   
--   It loops indefinitely; every time a key is pressed, it will print that
--   key as it was recognized by Haskeline. Pressing Ctrl-C will stop the
--   loop.
--   
--   Haskeline's behavior may be modified by editing your
--   <tt>~/.haskeline</tt> file. For details, see:
--   <a>https://github.com/judah/haskeline/wiki/CustomKeyBindings</a>
debugTerminalKeys :: IO a


-- | 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
--   <a>System.Console.Haskeline</a>, if possible, rather than the explicit
--   state management functions of this module.
--   
--   The equivalent REPL example is:
--   
--   <pre>
--   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 -&gt; loop hd &gt;&gt; closeInput hd)
--       where
--           loop :: InputState -&gt; IO ()
--           loop hd = do
--               minput &lt;- queryInput hd (getInputLine "% ")
--               case minput of
--                   Nothing -&gt; return ()
--                   Just "quit" -&gt; return ()
--                   Just input -&gt; do queryInput hd $ outputStrLn
--                                       $ "Input was: " ++ input
--                                    loop hd
--   </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
--   on an existing call to <a>queryInput</a>.
closeInput :: InputState -> IO ()

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

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