wrote basic structure of decodeRows

This commit is contained in:
2022-04-19 16:03:14 -04:00
parent 365dc3995b
commit 08c77d4d0f
5 changed files with 70 additions and 4 deletions

View File

@@ -23,6 +23,29 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
module Data.CSV.Slurp where
{-# LANGUAGE OverloadedStrings #-}
module Data.CSV.Slurp (
decodeRows,
decodeRawRows,
decodeUTF8,
) where
import Conduit (ConduitT, mapC, (.|))
import qualified Data.ByteString as BS
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
-- | decode the rows from a stream of ByteStrings
decodeRows :: Monad m => ConduitT BS.ByteString [T.Text] m ()
decodeRows = decodeRawRows .| mapC (map $ fromMaybe "" . decodeUTF8)
-- | decode the rows returning raw ByteStrings instead of text
decodeRawRows :: Monad m => ConduitT BS.ByteString [BS.ByteString] m ()
decodeRawRows = return ()
-- | decode a raw ByteString into Text (if possible)
decodeUTF8 :: BS.ByteString -> Maybe T.Text
decodeUTF8 = const Nothing
--jl