wrote basic structure of decodeRows
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user