Created
July 13, 2018 13:35
-
-
Save Leonidas-from-XIV/346c9dda7c8d13c16fa6d6194d526dea to your computer and use it in GitHub Desktop.
Looking for a way to handle polymorphic variants
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
type 'a resp = Handled of unit | Continue of 'a | |
let handle_x = function Handled () -> Handled () | Continue x -> match x with `X -> Handled () | rest -> Continue rest | |
let handle_y = function Handled () -> Handled () | Continue x -> match x with `Y -> Handled () | rest -> Continue rest | |
let handle_xy v = handle_x (handle_y v) | |
match handle_xy (Continue `X) with | |
| Handled () -> () | |
| Continue v -> | |
match v with | |
| `Z -> () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment