bug in language definition (strictness)

John Meacham john at repetae.net
Thu Aug 13 03:01:56 EDT 2009


On Fri, Aug 07, 2009 at 08:56:39AM +1000, Peter Gammie wrote:
> How so? Take this code:
>
> newtype BDD = BDD (ForeignPtr Int)
>
> exists :: Group BDD -> BDD -> BDD
> exists group bdd = bdd `seq` unsafePerformIO $
>   withGroup group $ \ gid ->
>     do bdd_assoc bdd_manager gid
>        withBDD bdd ({#call unsafe bdd_exists#} bdd_manager) >>=  
> addBDDfinalizer

Just a question, why not do

> How so? Take this code:
>
> newtype BDD = BDD (ForeignPtr Int)
>
> exists :: Group BDD -> BDD -> BDD
> exists group bdd = unsafePerformIO $
>   bdd <- evaluate bdd
>   withGroup group $ \ gid ->
>     do bdd_assoc bdd_manager gid
>        withBDD bdd ({#call unsafe bdd_exists#} bdd_manager) >>=  
> addBDDfinalizer

It seems that evaluate is exactly the thing to order evaluations in the
IO monad.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/


More information about the Haskell-prime mailing list