[GHC] #11115: Indicate missing associated type instances

#11115: Indicate missing associated type instances -------------------------------------+------------------------------------- Reporter: rimmington | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If there is no matching instance for a typeclass that defines an associated type, GHC cannot further reduce an application of that associated type. For nested type family applications, this produces rather large error messages, eg: {{{ <interactive>:98:20: Couldn't match type ‘units-2.3:Data.Metrology.Factor.Normalize (Data.Metrology.Suspicious.Poly.SurfaceUnitFactorsOf (Data.Singletons.Prelude.Tuple.Snd (Data.Metrology.Suspicious.Poly.SplitPrefix (PrefixExp Deci) Deci Core)) units-2.3:Data.Metrology.Factor.@- '['units-2.3:Data.Metrology.Factor.F Core ('Data.Metrology.Z.S 'Data.Metrology.Z.Zero)])’ with ‘'[]’ In the expression: (25 %> centi Core) `ceilToUnit` deci Core In an equation for ‘it’: it = (25 %> centi Core) `ceilToUnit` deci Core }}} The cause of the above error message is that `Deci` is not a member of the typeclass `ExpUnitPrefix` that defines the associated type `PrefixExp`. Unfortunately this is not clear at all from the error message, and adding additional class constraints to the appropriate functions doesn't improve things. It would be nice if GHC pointed out that there is no `ExpUnitPrefix Deci` instance, or at least that `PrefixExp Deci` cannot be further reduced. I imagine this would be useful for open type families as well, but I can't comment personally. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11115 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11115: Indicate missing associated type instances -------------------------------------+------------------------------------- Reporter: rimmington | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): That's a good idea. But perhaps `PrefixExp Deci` isn't the villain! It is part of {{{ Data.Metrology.Suspicious.Poly.SplitPrefix (PrefixExp Deci) Deci Core }}} so perhaps the cause is a missing {{{ type instance SplitPrefix x Deci Core = ...x.... }}} I suppose that a possible heuristic would be this: * When reporting a "cant-match" error with `F t1 .. tn ~ ty`, where `F` is a type function, generate a "stuck-heuristic" message for `F t1 .. tn`. To generate a "stuck-heuristic" message for `F t1 .. tn`, * see if the call is "surely apart" from all the instances of `F`. (See our closed-type family paper for "surely-apart".) * If so, report that there is no instance for `F t1 .. tn`. * If not, find a type-function application in `t1 .. tn` (say `G s1 .. sm`) that, if reduced, could perhaps make `F t1 .. tn` fire, if any such application exists. * And generate a stuck-heruristic message for `G s1 .. sm` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11115#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11115: Indicate missing associated type instances -------------------------------------+------------------------------------- Reporter: rimmington | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I like that idea -- would be very helpful, I think. It's rather like suggestions of missing class instances, no? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11115#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC