【发布时间】:2011-09-03 06:02:59
【问题描述】:
美好的一天,我尝试在我的项目中使用 TagSoup 库并在开始时卡住了。
Tagsoup 有 StringLike 类,我猜想这是很荣幸的目的,但我无法理解如何正确处理它。我写了函数:
parseFile :: (StringLike str) => String -> IO [Tag str]
parseFile f = do
html <- readFile f
return $ parseTags html
这给了我:
无法匹配预期类型
str' against inferred type[Char]'str' is a rigid type variable bound by the type signature forparseFile' 预期类型:IO [Tag str] 推断类型:IO [Tag String]
但是 TagSoup 的 'parseTags' 函数具有这样的签名并且运行良好:
parseTags :: StringLike str => str -> [Tag str]
如果我将其签名更改为:
parseFile :: String -> IO [Tag String]
但是我喜欢我的函数也retin这个typeclassed签名,而不是严格的String,如何实现这个?
【问题讨论】:
标签: haskell