stainless icon indicating copy to clipboard operation
stainless copied to clipboard

Classes with multiple parameter groups

Open jad-hamza opened this issue 4 years ago • 3 comments

This is currently not supported by Stainless:

case class C(var x: Int)(var y: Int = x) { }
Variables are only allowed within functions and as constructor parameters in Stainless.

jad-hamza avatar Jun 02 '21 08:06 jad-hamza

Are there uses of such constructors that do not involve partial application? If we need to support partial application, what does C(3) even mean, what is its type?

vkuncak avatar May 30 '22 09:05 vkuncak

Mostly for dependent types such as:

case class C(t: MyTrait)(a: MyTrait.A) 

As for C(3), Scala 3 types it as Int => C (as we would expect)

mario-bucev avatar May 30 '22 09:05 mario-bucev

I see, so partial application would probably be desugared in Stainless into a partial constructor:

  case class C(var x: Int, var y: Int)

  // replace all C constructor calls with makeC
  def makeC(x: Int)(y: Int) = C(x, y)

  def test: C =
    val pC = makeC(3)
    pC(42)

vkuncak avatar May 30 '22 09:05 vkuncak