multiarg-0.30.0.10: Command lines for options that take multiple arguments

Safe HaskellSafe
LanguageHaskell2010

Multiarg.Types

Description

Types used throughout Multiarg, and associated functions. Ordinarily you should not need this module; Multiarg and Multiarg.Mode export all the types and constructors you should ordinarily need. However, if you want more control than those modules afford, you can import this one.

Synopsis

Documentation

data ArgSpec a #

Specifies how many option arguments an option takes.

Constructors

ZeroArg a

This option takes no option arguments

OneArg (String -> a)

This option takes one option argument

TwoArg (String -> String -> a)

This option takes two option arguments

ThreeArg (String -> String -> String -> a)

This option takes three option arguments

Instances
Functor ArgSpec # 
Instance details

Defined in Multiarg.Types

Methods

fmap :: (a -> b) -> ArgSpec a -> ArgSpec b #

(<$) :: a -> ArgSpec b -> ArgSpec a #

Show (ArgSpec a) # 
Instance details

Defined in Multiarg.Types

Methods

showsPrec :: Int -> ArgSpec a -> ShowS #

show :: ArgSpec a -> String #

showList :: [ArgSpec a] -> ShowS #

data OptSpec a #

Specifies an option. Typically you will use optSpec to create an OptSpec rather than using the constructor directly. Each OptSpec may contain mulitple short option names and long option names; but each OptSpec contains only one ArgSpec. Therefore, all short option names and long option names specified in a single OptSpec are synonymous.

Constructors

OptSpec [ShortName] [LongName] (ArgSpec a) 
Instances
Functor OptSpec # 
Instance details

Defined in Multiarg.Types

Methods

fmap :: (a -> b) -> OptSpec a -> OptSpec b #

(<$) :: a -> OptSpec b -> OptSpec a #

Show (OptSpec a) # 
Instance details

Defined in Multiarg.Types

Methods

showsPrec :: Int -> OptSpec a -> ShowS #

show :: OptSpec a -> String #

showList :: [OptSpec a] -> ShowS #

optSpec #

Arguments

:: [Char]

There is one character for each desired short option name. Each of these characters may not be a hyphen; otherwise, optSpec will apply error.

-> [String]

There is one string for each desired long option name. Each string:

  • cannot be empty;
  • must not begin with a hyphen; and
  • must not contain an equal sign.

Otherwise, optSpec will apply error.

-> ArgSpec a

How many option arguments this option takes. This also specifies what is returned when the option is parsed on the command line.

-> OptSpec a 

Creates an OptSpec.

data ShortName #

A short option name.

Instances
Eq ShortName # 
Instance details

Defined in Multiarg.Types

Ord ShortName # 
Instance details

Defined in Multiarg.Types

Show ShortName # 
Instance details

Defined in Multiarg.Types

shortName :: Char -> Maybe ShortName #

Creates a short option name. Any character other than a single hyphen will succeed.

data LongName #

A long option name.

Instances
Eq LongName # 
Instance details

Defined in Multiarg.Types

Ord LongName # 
Instance details

Defined in Multiarg.Types

Show LongName # 
Instance details

Defined in Multiarg.Types

longName :: String -> Maybe LongName #

Creates a long option name. The string may not be empty, and the first character may not be a hyphen. In addition, no character may be an equal sign.

newtype Word #

A word supplied by the user on the command line.

Constructors

Word String 
Instances
Eq Word # 
Instance details

Defined in Multiarg.Types

Methods

(==) :: Word -> Word -> Bool #

(/=) :: Word -> Word -> Bool #

Ord Word # 
Instance details

Defined in Multiarg.Types

Methods

compare :: Word -> Word -> Ordering #

(<) :: Word -> Word -> Bool #

(<=) :: Word -> Word -> Bool #

(>) :: Word -> Word -> Bool #

(>=) :: Word -> Word -> Bool #

max :: Word -> Word -> Word #

min :: Word -> Word -> Word #

Show Word # 
Instance details

Defined in Multiarg.Types

Methods

showsPrec :: Int -> Word -> ShowS #

show :: Word -> String #

showList :: [Word] -> ShowS #

newtype OptName #

The name of an option (either a short option name or a long option name).

Instances
Eq OptName # 
Instance details

Defined in Multiarg.Types

Methods

(==) :: OptName -> OptName -> Bool #

(/=) :: OptName -> OptName -> Bool #

Ord OptName # 
Instance details

Defined in Multiarg.Types

Show OptName # 
Instance details

Defined in Multiarg.Types

newtype OptArg #

An option argument.

Constructors

OptArg 
Instances
Eq OptArg # 
Instance details

Defined in Multiarg.Types

Methods

(==) :: OptArg -> OptArg -> Bool #

(/=) :: OptArg -> OptArg -> Bool #

Ord OptArg # 
Instance details

Defined in Multiarg.Types

Show OptArg # 
Instance details

Defined in Multiarg.Types

newtype ShortTail #

Characters after the first short option name in a flag that specifies a short option instance, if the user supplies -afoobar, then this will be foobar.

Constructors

ShortTail String 
Instances
Eq ShortTail # 
Instance details

Defined in Multiarg.Types

Ord ShortTail # 
Instance details

Defined in Multiarg.Types

Show ShortTail # 
Instance details

Defined in Multiarg.Types

isLong #

Arguments

:: Word 
-> Maybe (LongName, Maybe OptArg)

Nothing if the option does not begin with a double dash and is not at least three characters long. Otherwise, returns the characters following the double dash to the left of any equal sign. The Maybe in the tuple is Nothing if there is no equal sign, or Just followed by characters following the equal sign if there is one.

Is this word an input for a long option?

isShort :: Word -> Maybe (ShortName, ShortTail) #

Is this an input word for a short argument?

splitShortTail :: ShortTail -> Maybe (ShortName, ShortTail) #

If possible, splits a ShortTail into a short option name and a remaining tail.