repl-toolkit-1.0.0.1: Toolkit for quickly whipping up config files and command-line interfaces.

Safe HaskellSafe
LanguageHaskell2010

System.REPL.Types

Description

Synopsis

Documentation

type TypeError = SomeException Source

An error message indicating that a value wasn't able to be parsed.

type PredicateError = SomeException Source

An error message indicating that a value failied a predicate.

type PromptMsg = Text Source

A prompt.

type Predicate m a b = a -> m (Either PredicateError b) Source

A predicate which a value has to fulfil.

type Predicate' m a = Predicate m a a Source

A predicate which does not change the type of its input.

type Parser a = Text -> Either TypeError a Source

A parser which either returns a parsed value or an error message.

data Asker m a b Source

The description of an 'ask for user input'-action. The type parameters are the used monad (typically IO or ExceptT), the type of the read value and the type of the error that is thrown in case of failures.

The components are a prompt, a parser, and a predicate that the parsed value must fulfil. The the predicate

  • is monadic and
  • can change the returned type (useful for adjoining additional information)

Constructors

Asker 

Fields

askerPrompt :: Text

The prompt to be displayed to the user.

askerParser :: Parser a

The parser for the input value.

askerPredicate :: Predicate m a b

The predicate which the input, once read, must fulfill. The Left side is an error message.

type Asker' m a = Asker m a a Source

An Asker which does not convert its argument into different type after parsing.

data SomeREPLError Source

Root of the exception hierarchy.

Constructors

forall e . Exception e => SomeREPLError e 

data SomeAskerError Source

Generic error related to Askers. Either the input was incorrect in some way, or the process was aborted by the user.

Constructors

forall e . Exception e => SomeAskerError e 

data AskerTypeError Source

The input wasn't able to be parsed.

data AskerInputAbortedError Source

The input for an Asker was aborted by the user.

data GenericTypeError Source

A generic type failure for use with Askers.

Constructors

GenericTypeError Text 

genericTypeError :: Text -> SomeException Source

Constructor for GenericTypeError which wraps the value into a SomeException.

genericPredicateError :: Text -> SomeException Source

Constructor for GenericTypeError which wraps the value into a SomeException.

newtype Verbatim Source

A verbatim Text whose Read instance simply returns the read string, as-is. This is useful for askers which ask for strings without quotes.

Constructors

Verbatim 

Fields

fromVerbatim :: Text
 

Instances

Read Verbatim Source

Read-instance for Verbatim. Wraps the given value into quotes and reads it a a Text.

data PathIsNotWritable Source

Indicatres that the last existing portion of a path is not writable.

data SomeCommandError Source

Generic error related to command execution.

Constructors

forall e . Exception e => SomeCommandError e 

data MalformedParamsError Source

The input of a command was malformed and could not interpreted. I.e. the input contained inadmissible characters, or quotes were mismatched. The Text argument contains the parser error.

data TooManyParamsError Source

Too many parameters were given to a command. The first value is the maximum, the second the actual number.

Constructors

TooManyParamsError Int Int 

data TooFewParamsError Source

Too few parameters were given to a command. The first value is the minium, the second the actual number.

Constructors

TooFewParamsError Int Int 

data Command m i a Source

A REPL command, possibly with parameters.

Constructors

Command 

Fields

commandName :: Text

The short name of the command. Purely informative.

commandTest :: i -> Bool

Returns whether the first part of an input (the command name) matches a the command. defCommandTest is appropriate for most cases.

commandDesc :: Text

A description of the command.

runPartialCommand :: [i] -> m (a, [i])

Runs the command with the input text as parameter, returning the unconsumed input.

Instances

Functor m => Functor (Command m i) Source 
Monad m => Apply (Command m i) Source 
Monad m => Bind (Command m i) Source