Trying the Pipes tutorial

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Main where

import Control.Proxy

downstream :: (Proxy p) => Consumer p () IO ()
downstream () = runIdentityP $ do
  lift $ print 1
  request ()
  lift $ print 3
  request ()

upstream :: (Proxy p) => Producer p () IO ()
upstream () = runIdentityP $ do
  lift $ print 2
  respond ()
  lift $ print 4

main = runProxy $ upstream >-> downstream

Trying the Pipes tutorial (annotation from Tekmo's response)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Main where

import Control.Proxy

downstream :: (Proxy p) => () -> Consumer p () IO ()
downstream () = runIdentityP $ do
  lift $ print 1
  request ()
  lift $ print 3
  request ()

upstream :: (Proxy p) => () -> Producer p () IO ()
upstream () = runIdentityP $ do
  lift $ print 2
  respond ()
  lift $ print 4

main = runProxy $ upstream >-> downstream