heliaxdev / extensible-data

Generate the boilerplate for the Trees That Grow pattern
https://heliaxdev.github.io/extensible-data/Extensible.html
5 stars 0 forks source link

Add newtype support #16

Closed andy-morris closed 4 years ago

andy-morris commented 4 years ago

Fixes #14.

What this patch does is spit out a warning ("please replace 'newtype' with 'data'") on a newtype and continue as if it was a (strict) datatype. Other options I can think of offhand are to silently do this without warning, or to make the warning into a more descriptive error and stop.

Which do you think this is the more intuitive behaviour @mariari?


This PR also replaces the error "not a datatype" to show the offending declaration. It still doesn't show a correct line number because TH doesn't let me do that. :(

mariari commented 4 years ago

What this patch does is spit out a warning ("please replace 'newtype' with 'data'") on a newtype and continue as if it was a (strict) datatype. Other options I can think of offhand are to silently do this without warning, or to make the warning into a more descriptive error and stop.

It would be great if this were a flag somehow, but I think a warning by default is fine, as long as you mention the ofending newtype. The flag would be able to demote or promote the warning to nothikng or an error respectively.

andy-morris commented 4 years ago

@mariari I added a flag for extensibleWith, which for extensible defaults to a warning