Read file problems

Frederic BELLOC belloc_f at epita.fr
Mon Sep 15 16:55:29 EDT 2003


HI,
I have a recurrent probleme with function readFile and Monad :
it is that i try to get a line, transform it  and stock it in a list
and what i want is that function return me the list.
But hugs say me that in

readFile my_file >>= \s -> map cons_line (lines s)
readFile is a IO String type but is used here as [[Char]] type...
and i don't know what to do... 

Ghc say me that is the lambda abstraction that fails with 
"map cons_line (lines s)" , he couldn't match IO against [] !

Help me please, i understand well (i hope) how Monad work but here i don't see
a solution.

Sorry for my poor english but i'm already a student.

Thanks for all.
-- 
C, socks and sun ;-)
and haskell bugs :-(



More information about the Haskell-Cafe mailing list