[Haskell-cafe] multi-thread and lazy evaluation

Corentin Dupont corentin.dupont at gmail.com
Tue Dec 25 17:57:17 CET 2012


Hi Brandon,
indeed in my example if you add:
*b <- evaluate a*
after the definition of "a" it works.
However, in my original program it doesn't work, I suppose because I
interpret the user submitted code (here "*let (a::String) = a" *
 for the example) via Hint and Hint-server, and the interpretation must be
done in another thread...

Best,
Corentin

On Mon, Dec 24, 2012 at 3:46 PM, Brandon Allbery <allbery.b at gmail.com>wrote:

> On Mon, Dec 24, 2012 at 8:45 AM, Corentin Dupont <
> corentin.dupont at gmail.com> wrote:
>
>> *execBlocking :: MVar (Maybe MyData) -> IO ()
>> execBlocking mv = do
>>    let (a::String) = a
>>    --If you uncomment the next line, it will work
>>    --putStrLn $ show a
>>    putMVar mv (Just $ MyData a "toto")*
>>
>
> It's laziness, yes; you need to do something along the lines of
>
> > let a = length a `seq` a
>
> or possibly Control.Exception.evaluate needs to be involved somewhere.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121225/9ddccaaf/attachment.htm>


More information about the Haskell-Cafe mailing list