[project @ 1996-07-25 20:43:49 by partain]
[ghc-hetmet.git] / ghc / compiler / utils / Bag.lhs
index 6085e37..15678cf 100644 (file)
@@ -4,16 +4,21 @@
 \section[Bags]{@Bag@: an unordered collection with duplicates}
 
 \begin{code}
+#ifdef COMPILING_GHC
 #include "HsVersions.h"
+#endif
 
 module Bag (
        Bag,    -- abstract type
 
        emptyBag, unitBag, unionBags, unionManyBags,
-       elemBag, mapBag,
+       mapBag,
+#ifndef COMPILING_GHC
+       elemBag,
+#endif
        filterBag, partitionBag, concatBag, foldBag,
        isEmptyBag, consBag, snocBag,
-       listToBag, bagToList, bagToList_append
+       listToBag, bagToList
     ) where
 
 #ifdef COMPILING_GHC
@@ -22,6 +27,8 @@ IMPORT_1_3(List(partition))
 
 import Outputable      ( interpp'SP )
 import Pretty
+#else
+import List(partition)
 #endif
 
 data Bag a
@@ -35,6 +42,7 @@ data Bag a
 emptyBag = EmptyBag
 unitBag  = UnitBag
 
+#ifndef COMPILING_GHC
 elemBag :: Eq a => a -> Bag a -> Bool
 
 elemBag x EmptyBag        = False
@@ -42,6 +50,7 @@ elemBag x (UnitBag y)     = x==y
 elemBag x (TwoBags b1 b2) = x `elemBag` b1 || x `elemBag` b2
 elemBag x (ListBag ys)    = any (x ==) ys
 elemBag x (ListOfBags bs) = any (x `elemBag`) bs
+#endif
 
 unionManyBags [] = EmptyBag
 unionManyBags xs = ListOfBags xs
@@ -53,8 +62,9 @@ unionBags b EmptyBag = b
 unionBags b1 b2      = TwoBags b1 b2
 
 consBag :: a -> Bag a -> Bag a
-consBag elt bag = (unitBag elt) `unionBags` bag
 snocBag :: Bag a -> a -> Bag a
+
+consBag elt bag = (unitBag elt) `unionBags` bag
 snocBag bag elt = bag `unionBags` (unitBag elt)
 
 isEmptyBag EmptyBag        = True
@@ -139,6 +149,7 @@ bagToList (ListBag vs) = vs
 bagToList b = bagToList_append b []
 
     -- (bagToList_append b xs) flattens b and puts xs on the end.
+    -- (not exported)
 bagToList_append EmptyBag       xs = xs
 bagToList_append (UnitBag x)    xs = x:xs
 bagToList_append (TwoBags b1 b2) xs = bagToList_append b1 (bagToList_append b2 xs)