summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_compile/T2856.hs
blob: 0e91e4e747f9f9328b88498554f91dea2ec7bd2d (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
{-# OPTIONS -fno-warn-redundant-constraints #-}
{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving, StandaloneDeriving, FlexibleInstances #-}

-- Test #2856

module T2856 where

import Data.Ratio

----------------------
class C a where
    data D a

instance C Bool where
    newtype D Bool = DInt Int deriving (Eq, Show, Num)

instance C a => C [a] where
    newtype D [a] = DList (Ratio a) deriving (Eq, Show, Num)

----------------------
data family W a
newtype instance W Bool = WInt Int deriving( Eq, Show )
newtype instance W [a] = WList (Ratio a) deriving( Eq, Show )

deriving instance Num (W Bool)
deriving instance (Integral a, Num a) => Num (W [a])
  -- Integral needed because superclass Eq needs it,
  -- because of the stupid context on Ratio