4

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 instance for (FilterMonad Response m0)
      arising from a use of `x'
Dingfeng Quek
  • 898
  • 5
  • 14

1 Answers1

5

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.

hammar
  • 138,522
  • 17
  • 304
  • 385
  • Thanks. It works =) Although I think it'll be a few months before I understand what that means, and what I'm giving away by using that flag. – Dingfeng Quek May 15 '11 at 15:43