848ee4e1b193ec86caad4e14dfd8540df203a0d1
[ghc-hetmet.git] / ghc / tests / programs / fast2haskell / Fast2haskell.hs
1        module Fast2haskell (
2             Complex_type, Array_type, Assoc_type, Descr_type,
3             abortstr, delay, fix, force, iff, iffrev, seQ,
4             pair, strcmp,
5             entier,
6             land_i, lnot_i, lor_i, lshift_i, rshift_i,
7             descr,
8             destr_update, indassoc, lowbound, tabulate, upbound, update, valassoc) where {
9             import Bits;
10             import Word;
11             import Complex; -- 1.3
12             import Array; -- 1.3
13             import Int ( Num(fromInt) );
14             type Complex_type   = Complex Double;
15             type Array_type b   = Array Int b;
16             type Assoc_type a   = (Int, a);
17             type Descr_type     = (Int,Int);
18             abortstr      str                 = error ("abort:"++str); -- abort (OtherError str);
19             delay         x                   = abortstr "delay not implemented";
20             fix           f                   = fix_f where {fix_f = f fix_f};
21             force         x                   = x; -- error  "force not implemented";
22             iff           b     x  y          = if b then x else y;
23             iffrev        y  x      b         = if b then x else y;
24             seQ           x    y              = x `seq` y;
25             pair          []                  = False;
26             pair          x                   = True;
27             strcmp        :: [Char] -> [Char] -> Bool;
28             strcmp        x      y            = x == y;
29             entier        x                   = fromIntegral (floor x);
30             land_i        :: Int -> Int -> Int;
31             land_i        x    y              = wordToInt (fromInt x .&. fromInt y);
32             lnot_i        :: Int -> Int;
33             lnot_i        x                   = wordToInt (complement (fromInt x));
34             lor_i         :: Int -> Int -> Int;
35             lor_i         x    y              = wordToInt (fromInt x .|. fromInt y);
36             lshift_i      :: Int -> Int -> Int;
37             lshift_i      x    y              = wordToInt (fromInt x `shiftL` y);
38             rshift_i      :: Int -> Int -> Int;
39             rshift_i      x    y              = wordToInt (fromInt x `shiftR` y);
40             write         x                   = abortstr "write not implemented";
41             descr         l    u              = (l,u);
42             destr_update  ar  i  x            = ar // [(i,x)];
43             indassoc      (i,v)              = i;
44             lowbound      (l,u)               = l;
45             tabulate      f (l,u)             = listArray (l,u) [f i | i <- [l..u]];
46             upbound       (l,u)               = u;
47             update        ar i x              = ar // [(i,x)];
48             valassoc      (i,v)               = v;
49        }