Safe Haskell | None |
---|---|
Language | Haskell2010 |
Primitive operations such as printing messages and reading input.
Synopsis
- data ReportType
- say :: MonadIO m => Stylized -> Byline m ()
- sayLn :: MonadIO m => Stylized -> Byline m ()
- ask :: MonadIO m => Stylized -> Maybe Text -> Byline m Text
- askChar :: MonadIO m => Stylized -> Byline m Char
- askPassword :: MonadIO m => Stylized -> Maybe Char -> Byline m Text
- askUntil :: MonadIO m => Stylized -> Maybe Text -> (Text -> m (Either Stylized a)) -> Byline m a
- report :: MonadIO m => ReportType -> Stylized -> Byline m ()
- reportLn :: MonadIO m => ReportType -> Stylized -> Byline m ()
- withCompletionFunc :: MonadIO m => CompletionFunc -> Byline m a -> Byline m a
Documentation
data ReportType Source #
Report types for the report
function.
say :: MonadIO m => Stylized -> Byline m () Source #
Output the stylized text to the output handle (default: stdout).
:: MonadIO m | |
=> Stylized | The prompt. |
-> Maybe Text | Optional default answer that will be returned if the user presses return without providing any input (a zero-length string). |
-> Byline m Text |
Read input after printing the given stylized text as a prompt.
:: MonadIO m | |
=> Stylized | The prompt. |
-> Maybe Char | Optional masking character that will be printed each time the user presses a key. |
-> Byline m Text |
Read a password without echoing it to the terminal. If a masking character is given it will replace each typed character.
:: MonadIO m | |
=> Stylized | The prompt. |
-> Maybe Text | Optional default answer. |
-> (Text -> m (Either Stylized a)) | Confirmation function. |
-> Byline m a |
Continue to prompt for a response until a confirmation function returns a valid result.
The confirmation function receives the output from ask
and should
return a Left Stylized
to produce an error message (printed with
sayLn
). When an acceptable answer from ask
is received, the
confirmation function should return it with Right
.
report :: MonadIO m => ReportType -> Stylized -> Byline m () Source #
Output stylized text with a prefix determined by ReportType
.
reportLn :: MonadIO m => ReportType -> Stylized -> Byline m () Source #
Like report
, but append a newline character.
withCompletionFunc :: MonadIO m => CompletionFunc -> Byline m a -> Byline m a Source #
Run the given Byline
action with a different completion
function.