Commit 26ea1e82 authored by dreixel's avatar dreixel

Adapt the testsuite to the recent ghc-generics changes.

parent 92af8175
{-# LANGUAGE Generics #-}
{-# LANGUAGE Generics #-}
{-# LANGUAGE TypeOperators #-}
module CanDoRep0 where
import GHC.Generics (Representable0)
module ShouldCompile0 where
-- We should be able to generate a generic representation for these types
data A
data A
deriving Representable0
data B a
deriving Representable0
data C = C0 | C1
deriving Representable0
data D a = D0 | D1 { d11 :: a, d12 :: (D a) }
deriving Representable0
data E a = E0 a (E a) (D a)
-- We do not support datatype contexts, but this should still compile
-- (Context will simply have no Representable0 instance)
data (Show a) => Context a = Context a
data (:*:) a b = a :*: b
deriving Representable0
{-# LANGUAGE DeriveRepresentable #-}
{-# LANGUAGE ExistentialQuantification #-}
module ShouldFail0 where
module CannotDoRep0 where
import GHC.Generics
......
cannotDoRep0.hs:9:45:
CannotDoRep0.hs:9:45:
Can't make a derived instance of `Representable0 Dynamic':
Cannot derive Representable for type Dynamic
In the data type declaration for `Dynamic'
{-# LANGUAGE DeriveRepresentable #-}
module ShouldFail1 where
module CannotDoRep1 where
import GHC.Generics
......
cannotDoRep1.hs:8:49:
CannotDoRep1.hs:8:49:
Can't make a derived instance of `Representable0 (Context a)':
Cannot derive Representable for type Context
In the data type declaration for `Context'
......@@ -2,7 +2,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GADTs #-}
module ShouldFail2 where
module CannotDoRep2 where
import GHC.Generics
......
cannotDoRep2.hs:13:1:
CannotDoRep2.hs:13:1:
Can't make a derived instance of `Representable0 (Term a)':
Cannot derive Representable for type Term
In the stand-alone deriving instance for `Representable0 (Term a)'
......@@ -10,10 +10,7 @@ class GEq' f where
instance GEq' U1 where
geq' _ _ = True
instance GEq' (K1 P c) where
geq' (K1 a) (K1 b) = undefined
instance (GEq c) => GEq' (K1 R c) where
instance (GEq c) => GEq' (K1 i c) where
geq' (K1 a) (K1 b) = geq a b
-- No instances for P or Rec because geq is only applicable to types of kind *
......
......@@ -8,8 +8,13 @@ import GEq
-- We should be able to generate a generic representation for these types
data C = C0 | C1
deriving Representable0
data D a = D0 | D1 { d11 :: a, d12 :: (D a) }
deriving Representable0
data (:**:) a b = a :**: b
deriving Representable0
-- Example values
c0 = C0
......@@ -19,13 +24,18 @@ d0 :: D Char
d0 = D0
d1 = D1 'p' D0
p1 :: Int :**: Char
p1 = 3 :**: 'p'
-- Generic instances
instance GEq C
instance (GEq a) => GEq (D a)
instance GEq C
instance (GEq a) => GEq (D a)
instance (GEq a, GEq b) => GEq (a :**: b)
-- Tests
teq0 = geq c0 c1
teq1 = geq d0 d1
teq2 = geq d0 d0
teq3 = geq p1 p1
main = mapM_ print [teq0, teq1, teq2]
main = mapM_ print [teq0, teq1, teq2, teq3]
{-# LANGUAGE StandaloneDeriving #-}
module ShouldFail0 where
import GHC.Generics (Representable0)
data X = X
deriving instance Representable0 X
-- Should fail (no XDeriveRepresentable)
ShouldFail0.hs:9:1:
Can't make a derived instance of `Representable0 X':
You need -XDeriveRepresentable to derive an instance for this class
or
You need -XGenerics to derive an instance for this class
In the stand-alone deriving instance for `Representable0 X'
......@@ -6,8 +6,8 @@ import GHC.Generics
import Uniplate
data Tree = Leaf | Node Int Tree Tree deriving Show
data Pair a b = Pair a b deriving Show
data Tree = Leaf | Node Int Tree Tree deriving (Show, Representable0)
data Pair a b = Pair a b deriving (Show, Representable0)
instance Uniplate Tree
instance Uniplate (Pair a b)
......
setTestOpts(only_compiler_types(['ghc']))
test('canDoRep0', normal, compile, [''])
test('CanDoRep0', normal, compile, [''])
test('cannotDoRep0', normal, compile_fail, [''])
test('cannotDoRep1', normal, compile_fail, [''])
test('cannotDoRep2', normal, compile_fail, [''])
test('ShouldFail0', normal, compile_fail, [''])
test('CannotDoRep0', normal, compile_fail, [''])
test('CannotDoRep1', normal, compile_fail, [''])
test('CannotDoRep2', normal, compile_fail, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment