summaryrefslogtreecommitdiff
path: root/testsuite/tests/quantified-constraints/T17267.hs
blob: eaad4780031c0476c83fee2aa6245ce20378a0e4 (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
49
50
51
52
53
54
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

module T17267 where

class a ~ b => Thing a b
instance a ~ b => Thing a b

unsafeCoerce :: forall a b. a -> b
unsafeCoerce a = oops a where
  oops :: (a ~ b => Thing a b) => (Thing a b => r) -> r
  oops r = r


{-
-- Now rejected
class C a b where
  op :: a -> b

uc :: a -> b
uc = oops where
  oops :: (C a b => C a b) => a -> b
  oops x = op x
-}

{-
-- Now rejected
uc :: a -> b
uc = oops where
  oops :: (a ~ b => a ~ b) => a -> b
  oops x = x
-}


{-
-- Now rejected
class C a b where
  op :: a -> b

class C a b => Thing a b
instance C a b => Thing a b

unsafeCoerce :: forall a b. a -> b
unsafeCoerce a = oops (op a :: Thing a b => b)
  where
    oops :: (C a b => Thing a b) => (Thing a b => x) -> x
    oops r = r
-}