The following code一类产生“预期的约束”错误:如何定义与一种类型的家庭
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExistentialQuantification #-}
type family Note a
type instance Note String = String
data SomeNote = forall a. Note a => SomeNote a
class HasNote b where
noteOf :: b -> SomeNote
该错误是Expected a constraint, but 'Note a' has kind '*', in the definition of SomeNote
。为什么?我该如何解决它?
目标是在某些数据结构b中包含Note类型的实例,并使用noteOf b提取它,无论实例是什么。