[Haskell-cafe] Inferring Safety

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Wed Jul 4 13:10:05 CEST 2012


When it says up the top of Haddock docs that a module is
"Safe-Infered" (which should probably Safe-Infer*r*ed), what does that
actually mean?

My understanding of Safe Haskell is that there's no unsafe* functions,
etc. being used unless the module author swears (by using -XSafe) that
the module is indeed safe...

Yet as I pointed out on Google+ [1], the Data.GraphViz [2] module of
my graphviz package is labelled as being safe-infered, despite having
this function in there:

dotizeGraph           :: (Ord cl, Graph gr) => GraphvizParams Node nl el cl l
                         -> gr nl el -> gr (AttributeNode nl) (AttributeEdge el)
dotizeGraph params gr = unsafePerformIO
                        $ graphToGraph params' gr
  where
    params' = params { fmtCluster = const []
                     , fmtNode    = const []
                     , fmtEdge    = const []
                     }

This function uses `dot -Tcanon` to add in positional (as well as
possibly other) information to FGL graphs.  Now, as far as I know this
function _is_ safe (assuming that you have Graphviz installed), but I
certainly haven't proven it enough that for every possible input graph
the same positional attributes will be attached back (i.e. that the
graph will always be laid out the same), and thus I haven't used
-XSafe.

So what's going on here?

[1]: https://plus.google.com/101302416956767249890/posts/3NUWxd9P6xV
[2]: http://hackage.haskell.org/packages/archive/graphviz/2999.13.0.3/doc/html/Data-GraphViz.html

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com



More information about the Haskell-Cafe mailing list