Re: [GHC] #7543: Constraint synonym instances

#7543: Constraint synonym instances -------------------------------------+------------------------------------- Reporter: monoidal | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by bheklilr): I don't have a particular attachment to being able to do this, my biggest concern is that it's somewhat inconsistent behavior. If a constraint isn't a class, then it shouldn't be possible to make an instance of it. Or we should allow all constraints to be instantiated as classes. This could lead to some interesting problems to have to solve, such as when two constraints are used that could have overlapping names {{{ module C1 where class C1 a where c :: a -> a }}} ---- {{{ module C2 where class C2 a where c :: a -> a }}} ---- {{{ module C where import C1 import C2 type Cs a = (C1 a, C2 a) instance Cs Int where C1.c = pred C2.c = succ }}} This won't work currently because you can't use qualified names in a binding position, but without the qualification you can't distinguish between the different `c` methods on the classes. I also can't say I'm a fan of having multiple instances defined in the same block. For example, the following would bother me {{{ newtype MyInt = MyInt Int type OrdNum a = (Num a, Ord a) instance OrdNum MyInt where compare (MyInt x) (MyInt y) = compare x y fromInteger = MyInt ... -- Results in -- instance Num MyInt -- instance Ord MyInt }}} Considering that the argument for being able use constraints like this is that it would slightly improve the usability of a handful of libraries, I'm personally leaning towards a fix that would simply disallow instancing anything that is not a class. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7543#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC