Ticket #1541: th-fixity.txt

File th-fixity.txt, 0.6 KB (added by ekmett@…, 6 years ago)

minimalist example

Line 
1module Foo where
2import Language.Haskell.TH
3
4defBinOp name op =
5        classD (cxt [] (mkName name) [a,b,c]
6                [FunDep [a,b] [c], FunDep [b,c] [a], FunDep [a,c] [b]]
7                [ sigD (mkName op) $ binOp a b c]
8 where
9        a = mkName "a"
10        b = mkName "b"
11        c = mkName "c"
12        binOp l m n = arrowT `appT` varT l `appT` (arrowT `appT` varT m `appT` varT n)
13
14
15module Bar where
16import Foo
17import Prelude ()
18-- infixl 6 +  -- illegal here, because TH not yet evaluated
19$(defBinOp "Add" "+")
20
21module Baz (module Bar) where
22import Bar
23-- infixl 6 + -- illegal here, because its another module!