Created
June 16, 2012 13:18
-
-
Save MgaMPKAy/2941316 to your computer and use it in GitHub Desktop.
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
import Control.Monad | |
type Reciver a = [a] -> IO () | |
type Sender a = [a] | |
sender :: Int -> Sender Int | |
sender n = n : sender (n + 1) | |
printer :: Show a => Reciver a | |
printer = mapM_ print | |
ignore :: Reciver a | |
ignore _ = return () | |
growth :: Show a => Reciver a | |
growth = mapM_ (putStrLn . concat . (replicate 2) . show) | |
split :: [Reciver a] -> Sender a -> IO () | |
split recvers [] = return () | |
split recvers (x:xs) = forM_ recvers (\r -> r [x]) >> split recvers xs | |
main = sender 1 |> take 10 |> split [printer, ignore, growth] | |
x |> f = f x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment