Commits

Anonymous committed 5f2c2a9

Add `compareSize`.

Comments (0)

Files changed (1)

Data/Text/Internal/Fusion/Size.hs

     , larger
     , upperBound
     , lowerBound
+    , compareSize
     , isEmpty
     ) where
 
 lowerBound k _             = k
 {-# INLINE lowerBound #-}
 
+compareSize :: Size -> Int -> Maybe Ordering
+compareSize (Between ma mb) n
+  | mb < n             = Just LT
+  | ma > n             = Just GT
+  | ma == n && mb == n = Just EQ
+compareSize _ _        = Nothing
+
+
 isEmpty :: Size -> Bool
 isEmpty (Between _ n) = n <= 0
 isEmpty _             = False