effects-haskeline-0.1: Terminal effects
Safe HaskellNone
LanguageGHC2021

Effects.Haskeline

Description

Warning: Effects.Haskeline is experimental and subject to change.

Synopsis

Class

class Monad m => MonadHaskeline (m :: Type -> Type) where Source #

Methods

haveTerminalUI :: m Bool Source #

Lifted haveTerminalUI.

Since: 0.1

getInputLine :: String -> m (Maybe String) Source #

Lifted getInputLine.

Since: 0.1

getInputLineWithInitial :: String -> (String, String) -> m (Maybe String) Source #

Lifted getInputLineWithInitial.

Since: 0.1

getInputChar :: String -> m (Maybe Char) Source #

Lifted getInputChar.

Since: 0.1

getPassword :: Maybe Char -> String -> m (Maybe String) Source #

Lifted getPassword.

Since: 0.1

waitForAnyKey :: String -> m Bool Source #

Lifted waitForAnyKey.

Since: 0.1

outputStr :: String -> m () Source #

Lifted outputStr.

Since: 0.1

outputStrLn :: String -> m () Source #

Lifted outputStrLn.

Since: 0.1

getHistory :: m History Source #

Lifted getHistory.

Since: 0.1

putHistory :: History -> m () Source #

Lifted putHistory.

Since: 0.1

modifyHistory :: (History -> History) -> m () Source #

Lifted modifyHistory.

Since: 0.1

withInterrupt :: HasCallStack => m a -> m a Source #

Lifted withInterrupt.

Since: 0.1

handleInterrupt :: HasCallStack => m a -> m a -> m a Source #

Lifted handleInterrupt.

Since: 0.1

Instances

Instances details
(MonadIO m, MonadMask m) => MonadHaskeline (InputT m) Source # 
Instance details

Defined in Effects.Haskeline

MonadHaskeline m => MonadHaskeline (ReaderT e m) Source # 
Instance details

Defined in Effects.Haskeline

IO Runners

runInputT :: (MonadIO m, MonadMask m) => Settings m -> InputT m a -> m a #

Run a line-reading application. This function should suffice for most applications.

This function is equivalent to runInputTBehavior defaultBehavior. It uses terminal-style interaction if stdin 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 #

Run a line-reading application according to the given behavior.

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.

runInputTBehaviorWithPrefs :: (MonadIO m, MonadMask m) => Behavior -> Prefs -> Settings m -> InputT m a -> m a #

Run a line-reading application.

Config

defaultSettings :: forall (m :: Type -> Type). MonadIO m => Settings m #

A useful default. In particular:

defaultSettings = Settings {
          complete = completeFilename,
          historyFile = Nothing,
          autoAddHistory = True
          }

defaultBehavior :: Behavior #

Read input from stdin. Use terminal-style interaction if stdin is connected to a terminal and has echoing enabled. Otherwise (e.g., if stdin is a pipe), use file-style interaction.

This behavior should suffice for most applications.

defaultPrefs :: Prefs #

The default preferences which may be overwritten in the .haskeline file.