Skip to content

Instantly share code, notes, and snippets.

@myme
Last active December 25, 2019 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myme/dd3c9adeab97bf7dc4ac804c82f71a5e to your computer and use it in GitHub Desktop.
Save myme/dd3c9adeab97bf7dc4ac804c82f71a5e to your computer and use it in GitHub Desktop.
import Data.Char (ord)
import Data.Conduit ((.|))
import qualified Data.Conduit as C
import qualified Data.Conduit.Combinators as C
import qualified Data.ByteString.Char8 as B
main = C.runConduit
$ C.stdin
.| C.concatMap B.words
.| C.concatMap transform
.| C.unlinesAscii
.| C.stdout
where transform = map (B.pack . show . ord) . B.unpack
[mmyrseth@set:~]$ echo -n "foo\nbar\nbaz" | runghc foo.hs
102
111
111
92
110
98
97
114
92
110
98
97
122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment