关于Haskell / HappStack中语法和类型签名的新手问题

时间:2011-05-15 06:34:10

标签: haskell happstack

为什么我不能做

z = x?

但我可以这样做吗?

y s = x s

我是Haskell的新手 这就是我在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'

1 个答案:

答案 0 :(得分:5)

看起来像monomorphism restriction

的另一个案例

您可以明确地包含参数,即y s = x s,包含显式类型签名,或者使用-XNoMonomorphismRestriction运行GHCi。