blob: 9760d1372e71afcd2211f0d8f37683a42cafce30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
{-# LANGUAGE Arrows, LambdaCase #-}
module Main (main) where
import Control.Arrow
main :: IO ()
main = do
putStrLn $ foo (Just 42)
putStrLn $ foo (Just 500)
putStrLn $ foo Nothing
foo :: ArrowChoice p => p (Maybe Int) String
foo = proc x ->
(| id (\case
Just x | x > 100 -> returnA -< "big " ++ show x
| otherwise -> returnA -< "small " ++ show x
Nothing -> returnA -< "none")
|) x
foo :: ArrowChoice p => p (Maybe Int) String
foo = proc x ->
(| id (\cases
y (Just x) | x > 100 -> returnA -< "big " ++ show x
| otherwise -> returnA -< "small " ++ show x
_ Nothing -> returnA -< "none")
|) 1 x
|