0
我是Haskell的新手,尝试实现here中的代码以使用地图替换字符串。我汇编,说使用地图编译错误替换字符串
* Expecting one more argument to `StringMap'
Expected a type, but `StringMap' has kind `* -> *'
* In the type signature:
stringMapReplace :: (Show stringMap) => StringMap -> String -> String
我试图寻找过程中收到错误信息,但我可以找到错误的唯一的答案是,我不是澄清StringMap
是什么类型。不过,我认为这是Show stringMap
正在做的。
import Data.Map
import Data.Strings
type StringMap stringMap = [(String, String)]
myStringMap =
[
("org1", "rep1"),
("org2", "rep2")
]
stringMapReplace :: (Show stringMap) => StringMap -> String -> String
stringMapReplace [] s = s
stringMapReplace (m:ms) s = strReplace ms (replace (fst m) (snd m) s)
main :: IO()
main = do
putStrLn "Enter some text:"
putStrLn =<< stringMapReplace myStringMap <$> toUpper getLine
注:strReplace
来自Data.Strings
我不知道是否有别的错误的代码,编译器只给上面,现在的错误。如果您注意到其他任何事情,请随时提及(或稍后作为练习留待我调试)。
@chi感谢。现在修复。 – crockeea