class Eq a where
(==), (/=) :: a -> a -> Bool
x /= y = not (x == y)
x == y = not (x /= y)
deriving instance Eq Bool
我假设它生成
instance Eq Bool where
True == True = True
False == False = True
但是我如何从类似的东西创建一个实例
newtype Sink p = Sink {unSink :: MVar (E.Iteratee (Message p) IO ())}
instance Eq (Sink p) where
?==? = True
我只是使用派生,ghc 会自己解决吗?
deriving instance Eq (Sink p)
PS我已经阅读了这篇文章,但它超出了我的理解能力 http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/deriving.html