@@ -54,12 +54,30 @@ repackBS_ = go . cycle
54 | otherwise = let (h,t) = B.splitAt b s
54 | otherwise = let (h,t) = B.splitAt b s
55 in h : go bs t
55 in h : go bs t
56 go _ _ = error "unpossible"
56 go _ _ = error "unpossible"
59+newtype Unicode = Unicode {fromUnicode :: Char}
61+valid :: Unicode -> Bool
62+valid (Unicode c) = c < '\55296' || '\57343' < c
64+instance Arbitrary Unicode where
65+ arbitrary = fmap Unicode (oneof [arbitrary, arbitraryBoundedEnum]) `suchThat` valid
66+ shrink = filter valid . map (Unicode . toEnum) . shrink . fromEnum . fromUnicode
68+packUnicode :: [Unicode] -> T.Text
69+packUnicode = T.pack . map fromUnicode
71+unpackUnicode :: T.Text -> [Unicode]
72+unpackUnicode = map Unicode . T.unpack
58instance Arbitrary T.Text where
74instance Arbitrary T.Text where
59− arbitrary = T.pack <$> arbitrary
75+ arbitrary = packUnicode <$> arbitrary
76+ shrink = map packUnicode . shrink . unpackUnicode
61instance Arbitrary TL.Text where
78instance Arbitrary TL.Text where
62 arbitrary = repackT <$> arbitrary <*> arbitrary
79 arbitrary = repackT <$> arbitrary <*> arbitrary
80+ shrink = map TL.fromChunks . shrink . TL.toChunks
64repackT :: Repack -> T.Text -> TL.Text
82repackT :: Repack -> T.Text -> TL.Text
65repackT (NonEmpty bs) =
83repackT (NonEmpty bs) =