{"action":"created","issue":{"url":"https://api.github.com/repos/CakeML/cakeml/issues/511","repository_url":"https://api.github.com/repos/CakeML/cakeml","labels_url":"https://api.github.com/repos/CakeML/cakeml/issues/511/labels{/name}","comments_url":"https://api.github.com/repos/CakeML/cakeml/issues/511/comments","events_url":"https://api.github.com/repos/CakeML/cakeml/issues/511/events","html_url":"https://github.com/CakeML/cakeml/pull/511","id":350855754,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4NTk3NjIx","number":511,"title":"ArgParse for CakeML","user":{"login":"agomezl","id":1539099,"node_id":"MDQ6VXNlcjE1MzkwOTk=","avatar_url":"https://avatars0.githubusercontent.com/u/1539099?v=4","gravatar_id":"","url":"https://api.github.com/users/agomezl","html_url":"https://github.com/agomezl","followers_url":"https://api.github.com/users/agomezl/followers","following_url":"https://api.github.com/users/agomezl/following{/other_user}","gists_url":"https://api.github.com/users/agomezl/gists{/gist_id}","starred_url":"https://api.github.com/users/agomezl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agomezl/subscriptions","organizations_url":"https://api.github.com/users/agomezl/orgs","repos_url":"https://api.github.com/users/agomezl/repos","events_url":"https://api.github.com/users/agomezl/events{/privacy}","received_events_url":"https://api.github.com/users/agomezl/received_events","type":"User","site_admin":false},"labels":[{"id":1029726988,"node_id":"MDU6TGFiZWwxMDI5NzI2OTg4","url":"https://api.github.com/repos/CakeML/cakeml/labels/test%20failing","name":"test failing","color":"fccbc4","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2018-08-15T15:31:54Z","updated_at":"2018-12-25T10:33:33Z","closed_at":"2018-11-28T00:09:16Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/CakeML/cakeml/pulls/511","html_url":"https://github.com/CakeML/cakeml/pull/511","diff_url":"https://github.com/CakeML/cakeml/pull/511.diff","patch_url":"https://github.com/CakeML/cakeml/pull/511.patch"},"body":"This is a relatively simple library for parsing arguments using a declarative interface for specifying which kind of argument/options to take. the following example shows a simple use case.\r\n\r\nAssume a program `foo` with the following arguments\r\n```\r\nUsage foo\r\n  -f  --input     Input file to use\r\n  -o  --output    Output file\r\n  -h  --help      This message\r\n```\r\nWe use a datatype to represent the configuration of `foo`\r\n```\r\nval _ = Datatype`\r\n  foo_opt = <| input  : mlstring option;\r\n               output : mlstring option;\r\n               help   : bool|>\r\n`;\r\n```\r\n\r\nand write a configuration using the `flag` datatype\r\n\r\n```sml\r\nval foo_conf_def = Define`\r\n  foo_conf = mkArgsConf [(* -i --input *)\r\n                         <| name  := implode \"input\";\r\n                            short := #\"i\";\r\n                            desc  := implode \"Input file to use\";\r\n                            has_option := T; (* It spects an option *)\r\n                            cont := (λarg conf. conf with <|input := arg|>) |>;\r\n                         (* -o --output  *)\r\n                         <| name  := implode \"output\";\r\n                            short := #\"o\";\r\n                            desc  := implode \"Output file\";\r\n                            has_option := T;\r\n                            cont := (λarg conf. conf with <|input := arg|>) |>;\r\n                         (* -h --help *)\r\n                         <| name  := implode \"help\";\r\n                            short := #\"h\";\r\n                            desc  := implode \"This message\";\r\n                            has_option := F;\r\n                            cont := K (λconf. conf with <|help := T|>)|>\r\n                        ]\r\n                  (* Default configuration *)\r\n                  <|input  := NONE;\r\n                    output := NONE;\r\n                    help   := F\r\n                   |>\r\n`;\r\n```\r\n\r\nand then\r\n\r\n```\r\n> EVAL ``parse_conf foo_conf (MAP implode [\"--input\"])``;\r\nval it =\r\n   ⊢ parse_conf foo_conf (MAP implode [\"--input\"]) =\r\n       INL (strlit \"Missing value to: --input\"): thm\r\n\r\n> EVAL ``parse_conf foo_conf (MAP implode [\"--input\";\"text.txt\"])``;\r\nval it =\r\n   ⊢ parse_conf foo_conf (MAP implode [\"--input\"; \"text.txt\"]) =\r\n       INR <|input := SOME (strlit \"text.txt\"); output := NONE; help := F|>:\r\n   thm\r\n\r\n> EVAL ``parse_conf foo_conf (MAP implode [\"--input=in.txt\";\"--output\";\"out.txt\"])``;\r\nval it =\r\n   ⊢ parse_conf foo_conf (MAP implode [\"--input=text.txt\"; \"--output\"; \"out.txt\"]) =\r\n       INR <|input := SOME (strlit \"out.txt\"); output := NONE; help := F|>:\r\n   thm\r\n```\r\nThis is just the core functionality since there are still some quality of life components  missing (help message generation, helper functions, etc)."},"comment":{"url":"https://api.github.com/repos/CakeML/cakeml/issues/comments/449837997","html_url":"https://github.com/CakeML/cakeml/pull/511#issuecomment-449837997","issue_url":"https://api.github.com/repos/CakeML/cakeml/issues/511","id":449837997,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTgzNzk5Nw==","user":{"login":"xrchz","id":181254,"node_id":"MDQ6VXNlcjE4MTI1NA==","avatar_url":"https://avatars1.githubusercontent.com/u/181254?v=4","gravatar_id":"","url":"https://api.github.com/users/xrchz","html_url":"https://github.com/xrchz","followers_url":"https://api.github.com/users/xrchz/followers","following_url":"https://api.github.com/users/xrchz/following{/other_user}","gists_url":"https://api.github.com/users/xrchz/gists{/gist_id}","starred_url":"https://api.github.com/users/xrchz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xrchz/subscriptions","organizations_url":"https://api.github.com/users/xrchz/orgs","repos_url":"https://api.github.com/users/xrchz/repos","events_url":"https://api.github.com/users/xrchz/events{/privacy}","received_events_url":"https://api.github.com/users/xrchz/received_events","type":"User","site_admin":false},"created_at":"2018-12-25T10:33:33Z","updated_at":"2018-12-25T10:33:33Z","author_association":"MEMBER","body":"Do we know what's wrong?"}}
{"actor":{"display_login":"xrchz"}}