Remove the type-checking knot.
[ghc.git] / testsuite / tests / polykinds / T14723.hs
1 {-# LANGUAGE DataKinds #-}
2 {-# LANGUAGE FunctionalDependencies #-}
3 {-# LANGUAGE KindSignatures #-}
4 {-# LANGUAGE PolyKinds #-}
5 {-# LANGUAGE RankNTypes #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# LANGUAGE UndecidableInstances #-}
8
9 module T14723 () where
10
11 import Data.Coerce( coerce )
12 import Data.Kind (Type)
13 import Data.Proxy (Proxy(..))
14 import Data.String (fromString)
15 import Data.Int (Int64)
16 import GHC.Stack (HasCallStack)
17 import GHC.TypeLits (Nat, Symbol)
18
19 data JType = Iface Symbol
20
21 data J (a :: JType)
22
23 newIterator
24 :: IO (J ('Iface "java.util.Iterator"))
25 newIterator = do
26 let tblPtr :: Int64
27 tblPtr = undefined
28 iterator <-
29 (qqMarker (Proxy :: Proxy "wuggle")
30 (Proxy :: Proxy "waggle")
31 (Proxy :: Proxy "tblPtr")
32 (Proxy :: Proxy 106)
33 (tblPtr, ())
34 Proxy
35 (undefined :: IO Int))
36 undefined
37
38 class Coercible (a :: Type) where
39 type Ty a :: JType
40
41 instance Coercible Int64 where
42 type Ty Int64 = Iface "Int64"
43 instance Coercible Int where
44 type Ty Int = Iface "Int"
45
46 class Coercibles xs (tys :: k) | xs -> tys
47 instance Coercibles () ()
48 instance (ty ~ Ty x, Coercible x, Coercibles xs tys) => Coercibles (x, xs) '(ty, tys)
49
50 qqMarker
51 :: forall
52 -- k -- the kind variable shows up in Core
53 (args_tys :: k) -- JType's of arguments
54 tyres -- JType of result
55 (input :: Symbol) -- input string of the quasiquoter
56 (mname :: Symbol) -- name of the method to generate
57 (antiqs :: Symbol) -- antiquoted variables as a comma-separated list
58 (line :: Nat) -- line number of the quasiquotation
59 args_tuple -- uncoerced argument types
60 b. -- uncoerced result type
61 (tyres ~ Ty b, Coercibles args_tuple args_tys, Coercible b, HasCallStack)
62 => Proxy input
63 -> Proxy mname
64 -> Proxy antiqs
65 -> Proxy line
66 -> args_tuple
67 -> Proxy args_tys
68 -> IO b
69 -> IO b
70 qqMarker = undefined