summaryrefslogtreecommitdiff
path: root/testsuite/tests/generics/T5462Yes1.hs
blob: 35785295d6b7d83d2e2ef27690b51beb12c68021 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{-# LANGUAGE FlexibleContexts       #-}
{-# LANGUAGE FlexibleInstances      #-}
{-# LANGUAGE DeriveGeneric          #-}
{-# LANGUAGE DeriveFunctor          #-}
{-# LANGUAGE DefaultSignatures      #-}
{-# LANGUAGE StandaloneDeriving     #-}
{-# LANGUAGE UndecidableInstances   #-}
{-# LANGUAGE DeriveAnyClass    #-}

module Main where

import GHC.Generics hiding (C, C1, D)
import GEq1A
import Enum
import GFunctor

data A = A1
  deriving (Show, Generic, GEq, GEnum)

data B a = B1 | B2 a (B a)
  deriving (Show, Generic, Generic1, GEq, GEnum, GFunctor)

data C phantom a = C1 | C2 a (C phantom a)
  deriving (Show, Generic, Generic1, GEq, GEnum, GFunctor)

data D f a = D1 (f a) (f (D f a)) deriving (Generic, Generic1)
deriving instance (Show (f a), Show (f (D f a))) => Show (D f a)
deriving instance (GEq  (f a), GEq  (f (D f a))) => GEq  (D f a)

data E f a = E1 (f a)
  deriving (Show, Eq, Generic, Generic1, GFunctor)


main = print (
               geq A1 A1
             , take 10 (genum :: [A])

             , geq (B2 A1 B1) B1
             , gmap (++ "lo") (B2 "hel" B1)
             , take 3 (genum :: [B A])

             , geq (C2 A1 C1) C1
             , gmap (++ "lo") (C2 "hel" C1)

             , geq (D1 "a" []) (D1 "a" [])

             , gmap (++ "lo") (E1 ["hel"])
             )