fsprojects / FSharp.Json

F# JSON Reflection based serialization library
Apache License 2.0
222 stars 26 forks source link

Represent single-case unions as their wrapped type #2

Closed cmeeren closed 6 years ago

cmeeren commented 6 years ago

Single-case DUs are frequently used for added type safety in F#. Since this is such a common pattern, any F# serialization library worth its salt should be able to represent single-case unions as their wrapped type. IMHO this should be the default behavior, but it should be configurable both globally and for specific types.

Pardon if your library already does this - I read through the documentation and couldn't t find any mention of it.

vsapronov commented 6 years ago

I agree - single case unions should be represented as wrapped type. Somehow I haven't thought about such scenario and the codebase that I'm working with mostly avoid this pattern. I can support such behaviour easily, stay tuned...

vsapronov commented 6 years ago

Implemented and released in version 0.2. Here's documentation: https://vsapronov.github.io/FSharp.Json/unions.html#Single-case-union

cmeeren commented 6 years ago

That was quick, thanks! 😁