Skip to content

Instantly share code, notes, and snippets.

@SkyWriter
Forked from jferris/Example.hs
Created April 21, 2017 17:39
Show Gist options
  • Save SkyWriter/6123d23a2c3f0d734224ea67ff010be7 to your computer and use it in GitHub Desktop.
Save SkyWriter/6123d23a2c3f0d734224ea67ff010be7 to your computer and use it in GitHub Desktop.
Arrows
{-# LANGUAGE Arrows #-}
import Control.Arrow
double :: Int -> Int
double x = x * 2
triple :: Int -> Int
triple x = x * 3
increment :: Int -> Int
increment x = x + 1
combine :: Int -> Int
combine =
( double &&& increment
>>^ (\(x, y) -> x + y)
) &&& triple >>^ (\(x, y) -> x + y)
combine' :: Int -> Int
combine' = proc x -> do
a <- double -< x
b <- increment -< x
c <- triple -< x
returnA -< a + b + c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment