implemented toBytes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user