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 :: forall (m :: Type -> Type) a. 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: 0.8.4.0
fromReaderT :: forall (m :: Type -> Type) a. 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: 0.8.4.0
mapInputTEnv :: (forall x. m x -> n x) -> InputTEnv m -> InputTEnv n Source #
Maps the environment.
Since: 0.8.4.0