Kind/book/Parser.repeat.kind2

20 lines
437 B
Plaintext
Raw Normal View History

2024-02-21 01:23:15 +03:00
Parser.repeat
2024-03-02 02:40:31 +03:00
: ∀(n: Nat) ∀(A: *) ∀(p: (Parser A))
2024-02-21 01:23:15 +03:00
(Parser (List A))
= λn λA λp
use P = λx (Parser (List A))
use succ = λn.pred
2024-03-02 02:40:31 +03:00
(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))
)
)
use zero = (Parser.pure (List A) (List.nil A))
2024-02-21 01:23:15 +03:00
(~n P succ zero)