[Haskell-cafe] [Newbie question] -- Looping stdin until condition
blais at furius.ca
Fri May 30 20:14:30 EDT 2008
On Fri, 30 May 2008 16:54:18 -0700, "Philip Weaver"
<philip.weaver at gmail.com> said:
> > 1. How do I catch the exception that is raised from "read"?
> I think you want readIO, which yields a computation in the IO monad,
> so it can be caught.
Holy schmoly, there it is, words of wisdom, written as clearly as can
be, from the docs:
The readIO function is similar to read except that it signals parse
failure to the IO monad instead of terminating the program.
I'll be prosternating on the floor towards my web browser for the next
Thank you very much Philip.
(And thank you Don for the verbose examples.)
> > 2. Where do I find the appropriate information I need in
> > order to fix this? I'm probably just not searching in the
> > right place. (Yes, I've seen the GHC docs, and it doesn't
> > help, maybe I'm missing some background info.)
> In this particular case, I am not sure where you'd find this
> information. It's not very intuitive to a beginner why "read" doesn't
> work in this case.
Dear Philip, could you point your virtual finger towards a
reference/paper/book/any-bleeping-thing that would help this simple
beginner understand why it doesn't work in this case? I'm trying to
picture why a "read" function that terminates the program would be
useful anywhere. In fact, any library function other than something like
UNIX's "exit" or "kill" which terminates my program is not really
welcome in any of my computer programs, but then again, I haven't yet
been illuminated by the genie of pure functional languages. A reference
would be awesome.
More information about the Haskell-Cafe