I have a class which accepts a function f: Option[Seq[Option[A]]] => Option[A]]
case class Function[A](operator: Option[Seq[Option[A]]] => Option[A], name: String, arity: Int)
What i would like is for the user of this class to be able to not have to worry about the Option
framework. So the user would pass a function g: Seq[A] => A
and under the hood i would lift that function. The lifting part is what i'm not being able to do.
This is what i have (using optionInstance.lift
of scalaz) :
object Function {
def apply[A](operator: Seq[A] => A) = new Function(optionInstance.lift(operator),"a", 1)
}
However this does not compile since the lift operator is returning Option[Seq[A]]
instead of Option[Seq[Option[A]]]
. How can this be done?
Here's an example of how to convert between your two prototypes :
You can use this to transform your operator