On Thu, Jul 23, 2015 at 8:02 AM, Adam Sjøgren <a...@koldfront.dk> wrote:

> Bob writes:
>
> > Here are some more tips on strictness and Haskell's evaluation model:
>
> >
> http://chimera.labs.oreilly.com/books/1230000000929/ch02.html#sec_par-eval-whnf
> > https://hackhands.com/lazy-evaluation-works-haskell/
>
> Thanks for the links!
>
> What is your experience, do you grow an intuition about when to worry
> about lazy/strict, or how do you think about it in the day-to-day
> programming?
>

Yes, you do develop an intuition about evaluation if you spend enough time
studying how it works.

If you're doing a left fold (over a left-biased structure such as a list),
it's almost always best to use a strict left fold. You'll get the best
performance if you use libraries that were designed with performance in
mind, for this particular module I might use something like this:
xhttps://hackage.haskell.org/package/foldl-1.1.1/docs/Control-Foldl.html

I would generally recommend to use strict fields in data types unless you
have a use case for them to be lazy (this will enable the unpack
optimization for better memory locality too). The common pitfalls here are
that tuples, Maybe, Either, etc. all have lazy fields.

If there were a strict IO interface available I'd combine that with pipes,
conduit, or machines to do the I/O incrementally. It looks like all of the
functions in BioHaskell use lazy I/O though.

Reply via email to