In answer to this question , I went to implement a Haskell-like expression in Scala style using the macro-paradise branch. The code is available in scala-where . Now I can write something like the following:
val result = where ( f1(1) * f2(2), {
def f1(x : Int) = x + 1
def f2(x : Int) = x + 2
})
However, what I really would like to do is be able to call it in infix position:
val result = ( f1(1) * f2(2)) where {
def f1(x : Int) = x + 1
def f2(x : Int) = x + 2
}
Normally, this kind of thing would be easy, but I can't figure out how to do this when calling a macro. The expression (f1 (1) * f2 (2)) will not be entered until the macro is applied, so something like constructing an implicit class of values ββdoes not work. Is there any way to get such syntax otherwise?
Otherwise, just having two lists of options that could be made:
val result = where (f1(1) * f2(2)) {
def f1(x : Int) = x + 1
def f2(x : Int) = x + 2
}
, . ?