
#14748: Infer context for Data instance of (data Foo f = Foo (f Bool) (f Int)) -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: | QuantifiedConstraints wipT2893, | deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: QuantifiedConstraints wipT2893 => QuantifiedConstraints wipT2893, deriving Comment: I'm not sure. When doing {{{ data T a = MkT a [a] deriving( Eq ) }}} the deriving mechanism says "oh, we need `Eq` on each field, that is `Eq a, Eq [a]`". Then it simplifies that to arrive at the instance context. For your example, it'd say "I need `Data (f Bool), Data (f Int)` and then get stuck. There are two ways to get unglued. One is simply to put those in the instance context {{{ instance (Data (f Int), Data (f Bool)) => Data (Foo f) where ... }}} The other is to use quantified constraints. It's not clear which is best in general. And even figuring out the appropriate quantified-constraint generalisation of a set of ground constraints is far from trivial. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14748#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler