Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Patch for random to use Safe Haskell #1

Merged
merged 1 commit into from over 2 years ago

2 participants

David Terei Ryan Newton
David Terei

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.

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

~ David

Ryan Newton rrnewton merged commit f9a348f into from August 08, 2011
Ryan Newton rrnewton closed this August 08, 2011
Ryan Newton
Collaborator

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

David Terei

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

Showing 1 unique commit by 1 author.

Aug 04, 2011
Use Safe Haskell for GHC >= 7.2 3fb0e9e
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  System/Random.hs
4  System/Random.hs
... ...
@@ -1,3 +1,7 @@
  1
+#if __GLASGOW_HASKELL__ >= 701
  2
+{-# LANGUAGE Trustworthy #-}
  3
+#endif
  4
+
1 5
 -----------------------------------------------------------------------------
2 6
 -- |
3 7
 -- Module      :  System.Random
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.