
#8516: Add (->) representation and the Invariant class to GHC.Generics -------------------------------------+------------------------------------- Reporter: nfrisby | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 7.7 checker) | Resolution: | Keywords: Generics 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): Thanks, Simon! `ImplicationConstraints`/`QuantifiedConstraints` is something I've been wanting for a while, and it would definitely help me express more things in GHC generics than I've been wanting to express (see [https://ghc.haskell.org/trac/ghc/ticket/5927#comment:17 this comment] in #5927 for more). nfrisby, I thought of one more scenario in which conditions (1) and (2) could hold, but it's a bit of a silly one: {{{#!hs type role Wat nominal newtype Wat a = Wat a deriving (Functor, Generic1) }}} A scheming user could use `RoleAnnotations` to explicitly mark a role as `nominal` that would otherwise be inferred as `representational` (or `phantom`). But this feels extremely silly to me, since having a `Functor` instance seems to defeat the whole point of having a `nominal` role, since you can just use `fmap` to change the internal representation yourself. Indeed, the only examples I can think of where users mark roles as `nominal` are: 1. `Set` (from the [http://hackage.haskell.org/package/containers-0.5.7.1/docs/Data- Set.html#t:Set containers] package) 2. `HashSet` (from the [http://hackage.haskell.org/package/unordered- containers-0.2.7.1/docs/Data-HashSet.html#t:HashSet unordered-containers] package) 3. `Key` (from the [http://hackage.haskell.org/package/vault-0.3.0.6/docs /Data-Vault-ST-Strict.html#t:Key vault] package) And none of those can have `Functor` instances anyway. So I don't think this "counterexample" is much of a concern at all. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8516#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler