On Thu, 8 May 2008, Mark Wallsgrove wrote:
Problem now is reading the data back into the program. When I read the data
back into the program it comes as IO [Track]. This is the code I have been
using to load the data:
loadData :: String -> Catalogue
loadData fileName = do x <- readFile fileName
return (read x :: Catalogue)
type should be
loadData :: String -> IO Catalogue
But using plainly 'read' may not satisfy you, because the program will
abort unrecoverably if the file has corrupt content. You may want to use
'reads' and check manually if parsing was successful:
case reads x of
[(cat, "")] -> return cat
_ -> fail "corrupt file content"
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe