mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 20:47:25 +03:00
27 lines
525 B
Plaintext
27 lines
525 B
Plaintext
Parser.variant
|
|
: ∀(A: *) ∀(variants: (List (Parser.Guard A)))
|
|
(Parser A)
|
|
= λA λvariants
|
|
let P = λx (Parser A)
|
|
let cons = λvariant λothers
|
|
(Pair.get
|
|
(Parser Bool)
|
|
(Parser A)
|
|
variant
|
|
(Parser A)
|
|
λguard λparser
|
|
(Parser.bind
|
|
Bool
|
|
A
|
|
guard
|
|
λsuccess
|
|
(Bool.if
|
|
success
|
|
(Parser A)
|
|
parser
|
|
(Parser.variant A others)
|
|
)
|
|
)
|
|
)
|
|
let nil = (Parser.fail A "error")
|
|
(~variants P cons nil) |