darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.UI.Options.Util

Contents

- Instantiating `OptSpec` and `PrimOptSpec`
- Constructing `DarcsOptDescr`s
- Raw option specs
- Simple primitive scalar valued options
- Simple primitive list valued options
- Parsing/showing option arguments
- Re-exports

Description

Constructing `OptSpec`s and `OptDescr`s

Synopsis

- type Flag = DarcsFlag
- type DarcsOptDescr = Compose OptDescr ((->) AbsolutePath)
- type PrimDarcsOption v = forall a. PrimOptSpec DarcsOptDescr Flag a v
- noArg :: [Char] -> [String] -> f -> String -> DarcsOptDescr f
- strArg :: SingleArgOptDescr String f
- optStrArg :: SingleArgOptDescr (Maybe String) f
- absPathArg :: SingleArgOptDescr AbsolutePath f
- absPathOrStdArg :: SingleArgOptDescr AbsolutePathOrStd f
- optAbsPathArg :: [Char] -> [String] -> String -> (AbsolutePath -> f) -> String -> String -> DarcsOptDescr f
- data RawOptSpec f v
  - = RawNoArg [Char] [String] f v String
  - | RawStrArg [Char] [String] (String -> f) (f -> [String]) (String -> v) (v -> [String]) String String
  - | RawAbsPathArg [Char] [String] (AbsolutePath -> f) (f -> [AbsolutePath]) (AbsolutePath -> v) (v -> [AbsolutePath]) String String
  - | RawAbsPathOrStdArg [Char] [String] (AbsolutePathOrStd -> f) (f -> [AbsolutePathOrStd]) (AbsolutePathOrStd -> v) (v -> [AbsolutePathOrStd]) String String
  - | RawOptAbsPathArg [Char] [String] (AbsolutePath -> f) (f -> [AbsolutePath]) (AbsolutePath -> v) (v -> [AbsolutePath]) String String String
- withDefault :: Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
- singleNoArg :: [Char] -> [String] -> Flag -> String -> PrimDarcsOption Bool
- singleStrArg :: [Char] -> [String] -> (String -> Flag) -> (Flag -> Maybe String) -> String -> String -> PrimDarcsOption (Maybe String)
- multiStrArg :: [Char] -> [String] -> (String -> Flag) -> ([Flag] -> [String]) -> String -> String -> PrimDarcsOption [String]
- multiOptStrArg :: [Char] -> [String] -> (Maybe String -> Flag) -> ([Flag] -> [Maybe String]) -> String -> String -> PrimDarcsOption [Maybe String]
- singleAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> Flag) -> (Flag -> Maybe AbsolutePath) -> String -> String -> PrimDarcsOption (Maybe AbsolutePath)
- multiAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> Flag) -> ([Flag] -> [AbsolutePath]) -> String -> String -> PrimDarcsOption [AbsolutePath]
- deprecated :: [String] -> [RawOptSpec Flag v] -> PrimDarcsOption ()
- parseIntArg :: String -> (Int -> Bool) -> String -> Int
- parseIndexRangeArg :: String -> (Int, Int)
- showIntArg :: Int -> String
- showIndexRangeArg :: (Int, Int) -> String
- withDashes :: [Char] -> [String] -> [String]
- data AbsolutePath
- data AbsolutePathOrStd

# Documentation

type Flag = DarcsFlag #

This type synonym is here for brevity and because we want to import the data constructors (but not the type) of `DarcsFlag` qualified.

# Instantiating `OptSpec` and `PrimOptSpec`

type DarcsOptDescr = Compose OptDescr ((->) AbsolutePath) #

We do not instantiate the `d` in ``OptSpec` d f` directly with `OptDescr`. Instead we (post-) compose it with `(->) `AbsolutePath``. Modulo newtype noise, this is the same as

     type DarcsOptDescr f = OptDescr (AbsolutePath -> f)

This is so we can pass a directory relative to which an option argument is interpreted (if it has the form of a relative path).

type PrimDarcsOption v = forall a. PrimOptSpec DarcsOptDescr Flag a v #

This is `PrimOptSpec` instantiated with `DarcsOptDescr` and `Flag`.

# Constructing `DarcsOptDescr`s

noArg :: [Char] -> [String] -> f -> String -> DarcsOptDescr f #

Construct a `DarcsOptDescr` with no arguments.

strArg :: SingleArgOptDescr String f #

Construct a `DarcsOptDescr` with a `String` argument.

optStrArg :: SingleArgOptDescr (Maybe String) f #

Construct a `DarcsOptDescr` with an optional `String` argument.

absPathArg :: SingleArgOptDescr AbsolutePath f #

Construct a `DarcsOptDescr` with an `AbsolutePath` argument.

absPathOrStdArg :: SingleArgOptDescr AbsolutePathOrStd f #

Construct a `DarcsOptDescr` with an `AbsolutePathOrStd` argument.

optAbsPathArg :: [Char] -> [String] -> String -> (AbsolutePath -> f) -> String -> String -> DarcsOptDescr f #

Construct a `DarcsOptDescr` with an optional `AbsolutePath` argument.

# Raw option specs

data RawOptSpec f v #

The raw material from which multi-valued options are built. See `withDefault`.

Constructors

RawNoArg [Char] [String] f v String |
RawStrArg [Char] [String] (String -> f) (f -> [String]) (String -> v) (v -> [String]) String String |
RawAbsPathArg [Char] [String] (AbsolutePath -> f) (f -> [AbsolutePath]) (AbsolutePath -> v) (v -> [AbsolutePath]) String String |
RawAbsPathOrStdArg [Char] [String] (AbsolutePathOrStd -> f) (f -> [AbsolutePathOrStd]) (AbsolutePathOrStd -> v) (v -> [AbsolutePathOrStd]) String String |
RawOptAbsPathArg [Char] [String] (AbsolutePath -> f) (f -> [AbsolutePath]) (AbsolutePath -> v) (v -> [AbsolutePath]) String String String |

