on master help sign in
Add `compareSize`.
2be75d4Edward Kmett
Data/Text/Internal/Fusion/Size.hs+9
@@ -28,6 +28,7 @@ module Data.Text.Internal.Fusion.Size
28 , larger
28 , larger
29 , upperBound
29 , upperBound
30 , lowerBound
30 , lowerBound
31+ , compareSize
31 , isEmpty
32 , isEmpty
32 ) where
33 ) where
33
34
@@ -144,6 +145,14 @@ lowerBound _ (Between n _) = n
144lowerBound k _ = k
145lowerBound k _ = k
145{-# INLINE lowerBound #-}
146{-# INLINE lowerBound #-}
146
147
148+compareSize :: Size -> Int -> Maybe Ordering
149+compareSize (Between ma mb) n
150+ | mb < n = Just LT
151+ | ma > n = Just GT
152+ | ma == n && mb == n = Just EQ
153+compareSize _ _ = Nothing
154+
155+
147isEmpty :: Size -> Bool
156isEmpty :: Size -> Bool
148isEmpty (Between _ n) = n <= 0
157isEmpty (Between _ n) = n <= 0
149isEmpty _ = False
158isEmpty _ = False