Roman Cheplyaka | 23 Nov 15:47 2012

Portability of Safe Haskell packages

It has been pointed out before that in order for Safe Haskell to be
useful, libraries (especially core libraries) should be annotated
properly with Safe Haskell LANGUAGE pragmas.

However, that would make these libraries unusable with alternative
Haskell implementations, even if otherwise they these libraries are
Haskell2010.

To quote the standard:

  If a Haskell implementation does not recognize or support a particular
  language feature that a source file requests (or cannot support the
  combination of language features requested), any attempt to compile or
  otherwise use that file with that Haskell implementation must fail
  with an error. 

Should it be advised to surround safe annotations with CPP #ifs?
Or does anyone see a better way out of this contradiction?

Roman
Bas van Dijk | 23 Nov 20:27 2012
Picon

Re: Portability of Safe Haskell packages

On 23 November 2012 15:47, Roman Cheplyaka <roma <at> ro-che.info> wrote:
> Should it be advised to surround safe annotations with CPP #ifs?
> Or does anyone see a better way out of this contradiction?

I think that would be good advice. Note that even if you're only using
GHC then you still want to use CPP in order to support older GHC
versions which don't support Safe Haskell as in:

http://hackage.haskell.org/packages/archive/usb/1.1.0.4/doc/html/src/System-USB-Internal.html

Arguably, in that example it would be better to move the check for the
availability of Safe Haskell to the cabal file which would define a
CPP pragma SAFE_HASKELL which can be used in source files.

Bas

Gmane