How to use unsafePerformIO properly (safely?)

I use the dreaded unsafePerformIO for a few functions in my graphviz library ( http://hackage.haskell.org/packages/archive/graphviz/2999.8.0.0/doc/html/src... ). However, a few months ago someone informed me that the documentation for unsafePerformIO had some steps that should be followed whenever it's used: http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/System-IO... . Looking through this documentation, I'm unsure on how to deal with the last two bullet points (adding NOINLINE pragmas is easy). The code doesn't combine IO actions, etc. and I don't deal with mutable variables, so do I have to worry about them? -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

In Feldspar's module for observable sharing [1] I use the following {-# OPTIONS_GHC -O0 #-} which I assumed would take care of the steps required for unsafePerformIO. Could someone please tell if this assumption is correct? (Of course, observable sharing is not safe regardless, but that's beside the point :) ) / Emil [1] http://hackage.haskell.org/packages/archive/feldspar-language/0.2/doc/html/s... Ivan Miljenovic skrev:
I use the dreaded unsafePerformIO for a few functions in my graphviz library ( http://hackage.haskell.org/packages/archive/graphviz/2999.8.0.0/doc/html/src... ). However, a few months ago someone informed me that the documentation for unsafePerformIO had some steps that should be followed whenever it's used: http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/System-IO... .
Looking through this documentation, I'm unsure on how to deal with the last two bullet points (adding NOINLINE pragmas is easy). The code doesn't combine IO actions, etc. and I don't deal with mutable variables, so do I have to worry about them?
participants (2)
-
Emil Axelsson
-
Ivan Miljenovic