ndmitchell / record-dot-preprocessor

A preprocessor for a Haskell record syntax using dot
Other
129 stars 19 forks source link

Preprocessor breaks when trying to update usual records #24

Closed DoctorRyner closed 4 years ago

DoctorRyner commented 4 years ago
Screenshot 2019-10-30 at 1 25 15 PM

There is a workaround, I can enable it with pragma in each file where I use it and divide code that uses preprocessor but it's not that convenient at all

DoctorRyner commented 4 years ago

For example, that is valid

Screenshot 2019-10-31 at 4 23 29 PM

But that is not, I can't use update syntax for record that wasn't compiled with record-dot-preprocessor

Screenshot 2019-10-31 at 4 23 12 PM
ndmitchell commented 4 years ago

Note from the user manual at https://github.com/ndmitchell/record-dot-preprocessor#how-do-i-use-this-magic:

You must make sure that the OPTIONS_GHC is applied both to the file where your records are defined, and where the record syntax is used

Does that answer your question? Unfortunately it's a fundamental limitation of this technique until after GHC gets support for deriving these instances itself (which is coming in a future GHC).

DoctorRyner commented 4 years ago

Not exactly, because it's also a native syntax to update a record, but ok, I get it, I will divide my code into parts that use only records made with record-dot-preprocessor and that don't use it at all

ndmitchell commented 4 years ago

One option would be to write the necessary instances to get update working via hand. Unfortunately, they would be orphan instances.