Created
March 15, 2017 04:31
-
-
Save jyc/b21bd20af6aac3a9cec59521986d87eb 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
| type 'a jsont = | |
| | String : string jsont | |
| | List_of : 'a jsont -> 'a list jsont | |
| let rec convert (type el) (t : el jsont) x : el option = | |
| match t with | |
| | String -> | |
| begin match x with | |
| | `String (s : string) -> Some s | |
| | _ -> None | |
| end | |
| | List_of yt -> | |
| begin match x with | |
| | `List ys -> | |
| Some (List.map (convert yt) ys) | |
| | _ -> None | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment