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

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

Modulehaskeline-0.8.5.0Haskell98

System.Console.Haskeline.ReaderT

Provides an interface for ReaderT rather than InputT.

  • 1 type
  • 3 values

ReaderT

4 declarations

These functions expose the InputT type in terms of ordinary ReaderT. This allows for easier integration with applications that do not use a concrete monad transformer stack, or do not want to commit to having InputT in the stack.

valuetoReaderT :: InputT m a -> ReaderT (InputTEnv m) m a
#

Maps an InputT to a ReaderT. Useful for lifting InputT functions into some other reader-like monad.

Examples:

import System.Console.Haskeline qualified as H

runApp :: ReaderT (InputTEnv IO) IO ()
runApp = do
  input <- toReaderT (H.getInputLine "Enter your name: ")
  ...
-- MTL-style polymorphism
class MonadHaskeline m where
  getInputLine :: String -> m (Maybe String)

-- AppT is the core type over ReaderT.
instance MonadHaskeline (AppT m) where
  getInputLine = lift . toReaderT . H.getInputLine

runApp :: (MonadHaskeline m) => m ()
runApp = do
  input <- getInputLine "Enter your name: "
  ...
valuefromReaderT :: ReaderT (InputTEnv m) m a -> InputT m a
#

Maps a ReaderT to an InputT. Allows defining an application in terms of ReaderT.

Examples:

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