diff options
Diffstat (limited to 'testsuite/tests/generics/GEq/GEq1A.hs')
-rw-r--r-- | testsuite/tests/generics/GEq/GEq1A.hs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/testsuite/tests/generics/GEq/GEq1A.hs b/testsuite/tests/generics/GEq/GEq1A.hs index 7bdfbebe54..9a91e8040b 100644 --- a/testsuite/tests/generics/GEq/GEq1A.hs +++ b/testsuite/tests/generics/GEq/GEq1A.hs @@ -1,7 +1,9 @@ -{-# LANGUAGE TypeOperators, DefaultSignatures, FlexibleContexts, FlexibleInstances #-} +{-# LANGUAGE TypeOperators, DefaultSignatures, + FlexibleContexts, FlexibleInstances, MagicHash #-} module GEq1A where +import GHC.Exts import GHC.Generics class GEq' f where @@ -26,13 +28,25 @@ instance (GEq' a, GEq' b) => GEq' (a :+: b) where instance (GEq' a, GEq' b) => GEq' (a :*: b) where geq' (a1 :*: b1) (a2 :*: b2) = geq' a1 a2 && geq' b1 b2 - -class GEq a where +-- Unboxed types +instance GEq' UAddr where + geq' (UAddr a1) (UAddr a2) = isTrue# (eqAddr# a1 a2) +instance GEq' UChar where + geq' (UChar c1) (UChar c2) = isTrue# (eqChar# c1 c2) +instance GEq' UDouble where + geq' (UDouble d1) (UDouble d2) = isTrue# (d1 ==## d2) +instance GEq' UFloat where + geq' (UFloat f1) (UFloat f2) = isTrue# (eqFloat# f1 f2) +instance GEq' UInt where + geq' (UInt i1) (UInt i2) = isTrue# (i1 ==# i2) +instance GEq' UWord where + geq' (UWord w1) (UWord w2) = isTrue# (eqWord# w1 w2) + +class GEq a where geq :: a -> a -> Bool default geq :: (Generic a, GEq' (Rep a)) => a -> a -> Bool geq x y = geq' (from x) (from y) - -- Base types instances (ad-hoc) instance GEq Char where geq = (==) instance GEq Int where geq = (==) |