1 module PreludeBuiltin where
3 --- 3-tuples ------------------------------------------
10 import List ( (++), foldr )
11 import Prel ( (&&), (.) )
12 import PS ( _PackedString, _unpackPS )
17 instance (Eq a, Eq b, Eq c) => Eq (a, b, c) where
18 (a1,a2,a3) == (b1,b2,b3) = a1 == b1 && a2 == b2 && a3 == b3
19 aaa /= bbb = if (aaa == bbb) then False else True
21 instance (Ord a, Ord b, Ord c) => Ord (a, b, c) 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) (a2, b2, c2)
31 = case (_tagCmp a1 a2) of {
34 _EQ -> case _tagCmp b1 b2 of {
41 instance (Ix a1, Ix a2, Ix a3) => Ix (a1,a2,a3) where
42 range ((l1,l2,l3),(u1,u2,u3)) =
43 [(i1,i2,i3) | i1 <- range (l1,u1),
47 index ((l1,l2,l3),(u1,u2,u3)) (i1,i2,i3) =
48 index (l3,u3) i3 + rangeSize (l3,u3) * (
49 index (l2,u2) i2 + rangeSize (l2,u2) * (
52 rangeSize (l,u) = index (l,u) u + (1 :: Int)
54 inRange ((l1,l2,l3),(u1,u2,u3)) (i1,i2,i3) =
55 inRange (l1,u1) i1 && inRange (l2,u2) i2 &&
58 -- ToDo: something for Binary
60 instance (Text a, Text b, Text c) => Text (a, b, c) where
61 readsPrec p = readParen False
62 (\a -> [((x,y,z), h) | ("(",b) <- lex a,
63 (x,c) <- readsPrec 0 b,
65 (y,e) <- readsPrec 0 d,
67 (z,g) <- readsPrec 0 f,
70 showsPrec p (x,y,z) = showChar '(' . showsPrec 0 x . showString ", " .
71 showsPrec 0 y . showString ", " .
72 showsPrec 0 z . showChar ')'
74 readList = _readList (readsPrec 0)
75 showList = _showList (showsPrec 0)
77 {-# SPECIALIZE instance Eq (Int,Int,Int) #-}
78 {-# SPECIALIZE instance Ord (Int,Int,Int) #-}
79 {-# SPECIALIZE instance Text (Int,Int,Int) #-}
81 #if defined(__UNBOXED_INSTANCES__)
83 -- We only create SPECIALIZED instances unboxed tuples
84 -- which have all the same unboxed component
86 -- {-# SPECIALIZE instance Eq (Char#,Char#,Char#) #-}
87 -- {-# SPECIALIZE instance Ord (Char#,Char#,Char#) #-}
88 -- {-# SPECIALIZE instance Ix (Char#,Char#,Char#) #-}
89 -- {-# SPECIALIZE instance Text (Char#,Char#,Char#) #-}
91 -- {-# SPECIALIZE instance Eq (Int#,Int#,Int#) #-}
92 -- {-# SPECIALIZE instance Ord (Int#,Int#,Int#) #-}
93 -- {-# SPECIALIZE instance Ix (Int#,Int#,Int#) #-}
94 -- {-# SPECIALIZE instance Text (Int#,Int#,Int#) #-}
96 -- {-# SPECIALIZE instance Eq (Double#,Double#,Double#) #-}
97 -- {-# SPECIALIZE instance Ord (Double#,Double#,Double#) #-}
98 -- {-# SPECIALIZE instance Text (Double#,Double#,Double#) #-}