-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Currently TupledFunction is limited as a solution for abstraction over fucntion arity - it can only abstract over arity of vanilla function types, it cannot turn inheritors of Function*, singleton function objects or refined function types into functions of tuples. It's also forcefully invariant and unwieldy when variance is involved.
Both of these can be solved by splitting TupledFunction into two type classes, one for converting into tupled function and one for converting from a tupled function. That way the "read" type class instance can still be synthesized for types that can never be created from a tupled function - such as singleton function objects. Both read and write type classes can also be made variant.
sealed trait ToTupledFunction[-F, +G]:
def tupled(f: F): G
sealed trait FromTupledFunction[-G, +F]:
def untupled(g: G): F
sealed trait TupledFunction[F, G] extends ToTupledFunction[F, G] with FromTupledFunction[G, F]:
def tupled(f: F): G
def untupled(g: G): FMetadata
Metadata
Assignees
Labels
No labels