Visible type application
[ghc.git] / testsuite / tests / typecheck / should_fail / VtaFail.hs
1 {-# LANGUAGE TypeApplications, RankNTypes, PolyKinds #-}
2
3 module VtaFail1 where
4
5 pairup_nosig x y = (x, y)
6
7 answer_nosig = pairup_nosig @Int @Bool 5 True
8
9 addOne :: Num a => a -> a
10 addOne x = x + 1
11
12 answer_constraint_fail = addOne @Bool 5
13
14 answer_lambda = (\x -> x) @Int 12
15
16 pair :: forall a. a -> forall b. b -> (a, b)
17 pair = (,)
18
19 a = pair 3 @Int @Bool True
20
21 data First (a :: * -> *) = F
22
23 first :: First a -> Int
24 first _ = 0
25
26 fInt = first @Int F -- should fail
27
28 data Proxy (a :: k) = P -- This expands to P (kind variable) (type variable)
29
30 foo :: Proxy a -> Int
31 foo _ = 0
32
33 baz = foo @Bool (P :: Proxy Int) -- should fail
34
35 data Three (a :: * -> k -> *) = T
36
37 too :: Three a -> Int
38 too _ = 3
39
40 threeBad = too @Maybe T
41 threeWorse = too @( -> ) (T :: Three Either)
42
43 plus :: Int -> Int -> Int
44 plus = (+)
45
46 b = plus @Int 5 7
47 c = plus @Rational 5 10
48 d = (+) @Int @Int @Int 12 14
49
50
51 e = show @Int @Float (read "5")
52 f = show (read @Int @Bool @Float "3")
53
54 silly :: a -> Bool
55 silly _ = False
56
57 g = silly @Maybe -- should fail