Created
June 30, 2012 13:42
-
-
Save joker1007/3023787 to your computer and use it in GitHub Desktop.
This file contains 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
{-# LANGUAGE Arrows #-} | |
import Control.Arrow | |
multiply2 :: (Num a) => (->) a a | |
multiply2 = arr (\x -> x * 2) | |
multiply4 :: (Num a) => (->) a a | |
multiply4 = arr (\x -> x * 4) | |
addA f g = proc x -> do | |
y <- f -< x | |
z <- g -< x | |
returnA -< (y + z) | |
plus1 :: Int -> Int | |
plus1 = proc x -> returnA -< (x + 1) | |
plus3 :: Int -> Int | |
plus3 = proc x -> returnA -< (x + 3) | |
plus2 :: Int -> Int | |
plus2 = proc y -> do x <- plus1 -< y | |
plus1 -< x | |
comparr :: Int -> Int | |
comparr = plus1 >>> plus3 >>> plus2 | |
main :: IO() | |
main = putStrLn $ show $ addA multiply2 multiply4 (5.5 :: Float) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment