【发布时间】:2018-02-25 14:41:59
【问题描述】:
我有一个关于泛化的问题。从这个函数开始:
test0 :: String -> String
test0 s = s
我们可以在它的论点中概括它:
test1 :: forall a. Show a => a -> String
test1 s = show s
或其函数结果:
test12 :: forall a. Show a => String -> a
test12 s = s
现在考虑以下函数:
test2 :: forall e. Aff e Int
test2 s = pure 0
我想将它概括为它的功能结果:
test3 :: forall e m. MonadAff e m => m e Int
test3 s = pure 0
但是,我现在收到一个错误: 在值声明 test3 中检查 MonadAff e m => m e Int 的种类时,无法将种类类型与种类 #Control.Monad.Eff.Effect 匹配。
我不明白为什么。此外,我在 Hyper.Node.Server 中找到了一个类似的泛化示例,例如这种类型:
write :: forall m e. MonadAff e m => Buffer -> NodeResponse m e
【问题讨论】:
标签: purescript