monoid-subclasses 0.4.1.2 → 0.4.2
raw patch · 3 files changed
+13/−17 lines, 3 filesdep ~quickcheck-instances
Dependency ranges changed: quickcheck-instances
Files
- Data/Monoid/Instances/ByteString/UTF8.hs +11/−9
- Test/TestMonoidSubclasses.hs +0/−6
- monoid-subclasses.cabal +2/−2
Data/Monoid/Instances/ByteString/UTF8.hs view
@@ -1,5 +1,5 @@ {- - Copyright 2013-2015 Mario Blazevic+ Copyright 2013-2016 Mario Blazevic License: BSD3 (see BSD3-LICENSE.txt file) -}@@ -218,7 +218,8 @@ of Just s1 -> dropASCII s1 tl Nothing -> (bs, s) {-# INLINE spanMaybe #-}- spanMaybe' s0 f (ByteStringUTF8 bs0) = (ByteStringUTF8 $ ByteString.take (ByteString.length bs0 - ByteString.length dropped) bs0,+ spanMaybe' s0 f (ByteStringUTF8 bs0) = (ByteStringUTF8 $+ ByteString.take (ByteString.length bs0 - ByteString.length dropped) bs0, ByteStringUTF8 dropped, s') where (dropped, s') = dropASCII s0 bs0@@ -373,19 +374,19 @@ reverseBytesToChar :: (ByteString -> a) -> (Char -> a) -> [Word8] -> a reverseBytesToChar ft fc [w] = if w < 0x80 then fc (w2c w) else ft (ByteString.singleton w) reverseBytesToChar ft fc [b0, b1] =- assert (0x80 <= b0 && b0 < 0xC0 && 0xC0 <= b1) $+ assert (0x80 <= b0 && b0 < 0xC0) $ if 0xC2 <= b1 && b1 < 0xE0 then fc (chr (shiftL (fromIntegral b1 .&. 0x1F) 6 .|. fromIntegral b0 .&. 0x3F)) else ft (ByteString.pack [b1, b0]) reverseBytesToChar ft fc [b0, b1, b2] =- assert (0x80 <= b0 && b0 < 0xC0 && 0x80 <= b1 && b1 < 0xC0 && 0xC0 <= b2) $+ assert (0x80 <= b0 && b0 < 0xC0 && 0x80 <= b1 && b1 < 0xC0) $ if (0xE0 < b2 || 0xE0 == b2 && 0xA0 <= b1) && b2 < 0xF0 then fc (chr (shiftL (fromIntegral b2 .&. 0xF) 12 .|. shiftL (fromIntegral b1 .&. 0x3F) 6 .|. fromIntegral b0 .&. 0x3F)) else ft (ByteString.pack [b2, b1, b0]) reverseBytesToChar ft fc [b0, b1, b2, b3] =- assert (0x80 <= b0 && b0 < 0xC0 && 0x80 <= b1 && b1 < 0xC0 && 0x80 <= b2 && b2 < 0xC0 && 0xC0 <= b3) $+ assert (0x80 <= b0 && b0 < 0xC0 && 0x80 <= b1 && b1 < 0xC0 && 0x80 <= b2 && b2 < 0xC0) $ if (0xF0 < b3 || 0xF0 == b3 && 0x90 <= b2) && b3 < 0xF4 then fc (chr (shiftL (fromIntegral b3 .&. 0x7) 18 .|. shiftL (fromIntegral b2 .&. 0x3F) 12@@ -484,8 +485,9 @@ charStartIndex :: Int -> ByteString -> Int charStartIndex n _ | n <= 0 = 0-charStartIndex n bs =- case List.drop (pred n) (ByteString.findIndices byteStartsCharacter $ ByteString.drop 1 bs)- of [] -> ByteString.length bs- k:_ -> succ k+charStartIndex n0 bs = ByteString.foldr count (const $ ByteString.length bs) bs (n0, False, 0)+ where count byte _ (0, high, i) | byte < 0x80 || byte >= 0xC0 || not high = i+ count byte cont (n, high, i) | byte < 0x80 = cont (pred n, False, succ i)+ | byte < 0xC0 = cont (if high then n else pred n, True, succ i)+ | otherwise = cont (pred n, True, succ i) {-# INLINE charStartIndex #-}
Test/TestMonoidSubclasses.hs view
@@ -783,9 +783,6 @@ instance Arbitrary a => Arbitrary (Sum a) where arbitrary = fmap Sum arbitrary -instance Arbitrary a => Arbitrary (Vector a) where- arbitrary = fmap fromList arbitrary- instance Arbitrary ByteStringUTF8 where arbitrary = fmap ByteStringUTF8 arbitrary @@ -824,9 +821,6 @@ instance CoArbitrary a => CoArbitrary (Sum a) where coarbitrary (Sum a) = coarbitrary a--instance CoArbitrary a => CoArbitrary (Vector a) where- coarbitrary = coarbitrary . toList instance CoArbitrary ByteStringUTF8 where coarbitrary (ByteStringUTF8 bs) = coarbitrary bs
monoid-subclasses.cabal view
@@ -1,5 +1,5 @@ Name: monoid-subclasses-Version: 0.4.1.2+Version: 0.4.2 Cabal-Version: >= 1.10 Build-Type: Simple Synopsis: Subclasses of Monoid@@ -35,7 +35,7 @@ Build-Depends: base >= 4.5 && < 5, bytestring >= 0.9 && < 1.0, containers >= 0.5.2.0 && < 0.6, text >= 0.11 && < 1.3, vector >= 0.9 && < 0.12, primes == 0.2.*,- QuickCheck == 2.*, quickcheck-instances == 0.3.*, tasty >= 0.7, tasty-quickcheck >= 0.7,+ QuickCheck == 2.*, quickcheck-instances >= 0.3.12 && <0.4, tasty >= 0.7, tasty-quickcheck >= 0.7, monoid-subclasses Main-is: Test/TestMonoidSubclasses.hs default-language: Haskell2010