butcher-1.3.3.2: Chops a command or program invocation into digestable pieces.

Safe Haskell | None
Language | Haskell2010

UI.Butcher.Monadic.Types

Description

Types used in the butcher interface.

Synopsis

- data CommandDesc out = CommandDesc {
  - _cmd_mParent :: Maybe (Maybe String, CommandDesc out)
  - _cmd_synopsis :: Maybe Doc
  - _cmd_help :: Maybe Doc
  - _cmd_parts :: [PartDesc]
  - _cmd_out :: Maybe out
  - _cmd_children :: Deque (Maybe String, CommandDesc out)
  - _cmd_visibility :: Visibility
  }
- cmd_out :: forall out. Lens' (CommandDesc out) (Maybe out)
- type CmdParser f out = Free (CmdParserF f out)
- data Input
  - = InputString String
  - | InputArgs [String]
- data ParsingError = ParsingError {
  - _pe_messages :: [String]
  - _pe_remaining :: Input
  }
- data PartDesc
  - = PartLiteral String
  - | PartVariable String
  - | PartOptional PartDesc
  - | PartAlts [PartDesc]
  - | PartSeq [PartDesc]
  - | PartDefault String PartDesc
  - | PartSuggestion [CompletionItem] PartDesc
  - | PartRedirect String PartDesc
  - | PartReorder [PartDesc]
  - | PartMany PartDesc
  - | PartWithHelp Doc PartDesc
  - | PartHidden PartDesc
- emptyCommandDesc :: CommandDesc out
- data Visibility
  - = Visible
  - | Hidden

# Documentation

data CommandDesc out Source #

A representation/description of a command parser built via the `CmdParser` monad. Can be transformed into a pretty Doc to display as usage/help via `ppUsage` and related functions.

Note that there is the `_cmd_out` accessor that contains `Maybe out` which might be useful after successful parsing.

Constructors

CommandDesc |

Fields

- _cmd_mParent :: Maybe (Maybe String, CommandDesc out)
- _cmd_synopsis :: Maybe Doc
- _cmd_help :: Maybe Doc
- _cmd_parts :: [PartDesc]
- _cmd_out :: Maybe out
- _cmd_children :: Deque (Maybe String, CommandDesc out)
- _cmd_visibility :: Visibility

#### Instances

Instances details

Functor CommandDesc Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods fmap :: (a -> b) -> CommandDesc a -> CommandDesc b (<$) :: a -> CommandDesc b -> CommandDesc a
Show (CommandDesc out) Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods showsPrec :: Int -> CommandDesc out -> ShowS show :: CommandDesc out -> String showList :: [CommandDesc out] -> ShowS

cmd_out :: forall out. Lens' (CommandDesc out) (Maybe out) Source #

type CmdParser f out = Free (CmdParserF f out) Source #

The CmdParser monad type. It is a free monad over some functor but users of butcher don't need to know more than that `CmdParser` is a `Monad`.

data Input Source #

Butcher supports two input modi: `String` and `[String]`. Program arguments have the latter form, while parsing interactive command input (e.g. when you implement a terminal of sorts) is easier when you can process the full `String` without having to wordify it first by some means (and List.words is not the right approach in many situations.)

Constructors

InputString String |
InputArgs [String] |

#### Instances

Instances details

Eq Input Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods (==) :: Input -> Input -> Bool (/=) :: Input -> Input -> Bool
Show Input Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods showsPrec :: Int -> Input -> ShowS show :: Input -> String showList :: [Input] -> ShowS

data ParsingError Source #

Information about an error that occured when trying to parse some `Input` using some `CmdParser`.

Constructors

ParsingError |

Fields

- _pe_messages :: [String]
- _pe_remaining :: Input

#### Instances

Instances details

Eq ParsingError Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods (==) :: ParsingError -> ParsingError -> Bool (/=) :: ParsingError -> ParsingError -> Bool
Show ParsingError Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods showsPrec :: Int -> ParsingError -> ShowS show :: ParsingError -> String showList :: [ParsingError] -> ShowS

data PartDesc Source #

A representation/description of a command's parts, i.e. flags or params. As a butcher user, the higher-level pretty-printing functions for `CommandDesc` are probably sufficient.

Constructors

PartLiteral String |
PartVariable String |
PartOptional PartDesc |
PartAlts [PartDesc] |
PartSeq [PartDesc] |
PartDefault String PartDesc |
PartSuggestion [CompletionItem] PartDesc |
PartRedirect String PartDesc |
PartReorder [PartDesc] |
PartMany PartDesc |
PartWithHelp Doc PartDesc |
PartHidden PartDesc |

#### Instances

Instances details

Show PartDesc Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods showsPrec :: Int -> PartDesc -> ShowS show :: PartDesc -> String showList :: [PartDesc] -> ShowS

emptyCommandDesc :: CommandDesc out Source #

Empty `CommandDesc` value. Mostly for butcher-internal usage.

data Visibility Source #

Constructors

Visible |
Hidden |

#### Instances

Instances details

Eq Visibility Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods (==) :: Visibility -> Visibility -> Bool (/=) :: Visibility -> Visibility -> Bool
Show Visibility Source # |
Instance details Defined in UI.Butcher.Monadic.Internal.Types Methods showsPrec :: Int -> Visibility -> ShowS show :: Visibility -> String showList :: [Visibility] -> ShowS