Haskell ---错误使用SplitOn","

时间:2015-03-27 03:33:44

标签: haskell

getLines = liftM lines . readFile

main = do
    argv <- getArgs
    name <- getProgName
    if not (null argv)
    then do
           let file = head argv 
           list <- getLines file
           let olist = mergesort (<=) list
           let splitter = splitOn "," olist
           loop olist
    else hPutStr stderr $ "usage: " ++ name ++ " filename"

loop a = do 
    line <- getLine
    case line of
     "help"  -> putStrLn "print - prints list in alphabetical order\n\
                \quit  - exits program"
     "print" -> do putStrLn "[print]"
                   mapM_ putStrLn a
                   putStr "\n"
     "quit"  -> do putStrLn "[quit]" 
                   exitSuccess
     _       -> putStrLn "invalid command" 
    loop a

我收到此错误: 无法将类型'[Char]'与`Char'匹配 预期类型:[Char] 实际类型:[String]

任何提示?

1 个答案:

答案 0 :(得分:6)

您需要为char常量使用单引号。 See this

let splitter = splitOn ',' olist