
On 4/26/07, Joe Thornber
but it's simpler to just write something like:
test = putStr $ unlines ["I", "need", "multiline", "string", "literals"]
Yes I know. My aim was just to see if I could do it with as less syntax as possible and then the 'do' syntax is handy. Another question: If I change: type MLS = Writer (Endo [B.ByteString]) () instance IsString MLS where fromString s = tell $ Endo (fromString s:) instance ToString MLS where toString w = toString $ B.unlines $ (appEndo $ execWriter w) [] to the simpler: type MLS2 = Writer [B.ByteString] () instance IsString MLS2 where fromString s = tell [fromString s] instance ToString MLS2 where toString = toString . B.unlines . execWriter then MLS2 is a bit faster (about 0.4 sec. when applied to a million strings). I thought the former MLS should be faster because it doesn't have to mappend every [fromString s]. MLS just 'builds' a large function: "(fromString s:) . (fromString s:) . (fromString s:) ... id []" Can anybody explain why MLS2 is faster? Thanks, Bas van Dijk