I have a number of traits that I am implementing which have methods of a signature something like
trait MyCache {
def getMyThing(key: String): Future[Option[MyThing]]
def setMyThing(data: MyThing, key: String): Future[Boolean]
}
I also have a generator function for these getters and setters that generates functions that (almost) map to these method traits. The simplified getters and setters generator produces functions (not methods) with the signature
val getMyThingGenerated: String => Future[Option[MyThing]]
val setMyThingGenerated: (MyThing, String) => Future[Boolean]
I would like to map in succinct manner between these generated functions and class methods but I am not sure how.
I could write something like
class CacheImplementation extends MyCache {
def getMyThing(key: String): Future[Option[MyThing]] =
getMyThingGenerated(key)
def setMyThing(data: MyThing, key: String): Future[Boolean] =
setMyThingGenerated(data, key)
}
but this seems somewhat overkill when I know that the method and function have similar signatures. I was hopefully that this could be done with partial function application but I can't seem to make it work.