Ticket #310: testeq_bad.2.hs

File testeq_bad.2.hs, 701 bytes (added by nobody, 11 years ago)
Line 
1{-# OPTIONS -fglasgow-exts #-}
2import Data.Generics.Basics
3import Data.Generics.Aliases
4import Data.Generics.Twins(gzipWithQ)
5{-
6-- | Twin map for queries
7gzipWithQ :: GenericQ (GenericQ r) -> GenericQ (GenericQ [r])
8gzipWithQ f x y = case gmapAccumQ perkid funs y of
9                   ([], r) -> r
10                   _       -> error "gzipWithQ"
11 where
12  perkid a d = (tail a, unGQ (head a) d)
13  funs = gmapQ (\k -> GQ (f k)) x
14-}
15-- | Generic equality: an alternative to \"deriving Eq\"
16geq :: Data a => a -> a -> Bool
17geq x y = geq' x y
18  where
19    geq' :: forall a b. (Data a, Data b) => a -> b -> Bool
20    geq' x y =     (toConstr x == toConstr y)
21                && and (gzipWithQ geq' x y)
22
23