module Data.Repa.Flow.Default.IO.TSV
(sourceTSV)
where
import Data.Repa.Flow.Default
import Data.Repa.Flow.IO.Bucket
import Data.Repa.Array as A
import Data.Repa.Array.Material as A
import Data.Char
import qualified Data.Repa.Flow.Generic.IO as G
import qualified Data.Repa.Flow.Generic as G
#include "repa-flow.h"
sourceTSV
:: BulkI l Bucket
=> Integer
-> IO ()
-> Array l Bucket
-> IO (Sources N (Array N (Array F Char)))
sourceTSV nChunk aFail bs
= do
let !nl = fromIntegral $ ord '\n'
let !nr = fromIntegral $ ord '\r'
let !nt = fromIntegral $ ord '\t'
sChunk <- G.sourceChunks nChunk (== nl) aFail bs
sRows8 <- G.map_i (A.diceSep nt nl . A.filter U (/= nr)) sChunk
sRows <- G.map_i
(A.mapElems (A.mapElems
(A.computeS F . A.map (chr . fromIntegral))))
sRows8
return sRows