File tree 1 file changed +58
-0
lines changed
1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -81,3 +81,61 @@ package b {
81
81
}
82
82
83
83
}
84
+
85
+ package c {
86
+
87
+ trait QCtx { qctx =>
88
+ type Expr [+ T ]
89
+ type Type [T ]
90
+ type NestedSCtx = SCtx {
91
+ type NestedQCtx = QCtx { type Expr [+ T ] >: qctx.Expr [T ]; type Type [T ] >: qctx.Type [T ] }
92
+ }
93
+ }
94
+
95
+ trait SCtx {
96
+ type NestedQCtx <: QCtx
97
+ }
98
+
99
+ /* Quote*/ def q [T ](using qctx : QCtx )(x : qctx.NestedSCtx ?=> T ): qctx.Expr [T ] = ???
100
+ /* Splice*/ def s [T ](using sctx : SCtx )(x : (qctx : sctx.NestedQCtx ) ?=> qctx.Expr [T ]): T = ???
101
+ /* run*/ def r [T ](x : (qctx : QCtx ) ?=> qctx.Expr [T ]): T = ???
102
+
103
+ val test : Any = {
104
+
105
+ def pow (using qctx : QCtx )(x : qctx.Expr [Double ], n : Int ): qctx.Expr [Double ] =
106
+ if n == 0 then q{1.0 } else q{ s{x} * s{pow(x, n - 1 )} }
107
+
108
+ r {
109
+ q{ (x : Double ) => s{pow(q{x}, 5 )} }
110
+ }
111
+
112
+ r {
113
+ q{ (x : Double ) =>
114
+ s{
115
+ val y = q{x}
116
+ pow(q{s{y}}, 5 )
117
+ }
118
+ }
119
+ }
120
+
121
+ r {
122
+ val a = q{ 4.0 }
123
+ q{ (x : Double ) =>
124
+ s{
125
+ pow(q{s{a}}, 5 )
126
+ }
127
+ }
128
+ }
129
+
130
+ r { qctx ?=>
131
+ var escaped : qctx.Expr [Double ] = ???
132
+ q{ (x : Double ) =>
133
+ s{
134
+ escaped = q{x} // error
135
+ pow(q{x}, 5 )
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ }
You can’t perform that action at this time.
0 commit comments