1 module PreludeBuiltin where
3 --- 5-tuples ------------------------------------------
10 import List ( (++), foldr )
11 import Prel ( (&&), (.) )
12 import PS ( _PackedString, _unpackPS )
17 instance (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a,b,c,d,e) where
18 (a1,a2,a3,a4,a5) == (b1,b2,b3,b4,b5) = a1 == b1 && a2 == b2 && a3 == b3 && a4 == b4 && a5 == b5
19 aaaaa /= bbbbb = if (aaaaa == bbbbb) then False else True
21 instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a,b,c,d,e) where
22 a < b = case _tagCmp a b of { _LT -> True; _EQ -> False; _GT -> False }
23 a <= b = case _tagCmp a b of { _LT -> True; _EQ -> True; _GT -> False }
24 a >= b = case _tagCmp a b of { _LT -> False; _EQ -> True; _GT -> True }
25 a > b = case _tagCmp a b of { _LT -> False; _EQ -> False; _GT -> True }
27 max a b = case _tagCmp a b of { _LT -> b; _EQ -> a; _GT -> a }
28 min a b = case _tagCmp a b of { _LT -> a; _EQ -> a; _GT -> b }
30 _tagCmp (a1, b1, c1, d1, e1) (a2, b2, c2, d2, e2)
31 = case (_tagCmp a1 a2) of {
34 _EQ -> case _tagCmp b1 b2 of {
37 _EQ -> case _tagCmp c1 c2 of {
40 _EQ -> case _tagCmp d1 d2 of {
49 instance (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1,a2,a3,a4,a5) where
50 range ((l1,l2,l3,l4,l5),(u1,u2,u3,u4,u5)) =
51 [(i1,i2,i3,i4,i5) | i1 <- range (l1,u1),
57 index ((l1,l2,l3,l4,l5),(u1,u2,u3,u4,u5)) (i1,i2,i3,i4,i5) =
58 index (l5,u5) i5 + rangeSize (l5,u5) * (
59 index (l4,u4) i4 + rangeSize (l4,u4) * (
60 index (l3,u3) i3 + rangeSize (l3,u3) * (
61 index (l2,u2) i2 + rangeSize (l2,u2) * (
64 rangeSize (l,u) = index (l,u) u + (1 :: Int)
66 inRange ((l1,l2,l3,l4,l5),(u1,u2,u3,u4,u5)) (i1,i2,i3,i4,i5) =
67 inRange (l1,u1) i1 && inRange (l2,u2) i2 &&
68 inRange (l3,u3) i3 && inRange (l4,u4) i4 && inRange (l5,u5) i5
70 -- ToDo: something for Binary
72 instance (Text a, Text b, Text c, Text d, Text e) => Text (a, b, c, d, e) where
73 readsPrec p = readParen False
74 (\a -> [((w,x,y,z,v), l) | ("(",b) <- lex a,
75 (w,c) <- readsPrec 0 b,
77 (x,e) <- readsPrec 0 d,
79 (y,g) <- readsPrec 0 f,
81 (z,i) <- readsPrec 0 h,
83 (v,k) <- readsPrec 0 j,
86 showsPrec p (v,w,x,y,z) = showChar '(' . showsPrec 0 v . showString ", " .
87 showsPrec 0 w . showString ", " .
88 showsPrec 0 x . showString ", " .
89 showsPrec 0 y . showString ", " .
90 showsPrec 0 z . showChar ')'
92 readList = _readList (readsPrec 0)
93 showList = _showList (showsPrec 0)
96 {-# SPECIALIZE instance Eq (Int,Int,Int,Int,Int) #-}
97 {-# SPECIALIZE instance Ord (Int,Int,Int,Int,Int) #-}