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 # 

Methods

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

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

Show (ArgSpec a) # 

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 # 

Methods

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

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

Show (OptSpec a) # 

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.

shortName :: Char -> Maybe ShortName #

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

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 # 

Methods

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

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

Ord Word # 

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 # 

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).

newtype OptArg #

An option argument.

Constructors

OptArg 

Instances

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 

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.