Skip to content
Browse files

Skip a space-leaking version of the attoparsec-conduit library

  • Loading branch information...
1 parent ea6d5ae commit 058b741c8be394b280adeac70b2da1edcbc3d3cd @ozataman committed Oct 7, 2012
Showing with 39 additions and 10 deletions.
  1. +6 −1 .gitignore
  2. +2 −1 csv-conduit.cabal
  3. +10 −8 src/Data/CSV/Conduit.hs
  4. +21 −0 test/AdHoc.hs
View
7 .gitignore
@@ -4,4 +4,9 @@ dist/
cabal-dev/
.DS*
TAGS
-
+*.prof
+*.hi
+*.o
+*.ps
+*.aux
+*.hp
View
3 csv-conduit.cabal
@@ -70,14 +70,15 @@ library
hs-source-dirs: src
build-depends:
attoparsec >= 0.10
- , attoparsec-conduit
+ , attoparsec-conduit >= 0.5.0.2
, base >= 4 && < 5
, bytestring
, conduit == 0.5.*
, containers >= 0.3
, monad-control
, text
ghc-options: -funbox-strict-fields
+ ghc-prof-options: -fprof-auto
test-suite test
type: exitcode-stdio-1.0
View
18 src/Data/CSV/Conduit.hs
@@ -37,7 +37,8 @@ import qualified Data.ByteString.Char8 as B8
import Data.ByteString.Internal (c2w)
import Data.Conduit
import Data.Conduit.Attoparsec
-import Data.Conduit.Binary (sinkFile, sinkIOHandle, sourceFile)
+import Data.Conduit.Binary (sinkFile, sinkIOHandle,
+ sourceFile)
import qualified Data.Conduit.List as C
import qualified Data.Map as M
import Data.String
@@ -164,9 +165,10 @@ fromCSVRow set = do
-------------------------------------------------------------------------------
intoCSVRow :: (MonadThrow m, AttoparsecInput i)
=> Parser i (Maybe o) -> GLInfConduit i m o
-intoCSVRow p = conduitParser p >+> puller
+intoCSVRow p = parse >+> puller
where
- puller = do
+ parse = {-# SCC "conduitParser_p" #-} conduitParser p
+ puller = {-# SCC "puller" #-} do
emrow <- awaitE
case emrow of
Left ures -> return ures
@@ -260,14 +262,14 @@ readCSVFile set fp = runResourceT $ sourceFile fp $= intoCSV set $$ C.consume
-------------------------------------------------------------------------------
-- | Write CSV data into file.
writeCSVFile
- :: (CSV ByteString a)
- => CSVSettings
+ :: (CSV ByteString a)
+ => CSVSettings
-- ^ CSV Settings
- -> FilePath
+ -> FilePath
-- ^ Target file
- -> IOMode
+ -> IOMode
-- ^ Write vs. append mode
- -> [a]
+ -> [a]
-- ^ List of rows
-> IO ()
writeCSVFile set fo fmode rows = runResourceT $ do
View
21 test/AdHoc.hs
@@ -0,0 +1,21 @@
+module Main where
+
+
+import qualified Data.ByteString.Char8 as B
+import Data.Conduit
+import Data.Conduit.Binary
+import Data.CSV.Conduit
+import Data.Map ((!))
+import System.Directory
+import System.Environment
+
+
+-------------------------------------------------------------------------------
+main = do
+ fi : fo : _ <- getArgs
+ runResourceT $ mapCSVFile defCSVSettings f fi fo
+ -- runResourceT $ sourceFile fi $$ sinkFile fo
+
+
+f :: Row B.ByteString -> [Row B.ByteString]
+f = return

0 comments on commit 058b741

Please sign in to comment.
Something went wrong with that request. Please try again.