[Haskell-cafe] monadic performance

Chad Scherrer chad.scherrer at gmail.com
Fri Oct 27 09:28:58 EDT 2006


I've written some code that does a foldl (or scanl, depending on my
mood) kind of thing, and builds a huge tree structure as it goes
along. I've been careful to make "insert"s as strict (and eager) as
possible, since I know all the pieces will be evaluated eventually
anyway. Now I'd like to be able to write various output as I traverse
the structure, and I was thinking about using the WriterT monad
transformer. For this, I could just make the base monad Identity, or I
think it could be nice (from a code elegance perspective) to use State
and rewrite the insert code to be State-ful. Sometimes when I have
used State before, I have been bitten by laziness. Should I expect a
monadic version to take a performance hit? What if I use some
SPECIALIZE pragmas or somesuch? Is it more efficient to write one from
scratch, or do specific type annotations give me the same thing



More information about the Haskell-Cafe mailing list