Patch for random to use Safe Haskell #1

merged 1 commit into from Aug 9, 2011


None yet

2 participants

Haskell member

Hi Ryan ,

I'm David Terei, a GHC developer.

I've worked on a new feature for GHC 7.2 called Safe Haskell. I'd like
to update random 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.

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 random to use Safe Haskell and
would love it if you could apply.

~ David

@rrnewton rrnewton merged commit f9a348f into haskell:master Aug 9, 2011
Haskell member

Thanks David! That looks simple enough. Alas, future versions of random may use the FFI behind the scenes for performance and lose this property.

Haskell member

Great thanks!

If future versions use FFI that's still OK as long as the exported API is 'safe', in that you can't break the type system through it or segfault... ect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment