summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T18851b.hs
blob: 0618c792ceef6a77d63fa2d39c64c6b2f3a3e7a7 (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
{-# LANGUAGE FunctionalDependencies, FlexibleInstances, UndecidableInstances,
             ScopedTypeVariables, TypeFamilies, TypeApplications, NoPolyKinds,
             FlexibleContexts, AllowAmbiguousTypes #-}

module T18851b where

-- NB: -XNoPolyKinds is important. Otherwise, we get IsInt :: forall k. k -> Constraint,
-- but its instance specializes k to Type. The [W] IsInt int doesn't match the instance
-- then, and so we get no int ~ Int equality.

class C a b | a -> b
instance C Int b => C Int b

class IsInt int
instance int ~ Int => IsInt int

data A
instance Show A where
  show _ = "A"
data B
instance Show B where
  show _ = "B"

f :: forall a b c int. (Show a, Show b, Show c, C int a, C int b, C int c, IsInt int) => String
f = show (undefined :: c)

g = f @A @B