KeykoYume
KeykoYume

Reputation: 33

Template Haskell in GHCI

I'm new at learning Haskell so I'll say sorry in advance for the silly questions.
I want to build a function that removes all the upper cases from a string (I use GHCI)

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

But when I compile it, it shows the following message:

Syntax error on 'elem' 
Perhaps you intended to use TemplateHaskell
In the Template Haskell quotation 'elem'

What am I doing wrong?

Upvotes: 2

Views: 1653

Answers (1)

Zeta
Zeta

Reputation: 105876

You used an apostrophe ', where you should have used a backtick `. Also, you're missing a closing single quote:

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

Note that your function is the same as

removeUppercase = filter (`elem` ['A' .. 'Z'])

This answer is a community answer since the actual question doesn't seem on-topic for StackOverflow, as the error origins from a typographical mistake.

Upvotes: 5

Related Questions