1

At the GHCi prompt,

I am able to do,

Prelude Text.Parsec> :t (oneOf "aeiou")

and get (oneOf "aeiou") :: Stream s m Char => ParsecT s u m Char

But when I do,

let s = oneOf "aeiou"

I get the following error,

interactive>:36:9:
    No instance for (Stream s0 m0 Char)
      arising from a use of `oneOf'
    Possible fix: add an instance declaration for (Stream s0 m0 Char)
    In the expression: oneOf "aeiou"
    In an equation for `m': m = oneOf "aeiou"

Could someone please tell me why I am not able to assign to s?

Jay
  • 1,083
  • 1
  • 10
  • 19
  • 1
    Maybe because of type defaulting. What about when you do `let s = (oneOf "aeiou") :: Stream s m Char => ParsecT s u m Char`? – Satvik Aug 17 '13 at 11:47
  • possible duplicate of [What is the monomorphism restriction?](http://stackoverflow.com/questions/32496864/what-is-the-monomorphism-restriction) – Bakuriu Sep 11 '15 at 09:08

1 Answers1

6

This is the monomorphism restriction in action.

This question is closely related, though it isn't about the ghci let but the idea is the same.

Community
  • 1
  • 1
n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243