
#8165: Use GeneralizedNewtypeDeriving to automatically create associated type families -------------------------------------+------------------------------------ Reporter: MikeIzbicki | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by MikeIzbicki): In all the cases where I've wanted to use this, the type is polymorphic. Here's a real example of when I've wanted to use this: {{{ class HasRing a where type Ring a instance HasRing [a] where type Ring [a] = a instance Hasring (Vector a) where type Ring (Vector a) = a newtype L2Norm a = L2Norm a deriving HasRing newtype L1Norm a = L1Norm a deriving HasRing }}} The deriving clauses would be equivalent to: {{{ instance HasRing a => HasRing (L2Norm a) where type Ring (L2Norm a) = Ring a instance HasRing a => HasRing (L1Norm a) where type Ring (L1Norm a) = Ring a }}} This might become problematic if there are multiple type parameters though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8165#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler