(A similar thing to @UniqSet@, as opposed to @Set@.)
\begin{code}
-#if defined(COMPILING_GHC)
#include "HsVersions.h"
-#define IF_NOT_GHC(a) {--}
-#else
-#define ASSERT(e) {--}
-#define IF_NOT_GHC(a) a
-#endif
module UniqFM (
UniqFM, -- abstract type
plusUFM_C,
minusUFM,
intersectUFM,
- IF_NOT_GHC(intersectUFM_C COMMA)
- IF_NOT_GHC(foldUFM COMMA)
+ intersectUFM_C,
+ foldUFM,
mapUFM,
filterUFM,
sizeUFM,
lookupWithDefaultUFM, lookupWithDefaultUFM_Directly,
eltsUFM, keysUFM,
ufmToList
-#if defined(COMPILING_GHC)
,FAST_STRING
-#endif
) where
IMP_Ubiq()
-#if defined(COMPILING_GHC)
-# if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 201
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 201
IMPORT_DELOOPER( SpecLoop )
-# else
+#else
import {-# SOURCE #-} Name
-# endif
#endif
import Unique ( Uniquable(..), Unique, u2i, mkUniqueGrimily )
\section[Util]{Highly random utility functions}
\begin{code}
-#if defined(COMPILING_GHC)
-# include "HsVersions.h"
-# define IF_NOT_GHC(a) {--}
-#else
-# define panic error
-# define TAG_ Ordering
-# define LT_ LT
-# define EQ_ EQ
-# define GT_ GT
-# define _LT LT
-# define _EQ EQ
-# define _GT GT
-# define GT__ _
-# define tagCmp_ compare
-# define _tagCmp compare
-# define FAST_STRING String
-# define ASSERT(x) {-nothing-}
-# define IF_NOT_GHC(a) a
-# define COMMA ,
-#endif
+#include "HsVersions.h"
+#define IF_NOT_GHC(a) {--}
#ifndef __GLASGOW_HASKELL__
# undef TAG_
zipLazy,
mapAndUnzip, mapAndUnzip3,
nOfThem, lengthExceeds, isSingleton,
-#if defined(COMPILING_GHC)
startsWith, endsWith,
isIn, isn'tIn,
-#endif
-- association lists
assoc, assocUsing, assocDefault, assocDefaultUsing,
mapAccumL, mapAccumR, mapAccumB,
-- comparisons
-#if defined(COMPILING_GHC)
Ord3(..), thenCmp, cmpList,
cmpPString, FAST_STRING,
-#else
- cmpString,
-#endif
-- pairs
IF_NOT_GHC(cfst COMMA applyToPair COMMA applyToFst COMMA)
unzipWith
-- error handling
-#if defined(COMPILING_GHC)
, panic, panic#, pprPanic, pprPanic#, pprError, pprTrace
, assertPanic, assertPprPanic
-#endif {- COMPILING_GHC -}
) where
-#if defined(COMPILING_GHC)
-
CHK_Ubiq() -- debugging consistency check
IMPORT_1_3(List(zipWith4))
import Pretty
-#else
-import List(zipWith4)
-#endif
-
infixr 9 `thenCmp`
\end{code}
Debugging/specialising versions of \tr{elem} and \tr{notElem}
\begin{code}
-#if defined(COMPILING_GHC)
isIn, isn'tIn :: (Eq a) => String -> a -> [a] -> Bool
# ifndef DEBUG
# endif {- DEBUG -}
-#endif {- COMPILING_GHC -}
\end{code}
%************************************************************************
else
f (x:seen_so_far) xs
-#if defined(COMPILING_GHC)
is_elem = isIn "hasNoDups"
-#else
- is_elem = elem
-#endif
\end{code}
\begin{code}
cmpString [] ys = LT_
cmpString xs [] = GT_
-#ifdef COMPILING_GHC
cmpString _ _ = panic# "cmpString"
-#else
-cmpString _ _ = error "cmpString"
-#endif
\end{code}
\begin{code}
%************************************************************************
\begin{code}
-#if defined(COMPILING_GHC)
panic x = error ("panic! (the `impossible' happened):\n\t"
++ x ++ "\n\n"
++ "Please report it as a compiler bug "
pprPanic heading pretty_msg = panic (heading++ " " ++ (show pretty_msg))
pprError heading pretty_msg = error (heading++ " " ++ (show pretty_msg))
-#if __GLASGOW_HASKELL__ == 201
+# if __GLASGOW_HASKELL__ == 201
pprTrace heading pretty_msg = GHCbase.trace (heading++" "++(show pretty_msg))
-#elif __GLASGOW_HASKELL__ >= 202
+# elif __GLASGOW_HASKELL__ >= 202
pprTrace heading pretty_msg = GlaExts.trace (heading++" "++(show pretty_msg))
-#else
+# else
pprTrace heading pretty_msg = trace (heading++" "++(show pretty_msg))
-#endif
+# endif
-- #-versions because panic can't return an unboxed int, and that's
-- what TAG_ is with GHC at the moment. Ugh. (Simon)
text "line", int line],
msg]))
-#endif {- COMPILING_GHC -}
\end{code}