Omari Norman | 8 Dec 14:34 2012

Safe Haskell safe-inferred status

Is there a way to determine whether a module has been marked safe by GHC for purposes of Safe Haskell?

The GHC 7.4 docs say that if I compile a module and I don't use the -XSafe or -XTrustworthy flag, GHC will automatically figure out whether the module would have compiled with -XSafe and, if so, marks the module as safe. Where does GHC record this determination? It doesn't seem to show up in ghc-pkg dump (there you can see trusted packages, but I am looking for safe-inferred status for modules.) ghc --show-iface seems to come up dry too.

I know Haddock shows this information but sometimes it says "Safe Haskell: None". I have no idea what this means so I was wondering what GHC itself says.

Thanks. --Omari

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Roman Cheplyaka | 8 Dec 15:45 2012

Re: Safe Haskell safe-inferred status

* Omari Norman <omari <at> smileystation.com> [2012-12-08 08:34:14-0500]
> Is there a way to determine whether a module has been marked safe by GHC
> for purposes of Safe Haskell?
> 
> The GHC 7.4 docs say that if I compile a module and I don't use the -XSafe
> or -XTrustworthy flag, GHC will automatically figure out whether the module
> would have compiled with -XSafe and, if so, marks the module as safe. Where
> does GHC record this determination? It doesn't seem to show up in ghc-pkg
> dump (there you can see trusted packages, but I am looking for
> safe-inferred status for modules.) ghc --show-iface seems to come up dry
> too.

% ghc --show-iface /opt/ghc761/lib/ghc-7.6.1/filepath-1.3.0.1/System/FilePath.hi | grep trusted:
trusted: safe

> I know Haddock shows this information but sometimes it says "Safe Haskell:
> None". I have no idea what this means so I was wondering what GHC itself
> says.

It's what GHC says — see the SafeHaskellMode type in
https://github.com/ghc/ghc/blob/master/compiler/main/DynFlags.hs

It seems that None means that the module was compile with Safe Haskell
disabled (-fno-safe-infer), but I'm not sure what the semantics of this
is. Perhaps it's equivalent to Unsafe?

Roman

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane