Created
October 10, 2019 11:54
-
-
Save vshapenko/8cd0c15d9e5c2f612da85b9d797d27fe 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
|Shape.Enum s-> | |
s.Accept { | |
new IEnumVisitor<Convert<'T>> with | |
member __.Visit<'t ,'u when 't : enum<'u> | |
and 't : struct | |
and 't :> ValueType | |
and 't : (new : unit -> 't)>() = | |
let printer= | |
fun x-> | |
let ts:'u = unbox<'t> x|>LanguagePrimitives.EnumToValue | |
ts|>BsonValue | |
let parser=fun(v:BsonValue)-> | |
let res:'t=LanguagePrimitives.EnumOfValue (unbox<'u> v.AsInt32) | |
res | |
mkParser printer parser | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment