import Data.Data
\end{code}
-\begin{code}
--- Unicode TODO: put isSymbol in libcompat
-#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ > 604
-#else
-isSymbol :: a -> Bool
-isSymbol = const False
-#endif
-
-\end{code}
-
%************************************************************************
%* *
\subsection{Name space}
import MonadUtils
import Control.Monad
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO (unsafeDupableInterleaveIO)
-#else
-import GHC.IOBase (unsafeDupableInterleaveIO)
-#endif
\end{code}
-#if __GLASGOW_HASKELL__ >= 611
{-# OPTIONS_GHC -XNoMonoLocalBinds #-}
-#endif
-- Norman likes local bindings
-- If this module lives on I'd like to get rid of this flag in due course
-#if __GLASGOW_HASKELL__ >= 611
{-# OPTIONS_GHC -XNoMonoLocalBinds #-}
-#endif
-- Norman likes local bindings
-- If this module lives on I'd like to get rid of this flag in due course
-#if __GLASGOW_HASKELL__ >= 611
{-# OPTIONS_GHC -XNoMonoLocalBinds #-}
-#endif
-- Norman likes local bindings
-- If this module lives on I'd like to get rid of this flag in due course
-#if __GLASGOW_HASKELL__ >= 611
{-# OPTIONS_GHC -XNoMonoLocalBinds #-}
-#endif
-- Norman likes local bindings
-- If this module lives on I'd like to get rid of this flag in due course
-#if __GLASGOW_HASKELL__ >= 611
{-# OPTIONS_GHC -XNoMonoLocalBinds #-}
-#endif
-- Norman likes local bindings
-- This module is pure representation and should be imported only by
import GHC.Arr ( Array(..) )
import GHC.Exts
-
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO ( IO(..) )
-#else
-import GHC.IOBase ( IO(..) )
-#endif
import Control.Monad
import Data.Maybe
) where
#ifdef GHCI
import GHC.Exts
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO ( IO(..) )
-#else
-import GHC.IOBase ( IO(..) )
-#endif
import Constants
data BreakArray = BA (MutableByteArray# RealWorld)
*/
#include "Rts.h"
-#if __GLASGOW_HASKELL__ <= 610
-#include "RtsFlags.h"
-#endif
#include "HsFFI.h"
import GHC.Real ( Ratio(..) )
import GHC.Exts
import GHC.Word ( Word8(..) )
-
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO ( IO(..) )
-#else
-import GHC.IOBase ( IO(..) )
-#endif
type BinArray = ForeignPtr Word8
import Data.Maybe
import Data.Array
import Data.List ( (\\) )
-
-#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ > 604
import Data.Array.ST
-#else
-import Data.Array.ST hiding ( indices, bounds )
-#endif
\end{code}
%************************************************************************
import GHC.Exts
import GHC.Word
-
-#if __GLASGOW_HASKELL__ >= 611
-import GHC.IO ( IO(..) )
-#else
-import GHC.IOBase ( IO(..) )
-#endif
-
-#if __GLASGOW_HASKELL__ >= 611
-import GHC.IO (unsafeDupableInterleaveIO)
-#else
-import GHC.IOBase (unsafeDupableInterleaveIO)
-#endif
-
+import GHC.IO (IO(..), unsafeDupableInterleaveIO)
import GHC.Base (unsafeChr)
-- Just like unsafePerformIO, but we inline it.
import GHC.Base
import GHC.Ptr
-#if __GLASGOW_HASKELL__ >= 611
--- import GHC.IO ( IO(..) )
-#else
-import GHC.IOBase ( IO(..) )
-#endif
-
#else /* ! __GLASGOW_HASKELL__ */
import Data.IORef
import Data.Maybe ( isJust )
import Data.Char ( ord )
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO ( IO(..) )
-#else
-import GHC.IOBase ( IO(..) )
-#endif
import GHC.Ptr ( Ptr(..) )
#if defined(__GLASGOW_HASKELL__)
serializeConstr (AlgConstr ix) = serializeWord8 1 . serializeInt ix
serializeConstr (IntConstr i) = serializeWord8 2 . serializeInteger i
serializeConstr (FloatConstr r) = serializeWord8 3 . serializeRational r
-#if __GLASGOW_HASKELL__ < 611
-serializeConstr (StringConstr s) = serializeWord8 4 . serializeString s
-#else
serializeConstr (CharConstr c) = serializeWord8 4 . serializeChar c
-#endif
deserializeConstr :: [Word8] -> (ConstrRep -> [Word8] -> a) -> a
1 -> deserializeInt bytes $ \ix -> k (AlgConstr ix)
2 -> deserializeInteger bytes $ \i -> k (IntConstr i)
3 -> deserializeRational bytes $ \r -> k (FloatConstr r)
-#if __GLASGOW_HASKELL__ >= 611
4 -> deserializeChar bytes $ \c -> k (CharConstr c)
-#else
- 4 -> deserializeString bytes $ \s -> k (StringConstr s)
-#endif
x -> error $ "deserializeConstr: unrecognised serialized constructor type " ++ show x ++ " in context " ++ show bytes
deserializeInteger bytes k = deserializeString bytes (k . read)
-#if __GLASGOW_HASKELL__ >= 611
serializeChar :: Char -> [Word8] -> [Word8]
serializeChar = serializeString . show
deserializeChar :: [Word8] -> (Char -> [Word8] -> a) -> a
deserializeChar bytes k = deserializeString bytes (k . read)
-#endif
serializeString :: String -> [Word8] -> [Word8]
plusUFM_C f (UFM x) (UFM y) = UFM (M.unionWith f x y)
minusUFM (UFM x) (UFM y) = UFM (M.difference x y)
intersectUFM (UFM x) (UFM y) = UFM (M.intersection x y)
-#if __GLASGOW_HASKELL__ >= 611
intersectUFM_C f (UFM x) (UFM y) = UFM (M.intersectionWith f x y)
-#else
--- In GHC 6.10, intersectionWith is (a -> b -> a) instead of (a -> b -> c),
--- so we need to jump through some hoops to get the more general type.
-intersectUFM_C f (UFM x) (UFM y) = UFM z
- where z = let x' = M.map Left x
- f' (Left a) b = Right (f a b)
- f' (Right _) _ = panic "intersectUFM_C: f': Right"
- z' = M.intersectionWith f' x' y
- fromRight (Right a) = a
- fromRight _ = panic "intersectUFM_C: Left"
- in M.map fromRight z'
-#endif
foldUFM k z (UFM m) = M.fold k z m
foldUFM_Directly k z (UFM m) = M.foldWithKey (k . getUnique) z m
abstractDataType n = mkDataType n [abstractConstr n]
\end{code}
-\begin{code}
--- Old GHC versions come with a base library with this function misspelled.
-#if __GLASGOW_HASKELL__ < 612
-mkNoRepType :: String -> DataType
-mkNoRepType = mkNorepType
-#endif
-\end{code}
-
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-#if __GLASGOW_HASKELL__ >= 611
{-# OPTIONS_GHC -XNoMonoLocalBinds #-}
-#endif
-- Roman likes local bindings
-- If this module lives on I'd like to get rid of this flag in due course