
#14661: Cannot derive (newtype I a b = I (F a -> F b) deriving newtype Category) for type family F -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.4.1-alpha1 Resolution: wontfix | Keywords: | DerivingStrategies, deriving, | TypeFamilies 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 RyanGlScott): Your example in comment:12 is quite interesting. It only fails because GHC attempts to generate the constraint `Semigroup (forall xx. Endo xx)` and immediately chokes. But we never intended to generate that constraint—we wanted `forall xx. Semigroup (Endo xx)`, a quantified constraint! I would posit that if we derive instances that require slapping a class onto a type, we should be pushing the class through `forall`s and other constraints. For instance, if we want to apply `Semigroup` to `forall xx. Endo xx`, we should push `Semigroup` through `forall xx` to obtain `forall xx. Show (Endo xx)`, and then chuck //that// into the constraint solver. (I think this same strategy would work with the program in comment:13, as we really want to generate the constraint `forall zz. ListLike zz => ListLike zz`, which could be discharged immediately. But that might require #14733 to be fixed, so perhaps it's not as good of a motivating example.) All of this assumes `QuantifiedConstraints`, of course, so it's not really actionable right now. Iceland_jack, perhaps you could open a separate ticket for this? (With the keyword `deriving` in there so that I can find it later.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14661#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler