@@ -97,10 +97,12 @@ reverseStream (Text arr off len) = Stream next (off+len-1) (maxSize len)
97unstream :: Stream Char -> Text
97unstream :: Stream Char -> Text
98unstream (Stream next0 s0 len) = a
98unstream (Stream next0 s0 len) = a
100− a = runText (\done -> A.new mlen >>= \arr -> outer done arr mlen s0 0)
100+ a = runText (\done -> A.new mlen >>= \arr -> first done arr mlen s0 0)
101 where mlen = upperBound 4 len
101 where mlen = upperBound 4 len
102− outer done arr top = loop
104+ outer arr top = loop
104 loop !s !i =
106 loop !s !i =
105 case next0 s of
107 case next0 s of
106 Done -> done arr i
108 Done -> done arr i
@@ -110,7 +112,7 @@ unstream (Stream next0 s0 len) = a
110 let top' = (top + 1) `shiftL` 1
112 let top' = (top + 1) `shiftL` 1
111 arr' <- A.new top'
113 arr' <- A.new top'
112 A.copyM arr' 0 arr 0 top
114 A.copyM arr' 0 arr 0 top
113− outer done arr' top' s i
115+ outer arr' top' s i
114 | otherwise -> do d <- unsafeWrite arr i x
116 | otherwise -> do d <- unsafeWrite arr i x
115 loop s' (i+d)
117 loop s' (i+d)
116 where j | ord x < 0x10000 = i
118 where j | ord x < 0x10000 = i