cassava
cassava copied to clipboard
Better error message when using value of headerOrder for DefaultOrdered instance
When using the value of headerOrder now you will see an error like this:
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at ./Data/Csv/Encoding.hs:292:36 in cassava-0.5.1.0-5YJOfCvyfAxEy7HZ6afV23:Data.Csv.Encoding
Perhaps undefined can replaced with something like error "you are not allowed to use the argument to headerOrder"?
What is also possible is to change the type of headerOrder not to take any argument and use Proxy or type signature on call site headerOrder @MyType but this is probably not backwards compatible.
I would recommend to use Data.Proxy to make sure compiler warns us about the error in advance.