l      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk Safe-Inferred?Long options. Options that are preceded with two dashes on the E command line and typically consist of an entire mnemonic word, such  as lines8. However, anything that is at least one letter long is < fine for a long option name. The name must be at least one > character long. It cannot have an equal sign anywhere in its : name. Otherwise any Unicode character is good (including # pathological ones like newlines). ?Short options. Options that are preceded with a single dash on E the command line and consist of a single letter. That single letter B cannot be a dash. Any other Unicode character is good (including # pathological ones like newlines). @Creates a short option. Returns Nothing if the character is not  valid for a short option. BMakes a long option. Returns Nothing if the string is not a valid  long option. lmnlmn Safe-Inferred?Error messages. To format error messages for nice display, see  . ?Parsers. Internally the parser tracks what input remains to be D parsed, whether there are any pending short options, and whether a A stopper has been seen. A parser can return a value of any type. ?The parser also includes the notion of failure. Any parser can C fail; a failed parser affects the behavior of combinators such as  choice. good a5 always succeeds without consuming any input and has 0 result a. This provides the implementation for   and    . ACombines two parsers into a single parser. The second parser can : optionally depend upon the result from the first parser. =This applies the first parser. If the first parser succeeds, B combine then takes the result from the first parser, applies the > function given to the result from the first parser, and then  applies the resulting parser. =If the first parser fails, combine will not apply the second 5 function but instead will bypass the second parser. %This provides the implementation for o in  p.  failString s/ always fails without consuming any input. The > failure contains a record of the string passed in by s. This ! provides the implementation for  . .Fail with an unhelpful error message. Usually  throwString is < more useful, but this is handy to implement some typeclass  instances. @Runs the first parser. If it fails without consuming any input, A then runs the second parser. If the first parser succeeds, then C returns the result of the first parser. If the first parser fails : and consumes input, then returns the result of the first . parser. This provides the implementation for  <|> in q. rApplies s1 if a parser would succeed without consuming any = input. Useful for preventing infinite loops on parsers like  . ?Runs a parser one or more times. Runs the parser once and then  applies . @Runs a parser zero or more times. If the last run of the parser A fails without consuming any input, this parser succeeds without @ consuming any input. If the last run of the parser fails while @ consuming input, this parser fails while consuming input. This ! provides the implementation for many in Control.Applicative. @Runs the parser given. If it fails without consuming any input, ? replaces all Expected messages with the one given. Otherwise, - returns the result of the parser unchanged. >Runs a parser. This is the only way to change a value of type  Parser a into a value of type a! (that is, it is the only way to  "get out of the Parser monad" or to "escape the Parser monad".) ?Parses only pending short options. Fails without consuming any > input if there has already been a stopper or if there are no C pending short options. Fails without consuming any input if there C is a pending short option, but it does not match the short option C given. Succeeds and consumes a pending short option if it matches  the short option given.  lookAhead p4 runs parser p. If p succeeds, lookAhead p succeeds ? without consuming any input. If p fails without consuming any D input, so does lookAhead. If p fails and consumes input, lookAhead E also fails and consumes input. If this is undesirable, combine with  try. ?Parses only non-pending short options. Fails without consuming  any input if: ! there are pending short options " there has already been a stopper & there are no arguments left to parse & the next argument is an empty string . the next argument does not begin with a dash $ the next argument is a single dash ; the next argument is a short option but it does not match  the one given  the next argument is a stopper BOtherwise, consumes the next argument, puts any remaining letters D from the argument into a pending short, and removes the first word ( from remaining arguments to be parsed. 6Parses an exact long option. That is, the text of the 8 command-line option must exactly match the text of the 2 option. Returns any argument that is attached to > the same word of the option with an equal sign (for example,   --follow=/dev/random will return Just "/dev/random" for the ? argument.) If there is no equal sign, returns Nothing for the D argument. If there is an equal sign but there is nothing after it,  returns Just "" for the argument. <If you do not want your long option to have equal signs and E GNU-style option arguments, wrap this parser in something that will & fail if there is an option argument. &Fails without consuming any input if: ! there are pending short options  a stopper has been parsed 1 there are no arguments left on the command line ; the next argument on the command line does not begin with  two dashes * the next argument on the command line is -- (a stopper) ; the next argument on the command line does begin with two 5 dashes but its text does not match the argument we're looking for tCTakes a single String and returns a tuple, where the first element E is the first two letters, the second element is everything from the E third letter to the equal sign, and the third element is Nothing if B there is no equal sign, or Just String with everything after the  equal sign if there is one. ;Examines the next word. If it matches a LongOpt in the set C unambiguously, returns a tuple of the word actually found and the D matching word in the set and the accompanying text after the equal C sign (if any). If the Set is empty, this parser will always fail. AParses only pending short option arguments. For example, for the  tail" command, if you enter the option -c25, then after parsing  the -c option the 25) becomes a pending short option argument 9 because it was in the same command line argument as the -c. &Fails without consuming any input if: # a stopper has already been parsed - there are no pending short option arguments DOn success, returns the String of the pending short option argument $ (this String will never be empty).  Parses a "stopper"0 - that is, a double dash. Changes the internal > state of the parser to reflect that a stopper has been seen. >If a stopper has already been seen, change the internal state 3 back to indicating that no stopper has been seen. Btry p behaves just like p, but if p fails, try p will not consume  any input. AReturns the next string on the command line as long as there are B no pendings. Succeeds even if a stopper is present. Be careful - B this will return the next string even if it looks like an option B (that is, it starts with a dash.) Consider whether you should be @ using nonOptionPosArg instead. However this can be useful when / parsing command line options after a stopper. !AParses the next word on the command line, but only if it exactly @ matches the word given. Otherwise, fails without consuming any D input. Also fails without consuming any input if there are pending E short options or if a stopper has already been parsed. Does not pay 0 any attention to whether a stopper is present. "GIf there are pending short options, fails without consuming any input. BOtherwise, if a stopper has NOT already been parsed, then returns D the next word if it is either a single dash or any other word that B does not begin with a dash. If the next word does not meet these . criteria, fails without consuming any input. BOtherwise, if a stopper has already been parsed, then returns the @ next word, regardless of whether it begins with a dash or not. #)Succeeds if there is no more input left. $>Examines the possible words in Set. If there are no pendings, B then get the next word and see if it matches one of the words in D Set. If so, returns the word actually parsed and the matching word = from Set. If there is no match, fails without consuming any > input. Pays no attention to whether a stopper has been seen. %manyTill p end/ runs parser p zero or more times until parser  end succeeds. If end, succeeds and consumes input, that input is ! also consumed. in the result of manyTill. If that is a problem,  wrap it in  lookAhead . Also, if end fails and consumes input,  manyTill6 fails and consumes input. If that is a problem, wrap  end in try. 9uvwxyz {|}~ rUse this label when applying s ?Command line arguments to parse. Presumably you got these from  getArgs2. If there is any chance that you will be parsing + Unicode strings, see the documentation in  System.Console.MultiArg.GetArgs before you use    . Parser to run <Success or failure. Any parser might fail; for example, the B command line might not have any values left to parse. Use of the  , combinator can lead to a list of failures. t !"#$%   !"#$% % !"$#  .uwvxzy {|}~ rt !"#$% Safe-Inferred&8Specifies how many arguments each option takes. As with  #, there are (at least) two ways to D use this type. You can simply represent each possible option using C different data constructors in an algebraic data type. Or you can E have each ArgSpec yield a function that transforms a record. For an / example that uses an algebraic data type, see  $System.Console.MultiArg.SampleParser. 6Some of these value constructors have names ending in E. Use E these constructors when you want to parse option arguments that may D fail to parse--for example, you want to parse an Int. The function E passed as an argument to the value constructor indicates failure by  returing an  Exception. '7This option takes a variable number of arguments, like  -'. Parsing of the arguments might fail. ((This option takes three arguments, like . . Parsing  of the arguments might fail. )&This option takes two arguments, like / . Parsing of  the arguments might fail. **This option takes a single argument, like 0 . Parsing  of the argument might fail. +-This option takes an optional argument, like  1/. Parsing of the optional argument might fail. ,=This option takes a single argument, which must match one of A the strings given in the list. The user may supply the shortest ; unambiguous string. If the argument list to ChoiceArg has A duplicate strings, only the first string is used. For instance, 3 ChoiceArg could be useful if you were parsing the --color > option to GNU grep, which requires the user to supply one of  three arguments: always, never, or auto. -:This option takes a variable number of arguments--zero or A more. Option arguments continue until the command line contains : a word that begins with a hyphen. For example, if option a , takes a variable number of arguments, then -a one two three  -b will be parsed as a taking three arguments, and -a -b  will be parsed as a) taking no arguments. If the user enters  -a; as the last option on the command line, then the only way & to indicate the end of arguments for a and the beginning of ( positional argments is with a stopper. .7This option takes three arguments. Parsed similarly to  0. /5This option takes two arguments. Parsed similarly to  0. 00This option takes one argument. Here, if option a takes one  argument, -a -b will be parsed with -b being an argument to  option a, even though -b$ starts with a hyphen and therefore  " looks like" an option. 14This option takes an optional argument. As noted in "The Tao  of Option Parsing"(, optional arguments can result in some  ambiguity. (Read it here:   -http://optik.sourceforge.net/doc/1.5/tao.html ) If option a ! takes an optional argument, and b is also an option, what  does -ab/ mean? SimpleParser resolves this ambiguity by  assuming that b is an argument to a. If the user does not  like this, she can specify -a -b (in such an instance -b is  not parsed as an option to -a , because -b begins with a  hyphen and therefore " looks like" an option.) Certainly < though, optional arguments lead to ambiguity, so if you don't  like it, don't use them :) 2This option takes no arguments 34Indicates errors when parsing options to arguments. 4@Parsing the argument failed with this error message. An example  might be !option argument is not an integer or option argument  is too large/. The text of the options the user provided is C automatically prepended to the error message, so do not replicate  this in your message. 5@No error message accompanies this failure. multiarg will create " a generic error message for you. 6Specifies options for the > function. Each OptSpec % represents one command-line option. 8-Each String is a single long option, such as version. When ? the user specifies long options on the command line, she must > type two dashes; however, do not include the dashes when you C specify the long option here. Strings you specify as long options 9 cannot include a dash as either the first or the second ? character, and they cannot include an equal sign anywhere. If B your long option does not meet these conditions, a runtime error  will occur. 9,Each Char is a single short option, such as v. The C character cannot be a dash; if it is, a runtime error will occur. :6What to do each time one of the given long options or , short options appears on the command line. ;notFollowedBy p. succeeds only if parser p fails. If p fails, C notFollowedBy succeeds without consuming any input. If p succeeds B and consumes input, notFollowedBy fails and consumes input. If p B succeeds and does not consume any input, notFollowedBy fails and  does not consume any input. <=Reads in values that are members of Read. Provides a generic " error message if the read fails. =AReads in values that are members of Read, but the value does not > have to appear on the command line. Provides a generic error @ message if the read fails. If the argument is Nothing, returns  Nothing. ,Create an error message from an InputError. >>Parses a single command line option. Examines all the options ? specified using multiple OptSpec and parses one option on the D command line accordingly. Fails without consuming any input if the B next word on the command line is not a recognized option. Allows = the user to specify the shortest unambiguous match for long + options; for example, the user could type --verb for  --verbose  and --vers for  --version. @This function is applied to a list of OptSpec, rather than to a E single OptSpec, because in order to correctly handle the parsing of  shortened long options (e.g. --verb rather than  --verbose) it < is necessary for one function to have access to all of the C OptSpec. Applying this function multiple times to different lists  of OptSpec and then using the  | function to combine them will 5 break the proper parsing of shortened long options. ,For an example that uses this function, see  $System.Console.MultiArg.SimpleParser. =Parses a short option without an argument, either pending or A non-pending. Fails with a single error message rather than two. <Finds the unambiguous short match for a string, if there is B one. Returns a string describing the error condition if there is , one, or the matching result if successful. ?>Formats error messages for nice display. Returns a multi-line @ string (there is no need to append a newline to the end of the  string returned). 2&'()*+,-./0123456789:;<=$The option with the faulty argument "The faulty command line arguments >??Pass the name of your program here. Displayed at the beginning  of the error message. &'()*+,-./0123456789:;<=>?;6789:354<=&210/.-,+*)('>? & 210/.-,+*)('3546789:;<=>? Safe-Inferred@>The name of the program that was entered on the command line, / obtained from System.Environment.getProgName. ASpecifies a mode. C:How the user specifies the mode on the command line. For git  for example this might be commit or log. DAThis function is applied to a list of the results of parsing the A options that are specific to this mode. The function returns a A type of your choosing (though all modes in the same parser will  have to return the same type.) E;Options and positional arguments that are specific to this ) mode. For example, in the command line git commit -a -m 'this  is a log message', commit! is the mode name and everything B after that is specified here as an option or positional argument  that is specific to this mode. F9Specification for both options and positional arguments. K:Things that contain shortcut options that can be changed. MSpecifies a set of options. O;If the user does not specify any shortcut options, she may & specify any number of these options. P.Shortcut options are commonly options such as --help or   --version6. Such options must be specified alone on the command @ line. The parser looks for one of these options first. If it ? finds one and it is the only option on the command line, only > this option is processed and returned. If the option is not = alone on the command line, an error occurs. If no shortcut < option is found, the parser processes non-shortcut options  instead. Q4What to do after encountering the first non-option, B non-option-argument word on the command line? In either case, no * more options are parsed after a stopper. R<No additional options will be parsed after encountering the , first positional argument. For example, if a and b are  options, in the command line  -a posarg -b, b will be parsed 4 as a positional argument rather than as an option. S9Additional options are allowed on the command line after = encountering the first positional argument. For example, if a  and b" are options, in the command line  -a posarg -b, b will  be parsed as an option. If b is not an option and the same  command line is entered, then -b will result in an error  because -b$ starts with a hyphen and therefore " looks like" an  option. T-Creates an Opts with a help shortcut option. U8Creates an Opts with help and version shortcut options. V?Creates a Mode with a help option (help specific to the mode.) WBA pure (non-IO) parser for simple command lines--that is, command  lines that do not have modes. X=A pure (non-IO) parser for command lines that contain modes. Y=A parser for simple command lines that do not contain modes.  Runs in the IO monad. ZAA command line parser for multi-mode command lines. Runs in the  IO monad. [*A parser for simple command lines. Adds a --help option for  you. \?A parser for simple command lines without modes. Adds options  for --help and  --version for you. :Parses positional arguments and handles errors with them. :Parses options only, where they are not interspersed with E positional arguments. Stops parsing only where it encouters a word E that does not begin with a dash. This way if the user enters a bad C option, it shows in the error message as a bad option rather than  simply not getting parsed. >Parses options and positional arguments where the two are not C interspersed. Stops parsing options when a stopper is encountered 9 or at the first word that does not look like an option. parseIntersperse o p* parses options and positional arguments, D where o is a parser that parses options, and p is a function that, 9 when applied to a string, returns the appropriate type. ALooks at the next word. Succeeds if it is a non-option, or if we + are at the end of input. Fails otherwise. /@ABCDEFGHIJKLMNOPQRST'Whatever type you wish to use for help UWhat you wish to use for help !What you wish to use for version V Mode name >Whatever you want to use for the help (perhaps a string, or a B function, or an IO action). Its type will have to match up with ? the type of the global shortcut options and with the shortcut  type of the other modes. :When applied to the the mode options, returns the result. Options for this mode >Allow interspersion of mode options and positional arguments? Parses positional arguments W=Specifies allowed regular options, allowed shortcut options, @ and how to parse positional arguments. Also specifies whether = the user may intersperse options with positional arguments. $The command line arguments to parse <Returns an error if the command line arguments could not be A parsed. If the parse was successful, returns an Either. A Left > indicates that the user selected a shortcut option. A Right @ indicates that the user did not specify a shortcut option, and > will contain a list of the options and positional arguments. X;Global options. These are specified before any mode. For  instance, in the command git --no-pager commit -a , the option   --no-pager1 is a global option. Global options can contain " shortcut options. For instance,  git --help contains a single  shortcut option. =This function processes the global options. If there are no A shortcut options specified in the global options, it is applied @ to the result of processing the global options. This function > may return an Exception if there is something wrong with the B global options (a nonsensical combination, perhaps.) Otherwise, = it returns an Either. Return a Left if there is no need to ; process any modes at all after seeing the global options. 1 Otherwise, return a Right with a list of modes.  Command line arguments to parse =If the command line arguments fail to parse, this will be an > Exception with the error. If the parser is successful, this = returns an Either. A Left indicates that the user entered a @ shortcut option, either in the global options or in one of the B mode-specific options. A Right indicates that the user selected  a mode. YOptions to parse .Allow interspersion of options and arguments? "How to parse positional arguments @If there is an error parsing the command line, the program will < exit with an error message. If successful the results are  returned here. Z5Specifies global options and global shortcut options =This function processes the global options. If there are no A shortcut options specified in the global options, it is applied @ to the result of processing the global options. This function > may return an Exception if there is something wrong with the B global options (a nonsensical combination, perhaps.) Otherwise, = it returns an Either. Return a Left if there is no need to ; process any modes at all after seeing the global options. 1 Otherwise, return a Right with a list of modes. ;If parsing fails, the program will exit with a failure. If > successful, the result is returned here. A Left indicates a = shortcut option, either from the global options or from the : mode-specific options; a Right indicates the mode a user  selected. [@Indicate the help here. This function, when applied to the name > of the program, returns help. simpleHelp automatically adds  options for --help and -h for you. Options to parse 9Allow interspersion of options and positional arguments? "How to parse positional arguments >If the parser fails, the program will exit with an error. If ? the user requested help, it will be displayed and the program < exits successfully. Otherwise, the options and positional  arguments are returned here. \@Indicate the help here. This function, when applied to the name E of the program, returns help. simpleHelpVersion automatically adds  options for --help and -h for you. >Indicate the version here. This function, when applied to the C name of the program, returns a version string. simpleHelpVersion " automatically adds an option for  --version for you. Options to parse 9Allow interspersion of options and positional arguments? "How to parse positional arguments >If the parser fails, the program will exit with an error. If < the user requested help or version information, it will be ? displayed and the program exits successfully. Otherwise, the 5 options and positional arguments are returned here. @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\QSR@MNOPKLFGHIJABCDEWY[\XZTUV!@ABCDEFGHIJKLMNOPQSRTUVWXYZ[\ Safe-Inferred]^_`abcdefghijk]^_`abcdefghijk]ihgfedcba`_^jk] ihgfedcba`_^jk Safe-Inferred  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFFGHIJKLMNOOPQRSSTUVWXYYZ[\]\^_`abcdefghijklmnopqrstuvwxywxzw{|}w~w w w w w w w wmultiarg-0.18.0.0System.Console.MultiArg.OptionSystem.Console.MultiArg.Prim"System.Console.MultiArg.Combinator#System.Console.MultiArg.CommandLine$System.Console.MultiArg.SampleParser formatErrorControl.Monad.MonadreturnControl.Applicative.ApplicativepurefailSystem.EnvironmentgetArgsSystem.Console.GetOptArgDescrSystem.Console.MultiArgLongOpt unLongOptShortOpt unShortOpt makeShortOpt makeLongOptError DescriptionExpectedGeneralUnknown InputDescParsergoodbind failString genericThrowchoiceseveral1severalparsependingShortOpt lookAheadnonPendingShortOpt exactLongOpt approxLongOptpendingShortOptArgstopper resetStoppertrynextWord nextWordIsnonOptionPosArgendmatchApproxWordmanyTillArgSpec VariableArgE ThreeArgETwoArgEOneArgE OptionalArgE ChoiceArg VariableArgThreeArgTwoArgOneArg OptionalArgNoArg InputErrorErrorMsgNoMsgOptSpeclongOpts shortOptsargSpec notFollowedByreader optReader parseOptionProgNameMode mModeName mGetResultmOptsOptsWithPosArgsopOpts opIntersperseopPosArg MapShortcutssmapOptsoOptions oShortcuts Intersperse StopOptionsoptsHelpoptsHelpVersionmodeHelp simplePure modesPuresimpleIOmodesIO simpleHelpsimpleHelpVersionFlagFilenameVersionHelpVerboseSleepQuietPidStatsLinesRetryFollowBytesspecs sampleMainisValidLongOptTextbaseGHC.Base>>=MonadControl.Applicative AlternativecrashOnEmptyOkGHC.Errerror splitLongWordConsumedEmptyReplyFailOkState SawStopper Remaining PendingShort runParser descLocationnextW getLongOptionapproxLongOptError$fMonadPlusParser$fMonoidParser$fAlternativeParser$fApplicativeParser$fFunctorParser $fMonadParsererrorMsg nextShort matchAbbrevunsafeShortOpt unsafeLongOpt longOptParser longOptSet longOptMaplongOptshortOptshortVariableArgshortVariableArgE shortOneArg shortOneArgE firstShortArgshortChoiceArg shortTwoArg shortTwoArgE shortThreeArgshortThreeArgEshortOptionalArgshortOptionalArgE$fFunctorArgSpec$fFunctorOptSpec parsePosArgparseOptsNoIntersperse parseStopOptsparseIntersperse endOrNonOpt parseOptsparseOptsWithPosArgs parseModessimpleIOCustomError displayActerrorActerrorActDisplayHelp $fFunctorMode$fMapShortcutsMode$fFunctorOptsWithPosArgs$fMapShortcutsOptsWithPosArgs$fMapShortcutsOpts $fFunctorOptsgetEnvironment withProgNamewithArgs lookupEnvgetEnv getProgName!System.Environment.ExecutablePathgetExecutablePathexplicit-exception-0.1.7.1#Control.Monad.Exception.SynchronousmergeT manyMonoidTmanyTtryTresolveTbracketTcatchTassertTthrowTmapExceptionalT mapExceptionTforceTswitchT fromExitCodeT toExitCodeT toEitherT fromEitherTtoErrorT fromErrorTtoMaybeT fromMaybeTmergeresolvecatchassertthrowmapExceptional mapExceptionforceswitchgetExceptionNull fromExitCode toExitCodetoEithertoMaybe fromEither fromMaybeSuccess Exception ExceptionalrunExceptionalT ExceptionalT