blob: c7a7c3e4c6b9a9c75bcfad9830263b6c0773520d (
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
|
{-# LANGUAGE RankNTypes #-}
-- 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 polymorphic.
-- 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)
|