我试图弄清楚是否可以(以及如何)为多参数类型同义词定义类实例。
例如:
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
type F a b = a -> b
data DF a b = DF (a -> b)
class C c a b where
doc :: c a b -> a -> b
它适用于多参数类型实例:
instance C DF a b where
doc (DF f) x = f x
但它不适用于类型同义词:
-- ERROR:
--
-- Type synonym `F' should have 2 arguments, but has been given none
-- In the instance declaration for `C F a b'
--
instance C F a b where
doc f x = f x
是否可以为 定义类型类实例F
?