[Haskell-cafe] Optimizing unamb by determining the "state" of a thunk?

Peter Verswyvelen bugfact at gmail.com
Mon Apr 20 03:41:17 EDT 2009


I was wandering if it would be possible to optimize
unamb<http://hackage.haskell.org/packages/archive/unamb/0.1.9/doc/html/Data-Unamb.html#v%3Aunamb>
by
checking if a value is already evaluated to head normal form.
So

f `unamb` g

would then be extremely fast if either f or g is already evaluated to head
normal form.

Maybe using some vacuum tricks?

This function would need to be in IO since it is of course not referentially
transparent.

Although threads are lightweight in Haskell, forking/waiting/killing surely
must have more overhead than just checking the thunk of an expression?

Of course one could also make unamb a primitive :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/7d56629d/attachment.htm


More information about the Haskell-Cafe mailing list