Ticket #5242: 0001-Moved-data-IntSet-to-Data.IntSet.Internal.patch

File 0001-Moved-data-IntSet-to-Data.IntSet.Internal.patch, 3.1 KB (added by liyang, 4 years ago)
  • Data/IntSet.hs

    From d6dc6ef9112699c2950aaf4a04849c30b84ec4cc Mon Sep 17 00:00:00 2001
    From: Liyang HU <[email protected]>
    Date: Tue, 7 Jun 2011 15:46:04 +0900
    Subject: [PATCH 1/4] Moved data IntSet to Data.IntSet.Internal
    
    ---
     Data/IntSet.hs          |   21 ++-------------------
     Data/IntSet/Internal.hs |   21 +++++++++++++++++++++
     containers.cabal        |    2 ++
     3 files changed, 25 insertions(+), 19 deletions(-)
     create mode 100644 Data/IntSet/Internal.hs
    
    diff --git a/Data/IntSet.hs b/Data/IntSet.hs
    index bcc5104..7c95324 100644
    a b import GlaExts ( Word(..), Int(..), shiftRL# ) 
    139139import Data.Word
    140140#endif
    141141
     142import Data.IntSet.Internal
     143
    142144infixl 9 \\{-This comment teaches CPP correct behaviour -}
    143145
    144146-- A "Nat" is a natural machine word (an unsigned Int)
    shiftRL x i = shiftR x i 
    171173(\\) :: IntSet -> IntSet -> IntSet
    172174m1 \\ m2 = difference m1 m2
    173175
    174 {--------------------------------------------------------------------
    175   Types 
    176 --------------------------------------------------------------------}
    177 -- | A set of integers.
    178 data IntSet = Nil
    179             | Tip {-# UNPACK #-} !Int
    180             | Bin {-# UNPACK #-} !Prefix {-# UNPACK #-} !Mask !IntSet !IntSet
    181 -- Invariant: Nil is never found as a child of Bin.
    182 -- Invariant: The Mask is a power of 2.  It is the largest bit position at which
    183 --            two elements of the set differ.
    184 -- Invariant: Prefix is the common high-order bits that all elements share to
    185 --            the left of the Mask bit.
    186 -- Invariant: In Bin prefix mask left right, left consists of the elements that
    187 --            don't have the mask bit set; right is all the elements that do.
    188 
    189 
    190 type Prefix = Int
    191 type Mask   = Int
    192 
    193176instance Monoid IntSet where
    194177    mempty  = empty
    195178    mappend = union
  • new file Data/IntSet/Internal.hs

    diff --git a/Data/IntSet/Internal.hs b/Data/IntSet/Internal.hs
    new file mode 100644
    index 0000000..4fe16b9
    - +  
     1module Data.IntSet.Internal {- export everything -} where
     2
     3{--------------------------------------------------------------------
     4  Types
     5--------------------------------------------------------------------}
     6
     7-- | A set of integers.
     8data IntSet = Nil
     9            | Tip {-# UNPACK #-} !Int
     10            | Bin {-# UNPACK #-} !Prefix {-# UNPACK #-} !Mask !IntSet !IntSet
     11-- Invariant: Nil is never found as a child of Bin.
     12-- Invariant: The Mask is a power of 2.  It is the largest bit position at which
     13--            two elements of the set differ.
     14-- Invariant: Prefix is the common high-order bits that all elements share to
     15--            the left of the Mask bit.
     16-- Invariant: In Bin prefix mask left right, left consists of the elements that
     17--            don't have the mask bit set; right is all the elements that do.
     18
     19type Prefix = Int
     20type Mask   = Int
     21
  • containers.cabal

    diff --git a/containers.cabal b/containers.cabal
    index 72d1a10..9d6abef 100644
    a b Library { 
    2929        Data.IntSet
    3030        Data.Map
    3131        Data.Set
     32    other-modules:
     33        Data.IntSet.Internal
    3234    include-dirs: include
    3335    extensions: CPP
    3436    if !impl(nhc98) {