/*---------------------------------------------------------------------------
  Copyright 2012-2021, Microsoft Research, Daan Leijen.

  This is free software; you can redistribute it and/or modify it under the
  terms of the Apache License, Version 2.0. A copy of the License can be
  found in the LICENSE file at the root of this distribution.
---------------------------------------------------------------------------*/

/* Parsing of command line flags.

For example:

```
struct myflags(
  verbose : bool = False,
  version : bool = False,
  name : string = "",
  output : string = "",
  arguments : list<string> = []
)

val myflags : list<flag<myflags>>
  = [ Flag( "V?", ["version"], Bool(set-version),     "display version information" ),
      Flag( "v",  ["verbose"], Bool(set-verbose),     "verbosely list files"),
      Flag( "o",  ["output"],  Opt(set-output,"FILE"),"use FILE for dump" ),
      Flag( "n",  ["name"],    Req(set-name,"USER"),  "only show USER files" ),
    ]

fun set-name( t : myflags, name )  { t(name = name)
fun set-verbose( t : myflags, v )  { t(verbose = v)
fun set-version( t : myflags, v )  { t(version = v)
fun set-output( t : myflags, mbs : maybe<string> ) : myflags

  match(mbs)
    Nothing -> t(output = "stdout")
    Just(s) -> t(output = s)


pub fun test( cmdargs )

  val header = "usage:\n program [options] files\n\noptions:"
  // testflags.usageInfo( header ).println
  val (flags,args,errs) = parse( Myflags(), myflags, cmdargs )
  if (errs.is-nil)
    println( "\nsuccess!" );
    println( "flags: " ++ flags.show-flags)
    println( "arguments: " ++ args.join(" ") );
    if (flags.version) myflags.usage(header).println

  else
    println( errs.join("\n") ++ "\n" ++ myflags.usage(header) )


fun show-flags( o : myflags )
  "{" ++ ["verbose=" ++ o.verbose.show,
         "version=" ++ o.version.show,
         "name=" ++ o.name.show,
         "output=" ++ o.output.show,
         "arguments=" ++ o.arguments.join(",")].join(";") ++ "}"

```
\/
*/
module std/os/flagsstd/os/flags

import std/os/envstd/os/env

// ----------------------------------------------------
// Usage example
// ----------------------------------------------------

