`builderToByteString` add an empty string when flushing.

24 views
Skip to first unread message

yi huang

unread,
May 3, 2012, 11:12:15 AM5/3/12
to yeso...@googlegroups.com
Is it intended or a bug?

{-# LANGUAGE OverloadedStrings #-}
import Data.ByteString.Char8 ()
import Data.Monoid (mappend)
import qualified Blaze.ByteString.Builder as B
import Data.Conduit.Blaze (builderToByteString)

import Data.Conduit
import qualified Data.Conduit.List as CL

main :: IO ()
main = do
    r <- CL.sourceList ["1", "2"]
           $$ CL.map B.fromByteString
           =$ CL.map (`mappend` B.flush)
           =$ builderToByteString
           =$ CL.consume
    print r 

-- output: ["1","","2",""]

Michael Snoyman

unread,
May 4, 2012, 1:40:09 AM5/4/12
to yeso...@googlegroups.com
This looks buggy to me. I'll try to look at this in the next few days.

yi huang

unread,
May 4, 2012, 2:59:22 AM5/4/12
to yeso...@googlegroups.com
I did some investigation to find that, `flush` is identical to `insertByteString S.empty`, we can make blaze-builder-conduit to ignore inserting of empty bytestring, that also prevents intentionally inserting of empty bytestring, it wouldn't cause any breakages i guess.
--
http://yi-programmer.com/

Michael Snoyman

unread,
May 4, 2012, 4:22:54 AM5/4/12
to yeso...@googlegroups.com
I like it. Thanks for the pull request, it's merged and release as 0.4.0.2.
Reply all
Reply to author
Forward
0 new messages