[GHC] #11534: Allow class associated types to reference functional dependencies
GHC
ghc-devs at haskell.org
Sat Mar 19 18:17:09 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 dfeuer):
If people want to go forward with desugaring fundeps to type families
(sounds great to me), I think it would be lovely to add naming syntax:
{{{#!hs
class Foo a b c d | (Q, R :: a -> b c), (S :: b d -> a)
}}}
would desugar to
{{{#!hs
class (b ~ Q a, c ~ R a, a ~ S b d) => Foo a b c d where
type family Q a
type family R a
type family S b d
}}}
To work with classes that lack named fundeps, some nasty names could be
made available.
{{{#!hs
class Foo a b c d | a -> b c, b d -> a
}}}
could desugar to use type families with (exposed, but unlikely) names like
`Foo__1_DET_2#`, `Foo__1_DET_3#`, and `Foo__2_4_DET_1#`, naming the
positions that determine other positions.
It might be good to add dysfunctional "soft dependencies" at the same
time, with `~>` syntax and vague semantics to be pinned down later (the
idea being that soft dependencies would only guide inference, as best they
could, without being relied upon for type checking).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11534#comment:27>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list