On 5/30/08, Martin Blais [EMAIL PROTECTED] wrote:
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
Hi
The best thing to do is bypass read and use 'reads' to define your
own safe read.
maybeRead :: Read a = String - Maybe a
maybeRead s = case reads s of
[(x, )] - Just x
_ - Nothing
Or just use the Safe package:
Allright, this is a definitely a newbie question.
I'm learning Haskell and going through the exercises in the
beautiful Hutton book, and one of them requires for me to
write a loop that queries a line from the user (stdin),
looping until the user enters a valid integer (at least
that's how I want
On Fri, May 30, 2008 at 5:28 PM, Martin Blais [EMAIL PROTECTED] wrote:
Allright, this is a definitely a newbie question.
I'm learning Haskell and going through the exercises in the
beautiful Hutton book, and one of them requires for me to
write a loop that queries a line from the user
blais:
Allright, this is a definitely a newbie question.
I'm learning Haskell and going through the exercises in the
beautiful Hutton book, and one of them requires for me to
write a loop that queries a line from the user (stdin),
looping until the user enters a valid integer (at least
philip.weaver:
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.
Ah, that's a third option, sequence the effect using readIO,
import System.IO
import qualified Control.Exception as C
On Fri, 30 May 2008 16:54:18 -0700, Philip Weaver
[EMAIL PROTECTED] 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
On Fri, May 30, 2008 at 5:14 PM, Martin Blais [EMAIL PROTECTED] wrote:
On Fri, 30 May 2008 16:54:18 -0700, Philip Weaver
[EMAIL PROTECTED] 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
On Fri, 30 May 2008 17:19:54 -0700, Philip Weaver
[EMAIL PROTECTED] said:
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