HORIZON HASKELLDocslts/ghc-10.0.x04404a62026-10-19Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 04404a6 · 2026-10-19

Modulehaskeline-0.8.5.0Haskell98

System.Console.Haskeline.ReaderT

Provides an interface for ReaderT rather than InputT.

Contents
  1. ReaderT
Synopsis

ReaderT

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