Bump `base` version to 4.9.0.0 (closes #11026)
[ghc.git] / testsuite / tests / typecheck / should_fail / TcCoercibleFail.hs
1 {-# LANGUAGE RoleAnnotations, RankNTypes, ScopedTypeVariables #-}
2
3 import Data.Coerce (coerce, Coercible)
4 import Data.Ord (Down)
5
6 newtype Age = Age Int deriving Show
7
8 type role Map nominal _
9 data Map a b = Map a b deriving Show
10
11 foo1 = coerce $ one :: ()
12
13 foo2 :: forall m. Monad m => m Age
14 foo2 = coerce $ (return one :: m Int)
15
16 foo3 = coerce $ Map one () :: Map Age ()
17
18 foo4 = coerce $ one :: Down Int
19
20 newtype Void = Void Void
21 foo5 = coerce :: Void -> ()
22
23 newtype VoidBad a = VoidBad (VoidBad (a,a))
24 foo5' = coerce :: (VoidBad ()) -> ()
25
26 -- This shoul fail with a context stack overflow
27 newtype Fix f = Fix (f (Fix f))
28 foo6 = coerce :: Fix (Either Int) -> Fix (Either Age)
29 foo7 = coerce :: Fix (Either Int) -> ()
30
31
32 one :: Int
33 one = 1
34 main = return ()