[GHC] #11534: Allow class associated types to reference functional dependencies
GHC
ghc-devs at haskell.org
Sun Feb 7 20:24:59 UTC 2016
#11534: Allow class associated types to reference functional dependencies
-------------------------------------+-------------------------------------
Reporter: ekmett | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.10.3
checker) | Keywords: TypeFamilies,
Resolution: | FunctionalDependencies
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
Another point is that GHC isn't very good at actually enforcing functional
dependencies. For one thing, you can certainly fool it by putting orphan
instances in different modules. But historically there have been several
bugs where GHC failed to check the necessary conditions for the dependency
to be functional under some cases.
Notably, see #8634 and related tickets. For better or worse, after 7.8
fixed an often-abused bug, many users clamored for the old behavior. But
that never quite happened, and the requests seem to have died out.
In the past we've been fairly lackadaisical about such bugs since they
don't seem to threaten type safety. From `class C a b | a -> b` and `C a
b` and `C a b'` you cannot deduce `b ~ b'`. (In fact I think functional
dependencies are much older than System FC.) But if we give access to the
"functionally determined type" through a type family, then type safety is
at stake so we have to treat such bugs seriously. Most likely, the
implementation will force us to check the functional dependency correctly,
and I would guess we will find a lot more programs that are currently
abusing functional dependencies, to no real harm, and have to break them.
Something to consider.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11534#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list