HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulehaskeline-0.8.5.0Haskell98

System.Console.Haskeline.Internal

A module containing semi-public internals. The functions here are not stable.

  • 22 types
  • 10 classes
  • 77 values
  • Packagehaskeline-0.8.5.0
  • Exports109
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceInternal.hs
classclass Monad m => MonadIO (m :: Type -> Type) where
#

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

  • liftIO :: IO a -> m a

    Lift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).

    Example
    import Control.Monad.Trans.State -- from the "transformers" library
    
    printState :: Show s => StateT s IO ()
    printState = do
      state <- get
      liftIO $ print state

    Had we omitted liftIO, we would have ended up with this error:

    • Couldn't match type ‘IO’ with ‘StateT s IO’
     Expected type: StateT s IO ()
       Actual type: IO ()

    The important part here is the mismatch between StateT s IO () and IO ().

    Luckily, we know of a function that takes an IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"
    
    > evalStateT printState 3
    3
    
Instances21MonadIO, …
classclass Monad m => MonadReader r (m :: Type -> Type) where
#

Methods

Instances7MonadReader, …
  • Monad m => MonadReader Handles (DumbTerm m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.DumbTerm
  • Monad m => MonadReader Handles (Draw m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.Terminfo
  • Monad m => MonadReader Actions (Draw m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.Terminfo
  • Monad m => MonadReader Terminal (Draw m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.Terminfo
  • (MonadReader r m, MonadTrans t, Monad (t m)) => MonadReader r (t m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Monads
  • Monad m => MonadReader r (ReaderT r m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Monads
  • Monad m => MonadReader s (StateT s m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Monads
classclass Monad m => MonadState s (m :: Type -> Type) where
#

Methods

Instances6MonadState
  • Monad m => MonadState Window (DumbTerm m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.DumbTerm
  • Monad m => MonadState TermPos (Draw m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.Terminfo
  • Monad m => MonadState TermRows (Draw m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.Terminfo
  • (MonadState s m, MonadTrans t, Monad (t m)) => MonadState s (t m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Monads
  • Monad m => MonadState s (StateT s m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Monads
  • MonadIO m => MonadState s (ReaderT (IORef s) m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.Monads
classclass (forall (m :: Type -> Type). Monad m => Monad (t m)) => MonadTrans (t :: (Type -> Type) -> Type -> Type) where
#

The class of monad transformers. For any monad m, the result t m should also be a monad, and lift should be a monad transformation from m to t m, i.e. it should satisfy the following laws:

Since 0.6.0.0 and for GHC 8.6 and later, the requirement that t m be a Monad is enforced by the implication constraint forall m. Monad m => Monad (t m) enabled by the QuantifiedConstraints extension.

Ambiguity error with GHC 9.0 to 9.2.2

These versions of GHC have a bug (https://gitlab.haskell.org/ghc/ghc/-/issues/20582) which causes constraints like

(MonadTrans t, forall m. Monad m => Monad (t m)) => ...

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.

Methods

  • lift :: Monad m => m a -> t m a

    Lift a computation from the argument monad to the constructed monad.

Instances20MonadTrans, …
  • MonadTrans CatchTDefined in exceptions-0.10.12 · Control.Monad.Catch.Pure
  • MonadTrans DumbTermDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.DumbTerm
  • MonadTrans DrawDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Backend.Terminfo
  • MonadTrans CmdMDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Command
  • MonadTrans InputTDefined in haskeline-0.8.5.0 · System.Console.Haskeline.InputT
  • MonadTrans MaybeTDefined in transformers-0.6.3.0 · Control.Monad.Trans.Maybe
  • Monoid w => MonadTrans (AccumT w)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Accum
  • Monoid w => MonadTrans (WriterT w)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.Lazy
  • Monoid w => MonadTrans (WriterT w)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.Strict
  • MonadTrans IdentityTDefined in transformers-0.6.3.0 · Control.Monad.Trans.Identity
  • MonadTrans (ExceptT e)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Except
  • MonadTrans (ReaderT r)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Reader
  • MonadTrans (SelectT r)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Select
  • MonadTrans (StateT s)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Lazy
  • MonadTrans (StateT s)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Strict
  • MonadTrans (WriterT w)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.CPS
  • MonadTrans (ContT r)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Cont
  • Monoid w => MonadTrans (RWST r w s)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy
  • Monoid w => MonadTrans (RWST r w s)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Strict
  • MonadTrans (RWST r w s)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.CPS
newtypenewtype MaybeT (m :: Type -> Type) a
#

The parameterizable maybe monad, a strict monad obtained by composing an arbitrary monad with the Maybe monad.

Computations are actions that may produce a value or exit.

The return function yields a computation that produces that value, while >>= sequences two subcomputations, exiting if either computation does.

Constructors

Instances36MonadTrans, MonadRWS, Generic1, MonadAccum, MonadError, MonadReader, …
newtypenewtype ReaderT r (m :: Type -> Type) a
#

The reader monad transformer, which adds a read-only environment to the given monad.

The return function ignores the environment, while m >>= k passes the inherited environment to both subcomputations:

image: images/bind-ReaderT.svg

ReaderT r m is strict if and only if m is.

Instances28Generic1, MonadAccum, MonadError, MonadWriter, MonadSelect, MonadState, …
newtypenewtype StateT s (m :: Type -> Type) a
#

A state transformer monad parameterized by:

  • s - The state.

  • m - The inner monad.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

Instances25MonadAccum, MonadError, MonadWriter, MonadSelect, MonadState, MonadReader, …
valuebracketSet
  1. :: (MonadMask m, MonadIO m)
  2. => IO a
  3. -> a -> IO ()
  4. -> a
  5. -> m b
  6. -> m b
#

Utility function for changing a property of a terminal for the duration of a computation.

classclass (MonadReader Prefs m, MonadReader Layout m, MonadIO m, MonadMask m) => CommandMonad (m :: Type -> Type) where
#
Instances2CommandMonad
classclass (MonadReader Layout m, MonadIO m, MonadMask m) => Term (m :: Type -> Type) where
#

Methods

Instances2Term
datadata Key
#

Constructors

Instances3Eq, Ord, Show
  • Eq KeyDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Key
  • Ord KeyDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Key
  • Show KeyDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Key
datadata ArgMode s
#

Used for commands which take an integer argument.

Constructors

Instances4Functor, LineState, Result, Save
  • Functor ArgModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState s => LineState (ArgMode s)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Result s => Result (ArgMode s)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Save s => Save (ArgMode s)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
datadata CommandMode
#

Used by vi mode. Considers the cursor to be located over some specific character. The first list is reversed.

Instances5Show, LineState, Move, Result, Save
  • Show CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Move CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Result CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Save CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
datadata Grapheme
#

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

Instances3Eq, Show, CommandMonad
  • Eq GraphemeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Show GraphemeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • (MonadIO m, MonadMask m) => CommandMonad (InputCmdT m)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.InputT
datadata InsertMode
#

The standard line state representation; considers the cursor to be located between two characters. The first list is reversed.

Constructors

Instances6Eq, Show, LineState, Move, Result, Save
  • Eq InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Show InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Move InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Result InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Save InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
typetype LineChars = ([Grapheme], [Grapheme])
#

The characters in the line (with the cursor in the middle). NOT in a zippered format; both lists are in the order left->right that appears on the screen.

classclass LineState s where
#

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.

Methods

Instances7LineState, …
  • LineState SearchModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Command.History
  • LineState CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState MessageDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState PasswordDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • LineState SearchEntryDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Vi
  • LineState s => LineState (ArgMode s)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
classclass LineState s => Result s where
#

Methods

Instances5Result
  • Result SearchModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.Command.History
  • Result CommandModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Result InsertModeDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Result PasswordDefined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
  • Result s => Result (ArgMode s)Defined in haskeline-0.8.5.0 · System.Console.Haskeline.LineState
datadata Behavior
#

Haskeline has two ways of interacting with the user:

  • "Terminal-style" interaction provides an rich user interface by connecting to the user's terminal (which may be different than stdin or stdout).

  • "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., getInputLine) print the prompt to stdout.

A Behavior is a method for deciding at run-time which type of interaction to use.

For most applications (e.g., a REPL), defaultBehavior should have the correct effect.

Constructors