Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  book question (Roelof Wobben)
   2. Re:  A first try (Daniel Fischer)
   3. Re:  A first try (Yitzchak Gale)


----------------------------------------------------------------------

Message: 1
Date: Mon, 27 Jun 2011 09:34:16 +0000
From: Roelof Wobben <[email protected]>
Subject: Re: [Haskell-beginners] book question
To: <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"



  Hello, 
 
First thanks for the help.
 
I looked at both books.
 
book.realworld.haskelll : 
 
Nice book with exercises but you need some functions to solve the exercises 
which are not mentioned in the book.
So there it will be very confusing.
 
 
learnyouahaskell : 
 
Also a nice book but without any exercices and in the first chapter a confusing 
part about list compreshenion.
 
Roelof
> Date: Mon, 27 Jun 2011 11:21:37 +0200
> Subject: Re: [Haskell-beginners] book question
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> 
> I used Real World Haskell
> Http:/book.realworldhaskell.org
> and was very happy with it.
> There's also Learn You A Haskell For Great Good
> http://www.learnyouahaskell.com
> which is probably funnier, but I can't tell you much more about it.
> For both it is helpful to have some experience with programming in
> genereal, but these are the first that came to mind.
> 
> Raf
> 
> On 6/27/11, Roelof Wobben <[email protected]> wrote:
> >
> >
> >
> >
> > Hello,  What's a good book for a absolute beginner in Haskell programming
> > with a lot of exercises so I can see if I understand it. Roelof
                                          
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110627/c654d483/attachment-0001.htm>

------------------------------

Message: 2
Date: Mon, 27 Jun 2011 11:49:37 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] A first try
To: [email protected]
Cc: Manfred Lotz <[email protected]>
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="utf-8"

On Monday 27 June 2011, 11:15:13, Manfred Lotz wrote:
> 
> I tried now:
> 
> getXmlContent :: String -> Handle -> IO Ctan
> getXmlContent xf inh = do
>     xml <- U.hGetContents inh
>     let content = xml `deepseq` parseXMLDoc xml
>     case content of
>     ...
> 
> deepseq really ensures parseXmlDoc gets the full file as a string.
> 
> It is unclear to me how this could be done without deepseq.

To ensure that the entire file is read, you can seq on the length,

    xml <- U.hGetContents inh
    let content = parseXMLDoc xml
    length xml `seq` case content of ...

that might be faster than deepseq (or it might make no difference, deepseq 
is cheap on Chars).
In general, it is often good to avoid deepseq if that would traverse large 
data structures which are already evaluated (consider modifying a Map or 
something similar, if you force it with deepseq, each alteration is 
O(size), so it's worth some effort to find a way to only force the modified 
parts to have the alterations be O(log size)).




------------------------------

Message: 3
Date: Mon, 27 Jun 2011 12:54:51 +0300
From: Yitzchak Gale <[email protected]>
Subject: Re: [Haskell-beginners] A first try
To: Heinrich Apfelmus <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Heinrich Apfelmus wrote:
> Again, let me stress that the biggest drawback of the Iteratee approach is
> that you have to rewrite the consumer and cannot reuse ordinary list
> functions like ?length , words , lines , and so on. But these functions are
> already lazy, so why not make use of this. (You don't lose anything, every
> Iteratee can be rewritten as an ordinary function ?String -> IO a ?by using
> ?`seq` ?in corresponding places.)
> Here one possibility for a lazier version of ?withFile' :

Let me just add my voice in support of Heinrich.

There has been a lot of FUD lately about lazy IO being
"unsafe" or even "evil". This is just not so.
When used correctly, there is nothing unsafe about lazy IO.

It's a matter of taste in the end, I suppose, but to me
lazy IO is the most natural way of doing IO in Haskell. True,
there are some subtleties. These stem from the fact that,
like Iteratees and any other current approach, they involve
superimposing operational semantics on top of Haskell.

I find that code written using lazy IO is clearer, more natural,
and easier to write than when written using
Iteratees/Enumeratees, even in more complicated cases when
you need to do some work to get the laziness to match up.

I have great respect for Oleg's enlightening research on
Iteratees. But for practical real-life programming, I choose
lazy IO over Iteratees when I have the choice.

Whether you are using lazy IO or Iteratees, we really need
some better higher-level combinators with simpler semantics
for more of the common use cases. Then it won't really matter.

And yes, that is possible with Iteratees too. See for, example,
Text.XML.Enumerator.Parse in Michael Snoyman's
xml-enumerator package. (But he conspicuously omits the ugly
type signatures in his sample usage. Those could use some
wrapping.)

Regards,
Yitz



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 36, Issue 69
*****************************************

Reply via email to