Last active
October 5, 2017 07:22
-
-
Save CoditCompany/c4029ee5c41fd854d9adbebd1eb43c98 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Parser<('a -> 'b), 'u> -> Parser<'a, 'u> -> Parser<'b, 'u> | |
| let apply fp xp = | |
| pipe2 fp xp (fun f x -> f x) | |
| // ('a -> Parser<'b, 'u>) -> 'a list -> Parser<'b list, 'u> | |
| let traverse f list = | |
| let (<*>) = apply | |
| let retn = preturn | |
| let cons head tail = head :: tail | |
| let init = retn [] | |
| let folder head tail = | |
| retn cons <*> (f head) <*> tail | |
| List.foldBack folder list init | |
| // Parser<'a, 'u> list -> Parser<'a list, 'u> | |
| let sequence x = traverse id x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment