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
Sat Jul 29 10:15:53 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 AntC):
> GHC rejects the following instance, complaining about the use of a type
synonym family in the instance head ...
? This isn't a bug. GHC has never allowed type family applications in the
instance head. (With FlexibleInstances, it does allow type synonyms.)
#3485 is an enhancement request (and closed, for good reasons IMO).
So the FunctionalDependency is a red herring.
I agree with your suggestion on lens#754 the Template Haskell for lenses
should be smarter.
If there's an opportunity for an enhancement, I think there's a more
general suggestion. Borrow the irrefutable patterns idea like:
{{{
instance HasValue (Rec a) ~(Fam a) where ...
}}}
And allow `~( ... )` to be any type or family application. Treat it as
syntactic sugar for:
{{{
instance (b0 ~ Fam a) => HasValue (Rec a) b0 where ... -- b0 is fresh
}}}
Also there's an opportunity for the compiler to see that instance (as
compared with others):
a. doesn't really overlap
b. is consistent with FunDeps
c. doesn't break the Coverage Condition
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14046#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list