user4706184
user4706184

Reputation:

Haskell --- error using SplitOn ","

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

I'm getting this error: Couldn't match type '[Char]' with `Char' Expected type: [Char] Actual type: [String]

any tips?

Upvotes: 1

Views: 733

Answers (1)

LJᛃ
LJᛃ

Reputation: 8153

You need to use single quotes for char constants. See this

let splitter = splitOn ',' olist

Upvotes: 6

Related Questions