mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 15:56:12 +03:00
13 lines
378 B
Plaintext
13 lines
378 B
Plaintext
Parser.repeat
|
|
: ∀(n: Nat)
|
|
∀(A: *)
|
|
∀(p: (Parser A))
|
|
(Parser (List A))
|
|
= λn λA λp
|
|
let P = λx (Parser (List A))
|
|
let succ = λn.pred
|
|
(Parser.bind A (List A) p λhead
|
|
(Parser.bind (List A) (List A) (Parser.repeat n.pred A p) λtail
|
|
(Parser.pure (List A) (List.cons A head tail))))
|
|
let zero = (Parser.pure (List A) (List.nil A))
|
|
(~n P succ zero) |