-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from mbarbin/stdlib.arg
Stdlib.arg
- Loading branch information
Showing
55 changed files
with
2,164 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,11 @@ | |
"cmdlang", | ||
"cmdliner", | ||
"conv", | ||
"groff", | ||
"janestreet", | ||
"odoc", | ||
"opam", | ||
"stdune", | ||
"stringable" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
synopsis: "A basic execution runner for cmdlang based on stdlib.arg" | ||
maintainer: ["Mathieu Barbin <[email protected]>"] | ||
authors: ["Mathieu Barbin"] | ||
license: "MIT" | ||
homepage: "https://github.com/mbarbin/cmdlang" | ||
doc: "https://mbarbin.github.io/cmdlang/" | ||
bug-reports: "https://github.com/mbarbin/cmdlang/issues" | ||
depends: [ | ||
"dune" {>= "3.16"} | ||
"ocaml" {>= "4.14"} | ||
"cmdlang" {= version} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://github.com/mbarbin/cmdlang.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ let () = | |
Getting_started.cmd | ||
~name:"my-calculator" | ||
~version:"%%VERSION%%") | ||
|> Stdlib.exit | ||
|> exit | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
let%expect_test "Param.assoc" = | ||
module Empty = struct | ||
type t = | | ||
|
||
let all = [] | ||
|
||
let to_string t = | ||
match[@coverage off] t with | ||
| (_ : t) -> . | ||
;; | ||
end | ||
|
||
let%expect_test "Param.enumerated" = | ||
let open Command.Std in | ||
require_does_raise [%here] (fun () -> Param.assoc []); | ||
[%expect {| (Invalid_argument Command.Param.assoc) |}]; | ||
require_does_raise [%here] (fun () -> Param.enumerated (module Empty)); | ||
[%expect {| (Invalid_argument Command.Param.enumerated) |}]; | ||
() | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
type 'a t = | ||
| Value : 'a -> 'a t | ||
| Map : | ||
{ x : 'a t | ||
; f : 'a -> 'b | ||
} | ||
-> 'b t | ||
| Both : 'a t * 'b t -> ('a * 'b) t | ||
| Apply : | ||
{ f : ('a -> 'b) t | ||
; x : 'a t | ||
} | ||
-> 'b t | ||
|
||
let rec eval : type a. a t -> a = | ||
fun (type a) (t : a t) : a -> | ||
match t with | ||
| Value a -> a | ||
| Map { x; f } -> f (eval x) | ||
| Both (a, b) -> | ||
let a = eval a in | ||
let b = eval b in | ||
a, b | ||
| Apply { f; x } -> | ||
let f = eval f in | ||
let x = eval x in | ||
f x | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(** Internal representation used to run a parser. | ||
This is the final representation returned after all of the parsing phases | ||
have completed, and is ready to run user code. *) | ||
|
||
type 'a t = | ||
| Value : 'a -> 'a t | ||
| Map : | ||
{ x : 'a t | ||
; f : 'a -> 'b | ||
} | ||
-> 'b t | ||
| Both : 'a t * 'b t -> ('a * 'b) t | ||
| Apply : | ||
{ f : ('a -> 'b) t | ||
; x : 'a t | ||
} | ||
-> 'b t | ||
|
||
val eval : 'a t -> 'a |
Oops, something went wrong.