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