implemented toBytes

This commit is contained in:
2022-04-19 20:12:12 -04:00
parent 67e85f0a78
commit 63b97649a6
2 changed files with 18 additions and 3 deletions
+8 -3
View File
@@ -23,7 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase, OverloadedStrings #-}
module Data.CSV.Slurp (
decodeRows,
@@ -32,7 +32,7 @@ module Data.CSV.Slurp (
toBytes,
) where
import Conduit (ConduitT, mapC, (.|))
import Conduit (ConduitT, await, mapC, yield, (.|))
import Control.Monad.Trans.State (StateT, evalStateT)
import qualified Data.ByteString as BS
import Data.Maybe (fromMaybe)
@@ -56,7 +56,12 @@ decodeUTF8 bs = case decodeUtf8' bs of
-- | convert a stream to ByteStrings to a string of bytes
toBytes :: Monad m => ConduitT BS.ByteString Word8 m ()
toBytes = return ()
toBytes = await >>= \case
Just bs -> do
let bytes = BS.unpack bs
mapM_ yield bytes
toBytes
Nothing -> return ()
data DecodeState = DecodeState
{ isQuoted :: Bool