2

I'm reading the Haskell book : http://learnyouahaskell.com/types-and-typeclasses

When I enter this line in the interpreter,

removeNonUppercase st = [c | c <- st, c `elem` ['A' .. 'Z']]

I get this error:

parse error on input `='

Whats causing this error ?

1

1 Answer 1

4

When defining variables or functions in the interpreter or in a GHCi script file (i.e. not a Haskell module), you need to use the let keyword.

> let removeNonUppercase st = [c | c <- st, c `elem` ['A' .. 'Z']]

This is because the interpreter essentially acts as if you were in a global do-block. Your code would be OK as-is in a Haskell source file.

If you got this error outside the interpreter, you probably either messed up the indentation, or you have some other syntax error in nearby code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.