Let’s say I have a function with a signature like this:
def tsadd(key: Any, time: Double, value: Any)(implicit format: Format): Option[Int]
And I want to create a list of some number of these functions for later evaluation. How do I do it. I tried creating a list like:
val pipelineCmds:List[(String,Double,Any)(Format) => Option[Int]] = Nil
and doing this:
pipelineCmds ++ r.tsadd(symbol, timestamp.getMillis.toDouble, value)
But the val didn’t respond well the implicit param Format. It expects to see a ] after the first set of parens.
The ultimate goal is to do something like
r.pipeline { p =>
pipelineCmds.foreach(c => p.c)
}
Any help is greatly appreciated!
As far as I know, functions with implicit parameters are annoying to work with. The appropriate types are (your choice):
but partial application of the function does not work well. You can annoyingly annotate all your types to get the last version:
but it’s not much harder to write your own to be whatever shape you want:
Of course, if you already know the implicit values when you’re creating the list, you just need the type
and you assign the functions like