I'd like to make synonyms for a class constraint like the following (very much simplified) example
{-# LANGUAGE ConstraintKinds #-}
type Foo = Functor
data MyFunctor a = MyFunctor
instance Foo MyFunctor where
fmap _ _ = MyFunctor
but I get fmap is not a (visible) method of class Foo
.
It seems like I should be able to do this because the GHC documentation says "... standard constraints, tuples and type synonyms for those two sorts of constraint are permitted in instance contexts and superclasses". I'm on GHC 7.6.
Your case isn't covered by those statements in the GHC documentation. An instance context using Foo
is something like:
instance Foo a => Bar a
A superclass would be something like:
class Foo a => Bar a
i.e. you're defining some other class or instance and Foo
/Functor
is one of the requirements. Here you're actually trying to define Functor
itself and you have to use the real class name.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句