From fc6c3c6e5a508b74bed8559c2e4ff6bf74b9ae92 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Wed, 5 Mar 2008 03:37:12 +0000 Subject: [PATCH 1/1] untabify --- Data/Bool.hs | 8 +- Data/Char.hs | 8 +- Data/HashTable.hs | 66 ++++++------- Data/Typeable.hs | 274 +++++++++++++++++++++++++-------------------------- Foreign/Ptr.hs | 18 ++-- Foreign/Storable.hs | 66 ++++++------- GHC/Pack.lhs | 32 +++--- GHC/Ptr.lhs | 6 +- GHC/Stable.lhs | 18 ++-- GHC/Storable.lhs | 66 ++++++------- Text/Show.hs | 22 ++--- include/CTypes.h | 12 +-- 12 files changed, 298 insertions(+), 298 deletions(-) diff --git a/Data/Bool.hs b/Data/Bool.hs index 0e14538..de5b3b0 100644 --- a/Data/Bool.hs +++ b/Data/Bool.hs @@ -17,10 +17,10 @@ module Data.Bool ( -- * Booleans Bool(..), -- ** Operations - (&&), -- :: Bool -> Bool -> Bool - (||), -- :: Bool -> Bool -> Bool - not, -- :: Bool -> Bool - otherwise, -- :: Bool + (&&), -- :: Bool -> Bool -> Bool + (||), -- :: Bool -> Bool -> Bool + not, -- :: Bool -> Bool + otherwise, -- :: Bool ) where #ifdef __GLASGOW_HASKELL__ diff --git a/Data/Char.hs b/Data/Char.hs index f770999..11eb084 100644 --- a/Data/Char.hs +++ b/Data/Char.hs @@ -13,7 +13,7 @@ -- ----------------------------------------------------------------------------- -module Data.Char +module Data.Char ( Char @@ -48,7 +48,7 @@ module Data.Char -- * String representations , showLitChar -- :: Char -> ShowS - , lexLitChar -- :: ReadS String + , lexLitChar -- :: ReadS String , readLitChar -- :: ReadS Char -- Implementation checked wrt. Haskell 98 lib report, 1/99. @@ -85,10 +85,10 @@ foreign import ccall unsafe "WCsubst.h u_gencat" wgencat :: CInt -> CInt -- (i.e. @\'0\'@..@\'9\'@, @\'a\'@..@\'f\'@, @\'A\'@..@\'F\'@). digitToInt :: Char -> Int digitToInt c - | isDigit c = ord c - ord '0' + | isDigit c = ord c - ord '0' | c >= 'a' && c <= 'f' = ord c - ord 'a' + 10 | c >= 'A' && c <= 'F' = ord c - ord 'A' + 10 - | otherwise = error ("Char.digitToInt: not a digit " ++ show c) -- sigh + | otherwise = error ("Char.digitToInt: not a digit " ++ show c) -- sigh #ifndef __GLASGOW_HASKELL__ isAsciiUpper, isAsciiLower :: Char -> Bool diff --git a/Data/HashTable.hs b/Data/HashTable.hs index 3db6cc9..ed0fb8f 100644 --- a/Data/HashTable.hs +++ b/Data/HashTable.hs @@ -18,16 +18,16 @@ ----------------------------------------------------------------------------- module Data.HashTable ( - -- * Basic hash table operations - HashTable, new, insert, delete, lookup, update, - -- * Converting to and from lists - fromList, toList, - -- * Hash functions - -- $hash_functions - hashInt, hashString, - prime, - -- * Diagnostics - longestChain + -- * Basic hash table operations + HashTable, new, insert, delete, lookup, update, + -- * Converting to and from lists + fromList, toList, + -- * Hash functions + -- $hash_functions + hashInt, hashString, + prime, + -- * Diagnostics + longestChain ) where -- This module is imported by Data.Dynamic, which is pretty low down in the @@ -36,36 +36,36 @@ module Data.HashTable ( #ifdef __GLASGOW_HASKELL__ import GHC.Base #else -import Prelude hiding ( lookup ) +import Prelude hiding ( lookup ) #endif -import Data.Tuple ( fst ) +import Data.Tuple ( fst ) import Data.Bits import Data.Maybe -import Data.List ( maximumBy, length, concat, foldl', partition ) -import Data.Int ( Int32 ) +import Data.List ( maximumBy, length, concat, foldl', partition ) +import Data.Int ( Int32 ) #if defined(__GLASGOW_HASKELL__) import GHC.Num -import GHC.Real ( fromIntegral ) -import GHC.Show ( Show(..) ) -import GHC.Int ( Int64 ) +import GHC.Real ( fromIntegral ) +import GHC.Show ( Show(..) ) +import GHC.Int ( Int64 ) -import GHC.IOBase ( IO, IOArray, newIOArray, - unsafeReadIOArray, unsafeWriteIOArray, unsafePerformIO, - IORef, newIORef, readIORef, writeIORef ) +import GHC.IOBase ( IO, IOArray, newIOArray, + unsafeReadIOArray, unsafeWriteIOArray, unsafePerformIO, + IORef, newIORef, readIORef, writeIORef ) #else -import Data.Char ( ord ) -import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) -import System.IO.Unsafe ( unsafePerformIO ) -import Data.Int ( Int64 ) +import Data.Char ( ord ) +import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) +import System.IO.Unsafe ( unsafePerformIO ) +import Data.Int ( Int64 ) # if defined(__HUGS__) -import Hugs.IOArray ( IOArray, newIOArray, - unsafeReadIOArray, unsafeWriteIOArray ) +import Hugs.IOArray ( IOArray, newIOArray, + unsafeReadIOArray, unsafeWriteIOArray ) # elif defined(__NHC__) -import NHC.IOExtras ( IOArray, newIOArray, readIOArray, writeIOArray ) +import NHC.IOExtras ( IOArray, newIOArray, readIOArray, writeIOArray ) # endif #endif -import Control.Monad ( mapM, mapM_, sequence_ ) +import Control.Monad ( mapM, mapM_, sequence_ ) ----------------------------------------------------------------------- @@ -101,17 +101,17 @@ thawArray = return -- unsafeThaw #endif data HashTable key val = HashTable { - cmp :: !(key -> key -> Bool), - hash_fn :: !(key -> Int32), + cmp :: !(key -> key -> Bool), + hash_fn :: !(key -> Int32), tab :: !(IORef (HT key val)) } -- TODO: the IORef should really be an MVar. data HT key val = HT { - kcount :: !Int32, -- Total number of keys. + kcount :: !Int32, -- Total number of keys. bmask :: !Int32, - buckets :: !(HTArray [(key,val)]) + buckets :: !(HTArray [(key,val)]) } -- ------------------------------------------------------------ @@ -278,7 +278,7 @@ hYSTERESIS = 64 -- entries to ignore in load computation -- new :: (key -> key -> Bool) -- ^ @eq@: An equality comparison on keys - -> (key -> Int32) -- ^ @hash@: A hash function on keys + -> (key -> Int32) -- ^ @hash@: A hash function on keys -> IO (HashTable key val) -- ^ Returns: an empty hash table new cmpr hash = do diff --git a/Data/Typeable.hs b/Data/Typeable.hs index 8d3e74c..c0a8cf9 100644 --- a/Data/Typeable.hs +++ b/Data/Typeable.hs @@ -2,9 +2,9 @@ -- The -fallow-overlapping-instances flag allows the user to over-ride -- the instances for Typeable given here. In particular, we provide an instance --- instance ... => Typeable (s a) +-- instance ... => Typeable (s a) -- But a user might want to say --- instance ... => Typeable (MyType a b) +-- instance ... => Typeable (MyType a b) ----------------------------------------------------------------------------- -- | @@ -30,54 +30,54 @@ module Data.Typeable ( - -- * The Typeable class - Typeable( typeOf ), -- :: a -> TypeRep - - -- * Type-safe cast - cast, -- :: (Typeable a, Typeable b) => a -> Maybe b - gcast, -- a generalisation of cast - - -- * Type representations - TypeRep, -- abstract, instance of: Eq, Show, Typeable - TyCon, -- abstract, instance of: Eq, Show, Typeable - showsTypeRep, - - -- * Construction of type representations - mkTyCon, -- :: String -> TyCon - mkTyConApp, -- :: TyCon -> [TypeRep] -> TypeRep - mkAppTy, -- :: TypeRep -> TypeRep -> TypeRep - mkFunTy, -- :: TypeRep -> TypeRep -> TypeRep - - -- * Observation of type representations - splitTyConApp, -- :: TypeRep -> (TyCon, [TypeRep]) - funResultTy, -- :: TypeRep -> TypeRep -> Maybe TypeRep - typeRepTyCon, -- :: TypeRep -> TyCon - typeRepArgs, -- :: TypeRep -> [TypeRep] - tyConString, -- :: TyCon -> String - typeRepKey, -- :: TypeRep -> IO Int - - -- * The other Typeable classes - -- | /Note:/ The general instances are provided for GHC only. - Typeable1( typeOf1 ), -- :: t a -> TypeRep - Typeable2( typeOf2 ), -- :: t a b -> TypeRep - Typeable3( typeOf3 ), -- :: t a b c -> TypeRep - Typeable4( typeOf4 ), -- :: t a b c d -> TypeRep - Typeable5( typeOf5 ), -- :: t a b c d e -> TypeRep - Typeable6( typeOf6 ), -- :: t a b c d e f -> TypeRep - Typeable7( typeOf7 ), -- :: t a b c d e f g -> TypeRep - gcast1, -- :: ... => c (t a) -> Maybe (c (t' a)) - gcast2, -- :: ... => c (t a b) -> Maybe (c (t' a b)) - - -- * Default instances - -- | /Note:/ These are not needed by GHC, for which these instances - -- are generated by general instance declarations. - typeOfDefault, -- :: (Typeable1 t, Typeable a) => t a -> TypeRep - typeOf1Default, -- :: (Typeable2 t, Typeable a) => t a b -> TypeRep - typeOf2Default, -- :: (Typeable3 t, Typeable a) => t a b c -> TypeRep - typeOf3Default, -- :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep - typeOf4Default, -- :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep - typeOf5Default, -- :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep - typeOf6Default -- :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep + -- * The Typeable class + Typeable( typeOf ), -- :: a -> TypeRep + + -- * Type-safe cast + cast, -- :: (Typeable a, Typeable b) => a -> Maybe b + gcast, -- a generalisation of cast + + -- * Type representations + TypeRep, -- abstract, instance of: Eq, Show, Typeable + TyCon, -- abstract, instance of: Eq, Show, Typeable + showsTypeRep, + + -- * Construction of type representations + mkTyCon, -- :: String -> TyCon + mkTyConApp, -- :: TyCon -> [TypeRep] -> TypeRep + mkAppTy, -- :: TypeRep -> TypeRep -> TypeRep + mkFunTy, -- :: TypeRep -> TypeRep -> TypeRep + + -- * Observation of type representations + splitTyConApp, -- :: TypeRep -> (TyCon, [TypeRep]) + funResultTy, -- :: TypeRep -> TypeRep -> Maybe TypeRep + typeRepTyCon, -- :: TypeRep -> TyCon + typeRepArgs, -- :: TypeRep -> [TypeRep] + tyConString, -- :: TyCon -> String + typeRepKey, -- :: TypeRep -> IO Int + + -- * The other Typeable classes + -- | /Note:/ The general instances are provided for GHC only. + Typeable1( typeOf1 ), -- :: t a -> TypeRep + Typeable2( typeOf2 ), -- :: t a b -> TypeRep + Typeable3( typeOf3 ), -- :: t a b c -> TypeRep + Typeable4( typeOf4 ), -- :: t a b c d -> TypeRep + Typeable5( typeOf5 ), -- :: t a b c d e -> TypeRep + Typeable6( typeOf6 ), -- :: t a b c d e f -> TypeRep + Typeable7( typeOf7 ), -- :: t a b c d e f g -> TypeRep + gcast1, -- :: ... => c (t a) -> Maybe (c (t' a)) + gcast2, -- :: ... => c (t a b) -> Maybe (c (t' a b)) + + -- * Default instances + -- | /Note:/ These are not needed by GHC, for which these instances + -- are generated by general instance declarations. + typeOfDefault, -- :: (Typeable1 t, Typeable a) => t a -> TypeRep + typeOf1Default, -- :: (Typeable2 t, Typeable a) => t a b -> TypeRep + typeOf2Default, -- :: (Typeable3 t, Typeable a) => t a b c -> TypeRep + typeOf3Default, -- :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep + typeOf4Default, -- :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep + typeOf5Default, -- :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep + typeOf6Default -- :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep ) where @@ -95,45 +95,45 @@ import GHC.Show import GHC.Err import GHC.Num import GHC.Float -import GHC.Real ( rem, Ratio ) -import GHC.IOBase (IORef,newIORef,unsafePerformIO) +import GHC.Real ( rem, Ratio ) +import GHC.IOBase (IORef,newIORef,unsafePerformIO) -- These imports are so we can define Typeable instances -- It'd be better to give Typeable instances in the modules themselves -- but they all have to be compiled before Typeable -import GHC.IOBase ( IO, MVar, Exception, ArithException, IOException, - ArrayException, AsyncException, Handle ) -import GHC.ST ( ST ) -import GHC.STRef ( STRef ) +import GHC.IOBase ( IO, MVar, Exception, ArithException, IOException, + ArrayException, AsyncException, Handle ) +import GHC.ST ( ST ) +import GHC.STRef ( STRef ) import GHC.Ptr ( Ptr, FunPtr ) import GHC.ForeignPtr ( ForeignPtr ) -import GHC.Stable ( StablePtr, newStablePtr, freeStablePtr, - deRefStablePtr, castStablePtrToPtr, - castPtrToStablePtr ) -import GHC.Exception ( block ) -import GHC.Arr ( Array, STArray ) +import GHC.Stable ( StablePtr, newStablePtr, freeStablePtr, + deRefStablePtr, castStablePtrToPtr, + castPtrToStablePtr ) +import GHC.Exception ( block ) +import GHC.Arr ( Array, STArray ) #endif #ifdef __HUGS__ -import Hugs.Prelude ( Key(..), TypeRep(..), TyCon(..), Ratio, - Exception, ArithException, IOException, - ArrayException, AsyncException, Handle, - Ptr, FunPtr, ForeignPtr, StablePtr ) -import Hugs.IORef ( IORef, newIORef, readIORef, writeIORef ) -import Hugs.IOExts ( unsafePerformIO ) - -- For the Typeable instance -import Hugs.Array ( Array ) -import Hugs.ConcBase ( MVar ) +import Hugs.Prelude ( Key(..), TypeRep(..), TyCon(..), Ratio, + Exception, ArithException, IOException, + ArrayException, AsyncException, Handle, + Ptr, FunPtr, ForeignPtr, StablePtr ) +import Hugs.IORef ( IORef, newIORef, readIORef, writeIORef ) +import Hugs.IOExts ( unsafePerformIO ) + -- For the Typeable instance +import Hugs.Array ( Array ) +import Hugs.ConcBase ( MVar ) #endif #ifdef __NHC__ import NHC.IOExtras (IORef,newIORef,readIORef,writeIORef,unsafePerformIO) import IO (Handle) import Ratio (Ratio) - -- For the Typeable instance -import NHC.FFI ( Ptr,FunPtr,StablePtr,ForeignPtr ) -import Array ( Array ) + -- For the Typeable instance +import NHC.FFI ( Ptr,FunPtr,StablePtr,ForeignPtr ) +import Array ( Array ) #endif #include "Typeable.h" @@ -142,7 +142,7 @@ import Array ( Array ) ------------------------------------------------------------- -- --- Type representations +-- Type representations -- ------------------------------------------------------------- @@ -175,16 +175,16 @@ instance Eq TyCon where typeRepKey :: TypeRep -> IO Int typeRepKey (TypeRep (Key i) _ _) = return i - -- - -- let fTy = mkTyCon "Foo" in show (mkTyConApp (mkTyCon ",,") - -- [fTy,fTy,fTy]) - -- - -- returns "(Foo,Foo,Foo)" - -- - -- The TypeRep Show instance promises to print tuple types - -- correctly. Tuple type constructors are specified by a - -- sequence of commas, e.g., (mkTyCon ",,,,") returns - -- the 5-tuple tycon. + -- + -- let fTy = mkTyCon "Foo" in show (mkTyConApp (mkTyCon ",,") + -- [fTy,fTy,fTy]) + -- + -- returns "(Foo,Foo,Foo)" + -- + -- The TypeRep Show instance promises to print tuple types + -- correctly. Tuple type constructors are specified by a + -- sequence of commas, e.g., (mkTyCon ",,,,") returns + -- the 5-tuple tycon. ----------------- Construction -------------------- @@ -238,10 +238,10 @@ mkAppTy (TypeRep tr_k tc trs) arg_tr -- > mkTyCon "a" == mkTyCon "a" -- -mkTyCon :: String -- ^ the name of the type constructor (should be unique - -- in the program, so it might be wise to use the - -- fully qualified name). - -> TyCon -- ^ A unique 'TyCon' object +mkTyCon :: String -- ^ the name of the type constructor (should be unique + -- in the program, so it might be wise to use the + -- fully qualified name). + -> TyCon -- ^ A unique 'TyCon' object mkTyCon str = TyCon (mkTyConKey str) str ----------------- Observation --------------------- @@ -266,15 +266,15 @@ instance Show TypeRep where [] -> showsPrec p tycon [x] | tycon == listTc -> showChar '[' . shows x . showChar ']' [a,r] | tycon == funTc -> showParen (p > 8) $ - showsPrec 9 a . + showsPrec 9 a . showString " -> " . showsPrec 8 r xs | isTupleTyCon tycon -> showTuple xs - | otherwise -> - showParen (p > 9) $ - showsPrec p tycon . - showChar ' ' . - showArgs tys + | otherwise -> + showParen (p > 9) $ + showsPrec p tycon . + showChar ' ' . + showArgs tys showsTypeRep :: TypeRep -> ShowS showsTypeRep = shows @@ -284,7 +284,7 @@ instance Show TyCon where isTupleTyCon :: TyCon -> Bool isTupleTyCon (TyCon _ ('(':',':_)) = True -isTupleTyCon _ = False +isTupleTyCon _ = False -- Some (Show.TypeRep) helpers: @@ -301,7 +301,7 @@ showTuple args = showChar '(' ------------------------------------------------------------- -- --- The Typeable class and friends +-- The Typeable class and friends -- ------------------------------------------------------------- @@ -437,7 +437,7 @@ instance (Typeable7 s, Typeable a) ------------------------------------------------------------- -- --- Type-safe cast +-- Type-safe cast -- ------------------------------------------------------------- @@ -445,9 +445,9 @@ instance (Typeable7 s, Typeable a) cast :: (Typeable a, Typeable b) => a -> Maybe b cast x = r where - r = if typeOf x == typeOf (fromJust r) + r = if typeOf x == typeOf (fromJust r) then Just $ unsafeCoerce x - else Nothing + else Nothing -- | A flexible variation parameterised in a type constructor gcast :: (Typeable a, Typeable b) => c a -> Maybe (c b) @@ -481,7 +481,7 @@ gcast2 x = r ------------------------------------------------------------- -- --- Instances of the Typeable classes for Prelude types +-- Instances of the Typeable classes for Prelude types -- ------------------------------------------------------------- @@ -588,7 +588,7 @@ INSTANCE_TYPEABLE0(RealWorld,realWorldTc,"RealWorld") --------------------------------------------- -- --- Internals +-- Internals -- --------------------------------------------- @@ -601,9 +601,9 @@ data KeyPr = KeyPr !Key !Key deriving( Eq ) hashKP :: KeyPr -> Int32 hashKP (KeyPr (Key k1) (Key k2)) = (HT.hashInt k1 + HT.hashInt k2) `rem` HT.prime -data Cache = Cache { next_key :: !(IORef Key), -- Not used by GHC (calls genSym instead) - tc_tbl :: !(HT.HashTable String Key), - ap_tbl :: !(HT.HashTable KeyPr Key) } +data Cache = Cache { next_key :: !(IORef Key), -- Not used by GHC (calls genSym instead) + tc_tbl :: !(HT.HashTable String Key), + ap_tbl :: !(HT.HashTable KeyPr Key) } {-# NOINLINE cache #-} #ifdef __GLASGOW_HASKELL__ @@ -613,25 +613,25 @@ foreign import ccall unsafe "RtsTypeable.h getOrSetTypeableStore" cache :: Cache cache = unsafePerformIO $ do - empty_tc_tbl <- HT.new (==) HT.hashString - empty_ap_tbl <- HT.new (==) hashKP - key_loc <- newIORef (Key 1) - let ret = Cache { next_key = key_loc, - tc_tbl = empty_tc_tbl, - ap_tbl = empty_ap_tbl } + empty_tc_tbl <- HT.new (==) HT.hashString + empty_ap_tbl <- HT.new (==) hashKP + key_loc <- newIORef (Key 1) + let ret = Cache { next_key = key_loc, + tc_tbl = empty_tc_tbl, + ap_tbl = empty_ap_tbl } #ifdef __GLASGOW_HASKELL__ - block $ do - stable_ref <- newStablePtr ret - let ref = castStablePtrToPtr stable_ref - ref2 <- getOrSetTypeableStore ref - if ref==ref2 - then deRefStablePtr stable_ref - else do - freeStablePtr stable_ref - deRefStablePtr - (castPtrToStablePtr ref2) + block $ do + stable_ref <- newStablePtr ret + let ref = castStablePtrToPtr stable_ref + ref2 <- getOrSetTypeableStore ref + if ref==ref2 + then deRefStablePtr stable_ref + else do + freeStablePtr stable_ref + deRefStablePtr + (castPtrToStablePtr ref2) #else - return ret + return ret #endif newKey :: IORef Key -> IO Key @@ -639,8 +639,8 @@ newKey :: IORef Key -> IO Key newKey kloc = do i <- genSym; return (Key i) #else newKey kloc = do { k@(Key i) <- readIORef kloc ; - writeIORef kloc (Key (i+1)) ; - return k } + writeIORef kloc (Key (i+1)) ; + return k } #endif #ifdef __GLASGOW_HASKELL__ @@ -651,24 +651,24 @@ foreign import ccall unsafe "genSymZh" mkTyConKey :: String -> Key mkTyConKey str = unsafePerformIO $ do - let Cache {next_key = kloc, tc_tbl = tbl} = cache - mb_k <- HT.lookup tbl str - case mb_k of - Just k -> return k - Nothing -> do { k <- newKey kloc ; - HT.insert tbl str k ; - return k } + let Cache {next_key = kloc, tc_tbl = tbl} = cache + mb_k <- HT.lookup tbl str + case mb_k of + Just k -> return k + Nothing -> do { k <- newKey kloc ; + HT.insert tbl str k ; + return k } appKey :: Key -> Key -> Key appKey k1 k2 = unsafePerformIO $ do - let Cache {next_key = kloc, ap_tbl = tbl} = cache - mb_k <- HT.lookup tbl kpr - case mb_k of - Just k -> return k - Nothing -> do { k <- newKey kloc ; - HT.insert tbl kpr k ; - return k } + let Cache {next_key = kloc, ap_tbl = tbl} = cache + mb_k <- HT.lookup tbl kpr + case mb_k of + Just k -> return k + Nothing -> do { k <- newKey kloc ; + HT.insert tbl kpr k ; + return k } where kpr = KeyPr k1 k2 diff --git a/Foreign/Ptr.hs b/Foreign/Ptr.hs index 90d395f..a394074 100644 --- a/Foreign/Ptr.hs +++ b/Foreign/Ptr.hs @@ -18,22 +18,22 @@ module Foreign.Ptr ( -- * Data pointers - + Ptr, -- data Ptr a nullPtr, -- :: Ptr a castPtr, -- :: Ptr a -> Ptr b plusPtr, -- :: Ptr a -> Int -> Ptr b alignPtr, -- :: Ptr a -> Int -> Ptr a minusPtr, -- :: Ptr a -> Ptr b -> Int - + -- * Function pointers - + FunPtr, -- data FunPtr a nullFunPtr, -- :: FunPtr a castFunPtr, -- :: FunPtr a -> FunPtr b castFunPtrToPtr, -- :: FunPtr a -> Ptr b castPtrToFunPtr, -- :: Ptr a -> FunPtr b - + freeHaskellFunPtr, -- :: FunPtr a -> IO () -- Free the function pointer created by foreign export dynamic. @@ -57,17 +57,17 @@ import GHC.Read import GHC.Real import GHC.Show import GHC.Enum -import GHC.Word ( Word(..) ) +import GHC.Word ( Word(..) ) import Data.Int import Data.Word #else -import Control.Monad ( liftM ) +import Control.Monad ( liftM ) import Foreign.C.Types #endif import Data.Bits -import Data.Typeable ( Typeable(..), mkTyCon, mkTyConApp ) +import Data.Typeable ( Typeable(..), mkTyCon, mkTyConApp ) import Foreign.Storable ( Storable(..) ) #ifdef __NHC__ @@ -108,12 +108,12 @@ foreign import ccall unsafe "freeHaskellFunctionPtr" -- | An unsigned integral type that can be losslessly converted to and from -- @Ptr@. INTEGRAL_TYPE(WordPtr,tyConWordPtr,"WordPtr",Word) - -- Word and Int are guaranteed pointer-sized in GHC + -- Word and Int are guaranteed pointer-sized in GHC -- | A signed integral type that can be losslessly converted to and from -- @Ptr@. INTEGRAL_TYPE(IntPtr,tyConIntPtr,"IntPtr",Int) - -- Word and Int are guaranteed pointer-sized in GHC + -- Word and Int are guaranteed pointer-sized in GHC -- | casts a @Ptr@ to a @WordPtr@ ptrToWordPtr :: Ptr a -> WordPtr diff --git a/Foreign/Storable.hs b/Foreign/Storable.hs index 3f05449..f77ffff 100644 --- a/Foreign/Storable.hs +++ b/Foreign/Storable.hs @@ -17,15 +17,15 @@ ----------------------------------------------------------------------------- module Foreign.Storable - ( Storable( - sizeOf, -- :: a -> Int - alignment, -- :: a -> Int - peekElemOff, -- :: Ptr a -> Int -> IO a - pokeElemOff, -- :: Ptr a -> Int -> a -> IO () - peekByteOff, -- :: Ptr b -> Int -> IO a - pokeByteOff, -- :: Ptr b -> Int -> a -> IO () - peek, -- :: Ptr a -> IO a - poke) -- :: Ptr a -> a -> IO () + ( Storable( + sizeOf, -- :: a -> Int + alignment, -- :: a -> Int + peekElemOff, -- :: Ptr a -> Int -> IO a + pokeElemOff, -- :: Ptr a -> Int -> a -> IO () + peekByteOff, -- :: Ptr b -> Int -> IO a + pokeByteOff, -- :: Ptr b -> Int -> a -> IO () + peek, -- :: Ptr a -> IO a + poke) -- :: Ptr a -> a -> IO () ) where @@ -34,14 +34,14 @@ import NHC.FFI (Storable(..),Ptr,FunPtr,StablePtr ,Int8,Int16,Int32,Int64,Word8,Word16,Word32,Word64) #else -import Control.Monad ( liftM ) +import Control.Monad ( liftM ) #include "MachDeps.h" #include "HsBaseConfig.h" #ifdef __GLASGOW_HASKELL__ import GHC.Storable -import GHC.Stable ( StablePtr ) +import GHC.Stable ( StablePtr ) import GHC.Num import GHC.Int import GHC.Word @@ -180,66 +180,66 @@ instance Storable Bool where peekElemOff p i = liftM (/= (0::HTYPE_INT)) $ peekElemOff (castPtr p) i pokeElemOff p i x = pokeElemOff (castPtr p) i (if x then 1 else 0::HTYPE_INT) -#define STORABLE(T,size,align,read,write) \ -instance Storable (T) where { \ - sizeOf _ = size; \ - alignment _ = align; \ - peekElemOff = read; \ +#define STORABLE(T,size,align,read,write) \ +instance Storable (T) where { \ + sizeOf _ = size; \ + alignment _ = align; \ + peekElemOff = read; \ pokeElemOff = write } #ifdef __GLASGOW_HASKELL__ STORABLE(Char,SIZEOF_INT32,ALIGNMENT_INT32, - readWideCharOffPtr,writeWideCharOffPtr) + readWideCharOffPtr,writeWideCharOffPtr) #elif defined(__HUGS__) STORABLE(Char,SIZEOF_HSCHAR,ALIGNMENT_HSCHAR, - readCharOffPtr,writeCharOffPtr) + readCharOffPtr,writeCharOffPtr) #endif STORABLE(Int,SIZEOF_HSINT,ALIGNMENT_HSINT, - readIntOffPtr,writeIntOffPtr) + readIntOffPtr,writeIntOffPtr) #ifndef __NHC__ STORABLE(Word,SIZEOF_HSWORD,ALIGNMENT_HSWORD, - readWordOffPtr,writeWordOffPtr) + readWordOffPtr,writeWordOffPtr) #endif STORABLE((Ptr a),SIZEOF_HSPTR,ALIGNMENT_HSPTR, - readPtrOffPtr,writePtrOffPtr) + readPtrOffPtr,writePtrOffPtr) STORABLE((FunPtr a),SIZEOF_HSFUNPTR,ALIGNMENT_HSFUNPTR, - readFunPtrOffPtr,writeFunPtrOffPtr) + readFunPtrOffPtr,writeFunPtrOffPtr) STORABLE((StablePtr a),SIZEOF_HSSTABLEPTR,ALIGNMENT_HSSTABLEPTR, - readStablePtrOffPtr,writeStablePtrOffPtr) + readStablePtrOffPtr,writeStablePtrOffPtr) STORABLE(Float,SIZEOF_HSFLOAT,ALIGNMENT_HSFLOAT, - readFloatOffPtr,writeFloatOffPtr) + readFloatOffPtr,writeFloatOffPtr) STORABLE(Double,SIZEOF_HSDOUBLE,ALIGNMENT_HSDOUBLE, - readDoubleOffPtr,writeDoubleOffPtr) + readDoubleOffPtr,writeDoubleOffPtr) STORABLE(Word8,SIZEOF_WORD8,ALIGNMENT_WORD8, - readWord8OffPtr,writeWord8OffPtr) + readWord8OffPtr,writeWord8OffPtr) STORABLE(Word16,SIZEOF_WORD16,ALIGNMENT_WORD16, - readWord16OffPtr,writeWord16OffPtr) + readWord16OffPtr,writeWord16OffPtr) STORABLE(Word32,SIZEOF_WORD32,ALIGNMENT_WORD32, - readWord32OffPtr,writeWord32OffPtr) + readWord32OffPtr,writeWord32OffPtr) STORABLE(Word64,SIZEOF_WORD64,ALIGNMENT_WORD64, - readWord64OffPtr,writeWord64OffPtr) + readWord64OffPtr,writeWord64OffPtr) STORABLE(Int8,SIZEOF_INT8,ALIGNMENT_INT8, - readInt8OffPtr,writeInt8OffPtr) + readInt8OffPtr,writeInt8OffPtr) STORABLE(Int16,SIZEOF_INT16,ALIGNMENT_INT16, - readInt16OffPtr,writeInt16OffPtr) + readInt16OffPtr,writeInt16OffPtr) STORABLE(Int32,SIZEOF_INT32,ALIGNMENT_INT32, - readInt32OffPtr,writeInt32OffPtr) + readInt32OffPtr,writeInt32OffPtr) STORABLE(Int64,SIZEOF_INT64,ALIGNMENT_INT64, - readInt64OffPtr,writeInt64OffPtr) + readInt64OffPtr,writeInt64OffPtr) #endif diff --git a/GHC/Pack.lhs b/GHC/Pack.lhs index d9c47db..4867e0c 100644 --- a/GHC/Pack.lhs +++ b/GHC/Pack.lhs @@ -23,16 +23,16 @@ -- #hide module GHC.Pack ( - -- (**) - emitted by compiler. + -- (**) - emitted by compiler. - packCString#, -- :: [Char] -> ByteArray# (**) - unpackCString, - unpackCString#, -- :: Addr# -> [Char] (**) - unpackNBytes#, -- :: Addr# -> Int# -> [Char] (**) - unpackFoldrCString#, -- (**) - unpackAppendCString#, -- (**) + packCString#, -- :: [Char] -> ByteArray# (**) + unpackCString, + unpackCString#, -- :: Addr# -> [Char] (**) + unpackNBytes#, -- :: Addr# -> Int# -> [Char] (**) + unpackFoldrCString#, -- (**) + unpackAppendCString#, -- (**) ) - where + where import GHC.Base import GHC.Err ( error ) @@ -41,15 +41,15 @@ import GHC.ST import GHC.Num import GHC.Ptr -data ByteArray ix = ByteArray ix ix ByteArray# +data ByteArray ix = ByteArray ix ix ByteArray# data MutableByteArray s ix = MutableByteArray ix ix (MutableByteArray# s) unpackCString :: Ptr a -> [Char] unpackCString a@(Ptr addr) | a == nullPtr = [] - | otherwise = unpackCString# addr + | otherwise = unpackCString# addr -packCString# :: [Char] -> ByteArray# +packCString# :: [Char] -> ByteArray# packCString# str = case (packString str) of { ByteArray _ _ bytes -> bytes } packString :: [Char] -> ByteArray Int @@ -78,23 +78,23 @@ packNBytesST (I# length#) str = return () fill_in arr_in# idx (C# c : cs) = - write_ps_array arr_in# idx c >> + write_ps_array arr_in# idx c >> fill_in arr_in# (idx +# 1#) cs -- (Very :-) ``Specialised'' versions of some CharArray things... -new_ps_array :: Int# -> ST s (MutableByteArray s Int) -write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s () +new_ps_array :: Int# -> ST s (MutableByteArray s Int) +write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s () freeze_ps_array :: MutableByteArray s Int -> Int# -> ST s (ByteArray Int) new_ps_array size = ST $ \ s -> - case (newByteArray# size s) of { (# s2#, barr# #) -> + case (newByteArray# size s) of { (# s2#, barr# #) -> (# s2#, MutableByteArray bot bot barr# #) } where bot = error "new_ps_array" write_ps_array (MutableByteArray _ _ barr#) n ch = ST $ \ s# -> - case writeCharArray# barr# n ch s# of { s2# -> + case writeCharArray# barr# n ch s# of { s2# -> (# s2#, () #) } -- same as unsafeFreezeByteArray diff --git a/GHC/Ptr.lhs b/GHC/Ptr.lhs index 8763a3e..0b5679f 100644 --- a/GHC/Ptr.lhs +++ b/GHC/Ptr.lhs @@ -22,7 +22,7 @@ import GHC.Base import GHC.Show import GHC.Num import GHC.List ( length, replicate ) -import Numeric ( showHex ) +import Numeric ( showHex ) #include "MachDeps.h" @@ -153,10 +153,10 @@ instance Show (Ptr a) where where -- want 0s prefixed to pad it out to a fixed length. pad_out ls rs = - '0':'x':(replicate (2*SIZEOF_HSPTR - length ls) '0') ++ ls ++ rs + '0':'x':(replicate (2*SIZEOF_HSPTR - length ls) '0') ++ ls ++ rs -- word2Integer :: Word# -> Integer (stolen from Word.lhs) word2Integer w = case word2Integer# w of - (# s, d #) -> J# s d + (# s, d #) -> J# s d instance Show (FunPtr a) where showsPrec p = showsPrec p . castFunPtrToPtr diff --git a/GHC/Stable.lhs b/GHC/Stable.lhs index 999472a..1e7222f 100644 --- a/GHC/Stable.lhs +++ b/GHC/Stable.lhs @@ -17,12 +17,12 @@ -- #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 + ( 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 @@ -101,7 +101,7 @@ castPtrToStablePtr (Ptr a) = StablePtr (unsafeCoerce# a) instance Eq (StablePtr a) where (StablePtr sp1) == (StablePtr sp2) = - case eqStablePtr# sp1 sp2 of - 0# -> False - _ -> True + case eqStablePtr# sp1 sp2 of + 0# -> False + _ -> True \end{code} diff --git a/GHC/Storable.lhs b/GHC/Storable.lhs index 803df9c..aa53236 100644 --- a/GHC/Storable.lhs +++ b/GHC/Storable.lhs @@ -17,41 +17,41 @@ -- #hide module GHC.Storable - ( readWideCharOffPtr - , readIntOffPtr - , readWordOffPtr - , readPtrOffPtr - , readFunPtrOffPtr - , readFloatOffPtr - , readDoubleOffPtr - , readStablePtrOffPtr - , readInt8OffPtr - , readInt16OffPtr - , readInt32OffPtr - , readInt64OffPtr - , readWord8OffPtr - , readWord16OffPtr - , readWord32OffPtr - , readWord64OffPtr - , writeWideCharOffPtr - , writeIntOffPtr - , writeWordOffPtr - , writePtrOffPtr - , writeFunPtrOffPtr - , writeFloatOffPtr - , writeDoubleOffPtr - , writeStablePtrOffPtr - , writeInt8OffPtr - , writeInt16OffPtr - , writeInt32OffPtr - , writeInt64OffPtr - , writeWord8OffPtr - , writeWord16OffPtr - , writeWord32OffPtr - , writeWord64OffPtr + ( readWideCharOffPtr + , readIntOffPtr + , readWordOffPtr + , readPtrOffPtr + , readFunPtrOffPtr + , readFloatOffPtr + , readDoubleOffPtr + , readStablePtrOffPtr + , readInt8OffPtr + , readInt16OffPtr + , readInt32OffPtr + , readInt64OffPtr + , readWord8OffPtr + , readWord16OffPtr + , readWord32OffPtr + , readWord64OffPtr + , writeWideCharOffPtr + , writeIntOffPtr + , writeWordOffPtr + , writePtrOffPtr + , writeFunPtrOffPtr + , writeFloatOffPtr + , writeDoubleOffPtr + , writeStablePtrOffPtr + , writeInt8OffPtr + , writeInt16OffPtr + , writeInt32OffPtr + , writeInt64OffPtr + , writeWord8OffPtr + , writeWord16OffPtr + , writeWord32OffPtr + , writeWord64OffPtr ) where -import GHC.Stable ( StablePtr(..) ) +import GHC.Stable ( StablePtr(..) ) import GHC.Int import GHC.Word import GHC.Ptr diff --git a/Text/Show.hs b/Text/Show.hs index dc4535e..5ae6288 100644 --- a/Text/Show.hs +++ b/Text/Show.hs @@ -15,26 +15,26 @@ ----------------------------------------------------------------------------- module Text.Show ( - ShowS, -- String -> String + ShowS, -- String -> String Show( - showsPrec, -- :: Int -> a -> ShowS - show, -- :: a -> String - showList -- :: [a] -> ShowS + showsPrec, -- :: Int -> a -> ShowS + show, -- :: a -> String + showList -- :: [a] -> ShowS ), - shows, -- :: (Show a) => a -> ShowS - showChar, -- :: Char -> ShowS - showString, -- :: String -> ShowS - showParen, -- :: Bool -> ShowS -> ShowS - showListWith, -- :: (a -> ShowS) -> [a] -> ShowS + shows, -- :: (Show a) => a -> ShowS + showChar, -- :: Char -> ShowS + showString, -- :: String -> ShowS + showParen, -- :: Bool -> ShowS -> ShowS + showListWith, -- :: (a -> ShowS) -> [a] -> ShowS ) where #ifdef __GLASGOW_HASKELL__ import GHC.Show -#endif +#endif -- | Show a list (using square brackets and commas), given a function -- for showing elements. -showListWith :: (a -> ShowS) -> [a] -> ShowS +showListWith :: (a -> ShowS) -> [a] -> ShowS showListWith = showList__ #ifndef __GLASGOW_HASKELL__ diff --git a/include/CTypes.h b/include/CTypes.h index a3a8b3a..3ca9f1c 100644 --- a/include/CTypes.h +++ b/include/CTypes.h @@ -114,7 +114,7 @@ instance Bits T where { \ instance Fractional T where { \ (T x) / (T y) = T (x / y) ; \ recip (T x) = T (recip x) ; \ - fromRational r = T (fromRational r) } + fromRational r = T (fromRational r) } #define INSTANCE_FLOATING(T) \ instance Floating T where { \ @@ -197,14 +197,14 @@ INSTANCE_TYPEABLE0(T,C,S) ; #define INSTANCE_READ(T,B) \ instance Read T where { \ - readsPrec = unsafeCoerce# (readsPrec :: Int -> ReadS B); \ - readList = unsafeCoerce# (readList :: ReadS [B]); } + readsPrec = unsafeCoerce# (readsPrec :: Int -> ReadS B); \ + readList = unsafeCoerce# (readList :: ReadS [B]); } #define INSTANCE_SHOW(T,B) \ instance Show T where { \ - showsPrec = unsafeCoerce# (showsPrec :: Int -> B -> ShowS); \ - show = unsafeCoerce# (show :: B -> String); \ - showList = unsafeCoerce# (showList :: [B] -> ShowS); } + showsPrec = unsafeCoerce# (showsPrec :: Int -> B -> ShowS); \ + show = unsafeCoerce# (show :: B -> String); \ + showList = unsafeCoerce# (showList :: [B] -> ShowS); } #endif /* __GLASGOW_HASKELL__ */ -- 1.7.10.4