Last active
December 26, 2015 20:19
-
-
Save michaelt/7207991 to your computer and use it in GitHub Desktop.
unlines . lines
This file contains hidden or 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
{-#LANGUAGE OverloadedStrings#-} | |
import qualified Data.Text.Lazy as TL | |
import qualified Data.Text.Lazy.IO as TL | |
import qualified Data.Text as T | |
import qualified Data.Text.Encoding as T | |
import Pipes | |
import qualified Pipes.Text as PT | |
import qualified Data.ByteString.Lazy.Char8 as BL | |
import qualified Data.ByteString.Char8 as B | |
import qualified Pipes.ByteString as PB | |
import Control.Monad | |
main = forM_ tests $ \strs -> | |
do let txt = map T.pack strs | |
bs = map B.pack strs | |
t = TL.unlines . TL.lines . TL.fromChunks | |
pt = PT.toLazy . PT.unlines . PT.lines . each | |
b = BL.unlines . BL.lines . BL.fromChunks | |
pb = PB.toLazy . PB.unlines . PB.lines . each | |
tw = TL.unwords . TL.words . TL.fromChunks | |
ptw = PT.toLazy . PT.unwords . PT.words . each | |
bw = BL.unwords . BL.words . BL.fromChunks | |
pbw = PB.toLazy . PB.unwords . PB.words . each | |
print strs | |
print $ unlines . lines . concat $ strs | |
print $ t txt | |
print $ pt txt | |
print $ b bs | |
print $ pb bs | |
print $ unwords . words . concat $ strs | |
print $ tw txt | |
print $ ptw txt | |
print $ bw bs | |
print $ pbw bs | |
tests = [["x"],["\n"," "], ["\n"," ","\n"], ["x\n", " \n", "x"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment