Commit 378dd296 authored by dterei's avatar dterei

Update base for latest Safe Haskell.

parent c9dceb6d
{-# LANGUAGE Trustworthy #-}
-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.Group
......@@ -32,3 +33,4 @@ class Monad m => MonadGroup m t where
instance Ord t => MonadGroup [] t where
mgroupWith = groupWith
#endif
......@@ -2,6 +2,7 @@
{-# OPTIONS_NHC98 --prelude #-}
-- This module deliberately declares orphan instances:
{-# OPTIONS_GHC -fno-warn-orphans #-}
-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.Instances
......@@ -37,3 +38,4 @@ instance Monad (Either e) where
return = Right
Left l >>= _ = Left l
Right r >>= k = k r
{-# LANGUAGE CPP #-}
#if sh_SAFE_DEFAULT
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Unsafe #-}
#endif
-----------------------------------------------------------------------------
-- |
......@@ -22,18 +17,22 @@
-----------------------------------------------------------------------------
module Control.Monad.ST (
module Control.Monad.ST.Safe
#if !sh_SAFE_DEFAULT
-- * 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 Functions
, unsafeInterleaveST
, unsafeIOToST
, unsafeSTToIO
#endif
unsafeInterleaveST,
unsafeIOToST,
unsafeSTToIO
) where
import Control.Monad.ST.Safe
#if !sh_SAFE_DEFAULT
import qualified Control.Monad.ST.Unsafe as U
{-# DEPRECATED unsafeInterleaveST, unsafeIOToST, unsafeSTToIO
......@@ -51,5 +50,4 @@ unsafeIOToST = U.unsafeIOToST
{-# INLINE unsafeSTToIO #-}
unsafeSTToIO :: ST s a -> IO a
unsafeSTToIO = U.unsafeSTToIO
#endif
{-# LANGUAGE CPP #-}
#if sh_SAFE_DEFAULT
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Unsafe #-}
#endif
-----------------------------------------------------------------------------
-- |
......@@ -22,16 +17,24 @@
-----------------------------------------------------------------------------
module Control.Monad.ST.Lazy (
module Control.Monad.ST.Lazy.Safe
#if !sh_SAFE_DEFAULT
-- * The 'ST' monad
ST,
runST,
fixST,
-- * Converting between strict and lazy 'ST'
strictToLazyST, lazyToStrictST,
-- * Converting 'ST' To 'IO'
RealWorld,
stToIO,
-- * Unsafe Functions
, unsafeInterleaveST
, unsafeIOToST
#endif
unsafeInterleaveST,
unsafeIOToST
) where
import Control.Monad.ST.Lazy.Safe
#if !sh_SAFE_DEFAULT
import qualified Control.Monad.ST.Lazy.Unsafe as U
{-# DEPRECATED unsafeInterleaveST, unsafeIOToST
......@@ -45,5 +48,4 @@ unsafeInterleaveST = U.unsafeInterleaveST
{-# INLINE unsafeIOToST #-}
unsafeIOToST :: IO a -> ST s a
unsafeIOToST = U.unsafeIOToST
#endif
......@@ -160,4 +160,3 @@ unsafeInterleaveST = strictToLazyST . ST.unsafeInterleaveST . lazyToStrictST
unsafeIOToST :: IO a -> ST s a
unsafeIOToST = strictToLazyST . ST.unsafeIOToST
{-# LANGUAGE Unsafe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.ST.Lazy.Unsafe
......
{-# LANGUAGE CPP #-}
#if sh_SAFE_DEFAULT
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Unsafe #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.ST.Strict
......@@ -22,9 +16,5 @@ 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
{-# LANGUAGE Unsafe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.ST.Unsafe
......
{-# LANGUAGE Safe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.Zip
......@@ -51,3 +52,4 @@ instance MonadZip [] where
mzip = zip
mzipWith = zipWith
munzip = unzip
......@@ -380,5 +380,4 @@ own to enable constant folding; for example 'shift':
10000000 -> ww_sOb
}
-}
......@@ -39,3 +39,4 @@ import Prelude
, otherwise
)
#endif
......@@ -209,3 +209,4 @@ isSeparator c = case generalCategory c of
toTitle :: Char -> Char
toTitle = toUpper
#endif
......@@ -205,3 +205,4 @@ instance (RealFloat a) => Floating (Complex a) where
asinh z = log (z + sqrt (1+z*z))
acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1)))
atanh z = 0.5 * log ((1.0+z) / (1.0-z))
......@@ -23,7 +23,6 @@
-- For more information, please visit the new
-- SYB wiki: <http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/SYB>.
--
--
-----------------------------------------------------------------------------
module Data.Data (
......
......@@ -168,3 +168,4 @@ dynApp f x = case dynApply f x of
dynTypeRep :: Dynamic -> TypeRep
dynTypeRep (Dynamic tr _) = tr
......@@ -22,3 +22,4 @@ module Data.Eq (
#if __GLASGOW_HASKELL__
import GHC.Base
#endif
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS -Wall -fno-warn-unused-binds #-}
#ifndef __NHC__
{-# LANGUAGE DeriveDataTypeable #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Module : Data.Fixed
......@@ -246,3 +246,4 @@ instance HasResolution E12 where
resolution _ = 1000000000000
-- | resolution of 10^-12 = .000000000001
type Pico = Fixed E12
......@@ -18,6 +18,8 @@
-- functor. To avoid ambiguity, either import those modules hiding
-- these names or qualify uses of these function names with an alias
-- for this module.
--
-----------------------------------------------------------------------------
module Data.Foldable (
-- * Folds
......@@ -320,3 +322,4 @@ notElem x = not . elem x
-- 'Nothing' if there is no such element.
find :: Foldable t => (a -> Bool) -> t a -> Maybe a
find p = listToMaybe . concatMap (\ x -> if p x then [x] else [])
{-# LANGUAGE Safe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.Function
......@@ -10,6 +11,8 @@
-- Portability : portable
--
-- Simple combinators working solely on and with functions.
--
-----------------------------------------------------------------------------
module Data.Function
( -- * "Prelude" re-exports
......@@ -82,3 +85,4 @@ fix f = let x = f x in x
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
(.*.) `on` f = \x y -> f x .*. f y
......@@ -33,3 +33,4 @@ infixl 4 <$>
-- | An infix synonym for 'fmap'.
(<$>) :: Functor f => (a -> b) -> f a -> f b
(<$>) = fmap
......@@ -531,3 +531,4 @@ longestChain = mapReduce id (maximumBy lengthCmp)
lengthCmp [] [] = EQ
lengthCmp [] _ = LT
lengthCmp _ [] = GT
......@@ -138,3 +138,4 @@ atomicModifyIORef r f =
'IORef' operations.
-}
......@@ -65,3 +65,4 @@ import NHC.SizedTypes (Int8, Int16, Int32, Int64) -- instances of Bits
count to the width of the type, for example @1 \<\< 32
== 1@ in some C implementations.
-}
......@@ -16,6 +16,7 @@
-- (see the array package).
--
-----------------------------------------------------------------------------
module Data.Ix
(
-- * The 'Ix' class
......
......@@ -1105,3 +1105,4 @@ errorEmptyList fun =
error ("Prelude." ++ fun ++ ": empty list")
#endif /* !__GLASGOW_HASKELL__ */
......@@ -149,3 +149,4 @@ mapMaybe f (x:xs) =
Just r -> r:rs
#endif /* else not __NHC__ */
......@@ -14,6 +14,7 @@
--
-- A class for monoids (types with an associative binary operation that
-- has an identity) with various general-purpose instances.
--
-----------------------------------------------------------------------------
module Data.Monoid (
......@@ -276,3 +277,4 @@ prop_mconcatLast x =
where listLastToMaybe [] = Nothing
listLastToMaybe lst = Just (last lst)
-- -}
......@@ -34,3 +34,4 @@ import GHC.Base
-- > ... sortBy (comparing fst) ...
comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
comparing p x y = compare (p x) (p y)
......@@ -95,3 +95,4 @@ approxRational rat eps = simplest (rat-eps) (rat+eps)
n'' = numerator nd''
d'' = denominator nd''
#endif
......@@ -42,3 +42,4 @@ INSTANCE_TYPEABLE2(STRef,stRefTc,"STRef")
-- |Mutate the contents of an 'STRef'
modifySTRef :: STRef s a -> (a -> a) -> ST s ()
modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref
{-# LANGUAGE Safe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.STRef.Lazy
......@@ -12,6 +13,7 @@
-- Mutable references in the lazy ST monad.
--
-----------------------------------------------------------------------------
module Data.STRef.Lazy (
-- * STRefs
ST.STRef, -- abstract, instance Eq
......@@ -30,7 +32,8 @@ readSTRef :: ST.STRef s a -> ST s a
writeSTRef :: ST.STRef s a -> a -> ST s ()
modifySTRef :: ST.STRef s a -> (a -> a) -> ST s ()
newSTRef = strictToLazyST . ST.newSTRef
readSTRef = strictToLazyST . ST.readSTRef
writeSTRef r a = strictToLazyST (ST.writeSTRef r a)
newSTRef = strictToLazyST . ST.newSTRef
readSTRef = strictToLazyST . ST.readSTRef
writeSTRef r a = strictToLazyST (ST.writeSTRef r a)
modifySTRef r f = strictToLazyST (ST.modifySTRef r f)
{-# LANGUAGE Safe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.STRef.Strict
......@@ -18,3 +19,4 @@ module Data.STRef.Strict (
) where
import Data.STRef
......@@ -41,3 +41,4 @@ class IsString a where
instance IsString [Char] where
fromString xs = xs
#endif
......@@ -29,6 +29,8 @@
-- functions of the same names from lists to any 'Traversable' functor.
-- To avoid ambiguity, either import the "Prelude" hiding these names
-- or qualify uses of these function names with an alias for this module.
--
-----------------------------------------------------------------------------
module Data.Traversable (
Traversable(..),
......@@ -194,3 +196,4 @@ instance Functor Id where
instance Applicative Id where
pure = Id
Id f <*> Id x = Id (f x)
......@@ -2,6 +2,7 @@
{-# LANGUAGE CPP, NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh.
-----------------------------------------------------------------------------
-- |
-- Module : Data.Tuple
......
{-# LANGUAGE Unsafe #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.Typeable.Internal
......
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-}
module Data.Typeable.Internal (
Typeable(typeOf),
TypeRep,
......
......@@ -68,3 +68,4 @@ type Word = Word32
truncate the shift count to the width of the type, for example @1 \<\<
32 == 1@ in some C implementations.
-}
......@@ -71,3 +71,4 @@ Like 'trace', but uses 'show' on the argument to convert it to a 'String'.
-}
traceShow :: (Show a) => a -> b -> b
traceShow = trace . show
#if sh_SAFE_DEFAULT
{-# LANGUAGE Trustworthy #-}
#else
{-# LANGUAGE Unsafe #-}
#endif
{-# LANGUAGE NoImplicitPrelude #-}
-----------------------------------------------------------------------------
......@@ -30,7 +26,6 @@ module Foreign
, module Foreign.Storable
, module Foreign.Marshal
#if !sh_SAFE_DEFAULT
-- * Unsafe Functions
-- | 'unsafePerformIO' is exported here for backwards
......@@ -38,7 +33,6 @@ module Foreign
-- the FFI, use 'unsafeLocalState'. For other uses, see
-- 'System.IO.Unsafe.unsafePerformIO'.
, unsafePerformIO
#endif
) where
import Data.Bits
......@@ -50,7 +44,6 @@ import Foreign.StablePtr
import Foreign.Storable
import Foreign.Marshal
#if !sh_SAFE_DEFAULT
import GHC.IO (IO)
import qualified System.IO.Unsafe (unsafePerformIO)
......@@ -59,5 +52,4 @@ import qualified System.IO.Unsafe (unsafePerformIO)
{-# INLINE unsafePerformIO #-}
unsafePerformIO :: IO a -> a
unsafePerformIO = System.IO.Unsafe.unsafePerformIO
#endif
......@@ -24,3 +24,4 @@ module Foreign.C
import Foreign.C.Types
import Foreign.C.String
import Foreign.C.Error
......@@ -616,3 +616,4 @@ errnoToIOError loc errno maybeHdl maybeName = unsafePerformIO $ do
#endif
foreign import ccall unsafe "string.h" strerror :: Errno -> IO (Ptr CChar)
......@@ -541,3 +541,4 @@ castCharToCWchar :: Char -> CWchar
castCharToCWchar ch = fromIntegral (ord ch)
#endif /* !mingw32_HOST_OS */
......@@ -331,3 +331,4 @@ INSTANCE_BITS(CIntMax)
INSTANCE_BITS(CUIntMax)
#endif
{-# LANGUAGE CPP, NoImplicitPrelude #-}
#if sh_SAFE_DEFAULT
{-# LANGUAGE Trustworthy #-}
#else
{-# LANGUAGE Unsafe #-}
#endif
{-# LANGUAGE CPP, NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
......@@ -23,16 +19,41 @@
-----------------------------------------------------------------------------
module Foreign.ForeignPtr (
module Foreign.ForeignPtr.Safe
#if !sh_SAFE_DEFAULT
-- * 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
-- ** Unsafe low-level operations
, unsafeForeignPtrToPtr
#endif
) where
import Foreign.ForeignPtr.Safe
#if !sh_SAFE_DEFAULT
import Foreign.Ptr ( Ptr )
import qualified Foreign.ForeignPtr.Unsafe as U
......@@ -40,5 +61,4 @@ import qualified Foreign.ForeignPtr.Unsafe as U
{-# INLINE unsafeForeignPtrToPtr #-}
unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a
unsafeForeignPtrToPtr = U.unsafeForeignPtrToPtr
#endif
......@@ -179,3 +179,4 @@ mallocForeignPtrArray = doMalloc undefined
-- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'.
mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a)
mallocForeignPtrArray0 size = mallocForeignPtrArray (size + 1)
......@@ -245,3 +245,4 @@ foreign import ccall unsafe "stdlib.h free" _free :: Ptr a -> IO ()
-- used as a finalizer (cf 'Foreign.ForeignPtr.ForeignPtr') for storage
-- allocated with 'malloc', 'mallocBytes', 'realloc' or 'reallocBytes'.
foreign import ccall unsafe "stdlib.h &free" finalizerFree :: FinalizerPtr a
......@@ -277,3 +277,4 @@ advancePtr = doAdvance undefined
where
doAdvance :: Storable a' => a' -> Ptr a' -> Int -> Ptr a'
doAdvance dummy ptr i = ptr `plusPtr` (i * sizeOf dummy)
......@@ -83,3 +83,4 @@ throwIfNull = throwIf (== nullPtr) . const
--
void :: IO a -> IO ()
void act = act >> return ()
......@@ -209,3 +209,4 @@ pooledNewArray0 pool marker vals = do
ptr <- pooledMallocArray0 pool (length vals)
pokeArray0 marker ptr vals
return ptr
......@@ -178,3 +178,4 @@ moveBytes dest src size = do _ <- memmove dest src (fromIntegral size)
--
foreign import ccall unsafe "string.h" memcpy :: Ptr a -> Ptr a -> CSize -> IO (Ptr a)
foreign import ccall unsafe "string.h" memmove :: Ptr a -> Ptr a -> CSize -> IO (Ptr a)
......@@ -162,3 +162,4 @@ foreign import ccall unsafe "__hscore_from_intptr"
# endif /* !__GLASGOW_HASKELL__ */
#endif /* !__NHC_ */
......@@ -61,3 +61,4 @@ import NHC.FFI
-- guarantee provided is that if they are passed back to Haskell land, the
-- function 'deRefStablePtr' will be able to reconstruct the
-- Haskell value referred to by the stable pointer.
......@@ -284,3 +284,4 @@ pokeFingerprint p0 (Fingerprint high low) = do
pokeW64 (castPtr p0) 8 high
pokeW64 (castPtr p0 `plusPtr` 8) 8 low
#endif
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP
, NoImplicitPrelude
, MagicHash
......
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples, ForeignFunctionInterface,
DeriveDataTypeable #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
......@@ -324,3 +324,4 @@ foreign import ccall unsafe "sendIOManagerEvent" -- in the RTS (ThrIOManager.c)
foreign import stdcall "WaitForSingleObject"
c_WaitForSingleObject :: HANDLE -> DWORD -> IO DWORD