Prevent optimization from tempering with unsafePerformIO

Bernd Brassel bbr at informatik.uni-kiel.de
Tue Oct 16 10:06:26 EDT 2007


Hi Neil, hi Don!

Nice meeting you at ICFP by the way.

> Can you give a specific example of what you have tried to do, and how it
> failed?

I have attached a short synopsis of what our Curry to Haskell
conceptually does. I could explain what all the parts mean and why they
are defined this way, if it is important. On first glance it looks
as if we were doing unsafe things in the very worst way. But the
invariants within the generated code clean up things again. E.g., the
result of main does not at all depend on whether or not the program is
evaluated eagerly or lazily.

I hope it is okay that I did not add any no-inline pragmata or something
like that. Unfortunately, I forgot all the things we have tried more
than a year ago to make optimization work.

But this is the way it should work:

$ ghc --make -O0 -o curry-no-opt curry.hs
[1 of 1] Compiling Main             ( curry.hs, curry.o )
Linking curry-no-opt ...
$ curry-no-opt
3 possibilities: [True,True,False]
2 possibilities: [True,False]

and this is what happens after optimization:

$ rm curry.hi curry.o
$ ghc --make -O2 -o curry-opt curry.hs
[1 of 1] Compiling Main             ( curry.hs, curry.o )
Linking curry-opt ...
$ curry-opt
3 possibilities: [True,False]
2 possibilities: [True,False]

As the code is now that is no surprise. But how can I prevent this from
happening by adding pragmata?

Thanks a lot for your time!

Bernd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: curry.hs
Type: text/x-haskell
Size: 1622 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20071016/a8ce9ff0/curry.bin


More information about the Glasgow-haskell-users mailing list