!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 7Gets the command-line arguments supplied by the program's  user. If the base. package is older than version 4.4, then this A function assumes the command line is encoded in UTF-8, which is C true for many newer Unix systems; however, many older systems may > use single-byte encodings like ISO-8859. In such cases, this ' function will give erroneous results. If the base2 package is version 4.4.0 or newer, this function ) simply uses the getArgs that comes with base. That getArgs  detects the system'/s default encoding and uses that, so it should ( give accurate results on most systems. 8Gets the name of the program that the user invoked. See  documentation for ' for important caveats that also apply  to this function.      ?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 not have a dash as B either the first or second character and it 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). >This function is partial. It calls error if its argument is a @ single dash. This is the only way to make a short option so it / prevents you from making one that is invalid. BThis function is partial. It calls error if its argument contains D text that is not a valid long option. This is the only way to make < a long option so it prevents you from making invalid ones.       6BWhat the parser actually saw. To give some text to be used in the  error message, use #. To generate a generic error, use  .  !"#$%&'()*+,@Each error consists of two parts: what the parser was expecting C to see, and what it actually saw. This type holds what the parser C expected to see. If you just want to give some text to be used in  an error message, use 0. To generate a generic error,  use -. -./0123456789:;<=>?-A simple type that is already an instance of A. @A?Instances of this typeclass represent multiarg errors. You can B declare instances of this typeclass so that you can use your own B type for errors. This makes multiarg easy to integrate into your D own programs. Then you can also easily add other errors, which you 2 can report from the parsers you build by calling  "System.Console.MultiArg.Prim.throw. B'Store an error in your Error instance. CGenerates error messages. D.Generates an error message from an Expecting. E Generates error messages from a . 6 !"#$%&'()*+,-./0123456789:;<=>?@ABCDE6AB?@C,>=<;:9876543210/.-D+*)('&%$#"! E6+*)('&%$#"!  !"#$%&'()*+,>=<;:9876543210/.--./0123456789:;<=>?@@ABBCDE<FParser a, is a parser with user state (), error type < SimpleError, underlying monad Identity, and result type a. G ParserE e a/ is a parser with user state (), error type e, / underlying monad Identity, and result type a. HParserSE s e a. is a parser with user state s, error type e, / underlying monad Identity, and result type a. IParserT s e m a. is a parser with user state s, error type e, C underlying monad m, and result type a. Internally the parser is a : state monad which keeps track of what is remaining to be E parsed. Since the parser has an internal state anyway, the user can ? add to this state (this is called the user state.) The parser D ignores this user state so you can use it however you wish. If you : do not need a user state, just make it the unit type (). ?The parser also includes the notion of failure. Any parser can C fail; a failed parser affects the behavior of combinators such as 3 combine. The failure type should be a instance of E System.Console.MultiArg.Error.Error. This allows you to define your D own type and use it for the failure type, which can be useful when + combining MultiArg with your own program. ;The underlying monad is m. This makes ParserT into a monad D transformer; you can layer it on top of other monads. For instance C you might layer it on top of the IO monad so that your parser can D perform IO (for example, by examining the disk to see if arguments * that specify files are valid.) If you don't need a monad 5 transformer, just layer ParserT on top of Identity. "Carries the result of each parse. BCarries the internal state of the parser. The counter is a simple B way to determine whether the remaining list one ParseSt has been < modified from another. When parsers modify remaining, they  increment the counter. @Takes the head of a Text. Returns Nothing if the Text is empty. BConverts a Text to a TextNonEmpty. Returns Nothing if the Text is  empty. =Load up the ParseSt with an initial user state and a list of  commmand line arguments. J<Runs a parser that has a user state and an underlying monad  Identity. The initial user state Command line arguments Parser to run -Success or failure, and the final user state K@Runs a parser that has no user state and an underlying monad of 2 Identity and is parameterized on the error type.  Command line arguments to parse Parser to run Success or failure L=The simplest parser runner; has no user state, an underlying - monad Identity, and error type SimpleError.  Command line arguments to parse Parser to run Successful result or an error MBThe most complex parser runner. Runs a parser with a user-defined B state, error type, and underlying monad. Returns the final parse B result and the final user state, inside of the underlying monad. Initial user state  Command line arguments to parse Parser to run ;Success or failure and the final user state, inside of the  underlying monad N=Lifts a computation of the underlying monad into the ParserT - monad. This provides the implementation for  . O7Lifts a computation from the IO monad into the ParserT - monad. This provides the implementation for  . PACombines 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  in  Control.Monad.Monad. Q 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. Rgood a5 always succeeds without consuming any input and has 0 result a. This provides the implementation for  Control.Monad.Monad.return and  $Control.Applicative.Applicative.pure. S throwString s/ always fails without consuming any input. The > failure contains a record of the string passed in by s. This ! provides the implementation for Control.Monad.Monad.fail. T parserMap f p, applies function f to the result of parser D p. First parser p is run. If it succeeds, function f is applied to B the result and another parser is returned with the result. If it ? fails, f is not applied and a failed parser is returned. This ! provides the implementation for Prelude.Functor.fmap. UBapply l r applies the function found in parser l to the result of ? parser r. First the l parser is run. If it succeeds, it has a C resulting function. Then the r parser is run. If it succeeds, the > function from the l parser is applied to the result of the r A parser, and a new parser is returned with the result. If either D parser l or parser r fails, then a failed parser is returned. This ! provides the implementation for <*> in  . V<Fail with an unhelpful error message. Usually throw is more B useful, but this is handy to implement some typeclass instances. W?throw e always fails without consuming any input and returns a # failed parser with error state e. X@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 . YBRuns the parser given. If it succeeds, then returns the result of C the parser. If it fails and consumes input, returns the result of C the parser. If it fails without consuming any input, then changes % the error using the function given. Z?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; returns the short option parsed. [?Parses only non-pending short options. Fails without consuming  any input if, in order: ! 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 A from remaining arguments to be parsed. Returns the short option  parsed. \6Parses an exact long option. That is, the text of the 8 command-line option must exactly match the text of the B option. Returns the option, and 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 ATakes a single Text 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 @ there is no equal sign, or Just Text with everything after the  equal sign if there is one. ]8Examines the next word. If it matches a Text in the set C unambiguously, returns a tuple of the word actually found and the  matching word in the set. ^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 BOn success, returns the text of the pending short option argument  (this text cannot be empty). _ Parses a stopper0 - that is, a double dash. Changes the internal > state of the parser to reflect that a stopper has been seen. `Btry p behaves just like p, but if p fails, try p will not consume  any input. aAReturns the next string on the command line as long as there are D no pendings. Be careful - this will return the next string even if D it looks like an option (that is, it starts with a dash.) Consider C whether you should be using nonOptionPosArg instead. However this B can be useful when parsing command line options after a stopper. bAReturns the next string on the command line as long as there are B no pendings and as long as the next string does not begin with a A dash. If there has already been a stopper, then will return the , next string even if it starts with a dash. c?manyTill p e runs parser p repeatedly until parser e succeeds. CMore precisely, first it runs parser e. If parser e succeeds, then D manyTill returns the result of all the preceding successful parses D of p. If parser e fails (it does not matter whether e consumed any @ input or not), manyTill runs parser p again. What happens next D depends on whether p succeeded or failed. If p succeeded, then the B loop starts over by running parser e again. If p failed (it does A not matter whether it consumed any input or not), then manyTill @ fails. The state of the parser is updated to reflect its state ? after the failed run of p, and the parser is left in a failed  state. CShould parser e succeed (as it will on a successful application of = manyTill), then the parser state will reflect that parser e D succeeded--that is, if parser e consumes input, that input will be ; consumed in the parser that is returned. Wrap e inside of   lookAhead if that is undesirable. :Be particularly careful to get the order of the arguments B correct. Applying this function to reversed arguments will yield + bugs that are very difficult to diagnose. d?several p runs parser p zero or more times and returns all the > results. This proceeds like this: parser p is run and, if it 3 succeeds, the result is saved and parser p is run C again. Repeat. Eventually this will have to fail. If the last run D of parser p fails without consuming any input, then several p runs A successfully. The state of the parser is updated to reflect the @ successful runs of p. If the last run of parser p fails but it B consumed input, then several p fails. The state of the parser is ? updated to reflect the state up to and including the run that A partially consumed input. The parser is left in a failed state. DThis semantic can come in handy. For example you might run a parser ; multiple times that parses an option and arguments to the A option. If the arguments fail to parse, then several will fail. e)Succeeds if there is no more input left. fGets the user state. gPuts a new user state. hModify the user state. #FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh#FGHILKJMTRUXPQdcNOWSVY`Z[^\]_abefgh#FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi option x p1 runs parser p. If p fails without consuming any ) input, returns x. Otherwise, returns p. j optionMaybe p1 runs parser p. If p fails without returning any @ input, returns Nothing. If p succeeds, returns the result of p ? wrapped in a Just. If p fails but consumes input, optionMaybe  fails. knotFollowedBy 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. l@Parses only a non-GNU style long option (that is, one that does A not take option arguments by attaching them with an equal sign,  such as  --lines=20). m@Takes a long option and a set of long options. If the next word D on the command line unambiguously starts with the name of the long B option given, returns the actual text found on the command line, 7 the long option, and the text of any GNU-style option A argument. Make sure that the long option you are looking for is = both the first argument and that it is included in the set; ) otherwise this parser will always fail. n;Like matchApproxLongOpt but only parses non-GNU-style long  options. o>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 D from Set. If there is no match, fails without consuming any input. p;Parses short options that do not take any argument. (It is C however okay for the short option to be combined with other short  options in the same word.) qBParses short options that take an optional argument. The argument 9 can be combined in the same word with the short option (-c42) or  can be in the ext word (-c 42). rBParses short options that take a required argument. The argument 9 can be combined in the same word with the short option (-c42) or  can be in the ext word (-c 42). sAParses short options that take two required arguments. The first A argument can be combined in the same word with the short option  (-c42) or can be in the ext word (-c 42). The next argument % will have to be in a separate word. t4Parses short options that take a variable number of @ arguments. This will keep on parsing option arguments until it  encounters one that does not  look like an option--that is, until D it encounters one that begins with a dash. Therefore, the only way E to terminate a variable argument option if it is the last option is E with a stopper. The first argument can be combined in the same word  with the short option (-c42) or can be in the ext word (-c  42;). Subsequent arguments will have to be in separate words. u3Parses long options that do not take any argument. v?Parses long options that take a single, optional argument. The ) single argument can be given GNU-style ( --lines=20 ) or non-GNU  style in separate words (lines 20). w?Parses long options that take a single, required argument. The ) single argument can be given GNU-style ( --lines=20 ) or non-GNU  style in separate words (lines 20). x?Parses long options that take a double, required argument. The ( first argument can be given GNU-style ( --lines=20 ) or non-GNU  style in separate words (lines 20!). The second argument will have  to be in a separate word. y3Parses long options that take a variable number of @ arguments. This will keep on parsing option arguments until it  encounters one that does not  look like an option--that is, until D it encounters one that begins with a dash. Therefore, the only way E to terminate a variable argument option if it is the last option is E with a stopper. The first argument can be combined in the same word  with the short option ( --lines=20) or can be in the ext word  ( --lines 424). Subsequent arguments will have to be in separate  words. z?Parses at least one long option and a variable number of short * and long options that take no arguments. {?Parses at least one long option and a variable number of short 2 and long options that take an optional argument. |>Parses at least one long option and additional long and short ! options that take one argument. }=Parses at least one long option and additonal long and short " options that take two arguments. ~>Parses at least one long option and additional long and short 3 options that take a variable number of arguments. ijklmnopqrstuvwxyz{|}~ijkpqrstlmnuvwxyz{|}~oijklmnopqrstuvwxyz{|}~,4What 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. <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. 9Additional 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. BHolds the result of command line parsing. Each option (along with E its option arguments) or positional argument is assigned to its own  Result. <Each option must have at least one long option. So that you @ can distinguish one option from another, the name of that long  option is returned here. .This datatype does dual duty. When part of an  , you use E it to specify how many arguments, if any, an option takes. When you E use it for this purpose, it only matters which data constructor you ( use; the fields can be any value, even . When part of a Result, # indicates what arguments the user  supplied to the option. :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. 5This option takes two arguments. Parsed similarly to . 0This 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. 4This 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 :) This option takes no arguments 1Specifies each option that your program accepts. :Each option must have at least one long option, which you  specify here. Your program' s users specify long options by ) preceding them with two dashes, such as  --verbose. When writing 5 your code you omit the dashes, so you would specify verbose > here; including the dashes in your code results in a runtime  error. 6Additional, synonymous short options may be specified A here. For instance if you want your users to be able to specify  -v in addition to  --verbose , include v in this list. >Additional synonymous long options may be specified here. For  instance, if you specified quiet for longOpt , you might  want to include silent in this list. 5Specifies what arguments, if any, this option takes. -Specify that this option takes no arguments. 5Specify that this option takes an optional argument. -Specify that this option takes one argument. .Specify that this option takes two arguments. ?Specify that this option takes a variable number of arguments. Parse a command line. ;The command line to parse. This function correctly handles # Unicode strings; however, because  ? does not always correctly handle Unicode strings, consult the  documentation in System.Console.MultiArg.GetArgs and consider C using the functions in there if there is any chance that you will 7 be parsing command lines that have non-ASCII strings. #?#?!  #?    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~U R   multiarg-0.1.0.0$System.Console.MultiArg.SimpleParserSystem.Console.MultiArg.GetArgs)System.Console.MultiArg.QuickCheckHelpers$System.Console.MultiArg.TextNonEmptySystem.Console.MultiArg.OptionSystem.Console.MultiArg.ErrorSystem.Console.MultiArg.Prim"System.Console.MultiArg.Combinator$System.Console.MultiArg.SampleParserSystem.Console.MultiArgbaseSystem.EnvironmentgetArgs getProgNameWTextunWTextrandTextrandSet TextNonEmptyLongOpt unLongOptShortOpt unShortOpt makeShortOpt makeLongOptSawSawOtherFailure SawFollowedBy SawTextErrorSawNoOptionOrPosArg SawNoOptionSawMultipleApproxMatchesSawMatchingApproxLongWithArgSawNotMatchingApproxLongSawGNULongOptArg SawMoreInputSawLeadingDashArg SawNotStopper SawNewStopperSawAlreadyStopperSawNoPendingShortArgSawMultipleMatches SawNoMatchesSawWrongLongArg SawNotLongArgSawWrongShortArgSawNotShortArgSawStillPendingShortsSawSingleDashArg SawEmptyArg SawNoArgsLeftSawWrongPendingShortSawNoPendingShorts ExpectingExpOtherFailureExpNotFollowedByExpNonPendingShortOpt ExpTextErrorExpOptionOrPosArg ExpApproxWordExpNonGNUMatchingApproxLongExpMatchingApproxLongExpNonGNUExactLongExpEndExpNonOptionPosArg ExpNextArg ExpStopperExpPendingShortArg ExpLongOptArg ExpApproxLong ExpExactLongExpPendingShortOpt SimpleErrorErrorparseErr printErrorprintExpectingprintSawParserParserEParserSEParserTparseSEparseEparseparseT parserLiftparserIOcombine lookAheadgood throwString parserMapapply genericThrowthrowchoicependingShortOptnonPendingShortOpt exactLongOpt approxLongOptpendingShortOptArgstoppertrynextArgnonOptionPosArgmanyTillseveralendgetputmodifyoption optionMaybe notFollowedBynonGNUexactLongOptmatchApproxLongOptmatchNonGNUApproxLongOptmatchApproxWord shortNoArgshortOptionalArg shortOneArg shortTwoArgshortVariableArg longNoArglongOptionalArg longOneArg longTwoArglongVariableArg mixedNoArgmixedOptionalArg mixedOneArg mixedTwoArgmixedVariableArg Intersperse StopOptionsResultOptionlabelargsStopperPosArgposArgArgs VariableArgvArgsTwoArgtArg1tArg2OneArgsArg1 OptionalArgoArgNoArgOptSpeclongOpt shortOptslongOptsargSpecnoArg optionalArgoneArgtwoArg variableArgspecs sampleMainisValidLongOptTextTillgoodslastSt lastFailure runParserTGoodBadParseSt pendingShort remaining sawStopper userStatecountertextHeadtoTextNonEmpty defaultStatetransformers-0.2.2.0Control.Monad.Trans.ClassliftControl.Monad.IO.ClassliftIOGHC.Base>>=Control.Applicative Applicative noConsumed Alternative increment splitLongWord parseTill parseRepeat AfterArgs AAStopperFirstArg EndOfInputGHC.Err undefinedparseNoInterspersenoIntersperseArgs afterArgsparseIntersperse stopperParser posArgParseroptSpec