1{-# LANGUAGE Arrows          #-}
2{-# LANGUAGE TemplateHaskell #-}
3{-# LANGUAGE UnicodeSyntax   #-}
4
5-- See Trac #10162 and #11743 for details
6
7module ShouldCompile where
8
9import Control.Arrow
10import Language.Haskell.TH
11
12handle :: ArrowPlus a => a (b,s) c -> a (b,(String,s)) c -> a (b,s) c
13handle f h = proc (b,s) -> (f -< (b,s)) <+> (h -< (b,("FAIL",s)))
14
15f :: ArrowPlus a => a (Int,Int) String
16f = proc (x,y) ->
17handle
18    (returnA -< show y)
19    (\s -> returnA -< s ++ show x)
2021
22g :: ArrowPlus a => a (Int,Int) String
23g = proc (x,y) ->
24handle
25    (\msg -> returnA -< msg ++ show y)
26    (\s msg -> returnA -< s ++ show x)
27  ⦈ ("hello " ++ show x)
28
29h :: ArrowPlus a => a (Int,Int) Int
30h = proc (x,y) ->
31  (
32    (\z -> returnA -< x + z)
33    <+>
34    (\z -> returnA -< y + z)
35  ) (x*y)
36
37
38matches :: PatQ -> ExpQ
39matches pat = ⟦\x ->
40  case x of
41    $pat -> True
42    _    -> False
4344
45