[GHC] #11534: Allow class associated types to reference functional dependencies
GHC
ghc-devs at haskell.org
Wed Feb 3 22:58:05 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 ekmett):
Then I get stuck when I get to the
{{{#!hs
instance (Category p, Category q) => Category (Nat p q) where
type Ob (Nat p q) = Functor p q
}}}
line mentioned.
I can't define
{{{#!hs
type Fun c d f = Functor (Dom f) (Cod f) f
}}}
and then put that in
{{{#!hs
instance (Category p, Category q) => Category (Nat p q) where
type Ob (Nat p q) = Fun p q
}}}
because that involves partially applying a type family.
For other reasons, I can't eta expand `Ob` to make it a type family with
two parameters.
Normally I'd do precisely what you suggest
{{{#!hs
class Functor (f :: i -> j) where
type Dom f :: i -> i -> *
type Cod f :: j -> j -> *
}}}
and then use the class/instance trick
{{{#!hs
class (Functor f, Dom f ~ c, Cod f ~ d) => FunctorOf c d f | f -> c d
instance (Functor f, Dom f ~ c, Cod f ~ d) => FunctorOf c d f
}}}
to get a type family I can partially apply:
{{{#!hs
instance (Category p, Category q) => Category (Nat p q) where
type Ob (Nat p q) = FunctorOf p q
}}}
but I get stuck due to #11523 causing the compiler to loop.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11534#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list