Safe Haskell | None |
---|---|
Language | Haskell2010 |
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...
ExpectedNoInputError | An option |
MissingCommandError !Text | An option |
Instances
Eq CommandExc Source # | |
Defined in Climb (==) :: CommandExc -> CommandExc -> Bool # (/=) :: CommandExc -> CommandExc -> Bool # | |
Show CommandExc Source # | |
Defined in Climb showsPrec :: Int -> CommandExc -> ShowS # show :: CommandExc -> String # showList :: [CommandExc] -> ShowS # | |
Exception CommandExc Source # | |
Defined in Climb 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.
ReplDef | |
|
data ReplDirective #
Directive to control voluntary REPL termination.
Instances
Eq ReplDirective | |
Defined in Linenoise.Repl (==) :: ReplDirective -> ReplDirective -> Bool # (/=) :: ReplDirective -> ReplDirective -> Bool # | |
Show ReplDirective | |
Defined in Linenoise.Repl 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.