
On Sun, 15 Aug 2010 21:11:52 +0200
Ertugrul Soeylemez
Just remember this: You have an IO computation? You want to refer to its result? Fine, just use '<-'. That's it.
that's what i've been doing the past two days and it works ... except in one case. for example, i have: ======== flData <- readFile key let (sec:tle:kwd:dsc:url:typ:dat:txt) = lines flData ======== so flData is the computation which reads the contents of a file and i can take that and do a lines on it. no problem. however, i also have: ======== subs (l:ls) | ls==[] = l : [] | otherwise = case l of "```" -> do let (code:z) = ls str = gt code -- works --str <- readFile "B" -- doesn't work subs (str:z) _ -> l : subs ls gt s = case s of "B" -> "BBBB" "C" -> "CCCC" ======== now str = gt code is fine because it's not monadic. however, if i try to get the data from a file or a db, it gives the error Couldn't match expected type `[[Char]]' against inferred type `IO b' because i'm trying to get an IO monad into a [String] from what i understand. so i'm trying different things here, but haven't found a way yet.
In fact, I recommend not to think more, but to think less.
ok! i'll see what i can do! as you rightly keep telling me, i'm being way too complicated. :D i'm enjoying your extensive tutorial: http://ertes.de/articles/monads.html though it's going slowly, but things are coming together little by little. i was also pointed to this: http://codingcactus.wordpress.com/2010/08/16/writemonad1/ and i just saw mike vanier's post here: very detailed monad tutorials (a series of articles) http://mvanier.livejournal.com/3917.html so with all this help i'm sure to 'get it' eventually!
At some point it will make click and suddenly everything gets clear. Everybody has this experience with monads (unless they give up).
no worries about that! i do see the light in the long tunnel - now it's just a matter of getting to it. -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's