-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing deriveArgDict behaviour/error messages #49
Comments
Check out https://github.com/gelisam/klister This is the proper solution to keep order independence and I hope we get it someday in Haskell. @david-christiansen being HF director is auspicious for this :)
I don't understand this. Are you asking why we can't also do |
Haskell languages changes are up to the GHC Steering Committee, not me :-) I'm glad you think Klister is promising, though, and I hope to someday have some time to do work on it again. |
Well that's why I used a vague work like "auspicious" :) For now, I just want to collect a Real World™ instance of the problem that solves to refer to sometime later. |
Thanks for sharing klister with me, I hadn't heard about it before and it looks interesting! ✨
Sorry, I don't think I asked the question very well, let me try again: I've found that removing the |
Consider the following toy example:
Compiling this errors with:
Dumping the splices (with
-ddump-splices
) we can see the generated code is:When instead I would expect it to generate:
As the
ArgDict
instance forB
has not been generated yet,hasArgDictInstance
isFalse
inderiveArgDict
, so noConstraintsFor B c
/recursive call toargDict
is generated.A solution to this is to make sure
deriveArgDict ''B
comes beforederiveArgDict ''A
, which does generate the expected code, but this can be difficult to work out just from the error message.I am curious what the
hasArgDictInstance
check actually prevents? Can we remove it, always "optimistically" generate constraints and just let GHC's constraint solver handle this for us (failing if the constraint can't be satisfied).I have patched our copy of
constraints-extras
in our codebase to do this and haven't noticed any errors, but am very possibly missing something!The text was updated successfully, but these errors were encountered: