在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\'
    
已邀请:
看起来像单态限制的另一种情况。 您可以显式包含参数,即
y s = x s
,包含显式类型签名,也可以使用
-XNoMonomorphismRestriction
运行GHCi。     

要回复问题请先登录注册