开发者

Newbie question on syntax and type signature in Haskell/HappStack

开发者 https://www.devze.com 2023-03-06 04:43 出处:网络
Why is it that I can\'t do z = x? but I can do this? y s = x s I\'m a Haskell newbie This is what I\'ve been trying in GHCi:

Why is it that I can't do

z = x?

but I can do this?

y s = x s

I'm a Haskell newbie This is what I've been trying in 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 instan开发者_如何转开发ce for (FilterMonad Response m0)
      arising from a use of `x'


Looks like another case of the monomorphism restriction.

You can either include the argument explicitly, i.e. y s = x s, include an explicit type signature, or run GHCi with -XNoMonomorphismRestriction.

0

精彩评论

暂无评论...
验证码 换一张
取 消