| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Effectful.Haskeline.Static
Description
Provides a static effect for haskeline.
Since: 0.1
Synopsis
- data Haskeline (a :: Type -> Type) b
- haveTerminalUI :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es Bool
- getInputLine :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es (Maybe String)
- getInputLineWithInitial :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> (String, String) -> Eff es (Maybe String)
- getInputChar :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es (Maybe Char)
- getPassword :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Maybe Char -> String -> Eff es (Maybe String)
- waitForAnyKey :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es Bool
- outputStr :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es ()
- outputStrLn :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es ()
- getHistory :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es History
- putHistory :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => History -> Eff es ()
- modifyHistory :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => (History -> History) -> Eff es ()
- withInterrupt :: forall (es :: [Effect]) a. (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es a -> Eff es a
- handleInterrupt :: forall (es :: [Effect]) a. (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es a -> Eff es a -> Eff es a
- runHaskeline :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Haskeline ': es) a -> Eff es a
- runEffInputTEnv :: forall (m :: Type -> Type) a. HasCallStack => InputTEnv m -> Eff '[Reader (InputTEnv m), IOE] a -> IO a
- runInputTEnv :: (HasCallStack, MonadIO m, MonadMask m) => (InputTEnv m -> m a) -> m a
- runInputTEnvWith :: HasCallStack => (InputT m a -> m a) -> (InputTEnv m -> m a) -> m a
- data InputT (m :: Type -> Type) a
- data InputTEnv (m :: Type -> Type)
- runInputT :: (MonadIO m, MonadMask m) => Settings m -> InputT m a -> m a
- runInputTBehavior :: (MonadIO m, MonadMask m) => Behavior -> Settings m -> InputT m a -> m a
- runInputTBehaviorWithPrefs :: (MonadIO m, MonadMask m) => Behavior -> Prefs -> Settings m -> InputT m a -> m a
- defaultSettings :: forall (m :: Type -> Type). MonadIO m => Settings m
- defaultBehavior :: Behavior
- defaultPrefs :: Prefs
Effect
data Haskeline (a :: Type -> Type) b Source #
Static haskeline effect.
Since: 0.1
Instances
| type DispatchOf Haskeline Source # | |
Defined in Effectful.Haskeline.Static | |
| data StaticRep Haskeline Source # | |
Defined in Effectful.Haskeline.Static | |
haveTerminalUI :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es Bool Source #
Lifted haveTerminalUI.
Since: 0.1
getInputLine :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es (Maybe String) Source #
Lifted getInputLine.
Since: 0.1
getInputLineWithInitial :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> (String, String) -> Eff es (Maybe String) Source #
Lifted getInputLineWithInitial.
Since: 0.1
getInputChar :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es (Maybe Char) Source #
Lifted getInputChar.
Since: 0.1
getPassword :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Maybe Char -> String -> Eff es (Maybe String) Source #
Lifted getPassword.
Since: 0.1
waitForAnyKey :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es Bool Source #
Lifted waitForAnyKey.
Since: 0.1
outputStr :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es () Source #
Lifted outputStr.
Since: 0.1
outputStrLn :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => String -> Eff es () Source #
Lifted outputStrLn.
Since: 0.1
getHistory :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es History Source #
Lifted getHistory.
Since: 0.1
putHistory :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => History -> Eff es () Source #
Lifted putHistory.
Since: 0.1
modifyHistory :: forall (es :: [Effect]). (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => (History -> History) -> Eff es () Source #
Lifted modifyHistory.
Since: 0.1
withInterrupt :: forall (es :: [Effect]) a. (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es a -> Eff es a Source #
Lifted withInterrupt.
Since: 0.1
handleInterrupt :: forall (es :: [Effect]) a. (HasCallStack, Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es a -> Eff es a -> Eff es a Source #
Lifted handleInterrupt.
Since: 0.1
Handlers
runHaskeline :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Haskeline ': es) a -> Eff es a Source #
Reader
These functions allow eliminating the Haskeline effect in terms of
ReaderT.
Examples:
app :: (Haskeline :> es, Reader (InputTEnv IO) :> es) => Eff es String
app = do
mLine <- getInputLine "Enter your name: "
let name = fromMaybe "<blank>" mLine
outputStrLn $ "Hello: " ++ name
pure name
appIO :: IO String
appIO = do
runInputTEnv
$ env -> runEffInputTEnv env
$ runHaskeline app
Arguments
| :: forall (m :: Type -> Type) a. HasCallStack | |
| => InputTEnv m | The |
| -> Eff '[Reader (InputTEnv m), IOE] a | Eff action that requires the |
| -> IO a | IO result. |
Runner for Eff with InputTEnv. Intended for usage with runInputTEnv
or runInputTEnvWith.
Since: 0.1
Arguments
| :: (HasCallStack, MonadIO m, MonadMask m) | |
| => (InputTEnv m -> m a) | Action. |
| -> m a | IO result. |
runInputTEnvWith with default haskeline settings.
Examples:
-- eff :: Eff [Reader (InputTEnv m), IOE] a runInputTEnv $ env -> runEffInputTEnv env eff
Since: 0.1
Arguments
| :: HasCallStack | |
| => (InputT m a -> m a) |
|
| -> (InputTEnv m -> m a) | Action. |
| -> m a | IO result. |
Haskeline Re-exports
Types
data InputT (m :: Type -> Type) a Source #
A monad transformer which carries all of the state and settings relevant to a line-reading application.
Instances
IO Runners
runInputT :: (MonadIO m, MonadMask m) => Settings m -> InputT m a -> m a Source #
Run a line-reading application. This function should suffice for most applications.
This function is equivalent to . It
uses terminal-style interaction if runInputTBehavior defaultBehaviorstdin is connected to a terminal and has
echoing enabled. Otherwise (e.g., if stdin is a pipe), it uses file-style interaction.
If it uses terminal-style interaction, Prefs will be read from the user's ~/.haskeline file
(if present).
If it uses file-style interaction, Prefs are not relevant and will not be read.
runInputTBehavior :: (MonadIO m, MonadMask m) => Behavior -> Settings m -> InputT m a -> m a Source #
runInputTBehaviorWithPrefs :: (MonadIO m, MonadMask m) => Behavior -> Prefs -> Settings m -> InputT m a -> m a Source #
Run a line-reading application.
Config
defaultSettings :: forall (m :: Type -> Type). MonadIO m => Settings m Source #
A useful default. In particular:
defaultSettings = Settings {
complete = completeFilename,
historyFile = Nothing,
autoAddHistory = True
}
defaultPrefs :: Prefs Source #
The default preferences which may be overwritten in the
.haskeline file.