@@ -33,6 +33,8 @@ default(Int)
33infixl 2 :!:
33infixl 2 :!:
34data PairS a b = !a :!: !b
34data PairS a b = !a :!: !b
36+data T4 a b c d = T4 !a !b !c !d
36data Switch = S1 | S2
38data Switch = S1 | S2
38data EitherS a b = LeftS !a | RightS !b
40data EitherS a b = LeftS !a | RightS !b
@@ -217,36 +219,36 @@ restream ASCII (Stream next0 s0 len) = Stream next s0 (len*2)
217 Yield x xs -> Yield x' xs
219 Yield x xs -> Yield x' xs
218 where x' = fromIntegral (ord x) :: Word8
220 where x' = fromIntegral (ord x) :: Word8
219restream Utf8 (Stream next0 s0 len) =
221restream Utf8 (Stream next0 s0 len) =
220− Stream next ((Just s0) :!: Nothing :!: Nothing :!: Nothing) (len*2)
222+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
222 {-# INLINE next #-}
224 {-# INLINE next #-}
223− next ((Just s) :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
225+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
224 Done -> Done
226 Done -> Done
225− Skip s' -> Skip ((Just s') :!: Nothing :!: Nothing :!: Nothing)
227+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
226 Yield x xs
228 Yield x xs
227− | n <= 0x7F -> Yield c ((Just xs) :!: Nothing :!: Nothing :!: Nothing)
229+ | n <= 0x7F -> Yield c (T4 (Just xs) Nothing Nothing Nothing)
228− | n <= 0x07FF -> Yield (fst c2) ((Just xs) :!: (Just $ snd c2) :!: Nothing :!: Nothing)
230+ | n <= 0x07FF -> Yield (fst c2) (T4 (Just xs) (Just $ snd c2) Nothing Nothing)
229− | n <= 0xFFFF -> Yield (fst3 c3) ((Just xs) :!: (Just $ snd3 c3) :!: (Just $ trd3 c3) :!: Nothing)
231+ | n <= 0xFFFF -> Yield (fst3 c3) (T4 (Just xs) (Just $ snd3 c3) (Just $ trd3 c3) Nothing)
230− | otherwise -> Yield (fst4 c4) ((Just xs) :!: (Just $ snd4 c4) :!: (Just $ trd4 c4) :!: (Just $ fth4 c4))
232+ | otherwise -> Yield (fst4 c4) (T4 (Just xs) (Just $ snd4 c4) (Just $ trd4 c4) (Just $ fth4 c4))
232 n = ord x
234 n = ord x
233 c = fromIntegral n
235 c = fromIntegral n
234 c2 = U8.ord2 x
236 c2 = U8.ord2 x
235 c3 = U8.ord3 x
237 c3 = U8.ord3 x
236 c4 = U8.ord4 x
238 c4 = U8.ord4 x
237− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
239+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
238− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
240+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
239− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
241+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
240restream Utf16BE (Stream next0 s0 len) =
242restream Utf16BE (Stream next0 s0 len) =
241− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
243+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
243 {-# INLINE next #-}
245 {-# INLINE next #-}
244− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
246+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
245 Done -> Done
247 Done -> Done
246− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
248+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
247 Yield x xs
249 Yield x xs
248− | n < 0x10000 -> Yield (fromIntegral $ shiftR n 8) (Just xs :!: Just (fromIntegral n) :!: Nothing :!: Nothing)
250+ | n < 0x10000 -> Yield (fromIntegral $ shiftR n 8) (T4 (Just xs) (Just (fromIntegral n)) Nothing Nothing)
249− | otherwise -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
251+ | otherwise -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
251 n = ord x
253 n = ord x
252 n1 = n - 0x10000
254 n1 = n - 0x10000
@@ -255,19 +257,19 @@ restream Utf16BE (Stream next0 s0 len) =
255 n2 = n1 .&. 0x3FF
257 n2 = n1 .&. 0x3FF
256 c3 = fromIntegral (shiftR n2 8 + 0xDC)
258 c3 = fromIntegral (shiftR n2 8 + 0xDC)
257 c4 = fromIntegral n2
259 c4 = fromIntegral n2
258− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
260+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
259− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
261+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
260− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
262+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
261restream Utf16LE (Stream next0 s0 len) =
263restream Utf16LE (Stream next0 s0 len) =
262− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
264+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
264 {-# INLINE next #-}
266 {-# INLINE next #-}
265− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
267+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
266 Done -> Done
268 Done -> Done
267− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
269+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
268 Yield x xs
270 Yield x xs
269− | n < 0x10000 -> Yield (fromIntegral n) (Just xs :!: Just (fromIntegral $ shiftR n 8) :!: Nothing :!: Nothing)
271+ | n < 0x10000 -> Yield (fromIntegral n) (T4 (Just xs) (Just (fromIntegral $ shiftR n 8)) Nothing Nothing)
270− | otherwise -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
272+ | otherwise -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
272 n = ord x
274 n = ord x
273 n1 = n - 0x10000
275 n1 = n - 0x10000
@@ -276,43 +278,43 @@ restream Utf16LE (Stream next0 s0 len) =
276 n2 = n1 .&. 0x3FF
278 n2 = n1 .&. 0x3FF
277 c4 = fromIntegral (shiftR n2 8 + 0xDC)
279 c4 = fromIntegral (shiftR n2 8 + 0xDC)
278 c3 = fromIntegral n2
280 c3 = fromIntegral n2
279− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
281+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
280− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
282+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
281− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
283+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
282restream Utf32BE (Stream next0 s0 len) =
284restream Utf32BE (Stream next0 s0 len) =
283− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
285+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
285 {-# INLINE next #-}
287 {-# INLINE next #-}
286− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
288+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
287 Done -> Done
289 Done -> Done
288− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
290+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
289− Yield x xs -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
291+ Yield x xs -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
291 n = ord x
293 n = ord x
292 c1 = fromIntegral $ shiftR n 24
294 c1 = fromIntegral $ shiftR n 24
293 c2 = fromIntegral $ shiftR n 16
295 c2 = fromIntegral $ shiftR n 16
294 c3 = fromIntegral $ shiftR n 8
296 c3 = fromIntegral $ shiftR n 8
295 c4 = fromIntegral n
297 c4 = fromIntegral n
296− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
298+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
297− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
299+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
298− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
300+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
299restream Utf32LE (Stream next0 s0 len) =
301restream Utf32LE (Stream next0 s0 len) =
300− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
302+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
302 {-# INLINE next #-}
304 {-# INLINE next #-}
303− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
305+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
304 Done -> Done
306 Done -> Done
305− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
307+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
306− Yield x xs -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
308+ Yield x xs -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
308 n = ord x
310 n = ord x
309 c4 = fromIntegral $ shiftR n 24
311 c4 = fromIntegral $ shiftR n 24
310 c3 = fromIntegral $ shiftR n 16
312 c3 = fromIntegral $ shiftR n 16
311 c2 = fromIntegral $ shiftR n 8
313 c2 = fromIntegral $ shiftR n 8
312 c1 = fromIntegral n
314 c1 = fromIntegral n
313− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
315+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
314− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
316+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
315− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
317+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
316{-# INLINE restream #-}
318{-# INLINE restream #-}