Optimizations for mutable structures?
Jan-Willem Maessen
jmaessen at alum.mit.edu
Wed Dec 7 08:30:36 EST 2005
Talk of uniqueness and so forth on the various Haskell mailing lists
causes me to wonder: with so much imperative code being written in
Haskell these days, to what extent is / should GHC perform standard
imperative optimizations? A few things come to mind:
- Fetch elimination for imperative reads:
writeIORef r e >> acts >> readIORef r === writeIORef r e >> acts
>> return e
readIORef r >>= \e -> acts >> readIORef r ===
readIORef r >>= \e -> acts >> return e
And that sort of thing, generalized for other imperative monadic
types...
My feeling is this doesn't come up much in code as written on
the page,
but might well be relevant after inlining.
- Some way to turn the following idiom into memcpy (for any array
type):
do a <- newArray
writeArray a 0 e0
writeArray a 1 e1
writeArray a 2 e2
...etc...
What say others? Is there a need yet? (I don't honestly know the
answer!)
-Jan-Willem Maessen
More information about the Glasgow-haskell-users
mailing list