@@ -36,6 +36,9 @@ import Data.Word (Word8)
3636import GHC.Conc (numCapabilities)
3737import System.Environment (getArgs)
3838import System.IO (Handle, openFile, IOMode(..))
39+import Streamly.Internal.Data.Unicode.Stream
40+ (DecodeState, DecodeError(..), CodePoint, decodeUtf8Either,
41+ resumeDecodeUtf8Either)
3942
4043import qualified Streamly as S
4144import qualified Streamly.Data.Unicode.Stream as S
@@ -239,7 +242,7 @@ resetHeaderOnNewChar counts = do
239242-- Manipulating the trailer
240243-------------------------------------------------------------------------------
241244
242−setTrailer :: V.IOVector Int -> S.DecodeState -> S.CodePoint -> IO ()
245+setTrailer :: V.IOVector Int -> DecodeState -> CodePoint -> IO ()
243246setTrailer counts st cp = do
244247 writeField counts TrailerState (fromIntegral st)
245248 writeField counts TrailerCodePoint cp
@@ -257,7 +260,7 @@ resetTrailerOnNewChar counts = do
257260-------------------------------------------------------------------------------
258261
259262{-# INLINE countChar #-}
260−countChar :: V.IOVector Int -> Either S.DecodeError Char -> IO ()
263+countChar :: V.IOVector Int -> Either DecodeError Char -> IO ()
261264countChar counts inp =
262265 case inp of
263266 Right ch -> do
@@ -272,7 +275,7 @@ countChar counts inp =
272275 wasSpace <- readField counts WasSpace
273276 when (wasSpace /= 0) $ modifyField counts WordCount (+ 1)
274277 accountChar counts False
275− Left (S.DecodeError st cp) -> do
278+ Left (DecodeError st cp) -> do
276279 hdone <- readField counts HeaderDone
277280 if hdone == 0
278281 then do
@@ -309,7 +312,7 @@ _wc_mwl_parserial :: Handle -> IO (V.IOVector Int)
309312_wc_mwl_parserial src = do
310313 counts <- newCounts
311314 S.mapM_ (countChar counts)
312− $ S.decodeUtf8Either
315+ $ decodeUtf8Either
313316 $ S.unfold FH.read src
314317 return counts
315318
@@ -348,7 +351,7 @@ _wc_mwl_serial src = print =<< (
348351reconstructChar :: Int
349352 -> V.IOVector Int
350353 -> V.IOVector Int
351− -> IO (S.SerialT IO (Either S.DecodeError Char))
354+ -> IO (S.SerialT IO (Either DecodeError Char))
352355reconstructChar hdrCnt v1 v2 = do
353356 when (hdrCnt > 3 || hdrCnt < 0) $ error "reconstructChar: hdrCnt > 3"
354357 stream1 <-
@@ -372,7 +375,7 @@ reconstructChar hdrCnt v1 v2 = do
372375
373376 state <- readField v1 TrailerState
374377 cp <- readField v1 TrailerCodePoint
375− return $ S.resumeDecodeUtf8Either (fromIntegral state) cp stream3
378+ return $ resumeDecodeUtf8Either (fromIntegral state) cp stream3
376379
377380getHdrChar :: V.IOVector Int -> IO (Maybe Int)
378381getHdrChar v = do
@@ -543,7 +546,7 @@ addCounts v1 v2 = do
543546 writeField v1 TrailerState trailerState2
544547 writeField v1 TrailerCodePoint trailerCodePoint2
545548 return v1
546− Left (S.DecodeError st cp) -> do
549+ Left (DecodeError st cp) -> do
547550 -- if header was incomplete it may result
548551 -- in partially decoded char to be written
549552 -- as trailer. Check if the last error is
@@ -554,7 +557,7 @@ addCounts v1 v2 = do
554557 Nothing -> (st, cp)
555558 Just lst -> case lst of
556559 Right _ -> error "addCounts: Bug"
557− Left (S.DecodeError st1 cp1) -> (st1, cp1)
560+ Left (DecodeError st1 cp1) -> (st1, cp1)
558561 if hdone2 == 0 && st' /= 12
559562 then do
560563 -- all elements before the last one must be errors
@@ -593,7 +596,7 @@ countArray :: A.Array Word8 -> IO (V.IOVector Int)
593596countArray src = do
594597 counts <- newCounts
595598 S.mapM_ (countChar counts)
596− $ S.decodeUtf8Either
599+ $ decodeUtf8Either
597600 $ S.unfold A.read src
598601 return counts
599602