summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc191.hs
blob: cf77c0505aa3be0c11a1894666540df231ca5c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


-- This only typechecks if forall-hoisting works ok when
-- importing from an interface file.  The type of Twins.gzipWithQ
-- is this:
--   type GenericQ r = forall a. Data a => a -> r
--   gzipWithQ :: GenericQ (GenericQ r) -> GenericQ (GenericQ [r])
-- It's kept this way in the interface file for brevity and documentation,
-- but when the type synonym is expanded, the foralls need expanding

module Foo where

import Data.Generics.Basics
import Data.Generics.Aliases
import Data.Generics.Twins(gzipWithQ)

-- | Generic equality: an alternative to \deriving Eq\
geq :: Data a => a -> a -> Bool
geq x y = geq' x y
  where
--    This type signature no longer works, because it is
--    insufficiently polymoprhic.
--    geq' :: forall a b. (Data a, Data b) => a -> b -> Bool
    geq' :: GenericQ (GenericQ Bool)
    geq' x y =     (toConstr x == toConstr y)
                && and (gzipWithQ geq' x y)