Skip to content

Conversation

@dterei
Copy link
Member

@dterei dterei commented Aug 9, 2011

Hi Johan and Milan,

I've worked on a new feature for GHC 7.2 called Safe Haskell. I'd like
to update containers to use it as I'm trying to get all packages included
with GHC updated.

Safe Haskell is a new language extension I've been working on with
David Mazieres and the Simons for GHC 7.2.

http://hackage.haskell.org/trac/ghc/wiki/SafeHaskell

Basically it provides a language pragmas 'Safe' that restricts the
module being compiled to only be able to use a subset of the Haskell
language so that you can trust the type system is sound. (i.e no
unsafePerformIO). As part of the restriction, the module can only
import other modules that are considered safe. A module is considered
Safe if it is compiled with the 'Safe' language pragma or if its
compiled with the 'Trustworthy' pragma. The trustworthy pragma doesn't
restrict the features the module can use at all so its appropriate for
modules that may use unsafe features internally but only export an API
that can be used in a safe manner. When I speak about safety I'm
mostly referring to being able to trust the type system and module
boundaries. Trustworthy compiled modules can therefore import any
other module, they don't require imports to be safe.

I've attached a patch that updates containers to use Safe Haskell and
would love it if you could apply.

Cheers,
David

foxik added a commit that referenced this pull request Aug 9, 2011
patch for containers to use Safe Haskell
@foxik foxik merged commit 770fbc3 into haskell:master Aug 9, 2011
@foxik
Copy link
Contributor

foxik commented Aug 9, 2011

Hi David,

Hi Johan and Milan,

I've worked on a new feature for GHC 7.2 called Safe Haskell. I'd like
to update containers to use it as I'm trying to get all packages included
with GHC updated.

Safe Haskell is a new language extension I've been working on with
David Mazieres and the Simons for GHC 7.2.

http://hackage.haskell.org/trac/ghc/wiki/SafeHaskell

Basically it provides a language pragmas 'Safe' that restricts the
module being compiled to only be able to use a subset of the Haskell
language so that you can trust the type system is sound. (i.e no
unsafePerformIO). As part of the restriction, the module can only
import other modules that are considered safe. A module is considered
Safe if it is compiled with the 'Safe' language pragma or if its
compiled with the 'Trustworthy' pragma. The trustworthy pragma doesn't
restrict the features the module can use at all so its appropriate for
modules that may use unsafe features internally but only export an API
that can be used in a safe manner. When I speak about safety I'm
mostly referring to being able to trust the type system and module
boundaries. Trustworthy compiled modules can therefore import any
other module, they don't require imports to be safe.

I've attached a patch that updates containers to use Safe Haskell and
would love it if you could apply.

Great work, the Safe feature sounds very interesting!

I have applied the patch.

Cheers,
Milan

@dterei
Copy link
Member Author

dterei commented Aug 9, 2011

Hi Milan,

Thanks! Sadly I made a mistake in the patch. GHC 6.12 and earlier stop parsing pragmas once they encounter a CPP directive. So I needed to change the layout from:

#if GLASGOW_HASKELL >= 701
{-# LANGUAGE Trustworthy #-}
#endif
{-# LANGUAGE ... #-}
{-# OPTIONS_GHC ... #-}

to this layout:

{-# LANGUAGE ... #-}
{-# OPTIONS_GHC ... #-}
#if GLASGOW_HASKELL >= 701
{-# LANGUAGE Trustworthy #-}
#endif

I'm sending a pull request now for a second patch that fixes this mistake in the first one.

~ David

@foxik
Copy link
Contributor

foxik commented Aug 9, 2011

Hi,

Hi Milan,

Thanks! Sadly I made a mistake in the patch. GHC 6.12 and earlier stop parsing pragmas once they encounter a CPP directive. So I needed to change the layout from:

#if GLASGOW_HASKELL >= 701
{-# LANGUAGE Trustworthy #-}
#endif
{-# LANGUAGE ... #-}
{-# OPTIONS_GHC ... #-}

to this layout:

{-# LANGUAGE ... #-}
{-# OPTIONS_GHC ... #-}
#if GLASGOW_HASKELL >= 701
{-# LANGUAGE Trustworthy #-}
#endif

I'm sending a pull request now for a second patch that fixes this mistake in the first one.

No problem, pulled.

Cheers,
Milan

alexfmpe pushed a commit to alexfmpe/containers that referenced this pull request Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants