在haskell中使用oneOf,编译错误
我是 Haskell 的新手。 我正在尝试编译我下载的这个 Haskell 文件,但它给了我一些错误。
No instance for (Text.Parsec.Prim.Stream s m Char)
arising from a use of 'letter' at Parse.lhs:649:26-31
Possible fix:
add an instance declaration for (Text.Parsec.Prim.Stream s m Char)
In the first argument of '(<|>)', namely 'letter'
In the expression: letter <|> oneOf "_"
In the definition of 'firstAllowed':
firstAllowed = letter <|> oneOf "_"
不确定这是否足够,但这是有错误的代码部分:
parseIdent = do { str <- indent
; return (makeIdent str)
} <?> "identifier"
where firstAllowed = oneOf "_" <|> letter
I'm a complete newbie at Haskell.
I'm trying to compile this Haskell file I've downloaded but it's giving me some errors.
No instance for (Text.Parsec.Prim.Stream s m Char)
arising from a use of 'letter' at Parse.lhs:649:26-31
Possible fix:
add an instance declaration for (Text.Parsec.Prim.Stream s m Char)
In the first argument of '(<|>)', namely 'letter'
In the expression: letter <|> oneOf "_"
In the definition of 'firstAllowed':
firstAllowed = letter <|> oneOf "_"
Not sure if this is enough, but here's the section of the code with the error:
parseIdent = do { str <- indent
; return (makeIdent str)
} <?> "identifier"
where firstAllowed = oneOf "_" <|> letter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您引用的部分中,本地
firstAllowed
函数似乎没有在任何地方使用。如果删除where
行会发生什么?或者,您可以尝试将此类型签名添加到
firstAllowed
:In the part you quoted the local
firstAllowed
function doesn't seem to be used anywhere. What happens if you remove thewhere
line?Alternatively you could try to add this type signature to
firstAllowed
: