arrowform1.hs 605 Bytes
Newer Older
1
{-# OPTIONS -farrows #-}
ross's avatar
ross committed
2
3
4
5
6
7

module ShouldCompile where

import Control.Arrow

handle :: ArrowPlus a => a b c -> a (b,String) c -> a b c
ross's avatar
ross committed
8
handle f h = proc b -> (f -< b) <+> (h -< (b,""))
ross's avatar
ross committed
9
10

f :: ArrowPlus a => a (Int,Int) String
ross's avatar
ross committed
11
f = proc (x,y) ->
ross's avatar
ross committed
12
13
14
15
	(|handle
		(returnA -< show y)
		(\s -> returnA -< s ++ show x)
	|)
ross's avatar
ross committed
16
17
18

g :: ArrowPlus a => a (Int,Int) String
g = proc (x,y) ->
ross's avatar
ross committed
19
20
21
22
	(|handle
		(\msg -> returnA -< msg ++ show y)
		(\s msg -> returnA -< s ++ show x)
	|) ("hello " ++ show x)
ross's avatar
ross committed
23

ross's avatar
ross committed
24
h :: ArrowPlus a => a (Int,Int) Int
ross's avatar
ross committed
25
h = proc (x,y) ->
ross's avatar
ross committed
26
27
	(
		(\z -> returnA -< x + z)
ross's avatar
ross committed
28
		<+>
ross's avatar
ross committed
29
30
		(\z -> returnA -< y + z)
	) (x*y)