# Combining TupledFunction with NamedTuple

**URL:** <https://contributors.scala-lang.org/t/combining-tupledfunction-with-namedtuple/7037>\
**Category:** Scala Improvement Process\
**Created:** [February 9, 2025, 12:52pm UTC](https://contributors.scala-lang.org/t/combining-tupledfunction-with-namedtuple/7037 "2025-02-09T12:52:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goshacodes](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/goshacodes/32/3068_2.png) [@goshacodes](https://contributors.scala-lang.org/u/goshacodes)\
**Post date:** [February 9, 2025, 12:52pm UTC](https://contributors.scala-lang.org/t/combining-tupledfunction-with-namedtuple/7037/1 "2025-02-09T12:52:35Z")

</div>

Hi! I’m currently using TupledFunction in scalamock like this:

```scala
extension [F](inline f: F)
    /**
     * Allows to get caught method arguments.
     * For multiple arguments - returns them tupled.
     * One list item per call.
     * {{{
     * trait Foo:
     * def foo2(x: Int, y: Int): Int
     *
     * val foo = stub[Foo]
     *
     * foo.foo2.returns(_ => 1)
     *
     * foo.foo2(0, 0)
     * foo.foo2(1, 1)
     *
     * foo.foo2.calls // List((0, 0), (1, 1))
     * }}}
     */
    inline def calls[Args <: NonEmptyTuple, R](
      using TupledFunction[F, Args => R]
    ): List[UntupledOne[Args]] = ???

type UntupledOne[X <: NonEmptyTuple] = X match
  case head *: EmptyTuple => head
  case _ => X

```

And I wonder if there is any possibility it can be improved to work with NamedTuple like this:

```scala
type NonEmptyNamedTuple = ???

extension [F](inline f: F)
    /**
     * same as before
     * {{{  
     * foo.foo2.calls // List((x = 0, y = 0), (x = 1, y = 1))
     * }}}
     */
    inline def calls[Args <: NonEmptyNamedTuple, R](
      using TupledFunction[F, Args => R]
    ): List[UntupledOne[Args]] = ???

type UntupledOne[X <: NonEmptyNamedTuple] = NonEmptyTuple.DropNames[X] match
  case head *: EmptyTuple => head
  case _ => X

```
