No, this is not possible (since 7.8.3, and I think also 7.10); GHS Error # 7543 . This is not a very dangerous mistake; Obviously, there are at least a few people who would like to write such things (for example, you, Edward Kmett), but mostly this goes unnoticed. There is no progress in changing this behavior recorded on the tracker.
As for why you can't, let me rephrase Simon Peyton-Jones's explanation in the error tracker. The problem is that type checking instances have two parts: first, the GHC must look for where the method names are (here, i ); secondly, the GHC should expand type synonyms. Because these two steps are performed on this issue by two different components of the GHC, instances of the constraint syntax cannot be supported; The GHC cannot determine in which class it should look in order to find i .
Another reason this is a mistake - and the reason I found it, according to the comments of András Kovács answer , is that the current behavior is not as simple as "it does not work." Instead, it tries to work, but you cannot declare any methods ... but you can declare an instance without a method! In GHCi:
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help ... Prelude> :set -XMultiParamTypeClasses -XFlexibleInstances -XConstraintKinds Prelude> class Interface ic where i :: c -> i Prelude> instance Interface ii where i = id Prelude> let (
In other words:
instance IDrawable () where i _ = IDrawable $ return ()
fails but
instance IDrawable () where {}
succeeds! Thus, the check should be loosened or tightened depending on the desired behavior :-)
PS: One more thing: you should always use synonyms like-reduce as much as possible. This is why I changed IDrawable to
type IDrawable = Interface IDrawable'
and reset parameter c on both sides in the GHCi code above. The advantage of this is that since type synonyms cannot be partially applied, you cannot pass your version of IDrawable as a parameter to everything; however, a fully eta-reduced version can be passed anywhere, expecting something like * -> Constraint .
(This touched on András Kovács answer , and I mentioned it in the comment there, however, since I wrote the answer too, I decided that I 'and add it here.)