As long as we have a PartialFunction[X,R] it\'s very easy to convert it to a function returning Option[R], e.g.
PartialFunction[X,R]
Option[R]
def pfToOptf[X, R](
Starting Scala 2.9, Function.unlift does precisely this:
Scala 2.9
def unlift[T, R](f: (T) => Option[R]): PartialFunction[T, R]
Turns a function T => Option[R] into a PartialFunction[T, R].