struct myflagsstd/os/flags/myflags: V(
  verboseverbose: bool : boolstd/core/types/bool: V = Falsestd/core/types/False: bool,
  versionversion: bool : boolstd/core/types/bool: V = Falsestd/core/types/False: bool,
  namename: string : stringstd/core/types/string: V = ""literal: string
count= 0
, outputoutput: string : stringstd/core/types/string: V = ""literal: string
count= 0
, argumentsarguments: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> = [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>
) fun show-flagsstd/os/flags/show-flags: (o : myflags) -> string( oo: myflags : myflagsstd/os/flags/myflags: V )result: -> total string "{"literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"verbose="literal: string
count= 8
++std/core/types/(++): (x : string, y : string) -> string oo: myflags.verbosestd/os/flags/myflags/verbose: (myflags : myflags) -> bool.showstd/core/bool/show: (b : bool) -> string, "version="literal: string
count= 8
++std/core/types/(++): (x : string, y : string) -> string oo: myflags.versionstd/os/flags/myflags/version: (myflags : myflags) -> bool.showstd/core/bool/show: (b : bool) -> string, "name="literal: string
count= 5
++std/core/types/(++): (x : string, y : string) -> string oo: myflags.namestd/os/flags/myflags/name: (myflags : myflags) -> string.showstd/core/show/string/show: (s : string) -> string, "output="literal: string
count= 7
++std/core/types/(++): (x : string, y : string) -> string oo: myflags.outputstd/os/flags/myflags/output: (myflags : myflags) -> string.showstd/core/show/string/show: (s : string) -> string, "arguments="literal: string
count= 10
++std/core/types/(++): (x : string, y : string) -> string oo: myflags.argumentsstd/os/flags/myflags/arguments: (myflags : myflags) -> list<string>.joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> string(","literal: string
count= 1
)]std/core/types/Nil: forall<a> list<a>.joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> string(";"literal: string
count= 1
) ++std/core/types/(++): (x : string, y : string) -> string "}"literal: string
count= 1
fun set-namestd/os/flags/set-name: (t : myflags, name : string) -> myflags( tt: myflags : myflagsstd/os/flags/myflags: V, namename: string )result: -> total myflags { tt: myflags(name = namename: string) } fun set-verbosestd/os/flags/set-verbose: (t : myflags, v : bool) -> myflags( tt: myflags : myflagsstd/os/flags/myflags: V, vv: bool : boolstd/core/types/bool: V)result: -> total myflags : myflagsstd/os/flags/myflags: V { tt: myflags(verbose = vv: bool) } fun set-versionstd/os/flags/set-version: (t : myflags, v : bool) -> myflags( tt: myflags : myflagsstd/os/flags/myflags: V, vv: bool )result: -> total myflags { tt: myflags(version = vv: bool) } fun set-outputstd/os/flags/set-output: (t : myflags, mbs : maybe<string>) -> myflags( tt: myflags : myflagsstd/os/flags/myflags: V, mbsmbs: maybe<string> : maybestd/core/types/maybe: V -> V<stringstd/core/types/string: V> )result: -> total myflags : myflagsstd/os/flags/myflags: V match(mbsmbs: maybe<string>) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> tt: myflags(output = "stdout"literal: string
count= 6
) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(ss: string) -> tt: myflags(output = ss: string
) val myflagsstd/os/flags/myflags: list<flag<myflags>> : liststd/core/types/list: V -> V<flagstd/os/flags/flag: V -> V<myflagsstd/os/flags/myflags: V>> = [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a> Flagstd/os/flags/Flag: forall<a> (short-names : string, long-names : list<string>, parser : flag-parser<a>, help : string) -> flag<a>( "V?"literal: string
count= 2
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"version"literal: string
count= 7
]std/core/types/Nil: forall<a> list<a>, Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a>(set-versionstd/os/flags/set-version: (t : myflags, v : bool) -> myflags), "display version information"literal: string
count= 27
), Flagstd/os/flags/Flag: forall<a> (short-names : string, long-names : list<string>, parser : flag-parser<a>, help : string) -> flag<a>( "v"literal: string
count= 1
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"verbose"literal: string
count= 7
]std/core/types/Nil: forall<a> list<a>, Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a>(set-verbosestd/os/flags/set-verbose: (t : myflags, v : bool) -> myflags), "verbosely list files"literal: string
count= 20
), Flagstd/os/flags/Flag: forall<a> (short-names : string, long-names : list<string>, parser : flag-parser<a>, help : string) -> flag<a>( "o"literal: string
count= 1
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"output"literal: string
count= 6
]std/core/types/Nil: forall<a> list<a>, Optstd/os/flags/Opt: forall<a> (parse : (a, maybe<string>) -> a, help : string) -> flag-parser<a>(set-outputstd/os/flags/set-output: (t : myflags, mbs : maybe<string>) -> myflags,"FILE"literal: string
count= 4
),"use FILE for dump"literal: string
count= 17
), Flagstd/os/flags/Flag: forall<a> (short-names : string, long-names : list<string>, parser : flag-parser<a>, help : string) -> flag<a>( "n"literal: string
count= 1
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"name"literal: string
count= 4
]std/core/types/Nil: forall<a> list<a>, Reqstd/os/flags/Req: forall<a> (parse : (a, string) -> a, help : string) -> flag-parser<a>(set-namestd/os/flags/set-name: (t : myflags, name : string) -> myflags,"USER"literal: string
count= 4
), "only show USER files"literal: string
count= 20
),
]std/core/types/Nil: forall<a> list<a> pub fun teststd/os/flags/test: (cmdargs : list<string>) -> console ()( cmdargscmdargs: list<string> )result: -> console () val headerheader: string = "usage:\n program [options] files\n\noptions:"literal: string
count= 41
// testflags.usageInfo( header ).println val (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)flagsflags: myflags,argsargs: list<string>,errserrs: list<string>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) = parsestd/os/flags/parse: (initial : myflags, flags : list<flag<myflags>>, args : list<string>, ordering : ? (flag-order<myflags>)) -> console (myflags, list<string>, list<string>)( Myflags(), myflagsstd/os/flags/myflags: list<flag<myflags>>, cmdargscmdargs: list<string> ) if errserrs: list<string>.is-nilstd/core/types/is-nil: (list : list<string>) -> console bool then printlnstd/core/console/string/println: (s : string) -> console ()( "\nsuccess!"literal: string
count= 9
); printlnstd/core/console/string/println: (s : string) -> console ()( "flags: "literal: string
count= 7
++std/core/types/(++): (x : string, y : string) -> console string flagsflags: myflags.show-flagsstd/os/flags/show-flags: (o : myflags) -> console string) printlnstd/core/console/string/println: (s : string) -> console ()( "arguments: "literal: string
count= 11
++std/core/types/(++): (x : string, y : string) -> console string argsargs: list<string>.joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> console string(" "literal: string
count= 1
) ); if flagsflags: myflags.versionstd/os/flags/myflags/version: (myflags : myflags) -> console bool then myflagsstd/os/flags/myflags: list<flag<myflags>>.usagestd/os/flags/usage: (flags : list<flag<myflags>>, header : ? string) -> console string(headerheader: string).printlnstd/core/console/string/println: (s : string) -> console () else printlnstd/core/console/string/println: (s : string) -> console ()( errserrs: list<string>.joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> console string("\n"literal: string
count= 1
) ++std/core/types/(++): (x : string, y : string) -> console string "\n"literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> console string myflagsstd/os/flags/myflags: list<flag<myflags>>.usagestd/os/flags/usage: (flags : list<flag<myflags>>, header : ? string) -> console string(headerheader: string)
) // Specifies how to handle flags that follow non-flag command line arguments. pub value type flag-orderstd/os/flags/flag-order: V -> V<aa: V> // Allow flags to be permuted with non-flag arguments (default) Permutestd/os/flags/Permute: forall<a> flag-order<a> // flags following non-flag arguments are treated as arguments Preorderstd/os/flags/Preorder: forall<a> flag-order<a> // Wrap each non-flag argument into an flag Wrapstd/os/flags/Wrap: forall<a> (wrap : (string) -> a) -> flag-order<a>( wrap : (stringstd/core/types/string: V) -> astd/core/types/total: E ) // Specifies a single command line flag // For example: `flag("h?",["help"],Bool(Help),"show help information")`. pub struct flagstd/os/flags/flag: V -> V<aa: V> short-namesstd/os/flags/flag/short-names: forall<a> (flag : flag<a>) -> string : stringstd/core/types/string: V long-namesstd/os/flags/flag/long-names: forall<a> (flag : flag<a>) -> list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> parserstd/os/flags/flag/parser: forall<a> (flag : flag<a>) -> flag-parser<a> : flag-parserstd/os/flags/flag-parser: V -> V<aa: V> helpstd/os/flags/flag/help: forall<a> (flag : flag<a>) -> string : stringstd/core/types/string: V // Specifies the argument of an flag pub type flag-parserstd/os/flags/flag-parser: V -> V<aa: V> // Boolean flag without an argument. // For a flag `foo` Automatically enables forms `--no-foo` and `--foo=true|false`. Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a>( default : (aa: V,boolstd/core/types/bool: V) -> astd/core/types/total: E) // A required argument. Reqstd/os/flags/Req: forall<a> (parse : (a, string) -> a, help : string) -> flag-parser<a>( parse : (aa: V,stringstd/core/types/string: V) -> astd/core/types/total: E, help : stringstd/core/types/string: V ) // An flagal argument. Optstd/os/flags/Opt: forall<a> (parse : (a, maybe<string>) -> a, help : string) -> flag-parser<a>( parse : (aa: V,maybestd/core/types/maybe: V -> V<stringstd/core/types/string: V>) -> astd/core/types/total: E, help : stringstd/core/types/string: V ) // Return a nicely formatted string describing the usage of a command, // consisting of a `header` followed by the descriptions of the `flags`. // The default header is ``"usage:\n program [flags] arguments\n\nflags:"``. pub fun usagestd/os/flags/usage: forall<a> (flags : list<flag<a>>, header : ? string) -> string( flagsflags: list<flag<$2229>> : liststd/core/types/list: V -> V<flagstd/os/flags/flag: V -> V<aa: V>>, headerheader: ? string : stringstd/core/types/string: V = "usage:\n program [flags] arguments\n\nflags:"literal: string
count= 41
)result: -> total string : stringstd/core/types/string: V fun align-leftalign-left: (xs : list<string>) -> list<string>( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> )result: -> total list<string> val nn: int = xsxs: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> int) -> list<int>(fnfn: (s : string) -> int(ss: string){ ss: string.countstd/core/string/count: (s : string) -> int }).maximumstd/core/list/maximum: (xs : list<int>, default : ? int) -> int xsxs: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>( fnfn: (s : string) -> string(ss: string){ ss: string.pad-rightstd/core/string/pad-right: (s : string, width : int, fill : ? char) -> string(nn: int) } ) fun pastepaste: (x : string, y : string, z : string) -> string(xx: string,yy: string,zz: string)result: -> total string (" "literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string xx: string ++std/core/types/(++): (x : string, y : string) -> string " "literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string yy: string ++std/core/types/(++): (x : string, y : string) -> string " "literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string zz: string
) val (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)shortsshorts: list<string>,longslongs: list<string>,helpshelps: list<string>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) = flagsflags: list<flag<$2229>>.mapstd/core/list/map: (xs : list<flag<$2229>>, f : (flag<$2229>) -> list<(string, string, string)>) -> list<list<(string, string, string)>>(show-flagstd/os/flags/show-flag: (flag : flag<$2229>) -> list<(string, string, string)>).concatstd/core/list/concat: (xss : list<list<(string, string, string)>>) -> list<(string, string, string)>.unzip3std/core/list/unzip3: (xs : list<(string, string, string)>) -> (list<string>, list<string>, list<string>) val tabletable: list<string> = zipWith3std/os/flags/zipWith3: (f : (string, string, string) -> string, xs : list<string>, ys : list<string>, zs : list<string>) -> list<string>( pastepaste: (x : string, y : string, z : string) -> string, shortsshorts: list<string>.align-leftalign-left: (xs : list<string>) -> list<string>, longslongs: list<string>.align-leftalign-left: (xs : list<string>) -> list<string>, helpshelps: list<string> ) (headerheader: string ++std/core/types/(++): (x : string, y : string) -> string "\n"literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string tabletable: list<string>.unlinesstd/core/list/unlines: (xs : list<string>) -> string
) fun show-flagstd/os/flags/show-flag: forall<a> (flag : flag<a>) -> list<(string, string, string)>( flagflag: flag<$1720> : flagstd/os/flags/flag: V -> V<aa: V> )result: -> total list<(string, string, string)> : liststd/core/types/list: V -> V<(std/core/types/tuple3: (V, V, V) -> Vstringstd/core/types/string: V,stringstd/core/types/string: V,stringstd/core/types/string: V)> val shortshort: string = flagflag: flag<$1720>.short-namesstd/os/flags/flag/short-names: (flag : flag<$1720>) -> string.liststd/core/string/list: (s : string) -> list<char>.mapstd/core/list/map: (xs : list<char>, f : (char) -> string) -> list<string>(fnfn: (c : char) -> string(cc: char){ "-"literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string cc: char.stringstd/core/string/char/string: (c : char) -> string ++std/core/types/(++): (x : string, y : string) -> string show-short-flagstd/os/flags/show-short-flag: (parser : flag-parser<$1720>) -> string(flagflag: flag<$1720>.parserstd/os/flags/flag/parser: (flag : flag<$1720>) -> flag-parser<$1720>) }).joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> string(" "literal: string
count= 1
) val longlong: string = flagflag: flag<$1720>.long-namesstd/os/flags/flag/long-names: (flag : flag<$1720>) -> list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>(fnfn: (name : string) -> string(namename: string){ "--"literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string namename: string ++std/core/types/(++): (x : string, y : string) -> string show-long-flagstd/os/flags/show-long-flag: (parser : flag-parser<$1720>) -> string(flagflag: flag<$1720>.parserstd/os/flags/flag/parser: (flag : flag<$1720>) -> flag-parser<$1720>) }).joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> string(" "literal: string
count= 1
) match (linesstd/core/list/lines: (s : string) -> list<string>(flagflag: flag<$1720>.helpstd/os/flags/flag/help: (flag : flag<$1720>) -> string)) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(hdhd: string,tltl: list<string>) -> [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)shortshort: string,longlong: string,hdhd: string)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)]std/core/types/Nil: forall<a> list<a> ++std/core/list/(++): (xs : list<(string, string, string)>, ys : list<(string, string, string)>) -> list<(string, string, string)> tltl: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> (string, string, string)) -> list<(string, string, string)>( fnfn: (s : string) -> (string, string, string)(ss: string){ (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)""literal: string
count= 0
,""literal: string
count= 0
,ss: string)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)}) Nilstd/core/types/Nil: forall<a> list<a> -> [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)shortshort: string,longlong: string,""literal: string
count= 0
)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)
]std/core/types/Nil: forall<a> list<a> fun show-short-flagstd/os/flags/show-short-flag: forall<a> (parser : flag-parser<a>) -> string( parserparser: flag-parser<$1020> : flag-parserstd/os/flags/flag-parser: V -> V<aa: V> )result: -> total string match(parserparser: flag-parser<$1020>) Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a> -> ""literal: string
count= 0
Reqstd/os/flags/Req: forall<a> (parse : (a, string) -> a, help : string) -> flag-parser<a>( help=hh: string ) -> "<"literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string hh: string ++std/core/types/(++): (x : string, y : string) -> string ">"literal: string
count= 1
Optstd/os/flags/Opt: forall<a> (parse : (a, maybe<string>) -> a, help : string) -> flag-parser<a>( help=hh: string ) -> "["literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string hh: string ++std/core/types/(++): (x : string, y : string) -> string "]"literal: string
count= 1
fun show-long-flagstd/os/flags/show-long-flag: forall<a> (parser : flag-parser<a>) -> string( parserparser: flag-parser<$949> : flag-parserstd/os/flags/flag-parser: V -> V<aa: V> )result: -> total string match(parserparser: flag-parser<$949>) Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a>(_) -> ""literal: string
count= 0
Reqstd/os/flags/Req: forall<a> (parse : (a, string) -> a, help : string) -> flag-parser<a>( help=hh: string ) -> "="literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> string hh: string Optstd/os/flags/Opt: forall<a> (parse : (a, maybe<string>) -> a, help : string) -> flag-parser<a>( help=hh: string ) -> "[="literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string hh: string ++std/core/types/(++): (x : string, y : string) -> string "]"literal: string
count= 1
value type flag-kindstd/os/flags/flag-kind: V -> V<aa: V> Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>( set : aa: V -> astd/core/types/total: E ) Argstd/os/flags/Arg: forall<a> (arg : string) -> flag-kind<a>( arg : stringstd/core/types/string: V ) Endstd/os/flags/End: forall<a> flag-kind<a> Unknownstd/os/flags/Unknown: forall<a> (arg : string) -> flag-kind<a>( arg : stringstd/core/types/string: V ) Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>( msg : stringstd/core/types/string: V ) // Parse the command line arguments `args` (see `std/env/get-args`) // according to the flag descriptions `flags`. Takes an flagal argument // `ordering` (=`Permute`) that specifies how optare handled that follow non-flag arguments. // Returns three lists: the list of parsed flags, // a list of non-flag arguments, and a list of potential error messages. pub fun parsestd/os/flags/parse: forall<a> (initial : a, flags : list<flag<a>>, args : list<string>, ordering : ? (flag-order<a>)) -> (a, list<string>, list<string>)( initialinitial: $3735 : aa: V, flagsflags: list<flag<$3735>> : liststd/core/types/list: V -> V<flagstd/os/flags/flag: V -> V<aa: V>>, argsargs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V>, orderingordering: ? (flag-order<$3735>) : flag-orderstd/os/flags/flag-order: V -> V<aa: V> = Permutestd/os/flags/Permute: forall<a> flag-order<a> )result: -> total (4095, list<string>, list<string>) : totalstd/core/types/total: E (std/core/types/tuple3: (V, V, V) -> Vaa: V, liststd/core/types/list: V -> V<stringstd/core/types/string: V>, liststd/core/types/list: V -> V<stringstd/core/types/string: V>) var donedone: local-var<$3750,bool> := Falsestd/core/types/False: bool // done scanning flags? (the rest is treated as an argument) val optsopts: list<list<flag-kind<$3735>>> = argsargs: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> (local<$3750>) list<flag-kind<$3735>>) -> (local<$3750>) list<list<flag-kind<$3735>>> fnfn: (arg : string) -> (local<$3750>) list<flag-kind<$3735>>(argarg: string) val optsopts: list<flag-kind<$3735>> = if (donedone: bool) then [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>Argstd/os/flags/Arg: forall<a> (arg : string) -> flag-kind<a>(argarg: string)]std/core/types/Nil: forall<a> list<a> else process-nextstd/os/flags/process-next: (arg : string, flags : list<flag<$3735>>) -> (local<$3750>) list<flag-kind<$3735>>(argarg: string,flagsflags: list<flag<$3735>>) optsopts: list<flag-kind<$3735>>.foreachstd/core/list/foreach: (xs : list<flag-kind<$3735>>, action : (flag-kind<$3735>) -> (local<$3750>) ()) -> (local<$3750>) () fnfn: (opt : flag-kind<$3735>) -> (local<$3750>) ()(optopt: flag-kind<$3735>) match(optopt: flag-kind<$3735>) Endstd/os/flags/End: forall<a> flag-kind<a> -> donedone: local-var<$3750,bool> :=std/core/types/local-set: (v : local-var<$3750,bool>, assigned : bool) -> (local<$3750>) () Truestd/core/types/True: bool Argstd/os/flags/Arg: forall<a> (arg : string) -> flag-kind<a>(_) | orderingordering: flag-order<$3735>.is-preorderstd/os/flags/is-preorder: (flag-order : flag-order<$3735>) -> bool -> donedone: local-var<$3750,bool> :=std/core/types/local-set: (v : local-var<$3750,bool>, assigned : bool) -> (local<$3750>) () Truestd/core/types/True: bool _ -> (std/core/types/Unit: ())std/core/types/Unit: () optsopts: list<flag-kind<$3735>> optsopts: list<list<flag-kind<$3735>>>.concatstd/core/list/concat: (xss : list<list<flag-kind<$3735>>>) -> (local<$3750>) list<flag-kind<$3735>>.foldlstd/core/list/foldl: (xs : list<flag-kind<$3735>>, z : ($3735, list<string>, list<string>), f : (($3735, list<string>, list<string>), flag-kind<$3735>) -> (local<$3750>) ($3735, list<string>, list<string>)) -> (local<$3750>) ($3735, list<string>, list<string>)((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)initialinitial: $3735,[std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,[std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)) fnfn: (acc : ($3735, list<string>, list<string>), opt : flag-kind<$3735>) -> (local<$3750>) ($3735, list<string>, list<string>)(accacc: ($3735, list<string>, list<string>),optopt: flag-kind<$3735>) val (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)oo: $3735,xsxs: list<string>,errserrs: list<string>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) = accacc: ($3735, list<string>, list<string>) match(optopt: flag-kind<$3735>) Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(setset: ($3735) -> $3735) -> (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)setset: ($3735) -> (local<$3750>) $3735(oo: $3735),xsxs: list<string>,errserrs: list<string>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) Unknownstd/os/flags/Unknown: forall<a> (arg : string) -> flag-kind<a>(ee: string) -> (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)oo: $3735,xsxs: list<string>,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(error-unknown-messagestd/os/flags/error-unknown-message: (opt : string) -> (local<$3750>) string(ee: string),errserrs: list<string>))std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) flags/Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>(ee: string) -> (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)oo: $3735,xsxs: list<string>,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ee: string,errserrs: list<string>))std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) Argstd/os/flags/Arg: forall<a> (arg : string) -> flag-kind<a>(xx: string) -> (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)oo: $3735,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: string,xsxs: list<string>),errserrs: list<string>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) Endstd/os/flags/End: forall<a> flag-kind<a> -> (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)oo: $3735,xsxs: list<string>,errserrs: list<string>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) fun process-nextstd/os/flags/process-next: forall<a> (arg : string, flags : list<flag<a>>) -> list<flag-kind<a>>( argarg: string : stringstd/core/types/string: V, flagsflags: list<flag<$3621>> : liststd/core/types/list: V -> V<flagstd/os/flags/flag: V -> V<aa: V>> )result: -> total list<flag-kind<3730>> : liststd/core/types/list: V -> V<flag-kindstd/os/flags/flag-kind: V -> V<aa: V>> match(argarg: string.starts-withstd/core/sslice/starts-with: (s : string, pre : string) -> maybe<sslice>("--"literal: string
count= 2
)) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(sliceslice: sslice) -> if (sliceslice: sslice.is-emptystd/core/sslice/is-empty: (slice : sslice) -> bool) then [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>Endstd/os/flags/End: forall<a> flag-kind<a>]std/core/types/Nil: forall<a> list<a> else [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>parse-longstd/os/flags/parse-long: (s : string, flags : list<flag<$3621>>) -> flag-kind<$3621>(sliceslice: sslice.stringstd/core/sslice/string: (slice : sslice) -> string,flagsflags: list<flag<$3621>>)]std/core/types/Nil: forall<a> list<a> _ -> match(argarg: string.starts-withstd/core/sslice/starts-with: (s : string, pre : string) -> maybe<sslice>("-"literal: string
count= 1
)) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(sliceslice: sslice) | !std/core/types/bool/(!): (b : bool) -> boolsliceslice: sslice.is-emptystd/core/sslice/is-empty: (slice : sslice) -> bool -> parse-shortsstd/os/flags/parse-shorts: (s : string, flags : list<flag<$3621>>) -> list<flag-kind<$3621>>(sliceslice: sslice.stringstd/core/sslice/string: (slice : sslice) -> string,flagsflags: list<flag<$3621>>) _ -> [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>Argstd/os/flags/Arg: forall<a> (arg : string) -> flag-kind<a>(argarg: string)
]std/core/types/Nil: forall<a> list<a> fun breakstd/os/flags/break: (s : string, c : string) -> (string, string)( ss: string : stringstd/core/types/string: V, cc: string : stringstd/core/types/string: V )result: -> total (string, string) : (std/core/types/tuple2: (V, V) -> Vstringstd/core/types/string: V,stringstd/core/types/string: V) val partsparts: list<string> = ss: string.splitstd/core/string/splitn/split: (s : string, sep : string, n : int) -> list<string>(cc: string,2literal: int
dec = 2
hex8 = 0x02
bit8 = 0b00000010
) match (partsparts: list<string>) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: string,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: string,_)) -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xx: string,yy: string)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) _ -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)ss: string,""literal: string
count= 0
)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) fun parse-longstd/os/flags/parse-long: forall<a> (s : string, flags : list<flag<a>>) -> flag-kind<a>( ss: string : stringstd/core/types/string: V, flagsflags: list<flag<$2630>> : liststd/core/types/list: V -> V<flagstd/os/flags/flag: V -> V<aa: V>> )result: -> total flag-kind<3230> : totalstd/core/types/total: E flag-kindstd/os/flags/flag-kind: V -> V<aa: V> val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)cflagnamecflagname: string,flagargflagarg: string)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = ss: string.breakstd/os/flags/break: (s : string, c : string) -> (string, string)("="literal: string
count= 1
) val optstroptstr: string = "--"literal: string
count= 2
++std/core/types/(++): (x : string, y : string) -> string ss: string val flagnameflagname: string = cflagnamecflagname: string.to-lowerstd/core/string/to-lower: (s : string) -> string val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)baseflagnamebaseflagname: string,negatednegated: bool)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = match (flagnameflagname: string.starts-withstd/core/sslice/starts-with: (s : string, pre : string) -> maybe<sslice>("no-"literal: string
count= 3
)) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(sliceslice: sslice) -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)sliceslice: sslice.stringstd/core/sslice/string: (slice : sslice) -> string,Truestd/core/types/True: bool)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) _ -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)flagnameflagname: string,Falsestd/core/types/False: bool)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) val exactsexacts: list<flag<$2630>> = flagsflags: list<flag<$2630>>.filterstd/core/list/filter: (xs : list<flag<$2630>>, pred : (flag<$2630>) -> bool) -> list<flag<$2630>> fnfn: (opt : flag<$2630>) -> bool(optopt: flag<$2630>) optopt: flag<$2630>.long-namesstd/os/flags/flag/long-names: (flag : flag<$2630>) -> list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>(to-lowerstd/core/string/to-lower: (s : string) -> string).anystd/core/list/any: (xs : list<string>, predicate : (string) -> bool) -> bool fnfn: (name : string) -> bool(namename: string) namename: string==std/core/string/(==): (string, string) -> boolflagnameflagname: string ||std/core/types/(||): (x : bool, y : bool) -> bool namename: string==std/core/string/(==): (string, string) -> boolbaseflagnamebaseflagname: string val prefixesprefixes: list<flag<$2630>> = flagsflags: list<flag<$2630>>.filterstd/core/list/filter: (xs : list<flag<$2630>>, pred : (flag<$2630>) -> bool) -> list<flag<$2630>> fnfn: (opt : flag<$2630>) -> bool(optopt: flag<$2630>) optopt: flag<$2630>.long-namesstd/os/flags/flag/long-names: (flag : flag<$2630>) -> list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>(to-lowerstd/core/string/to-lower: (s : string) -> string).anystd/core/list/any: (xs : list<string>, predicate : (string) -> bool) -> bool fnfn: (name : string) -> bool(namename: string) namename: string.starts-withstd/core/sslice/starts-with: (s : string, pre : string) -> maybe<sslice>(flagnameflagname: string).is-juststd/core/types/is-just: (maybe : maybe<sslice>) -> bool ||std/core/types/(||): (x : bool, y : bool) -> bool namename: string.starts-withstd/core/sslice/starts-with: (s : string, pre : string) -> maybe<sslice>(baseflagnamebaseflagname: string).is-juststd/core/types/is-just: (maybe : maybe<sslice>) -> bool val applicableapplicable: list<flag<$2630>> = if (exactsexacts: list<flag<$2630>>.is-nilstd/core/types/is-nil: (list : list<flag<$2630>>) -> bool) then prefixesprefixes: list<flag<$2630>> else exactsexacts: list<flag<$2630>> match(applicableapplicable: list<flag<$2630>>) Nilstd/core/types/Nil: forall<a> list<a> -> error-unknownstd/os/flags/error-unknown: (opt : string) -> flag-kind<$2630>(optstroptstr: string) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,_)) -> error-ambiguousstd/os/flags/error-ambiguous: (applicable : list<flag<$2630>>, opt : string) -> flag-kind<$2630>(applicableapplicable: list<flag<$2630>>,optstroptstr: string) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(descdesc: flag<$2630>,_) -> match(descdesc: flag<$2630>.parserstd/os/flags/flag/parser: (flag : flag<$2630>) -> flag-parser<$2630>) Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a>(setset: ($2630, bool) -> $2630) -> if (flagargflagarg: string ==std/core/string/(==): (string, string) -> bool ""literal: string
count= 0
) then Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $2630) -> $2630(oo: $2630){ setset: ($2630, bool) -> $2630(oo: $2630, !std/core/types/bool/(!): (b : bool) -> boolnegatednegated: bool) }) elif (flagargflagarg: string.to-lowerstd/core/string/to-lower: (s : string) -> string ==std/core/string/(==): (string, string) -> bool "true"literal: string
count= 4
) then Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $2630) -> $2630(oo: $2630) { setset: ($2630, bool) -> $2630(oo: $2630,Truestd/core/types/True: bool) }) elif (flagargflagarg: string.to-lowerstd/core/string/to-lower: (s : string) -> string ==std/core/string/(==): (string, string) -> bool "false"literal: string
count= 5
) then Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $2630) -> $2630(oo: $2630) { setset: ($2630, bool) -> $2630(oo: $2630,Falsestd/core/types/False: bool) }) else error-noargstd/os/flags/error-noarg: (opt : string) -> flag-kind<$2630>(optstroptstr: string) Reqstd/os/flags/Req: forall<a> (parse : (a, string) -> a, help : string) -> flag-parser<a>(parseparse: ($2630, string) -> $2630,helphelp: string) -> if (negatednegated: bool) then error-negatestd/os/flags/error-negate: (flagname : string) -> flag-kind<$2630>(baseflagnamebaseflagname: string) elif (flagargflagarg: string.is-notemptystd/core/string/is-notempty: (s : string) -> bool) then Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $2630) -> $2630(oo: $2630) { parseparse: ($2630, string) -> $2630(oo: $2630,flagargflagarg: string) }) else error-requiredstd/os/flags/error-required: (help : string, opt : string) -> flag-kind<$2630>(helphelp: string,optstroptstr: string) Optstd/os/flags/Opt: forall<a> (parse : (a, maybe<string>) -> a, help : string) -> flag-parser<a>(parseparse: ($2630, maybe<string>) -> $2630) -> if (negatednegated: bool) then error-negatestd/os/flags/error-negate: (flagname : string) -> flag-kind<$2630>(baseflagnamebaseflagname: string) elif (flagargflagarg: string.is-notemptystd/core/string/is-notempty: (s : string) -> bool) then Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $2630) -> $2630(oo: $2630) { parseparse: ($2630, maybe<string>) -> $2630(oo: $2630,Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(flagargflagarg: string)) }) else Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $2630) -> $2630(oo: $2630) { parseparse: ($2630, maybe<string>) -> $2630(oo: $2630,Nothingstd/core/types/Nothing: forall<a> maybe<a>) }
) fun parse-shortsstd/os/flags/parse-shorts: forall<a> (s : string, flags : list<flag<a>>) -> list<flag-kind<a>>( ss: string : stringstd/core/types/string: V, flagsflags: list<flag<$3235>> : liststd/core/types/list: V -> V<flagstd/os/flags/flag: V -> V<aa: V>> )result: -> total list<flag-kind<3616>> : liststd/core/types/list: V -> V<flag-kindstd/os/flags/flag-kind: V -> V<aa: V>> var donedone: local-var<$3244,bool> := Falsestd/core/types/False: bool val fsfs: list<maybe<flag-kind<$3235>>> = ss: string.liststd/core/string/list: (s : string) -> (local<$3244>) list<char>.map-indexedstd/core/list/map-indexed: (xs : list<char>, f : (idx : int, value : char) -> (local<$3244>) maybe<flag-kind<$3235>>) -> (local<$3244>) list<maybe<flag-kind<$3235>>> fnfn: (i : int, c : char) -> (local<$3244>) maybe<flag-kind<$3235>>(ii: int,cc: char) if (donedone: bool) returnreturn: maybe<flag-kind<$3235>> Nothingstd/core/types/Nothing: forall<a> maybe<a> val optstroptstr: string = "-"literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> (local<$3244>) string cc: char.stringstd/core/string/char/string: (c : char) -> (local<$3244>) string val applicableapplicable: list<flag<$3235>> = flagsflags: list<flag<$3235>>.filterstd/core/list/filter: (xs : list<flag<$3235>>, pred : (flag<$3235>) -> (local<$3244>) bool) -> (local<$3244>) list<flag<$3235>>( fnfn: (opt : flag<$3235>) -> (local<$3244>) bool(optopt: flag<$3235>){ optopt: flag<$3235>.short-namesstd/os/flags/flag/short-names: (flag : flag<$3235>) -> (local<$3244>) string.containsstd/core/string/contains: (s : string, sub : string) -> (local<$3244>) bool(cc: char.stringstd/core/string/char/string: (c : char) -> (local<$3244>) string) } ) match(applicableapplicable: list<flag<$3235>>) Nilstd/core/types/Nil: forall<a> list<a> -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(error-unknownstd/os/flags/error-unknown: (opt : string) -> (local<$3244>) flag-kind<$3235>(optstroptstr: string)) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,_)) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(error-ambiguousstd/os/flags/error-ambiguous: (applicable : list<flag<$3235>>, opt : string) -> (local<$3244>) flag-kind<$3235>(applicableapplicable: list<flag<$3235>>,optstroptstr: string)) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(descdesc: flag<$3235>,_) -> match(descdesc: flag<$3235>.parserstd/os/flags/flag/parser: (flag : flag<$3235>) -> (local<$3244>) flag-parser<$3235>) Boolstd/os/flags/Bool: forall<a> (default : (a, bool) -> a) -> flag-parser<a>(setset: ($3235, bool) -> $3235) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $3235) -> $3235(oo: $3235){ setset: ($3235, bool) -> $3235(oo: $3235,Truestd/core/types/True: bool) })) Reqstd/os/flags/Req: forall<a> (parse : (a, string) -> a, help : string) -> flag-parser<a>(parseparse: ($3235, string) -> $3235,helphelp: string) -> val argarg: string = ss: string.firststd/core/sslice/first: (s : string, n : ? int) -> (local<$3244>) sslice.advancestd/core/sslice/advance: (slice : sslice, count : int) -> (local<$3244>) sslice(ii: int).afterstd/core/sslice/after: (slice : sslice) -> (local<$3244>) sslice.stringstd/core/sslice/string: (slice : sslice) -> (local<$3244>) string if (argarg: string.is-notemptystd/core/string/is-notempty: (s : string) -> (local<$3244>) bool) then { donedone: local-var<$3244,bool> :=std/core/types/local-set: (v : local-var<$3244,bool>, assigned : bool) -> (local<$3244>) () Truestd/core/types/True: bool; Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $3235) -> $3235(oo: $3235){ parseparse: ($3235, string) -> $3235(oo: $3235,argarg: string) })) } else Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(error-requiredstd/os/flags/error-required: (help : string, opt : string) -> (local<$3244>) flag-kind<$3235>(helphelp: string,optstroptstr: string)) Optstd/os/flags/Opt: forall<a> (parse : (a, maybe<string>) -> a, help : string) -> flag-parser<a>(parseparse: ($3235, maybe<string>) -> $3235) -> val argarg: string = ss: string.firststd/core/sslice/first: (s : string, n : ? int) -> (local<$3244>) sslice.advancestd/core/sslice/advance: (slice : sslice, count : int) -> (local<$3244>) sslice(ii: int).afterstd/core/sslice/after: (slice : sslice) -> (local<$3244>) sslice.stringstd/core/sslice/string: (slice : sslice) -> (local<$3244>) string if (argarg: string.is-notemptystd/core/string/is-notempty: (s : string) -> (local<$3244>) bool ) then { donedone: local-var<$3244,bool> :=std/core/types/local-set: (v : local-var<$3244,bool>, assigned : bool) -> (local<$3244>) () Truestd/core/types/True: bool; Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $3235) -> $3235(oo: $3235){ parseparse: ($3235, maybe<string>) -> $3235(oo: $3235,Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(argarg: string)) })) } else Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(Flgstd/os/flags/Flg: forall<a> (set : (a) -> a) -> flag-kind<a>(fnfn: (o : $3235) -> $3235(oo: $3235){parseparse: ($3235, maybe<string>) -> $3235(oo: $3235,Nothingstd/core/types/Nothing: forall<a> maybe<a>)})) fsfs: list<maybe<flag-kind<$3235>>>.flatmapstd/core/list/flatmap: (xs : list<maybe<flag-kind<$3235>>>, f : (maybe<flag-kind<$3235>>) -> (local<$3244>) list<flag-kind<$3235>>) -> (local<$3244>) list<flag-kind<$3235>>(liststd/core/list/maybe/list: (m : maybe<flag-kind<$3235>>) -> (local<$3244>) list<flag-kind<$3235>>
) fun error-ambiguousstd/os/flags/error-ambiguous: forall<a,b> (applicable : list<flag<a>>, opt : string) -> flag-kind<b>( applicableapplicable: list<flag<_2584>>, optopt: string )result: -> total flag-kind<6199> val headerheader: string = "flag \""literal: string
count= 6
++std/core/types/(++): (x : string, y : string) -> string optopt: string ++std/core/types/(++): (x : string, y : string) -> string "\" is ambiguous. It could be one of:"literal: string
count= 35
Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>( usagestd/os/flags/usage: (flags : list<flag<_2584>>, header : ? string) -> string( applicableapplicable: list<flag<_2584>>, headerheader: string )
) fun error-requiredstd/os/flags/error-required: forall<a> (help : string, opt : string) -> flag-kind<a>( helphelp: string, optopt: string )result: -> total flag-kind<3501> Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>( "flag \""literal: string
count= 6
++std/core/types/(++): (x : string, y : string) -> string optopt: string ++std/core/types/(++): (x : string, y : string) -> string "\" requires an argument "literal: string
count= 23
++std/core/types/(++): (x : string, y : string) -> string helphelp: string
) fun error-negatestd/os/flags/error-negate: forall<a> (flagname : string) -> flag-kind<a>( flagnameflagname: string )result: -> total flag-kind<3287> Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>( "flag \"--"literal: string
count= 8
++std/core/types/(++): (x : string, y : string) -> string flagnameflagname: string ++std/core/types/(++): (x : string, y : string) -> string "\" cannot be negated"literal: string
count= 19
)
; fun error-noargstd/os/flags/error-noarg: forall<a> (opt : string) -> flag-kind<a>( optopt: string )result: -> total flag-kind<3381> Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>( "flag \""literal: string
count= 6
++std/core/types/(++): (x : string, y : string) -> string optopt: string ++std/core/types/(++): (x : string, y : string) -> string "\" does not take an argument"literal: string
count= 27
) fun error-unknownstd/os/flags/error-unknown: forall<a> (opt : string) -> flag-kind<a>( optopt: string )result: -> total flag-kind<6247> Errorstd/os/flags/Error: forall<a> (msg : string) -> flag-kind<a>( error-unknown-messagestd/os/flags/error-unknown-message: (opt : string) -> string(optopt: string) ) fun error-unknown-messagestd/os/flags/error-unknown-message: (opt : string) -> string( optopt: string )result: -> total string ( "unrecognized flag \""literal: string
count= 19
++std/core/types/(++): (x : string, y : string) -> string optopt: string ++std/core/types/(++): (x : string, y : string) -> string "\""literal: string
count= 1
) fun zipWith3std/os/flags/zipWith3: forall<a,b,c,d,e> (f : (a, b, c) -> e d, xs : list<a>, ys : list<b>, zs : list<c>) -> e list<d>(ff: ($2170, $2171, $2172) -> $2174 $2173 : (aa: V,bb: V,cc: V) -> ee: E dd: V, xsxs: list<$2170> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$2171> : liststd/core/types/list: V -> V<bb: V>, zszs: list<$2172> : liststd/core/types/list: V -> V<cc: V> )result: -> 2213 list<2212> : ee: E liststd/core/types/list: V -> V<dd: V> zipWith3Accstd/os/flags/zipWith3Acc: (f : ($2170, $2171, $2172) -> $2174 $2173, acc : list<$2173>, xs : list<$2170>, ys : list<$2171>, zs : list<$2172>) -> $2174 list<$2173>(ff: ($2170, $2171, $2172) -> $2174 $2173, [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>, xsxs: list<$2170>, ysys: list<$2171>, zszs: list<$2172> ) fun zipWith3Accstd/os/flags/zipWith3Acc: forall<a,b,c,d,e> (f : (a, b, c) -> e d, acc : list<d>, xs : list<a>, ys : list<b>, zs : list<c>) -> e list<d>( ff: (_2104, _2117, _2130) -> _2094 _2110, accacc: list<_2110>, xsxs: list<_2104>, ysys: list<_2117>, zszs: list<_2130> )result: -> _2094 list<_2110> match(xsxs: list<_2104>) Nilstd/core/types/Nil: forall<a> list<a> -> reversestd/core/list/reverse: (xs : list<_2110>) -> _2094 list<_2110>(accacc: list<_2110>) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _2104,xxxx: list<_2104>) -> match(ysys: list<_2117>) Nilstd/core/types/Nil: forall<a> list<a> -> reversestd/core/list/reverse: (xs : list<_2110>) -> _2094 list<_2110>(accacc: list<_2110>) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _2117,yyyy: list<_2117>) -> match (zszs: list<_2130>) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: _2130,zzzz: list<_2130>) -> zipWith3Accstd/os/flags/zipWith3Acc: (f : (_2104, _2117, _2130) -> _2094 _2110, acc : list<_2110>, xs : list<_2104>, ys : list<_2117>, zs : list<_2130>) -> _2094 list<_2110>(ff: (_2104, _2117, _2130) -> _2094 _2110, Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( ff: (_2104, _2117, _2130) -> _2094 _2110(xx: _2104,yy: _2117,zz: _2130), accacc: list<_2110>), xxxx: list<_2104>, yyyy: list<_2117>, zzzz: list<_2130>) _ -> reversestd/core/list/reverse: (xs : list<_2110>) -> _2094 list<_2110>(accacc: list<_2110>)