darcs patch: Use Safe Haskell for GHC >= 7.2

Duncan Coutts duncan.coutts at googlemail.com
Tue Aug 9 00:35:42 CEST 2011


On Tue, 2011-08-02 at 11:09 -0700, David Terei wrote:
> Hi Duncan and Ian,
> 
> Attached is a patch that enables Safe Haskell for Cabal modules when
> its built with GHC >= 7.2. I'd love to get this patch included asap as
> I'm hoping to get all the libraries included with GHC using Safe
> Haskell for the 7.2 release. Is there any issue with pulling in the
> latest Cabal for 7.2? If there is the patch should backport fine,
> probably would apply cleanly in it current state.

Hi David,

Sorry, just got back from holiday. I understand from Ian that 7.2.1 is
being built as we speak, so it's too late for this for 7.2.1. I don't
know if there will be a 7.2.2 or if we just wait for 7.4.1 around
post-ICFP time.

I see that you're adding

+{-# LANGUAGE CPP #-}
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Trustworthy #-}
+#endif

In basically every module in Cabal. Is it necessary to use a language
pragma here or could we just use an extension in the .cabal file, which
would apply it to every module. We can do this conditionally on the ghc
version. I prefer not to have all modules using CPP if I can help it.

I'm also slightly confused as to why so many modules are marked as
'Trustworthy' rather than as simply 'Safe'. In particular, many simple
pure modules that have no FFI etc you're marking with 'Trustworthy'. As
I understand it from the docs on the ghc wiki, 'Trustworthy' is only
needed for modules that use unsafe features in a way that the module
author claims is externally safe. In fact, it's not obvious to me that
any modules in Cabal need to be marked as 'Trustworthy'. We don't use
any exotic extensions and all the FFI imports we use are in IO, not
pure. We don't use Typeable, unsafePerformIO, bytestring etc.

We use unsafeInterleaveIO in one place. Is unsafeInterleaveIO unsafe in
the SafeHaskell sense? (If so I'd be interested in why, but that'd be an
orthogonal argument.)

I also notice in a couple places that you're changing:

-import Text.PrettyPrint.HughesPJ
+import Text.PrettyPrint

Is this necessary?

Duncan




More information about the cabal-devel mailing list