1{-# LANGUAGE TypeApplications, ScopedTypeVariables, PolyKinds,
2  TypeFamilies, RankNTypes, FlexibleContexts #-}
3module Vta1 where
4
5quad :: a -> b -> c -> d -> (a, b, c, d)
6quad = (,,,)
7silly = quad @_ @Bool @Char @_ 5 True 'a' "Hello"
8pairup_nosig x y = (x, y)
9
10pairup_sig :: a -> b -> (a, b)
11pairup_sig u w = (u, w)
12answer_sig = pairup_sig @Bool @Int False 7
13answer_read = show (read @Int "3")
14answer_show = show @Integer (read "5")
15answer_showread = show @Int (read @Int "7")
16intcons a = (:) @Int a
17intpair x y = pairup_sig @Int x y
18answer_pairup = pairup_sig @Int 5 True
19answer_intpair = intpair 1 "hello"
20answer_intcons = intcons 7 []
21
22type family F a
23
24type instance F Char = Bool
25
26g :: F a -> a
27g _ = undefined
28
29f :: Char
30f = g True
31answer = g @Char False
32
33mapSame :: forall b . (forall a . a -> a) -> [b] -> [b]
34mapSame _ [] = []
35mapSame fun (x : xs) = fun @b x : (mapSame @b fun xs)
36
37pair :: forall a . a -> (forall b . b -> (a, b))
38pair x y = (x, y)
39b = pair @Int 3 @Bool True
40c = mapSame id [1, 2, 3]
41d = pair 3 @Bool True
42
43pairnum :: forall a . Num a => forall b . b -> (a, b)
44pairnum = pair 3
45e = (pair 3 :: forall a . Num a => forall b . b -> (a, b)) @Int
46      @Bool
47      True
48h = pairnum @Int @Bool True
49
50data First (a :: * -> *) = F
51
52data Proxy (a :: k) = P
53
54data Three (a :: * -> k -> *) = T
55
56foo :: Proxy a -> Int
57foo _ = 0
58
59first :: First a -> Int
60first _ = 0
61fTest = first F
62fMaybe = first @Maybe F
63test = foo P
64bar = foo @Bool P
65
66too :: Three a -> Int
67too _ = 3
68threeBase = too T
69threeOk = too @Either T
70blah = Nothing @Int
71
72newtype N = MkN{unMkN :: forall a . Show a => a -> String}
73n = MkN show
74boo = unMkN n @Bool
75
76boo2 :: forall (a :: * -> *) . Proxy a -> Bool
77boo2 _ = False
78base = boo2 P
79bar' = boo2 @Maybe P
80