Skip to content

Instantly share code, notes, and snippets.

@ivanbrennan
Created March 15, 2019 02:54
Show Gist options
  • Save ivanbrennan/b037448f368c660bc84da5ae1eaf060c to your computer and use it in GitHub Desktop.
Save ivanbrennan/b037448f368c660bc84da5ae1eaf060c to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (ps: [ps.conduit])"
import Conduit
trans :: Monad m => ConduitT Int Int m ()
trans = do
takeC 3 .| mapC (+ 1)
takeC 3 .| mapC (* 2)
xs <- foldlC (\z x -> x : (take 2 z)) []
yieldMany (reverse xs) .| mapC (* 10)
main :: IO ()
main = runConduit $ yieldMany [1..10]
.| trans
.| mapM_C print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment