Is it possible the encode the following into types?

For the below method, is it possible to somehow encode the information in types that makes sure that the length of the input list and the returned list is the same?

def addOne(list: List[Int]): List[Int]
1 Like

Instead of List you can use shapeless.Sized or shapeless.HList in Scala 2 or tuple in Scala 3.


Thanks! Can you point me towards how I should go about with the Scala 3 tuple implementation?