-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A simple library for processing command-line options.
--   
--   A simple library for processing command-line options. The library
--   captures a common usage pattern of the GetOpt module form the standard
--   libraries.
@package simple-get-opt
@version 0.5


-- | Provides support for processing command-line arguments. This is a
--   simple wrapper around get-opt. Here is an example of a typical usage:
--   
--   <pre>
--   data Settings = Settings
--     { verbose :: Bool
--     , inPar   :: Int
--     , files   :: [String]
--     }
--   
--   options :: OptSpec Settings
--   options = optSpec
--     { progDescription = [ "A useful utility." ]
--   
--     , progOptions =
--         [ Option ['v'] ["verbose"]
--           "Display more information while working."
--           $ NoArg $ \s -&gt; Right s { verbose = True }
--   
--         , Option ['p'] ["par"]
--           "Process that many files at once."
--           $ ReqArg "NUM" $ \a s -&gt;
--             case readMaybe a of
--               Just n | n &gt; 0  -&gt; Right s { inPar = n }
--               _               -&gt; Left "Invalid value for `par`"
--         ]
--   
--     , progParamDocs =
--         [ ("FILES",   "The files that need processing.") ]
--   
--     , progParams = \p s -&gt; Right s { files = p : files s }
--   
--     , progArgOrder = Permute
--     }
--   </pre>
--   
--   Here is what the usage information looks like:
--   
--   <pre>
--   *Main&gt; dumpUsage options
--   A useful utility.
--   
--   Parameters:
--     FILES    The files that need processing.
--   
--   Flags:
--     -v      --verbose  Display more information while working.
--     -p NUM  --par=NUM  Process that many files at once.
--   </pre>
module SimpleGetOpt

-- | Get the command-line options and process them according to the given
--   spec. The options will be permuted to get flags. On failure, print an
--   error message on standard error and exit.
getOpts :: a -> OptSpec a -> IO a

-- | Get the command-line options and process them according to the given
--   spec. The options will be permuted to get flags. Throws a
--   <a>GetOptException</a> if some problems are found.
getOptsX :: a -> OptSpec a -> IO a

-- | Process the given command line options according to the given spec.
--   The options will be permuted to get flags. Returns errors on the
--   <a>Left</a>.
getOptsFrom :: a -> OptSpec a -> [String] -> Either GetOptException a

-- | Specification of a collection of options, described by type
--   <tt>a</tt>.
data OptSpec a
OptSpec :: [String] -> [OptDescr a] -> [(String, String)] -> (String -> OptSetter a) -> !ArgOrder (OptSetter a) -> OptSpec a

-- | Free form lines to be shown with the generated help
[progDescription] :: OptSpec a -> [String]

-- | A list of options and command-line flags.
[progOptions] :: OptSpec a -> [OptDescr a]

-- | Documentation for the free-form parameters.
[progParamDocs] :: OptSpec a -> [(String, String)]

-- | Used to add the parameters that are not an option or a flag (i.e.,
--   this is just a free form command line parameter) in left-to-right
--   order.
[progParams] :: OptSpec a -> String -> OptSetter a

-- | What to do with parameters
[progArgOrder] :: OptSpec a -> !ArgOrder (OptSetter a)

-- | Describe an option.
data OptDescr a
Option :: [Char] -> [String] -> String -> ArgDescr a -> OptDescr a
[optShortFlags] :: OptDescr a -> [Char]
[optLongFlags] :: OptDescr a -> [String]
[optDescription] :: OptDescr a -> String
[optArgument] :: OptDescr a -> ArgDescr a

-- | Manipulate options of type <tt>a</tt>, with support for errors.
type OptSetter a = a -> Either String a

-- | Describe an option argumnet.
data ArgDescr a

-- | This option does not take an argument.
NoArg :: OptSetter a -> ArgDescr a

-- | This option has a required argument. The string describes the type of
--   the argument.
ReqArg :: String -> (String -> OptSetter a) -> ArgDescr a

-- | This option has an optional argument. The string describes the type of
--   the argument.
OptArg :: String -> (Maybe String -> OptSetter a) -> ArgDescr a
data GetOptException
GetOptException :: [String] -> GetOptException
data ArgOrder a
RequireOrder :: ArgOrder a
Permute :: ArgOrder a
ReturnInOrder :: (String -> a) -> ArgOrder a

-- | A default empty specification. The default argument order is
--   <tt>Permute</tt>.
optSpec :: OptSpec a

-- | Show the program's usage information on <a>stderr</a>.
dumpUsage :: OptSpec a -> IO ()

-- | Print the given messages on <a>stderr</a> and show the program's usage
--   info, then exit.
reportUsageError :: OptSpec a -> [String] -> IO b

-- | A string descibing the options.
usageString :: OptSpec a -> String
specToGetOpt :: OptSpec a -> [OptDescr (OptSetter a)]
instance GHC.Internal.Exception.Type.Exception SimpleGetOpt.GetOptException
instance GHC.Internal.Show.Show SimpleGetOpt.GetOptException
