summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b659591)
Removed use of COMPILING_GHC
\section[Bags]{@Bag@: an unordered collection with duplicates}
\begin{code}
\section[Bags]{@Bag@: an unordered collection with duplicates}
\begin{code}
module Bag (
Bag, -- abstract type
emptyBag, unitBag, unionBags, unionManyBags,
mapBag,
module Bag (
Bag, -- abstract type
emptyBag, unitBag, unionBags, unionManyBags,
mapBag,
filterBag, partitionBag, concatBag, foldBag, foldrBag,
isEmptyBag, consBag, snocBag,
listToBag, bagToList
) where
filterBag, partitionBag, concatBag, foldBag, foldrBag,
isEmptyBag, consBag, snocBag,
listToBag, bagToList
) where
IMP_Ubiq(){-uitous-}
IMPORT_1_3(List(partition))
import Outputable --( interpp'SP )
import Pretty
IMP_Ubiq(){-uitous-}
IMPORT_1_3(List(partition))
import Outputable --( interpp'SP )
import Pretty
-#else
-import List(partition)
-#endif
emptyBag = EmptyBag
unitBag = UnitBag
emptyBag = EmptyBag
unitBag = UnitBag
elemBag :: Eq a => a -> Bag a -> Bool
elemBag x EmptyBag = False
elemBag :: Eq a => a -> Bag a -> Bool
elemBag x EmptyBag = False
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
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
unionManyBags [] = EmptyBag
unionManyBags xs = ListOfBags xs
unionManyBags [] = EmptyBag
unionManyBags xs = ListOfBags xs
instance (Outputable a) => Outputable (Bag a) where
ppr sty EmptyBag = ptext SLIT("emptyBag")
ppr sty (UnitBag a) = ppr sty a
instance (Outputable a) => Outputable (Bag a) where
ppr sty EmptyBag = ptext SLIT("emptyBag")
ppr sty (UnitBag a) = ppr sty a
ppr sty (ListBag as) = interpp'SP sty as
ppr sty (ListOfBags bs) = brackets (interpp'SP sty bs)
ppr sty (ListBag as) = interpp'SP sty as
ppr sty (ListOfBags bs) = brackets (interpp'SP sty bs)
-#endif {- COMPILING_GHC -}
BitSet, -- abstract type
mkBS, listBS, emptyBS, unitBS,
unionBS, minusBS
BitSet, -- abstract type
mkBS, listBS, emptyBS, unitBS,
unionBS, minusBS
-#if ! defined(COMPILING_GHC)
- , elementBS, intersectBS, isEmptyBS
-#endif
) where
#ifdef __GLASGOW_HASKELL__
) where
#ifdef __GLASGOW_HASKELL__
minusBS :: BitSet -> BitSet -> BitSet
minusBS (MkBS x#) (MkBS y#) = MkBS (x# `and#` (not# y#))
minusBS :: BitSet -> BitSet -> BitSet
minusBS (MkBS x#) (MkBS y#) = MkBS (x# `and#` (not# y#))
-#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
isEmptyBS (MkBS s#)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
isEmptyBS (MkBS s#)
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x) (MkBS y) = MkBS (x `logiorInt` y)
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x) (MkBS y) = MkBS (x `logiorInt` y)
-#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
isEmptyBS (MkBS s)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
isEmptyBS (MkBS s)
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x) (MkBS y) = MkBS (x `bitOr` y)
unionBS :: BitSet -> BitSet -> BitSet
unionBS (MkBS x) (MkBS y) = MkBS (x `bitOr` y)
-#if ! defined(COMPILING_GHC)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
isEmptyBS (MkBS s)
-- not used in GHC
isEmptyBS :: BitSet -> Bool
isEmptyBS (MkBS s)
-#if defined(COMPILING_GHC)