Created
October 28, 2012 06:36
-
-
Save takaki/3967886 to your computer and use it in GitHub Desktop.
blaze-builder sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Monoid | |
import Blaze.ByteString.Builder | |
import Blaze.ByteString.Builder.Char.Utf8 | |
import qualified Data.ByteString.Char8 as BSC | |
main = do | |
let end = 50000 | |
-- print $ foldl1 (++) (map show [1..end]) -- too much slow | |
print $ length $ BSC.unpack $ toByteString $ foldl1 mappend $ map fromString $ (map show) [1..end] | |
print $ length $ BSC.unpack $ foldl1 mappend $ map BSC.pack $ Prelude.map show [1..end] -- slow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment