Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion Doubting Haskell
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jonathan Cast  
View profile  
 More options Feb 16 2008, 9:48 pm
Newsgroups: fa.haskell
From: Jonathan Cast <jonathancc...@fastmail.fm>
Date: Sun, 17 Feb 2008 02:48:56 UTC
Local: Sat, Feb 16 2008 9:48 pm
Subject: Re: [Haskell-cafe] Doubting Haskell
On 16 Feb 2008, at 5:04 PM, Donn Cave wrote:

> On Feb 16, 2008, at 3:46 PM, Philippa Cowderoy wrote:

>> On Sat, 16 Feb 2008, Alan Carter wrote:

>>> I'm a Haskell newbie, and this post began as a scream for help.

>> Extremely understandable - to be blunt, I don't really feel that  
>> Haskell
>> is ready as a general-purpose production environment unless users are
>> willing to invest considerably more than usual. Not only is it not as
>> "batteries included" as one might like, sometimes it's necessary  
>> to build
>> your own batteries!

> Ironically, the simple task of reading a file is more work than I  
> expect
> precisely because I don't want to bother to handle exceptions.  I  
> mean,
> in some applications it's perfectly OK to let an exception go to  
> the top.

> But in Haskell, you cannot read a file line by line without writing an
> exception handler, because end of file is an exception!  as if a  
> file does
> not normally have an end where the authors of these library functions
> came from?

I agree 100%; to make life tolerable around Haskell I/O, I usually  
end up binding the moral equivalent of

tryJust (\ exc -> case exc of
                              IOException e | isEOFError e -> return ()
                              _ -> Nothing) $
            getLine

somewhere at top level and then calling that where it's needed.

> For the author of the original post ... can't make out what you  
> actually
> found and tried, so you should know about "catch" in the Prelude, the
> basic exception handler.

Also, you might need to know that bracket nests in various ways:

bracket openFile hClose $ bracket readLine cleanUpLine $ proceed

There's also finally, for when the first argument to bracket is  
ommitted, and (>>) for when the second argument is :)

jcc

_______________________________________________
Haskell-Cafe mailing list
Haskell-C...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.