diff options
author | David Terei <davidterei@gmail.com> | 2011-05-16 14:57:46 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-06-18 01:06:34 -0700 |
commit | a61aedc730e68a1b0c166b81a65a8ea575e8094b (patch) | |
tree | 85e0237044e1ec4bc29e1bfb80076055035eb6f7 /libraries/base | |
parent | 191656199189e584e66dda194b7f772694388102 (diff) | |
download | haskell-a61aedc730e68a1b0c166b81a65a8ea575e8094b.tar.gz |
SafeHaskell: Added SafeHaskell to base
Diffstat (limited to 'libraries/base')
168 files changed, 1176 insertions, 482 deletions
diff --git a/libraries/base/Control/Applicative.hs b/libraries/base/Control/Applicative.hs index 6ef8bba386..248bbacd40 100644 --- a/libraries/base/Control/Applicative.hs +++ b/libraries/base/Control/Applicative.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- @@ -51,8 +52,8 @@ import Control.Arrow (Arrow(arr, (&&&)), ArrowZero(zeroArrow), ArrowPlus((<+>))) import Control.Monad (liftM, ap, MonadPlus(..)) import Control.Monad.Instances () #ifndef __NHC__ -import Control.Monad.ST (ST) -import qualified Control.Monad.ST.Lazy as Lazy (ST) +import Control.Monad.ST.Safe (ST) +import qualified Control.Monad.ST.Lazy.Safe as Lazy (ST) #endif import Data.Functor ((<$>), (<$)) import Data.Monoid (Monoid(..)) diff --git a/libraries/base/Control/Arrow.hs b/libraries/base/Control/Arrow.hs index 20e367799f..012a75a6fe 100644 --- a/libraries/base/Control/Arrow.hs +++ b/libraries/base/Control/Arrow.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Arrow diff --git a/libraries/base/Control/Category.hs b/libraries/base/Control/Category.hs index b63fc67c92..b06155fe6a 100644 --- a/libraries/base/Control/Category.hs +++ b/libraries/base/Control/Category.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index 62a30b4348..04e0a8fbf8 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , ForeignFunctionInterface , MagicHash diff --git a/libraries/base/Control/Concurrent/Chan.hs b/libraries/base/Control/Concurrent/Chan.hs index d6be913e66..23b21bbca1 100644 --- a/libraries/base/Control/Concurrent/Chan.hs +++ b/libraries/base/Control/Concurrent/Chan.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} diff --git a/libraries/base/Control/Concurrent/MVar.hs b/libraries/base/Control/Concurrent/MVar.hs index 2fda9f79c8..c40730601e 100644 --- a/libraries/base/Control/Concurrent/MVar.hs +++ b/libraries/base/Control/Concurrent/MVar.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Concurrent/QSem.hs b/libraries/base/Control/Concurrent/QSem.hs index 6b9a059e28..5ed887dfb5 100644 --- a/libraries/base/Control/Concurrent/QSem.hs +++ b/libraries/base/Control/Concurrent/QSem.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} diff --git a/libraries/base/Control/Concurrent/QSemN.hs b/libraries/base/Control/Concurrent/QSemN.hs index 43fe288380..7e2cb2c52a 100644 --- a/libraries/base/Control/Concurrent/QSemN.hs +++ b/libraries/base/Control/Concurrent/QSemN.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} diff --git a/libraries/base/Control/Concurrent/SampleVar.hs b/libraries/base/Control/Concurrent/SampleVar.hs index 615a0bf072..a6211933fd 100644 --- a/libraries/base/Control/Concurrent/SampleVar.hs +++ b/libraries/base/Control/Concurrent/SampleVar.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} diff --git a/libraries/base/Control/Exception.hs b/libraries/base/Control/Exception.hs index c650682ed1..a13b9907fa 100644 --- a/libraries/base/Control/Exception.hs +++ b/libraries/base/Control/Exception.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ExistentialQuantification #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs index a6179178de..8a0f7b04ec 100644 --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} @@ -400,7 +401,7 @@ catch :: Exception e -> (e -> IO a) -- ^ Handler to invoke if an exception is raised -> IO a #if __GLASGOW_HASKELL__ -catch = GHC.IO.catchException +catch = catchException #elif __HUGS__ catch m h = Hugs.Exception.catchException m h' where h' e = case fromException e of diff --git a/libraries/base/Control/Monad.hs b/libraries/base/Control/Monad.hs index 75b9d0b6dd..21f01538d3 100644 --- a/libraries/base/Control/Monad.hs +++ b/libraries/base/Control/Monad.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Monad/Fix.hs b/libraries/base/Control/Monad/Fix.hs index a1309faccd..b1fe43d619 100644 --- a/libraries/base/Control/Monad/Fix.hs +++ b/libraries/base/Control/Monad/Fix.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Monad/Group.hs b/libraries/base/Control/Monad/Group.hs index baab7daf96..3516562814 100644 --- a/libraries/base/Control/Monad/Group.hs +++ b/libraries/base/Control/Monad/Group.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.Group diff --git a/libraries/base/Control/Monad/Instances.hs b/libraries/base/Control/Monad/Instances.hs index d41be4f7c2..0cc1c53b06 100644 --- a/libraries/base/Control/Monad/Instances.hs +++ b/libraries/base/Control/Monad/Instances.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# OPTIONS_NHC98 --prelude #-} -- This module deliberately declares orphan instances: {-# OPTIONS_GHC -fno-warn-orphans #-} diff --git a/libraries/base/Control/Monad/ST.hs b/libraries/base/Control/Monad/ST.hs index 397b072533..0508b6e50f 100644 --- a/libraries/base/Control/Monad/ST.hs +++ b/libraries/base/Control/Monad/ST.hs @@ -1,11 +1,14 @@ -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP, SafeImports #-} +#if sh_SAFE_DEFAULT +{-# LANGUAGE Safe #-} +#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.ST -- Copyright : (c) The University of Glasgow 2001 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : experimental -- Portability : non-portable (requires universal quantification for runST) @@ -16,55 +19,35 @@ -- ----------------------------------------------------------------------------- -module Control.Monad.ST - ( - -- * The 'ST' Monad - ST, -- abstract, instance of Functor, Monad, Typeable. - runST, -- :: (forall s. ST s a) -> a - fixST, -- :: (a -> ST s a) -> ST s a - - -- * Converting 'ST' to 'IO' - RealWorld, -- abstract - stToIO, -- :: ST RealWorld a -> IO a - - -- * Unsafe operations - unsafeInterleaveST, -- :: ST s a -> ST s a - unsafeIOToST, -- :: IO a -> ST s a - unsafeSTToIO -- :: ST s a -> IO a - ) where - -#if defined(__GLASGOW_HASKELL__) -import Control.Monad.Fix () -#else -import Control.Monad.Fix +module Control.Monad.ST ( + module Control.Monad.ST.Safe +#if !sh_SAFE_DEFAULT + -- * Unsafe Functions + , unsafeInterleaveST + , unsafeIOToST + , unsafeSTToIO #endif + ) where -#include "Typeable.h" +import safe Control.Monad.ST.Safe -#if defined(__GLASGOW_HASKELL__) -import GHC.ST ( ST, runST, fixST, unsafeInterleaveST ) -import GHC.Base ( RealWorld ) -import GHC.IO ( stToIO, unsafeIOToST, unsafeSTToIO ) -#elif defined(__HUGS__) -import Data.Typeable -import Hugs.ST -import qualified Hugs.LazyST as LazyST -#endif - -#if defined(__HUGS__) -INSTANCE_TYPEABLE2(ST,sTTc,"ST") -INSTANCE_TYPEABLE0(RealWorld,realWorldTc,"RealWorld") +#if !sh_SAFE_DEFAULT +import qualified Control.Monad.ST.Unsafe as U -fixST :: (a -> ST s a) -> ST s a -fixST f = LazyST.lazyToStrictST (LazyST.fixST (LazyST.strictToLazyST . f)) +{-# DEPRECATED unsafeInterleaveST, unsafeIOToST, unsafeSTToIO + "Please import from Control.Monad.ST.Unsafe instead; This will be removed in the next release" + #-} +{-# INLINE unsafeInterleaveST #-} unsafeInterleaveST :: ST s a -> ST s a -unsafeInterleaveST = - LazyST.lazyToStrictST . LazyST.unsafeInterleaveST . LazyST.strictToLazyST -#endif +unsafeInterleaveST = U.unsafeInterleaveST + +{-# INLINE unsafeIOToST #-} +unsafeIOToST :: IO a -> ST s a +unsafeIOToST = U.unsafeIOToST -#if !defined(__GLASGOW_HASKELL__) -instance MonadFix (ST s) where - mfix = fixST +{-# INLINE unsafeSTToIO #-} +unsafeSTToIO :: ST s a -> IO a +unsafeSTToIO = U.unsafeSTToIO #endif diff --git a/libraries/base/Control/Monad/ST/Imp.hs b/libraries/base/Control/Monad/ST/Imp.hs new file mode 100644 index 0000000000..ca768b48ea --- /dev/null +++ b/libraries/base/Control/Monad/ST/Imp.hs @@ -0,0 +1,72 @@ +{-# LANGUAGE CPP #-} +{-# OPTIONS_HADDOCK hide #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Control.Monad.ST.Imp +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : non-portable (requires universal quantification for runST) +-- +-- This library provides support for /strict/ state threads, as +-- described in the PLDI \'94 paper by John Launchbury and Simon Peyton +-- Jones /Lazy Functional State Threads/. +-- +----------------------------------------------------------------------------- + +-- #hide +module Control.Monad.ST.Imp ( + -- * The 'ST' Monad + ST, -- abstract, instance of Functor, Monad, Typeable. + runST, -- :: (forall s. ST s a) -> a + fixST, -- :: (a -> ST s a) -> ST s a + + -- * Converting 'ST' to 'IO' + RealWorld, -- abstract + stToIO, -- :: ST RealWorld a -> IO a + + -- * Unsafe operations + unsafeInterleaveST, -- :: ST s a -> ST s a + unsafeIOToST, -- :: IO a -> ST s a + unsafeSTToIO -- :: ST s a -> IO a + ) where + +#if defined(__GLASGOW_HASKELL__) +import Control.Monad.Fix () +#else +import Control.Monad.Fix +#endif + +#include "Typeable.h" + +#if defined(__GLASGOW_HASKELL__) +import GHC.ST ( ST, runST, fixST, unsafeInterleaveST ) +import GHC.Base ( RealWorld ) +import GHC.IO ( stToIO, unsafeIOToST, unsafeSTToIO ) +#elif defined(__HUGS__) +import Data.Typeable +import Hugs.ST +import qualified Hugs.LazyST as LazyST +#endif + +#if defined(__HUGS__) +INSTANCE_TYPEABLE2(ST,sTTc,"ST") +INSTANCE_TYPEABLE0(RealWorld,realWorldTc,"RealWorld") + +fixST :: (a -> ST s a) -> ST s a +fixST f = LazyST.lazyToStrictST (LazyST.fixST (LazyST.strictToLazyST . f)) + +unsafeInterleaveST :: ST s a -> ST s a +unsafeInterleaveST = + LazyST.lazyToStrictST . LazyST.unsafeInterleaveST . LazyST.strictToLazyST +#endif + +#if !defined(__GLASGOW_HASKELL__) +instance MonadFix (ST s) where + mfix = fixST +#endif + + diff --git a/libraries/base/Control/Monad/ST/Lazy.hs b/libraries/base/Control/Monad/ST/Lazy.hs index 8aac6651a7..d1ec5b9e18 100644 --- a/libraries/base/Control/Monad/ST/Lazy.hs +++ b/libraries/base/Control/Monad/ST/Lazy.hs @@ -1,4 +1,7 @@ -{-# LANGUAGE CPP, MagicHash, UnboxedTuples, Rank2Types #-} +{-# LANGUAGE CPP, SafeImports #-} +#if sh_SAFE_DEFAULT +{-# LANGUAGE Safe #-} +#endif ----------------------------------------------------------------------------- -- | @@ -17,136 +20,28 @@ ----------------------------------------------------------------------------- module Control.Monad.ST.Lazy ( - -- * The 'ST' monad - ST, - runST, - fixST, - - -- * Converting between strict and lazy 'ST' - strictToLazyST, lazyToStrictST, - - -- * Converting 'ST' To 'IO' - RealWorld, - stToIO, - - -- * Unsafe operations - unsafeInterleaveST, - unsafeIOToST - ) where - -import Prelude - -import Control.Monad.Fix - -import qualified Control.Monad.ST as ST - -#ifdef __GLASGOW_HASKELL__ -import qualified GHC.ST -import GHC.Base -#endif - -#ifdef __HUGS__ -import Hugs.LazyST + module Control.Monad.ST.Lazy.Safe +#if !sh_SAFE_DEFAULT + -- * Unsafe Functions + , unsafeInterleaveST + , unsafeIOToST #endif + ) where -#ifdef __GLASGOW_HASKELL__ --- | The lazy state-transformer monad. --- A computation of type @'ST' s a@ transforms an internal state indexed --- by @s@, and returns a value of type @a@. --- The @s@ parameter is either --- --- * an unstantiated type variable (inside invocations of 'runST'), or --- --- * 'RealWorld' (inside invocations of 'stToIO'). --- --- It serves to keep the internal states of different invocations of --- 'runST' separate from each other and from invocations of 'stToIO'. --- --- The '>>=' and '>>' operations are not strict in the state. For example, --- --- @'runST' (writeSTRef _|_ v >>= readSTRef _|_ >> return 2) = 2@ -newtype ST s a = ST (State s -> (a, State s)) -data State s = S# (State# s) - -instance Functor (ST s) where - fmap f m = ST $ \ s -> - let - ST m_a = m - (r,new_s) = m_a s - in - (f r,new_s) - -instance Monad (ST s) where - - return a = ST $ \ s -> (a,s) - m >> k = m >>= \ _ -> k - fail s = error s - - (ST m) >>= k - = ST $ \ s -> - let - (r,new_s) = m s - ST k_a = k r - in - k_a new_s - -{-# NOINLINE runST #-} --- | Return the value computed by a state transformer computation. --- The @forall@ ensures that the internal state used by the 'ST' --- computation is inaccessible to the rest of the program. -runST :: (forall s. ST s a) -> a -runST st = case st of ST the_st -> let (r,_) = the_st (S# realWorld#) in r - --- | Allow the result of a state transformer computation to be used (lazily) --- inside the computation. --- Note that if @f@ is strict, @'fixST' f = _|_@. -fixST :: (a -> ST s a) -> ST s a -fixST m = ST (\ s -> - let - ST m_r = m r - (r,s') = m_r s - in - (r,s')) -#endif - -instance MonadFix (ST s) where - mfix = fixST - --- --------------------------------------------------------------------------- --- Strict <--> Lazy - -#ifdef __GLASGOW_HASKELL__ -{-| -Convert a strict 'ST' computation into a lazy one. The strict state -thread passed to 'strictToLazyST' is not performed until the result of -the lazy state thread it returns is demanded. --} -strictToLazyST :: ST.ST s a -> ST s a -strictToLazyST m = ST $ \s -> - let - pr = case s of { S# s# -> GHC.ST.liftST m s# } - r = case pr of { GHC.ST.STret _ v -> v } - s' = case pr of { GHC.ST.STret s2# _ -> S# s2# } - in - (r, s') +import safe Control.Monad.ST.Lazy.Safe +#if !sh_SAFE_DEFAULT +import qualified Control.Monad.ST.Lazy.Unsafe as U -{-| -Convert a lazy 'ST' computation into a strict one. --} -lazyToStrictST :: ST s a -> ST.ST s a -lazyToStrictST (ST m) = GHC.ST.ST $ \s -> - case (m (S# s)) of (a, S# s') -> (# s', a #) +{-# DEPRECATED unsafeInterleaveST, unsafeIOToST + "Please import from Control.Monad.ST.Lazy.Unsafe instead; This will be removed in the next release" + #-} +{-# INLINE unsafeInterleaveST #-} unsafeInterleaveST :: ST s a -> ST s a -unsafeInterleaveST = strictToLazyST . ST.unsafeInterleaveST . lazyToStrictST -#endif +unsafeInterleaveST = U.unsafeInterleaveST +{-# INLINE unsafeIOToST #-} unsafeIOToST :: IO a -> ST s a -unsafeIOToST = strictToLazyST . ST.unsafeIOToST +unsafeIOToST = U.unsafeIOToST +#endif --- | A monad transformer embedding lazy state transformers in the 'IO' --- monad. The 'RealWorld' parameter indicates that the internal state --- used by the 'ST' computation is a special one supplied by the 'IO' --- monad, and thus distinct from those used by invocations of 'runST'. -stToIO :: ST RealWorld a -> IO a -stToIO = ST.stToIO . lazyToStrictST diff --git a/libraries/base/Control/Monad/ST/Lazy/Imp.hs b/libraries/base/Control/Monad/ST/Lazy/Imp.hs new file mode 100644 index 0000000000..82c4974b24 --- /dev/null +++ b/libraries/base/Control/Monad/ST/Lazy/Imp.hs @@ -0,0 +1,162 @@ +{-# LANGUAGE CPP, MagicHash, UnboxedTuples, Rank2Types #-} +{-# OPTIONS_HADDOCK hide #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Control.Monad.ST.Lazy.Imp +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : provisional +-- Portability : non-portable (requires universal quantification for runST) +-- +-- This module presents an identical interface to "Control.Monad.ST", +-- except that the monad delays evaluation of state operations until +-- a value depending on them is required. +-- +----------------------------------------------------------------------------- + +-- #hide +module Control.Monad.ST.Lazy.Imp ( + -- * The 'ST' monad + ST, + runST, + fixST, + + -- * Converting between strict and lazy 'ST' + strictToLazyST, lazyToStrictST, + + -- * Converting 'ST' To 'IO' + RealWorld, + stToIO, + + -- * Unsafe operations + unsafeInterleaveST, + unsafeIOToST + ) where + +import Prelude + +import Control.Monad.Fix + +import qualified Control.Monad.ST.Safe as ST +import qualified Control.Monad.ST.Unsafe as ST + +#ifdef __GLASGOW_HASKELL__ +import qualified GHC.ST as GHC.ST +import GHC.Base +#endif + +#ifdef __HUGS__ +import Hugs.LazyST +#endif + +#ifdef __GLASGOW_HASKELL__ +-- | The lazy state-transformer monad. +-- A computation of type @'ST' s a@ transforms an internal state indexed +-- by @s@, and returns a value of type @a@. +-- The @s@ parameter is either +-- +-- * an unstantiated type variable (inside invocations of 'runST'), or +-- +-- * 'RealWorld' (inside invocations of 'stToIO'). +-- +-- It serves to keep the internal states of different invocations of +-- 'runST' separate from each other and from invocations of 'stToIO'. +-- +-- The '>>=' and '>>' operations are not strict in the state. For example, +-- +-- @'runST' (writeSTRef _|_ v >>= readSTRef _|_ >> return 2) = 2@ +newtype ST s a = ST (State s -> (a, State s)) +data State s = S# (State# s) + +instance Functor (ST s) where + fmap f m = ST $ \ s -> + let + ST m_a = m + (r,new_s) = m_a s + in + (f r,new_s) + +instance Monad (ST s) where + + return a = ST $ \ s -> (a,s) + m >> k = m >>= \ _ -> k + fail s = error s + + (ST m) >>= k + = ST $ \ s -> + let + (r,new_s) = m s + ST k_a = k r + in + k_a new_s + +{-# NOINLINE runST #-} +-- | Return the value computed by a state transformer computation. +-- The @forall@ ensures that the internal state used by the 'ST' +-- computation is inaccessible to the rest of the program. +runST :: (forall s. ST s a) -> a +runST st = case st of ST the_st -> let (r,_) = the_st (S# realWorld#) in r + +-- | Allow the result of a state transformer computation to be used (lazily) +-- inside the computation. +-- Note that if @f@ is strict, @'fixST' f = _|_@. +fixST :: (a -> ST s a) -> ST s a +fixST m = ST (\ s -> + let + ST m_r = m r + (r,s') = m_r s + in + (r,s')) +#endif + +instance MonadFix (ST s) where + mfix = fixST + +-- --------------------------------------------------------------------------- +-- Strict <--> Lazy + +#ifdef __GLASGOW_HASKELL__ +{-| +Convert a strict 'ST' computation into a lazy one. The strict state +thread passed to 'strictToLazyST' is not performed until the result of +the lazy state thread it returns is demanded. +-} +strictToLazyST :: ST.ST s a -> ST s a +strictToLazyST m = ST $ \s -> + let + pr = case s of { S# s# -> GHC.ST.liftST m s# } + r = case pr of { GHC.ST.STret _ v -> v } + s' = case pr of { GHC.ST.STret s2# _ -> S# s2# } + in + (r, s') + +{-| +Convert a lazy 'ST' computation into a strict one. +-} +lazyToStrictST :: ST s a -> ST.ST s a +lazyToStrictST (ST m) = GHC.ST.ST $ \s -> + case (m (S# s)) of (a, S# s') -> (# s', a #) +#endif + +-- | A monad transformer embedding lazy state transformers in the 'IO' +-- monad. The 'RealWorld' parameter indicates that the internal state +-- used by the 'ST' computation is a special one supplied by the 'IO' +-- monad, and thus distinct from those used by invocations of 'runST'. +stToIO :: ST RealWorld a -> IO a +stToIO = ST.stToIO . lazyToStrictST + +-- --------------------------------------------------------------------------- +-- Strict <--> Lazy + +#ifdef __GLASGOW_HASKELL__ +unsafeInterleaveST :: ST s a -> ST s a +unsafeInterleaveST = strictToLazyST . ST.unsafeInterleaveST . lazyToStrictST +#endif + +unsafeIOToST :: IO a -> ST s a +unsafeIOToST = strictToLazyST . ST.unsafeIOToST + + diff --git a/libraries/base/Control/Monad/ST/Lazy/Safe.hs b/libraries/base/Control/Monad/ST/Lazy/Safe.hs new file mode 100644 index 0000000000..387313f287 --- /dev/null +++ b/libraries/base/Control/Monad/ST/Lazy/Safe.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE Trustworthy #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Control.Monad.ST.Lazy.Safe +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : provisional +-- Portability : non-portable (requires universal quantification for runST) +-- +-- This module presents an identical interface to "Control.Monad.ST", +-- except that the monad delays evaluation of state operations until +-- a value depending on them is required. +-- +-- Safe API only. +-- +----------------------------------------------------------------------------- + +module Control.Monad.ST.Lazy.Safe ( + -- * The 'ST' monad + ST, + runST, + fixST, + + -- * Converting between strict and lazy 'ST' + strictToLazyST, lazyToStrictST, + + -- * Converting 'ST' To 'IO' + RealWorld, + stToIO, + ) where + +import Control.Monad.ST.Lazy.Imp + diff --git a/libraries/base/Control/Monad/ST/Lazy/Unsafe.hs b/libraries/base/Control/Monad/ST/Lazy/Unsafe.hs new file mode 100644 index 0000000000..1ccdbbf5bf --- /dev/null +++ b/libraries/base/Control/Monad/ST/Lazy/Unsafe.hs @@ -0,0 +1,26 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Control.Monad.ST.Lazy.Unsafe +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : provisional +-- Portability : non-portable (requires universal quantification for runST) +-- +-- This module presents an identical interface to "Control.Monad.ST", +-- except that the monad delays evaluation of state operations until +-- a value depending on them is required. +-- +-- Unsafe API. +-- +----------------------------------------------------------------------------- + +module Control.Monad.ST.Lazy.Unsafe ( + -- * Unsafe operations + unsafeInterleaveST, + unsafeIOToST + ) where + +import Control.Monad.ST.Lazy.Imp + diff --git a/libraries/base/Control/Monad/ST/Safe.hs b/libraries/base/Control/Monad/ST/Safe.hs new file mode 100644 index 0000000000..e6c8e8cfdc --- /dev/null +++ b/libraries/base/Control/Monad/ST/Safe.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE Trustworthy #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Control.Monad.ST.Safe +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : non-portable (requires universal quantification for runST) +-- +-- This library provides support for /strict/ state threads, as +-- described in the PLDI \'94 paper by John Launchbury and Simon Peyton +-- Jones /Lazy Functional State Threads/. +-- +-- Safe API Only. +-- +----------------------------------------------------------------------------- + +module Control.Monad.ST.Safe ( + -- * The 'ST' Monad + ST, -- abstract, instance of Functor, Monad, Typeable. + runST, -- :: (forall s. ST s a) -> a + fixST, -- :: (a -> ST s a) -> ST s a + + -- * Converting 'ST' to 'IO' + RealWorld, -- abstract + stToIO, -- :: ST RealWorld a -> IO a + ) where + +import Control.Monad.ST.Imp + diff --git a/libraries/base/Control/Monad/ST/Strict.hs b/libraries/base/Control/Monad/ST/Strict.hs index d8692f851f..1b63034483 100644 --- a/libraries/base/Control/Monad/ST/Strict.hs +++ b/libraries/base/Control/Monad/ST/Strict.hs @@ -1,9 +1,13 @@ +{-# LANGUAGE CPP #-} +#if sh_SAFE_DEFAULT +{-# LANGUAGE Safe #-} +#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.ST.Strict -- Copyright : (c) The University of Glasgow 2001 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires universal quantification for runST) @@ -16,4 +20,9 @@ module Control.Monad.ST.Strict ( module Control.Monad.ST ) where +#if sh_SAFE_DEFAULT +import safe Control.Monad.ST +#else import Control.Monad.ST +#endif + diff --git a/libraries/base/Control/Monad/ST/Unsafe.hs b/libraries/base/Control/Monad/ST/Unsafe.hs new file mode 100644 index 0000000000..1a224d0375 --- /dev/null +++ b/libraries/base/Control/Monad/ST/Unsafe.hs @@ -0,0 +1,27 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Control.Monad.ST.Unsafe +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : non-portable (requires universal quantification for runST) +-- +-- This library provides support for /strict/ state threads, as +-- described in the PLDI \'94 paper by John Launchbury and Simon Peyton +-- Jones /Lazy Functional State Threads/. +-- +-- Unsafe API. +-- +----------------------------------------------------------------------------- + +module Control.Monad.ST.Unsafe ( + -- * Unsafe operations + unsafeInterleaveST, + unsafeIOToST, + unsafeSTToIO + ) where + +import Control.Monad.ST.Imp + diff --git a/libraries/base/Control/Monad/Zip.hs b/libraries/base/Control/Monad/Zip.hs index d6475b8c1f..8c431bdbfb 100644 --- a/libraries/base/Control/Monad/Zip.hs +++ b/libraries/base/Control/Monad/Zip.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.Zip diff --git a/libraries/base/Control/OldException.hs b/libraries/base/Control/OldException.hs index 6442d6789d..0b4d751080 100644 --- a/libraries/base/Control/OldException.hs +++ b/libraries/base/Control/OldException.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , ForeignFunctionInterface diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs index cbf7b37015..35006f4457 100644 --- a/libraries/base/Data/Bits.hs +++ b/libraries/base/Data/Bits.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Bool.hs b/libraries/base/Data/Bool.hs index ba2d8aea27..8d80ec849d 100644 --- a/libraries/base/Data/Bool.hs +++ b/libraries/base/Data/Bool.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Char.hs b/libraries/base/Data/Char.hs index 40052a7607..f45f3696ca 100644 --- a/libraries/base/Data/Char.hs +++ b/libraries/base/Data/Char.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs index 3692501492..b456055ee9 100644 --- a/libraries/base/Data/Complex.hs +++ b/libraries/base/Data/Complex.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, DeriveDataTypeable #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE StandaloneDeriving #-} diff --git a/libraries/base/Data/Either.hs b/libraries/base/Data/Either.hs index 6ffc607303..cdfa76106a 100644 --- a/libraries/base/Data/Either.hs +++ b/libraries/base/Data/Either.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, DeriveGeneric, StandaloneDeriving #-} diff --git a/libraries/base/Data/Eq.hs b/libraries/base/Data/Eq.hs index e7b99f118f..9386d60fec 100644 --- a/libraries/base/Data/Eq.hs +++ b/libraries/base/Data/Eq.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Fixed.hs b/libraries/base/Data/Fixed.hs index cd4409295b..b1d7113c14 100644 --- a/libraries/base/Data/Fixed.hs +++ b/libraries/base/Data/Fixed.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} {-# OPTIONS -Wall -fno-warn-unused-binds #-} diff --git a/libraries/base/Data/Foldable.hs b/libraries/base/Data/Foldable.hs index 354bd8b270..a925fca9d6 100644 --- a/libraries/base/Data/Foldable.hs +++ b/libraries/base/Data/Foldable.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Function.hs b/libraries/base/Data/Function.hs index 64ebfd09aa..ef6d9cf589 100644 --- a/libraries/base/Data/Function.hs +++ b/libraries/base/Data/Function.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Function diff --git a/libraries/base/Data/Functor.hs b/libraries/base/Data/Functor.hs index 84d0aa7256..2369cdb497 100644 --- a/libraries/base/Data/Functor.hs +++ b/libraries/base/Data/Functor.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/HashTable.hs b/libraries/base/Data/HashTable.hs index e96160a59c..9fe78991d7 100644 --- a/libraries/base/Data/HashTable.hs +++ b/libraries/base/Data/HashTable.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} {-# OPTIONS_GHC -funbox-strict-fields -fno-warn-name-shadowing #-} diff --git a/libraries/base/Data/IORef.hs b/libraries/base/Data/IORef.hs index 934f1de794..13eb9c9a48 100644 --- a/libraries/base/Data/IORef.hs +++ b/libraries/base/Data/IORef.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-} ----------------------------------------------------------------------------- @@ -40,7 +41,6 @@ import Hugs.IORef #ifdef __GLASGOW_HASKELL__ import GHC.Base import GHC.STRef --- import GHC.IO import GHC.IORef hiding (atomicModifyIORef) import qualified GHC.IORef #if !defined(__PARALLEL_HASKELL__) diff --git a/libraries/base/Data/Int.hs b/libraries/base/Data/Int.hs index c9c9036d53..1ff37bd51c 100644 --- a/libraries/base/Data/Int.hs +++ b/libraries/base/Data/Int.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Ix.hs b/libraries/base/Data/Ix.hs index a01e516265..f1edf00907 100644 --- a/libraries/base/Data/Ix.hs +++ b/libraries/base/Data/Ix.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/List.hs b/libraries/base/Data/List.hs index bb71da5f06..4f76c83c22 100644 --- a/libraries/base/Data/List.hs +++ b/libraries/base/Data/List.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Maybe.hs b/libraries/base/Data/Maybe.hs index 2f98c70e6e..a405bb4625 100644 --- a/libraries/base/Data/Maybe.hs +++ b/libraries/base/Data/Maybe.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, DeriveGeneric #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Monoid.hs b/libraries/base/Data/Monoid.hs index aaefd42169..beac4f70f7 100644 --- a/libraries/base/Data/Monoid.hs +++ b/libraries/base/Data/Monoid.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Ord.hs b/libraries/base/Data/Ord.hs index fd291ae960..250e797d2c 100644 --- a/libraries/base/Data/Ord.hs +++ b/libraries/base/Data/Ord.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Ratio.hs b/libraries/base/Data/Ratio.hs index f0440993a3..766fe41e82 100644 --- a/libraries/base/Data/Ratio.hs +++ b/libraries/base/Data/Ratio.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/STRef.hs b/libraries/base/Data/STRef.hs index 5002ee7fde..851a20f9fc 100644 --- a/libraries/base/Data/STRef.hs +++ b/libraries/base/Data/STRef.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/STRef/Lazy.hs b/libraries/base/Data/STRef/Lazy.hs index 288343ee4c..ccc19051de 100644 --- a/libraries/base/Data/STRef/Lazy.hs +++ b/libraries/base/Data/STRef/Lazy.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : Data.STRef.Lazy @@ -20,7 +21,7 @@ module Data.STRef.Lazy ( modifySTRef -- :: STRef s a -> (a -> a) -> ST s () ) where -import Control.Monad.ST.Lazy +import Control.Monad.ST.Lazy.Safe import qualified Data.STRef as ST import Prelude diff --git a/libraries/base/Data/STRef/Strict.hs b/libraries/base/Data/STRef/Strict.hs index 9eb54a528e..202df73450 100644 --- a/libraries/base/Data/STRef/Strict.hs +++ b/libraries/base/Data/STRef/Strict.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : Data.STRef.Strict diff --git a/libraries/base/Data/String.hs b/libraries/base/Data/String.hs index ac1e416c90..27d61d5991 100644 --- a/libraries/base/Data/String.hs +++ b/libraries/base/Data/String.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, FlexibleInstances #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Traversable.hs b/libraries/base/Data/Traversable.hs index 062d1a0b1c..96ea010d8b 100644 --- a/libraries/base/Data/Traversable.hs +++ b/libraries/base/Data/Traversable.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Tuple.hs b/libraries/base/Data/Tuple.hs index a5ea87570f..5b5d32f1dd 100644 --- a/libraries/base/Data/Tuple.hs +++ b/libraries/base/Data/Tuple.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh. diff --git a/libraries/base/Data/Typeable.hs b/libraries/base/Data/Typeable.hs index ce602e4999..8180790cc6 100644 --- a/libraries/base/Data/Typeable.hs +++ b/libraries/base/Data/Typeable.hs @@ -106,7 +106,7 @@ import GHC.Err (undefined) import GHC.Num (Integer, (+)) import GHC.Real ( rem, Ratio ) import GHC.IORef (IORef,newIORef) -import GHC.IO (unsafePerformIO,mask_) +import GHC.IO (mask_, unsafePerformIO) -- These imports are so we can define Typeable instances -- It'd be better to give Typeable instances in the modules themselves diff --git a/libraries/base/Data/Unique.hs b/libraries/base/Data/Unique.hs index c4c8827433..50bc40fce4 100644 --- a/libraries/base/Data/Unique.hs +++ b/libraries/base/Data/Unique.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ diff --git a/libraries/base/Data/Version.hs b/libraries/base/Data/Version.hs index 7d7d329635..b0dd92e9ae 100644 --- a/libraries/base/Data/Version.hs +++ b/libraries/base/Data/Version.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, DeriveDataTypeable #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Word.hs b/libraries/base/Data/Word.hs index 18300d2512..1540999df4 100644 --- a/libraries/base/Data/Word.hs +++ b/libraries/base/Data/Word.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Foreign.hs b/libraries/base/Foreign.hs index a26ffaf2bd..e6280b6a84 100644 --- a/libraries/base/Foreign.hs +++ b/libraries/base/Foreign.hs @@ -1,3 +1,6 @@ +#if sh_SAFE_DEFAULT +{-# LANGUAGE Trustworthy #-} +#endif {-# LANGUAGE NoImplicitPrelude #-} ----------------------------------------------------------------------------- @@ -25,11 +28,15 @@ module Foreign , module Foreign.Storable , module Foreign.Marshal +#if !sh_SAFE_DEFAULT + -- * Unsafe Functions + -- | 'unsafePerformIO' is exported here for backwards -- compatibility reasons only. For doing local marshalling in -- the FFI, use 'unsafeLocalState'. For other uses, see -- 'System.IO.Unsafe.unsafePerformIO'. , unsafePerformIO +#endif ) where import Data.Bits @@ -41,4 +48,14 @@ import Foreign.StablePtr import Foreign.Storable import Foreign.Marshal -import System.IO.Unsafe (unsafePerformIO) +#if !sh_SAFE_DEFAULT +import GHC.IO (IO) +import qualified System.IO.Unsafe (unsafePerformIO) + +{-# DEPRECATED unsafePerformIO "Use System.IO.Unsafe.unsafePerformIO instead; This function will be removed in the next release" #-} + +{-# INLINE unsafePerformIO #-} +unsafePerformIO :: IO a -> a +unsafePerformIO = System.IO.Unsafe.unsafePerformIO +#endif + diff --git a/libraries/base/Foreign/C.hs b/libraries/base/Foreign/C.hs index 2c7fd2e24f..2e925ccc04 100644 --- a/libraries/base/Foreign/C.hs +++ b/libraries/base/Foreign/C.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Foreign/C/Error.hs b/libraries/base/Foreign/C/Error.hs index 89c736d065..6d3ef80842 100644 --- a/libraries/base/Foreign/C/Error.hs +++ b/libraries/base/Foreign/C/Error.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-} {-# OPTIONS_GHC -#include "HsBase.h" #-} diff --git a/libraries/base/Foreign/C/String.hs b/libraries/base/Foreign/C/String.hs index fdefdc67c8..f3699160e3 100644 --- a/libraries/base/Foreign/C/String.hs +++ b/libraries/base/Foreign/C/String.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Foreign/C/Types.hs b/libraries/base/Foreign/C/Types.hs index 14b53df508..c571049041 100644 --- a/libraries/base/Foreign/C/Types.hs +++ b/libraries/base/Foreign/C/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , MagicHash diff --git a/libraries/base/Foreign/Concurrent.hs b/libraries/base/Foreign/Concurrent.hs index e0f2faaa95..6a21b792dd 100644 --- a/libraries/base/Foreign/Concurrent.hs +++ b/libraries/base/Foreign/Concurrent.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- @@ -29,13 +30,11 @@ module Foreign.Concurrent ) where #ifdef __GLASGOW_HASKELL__ -import GHC.IO ( IO ) -import GHC.Ptr ( Ptr ) -import GHC.ForeignPtr ( ForeignPtr ) +import GHC.IO ( IO ) +import GHC.Ptr ( Ptr ) +import GHC.ForeignPtr ( ForeignPtr ) import qualified GHC.ForeignPtr -#endif -#ifdef __GLASGOW_HASKELL__ newForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a) -- ^Turns a plain memory reference into a foreign object by associating -- a finalizer - given by the monadic operation - with the reference. @@ -52,3 +51,4 @@ addForeignPtrFinalizer :: ForeignPtr a -> IO () -> IO () -- same object. addForeignPtrFinalizer = GHC.ForeignPtr.addForeignPtrConcFinalizer #endif + diff --git a/libraries/base/Foreign/ForeignPtr.hs b/libraries/base/Foreign/ForeignPtr.hs index b91ffebf52..0199fe7094 100644 --- a/libraries/base/Foreign/ForeignPtr.hs +++ b/libraries/base/Foreign/ForeignPtr.hs @@ -1,4 +1,8 @@ -{-# LANGUAGE CPP, NoImplicitPrelude #-} +{-# LANGUAGE SafeImports, CPP, NoImplicitPrelude #-} +#if sh_SAFE_DEFAULT +{-# LANGUAGE Trustworthy #-} +#endif +{-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- -- | @@ -16,165 +20,23 @@ -- ----------------------------------------------------------------------------- -module Foreign.ForeignPtr - ( - -- * Finalised data pointers - ForeignPtr - , FinalizerPtr -#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) - , FinalizerEnvPtr -#endif - -- ** Basic operations - , newForeignPtr - , newForeignPtr_ - , addForeignPtrFinalizer -#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) - , newForeignPtrEnv - , addForeignPtrFinalizerEnv -#endif - , withForeignPtr - -#ifdef __GLASGOW_HASKELL__ - , finalizeForeignPtr -#endif - - -- ** Low-level operations +module Foreign.ForeignPtr ( + module Foreign.ForeignPtr.Safe +#if !sh_SAFE_DEFAULT + -- ** Unsafe low-level operations , unsafeForeignPtrToPtr - , touchForeignPtr - , castForeignPtr - - -- ** Allocating managed memory - , mallocForeignPtr - , mallocForeignPtrBytes - , mallocForeignPtrArray - , mallocForeignPtrArray0 - ) - where - -import Foreign.Ptr - -#ifdef __NHC__ -import NHC.FFI - ( ForeignPtr - , FinalizerPtr - , newForeignPtr - , newForeignPtr_ - , addForeignPtrFinalizer - , withForeignPtr - , unsafeForeignPtrToPtr - , touchForeignPtr - , castForeignPtr - , Storable(sizeOf) - , malloc, mallocBytes, finalizerFree - ) -#endif - -#ifdef __HUGS__ -import Hugs.ForeignPtr -#endif - -#ifndef __NHC__ -import Foreign.Storable ( Storable(sizeOf) ) -#endif - -#ifdef __GLASGOW_HASKELL__ -import GHC.Base --- import GHC.IO -import GHC.Num -import GHC.Err ( undefined ) -import GHC.ForeignPtr #endif + ) where -#if !defined(__NHC__) && !defined(__GLASGOW_HASKELL__) -import Foreign.Marshal.Alloc ( malloc, mallocBytes, finalizerFree ) +import safe Foreign.ForeignPtr.Safe -instance Eq (ForeignPtr a) where - p == q = unsafeForeignPtrToPtr p == unsafeForeignPtrToPtr q +#if !sh_SAFE_DEFAULT +import Foreign.Ptr ( Ptr ) +import qualified Foreign.ForeignPtr.Unsafe as U -instance Ord (ForeignPtr a) where - compare p q = compare (unsafeForeignPtrToPtr p) (unsafeForeignPtrToPtr q) - -instance Show (ForeignPtr a) where - showsPrec p f = showsPrec p (unsafeForeignPtrToPtr f) +{-# DEPRECATED unsafeForeignPtrToPtr "Use Foreign.ForeignPtr.Unsafe.unsafeForeignPtrToPtr instead; This function will be removed in the next release" #-} +{-# INLINE unsafeForeignPtrToPtr #-} +unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a +unsafeForeignPtrToPtr = U.unsafeForeignPtrToPtr #endif - -#ifndef __NHC__ -newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a) --- ^Turns a plain memory reference into a foreign pointer, and --- associates a finalizer with the reference. The finalizer will be --- executed after the last reference to the foreign object is dropped. --- There is no guarantee of promptness, however the finalizer will be --- executed before the program exits. -newForeignPtr finalizer p - = do fObj <- newForeignPtr_ p - addForeignPtrFinalizer finalizer fObj - return fObj - -withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b --- ^This is a way to look at the pointer living inside a --- foreign object. This function takes a function which is --- applied to that pointer. The resulting 'IO' action is then --- executed. The foreign object is kept alive at least during --- the whole action, even if it is not used directly --- inside. Note that it is not safe to return the pointer from --- the action and use it after the action completes. All uses --- of the pointer should be inside the --- 'withForeignPtr' bracket. The reason for --- this unsafeness is the same as for --- 'unsafeForeignPtrToPtr' below: the finalizer --- may run earlier than expected, because the compiler can only --- track usage of the 'ForeignPtr' object, not --- a 'Ptr' object made from it. --- --- This function is normally used for marshalling data to --- or from the object pointed to by the --- 'ForeignPtr', using the operations from the --- 'Storable' class. -withForeignPtr fo io - = do r <- io (unsafeForeignPtrToPtr fo) - touchForeignPtr fo - return r -#endif /* ! __NHC__ */ - -#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) --- | This variant of 'newForeignPtr' adds a finalizer that expects an --- environment in addition to the finalized pointer. The environment --- that will be passed to the finalizer is fixed by the second argument to --- 'newForeignPtrEnv'. -newForeignPtrEnv :: - FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a) -newForeignPtrEnv finalizer env p - = do fObj <- newForeignPtr_ p - addForeignPtrFinalizerEnv finalizer env fObj - return fObj -#endif /* __HUGS__ */ - -#ifndef __GLASGOW_HASKELL__ -mallocForeignPtr :: Storable a => IO (ForeignPtr a) -mallocForeignPtr = do - r <- malloc - newForeignPtr finalizerFree r - -mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) -mallocForeignPtrBytes n = do - r <- mallocBytes n - newForeignPtr finalizerFree r -#endif /* !__GLASGOW_HASKELL__ */ - --- | This function is similar to 'Foreign.Marshal.Array.mallocArray', --- but yields a memory area that has a finalizer attached that releases --- the memory area. As with 'mallocForeignPtr', it is not guaranteed that --- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'. -mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) -mallocForeignPtrArray = doMalloc undefined - where - doMalloc :: Storable b => b -> Int -> IO (ForeignPtr b) - doMalloc dummy size = mallocForeignPtrBytes (size * sizeOf dummy) - --- | This function is similar to 'Foreign.Marshal.Array.mallocArray0', --- but yields a memory area that has a finalizer attached that releases --- the memory area. As with 'mallocForeignPtr', it is not guaranteed that --- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'. -mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a) -mallocForeignPtrArray0 size = mallocForeignPtrArray (size + 1) diff --git a/libraries/base/Foreign/ForeignPtr/Imp.hs b/libraries/base/Foreign/ForeignPtr/Imp.hs new file mode 100644 index 0000000000..6ce615f25f --- /dev/null +++ b/libraries/base/Foreign/ForeignPtr/Imp.hs @@ -0,0 +1,180 @@ +{-# LANGUAGE CPP, NoImplicitPrelude #-} +{-# OPTIONS_HADDOCK hide #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Foreign.ForeignPtr.Imp +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : ffi@haskell.org +-- Stability : provisional +-- Portability : portable +-- +-- The 'ForeignPtr' type and operations. This module is part of the +-- Foreign Function Interface (FFI) and will usually be imported via +-- the "Foreign" module. +-- +----------------------------------------------------------------------------- + +module Foreign.ForeignPtr.Imp + ( + -- * Finalised data pointers + ForeignPtr + , FinalizerPtr +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) + , FinalizerEnvPtr +#endif + -- ** Basic operations + , newForeignPtr + , newForeignPtr_ + , addForeignPtrFinalizer +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) + , newForeignPtrEnv + , addForeignPtrFinalizerEnv +#endif + , withForeignPtr + +#ifdef __GLASGOW_HASKELL__ + , finalizeForeignPtr +#endif + + -- ** Low-level operations + , unsafeForeignPtrToPtr + , touchForeignPtr + , castForeignPtr + + -- ** Allocating managed memory + , mallocForeignPtr + , mallocForeignPtrBytes + , mallocForeignPtrArray + , mallocForeignPtrArray0 + ) + where + +import Foreign.Ptr + +#ifdef __NHC__ +import NHC.FFI + ( ForeignPtr + , FinalizerPtr + , newForeignPtr + , newForeignPtr_ + , addForeignPtrFinalizer + , withForeignPtr + , unsafeForeignPtrToPtr + , touchForeignPtr + , castForeignPtr + , Storable(sizeOf) + , malloc, mallocBytes, finalizerFree + ) +#endif + +#ifdef __HUGS__ +import Hugs.ForeignPtr +#endif + +#ifndef __NHC__ +import Foreign.Storable ( Storable(sizeOf) ) +#endif + +#ifdef __GLASGOW_HASKELL__ +import GHC.Base +import GHC.Num +import GHC.Err ( undefined ) +import GHC.ForeignPtr +#endif + +#if !defined(__NHC__) && !defined(__GLASGOW_HASKELL__) +import Foreign.Marshal.Alloc ( malloc, mallocBytes, finalizerFree ) + +instance Eq (ForeignPtr a) where + p == q = unsafeForeignPtrToPtr p == unsafeForeignPtrToPtr q + +instance Ord (ForeignPtr a) where + compare p q = compare (unsafeForeignPtrToPtr p) (unsafeForeignPtrToPtr q) + +instance Show (ForeignPtr a) where + showsPrec p f = showsPrec p (unsafeForeignPtrToPtr f) +#endif + + +#ifndef __NHC__ +newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a) +-- ^Turns a plain memory reference into a foreign pointer, and +-- associates a finalizer with the reference. The finalizer will be +-- executed after the last reference to the foreign object is dropped. +-- There is no guarantee of promptness, however the finalizer will be +-- executed before the program exits. +newForeignPtr finalizer p + = do fObj <- newForeignPtr_ p + addForeignPtrFinalizer finalizer fObj + return fObj + +withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b +-- ^This is a way to look at the pointer living inside a +-- foreign object. This function takes a function which is +-- applied to that pointer. The resulting 'IO' action is then +-- executed. The foreign object is kept alive at least during +-- the whole action, even if it is not used directly +-- inside. Note that it is not safe to return the pointer from +-- the action and use it after the action completes. All uses +-- of the pointer should be inside the +-- 'withForeignPtr' bracket. The reason for +-- this unsafeness is the same as for +-- 'unsafeForeignPtrToPtr' below: the finalizer +-- may run earlier than expected, because the compiler can only +-- track usage of the 'ForeignPtr' object, not +-- a 'Ptr' object made from it. +-- +-- This function is normally used for marshalling data to +-- or from the object pointed to by the +-- 'ForeignPtr', using the operations from the +-- 'Storable' class. +withForeignPtr fo io + = do r <- io (unsafeForeignPtrToPtr fo) + touchForeignPtr fo + return r +#endif /* ! __NHC__ */ + +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) +-- | This variant of 'newForeignPtr' adds a finalizer that expects an +-- environment in addition to the finalized pointer. The environment +-- that will be passed to the finalizer is fixed by the second argument to +-- 'newForeignPtrEnv'. +newForeignPtrEnv :: + FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a) +newForeignPtrEnv finalizer env p + = do fObj <- newForeignPtr_ p + addForeignPtrFinalizerEnv finalizer env fObj + return fObj +#endif /* __HUGS__ */ + +#ifndef __GLASGOW_HASKELL__ +mallocForeignPtr :: Storable a => IO (ForeignPtr a) +mallocForeignPtr = do + r <- malloc + newForeignPtr finalizerFree r + +mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) +mallocForeignPtrBytes n = do + r <- mallocBytes n + newForeignPtr finalizerFree r +#endif /* !__GLASGOW_HASKELL__ */ + +-- | This function is similar to 'Foreign.Marshal.Array.mallocArray', +-- but yields a memory area that has a finalizer attached that releases +-- the memory area. As with 'mallocForeignPtr', it is not guaranteed that +-- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'. +mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) +mallocForeignPtrArray = doMalloc undefined + where + doMalloc :: Storable b => b -> Int -> IO (ForeignPtr b) + doMalloc dummy size = mallocForeignPtrBytes (size * sizeOf dummy) + +-- | This function is similar to 'Foreign.Marshal.Array.mallocArray0', +-- but yields a memory area that has a finalizer attached that releases +-- the memory area. As with 'mallocForeignPtr', it is not guaranteed that +-- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'. +mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a) +mallocForeignPtrArray0 size = mallocForeignPtrArray (size + 1) diff --git a/libraries/base/Foreign/ForeignPtr/Safe.hs b/libraries/base/Foreign/ForeignPtr/Safe.hs new file mode 100644 index 0000000000..4f1907242a --- /dev/null +++ b/libraries/base/Foreign/ForeignPtr/Safe.hs @@ -0,0 +1,55 @@ +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE CPP, NoImplicitPrelude #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Foreign.ForeignPtr.Safe +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : ffi@haskell.org +-- Stability : provisional +-- Portability : portable +-- +-- The 'ForeignPtr' type and operations. This module is part of the +-- Foreign Function Interface (FFI) and will usually be imported via +-- the "Foreign" module. +-- +-- Safe API Only. +-- +----------------------------------------------------------------------------- + +module Foreign.ForeignPtr.Safe ( + -- * Finalised data pointers + ForeignPtr + , FinalizerPtr +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) + , FinalizerEnvPtr +#endif + -- ** Basic operations + , newForeignPtr + , newForeignPtr_ + , addForeignPtrFinalizer +#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__) + , newForeignPtrEnv + , addForeignPtrFinalizerEnv +#endif + , withForeignPtr + +#ifdef __GLASGOW_HASKELL__ + , finalizeForeignPtr +#endif + + -- ** Low-level operations + , touchForeignPtr + , castForeignPtr + + -- ** Allocating managed memory + , mallocForeignPtr + , mallocForeignPtrBytes + , mallocForeignPtrArray + , mallocForeignPtrArray0 + ) where + +import Foreign.ForeignPtr.Imp + diff --git a/libraries/base/Foreign/ForeignPtr/Unsafe.hs b/libraries/base/Foreign/ForeignPtr/Unsafe.hs new file mode 100644 index 0000000000..8980ab90ba --- /dev/null +++ b/libraries/base/Foreign/ForeignPtr/Unsafe.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE CPP, NoImplicitPrelude #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Foreign.ForeignPtr.Unsafe +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : ffi@haskell.org +-- Stability : provisional +-- Portability : portable +-- +-- The 'ForeignPtr' type and operations. This module is part of the +-- Foreign Function Interface (FFI) and will usually be imported via +-- the "Foreign" module. +-- +-- Unsafe API Only. +-- +----------------------------------------------------------------------------- + +module Foreign.ForeignPtr.Unsafe ( + -- ** Unsafe low-level operations + unsafeForeignPtrToPtr, + ) where + +import Foreign.ForeignPtr.Imp + diff --git a/libraries/base/Foreign/Marshal.hs b/libraries/base/Foreign/Marshal.hs index 77a4ebf3cc..438dc2ffbe 100644 --- a/libraries/base/Foreign/Marshal.hs +++ b/libraries/base/Foreign/Marshal.hs @@ -57,5 +57,9 @@ results in undefined behaviour. It is expected that this operation will be replaced in a future revision of Haskell. -} +{-# DEPRECATED unsafeLocalState + "Please import from Foreign.Marshall.Unsafe instead; This will be removed in the next release" + #-} unsafeLocalState :: IO a -> a unsafeLocalState = unsafePerformIO + diff --git a/libraries/base/Foreign/Marshal/Alloc.hs b/libraries/base/Foreign/Marshal/Alloc.hs index 612d2c7ceb..74db1646c5 100644 --- a/libraries/base/Foreign/Marshal/Alloc.hs +++ b/libraries/base/Foreign/Marshal/Alloc.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , MagicHash diff --git a/libraries/base/Foreign/Marshal/Array.hs b/libraries/base/Foreign/Marshal/Array.hs index 1ca3e9e236..e284ec47bb 100644 --- a/libraries/base/Foreign/Marshal/Array.hs +++ b/libraries/base/Foreign/Marshal/Array.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Foreign/Marshal/Error.hs b/libraries/base/Foreign/Marshal/Error.hs index ccf514d70d..9e3ad3b5ba 100644 --- a/libraries/base/Foreign/Marshal/Error.hs +++ b/libraries/base/Foreign/Marshal/Error.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- @@ -38,7 +39,6 @@ import System.IO.Error #endif import GHC.Base import GHC.Num --- import GHC.IO import GHC.IO.Exception #endif diff --git a/libraries/base/Foreign/Marshal/Pool.hs b/libraries/base/Foreign/Marshal/Pool.hs index ed94e464fb..8ca160d990 100644 --- a/libraries/base/Foreign/Marshal/Pool.hs +++ b/libraries/base/Foreign/Marshal/Pool.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} -------------------------------------------------------------------------------- diff --git a/libraries/base/Foreign/Marshal/Safe.hs b/libraries/base/Foreign/Marshal/Safe.hs new file mode 100644 index 0000000000..73132176da --- /dev/null +++ b/libraries/base/Foreign/Marshal/Safe.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE Safe #-} +{-# LANGUAGE CPP, NoImplicitPrelude #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Foreign.Marshal.Safe +-- Copyright : (c) The FFI task force 2003 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : ffi@haskell.org +-- Stability : provisional +-- Portability : portable +-- +-- Marshalling support +-- +-- Safe API Only. +-- +----------------------------------------------------------------------------- + +module Foreign.Marshal.Safe + ( + -- | The module "Foreign.Marshal.Safe" re-exports the other modules in the + -- @Foreign.Marshal@ hierarchy: + module Foreign.Marshal.Alloc + , module Foreign.Marshal.Array + , module Foreign.Marshal.Error + , module Foreign.Marshal.Pool + , module Foreign.Marshal.Utils + ) where + +import Foreign.Marshal.Alloc +import Foreign.Marshal.Array +import Foreign.Marshal.Error +import Foreign.Marshal.Pool +import Foreign.Marshal.Utils + diff --git a/libraries/base/Foreign/Marshal/Unsafe.hs b/libraries/base/Foreign/Marshal/Unsafe.hs new file mode 100644 index 0000000000..1fa0e3aa59 --- /dev/null +++ b/libraries/base/Foreign/Marshal/Unsafe.hs @@ -0,0 +1,49 @@ +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE CPP, NoImplicitPrelude #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Foreign.Marshal.Unsafe +-- Copyright : (c) The FFI task force 2003 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : ffi@haskell.org +-- Stability : provisional +-- Portability : portable +-- +-- Marshalling support. Unsafe API. +-- +----------------------------------------------------------------------------- + +module Foreign.Marshal.Unsafe ( + -- * Unsafe functions + unsafeLocalState + ) where + +#ifdef __GLASGOW_HASKELL__ +import GHC.IO +#else +import System.IO.Unsafe +#endif + +{- | +Sometimes an external entity is a pure function, except that it passes +arguments and/or results via pointers. The function +@unsafeLocalState@ permits the packaging of such entities as pure +functions. + +The only IO operations allowed in the IO action passed to +@unsafeLocalState@ are (a) local allocation (@alloca@, @allocaBytes@ +and derived operations such as @withArray@ and @withCString@), and (b) +pointer operations (@Foreign.Storable@ and @Foreign.Ptr@) on the +pointers to local storage, and (c) foreign functions whose only +observable effect is to read and/or write the locally allocated +memory. Passing an IO operation that does not obey these rules +results in undefined behaviour. + +It is expected that this operation will be +replaced in a future revision of Haskell. +-} +unsafeLocalState :: IO a -> a +unsafeLocalState = unsafePerformIO + diff --git a/libraries/base/Foreign/Marshal/Utils.hs b/libraries/base/Foreign/Marshal/Utils.hs index bf9bdb3c8b..d3ab1fd057 100644 --- a/libraries/base/Foreign/Marshal/Utils.hs +++ b/libraries/base/Foreign/Marshal/Utils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Foreign/Ptr.hs b/libraries/base/Foreign/Ptr.hs index 26dda5c237..d6588f5dee 100644 --- a/libraries/base/Foreign/Ptr.hs +++ b/libraries/base/Foreign/Ptr.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , ForeignFunctionInterface @@ -67,7 +68,6 @@ import GHC.Show import GHC.Enum import GHC.Word ( Word(..) ) --- import Data.Int import Data.Word #else import Control.Monad ( liftM ) diff --git a/libraries/base/Foreign/Safe.hs b/libraries/base/Foreign/Safe.hs new file mode 100644 index 0000000000..9809aff1cb --- /dev/null +++ b/libraries/base/Foreign/Safe.hs @@ -0,0 +1,40 @@ +{-# LANGUAGE Safe #-} +{-# LANGUAGE NoImplicitPrelude #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Foreign.Safe +-- Copyright : (c) The FFI task force 2001 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : ffi@haskell.org +-- Stability : provisional +-- Portability : portable +-- +-- A collection of data types, classes, and functions for interfacing +-- with another programming language. +-- +-- Safe API Only. +-- +----------------------------------------------------------------------------- + +module Foreign.Safe + ( module Data.Bits + , module Data.Int + , module Data.Word + , module Foreign.Ptr + , module Foreign.ForeignPtr.Safe + , module Foreign.StablePtr + , module Foreign.Storable + , module Foreign.Marshal.Safe + ) where + +import Data.Bits +import Data.Int +import Data.Word +import Foreign.Ptr +import Foreign.ForeignPtr.Safe +import Foreign.StablePtr +import Foreign.Storable +import Foreign.Marshal.Safe + diff --git a/libraries/base/Foreign/StablePtr.hs b/libraries/base/Foreign/StablePtr.hs index 522c6fc344..68b205694f 100644 --- a/libraries/base/Foreign/StablePtr.hs +++ b/libraries/base/Foreign/StablePtr.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Foreign/Storable.hs b/libraries/base/Foreign/Storable.hs index 700a4ff5ee..482b5d9549 100644 --- a/libraries/base/Foreign/Storable.hs +++ b/libraries/base/Foreign/Storable.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ScopedTypeVariables #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/Arr.lhs b/libraries/base/GHC/Arr.lhs index ade0b984d9..9ef20906ca 100644 --- a/libraries/base/GHC/Arr.lhs +++ b/libraries/base/GHC/Arr.lhs @@ -18,7 +18,28 @@ ----------------------------------------------------------------------------- -- #hide -module GHC.Arr where +module GHC.Arr ( + Ix(..), Array(..), STArray(..), + + indexError, hopelessIndexError, + arrEleBottom, array, listArray, + (!), safeRangeSize, negRange, safeIndex, badSafeIndex, + bounds, numElements, numElementsSTArray, indices, elems, + assocs, accumArray, adjust, (//), accum, + amap, ixmap, + eqArray, cmpArray, cmpIntArray, + newSTArray, boundsSTArray, + readSTArray, writeSTArray, + freezeSTArray, thawSTArray, + + -- * Unsafe operations + fill, done, + unsafeArray, unsafeArray', + lessSafeIndex, unsafeAt, unsafeReplace, + unsafeAccumArray, unsafeAccumArray', unsafeAccum, + unsafeReadSTArray, unsafeWriteSTArray, + unsafeFreezeSTArray, unsafeThawSTArray, + ) where import GHC.Enum import GHC.Num @@ -351,8 +372,6 @@ instance (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1,a2,a3,a4,a5) where %********************************************************* \begin{code} -type IPr = (Int, Int) - -- | The type of immutable non-strict (boxed) arrays -- with indices in @i@ and elements in @e@. data Array i e diff --git a/libraries/base/GHC/Base.lhs b/libraries/base/GHC/Base.lhs index 5075478ea1..f4181eb160 100644 --- a/libraries/base/GHC/Base.lhs +++ b/libraries/base/GHC/Base.lhs @@ -98,7 +98,7 @@ module GHC.Base module GHC.Base, module GHC.Classes, module GHC.CString, - --module GHC.Generics, -- JPM: We no longer export GHC.Generics + -- module GHC.Generics, -- JPM: We no longer export GHC.Generics -- by default to avoid name clashes module GHC.Ordering, module GHC.Types, @@ -111,7 +111,7 @@ import GHC.Types import GHC.Classes import GHC.CString -- JPM: Since we don't export it, we don't need to import GHC.Generics ---import GHC.Generics +-- import GHC.Generics import GHC.Ordering import GHC.Prim import {-# SOURCE #-} GHC.Show @@ -613,7 +613,7 @@ instance Monad IO where m >> k = m >>= \ _ -> k return = returnIO (>>=) = bindIO - fail s = GHC.IO.failIO s + fail s = failIO s returnIO :: a -> IO a returnIO x = IO $ \ s -> (# s, x #) @@ -833,3 +833,4 @@ a `iShiftRL#` b | b >=# WORD_SIZE_IN_BITS# = 0# data RealWorld \end{code} #endif + diff --git a/libraries/base/GHC/Classes.hs b/libraries/base/GHC/Classes.hs index 54b36bc112..071905ce4f 100644 --- a/libraries/base/GHC/Classes.hs +++ b/libraries/base/GHC/Classes.hs @@ -1,4 +1,4 @@ - +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, MagicHash, StandaloneDeriving #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh. diff --git a/libraries/base/GHC/Conc/Signal.hs b/libraries/base/GHC/Conc/Signal.hs index 851c4bb72c..3ceb4b33d5 100644 --- a/libraries/base/GHC/Conc/Signal.hs +++ b/libraries/base/GHC/Conc/Signal.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, ForeignFunctionInterface #-} module GHC.Conc.Signal @@ -19,8 +20,8 @@ import GHC.Arr (inRange) import GHC.Base import GHC.Conc.Sync (forkIO) import GHC.IO (mask_, unsafePerformIO) -import GHC.IOArray (IOArray, boundsIOArray, newIOArray, unsafeReadIOArray, - unsafeWriteIOArray) +import GHC.IOArray (IOArray, boundsIOArray, newIOArray, + unsafeReadIOArray, unsafeWriteIOArray) import GHC.Real (fromIntegral) import GHC.Word (Word8) diff --git a/libraries/base/GHC/ConsoleHandler.hs b/libraries/base/GHC/ConsoleHandler.hs index 562ef32a67..a72b2b23e4 100644 --- a/libraries/base/GHC/ConsoleHandler.hs +++ b/libraries/base/GHC/ConsoleHandler.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, ForeignFunctionInterface #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/Constants.hs b/libraries/base/GHC/Constants.hs index 871829d832..99abba55cc 100644 --- a/libraries/base/GHC/Constants.hs +++ b/libraries/base/GHC/Constants.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} module GHC.Constants where diff --git a/libraries/base/GHC/Desugar.hs b/libraries/base/GHC/Desugar.hs index 65dd645dab..3d1d740f2e 100644 --- a/libraries/base/GHC/Desugar.hs +++ b/libraries/base/GHC/Desugar.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , Rank2Types diff --git a/libraries/base/GHC/Enum.lhs b/libraries/base/GHC/Enum.lhs index ac6e9a916a..abcc624d2b 100644 --- a/libraries/base/GHC/Enum.lhs +++ b/libraries/base/GHC/Enum.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, BangPatterns, MagicHash #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/Environment.hs b/libraries/base/GHC/Environment.hs index aeffeb41c8..57c0a9089d 100644 --- a/libraries/base/GHC/Environment.hs +++ b/libraries/base/GHC/Environment.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, ForeignFunctionInterface #-} module GHC.Environment (getFullArgs) where diff --git a/libraries/base/GHC/Err.lhs b/libraries/base/GHC/Err.lhs index 90142f400f..348f17c7d3 100644 --- a/libraries/base/GHC/Err.lhs +++ b/libraries/base/GHC/Err.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/Err.lhs-boot b/libraries/base/GHC/Err.lhs-boot index 932f699de9..cc39bc8e0a 100644 --- a/libraries/base/GHC/Err.lhs-boot +++ b/libraries/base/GHC/Err.lhs-boot @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} --------------------------------------------------------------------------- diff --git a/libraries/base/GHC/Event.hs b/libraries/base/GHC/Event.hs index 79208958db..850e036a12 100644 --- a/libraries/base/GHC/Event.hs +++ b/libraries/base/GHC/Event.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} -- | This module provides scalable event notification for file -- descriptors and timeouts. -- diff --git a/libraries/base/GHC/Exception.lhs b/libraries/base/GHC/Exception.lhs index c5b967970d..ec4f893b43 100644 --- a/libraries/base/GHC/Exception.lhs +++ b/libraries/base/GHC/Exception.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude , ExistentialQuantification , MagicHash diff --git a/libraries/base/GHC/Exts.hs b/libraries/base/GHC/Exts.hs index 81a9dbb4ed..67b4a97b2d 100644 --- a/libraries/base/GHC/Exts.hs +++ b/libraries/base/GHC/Exts.hs @@ -60,7 +60,6 @@ import GHC.Base import GHC.Magic import GHC.Word import GHC.Int --- import GHC.Float import GHC.Ptr import Data.String import Data.List diff --git a/libraries/base/GHC/Float.lhs b/libraries/base/GHC/Float.lhs index 1c6fd5f8d7..fa31751b25 100644 --- a/libraries/base/GHC/Float.lhs +++ b/libraries/base/GHC/Float.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , MagicHash diff --git a/libraries/base/GHC/Float/ConversionUtils.hs b/libraries/base/GHC/Float/ConversionUtils.hs index 83dbe74d46..1d849f1ff6 100644 --- a/libraries/base/GHC/Float/ConversionUtils.hs +++ b/libraries/base/GHC/Float/ConversionUtils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, MagicHash, UnboxedTuples, NoImplicitPrelude #-} {-# OPTIONS_GHC -O2 #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/Float/RealFracMethods.hs b/libraries/base/GHC/Float/RealFracMethods.hs index 8ef5a20f91..79679575c3 100644 --- a/libraries/base/GHC/Float/RealFracMethods.hs +++ b/libraries/base/GHC/Float/RealFracMethods.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, MagicHash, UnboxedTuples, ForeignFunctionInterface, NoImplicitPrelude #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/Foreign.hs b/libraries/base/GHC/Foreign.hs index 109fa836e8..12d78887ea 100644 --- a/libraries/base/GHC/Foreign.hs +++ b/libraries/base/GHC/Foreign.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/Handle.hs b/libraries/base/GHC/Handle.hs index e99c40ac93..8cc81f8043 100644 --- a/libraries/base/GHC/Handle.hs +++ b/libraries/base/GHC/Handle.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- -- | @@ -53,3 +54,4 @@ import GHC.IO.IOMode import GHC.IO.Handle import GHC.IO.Handle.Internals import GHC.IO.Handle.FD + diff --git a/libraries/base/GHC/IO.hs b/libraries/base/GHC/IO.hs index ad98a5ebf5..99dc093dcd 100644 --- a/libraries/base/GHC/IO.hs +++ b/libraries/base/GHC/IO.hs @@ -22,22 +22,22 @@ -- #hide module GHC.IO ( - IO(..), unIO, failIO, liftIO, - unsafePerformIO, unsafeInterleaveIO, - unsafeDupablePerformIO, unsafeDupableInterleaveIO, - noDuplicate, + IO(..), unIO, failIO, liftIO, + unsafePerformIO, unsafeInterleaveIO, + unsafeDupablePerformIO, unsafeDupableInterleaveIO, + noDuplicate, -- To and from from ST - stToIO, ioToST, unsafeIOToST, unsafeSTToIO, + stToIO, ioToST, unsafeIOToST, unsafeSTToIO, - FilePath, + FilePath, - catchException, catchAny, throwIO, - mask, mask_, uninterruptibleMask, uninterruptibleMask_, - MaskingState(..), getMaskingState, - block, unblock, blocked, unsafeUnmask, - onException, bracket, finally, evaluate - ) where + catchException, catchAny, throwIO, + mask, mask_, uninterruptibleMask, uninterruptibleMask_, + MaskingState(..), getMaskingState, + block, unblock, blocked, unsafeUnmask, + onException, bracket, finally, evaluate + ) where import GHC.Base import GHC.ST diff --git a/libraries/base/GHC/IO/Buffer.hs b/libraries/base/GHC/IO/Buffer.hs index c019d69bea..456b1e1919 100644 --- a/libraries/base/GHC/IO/Buffer.hs +++ b/libraries/base/GHC/IO/Buffer.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-} {-# OPTIONS_GHC -funbox-strict-fields #-} diff --git a/libraries/base/GHC/IO/BufferedIO.hs b/libraries/base/GHC/IO/BufferedIO.hs index 874a02d1dc..7690fc7341 100644 --- a/libraries/base/GHC/IO/BufferedIO.hs +++ b/libraries/base/GHC/IO/BufferedIO.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -funbox-strict-fields #-} @@ -16,16 +17,15 @@ ----------------------------------------------------------------------------- module GHC.IO.BufferedIO ( - BufferedIO(..), - readBuf, readBufNonBlocking, writeBuf, writeBufNonBlocking - ) where + BufferedIO(..), + readBuf, readBufNonBlocking, writeBuf, writeBufNonBlocking + ) where import GHC.Base import GHC.Ptr import Data.Word import GHC.Num import Data.Maybe --- import GHC.IO import GHC.IO.Device as IODevice import GHC.IO.Device as RawIO import GHC.IO.Buffer diff --git a/libraries/base/GHC/IO/Device.hs b/libraries/base/GHC/IO/Device.hs index bc772b8178..903c0412aa 100644 --- a/libraries/base/GHC/IO/Device.hs +++ b/libraries/base/GHC/IO/Device.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns #-} ----------------------------------------------------------------------------- @@ -15,11 +16,11 @@ ----------------------------------------------------------------------------- module GHC.IO.Device ( - RawIO(..), - IODevice(..), - IODeviceType(..), - SeekMode(..) - ) where + RawIO(..), + IODevice(..), + IODeviceType(..), + SeekMode(..) + ) where #ifdef __GLASGOW_HASKELL__ import GHC.Base diff --git a/libraries/base/GHC/IO/Encoding.hs b/libraries/base/GHC/IO/Encoding.hs index 92ca843d80..6a977750be 100644 --- a/libraries/base/GHC/IO/Encoding.hs +++ b/libraries/base/GHC/IO/Encoding.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, PatternGuards #-} {-# OPTIONS_GHC -funbox-strict-fields #-} @@ -16,18 +17,17 @@ ----------------------------------------------------------------------------- module GHC.IO.Encoding ( - BufferCodec(..), TextEncoding(..), TextEncoder, TextDecoder, CodingProgress(..), - latin1, latin1_encode, latin1_decode, - utf8, utf8_bom, - utf16, utf16le, utf16be, - utf32, utf32le, utf32be, - localeEncoding, fileSystemEncoding, foreignEncoding, - char8, - mkTextEncoding, - ) where + BufferCodec(..), TextEncoding(..), TextEncoder, TextDecoder, CodingProgress(..), + latin1, latin1_encode, latin1_decode, + utf8, utf8_bom, + utf16, utf16le, utf16be, + utf32, utf32le, utf32be, + localeEncoding, fileSystemEncoding, foreignEncoding, + char8, + mkTextEncoding, + ) where import GHC.Base ---import GHC.IO import GHC.IO.Exception import GHC.IO.Buffer import GHC.IO.Encoding.Failure diff --git a/libraries/base/GHC/IO/Encoding.hs-boot b/libraries/base/GHC/IO/Encoding.hs-boot index 9223cc3495..48c7825747 100644 --- a/libraries/base/GHC/IO/Encoding.hs-boot +++ b/libraries/base/GHC/IO/Encoding.hs-boot @@ -1,6 +1,7 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module GHC.IO.Encoding where import GHC.IO.Encoding.Types -localeEncoding, fileSystemEncoding, foreignEncoding :: TextEncoding
\ No newline at end of file +localeEncoding, fileSystemEncoding, foreignEncoding :: TextEncoding diff --git a/libraries/base/GHC/IO/Encoding/CodePage.hs b/libraries/base/GHC/IO/Encoding/CodePage.hs index a6b4e95b4b..724b8ae408 100644 --- a/libraries/base/GHC/IO/Encoding/CodePage.hs +++ b/libraries/base/GHC/IO/Encoding/CodePage.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, BangPatterns, ForeignFunctionInterface, NoImplicitPrelude, NondecreasingIndentation, MagicHash #-} module GHC.IO.Encoding.CodePage( diff --git a/libraries/base/GHC/IO/Encoding/Failure.hs b/libraries/base/GHC/IO/Encoding/Failure.hs index a27650b00a..08e084d4ff 100644 --- a/libraries/base/GHC/IO/Encoding/Failure.hs +++ b/libraries/base/GHC/IO/Encoding/Failure.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, PatternGuards #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/GHC/IO/Encoding/Iconv.hs b/libraries/base/GHC/IO/Encoding/Iconv.hs index d91907132c..f8dfb88ae7 100644 --- a/libraries/base/GHC/IO/Encoding/Iconv.hs +++ b/libraries/base/GHC/IO/Encoding/Iconv.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , ForeignFunctionInterface @@ -31,7 +32,7 @@ module GHC.IO.Encoding.Iconv ( #if !defined(mingw32_HOST_OS) -import Foreign hiding (unsafePerformIO) +import Foreign.Safe import Foreign.C import Data.Maybe import GHC.Base diff --git a/libraries/base/GHC/IO/Encoding/Latin1.hs b/libraries/base/GHC/IO/Encoding/Latin1.hs index 197222eaa7..0e3de3922e 100644 --- a/libraries/base/GHC/IO/Encoding/Latin1.hs +++ b/libraries/base/GHC/IO/Encoding/Latin1.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude , BangPatterns , NondecreasingIndentation diff --git a/libraries/base/GHC/IO/Encoding/Types.hs b/libraries/base/GHC/IO/Encoding/Types.hs index ebce578219..df6ce2f257 100644 --- a/libraries/base/GHC/IO/Encoding/Types.hs +++ b/libraries/base/GHC/IO/Encoding/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, ExistentialQuantification #-} {-# OPTIONS_GHC -funbox-strict-fields #-} diff --git a/libraries/base/GHC/IO/Encoding/UTF16.hs b/libraries/base/GHC/IO/Encoding/UTF16.hs index 193222099d..af3cae057d 100644 --- a/libraries/base/GHC/IO/Encoding/UTF16.hs +++ b/libraries/base/GHC/IO/Encoding/UTF16.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , BangPatterns diff --git a/libraries/base/GHC/IO/Encoding/UTF32.hs b/libraries/base/GHC/IO/Encoding/UTF32.hs index 89a0d11b7f..815f36ca19 100644 --- a/libraries/base/GHC/IO/Encoding/UTF32.hs +++ b/libraries/base/GHC/IO/Encoding/UTF32.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude , BangPatterns , NondecreasingIndentation diff --git a/libraries/base/GHC/IO/Encoding/UTF8.hs b/libraries/base/GHC/IO/Encoding/UTF8.hs index 55d09c82b1..df3e67b889 100644 --- a/libraries/base/GHC/IO/Encoding/UTF8.hs +++ b/libraries/base/GHC/IO/Encoding/UTF8.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude , BangPatterns , NondecreasingIndentation diff --git a/libraries/base/GHC/IO/Exception.hs b/libraries/base/GHC/IO/Exception.hs index 4134fca867..e3482cb659 100644 --- a/libraries/base/GHC/IO/Exception.hs +++ b/libraries/base/GHC/IO/Exception.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, DeriveDataTypeable, MagicHash #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/IO/Exception.hs-boot b/libraries/base/GHC/IO/Exception.hs-boot index d094ef2c54..fa3abe7a19 100644 --- a/libraries/base/GHC/IO/Exception.hs-boot +++ b/libraries/base/GHC/IO/Exception.hs-boot @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module GHC.IO.Exception where diff --git a/libraries/base/GHC/IO/FD.hs b/libraries/base/GHC/IO/FD.hs index 65ed913788..282c215a85 100644 --- a/libraries/base/GHC/IO/FD.hs +++ b/libraries/base/GHC/IO/FD.hs @@ -13,7 +13,7 @@ -- Module : GHC.IO.FD -- Copyright : (c) The University of Glasgow, 1994-2008 -- License : see libraries/base/LICENSE --- +-- -- Maintainer : libraries@haskell.org -- Stability : internal -- Portability : non-portable @@ -23,12 +23,12 @@ ----------------------------------------------------------------------------- module GHC.IO.FD ( - FD(..), - openFile, mkFD, release, - setNonBlockingMode, - readRawBufferPtr, readRawBufferPtrNoBlock, writeRawBufferPtr, - stdin, stdout, stderr - ) where + FD(..), + openFile, mkFD, release, + setNonBlockingMode, + readRawBufferPtr, readRawBufferPtrNoBlock, writeRawBufferPtr, + stdin, stdout, stderr + ) where import GHC.Base import GHC.Num @@ -56,7 +56,6 @@ import Foreign.C import qualified System.Posix.Internals import System.Posix.Internals hiding (FD, setEcho, getEcho) import System.Posix.Types --- import GHC.Ptr c_DEBUG_DUMP :: Bool c_DEBUG_DUMP = False diff --git a/libraries/base/GHC/IO/Handle.hs b/libraries/base/GHC/IO/Handle.hs index fcfa92d080..cb6f6502a1 100644 --- a/libraries/base/GHC/IO/Handle.hs +++ b/libraries/base/GHC/IO/Handle.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , RecordWildCards diff --git a/libraries/base/GHC/IO/Handle.hs-boot b/libraries/base/GHC/IO/Handle.hs-boot index d925f08439..935bf5e4e9 100644 --- a/libraries/base/GHC/IO/Handle.hs-boot +++ b/libraries/base/GHC/IO/Handle.hs-boot @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module GHC.IO.Handle where diff --git a/libraries/base/GHC/IO/Handle/FD.hs b/libraries/base/GHC/IO/Handle/FD.hs index cb166456d6..31f90eac0a 100644 --- a/libraries/base/GHC/IO/Handle/FD.hs +++ b/libraries/base/GHC/IO/Handle/FD.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, PatternGuards, ForeignFunctionInterface #-} ----------------------------------------------------------------------------- @@ -24,19 +25,16 @@ module GHC.IO.Handle.FD ( import GHC.Base import GHC.Show import Data.Maybe --- import Control.Monad import Foreign.C.Types import GHC.MVar import GHC.IO import GHC.IO.Encoding --- import GHC.IO.Exception import GHC.IO.Device as IODevice import GHC.IO.Exception import GHC.IO.IOMode import GHC.IO.Handle import GHC.IO.Handle.Types import GHC.IO.Handle.Internals -import GHC.IO.FD (FD(..)) import qualified GHC.IO.FD as FD import qualified System.Posix.Internals as Posix @@ -90,7 +88,7 @@ stdHandleFinalizer fp m = do -- We have to put the FDs into binary mode on Windows to avoid the newline -- translation that the CRT IO library does. -setBinaryMode :: FD -> IO () +setBinaryMode :: FD.FD -> IO () #ifdef mingw32_HOST_OS setBinaryMode fd = do _ <- setmode (fdFD fd) True return () @@ -199,7 +197,7 @@ openFile' filepath iomode binary non_blocking = do -- Converting file descriptors to Handles mkHandleFromFD - :: FD + :: FD.FD -> IODeviceType -> FilePath -- a string describing this file descriptor (e.g. the filename) -> IOMode diff --git a/libraries/base/GHC/IO/Handle/FD.hs-boot b/libraries/base/GHC/IO/Handle/FD.hs-boot index 2d84884a45..fb8ee973fc 100644 --- a/libraries/base/GHC/IO/Handle/FD.hs-boot +++ b/libraries/base/GHC/IO/Handle/FD.hs-boot @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module GHC.IO.Handle.FD where diff --git a/libraries/base/GHC/IO/Handle/Internals.hs b/libraries/base/GHC/IO/Handle/Internals.hs index a2b644f514..7e619c4c50 100644 --- a/libraries/base/GHC/IO/Handle/Internals.hs +++ b/libraries/base/GHC/IO/Handle/Internals.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude , RecordWildCards , BangPatterns @@ -75,8 +76,7 @@ import GHC.MVar import Data.Typeable import Control.Monad import Data.Maybe -import Foreign hiding (unsafePerformIO) --- import System.IO.Error +import Foreign.Safe import System.Posix.Internals hiding (FD) import Foreign.C diff --git a/libraries/base/GHC/IO/Handle/Text.hs b/libraries/base/GHC/IO/Handle/Text.hs index 0d0e05b4d5..7b390cd490 100644 --- a/libraries/base/GHC/IO/Handle/Text.hs +++ b/libraries/base/GHC/IO/Handle/Text.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , RecordWildCards @@ -27,11 +28,11 @@ -- #hide module GHC.IO.Handle.Text ( - hWaitForInput, hGetChar, hGetLine, hGetContents, hPutChar, hPutStr, - commitBuffer', -- hack, see below - hGetBuf, hGetBufSome, hGetBufNonBlocking, hPutBuf, hPutBufNonBlocking, - memcpy, hPutStrLn, - ) where + hWaitForInput, hGetChar, hGetLine, hGetContents, hPutChar, hPutStr, + commitBuffer', -- hack, see below + hGetBuf, hGetBufSome, hGetBufNonBlocking, hPutBuf, hPutBufNonBlocking, + memcpy, hPutStrLn, + ) where import GHC.IO import GHC.IO.FD diff --git a/libraries/base/GHC/IO/Handle/Types.hs b/libraries/base/GHC/IO/Handle/Types.hs index bff4681398..40c557a840 100644 --- a/libraries/base/GHC/IO/Handle/Types.hs +++ b/libraries/base/GHC/IO/Handle/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , ExistentialQuantification diff --git a/libraries/base/GHC/IO/IOMode.hs b/libraries/base/GHC/IO/IOMode.hs index 3b0943cec9..b649ac1c0b 100644 --- a/libraries/base/GHC/IO/IOMode.hs +++ b/libraries/base/GHC/IO/IOMode.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/IOArray.hs b/libraries/base/GHC/IOArray.hs index 67ee0149f2..0b43c8b574 100644 --- a/libraries/base/GHC/IOArray.hs +++ b/libraries/base/GHC/IOArray.hs @@ -6,7 +6,7 @@ -- Module : GHC.IOArray -- Copyright : (c) The University of Glasgow 2008 -- License : see libraries/base/LICENSE --- +-- -- Maintainer : cvs-ghc@haskell.org -- Stability : internal -- Portability : non-portable (GHC Extensions) @@ -16,25 +16,25 @@ ----------------------------------------------------------------------------- module GHC.IOArray ( - IOArray(..), - newIOArray, unsafeReadIOArray, unsafeWriteIOArray, - readIOArray, writeIOArray, - boundsIOArray - ) where + IOArray(..), + newIOArray, unsafeReadIOArray, unsafeWriteIOArray, + readIOArray, writeIOArray, + boundsIOArray + ) where import GHC.Base import GHC.IO import GHC.Arr -- --------------------------------------------------------------------------- --- | An 'IOArray' is a mutable, boxed, non-strict array in the 'IO' monad. +-- | An 'IOArray' is a mutable, boxed, non-strict array in the 'IO' monad. -- The type arguments are as follows: -- -- * @i@: the index type of the array (should be an instance of 'Ix') -- -- * @e@: the element type of the array. -- --- +-- newtype IOArray i e = IOArray (STArray RealWorld i e) @@ -66,5 +66,6 @@ writeIOArray :: Ix i => IOArray i e -> i -> e -> IO () writeIOArray (IOArray marr) i e = stToIO (writeSTArray marr i e) {-# INLINE boundsIOArray #-} -boundsIOArray :: IOArray i e -> (i,i) +boundsIOArray :: IOArray i e -> (i,i) boundsIOArray (IOArray marr) = boundsSTArray marr + diff --git a/libraries/base/GHC/IORef.hs b/libraries/base/GHC/IORef.hs index be2808d338..6efb77f7e4 100644 --- a/libraries/base/GHC/IORef.hs +++ b/libraries/base/GHC/IORef.hs @@ -7,7 +7,7 @@ -- Module : GHC.IORef -- Copyright : (c) The University of Glasgow 2008 -- License : see libraries/base/LICENSE --- +-- -- Maintainer : cvs-ghc@haskell.org -- Stability : internal -- Portability : non-portable (GHC Extensions) @@ -16,9 +16,9 @@ -- ----------------------------------------------------------------------------- module GHC.IORef ( - IORef(..), - newIORef, readIORef, writeIORef, atomicModifyIORef - ) where + IORef(..), + newIORef, readIORef, writeIORef, atomicModifyIORef + ) where import GHC.Base import GHC.STRef diff --git a/libraries/base/GHC/Int.hs b/libraries/base/GHC/Int.hs index 27ee9906cd..b80bd1a222 100644 --- a/libraries/base/GHC/Int.hs +++ b/libraries/base/GHC/Int.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash, StandaloneDeriving #-} {-# OPTIONS_HADDOCK hide #-} @@ -19,8 +20,8 @@ -- #hide module GHC.Int ( - Int8(..), Int16(..), Int32(..), Int64(..), - uncheckedIShiftL64#, uncheckedIShiftRA64# + Int8(..), Int16(..), Int32(..), Int64(..), + uncheckedIShiftL64#, uncheckedIShiftRA64# ) where import Data.Bits diff --git a/libraries/base/GHC/List.lhs b/libraries/base/GHC/List.lhs index ff8593ca42..838491a498 100644 --- a/libraries/base/GHC/List.lhs +++ b/libraries/base/GHC/List.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/MVar.hs b/libraries/base/GHC/MVar.hs index 8c653dca6a..e6d960e5e8 100644 --- a/libraries/base/GHC/MVar.hs +++ b/libraries/base/GHC/MVar.hs @@ -7,7 +7,7 @@ -- Module : GHC.MVar -- Copyright : (c) The University of Glasgow 2008 -- License : see libraries/base/LICENSE --- +-- -- Maintainer : cvs-ghc@haskell.org -- Stability : internal -- Portability : non-portable (GHC Extensions) @@ -27,11 +27,10 @@ module GHC.MVar ( , tryPutMVar -- :: MVar a -> a -> IO Bool , isEmptyMVar -- :: MVar a -> IO Bool , addMVarFinalizer -- :: MVar a -> IO () -> IO () - - ) where + ) where import GHC.Base -import GHC.IO() -- instance Monad IO +import GHC.IO () -- instance Monad IO import Data.Maybe data MVar a = MVar (MVar# RealWorld a) @@ -71,9 +70,9 @@ newMVar value = return mvar -- |Return the contents of the 'MVar'. If the 'MVar' is currently --- empty, 'takeMVar' will wait until it is full. After a 'takeMVar', +-- empty, 'takeMVar' will wait until it is full. After a 'takeMVar', -- the 'MVar' is left empty. --- +-- -- There are two further important properties of 'takeMVar': -- -- * 'takeMVar' is single-wakeup. That is, if there are multiple @@ -133,13 +132,13 @@ tryPutMVar (MVar mvar#) x = IO $ \ s# -> -- the MVar may have been filled (or emptied) - so be extremely -- careful when using this operation. Use 'tryTakeMVar' instead if possible. isEmptyMVar :: MVar a -> IO Bool -isEmptyMVar (MVar mv#) = IO $ \ s# -> +isEmptyMVar (MVar mv#) = IO $ \ s# -> case isEmptyMVar# mv# s# of (# s2#, flg #) -> (# s2#, not (flg ==# 0#) #) -- |Add a finalizer to an 'MVar' (GHC only). See "Foreign.ForeignPtr" and -- "System.Mem.Weak" for more about finalizers. addMVarFinalizer :: MVar a -> IO () -> IO () -addMVarFinalizer (MVar m) finalizer = +addMVarFinalizer (MVar m) finalizer = IO $ \s -> case mkWeak# m () finalizer s of { (# s1, _ #) -> (# s1, () #) } diff --git a/libraries/base/GHC/Num.lhs b/libraries/base/GHC/Num.lhs index 5dc5e753d1..b7b026048c 100644 --- a/libraries/base/GHC/Num.lhs +++ b/libraries/base/GHC/Num.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-} -- We believe we could deorphan this module, by moving lots of things -- around, but we haven't got there yet: diff --git a/libraries/base/GHC/PArr.hs b/libraries/base/GHC/PArr.hs index 704fc5a4b5..ee7eea8b27 100644 --- a/libraries/base/GHC/PArr.hs +++ b/libraries/base/GHC/PArr.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE ParallelArrays, MagicHash #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/Ptr.lhs b/libraries/base/GHC/Ptr.lhs index bf78f713bd..e7e0b1fd0e 100644 --- a/libraries/base/GHC/Ptr.lhs +++ b/libraries/base/GHC/Ptr.lhs @@ -17,7 +17,14 @@ ----------------------------------------------------------------------------- -- #hide -module GHC.Ptr where +module GHC.Ptr ( + Ptr(..), FunPtr(..), + nullPtr, castPtr, plusPtr, alignPtr, minusPtr, + nullFunPtr, castFunPtr, + + -- * Unsafe functions + castFunPtrToPtr, castPtrToFunPtr + ) where import GHC.Base import GHC.Show @@ -156,5 +163,5 @@ instance Show (Ptr a) where instance Show (FunPtr a) where showsPrec p = showsPrec p . castFunPtrToPtr -\end{code} +\end{code} diff --git a/libraries/base/GHC/Read.lhs b/libraries/base/GHC/Read.lhs index 6305276cdd..fcbdb8e8b9 100644 --- a/libraries/base/GHC/Read.lhs +++ b/libraries/base/GHC/Read.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, StandaloneDeriving #-} {-# OPTIONS_HADDOCK hide #-} @@ -688,4 +689,4 @@ Instances for types of the generic deriving mechanism. deriving instance Read Arity deriving instance Read Associativity deriving instance Read Fixity -\end{code}
\ No newline at end of file +\end{code} diff --git a/libraries/base/GHC/Real.lhs b/libraries/base/GHC/Real.lhs index 27b1b6c3a5..6d44e29a60 100644 --- a/libraries/base/GHC/Real.lhs +++ b/libraries/base/GHC/Real.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/ST.lhs b/libraries/base/GHC/ST.lhs index a66a5f8aa6..4e27fb2be7 100644 --- a/libraries/base/GHC/ST.lhs +++ b/libraries/base/GHC/ST.lhs @@ -16,7 +16,13 @@ ----------------------------------------------------------------------------- -- #hide -module GHC.ST where +module GHC.ST ( + ST(..), STret(..), STRep, + fixST, runST, runSTRep, + + -- * Unsafe functions + liftST, unsafeInterleaveST + ) where import GHC.Base import GHC.Show diff --git a/libraries/base/GHC/STRef.lhs b/libraries/base/GHC/STRef.lhs index 9306b2473c..4e5952a88b 100644 --- a/libraries/base/GHC/STRef.lhs +++ b/libraries/base/GHC/STRef.lhs @@ -7,7 +7,7 @@ -- Module : GHC.STRef -- Copyright : (c) The University of Glasgow, 1994-2002 -- License : see libraries/base/LICENSE --- +-- -- Maintainer : cvs-ghc@haskell.org -- Stability : internal -- Portability : non-portable (GHC Extensions) @@ -17,7 +17,10 @@ ----------------------------------------------------------------------------- -- #hide -module GHC.STRef where +module GHC.STRef ( + STRef(..), + newSTRef, readSTRef, writeSTRef + ) where import GHC.ST import GHC.Base @@ -45,4 +48,5 @@ writeSTRef (STRef var#) val = ST $ \s1# -> -- Just pointer equality on mutable references: instance Eq (STRef s a) where STRef v1# == STRef v2# = sameMutVar# v1# v2# + \end{code} diff --git a/libraries/base/GHC/Show.lhs b/libraries/base/GHC/Show.lhs index bbfe45849b..1645b4a8da 100644 --- a/libraries/base/GHC/Show.lhs +++ b/libraries/base/GHC/Show.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, BangPatterns, MagicHash, StandaloneDeriving #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/Show.lhs-boot b/libraries/base/GHC/Show.lhs-boot index 6c5fa61308..a2363f69f4 100644 --- a/libraries/base/GHC/Show.lhs-boot +++ b/libraries/base/GHC/Show.lhs-boot @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module GHC.Show (showSignedInt) where diff --git a/libraries/base/GHC/Stable.lhs b/libraries/base/GHC/Stable.lhs index e96bf687ae..10675f7a9c 100644 --- a/libraries/base/GHC/Stable.lhs +++ b/libraries/base/GHC/Stable.lhs @@ -21,18 +21,17 @@ ----------------------------------------------------------------------------- -- #hide -module GHC.Stable - ( StablePtr(..) - , newStablePtr -- :: a -> IO (StablePtr a) - , deRefStablePtr -- :: StablePtr a -> a - , freeStablePtr -- :: StablePtr a -> IO () - , castStablePtrToPtr -- :: StablePtr a -> Ptr () - , castPtrToStablePtr -- :: Ptr () -> StablePtr a - ) where +module GHC.Stable ( + StablePtr(..), + newStablePtr, -- :: a -> IO (StablePtr a) + deRefStablePtr, -- :: StablePtr a -> a + freeStablePtr, -- :: StablePtr a -> IO () + castStablePtrToPtr, -- :: StablePtr a -> Ptr () + castPtrToStablePtr -- :: Ptr () -> StablePtr a + ) where import GHC.Ptr import GHC.Base --- import GHC.IO ----------------------------------------------------------------------------- -- Stable Pointers @@ -109,4 +108,5 @@ instance Eq (StablePtr a) where case eqStablePtr# sp1 sp2 of 0# -> False _ -> True + \end{code} diff --git a/libraries/base/GHC/Storable.lhs b/libraries/base/GHC/Storable.lhs index a722873865..119fed6293 100644 --- a/libraries/base/GHC/Storable.lhs +++ b/libraries/base/GHC/Storable.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-} {-# OPTIONS_HADDOCK hide #-} @@ -52,7 +53,7 @@ module GHC.Storable , writeWord64OffPtr ) where -import GHC.Stable ( StablePtr(..) ) +import GHC.Stable ( StablePtr(..) ) import GHC.Int import GHC.Word import GHC.Ptr diff --git a/libraries/base/GHC/TopHandler.lhs b/libraries/base/GHC/TopHandler.lhs index 7bedcfea5d..0ebc42c29a 100644 --- a/libraries/base/GHC/TopHandler.lhs +++ b/libraries/base/GHC/TopHandler.lhs @@ -1,4 +1,5 @@ \begin{code} +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , ForeignFunctionInterface @@ -26,10 +27,10 @@ -- #hide module GHC.TopHandler ( - runMainIO, runIO, runIOFastExit, runNonIO, - topHandler, topHandlerFastExit, - reportStackOverflow, reportError, - ) where + runMainIO, runIO, runIOFastExit, runNonIO, + topHandler, topHandlerFastExit, + reportStackOverflow, reportError, + ) where #include "HsBaseConfig.h" diff --git a/libraries/base/GHC/Unicode.hs b/libraries/base/GHC/Unicode.hs index b34f677069..a55c8a064e 100644 --- a/libraries/base/GHC/Unicode.hs +++ b/libraries/base/GHC/Unicode.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-} {-# OPTIONS -#include "WCsubst.h" #-} {-# OPTIONS_HADDOCK hide #-} @@ -20,14 +21,14 @@ -- #hide module GHC.Unicode ( - isAscii, isLatin1, isControl, - isAsciiUpper, isAsciiLower, - isPrint, isSpace, isUpper, - isLower, isAlpha, isDigit, - isOctDigit, isHexDigit, isAlphaNum, - toUpper, toLower, toTitle, - wgencat, - ) where + isAscii, isLatin1, isControl, + isAsciiUpper, isAsciiLower, + isPrint, isSpace, isUpper, + isLower, isAlpha, isDigit, + isOctDigit, isHexDigit, isAlphaNum, + toUpper, toLower, toTitle, + wgencat + ) where import GHC.Base import GHC.Real (fromIntegral) diff --git a/libraries/base/GHC/Unicode.hs-boot b/libraries/base/GHC/Unicode.hs-boot index cc67dbbb11..1e01a1ce29 100644 --- a/libraries/base/GHC/Unicode.hs-boot +++ b/libraries/base/GHC/Unicode.hs-boot @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module GHC.Unicode where diff --git a/libraries/base/GHC/Weak.lhs b/libraries/base/GHC/Weak.lhs index 92e1eb89b0..3de465589c 100644 --- a/libraries/base/GHC/Weak.lhs +++ b/libraries/base/GHC/Weak.lhs @@ -24,7 +24,13 @@ ----------------------------------------------------------------------------- -- #hide -module GHC.Weak where +module GHC.Weak ( + Weak(..), + mkWeak, + deRefWeak, + finalize, + runFinalizerBatch + ) where import GHC.Base import Data.Maybe diff --git a/libraries/base/GHC/Windows.hs b/libraries/base/GHC/Windows.hs index 2a74a5f71e..836dcf887d 100644 --- a/libraries/base/GHC/Windows.hs +++ b/libraries/base/GHC/Windows.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, ForeignFunctionInterface #-} ----------------------------------------------------------------------------- -- | @@ -17,7 +18,10 @@ -- ----------------------------------------------------------------------------- -module GHC.Windows where +module GHC.Windows ( + HANDLE, DWORD, LPTSTR, iNFINITE, + throwGetLastError, maperrno + ) where import GHC.Base import GHC.Ptr diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs index 9d3e1a6ae7..dd7e7d5da8 100644 --- a/libraries/base/GHC/Word.hs +++ b/libraries/base/GHC/Word.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/Numeric.hs b/libraries/base/Numeric.hs index 4b202d0efd..8989f967a2 100644 --- a/libraries/base/Numeric.hs +++ b/libraries/base/Numeric.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Prelude.hs b/libraries/base/Prelude.hs index 4c183ae38c..59bffae6e5 100644 --- a/libraries/base/Prelude.hs +++ b/libraries/base/Prelude.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns #-} ----------------------------------------------------------------------------- @@ -156,8 +157,6 @@ import Data.Tuple #ifdef __GLASGOW_HASKELL__ import GHC.Base --- import GHC.IO --- import GHC.IO.Exception import Text.Read import GHC.Enum import GHC.Num diff --git a/libraries/base/System/CPUTime.hsc b/libraries/base/System/CPUTime.hsc index 90ff1e9656..f07b2e448d 100644 --- a/libraries/base/System/CPUTime.hsc +++ b/libraries/base/System/CPUTime.hsc @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NondecreasingIndentation, ForeignFunctionInterface #-} ----------------------------------------------------------------------------- @@ -33,7 +34,7 @@ import CPUTime ( getCPUTime, cpuTimePrecision ) #endif #ifdef __GLASGOW_HASKELL__ -import Foreign hiding (unsafePerformIO) +import Foreign.Safe import Foreign.C #if !defined(CLK_TCK) import System.IO.Unsafe (unsafePerformIO) diff --git a/libraries/base/System/Console/GetOpt.hs b/libraries/base/System/Console/GetOpt.hs index 92ebd52055..d5a32f395f 100644 --- a/libraries/base/System/Console/GetOpt.hs +++ b/libraries/base/System/Console/GetOpt.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : System.Console.GetOpt diff --git a/libraries/base/System/Environment.hs b/libraries/base/System/Environment.hs index cf73c3d9bc..e185575147 100644 --- a/libraries/base/System/Environment.hs +++ b/libraries/base/System/Environment.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP, ForeignFunctionInterface #-} ----------------------------------------------------------------------------- @@ -31,7 +32,7 @@ module System.Environment import Prelude #ifdef __GLASGOW_HASKELL__ -import Foreign +import Foreign.Safe import Foreign.C import Control.Exception.Base ( bracket ) -- import GHC.IO diff --git a/libraries/base/System/Exit.hs b/libraries/base/System/Exit.hs index 7eb17cfbfe..9a9ed00045 100644 --- a/libraries/base/System/Exit.hs +++ b/libraries/base/System/Exit.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/System/IO.hs b/libraries/base/System/IO.hs index bf26835eef..768d557653 100644 --- a/libraries/base/System/IO.hs +++ b/libraries/base/System/IO.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/System/IO/Error.hs b/libraries/base/System/IO/Error.hs index a026f338a1..1458d60bed 100644 --- a/libraries/base/System/IO/Error.hs +++ b/libraries/base/System/IO/Error.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/System/IO/Unsafe.hs b/libraries/base/System/IO/Unsafe.hs index 3ef3d9f3e0..719bd3eed5 100644 --- a/libraries/base/System/IO/Unsafe.hs +++ b/libraries/base/System/IO/Unsafe.hs @@ -21,7 +21,7 @@ module System.IO.Unsafe ( ) where #ifdef __GLASGOW_HASKELL__ -import GHC.IO (unsafePerformIO, unsafeInterleaveIO) +import GHC.IO (unsafePerformIO, unsafeInterleaveIO) #endif #ifdef __HUGS__ diff --git a/libraries/base/System/Info.hs b/libraries/base/System/Info.hs index 92da1a64b7..5fc816c080 100644 --- a/libraries/base/System/Info.hs +++ b/libraries/base/System/Info.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/System/Mem.hs b/libraries/base/System/Mem.hs index af96b5dd1c..67b80cc320 100644 --- a/libraries/base/System/Mem.hs +++ b/libraries/base/System/Mem.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ diff --git a/libraries/base/System/Mem/StableName.hs b/libraries/base/System/Mem/StableName.hs index 2bce839dd2..7d688e9aa8 100644 --- a/libraries/base/System/Mem/StableName.hs +++ b/libraries/base/System/Mem/StableName.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} diff --git a/libraries/base/System/Mem/Weak.hs b/libraries/base/System/Mem/Weak.hs index 21411e531c..8980a51b55 100644 --- a/libraries/base/System/Mem/Weak.hs +++ b/libraries/base/System/Mem/Weak.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs index 6a30ba07e8..632e69eb27 100644 --- a/libraries/base/System/Posix/Internals.hs +++ b/libraries/base/System/Posix/Internals.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/System/Posix/Internals.hs-boot b/libraries/base/System/Posix/Internals.hs-boot index 40415fcd61..ff4c4e8427 100644 --- a/libraries/base/System/Posix/Internals.hs-boot +++ b/libraries/base/System/Posix/Internals.hs-boot @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} module System.Posix.Internals where diff --git a/libraries/base/System/Posix/Types.hs b/libraries/base/System/Posix/Types.hs index 9bb85e298a..c8c0c486b4 100644 --- a/libraries/base/System/Posix/Types.hs +++ b/libraries/base/System/Posix/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP , NoImplicitPrelude , MagicHash diff --git a/libraries/base/System/Timeout.hs b/libraries/base/System/Timeout.hs index df33625c8d..d1cbbffc91 100644 --- a/libraries/base/System/Timeout.hs +++ b/libraries/base/System/Timeout.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} diff --git a/libraries/base/Text/ParserCombinators/ReadP.hs b/libraries/base/Text/ParserCombinators/ReadP.hs index 27bba5404e..2bb93639bb 100644 --- a/libraries/base/Text/ParserCombinators/ReadP.hs +++ b/libraries/base/Text/ParserCombinators/ReadP.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} #ifndef __NHC__ {-# LANGUAGE Rank2Types #-} diff --git a/libraries/base/Text/ParserCombinators/ReadPrec.hs b/libraries/base/Text/ParserCombinators/ReadPrec.hs index f282d1af45..8a200b956e 100644 --- a/libraries/base/Text/ParserCombinators/ReadPrec.hs +++ b/libraries/base/Text/ParserCombinators/ReadPrec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Text/Printf.hs b/libraries/base/Text/Printf.hs index 7d4611eade..021f670e1b 100644 --- a/libraries/base/Text/Printf.hs +++ b/libraries/base/Text/Printf.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Text/Read.hs b/libraries/base/Text/Read.hs index d935ffec41..cea334b28a 100644 --- a/libraries/base/Text/Read.hs +++ b/libraries/base/Text/Read.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs index 222d6cf06d..88c9c07212 100644 --- a/libraries/base/Text/Read/Lex.hs +++ b/libraries/base/Text/Read/Lex.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Text/Show.hs b/libraries/base/Text/Show.hs index 4d23e578df..3662d124c2 100644 --- a/libraries/base/Text/Show.hs +++ b/libraries/base/Text/Show.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP, NoImplicitPrelude #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Text/Show/Functions.hs b/libraries/base/Text/Show/Functions.hs index 1ae46aa29d..fa202f7edd 100644 --- a/libraries/base/Text/Show/Functions.hs +++ b/libraries/base/Text/Show/Functions.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE CPP #-} -- This module deliberately declares orphan instances: {-# OPTIONS_GHC -fno-warn-orphans #-} diff --git a/libraries/base/base.cabal b/libraries/base/base.cabal index 6bb96f6474..5824952dce 100644 --- a/libraries/base/base.cabal +++ b/libraries/base/base.cabal @@ -52,38 +52,38 @@ Library { GHC.Exception, GHC.Exts, GHC.Float, + GHC.Float.ConversionUtils, GHC.Float.RealFracMethods, GHC.Foreign, - GHC.Float.ConversionUtils, GHC.ForeignPtr, - GHC.MVar, + GHC.Handle, GHC.IO, - GHC.IO.IOMode, GHC.IO.Buffer, - GHC.IO.Device, GHC.IO.BufferedIO, - GHC.IO.FD, - GHC.IO.Exception, + GHC.IO.Device, GHC.IO.Encoding, + GHC.IO.Encoding.CodePage, + GHC.IO.Encoding.Failure, + GHC.IO.Encoding.Iconv, GHC.IO.Encoding.Latin1, - GHC.IO.Encoding.UTF8, + GHC.IO.Encoding.Types, GHC.IO.Encoding.UTF16, GHC.IO.Encoding.UTF32, - GHC.IO.Encoding.Types, - GHC.IO.Encoding.Iconv, - GHC.IO.Encoding.CodePage, - GHC.IO.Encoding.Failure, + GHC.IO.Encoding.UTF8, + GHC.IO.Exception, + GHC.IO.FD, GHC.IO.Handle, - GHC.IO.Handle.Types, - GHC.IO.Handle.Internals, GHC.IO.Handle.FD, + GHC.IO.Handle.Internals, GHC.IO.Handle.Text, + GHC.IO.Handle.Types, + GHC.IO.IOMode, + GHC.IOArray, GHC.IOBase, - GHC.Handle, GHC.IORef, - GHC.IOArray, GHC.Int, GHC.List, + GHC.MVar, GHC.Num, GHC.PArr, GHC.Pack, @@ -91,10 +91,10 @@ Library { GHC.Read, GHC.Real, GHC.ST, - GHC.STRef, GHC.Show, GHC.Stable, GHC.Storable, + GHC.STRef, GHC.TopHandler, GHC.Unicode, GHC.Weak, @@ -121,9 +121,13 @@ Library { Control.Monad, Control.Monad.Fix, Control.Monad.Instances, - Control.Monad.ST - Control.Monad.ST.Lazy - Control.Monad.ST.Strict + Control.Monad.ST, + Control.Monad.ST.Safe, + Control.Monad.ST.Unsafe, + Control.Monad.ST.Lazy, + Control.Monad.ST.Lazy.Safe, + Control.Monad.ST.Lazy.Unsafe, + Control.Monad.ST.Strict, Control.Monad.Group Control.Monad.Zip Data.Bits, @@ -164,13 +168,18 @@ Library { Foreign.C.String, Foreign.C.Types, Foreign.ForeignPtr, + Foreign.ForeignPtr.Safe, + Foreign.ForeignPtr.Unsafe, Foreign.Marshal, Foreign.Marshal.Alloc, Foreign.Marshal.Array, Foreign.Marshal.Error, Foreign.Marshal.Pool, + Foreign.Marshal.Safe, Foreign.Marshal.Utils, + Foreign.Marshal.Unsafe, Foreign.Ptr, + Foreign.Safe, Foreign.StablePtr, Foreign.Storable, Numeric, @@ -196,6 +205,10 @@ Library { Text.Show, Text.Show.Functions Unsafe.Coerce + other-modules: + Control.Monad.ST.Imp + Control.Monad.ST.Lazy.Imp + Foreign.ForeignPtr.Imp c-sources: cbits/PrelIOUtils.c cbits/WCsubst.c @@ -232,4 +245,5 @@ Library { -- as it's magic. ghc-options: -package-name base nhc98-options: -H4M -K3M + extensions: CPP } |