Options.Applicative.Builder.Internal

optparse-applicative-0.13.1.0: Utilities and combinators for parsing command line options

Safe Haskell | Safe
Language | Haskell98

Options.Applicative.Builder.Internal

Contents

- Internals

Synopsis

- data Mod f a = Mod (f a -> f a) (DefaultProp a) (OptProperties -> OptProperties)
- class HasName f where
- class HasCompleter f where
- class HasValue f where
- class HasMetavar f where
- data OptionFields a = OptionFields {
  - optNames :: [OptName]
  - optCompleter :: Completer
  - optNoArgError :: ParseError
  }
- data FlagFields a = FlagFields {
  - flagNames :: [OptName]
  - flagActive :: a
  }
- data CommandFields a = CommandFields {
  - cmdCommands :: [(String, ParserInfo a)]
  - cmdGroup :: Maybe String
  }
- data ArgumentFields a = ArgumentFields {
  - argCompleter :: Completer
  }
- data DefaultProp a = DefaultProp (Maybe a) (Maybe (a -> String))
- optionMod :: (OptProperties -> OptProperties) -> Mod f a
- fieldMod :: (f a -> f a) -> Mod f a
- baseProps :: OptProperties
- mkCommand :: Mod CommandFields a -> (Maybe String, [String], String -> Maybe (ParserInfo a))
- mkParser :: DefaultProp a -> (OptProperties -> OptProperties) -> OptReader a -> Parser a
- mkOption :: DefaultProp a -> (OptProperties -> OptProperties) -> OptReader a -> Option a
- mkProps :: DefaultProp a -> (OptProperties -> OptProperties) -> OptProperties
- internal :: Mod f a

# Internals

data Mod f a #

An option modifier.

Option modifiers are values that represent a modification of the properties of an option.

The type parameter `a` is the return type of the option, while `f` is a record containing its properties (e.g. `OptionFields` for regular options, `FlagFields` for flags, etc...).

An option modifier consists of 3 elements:

- A field modifier, of the form `f a -> f a`. These are essentially (compositions of) setters for some of the properties supported by `f`.
- An optional default value and function to display it.
- A property modifier, of the form `OptProperties -> OptProperties`. This is just like the field modifier, but for properties applicable to any option.

Modifiers are instances of `Monoid`, and can be composed as such.

You rarely need to deal with modifiers directly, as most of the times it is sufficient to pass them to builders (such as `strOption` or `flag`) to create options (see `Builder`).

Constructors

Mod (f a -> f a) (DefaultProp a) (OptProperties -> OptProperties) |

Instances

Semigroup (Mod f a) # |
Methods (<>) :: Mod f a -> Mod f a -> Mod f a # sconcat :: NonEmpty (Mod f a) -> Mod f a # stimes :: Integral b => b -> Mod f a -> Mod f a #
Monoid (Mod f a) # |
Methods mempty :: Mod f a # mappend :: Mod f a -> Mod f a -> Mod f a # mconcat :: [Mod f a] -> Mod f a #

class HasName f where #

Minimal complete definition

name

Methods

name :: OptName -> f a -> f a #

Instances

HasName FlagFields # |
Methods name :: OptName -> FlagFields a -> FlagFields a #
HasName OptionFields # |
Methods name :: OptName -> OptionFields a -> OptionFields a #

class HasCompleter f where #

Minimal complete definition

modCompleter

Methods

modCompleter :: (Completer -> Completer) -> f a -> f a #

Instances

HasCompleter ArgumentFields # |
Methods modCompleter :: (Completer -> Completer) -> ArgumentFields a -> ArgumentFields a #
HasCompleter OptionFields # |
Methods modCompleter :: (Completer -> Completer) -> OptionFields a -> OptionFields a #

class HasValue f where #

Minimal complete definition

hasValueDummy

Methods

hasValueDummy :: f a -> () #

Instances

HasValue ArgumentFields # |
Methods hasValueDummy :: ArgumentFields a -> () #
HasValue OptionFields # |
Methods hasValueDummy :: OptionFields a -> () #

class HasMetavar f where #

Minimal complete definition

hasMetavarDummy

Methods

hasMetavarDummy :: f a -> () #

Instances

HasMetavar ArgumentFields # |
Methods hasMetavarDummy :: ArgumentFields a -> () #
HasMetavar CommandFields # |
Methods hasMetavarDummy :: CommandFields a -> () #
HasMetavar OptionFields # |
Methods hasMetavarDummy :: OptionFields a -> () #

data OptionFields a #

Constructors

OptionFields |
Fields optNames :: [OptName] optCompleter :: Completer optNoArgError :: ParseError

Instances

HasMetavar OptionFields # |
Methods hasMetavarDummy :: OptionFields a -> () #
HasValue OptionFields # |
Methods hasValueDummy :: OptionFields a -> () #
HasCompleter OptionFields # |
Methods modCompleter :: (Completer -> Completer) -> OptionFields a -> OptionFields a #
HasName OptionFields # |
Methods name :: OptName -> OptionFields a -> OptionFields a #

data FlagFields a #

Constructors

FlagFields |
Fields flagNames :: [OptName] flagActive :: a

Instances

HasName FlagFields # |
Methods name :: OptName -> FlagFields a -> FlagFields a #

data CommandFields a #

Constructors

CommandFields |
Fields cmdCommands :: [(String, ParserInfo a)] cmdGroup :: Maybe String

Instances

HasMetavar CommandFields # |
Methods hasMetavarDummy :: CommandFields a -> () #

data ArgumentFields a #

Constructors

ArgumentFields |
Fields argCompleter :: Completer

Instances

HasMetavar ArgumentFields # |
Methods hasMetavarDummy :: ArgumentFields a -> () #
HasValue ArgumentFields # |
Methods hasValueDummy :: ArgumentFields a -> () #
HasCompleter ArgumentFields # |
Methods modCompleter :: (Completer -> Completer) -> ArgumentFields a -> ArgumentFields a #

data DefaultProp a #

Constructors

DefaultProp (Maybe a) (Maybe (a -> String)) |

Instances

Semigroup (DefaultProp a) # |
Methods (<>) :: DefaultProp a -> DefaultProp a -> DefaultProp a # sconcat :: NonEmpty (DefaultProp a) -> DefaultProp a # stimes :: Integral b => b -> DefaultProp a -> DefaultProp a #
Monoid (DefaultProp a) # |
Methods mempty :: DefaultProp a # mappend :: DefaultProp a -> DefaultProp a -> DefaultProp a # mconcat :: [DefaultProp a] -> DefaultProp a #

optionMod :: (OptProperties -> OptProperties) -> Mod f a #

fieldMod :: (f a -> f a) -> Mod f a #

baseProps :: OptProperties #

Base default properties.

mkCommand :: Mod CommandFields a -> (Maybe String, [String], String -> Maybe (ParserInfo a)) #

mkParser :: DefaultProp a -> (OptProperties -> OptProperties) -> OptReader a -> Parser a #

mkOption :: DefaultProp a -> (OptProperties -> OptProperties) -> OptReader a -> Option a #

mkProps :: DefaultProp a -> (OptProperties -> OptProperties) -> OptProperties #

internal :: Mod f a #

Hide this option from the help text