为什么我做不到
z = x?
但我能做到吗?
y s = x s
我是哈斯克尔新手这是我在GHCi中一直在尝试的:
Prelude> import Happstack.Server
Prelude Happstack.Server> let x s = ok $ toResponse $ "Some string"
Prelude Happstack.Server> :t x
x :: FilterMonad Response m => t -> m Response
Prelude Happstack.Server> let y s = x s
Prelude Happstack.Server> :t y
y :: FilterMonad Response m => t -> m Response
Prelude Happstack.Server> let z = x
<interactive>:1:9:
No instance for (FilterMonad Response m0)
arising from a use of `x'
看起来像是单态限制的另一种情况。
您可以显式包含参数,即 y s = x s
,包括显式类型签名,或使用 -XNoMonomorphismRestriction
运行 GHCi。