1module Main where
2
3import Effect.Console (log)
4import Prim.Row
5
6data Proxy a = Proxy
7data Identity a = Identity a
8data App f a = App (f a)
9
10type RowType =
11  ( a :: Int
12  , b :: String
13  , c :: Boolean
14  )
15
16type RowTypeType =
17  ( a :: Proxy
18  , b :: Identity
19  , c :: App Identity
20  )
21
22type RowSymbol =
23  ( a :: "a"
24  , b :: "b"
25  , c :: "c"
26  )
27
28lookup :: forall sym v rx r. Cons sym v rx r => Proxy sym -> Proxy r -> Proxy v
29lookup _ _ = Proxy
30
31lookup1 = lookup (Proxy :: _ "a") (Proxy :: _ RowType)
32lookup2 = lookup (Proxy :: _ "b") (Proxy :: _ RowType)
33lookup3 = lookup (Proxy :: _ "c") (Proxy :: _ RowType)
34lookup4 = lookup (Proxy :: _ "a") (Proxy :: _ RowTypeType)
35lookup5 = lookup (Proxy :: _ "b") (Proxy :: _ RowTypeType)
36lookup6 = lookup (Proxy :: _ "c") (Proxy :: _ RowTypeType)
37lookup7 = lookup (Proxy :: _ "a") (Proxy :: _ RowSymbol)
38lookup8 = lookup (Proxy :: _ "b") (Proxy :: _ RowSymbol)
39lookup9 = lookup (Proxy :: _ "c") (Proxy :: _ RowSymbol)
40
41test1 = lookup1 :: Proxy Int
42test2 = lookup2 :: Proxy String
43test3 = lookup3 :: Proxy Boolean
44test4 = lookup4 :: Proxy Proxy
45test5 = lookup5 :: Proxy Identity
46test6 = lookup6 :: Proxy (App Identity)
47test7 = lookup7 :: Proxy "a"
48test8 = lookup8 :: Proxy "b"
49test9 = lookup9 :: Proxy "c"
50
51main = log "Done"
52