Skip to content

Commit d6bb3fc

Browse files
committed
transformed map{myfunc} to map{t => myfunc{t})
1 parent 4b17a99 commit d6bb3fc

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

effekt/shared/src/main/scala/effekt/core/ArityRaising.scala

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,32 @@ object ArityRaising extends Phase[CoreTransformed, CoreTransformed] {
101101

102102
val transformedBargs = bargs.map { barg =>
103103
barg match {
104-
// case direct reference here
105-
// transform to lambda and then do the same as below for blocklit
104+
// this handles:
105+
// val res = myList.map {myFunc}
106+
// by making it:
107+
// val res = myList.map {t => myFunc(t)}
106108
case BlockVar(id, annotatedTpe, annotatedCapt) =>
107-
println(barg.tpe)
108-
transform(barg)
109+
annotatedTpe match {
110+
case BlockType.Function(tparams, cparams, vparams, bparams, result) =>
111+
val params = vparams.map { tpe =>
112+
// need to fix for propper implementation
113+
val freshId = Id("x_" + scala.util.Random.nextInt())
114+
(ValueParam(freshId, tpe), ValueVar(freshId, tpe))
115+
}
116+
val call = Stmt.App(barg, List(), params.map(_._2), List())
117+
val transformedBody = transform(call)
118+
119+
// empty List for Bargs should be fine, since myList.map {myFunc} the myFunc cant have any bargs??
120+
BlockLit(tparams, cparams, params.map(_._1), List(), transformedBody)
121+
122+
case _ => transform(barg)
123+
}
124+
109125

110126
case BlockLit(btparams, bcparams, bvparams, bbparams, body) =>
111127
// Keep the signature unchanged
112128
// But recursively transform the body
113129
val transformedBody = transform(body)
114-
println(barg.tpe)
115130
BlockLit(btparams, bcparams, bvparams, bbparams, transformedBody)
116131

117132
case _ =>

0 commit comments

Comments
 (0)