1 module Main (main) -- TEST
7 c_eps=(5.00000e-06 :: Double);
13 r_x=[(a_tf,(++) (show a_i) ((++) "\t" a_str))|(a_i,(a_tf,a_str))<-f_zip2 (enumFrom (1 :: Int)) c_testlist];
14 r_noks=[(++) a_str "\n"|(a_tf,a_str)<-r_x,not a_tf];
15 r_oks=[(++) a_str "\n"|(a_tf,a_str)<-r_x,a_tf]
17 if (((>) :: (Int -> Int -> Bool)) a_n (0 :: Int))
18 then (f_onetest ((!!) c_testlist (((-) :: (Int -> Int -> Int)) a_n (1 :: Int))))
20 ((++) (show (length r_oks)) ((++) " tests passed and " ((++) (show
21 (length r_noks)) ((++) " failed\n" (c_concat r_noks)))));
22 f_onetest (True,a_str)=(++) "true: " ((++) a_str "\n");
23 f_onetest (False,a_str)=(++) "false: " ((++) a_str "\n");
24 f_booltest a_name True a_try=
28 (False,(++) a_name "\tok: true is: false");
29 f_booltest a_name False a_try=
33 (False,(++) a_name "\tok: false is: true");
34 f_inttest a_name a_ok a_try=
35 if (((==) :: (Int -> Int -> Bool)) a_ok a_try)
38 (False,(++) a_name ((++) "\tok: " ((++) (show a_ok) ((++) "\tis: "
40 f_chartest a_name a_ok a_try=
41 if (((==) :: (Int -> Int -> Bool)) (fromEnum a_ok) (fromEnum a_try))
44 (False,(++) a_name ((++) "\tok: " ((++) ((:) a_ok []) ((++) "\tis: "
46 f_strtest a_name a_ok a_try=
47 if (strcmp a_ok a_try)
50 (False,(++) a_name ((++) "\tok: " ((++) a_ok ((++) "\tis: " a_try))));
51 f_linttest a_name a_ok a_try=
52 if (f_lintcmp a_ok a_try)
55 (False,(++) a_name ((++) "\tok: " ((++) (f_showlint a_ok) ((++) "\tis: "
56 (f_showlint a_try)))));
57 f_doubtest a_name a_ok a_try=
58 if (((<=) :: (Double -> Double -> Bool)) (f_abs (((-) :: (Double -> Double -> Double)) a_ok a_try)) c_eps)
61 (False,(++) a_name ((++) "\tok: " ((++) (show a_ok) ((++) "\tis: "
62 ((++) (show a_try) ((++) "\tok-is: " (show (((-) :: (Double -> Double -> Double)) a_ok a_try))))))));
63 f_alternating a_l=(:) (0 :: Int) ((:) (1 :: Int) a_l);
65 f_showlint a_xs=tail (c_concat [(++) "," (show a_x)|a_x<-a_xs]);
67 f_lintcmp [] a_ys=False;
68 f_lintcmp a_xs []=False;
69 f_lintcmp (a_x:a_xs) (a_y:a_ys)=
70 if (((==) :: (Int -> Int -> Bool)) a_x a_y)
71 then (f_lintcmp a_xs a_ys)
74 c_testlist=(:) (f_inttest "array" (10 :: Int) ((!) (array (descr (1 :: Int) (3 :: Int)) ((:)
75 ((,) (3 :: Int) (30 :: Int)) ((:) ((,) (1 :: Int) (10 :: Int)) ((:) ((,) (2 :: Int) (20 :: Int)) [])))) (1 :: Int))) ((:) (f_inttest "array" (20 :: Int)
76 ((!) (array (descr (1 :: Int) (3 :: Int)) ((:) ((,) (3 :: Int) (30 :: Int)) ((:) ((,) (1 :: Int) (10 :: Int))
77 ((:) ((,) (2 :: Int) (20 :: Int)) [])))) (2 :: Int))) ((:) (f_inttest "array" (30 :: Int) ((!) (array (descr (1 :: Int) (3 :: Int))
78 ((:) ((,) (3 :: Int) (30 :: Int)) [])) (3 :: Int))) ((:) (f_inttest "assoc" (0 :: Int) (indassoc ((,) (0 :: Int) (1 :: Int)))) ((:)
79 (f_inttest "assoc" (1 :: Int) (valassoc ((,) (0 :: Int) (1 :: Int)))) ((:) (f_inttest "bounds" (1 :: Int) (lowbound (bounds
80 (listArray (descr (1 :: Int) (3 :: Int)) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) []))))))) ((:) (f_inttest "bounds" (3 :: Int)
81 (upbound (bounds (listArray (descr (1 :: Int) (3 :: Int)) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))))))
82 ((:) (f_inttest "descr" (0 :: Int) (lowbound (descr (0 :: Int) (1 :: Int)))) ((:) (f_inttest "descr" (1 :: Int) (upbound
83 (descr (0 :: Int) (1 :: Int)))) ((:) (f_linttest "destr_update" ((:) (1 :: Int) ((:) (0 :: Int) ((:) (3 :: Int) []))) (elems
84 (destr_update (listArray (descr (0 :: Int) (2 :: Int)) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))) (1 :: Int) (0 :: Int)))) ((:)
85 (f_linttest "destr_update" ((:) (0 :: Int) []) (elems (destr_update (listArray (descr (0 :: Int) (0 :: Int)) ((:) (1 :: Int)
86 ((:) (2 :: Int) ((:) (3 :: Int) [])))) (0 :: Int) (0 :: Int)))) ((:) (f_linttest "elems" ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))
87 (elems (listArray (descr (0 :: Int) (2 :: Int)) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))))) ((:)
88 (f_linttest "elems" ((:) (1 :: Int) []) (elems (listArray (descr (0 :: Int) (0 :: Int)) ((:) (1 :: Int) ((:) (2 :: Int)
89 ((:) (3 :: Int) [])))))) ((:) (f_inttest "indassoc" (0 :: Int) (indassoc ((,) (0 :: Int) (1 :: Int)))) ((:) (f_linttest "listarray"
90 ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) []))) (elems (listArray (descr (0 :: Int) (2 :: Int)) ((:) (1 :: Int)
91 ((:) (2 :: Int) ((:) (3 :: Int) [])))))) ((:) (f_linttest "listarray" ((:) (1 :: Int) []) (elems (listArray
92 (descr (0 :: Int) (0 :: Int)) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))))) ((:) (f_inttest "lowbound" (0 :: Int) (lowbound
93 (descr (0 :: Int) (1 :: Int)))) ((:) (f_inttest "subscript" (1 :: Int) ((!) (tabulate ((!!) ((:) (1 :: Int)
94 ((:) (2 :: Int) ((:) (3 :: Int) [])))) (descr (0 :: Int) (2 :: Int))) (0 :: Int))) ((:) (f_inttest "subscript" (2 :: Int) ((!) (tabulate
95 ((!!) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))) (descr (0 :: Int) (2 :: Int))) (1 :: Int))) ((:) (f_inttest "subscript" (3 :: Int)
96 ((!) (tabulate ((!!) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))) (descr (0 :: Int) (2 :: Int))) (2 :: Int)))
97 ((:) (f_linttest "tabulate" ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) []))) (elems (tabulate
98 ((!!) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) [])))) (descr (0 :: Int) (2 :: Int))))) ((:) (f_linttest "tabulate"
99 ((:) (1 :: Int) []) (elems (tabulate ((!!) ((:) (1 :: Int) ((:) (2 :: Int) ((:) (3 :: Int) []))))
100 (descr (0 :: Int) (0 :: Int))))) ((:) (f_inttest "upbound" (1 :: Int) (upbound (descr (0 :: Int) (1 :: Int)))) ((:) (f_inttest "valassoc" (1 :: Int)
101 (valassoc ((,) (0 :: Int) (1 :: Int)))) ((:) (f_doubtest "add_x" (0.00000 :: Double) (realPart (((+) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (0.00000 :: Double) (0.00000 :: Double))
102 ((:+) (0.00000 :: Double) (0.00000 :: Double))))) ((:) (f_doubtest "add_x" (0.00000 :: Double) (imagPart (((+) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (0.00000 :: Double) (0.00000 :: Double)) ((:+) (0.00000 :: Double) (0.00000 :: Double)))))
103 ((:) (f_doubtest "add_x" (4.00000 :: Double) (realPart (((+) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (1.00000 :: Double) (2.00000 :: Double)) ((:+) (3.00000 :: Double) (4.00000 :: Double))))) ((:)
104 (f_doubtest "add_x" (6.00000 :: Double) (imagPart (((+) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (1.00000 :: Double) (2.00000 :: Double)) ((:+) (3.00000 :: Double) (4.00000 :: Double))))) ((:) (f_doubtest "complex" (1.00000 :: Double)
105 (realPart ((:+) (1.00000 :: Double) (0.00000 :: Double)))) ((:) (f_doubtest "complex" (1.00000 :: Double) (imagPart ((:+) (0.00000 :: Double) (1.00000 :: Double)))) ((:)
106 (f_doubtest "complex_im" (0.00000 :: Double) (imagPart ((:+) (1.00000 :: Double) (0.00000 :: Double)))) ((:) (f_doubtest "complex_im" (1.00000 :: Double) (imagPart ((:+) (0.00000 :: Double) (1.00000 :: Double))))
107 ((:) (f_doubtest "complex_re" (0.00000 :: Double) (realPart ((:+) (0.00000 :: Double) (1.00000 :: Double)))) ((:) (f_doubtest "complex_re" (1.00000 :: Double) (realPart
108 ((:+) (1.00000 :: Double) (0.00000 :: Double)))) ((:) (f_doubtest "mul_x" (0.00000 :: Double) (realPart (((*) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (0.00000 :: Double) (0.00000 :: Double)) ((:+) (0.00000 :: Double) (0.00000 :: Double)))))
109 ((:) (f_doubtest "mul_x" (0.00000 :: Double) (imagPart (((*) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (0.00000 :: Double) (0.00000 :: Double)) ((:+) (0.00000 :: Double) (0.00000 :: Double))))) ((:)
110 (f_doubtest "mul_x" (((negate) :: (Double -> Double)) (5.00000 :: Double)) (realPart (((*) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (1.00000 :: Double) (2.00000 :: Double)) ((:+) (3.00000 :: Double) (4.00000 :: Double))))) ((:)
111 (f_doubtest "mul_x" (10.0000 :: Double) (imagPart (((*) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (1.00000 :: Double) (2.00000 :: Double)) ((:+) (3.00000 :: Double) (4.00000 :: Double))))) ((:) (f_doubtest "sub_x" (0.00000 :: Double)
112 (realPart (((-) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (0.00000 :: Double) (0.00000 :: Double)) ((:+) (0.00000 :: Double) (0.00000 :: Double))))) ((:) (f_doubtest "sub_x" (0.00000 :: Double) (imagPart
113 (((-) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (0.00000 :: Double) (0.00000 :: Double)) ((:+) (0.00000 :: Double) (0.00000 :: Double))))) ((:) (f_doubtest "sub_x" (((negate) :: (Double -> Double)) (2.00000 :: Double)) (realPart
114 (((-) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (1.00000 :: Double) (2.00000 :: Double)) ((:+) (3.00000 :: Double) (4.00000 :: Double))))) ((:) (f_doubtest "sub_x" (((negate) :: (Double -> Double)) (2.00000 :: Double)) (imagPart
115 (((-) :: (Complex_type -> Complex_type -> Complex_type)) ((:+) (1.00000 :: Double) (2.00000 :: Double)) ((:+) (3.00000 :: Double) (4.00000 :: Double))))) ((:) (f_inttest "seq" (2 :: Int) (seq (enumFrom (1 :: Int)) (2 :: Int)))
116 ((:) (f_strtest "**" "this one" "should fail") [])))))))))))))))))))))))))))))))))))))))))));
118 if (((<=) :: (Double -> Double -> Bool)) a_x (0.00000 :: Double))
119 then (((negate) :: (Double -> Double)) a_x)
122 c_and=f_foldr (&&) True;
125 r_margin=((-) :: (Int -> Int -> Int)) a_n (length a_s);
126 r_lmargin=((div) :: (Int -> Int -> Int)) r_margin (2 :: Int);
127 r_rmargin=((-) :: (Int -> Int -> Int)) r_margin r_lmargin
128 } in (++) (f_spaces r_lmargin) ((++) a_s (f_spaces r_rmargin));
129 c_concat=f_foldr (++) [];
132 if (((<=) :: (Int -> Int -> Bool)) (fromEnum '0') (fromEnum a_x))
133 then (((<=) :: (Int -> Int -> Bool)) (fromEnum a_x) (fromEnum '9'))
137 f_drop a_n (a_a:a_x)=f_drop (((-) :: (Int -> Int -> Int)) a_n (1 :: Int)) a_x;
139 f_dropwhile a_f []=[];
140 f_dropwhile a_f (a_a:a_x)=
142 then (f_dropwhile a_f a_x)
145 c_e=((exp) :: (Double -> Double)) (1.00000 :: Double);
146 f_filter a_f a_x=[a_a|a_a<-a_x,a_f a_a];
147 f_foldl a_op a_r []=a_r;
148 f_foldl a_op a_r (a_a:a_x)=
150 f_strict a_f a_x=seq a_x (a_f a_x)
151 } in f_foldl a_op (f_strict a_op a_r a_a) a_x;
152 f_foldl1 a_op (a_a:a_x)=f_foldl a_op a_a a_x;
153 f_foldr a_op a_r []=a_r;
154 f_foldr a_op a_r (a_a:a_x)=a_op a_a (f_foldr a_op a_r a_x);
155 f_foldr1 a_op (a_a:[])=a_a;
156 f_foldr1 a_op (a_a:a_b:a_x)=a_op a_a (f_foldr1 a_op ((:) a_b a_x));
162 f_f a_n (a_a:a_x)=(:) a_n (f_f (((+) :: (Int -> Int -> Int)) a_n (1 :: Int)) a_x)
163 } in f_f (0 :: Int) a_x;
168 ((:) a_a (f_init a_x));
169 f_iterate a_f a_x=(:) a_x (f_iterate a_f (a_f a_x));
170 f_last a_x=(!!) a_x (((-) :: (Int -> Int -> Int)) (length a_x) (1 :: Int));
172 f_lay (a_a:a_x)=(++) a_a ((++) "\n" (f_lay a_x));
176 f_f a_n (a_a:a_x)=(++) (f_rjustify (4 :: Int) (show a_n)) ((++) ") " ((++) a_a ((++) "\n"
177 (f_f (((+) :: (Int -> Int -> Int)) a_n (1 :: Int)) a_x))))
178 } in f_f (1 :: Int) a_x;
181 if (((<=) :: (Int -> Int -> Bool)) (fromEnum 'a') (fromEnum a_c))
182 then (((<=) :: (Int -> Int -> Bool)) (fromEnum a_c) (fromEnum 'z'))
187 if (((<=) :: (Int -> Int -> Bool)) (fromEnum 'A') (fromEnum a_c))
188 then (((<=) :: (Int -> Int -> Bool)) (fromEnum a_c) (fromEnum 'Z'))
191 f_limit (a_a:a_b:a_x)=
192 if (((==) :: (Double -> Double -> Bool)) a_a a_b)
195 (f_limit ((:) a_b a_x));
205 if (((==) :: (Int -> Int -> Bool)) (fromEnum a_a) (fromEnum '\o012'))
206 then ((:) [] (f_lines a_x))
208 ((:) ((:) a_a (head r_xs)) (tail r_xs));
209 f_ljustify a_n a_s=(++) a_s (f_spaces (((-) :: (Int -> Int -> Int)) a_n (length a_s)));
210 f_map a_f a_x=[a_f a_a|a_a<-a_x];
211 f_map2 a_f a_x a_y=[a_f a_a a_b|(a_a,a_b)<-f_zip2 a_x a_y];
212 f_max a_xs=f_foldl1 f_max2 a_xs;
214 if (((>=) :: (Int -> Int -> Bool)) a_a a_b)
218 f_member a_x a_a=c_or (f_map (flip ((==) :: (Int -> Int -> Bool)) a_a) a_x);
220 f_merge (a_a:a_x) []=(:) a_a a_x;
221 f_merge (a_a:a_x) (a_b:a_y)=
222 if (((<=) :: (Int -> Int -> Bool)) a_a a_b)
223 then ((:) a_a (f_merge a_x ((:) a_b a_y)))
225 ((:) a_b (f_merge ((:) a_a a_x) a_y));
226 f_min a_xs=f_foldl1 f_min2 a_xs;
228 if (((>) :: (Int -> Int -> Bool)) a_a a_b)
233 f_mkset (a_a:a_x)=(:) a_a (f_filter (flip ((/=) :: (Int -> Int -> Bool)) a_a) (f_mkset a_x));
234 c_or=f_foldr (||) False;
235 c_pi=((*) :: (Double -> Double -> Double)) (4.00000 :: Double) (((atan) :: (Double -> Double)) (1.00000 :: Double));
236 f_postfix a_a a_x=(++) a_x ((:) a_a []);
237 c_product=f_foldl ((*) :: (Int -> Int -> Int)) (1 :: Int);
238 f_rep a_n a_x=f_take a_n (f_repeat a_x);
239 f_repeat a_x=(:) a_x (f_repeat a_x);
240 c_reverse=f_foldl (flip (:)) [];
241 f_rjustify a_n a_s=(++) (f_spaces (((-) :: (Int -> Int -> Int)) a_n (length a_s))) a_s;
244 f_g a_r []=(:) a_r [];
245 f_g a_r (a_a:a_x)=(:) a_r (f_g (a_op a_r a_a) a_x)
251 r_n2=((div) :: (Int -> Int -> Int)) r_n (2 :: Int)
253 if (((<=) :: (Int -> Int -> Bool)) r_n (1 :: Int))
256 (f_merge (f_sort (f_take r_n2 a_x)) (f_sort (f_drop r_n2 a_x)));
257 f_spaces a_n=f_rep a_n ' ';
258 f_subtract a_x a_y=((-) :: (Int -> Int -> Int)) a_y a_x;
259 c_sum=f_foldl ((+) :: (Int -> Int -> Int)) (0 :: Int);
261 T_sys_message=F_Stdout [Char] | F_Stderr [Char] | F_Tofile [Char] [Char] | F_Closefile [Char] | F_Appendfile [Char] | F_System [Char] | F_Exit Int;
263 f_take a_n (a_a:a_x)=(:) a_a (f_take (((-) :: (Int -> Int -> Int)) a_n (1 :: Int)) a_x);
265 f_takewhile a_f []=[];
266 f_takewhile a_f (a_a:a_x)=
268 then ((:) a_a (f_takewhile a_f a_x))
273 r_x'=f_takewhile pair a_x
278 ((:) (f_map head r_x') (f_transpose (f_map tail r_x')));
283 (f_until a_f a_g (a_g a_x));
284 f_zip2 (a_a:a_x) (a_b:a_y)=(:) (a_a,a_b) (f_zip2 a_x a_y);
286 f_zip3 (a_a:a_x) (a_b:a_y) (a_c:a_z)=(:) (a_a,a_b,a_c) (f_zip3 a_x a_y a_z);
287 f_zip3 a_x a_y a_z=[];
288 f_zip4 (a_a:a_w) (a_b:a_x) (a_c:a_y) (a_d:a_z)=(:) (a_a,a_b,a_c,a_d) (f_zip4 a_w a_x a_y a_z);
289 f_zip4 a_w a_x a_y a_z=[];
290 f_zip5 (a_a:a_v) (a_b:a_w) (a_c:a_x) (a_d:a_y) (a_e:a_z)=(:) (a_a,a_b,a_c,a_d,a_e) (f_zip5 a_v a_w a_x a_y a_z);
291 f_zip5 a_v a_w a_x a_y a_z=[];
292 f_zip6 (a_a:a_u) (a_b:a_v) (a_c:a_w) (a_d:a_x) (a_e:a_y) (a_f:a_z)=(:) (a_a,a_b,a_c,a_d,a_e,a_f) (f_zip6 a_u a_v a_w a_x a_y a_z);
293 f_zip6 a_u a_v a_w a_x a_y a_z=[];
294 f_zip (a_x,a_y)=f_zip2 a_x a_y;
295 main = putStr (f_main c_input)