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

Thomas Davie tom.davie at gmail.com
Mon Apr 20 04:23:27 EDT 2009


On 20 Apr 2009, at 09:41, Peter Verswyvelen wrote:

> I was wandering if it would be possible to optimize unamb 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.

Really?  Is it any less referentially transparent than unamb already  
is - i.e. it's referentially transparent, as long as the two values  
really are equal.

> 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 :-)

That would be a lovely solution for me.

Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/daf56ac8/attachment.htm


More information about the Haskell-Cafe mailing list