[Haskell-beginners] Re: monad nomad gonad gomad
prad at towardsfreedom.com
Tue Aug 17 13:25:25 EDT 2010
On Sun, 15 Aug 2010 21:11:52 +0200
Ertugrul Soeylemez <es at ertes.de> wrote:
> 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:
| ls== = l : 
| otherwise =
case l of
"```" -> do
let (code:z) = ls
str = gt code -- works
--str <- readFile "B" -- doesn't work
_ -> 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
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:
though it's going slowly, but things are coming together little by
i was also pointed to this:
and i just saw mike vanier's post here:
very detailed monad tutorials (a series of articles)
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.
... with you on your journey
Information, Inspiration, Imagination - truly a site for soaring I's
More information about the Beginners