climb-0.5.0: Building blocks for a GHCi-like REPL with colon-commands
Safe HaskellSafe-Inferred
LanguageHaskell2010

Climb

Description

Building blocks for a GHCI-like REPL with colon-commands.

Synopsis

Documentation

type Command m = Text -> m ReplDirective Source #

A Command takes some input, performs some effect, and returns a directive (continue or quit).

data CommandErr Source #

Sometimes things go wrong...

Constructors

CommandErrExpectedNoInput

An option Command got input when it expected None

CommandErrUnknownCommand !Text

An option Command was not found by name.

Instances

Instances details
Exception CommandErr Source # 
Instance details

Defined in Climb

Show CommandErr Source # 
Instance details

Defined in Climb

Eq CommandErr Source # 
Instance details

Defined in Climb

type Completion m = Text -> m [Text] Source #

A Completion takes some input and returns potential matches.

type OptionCommands m = Map Text (Text, Command m) Source #

List of Commands by name with help text.

data ReplDef m Source #

Defines a REPL with commands, options, and completion.

data ReplDirective #

Directive to control voluntary REPL termination.

Constructors

ReplQuit 
ReplContinue 

Instances

Instances details
Show ReplDirective 
Instance details

Defined in Linenoise.Repl

Eq ReplDirective 
Instance details

Defined in Linenoise.Repl

bareCommand :: MonadThrow m => m ReplDirective -> Command m Source #

Helps you define commands that expect no input.

runReplDef :: (MonadCatch m, MonadUnliftIO m) => ReplDef m -> m () Source #

Runs a REPL as defined.

stepReplDef :: MonadThrow m => ReplDef m -> Text -> m ReplDirective Source #

Processes a single line of input. Useful for testing. (Note that this does not handle default option commands.)