dhall-lang / dhall-json

This repository has moved to https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-json
BSD 3-Clause "New" or "Revised" License
65 stars 6 forks source link

Add support for preserving sum type tags #38

Closed Gabriella439 closed 6 years ago

Gabriella439 commented 6 years ago

Fixes #32

Previously dhall-to-json would discard tags when converting to JSON and this adds support for preserving the tag name in a configurable way

enolan commented 6 years ago

Works! Thanks Gabriel. It'd be nice to have Tagged, Nesting and maybe a convenience function for writing things like wrap in a library somewhere.

enolan commented 6 years ago

Oh, one other thing. If you have a constructor for your union that doesn't take a record, then it's invalid to use Inline, but the implementation doesn't check for this, which is confusing.

Gabriella439 commented 6 years ago

@enolan: The implementation falls back to performing no transformation if anything doesn't match up. In this case, if you use Inline on a constructor wrapping a non-record value then it doesn't perform any special conversion.