-
-
Save Maxdamantus/121c4931aba573541130f39997dea8aa to your computer and use it in GitHub Desktop.
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
type ('s, 't) parser = 's -> ('t, 't) outcome | |
and ('s, 't) outcome = Fail | Success of { result: 't; state: 's; } | |
let fail s = Fail | |
let mapOutcome (f : 'a -> 'b) (o : ('s, 'a) outcome) : ('s, 'b) outcome = match o with | |
| Fail -> Fail | |
| Success { result = r; state; } -> Success { result = f r; state; } | |
let map | |
(f: 'x -> 'b) | |
(p: ('s, 'x) parser) | |
: (('s, 'b) parser) = | |
fun state0 -> mapOutcome f (p state0) (* with | |
| Fail -> Fail | |
| Success { result = (r : 'x); state; } -> Success { result = (f r : 'b); state; } | |
*) |
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
type ('s, 't) parser = 's -> ('t, 't) outcome | |
and ('s, 't) outcome = Fail | Success of { result: 't; state: 's; } | |
val fail : ('s, 't) parser | |
val mapOutcome : ('a -> 'b) -> ('s, 'a) outcome -> ('s, 'b) outcome | |
val map : ('a -> 'b) -> ('s, 'a) parser -> ('s, 'b) parser |
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
Error: The implementation parse.ml does not match the interface parse.cmi: | |
Values do not match: | |
val map : ('b -> 'b) -> ('s, 'b) parser -> ('s, 'b) parser | |
is not included in | |
val map : ('a -> 'b) -> ('s, 'a) parser -> ('s, 'b) parser | |
File "parse.ml", line 10, characters 4-7: Actual declaration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment