| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
System.Console.Haskeline.ReaderT
Contents
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.
toReaderT :: InputT m a -> ReaderT (InputTEnv m) m a Source #
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: " ...
Since: haskeline-0.8.4.0
fromReaderT :: ReaderT (InputTEnv m) m a -> InputT m a Source #
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
Since: haskeline-0.8.4.0
mapInputTEnv :: (forall x. m x -> n x) -> InputTEnv m -> InputTEnv n Source #
Maps the environment.
Since: haskeline-0.8.4.0