1 -- !!! basic Rational operations
2 --
3 import Data.Ratio
5 main
6 = putStr
7 (-- Ratio Ints
8 show [i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc]
9 ++ "\n"
10 -- the Ints
11 ++ show ((map numerator [i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc])
12 ++(map denominator [i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc]))
13 ++ "\n"
14 -- Booleans
15 -- ++ show []
16 -- ++ "\n"
18 -- Rationals (Ratio Integers)
19 ++ show [r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc]
20 ++ "\n"
21 -- the Integers
22 ++ show ((map numerator [r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc])
23 ++(map denominator [r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc]))
24 ++ "\n"
25 -- Booleans
26 -- ++ show []
27 -- ++ "\n"
28 )
29 where
30 i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc :: Ratio Int
32 i0a = 0 % 1
33 i0b = (-0) % 1
34 i0c = 0 % (-1)
35 i2a = 4 % 2
36 i2b = (-4) % (-2)
37 im2a = (-4) % 2
38 im2b = 4 % (-2)
39 i_pi = 22 % 7
40 i_misc = 2 % 10000
42 r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc :: Rational
44 r0a = 0 % 1
45 r0b = (-0) % 1
46 r0c = 0 % (-1)
47 r2a = 4 % 2
48 r2b = (-4) % (-2)
49 rm2a = (-4) % 2
50 rm2b = 4 % (-2)
51 r_pi = 22 % 7
52 r_misc = 2 % 10000