Deal correctly with infix type constructors in GADT decls
[ghc-hetmet.git] / compiler / ilxGen / tests / test1b.hs
1 -- To start:
2 -- source /bin/devghc
3
4 -- To compile GHC
5 -- make ilxGen/IlxGen.o hsc
6
7 -- To compile ILXASM
8 -- (cd /devel/fcom/src; make bin/ilxasm.exe) 
9
10 -- To compile to ILX
11 -- (cd ilxGen/tests; ../../../driver/ghc-inplace --ilx test.hs) 
12
13
14
15 -- To generate a complete ILX file, including preludes for GHC and ILX:
16 -- (cd ilxGen/tests/; cat prelude.ilx test.ilx  /devel/fcom/src/ilxasm/stdlib-func.ilx > test.full.ilx)
17
18 -- Run ILXASM to get a IL
19 -- ( cd ilxGen/tests/; /devel/fcom/src/bin/ilxasm.exe --no-ilasm --no-stdlib test.full.ilx > test.il)
20
21 -- To compile IL to .EXE or .DLL:
22 -- With build of VS (e.g. Don & Andrew)
23 --   ( cd ilxGen/tests/; cmd /C "c:\\bin\\devvs.bat && ilasm test.il") 
24 -- With Lightning SDK, where env. variables are on path (e.g. Reuben):
25 --   ( cd ilxGen/tests/; ilasm test.il) 
26
27 -- To validate .EXE:
28 -- (cd /devel/fcom/src; make  bin/ilvalid.exe mscorlib.vlb)
29 -- (export ILVALID_HOME=/devel/fcom/src; cd ilxGen/tests/; /devel/fcom/src/bin/ilvalid.exe test.il) 
30
31 -- To run unverifiable code:
32 -- With build of VS (e.g. Don & Andrew)
33 --    (cd ilxGen/tests/;  cmd /C "c:\\bin\\devvs.bat && .\test.exe")
34 -- With Lightning SDK, where env. variables are on path (e.g. Reuben):
35 --    (cd ilxGen/tests/; ./test.exe)
36
37 -- To compile ILX to verifiable code and verify
38 -- (cd /devel/fcom/src; make bin/ilxasm.exe bin/ilverify.exe)  && (cd ilxGen/tests/; export ILVALID_HOME=/devel/fcom/src; cat prelude.ilx  test.ilx /devel/fcom/src/assem/stdlib-func.ilx > test.full.ilx && cd ilxGen/tests/; /devel/fcom/src/bin/ilxasm.exe --no-ilasm test.full.ilx > test.safe.il && /devel/fcom/src/bin/ilverify.exe test.safe.il) 
39
40 -- (cd ilxGen/tests/;  cmd /C "c:\\bin\\devvs.bat && .\test.safe.exe")
41
42 --append:: [Char] -> [Char] -> [Char]
43 --append [] l2 = l2
44 --append (h:t) l2 = h:append t l2
45
46 data N = Z | S N
47
48 chooseN n  = 
49   case n of 
50        Z -> "even\n"
51        S Z -> "odd\n"
52        S (S m) -> chooseN m 
53
54 signN n  = 
55   case n of 
56        Z -> Z
57        S Z -> S Z
58        S (S m) -> signN m 
59 add n m = 
60    case n of
61        Z -> m  
62        S nn -> S (add nn m)
63
64 mul n m = 
65    case n of
66        Z -> Z
67        S nn -> add m (mul nn m)
68
69 pow n m = 
70    case m of
71        Z -> S Z
72        S mm -> mul n (pow n mm)
73
74 sq n = mul n n
75
76 n1 = S Z
77 n2 = add n1 n1
78 n4 = add n2 n2
79 n6 = add n2 n4
80 n8 = add n2 n6
81 n10 = add n2 n8
82 n11 = add n1 n10
83 n12 = add n1 n11
84 n13 = add n1 n12
85 n14 = add n1 n13
86 n15 = add n1 n14
87 n16 = add n1 n15
88 n17 = add n1 n16
89 n18 = add n1 n17
90 n19 = add n1 n18
91 n20 = add n1 n18
92
93 bign = pow n2 n19
94 bign1 = add bign n1
95
96 foldn f n acc = 
97    case n of
98     Z -> acc
99     S x -> foldn f x (f n acc)
100
101 main = putStr (chooseN (foldn (\x y -> add (signN x) y)  (pow n2 n4)  n1))
102
103
104