相关疑难解决方法(0)

制定一个可能的约束方程式

我怎样才能约束到Eq a?它需要是善良的 - >>约束

我尝试了什么:

class (a ~ Maybe b, Eq b) => K a where
instance (a ~ Maybe b, Eq b) => K a where
Run Code Online (Sandbox Code Playgroud)

错误:

Not in scope: type variable ‘b’
Run Code Online (Sandbox Code Playgroud)

用法示例:

data Test c = forall a. (c a) => Test a
r :: Test K -> Maybe Bool
r (Test o) = (==) <$> o <*> o -- I need GHC to infer that o is Maybe Eq
Run Code Online (Sandbox Code Playgroud)

有效的案例:

pp :: Test ((~) String) -> …
Run Code Online (Sandbox Code Playgroud)

haskell

7
推荐指数
2
解决办法
420
查看次数

标签 统计

haskell ×1