summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T16502.hs
blob: c5ddea3938736ad2b34c9310a84aa00eb27b20af (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
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE InstanceSigs #-}
module T16502 where

import Data.Kind

class    (forall c. c ~ T a => Show (c b)) => ShowT a b
instance Show (T a b) => ShowT a b

class (forall b. Show b => ShowT a b) => C a where
  type family T a :: Type -> Type

data D a = MkD (T a Int)

instance C a => Show (D a) where
  showsPrec p (MkD x)
    = (showParen (p > 10) $ showString "MkD " . showsPrec 11 x)

-- This is rejected because we cannot derive (Show (D a)) from (C a)
-- due to troublesome quantified constraints. And then the error
-- message mentions the internal name of the default method for show.
-- Simon thinks that we should accept the fact that this doesn't get
-- accepted, given that a quantified constraint for (Show (c b)) is far
-- too applicable to be useful. So we're left with the suboptimal
-- error message.