Commit b63c7192 authored by ross's avatar ross
Browse files

[project @ 2003-06-19 08:50:40 by ross]

tests for arrow notation (needs arrows-branch)
parent 370509c2
test('arrow1', normal, compile, [''])
test('arrowapply1', normal, compile, [''])
test('arrowapply2', normal, compile, [''])
test('arrowapply3', normal, compile, [''])
test('arrowcase1', normal, compile, [''])
test('arrowdo1', normal, compile, [''])
test('arrowform1', normal, compile, [''])
test('arrowif1', normal, compile, [''])
# test('mod1', normal, compile_fail, [''])
# test('mod2', normal, compile_fail, [''])
......
{-# OPTIONS -fglasgow-exts #-}
module ShouldCompile where
import Control.Arrow
f :: ArrowApply a => a (a Int Int,Int,Int) Int
f = proc (x,y,z) -> x -<< 2+y
g :: ArrowApply a => Int -> a (a Int Int,Int) Int
g y = proc (x,z) -> x -<< 2+y
{-# OPTIONS -fglasgow-exts #-}
module ShouldCompile where
import Control.Arrow
g :: Arrow a => a Int c -> a Int c
g f = proc b -> f -< b+1
-- something mysterious is going wrong with the desugarer if the pattern
-- consists of a single variable.
{-# OPTIONS -fglasgow-exts #-}
module ShouldCompile where
import Control.Arrow
h :: ArrowChoice a => Int -> a (Int,Int) Int
h x = proc (y,z) -> case compare x y of
LT -> returnA -< x+y
EQ -> returnA -< y+z
GT -> returnA -< z+x
{-# OPTIONS -fglasgow-exts #-}
module ShouldCompile where
import Control.Arrow
f :: Arrow a => a (Int,Int,Int) (Int,Int)
f = proc (x,y,z) -> returnA -< (x,y)
g :: Arrow a => Int -> a (Int,Int) Int
g x = proc (y,z) -> returnA -< x*y
h :: Arrow a => Int -> a (Int,Int) Int
h x = proc (y,z) -> do
(a,c) <- f -< (x,y,3)
b <- g (2+x) -< (a,y+c)
returnA -< a*b+z
{-# OPTIONS -fglasgow-exts #-}
module ShouldCompile where
import Control.Arrow
handle :: ArrowPlus a => a b c -> a (b,String) c -> a b c
handle b h = b <+> (arr (\b -> (b,"")) >>> h)
f :: ArrowPlus a => a (Int,Int) String
f = proc (x,y) -> (|handle|) (returnA -< show y) (\s -> returnA -< s ++ show x)
inject :: Arrow a => v -> a (b,v) c -> a b c
inject v f = arr (\b -> (b,v)) >>> f
-- inject v f = proc b -> f -< (b,v)
g :: ArrowPlus a => a (Int,Int) String
g = proc (x,y) ->
(|inject "hello"|)
((|handle|)
(\msg -> returnA -< msg ++ show y)
(\s msg -> returnA -< s ++ show x))
{-# OPTIONS -fglasgow-exts #-}
module ShouldCompile where
import Control.Arrow
f :: ArrowChoice a => a (Int,Int,Int) Int
f = proc (x,y,z) -> if x < y then returnA -< x+y else returnA -< x+z
g :: ArrowChoice a => Int -> a (Int,Int) Int
g x = proc (y,z) -> if x < y then returnA -< x+y else returnA -< x+z
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment