Last active
August 14, 2017 19:23
-
-
Save Dzoukr/a48e5b2d58f91b3a7638997ea40a44fb 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
module Chiron.Extensions | |
let tryDeserializeWith (fromJson : Json<'a>) : Json -> Choice<'a, string> = | |
fun json -> | |
match fromJson json with | |
| JsonResult.Value x, _ -> Choice1Of2(x) | |
| JsonResult.Error err, _ -> Choice2Of2(err) | |
let tryDeserializeWithP (_, fromJson : Json<'a>) : Json -> Choice<'a, string> = | |
tryDeserializeWith fromJson | |
let deserializeWith (fromJson : Json<'a>) : Json -> 'a = | |
fun json -> | |
match tryDeserializeWith fromJson json with | |
| Choice1Of2 x -> x | |
| Choice2Of2 err -> failwith err | |
let deserializeWithP (_, fromJson : Json<'a>) : Json -> 'a = | |
deserializeWith fromJson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment