[Haskell-cafe] list comprehansion performance has hug different

Brandon Allbery allbery.b at gmail.com
Wed Jan 30 16:07:44 CET 2013

On Wed, Jan 30, 2013 at 7:02 AM, Junior White <efiish at gmail.com> wrote:

> Thanks for your reply!  I must learn more to fully understand what's going
> on inside the list comprehension.
> But when I frist learn Haskell, it says sequence doesn't matter, but now
> it is a big matter, can compiler do some thing for us? I think this
> behavior is not friendly to newbies like me, I will take a very long time
> to work through it.

No, the compiler can't help you here.  The compiler is not an oracle; even
if it could invert your calculation (effectively swapping the loops
around), it can't know which one is more appropriate.

As to sequences:  sequence doesn't matter indeed; data dependencies matter,
and loop ordering imposes a data dependency because loops in Haskell are
encoded as data structures (lists).

brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130130/a012c277/attachment.htm>

More information about the Haskell-Cafe mailing list