Re: [GHC] #14046: “Illegal type synonym family application in instance” is too strict in the presence of functional dependencies
GHC
ghc-devs at haskell.org
Fri Jul 28 07:32:20 UTC 2017
#14046: “Illegal type synonym family application in instance” is too strict in the
presence of functional dependencies
-------------------------------------+-------------------------------------
Reporter: lexi.lambda | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #3485 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by lexi.lambda):
Could you give me an example of a program with observably different
behavior between the two instances? That is, given the thing being
discussed, probably a program that typechecks under the presence of one
instance but not the other. Without that, I’m not familiar enough with the
precise details of how the constraint solver handles functional
dependencies to understand the difference.
Also, even if there ''is'' a meaningful difference, is it significant
enough that it would make allowing the instance defined without the
equality constraint meaningless or inconsistent?
----
The example I gave in the ticket is in something of a vacuum, so allow me
to give an example of what actually caused this in the first place.
Specifically, I was using the `lens` library’s TH function `makeFields` on
a record type that had a type family application as the type of one of its
fields. The code in question looked something like this:
{{{#!hs
type family Fam a
data Rec a = Rec { _recValue :: Fam a }
makeFields ''Rec
}}}
This effectively generates the following code:
{{{#!hs
class HasValue s a | s -> a where
value :: Lens' s a
instance HasValue (Rec a) (Fam a) where
value = -- ...
}}}
…which raises the error.
I opened [https://github.com/ekmett/lens/issues/754 ekmett/lens#754] to
raise the issue with the `lens` folks directly, and I may very well
attempt to solve the issue there myself by inserting the relevant Template
Haskell checks and generating the equality constraint where necessary. I
just figured it would make sense to ensure I wasn’t doing a lot of extra
work to circumvent a possibly unnecessary restriction in GHC.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14046#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list