#### Instances

Instances details

IsoFunctor (RawOptSpec f) # |
Instance details Defined in Darcs.UI.Options.Util Methods imap :: Iso a b -> RawOptSpec f a -> RawOptSpec f b #

withDefault :: Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v #

Construct a `PrimDarcsOption` from a default value and a list of `RawOptSpec`.

Precondition: the list must have an entry for each possible value (type `v`).

# Simple primitive scalar valued options

singleNoArg :: [Char] -> [String] -> Flag -> String -> PrimDarcsOption Bool #

Construct a `Bool` valued option with a single flag that takes no arguments and has no default flag.

The arguments are: short switches, long switches, flag value, help string.

singleStrArg :: [Char] -> [String] -> (String -> Flag) -> (Flag -> Maybe String) -> String -> String -> PrimDarcsOption (Maybe String) #

Construct a ``Maybe` `String`` valued option with a single flag that takes a `String` argument and has no default flag.

The arguments are: short switches, long switches, flag constructor, single flag parser, help string.

# Simple primitive list valued options

multiStrArg :: [Char] -> [String] -> (String -> Flag) -> ([Flag] -> [String]) -> String -> String -> PrimDarcsOption [String] #

Similar to `singleStrArg`, except that the flag can be given more than once. The flag arguments are collected in a list of `String`s.

multiOptStrArg :: [Char] -> [String] -> (Maybe String -> Flag) -> ([Flag] -> [Maybe String]) -> String -> String -> PrimDarcsOption [Maybe String] #

Similar to `multiStrArg`, except that the flag arguments are optional.

singleAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> Flag) -> (Flag -> Maybe AbsolutePath) -> String -> String -> PrimDarcsOption (Maybe AbsolutePath) #

Construct a ``Maybe` `AbsolutePath`` valued option with a single flag that takes an `AbsolutePath` argument and has no default flag.

The arguments are: short switches, long switches, flag constructor, single flag parser, help string.

multiAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> Flag) -> ([Flag] -> [AbsolutePath]) -> String -> String -> PrimDarcsOption [AbsolutePath] #

Similar to `singleAbsPathArg`, except that the flag can be given more than once. The flag arguments are collected in a list of `AbsolutePath`s.

deprecated :: [String] -> [RawOptSpec Flag v] -> PrimDarcsOption () #

A deprecated option. If you want to deprecate only some flags and not the whole option, extract the `RawOptSpec`s out of the original option and create a new deprecated option. The strings in the first argument are appended to the automatically generated error message in case additional hints should be provided.

# Parsing/showing option arguments

parseIntArg :: String -> (Int -> Bool) -> String -> Int #

parseIndexRangeArg :: String -> (Int, Int) #

showIntArg :: Int -> String #

showIndexRangeArg :: (Int, Int) -> String #

withDashes :: [Char] -> [String] -> [String] #

# Re-exports

data AbsolutePath #

#### Instances

Instances details

Show AbsolutePath # |
Instance details Defined in Darcs.Util.Path Methods showsPrec :: Int -> AbsolutePath -> ShowS # show :: AbsolutePath -> String # showList :: [AbsolutePath] -> ShowS #
FilePathLike AbsolutePath # |
Instance details Defined in Darcs.Util.Path Methods toFilePath :: AbsolutePath -> FilePath #
FilePathOrURL AbsolutePath # |
Instance details Defined in Darcs.Util.Path Methods toPath :: AbsolutePath -> String #
Eq AbsolutePath # |
Instance details Defined in Darcs.Util.Path Methods (==) :: AbsolutePath -> AbsolutePath -> Bool # (/=) :: AbsolutePath -> AbsolutePath -> Bool #
Ord AbsolutePath # |
Instance details Defined in Darcs.Util.Path Methods compare :: AbsolutePath -> AbsolutePath -> Ordering # (<) :: AbsolutePath -> AbsolutePath -> Bool # (<=) :: AbsolutePath -> AbsolutePath -> Bool # (>) :: AbsolutePath -> AbsolutePath -> Bool # (>=) :: AbsolutePath -> AbsolutePath -> Bool # max :: AbsolutePath -> AbsolutePath -> AbsolutePath # min :: AbsolutePath -> AbsolutePath -> AbsolutePath #

data AbsolutePathOrStd #

This is for situations where a string (e.g. a command line argument) may take the value "-" to mean stdin or stdout (which one depends on context) instead of a normal file path.

#### Instances

Instances details

Show AbsolutePathOrStd # |
Instance details Defined in Darcs.Util.Path Methods showsPrec :: Int -> AbsolutePathOrStd -> ShowS # show :: AbsolutePathOrStd -> String # showList :: [AbsolutePathOrStd] -> ShowS #
Eq AbsolutePathOrStd # |
Instance details Defined in Darcs.Util.Path Methods (==) :: AbsolutePathOrStd -> AbsolutePathOrStd -> Bool # (/=) :: AbsolutePathOrStd -> AbsolutePathOrStd -> Bool #
Ord AbsolutePathOrStd # |

Instance details

Defined in Darcs.Util.Path

Methods

compare :: AbsolutePathOrStd -> AbsolutePathOrStd -> Ordering #

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

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

(>) :: AbsolutePathOrStd -> AbsolutePathOrStd -> Bool #

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

max :: AbsolutePathOrStd -> AbsolutePathOrStd -> AbsolutePathOrStd #

min :: AbsolutePathOrStd -> AbsolutePathOrStd -> AbsolutePathOrStd #