Back Story: I've been struggling with this problem for the last week now, reading through Learn You A Haskell, and tutorials online, but I can't figure it out.
I've made a lot of progress with understanding list comprehension and recursion, but this one problem is the one thing still standing in my way.
Question: I'm trying to convert a String (or what I think is a String) into a divided list. Here's the code that I have so far (thanks again Jan for the help). It imports the contents of a .txt file.
import System.Environment
main :: IO ()
main = do
args <- getArgs
if null args
then putStrLn "usage: ./pattern dataset.txt"
else do contents <- readFile $ head args
putStrLn $ "Filer1: " ++ filterLower(contents)
convert' contents
filterLower :: String -> String
filterLower st = [ c | c <- st, c `elem` ['A'..'Z']]
I tried making my own convert function:
convert' :: String -> [String]
convert' x = (x:[])
It works, but it doesn't work for this problem.
Any help would be appreciated.
Error: This is the error that I regularly get.
Couldn't match expected type `IO ()' with actual type `[String]'
In the return type of a call of `convert''
In the expression: convert' contents
In the expression:
do { contents <- readFile $ head args;
putStrLn $ "-: " ++ filterLower contents;
convert' contents }
convert'? It looks like you're just trying to throw the result away: you don't try to print it or anything.