blob: bba609a5ceb23fc0354b0338c181de30ba2f8b04 (
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
|
{-# LANGUAGE FunctionalDependencies, FlexibleInstances, UndecidableInstances,
ScopedTypeVariables, TypeFamilies, TypeApplications,
FlexibleContexts, AllowAmbiguousTypes, ExtendedDefaultRules #-}
module T18851 where
default (Int)
type family C_FD a
class C_FD a ~ b => C a b
type instance C_FD Int = Bool -- just for Show (C_FD Int)
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 c, Num int
, C int a, C int b, C int c
-- , c ~ C_FD int -- add this to get rid of ambiguity error
)
=> String
f = show (undefined :: c)
-- blows up at run time once type checks
g :: String
g = f @A @B
|