on 0dca71e help sign in
haskell.nix/test/coverage/pkgb/src/ConduitExample.hs
21 lines 680 B history raw
1-- https://github.com/snoyberg/conduit#readme
3module ConduitExample (example) where
5import Conduit
6import System.Directory (removeFile)
8example = do
9 -- Pure operations: summing numbers.
10 print $ runConduitPure $ yieldMany [1..10] .| sumC
12 -- Exception safe file access: copy a file.
13 writeFile "input.txt" "This is a test." -- create the source file
14 runConduitRes $ sourceFileBS "input.txt" .| sinkFile "output.txt" -- actual copying
15 readFile "output.txt" >>= putStrLn -- prove that it worked
17 -- Perform transformations.
18 print $ runConduitPure $ yieldMany [1..10] .| mapC (+ 1) .| sinkList
20 removeFile "input.txt"
21 removeFile "output.txt"