| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Climb
Description
Building blocks for a GHCI-like REPL with colon-commands.
Synopsis
- type Command m = Text -> m ReplDirective
- data CommandExc
- type Completion m = Text -> m [Text]
- type OptionCommands m = Map Text (Text, Command m)
- data ReplDef m = ReplDef {
- _rdOnInterrupt :: !ReplDirective
- _rdGreeting :: !Text
- _rdPrompt :: !Text
- _rdOptionCommands :: !(OptionCommands m)
- _rdExecCommand :: !(Command m)
- _rdCompletion :: !(Completion m)
- data ReplDirective
- bareCommand :: MonadThrow m => m ReplDirective -> Command m
- noOptionCommands :: OptionCommands m
- noCompletion :: Applicative m => Completion m
- runReplDef :: (MonadThrow m, MonadUnliftIO m) => ReplDef m -> m ()
Documentation
type Command m = Text -> m ReplDirective Source #
A Command takes some input, performs some effect, and returns a directive (continue or quit).
data CommandExc Source #
Sometimes things go wrong...
Constructors
| ExpectedNoInputError | An option |
| MissingCommandError !Text | An option |
Instances
| Eq CommandExc Source # | |
Defined in Climb | |
| Show CommandExc Source # | |
Defined in Climb Methods showsPrec :: Int -> CommandExc -> ShowS # show :: CommandExc -> String # showList :: [CommandExc] -> ShowS # | |
| Exception CommandExc Source # | |
Defined in Climb Methods toException :: CommandExc -> SomeException # fromException :: SomeException -> Maybe CommandExc # displayException :: CommandExc -> String # | |
type Completion m = Text -> m [Text] Source #
A Completion takes some input and returns potential matches.
Defines a REPL with commands, options, and completion.
Constructors
| ReplDef | |
Fields
| |
data ReplDirective #
Directive to control voluntary REPL termination.
Constructors
| ReplQuit | |
| ReplContinue |
Instances
| Eq ReplDirective | |
Defined in Linenoise.Repl Methods (==) :: ReplDirective -> ReplDirective -> Bool # (/=) :: ReplDirective -> ReplDirective -> Bool # | |
| Show ReplDirective | |
Defined in Linenoise.Repl Methods showsPrec :: Int -> ReplDirective -> ShowS # show :: ReplDirective -> String # showList :: [ReplDirective] -> ShowS # | |
bareCommand :: MonadThrow m => m ReplDirective -> Command m Source #
Helps you define commands that expect no input.
noCompletion :: Applicative m => Completion m Source #
runReplDef :: (MonadThrow m, MonadUnliftIO m) => ReplDef m -> m () Source #
Runs a REPL as defined.