fsprojects / Fleece

Json mapper for F#
http://fsprojects.github.io/Fleece
Apache License 2.0
199 stars 31 forks source link

Map and Dictionary<string, V> #3

Closed mausch closed 10 years ago

mausch commented 10 years ago

Map in 98189e37121f3da5472d72a46b8063b1b52618f0

mausch commented 10 years ago

For some reason, when defining the 'instance' for Dictionary<string, 'a> the F# compiler tries to unify 'a and Dictionary<string, 'a> so it doesn't compile.

When wrapping Dictionary (e.g. type JDictionary<'TKey, 'TValue> = JDictionary of Dictionary<'TKey, 'TValue>) it works fine, so this looks like a compiler bug.

When given a trivial, incorrect definition:

    type FromJSONClass with
        static member inline FromJSON (_: Dictionary<string, 'a>) =
            function
            | JObject o as jobj ->
                Success (Dictionary<string, 'a>())
            | a -> failparse "Map" a

it breaks all other inline instances, only leaving the primitive ones in effect. So for example string list doesn't work, listing only byte, int, etc as available instances.