s~m^      Safe-  !"#$%& !"#$% !"#$%&Safe'()'('()Safe *+,-./0123 *+,-./0123*+,-./0123Safe -3455Type to wrap results from the pure parsing functions./The CLI was used correctly and a value of type a! was successfully constructed. "The CLI was used incorrectly. The & contains a list of error messages.ZIt can also happen that the data type you're trying to use isn't supported. See the  9https://github.com/zalora/getopt-generics#getopt-genericsREADME for details. The CLI was used with --help. The  contains the help message.  45678 45 45678Safe !"*INU9:;<=>?@ABCDEFGHIJKLM9:;<=>?@ABCDEFGHIJKL 9:;<=>?@ABCDEFGHIJKLMNone !")135NU   is a typeclass for things that can be parsed as atomic values from single command line arguments, e.g. strings (and filenames) and numbers.Occasionally you might want to declare your own instance for additional type safety and for providing a more informative command argument type. Here's an example: q {-# LANGUAGE DeriveDataTypeable #-} import WithCli data File = File FilePath deriving (Show, Typeable) instance Argument File where argumentType Proxy = "custom-file-type" parseArgument f = Just (File f) instance HasArguments File where argumentsParser = atomicArgumentsParser main :: IO () main = withCli run run :: File -> IO () run = print*And this is how the above program behaves: ~ $ program --help program [OPTIONS] custom-file-type -h --help show help and exit $ program some/file File "some/file" NOPQRS N  NOPQRS Safe !"4FU3s can be used to customize the command line parser.AddShortOption fieldName c adds the T c1 as a short option for the field addressed by  fieldName.!RenameOption fieldName customName- renames the option generated through the  fieldName by  customName.RenameOptions fO renames all options with the given functions. In case the function returns Nothing! the original field name is used.Can be used together with  .0UseForPositionalArguments fieldName argumentType! fills the field addressed by  fieldNamer with the positional arguments (i.e. arguments that don't correspond to a flag). The field has to have type [U]. argumentTypeG is used as the type of the positional arguments in the help output. AddOptionHelp fieldName helpText$ adds a help text for the option  fieldName.AddVersionFlag version adds a  --version flag.VWXYZ[\]*123VWYZ VWXYZ[\] None !"&)+-013457>FIKLNU3Everything that can be used as an argument to your main function (see withCli) needs to have a  instance.{ also allows to conjure up instances for record types to create more complex command line interfaces. Here's an example: 1 {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} import WithCli data Options = Options { port :: Int, daemonize :: Bool, config :: Maybe FilePath } deriving (Show, Generic, HasArguments) main :: IO () main = withCli run run :: Options -> IO () run = print*In a shell this program behaves like this:  $ program --port 8080 --config some/path Options {port = 8080, daemonize = False, config = Just "some/path"} $ program --port 8080 --daemonize Options {port = 8080, daemonize = True, config = Nothing} $ program --port foo cannot parse as INTEGER: foo # exit-code 1 $ program missing option: --port=INTEGER # exit-code 1 $ program --help program [OPTIONS] --port=INTEGER --daemonize --config=STRING (optional) -h --help show help and exit.Useful for implementing your own instances of  on top of a custom   instance.^_`abcdefghijklmnopq^_`abcdefgh^_`abcdefghijklmnopqNone 135>LNU!Everything that can be used as a main function with ! needs to have an instance of 8. You shouldn't need to implement your own instances.h converts an IO operation into a program with a proper CLI. Retrieves command line arguments through r. mainm (the given IO operation) can have arbitrarily many parameters provided all parameters have instances for .#May throw the following exceptions: ExitFailure 1@ in case of invalid options. Error messages are written to stderr. ExitSuccess in case --help is given. ( ExitSuccesso behaves like a normal exception, except that -- if uncaught -- the process will exit with exit-code 0.) Help output is written to stdout.Example: x import WithCli main :: IO () main = withCli run run :: String -> Int -> Bool -> IO () run s i b = print (s, i, b)#Using the above program in a shell: ~ $ program foo 42 true ("foo",42,True) $ program --help program [OPTIONS] STRING INTEGER BOOL -h --help show help and exit $ program foo 42 bar cannot parse as BOOL: bar # exit-code 1 $ program missing argument of type STRING missing argument of type INTEGER missing argument of type BOOL # exit-code 1 $ program foo 42 yes bar unknown argument: bar # exit-code 1This is a variant of U that allows to tweak the generated command line interface by providing a list of s.stu  stuNone  &4>LN+Parses command line arguments (gotten from rW) and returns the parsed value. This function should be enough for simple use-cases.Throws the same exceptions as .Here's an example:  {-# LANGUAGE DeriveGeneric #-} module RecordType where import System.Console.GetOpt.Generics -- All you have to do is to define a type and derive an instance for Generic: data Options = Options { port :: Int, daemonize :: Bool, config :: Maybe FilePath } deriving (Show, Generic) -- Then you can use `getArguments` to create a command-line argument parser: main :: IO () main = do options <- getArguments print (options :: Options)*And this is how the above program behaves:  $ program --port 8080 --config some/path Options {port = 8080, daemonize = False, config = Just "some/path"} $ program --port 8080 --daemonize Options {port = 8080, daemonize = True, config = Nothing} $ program --port foo cannot parse as INTEGER: foo # exit-code 1 $ program missing option: --port=INTEGER # exit-code 1 $ program --help program [OPTIONS] --port=INTEGER --daemonize --config=STRING (optional) -h --help show help and exitLike  but allows you to pass in s.Pure variant of .Does not throw any exceptions.Name of the program (e.g. from v).List of /s to manually tweak the command line interface.3List of command line arguments to parse (e.g. from w).   x     ! " # $ % & ' ( ) *+,-./0123456789:;<<=>?@ABCDEFGHIJKLLMNOPQQRSTUVWXYZ[\]^_`abcde fg h i j k l m n o p q r s t u v w x y z { | } ~   getop_IOB6Q5hjORfEjWxEiw0psRWithCliSystem.Console.GetOpt.Generics WithCli.FlagWithCli.Normalize-System.Console.GetOpt.Generics.Modifier.TypesWithCli.ResultWithCli.ParserWithCli.Argument'System.Console.GetOpt.Generics.Modifier Data.List stripPrefixWithCli.HasArgumentsbaseData.Typeable.InternalTypeable GHC.GenericsGeneric Data.ProxyProxygener_3yxdDgIB0bACzU0F344ehVGenerics.SOP.GGPGCode GDatatypeInfoGenerics.SOP.ConstraintAll2ResultSuccessErrors OutputAndExitArgument argumentType parseArgumentModifierAddShortOption RenameOption RenameOptionsUseForPositionalArguments AddOptionHelpAddVersionFlag HasArgumentsargumentsParseratomicArgumentsParserwithCliwithCliModified getArgumentsmodifiedGetArgumentsparseArgumentsFlagHelpVersionNoHelp foldFlags helpOption versionOptionusage $fMonoidFlagmatches normalize isAllowedChar Modifiers shortOptionsrenamingpositionalArgumentsField _helpTextsversion getVersionisPositionalArgumentsFieldgetPositionalArgumentType handleResultsanitizestripTrailingSpaces $fMonadResult$fApplicativeResult Normalized UnnormalizedParser parserDefault parserOptionsparserNonOptions parserConvertNonOptionsParsernonOptionsTypenonOptionsParsercombineNonOptionsParser emptyParsernormalizeParsermodParserOptionscombine fillInOptionsfillInNonOptions runParser$fFunctorParser readFloat$fArgumentDouble$fArgumentFloat$fArgumentInteger $fArgumentInt $fArgument[]ghc-prim GHC.TypesCharGHC.BaseString mkModifiers insertWithinsertapplyModifiersapplyModifiersLonglongsaddShortmodLongsparseArgumentResult parseErrorwrapForPositionalArguments listParserpositionalArgumentsParser maybeParser boolParser parseBool genericParser fieldsParsernoSelectorsParser$fHasArguments[]$fHasArgumentsMaybe$fHasArguments(,,)$fHasArguments(,)$fHasArgumentsDouble$fHasArgumentsFloat$fHasArguments[]0$fHasArgumentsBool$fHasArgumentsIntSystem.EnvironmentwithArgs_run $fWithCli(->) $fWithCliIO getProgNamegetArgs