我想知道是否有可能(以及如何)爲多參數類型同義詞定義類實例。多參數類型同義詞實例
例如:
{-# 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
定義一個類型類實例嗎?