
#10978: Anonymous type instances -------------------------------------+------------------------------------- Reporter: | Owner: benjamin.hodgson | 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: -------------------------------------+------------------------------------- I find that commonly I write a `type family` (because it doesn't ''need'' to be a `data family`, and `type` families are more flexible), but I find myself writing `data` types for some of the instances anyway. Presently you're forced to use type synonyms for all the instances of a `type family`, even if you don't intend to refer to the type by any name other than that of the type family. I find this tiresome: {{{#!hs type family F a type instance F Char = Int newtype FBool = FBool Int type instance F Bool = FBool data FInt = A | B | ... type instance F Int = FInt }}} '''I want to write `data instance`s and `newtype instance`s for `type` families'''. These proposed constructs would introduce a new type without a name of its own (the only way to refer to it would be through the `type family`), just like the current design of `data` families. The above code would be roughly equivalent to: {{{#!hs type family F a type instance F Char = Int -- already legal newtype instance F Bool = FBool Int data instance F Int = A | B | ... }}} I call this idea ''anonymous type instances'' but I'm open to suggestions for a snappier name. Going the other way (writing a `type instance` for a `data family`) would remain illegal under this proposal. {{{#!hs data family G a type instance G Char = Int -- still illegal }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10978 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler