简体   繁体   English

GHCI中的模板Haskell

[英]Template Haskell in GHCI

I'm new at learning Haskell so I'll say sorry in advance for the silly questions. 我是学习Haskell的新手,所以对于那些愚蠢的问题,我会提前对不起。
I want to build a function that removes all the upper cases from a string (I use GHCI) 我想构建一个函数,该函数从字符串中删除所有大写字母(我使用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? 我究竟做错了什么?

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. 该答案是一个社区答案,因为对于StackOverflow而言,实际问题似乎不是主题,因为该错误源于印刷错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM