--- Set.hs	2009-11-19 07:51:36.000000000 -0800
+++ SetInteger.hs	2010-06-19 15:45:00.000000000 -0700
@@ -178,7 +178,7 @@
       Bin {} -> False
 
 -- | /O(1)/. The number of elements in the set.
-size :: Set a -> Int
+size :: Set a -> Size
 size t
   = case t of
       Tip          -> 0
@@ -707,8 +707,8 @@
 join x Tip r  = insertMin x r
 join x l Tip  = insertMax x l
 join x l@(Bin sizeL y ly ry) r@(Bin sizeR z lz rz)
-  | delta*sizeL <= sizeR  = balance z (join x l lz) rz
-  | delta*sizeR <= sizeL  = balance y ly (join x ry r)
+  | delta*(toInteger sizeL) <= (toInteger sizeR)  = balance z (join x l lz) rz
+  | delta*(toInteger sizeR) <= (toInteger sizeL)  = balance y ly (join x ry r)
   | otherwise             = bin x l r
 
 
@@ -733,8 +733,8 @@
 merge Tip r   = r
 merge l Tip   = l
 merge l@(Bin sizeL x lx rx) r@(Bin sizeR y ly ry)
-  | delta*sizeL <= sizeR = balance y (merge l ly) ry
-  | delta*sizeR <= sizeL = balance x lx (merge rx r)
+  | delta*(toInteger sizeL) <= (toInteger sizeR) = balance y (merge l ly) ry
+  | delta*(toInteger sizeR) <= (toInteger sizeL) = balance x lx (merge rx r)
   | otherwise            = glue l r
 
 {--------------------------------------------------------------------
@@ -827,7 +827,7 @@
   However (since we use quickcheck :-) we will stick to strictly balanced 
   trees.
 --------------------------------------------------------------------}
-delta,ratio :: Int
+delta,ratio :: Integer
 delta = 4
 ratio = 2
 
@@ -838,20 +838,20 @@
   | sizeL >= delta*sizeR  = rotateR x l r
   | otherwise             = Bin sizeX x l r
   where
-    sizeL = size l
-    sizeR = size r
-    sizeX = sizeL + sizeR + 1
+    sizeL = toInteger $ size l
+    sizeR = toInteger $ size r
+    sizeX = size l + size r + 1
 
 -- rotate
 rotateL :: a -> Set a -> Set a -> Set a
 rotateL x l r@(Bin _ _ ly ry)
-  | size ly < ratio*size ry = singleL x l r
+  | (toInteger $ size ly) < ratio*(toInteger $ size ry) = singleL x l r
   | otherwise               = doubleL x l r
 rotateL _ _ Tip = error "rotateL Tip"
 
 rotateR :: a -> Set a -> Set a -> Set a
 rotateR x l@(Bin _ _ ly ry) r
-  | size ry < ratio*size ly = singleR x l r
+  | (toInteger $ size ry) < ratio*(toInteger $ size ly) = singleR x l r
   | otherwise               = doubleR x l r
 rotateR _ Tip _ = error "rotateL Tip"
 
@@ -1002,7 +1002,7 @@
 balanced t
   = case t of
       Tip         -> True
-      Bin _ _ l r -> (size l + size r <= 1 || (size l <= delta*size r && size r <= delta*size l)) &&
+      Bin _ _ l r -> ((toInteger $ size l) + (toInteger $ size r) <= 1 || ((toInteger $ size l) <= delta*(toInteger $ size r) && (toInteger $ size r) <= delta*(toInteger $ size l))) &&
                      balanced l && balanced r
 
 validsize :: Set a -> Bool
