# Scala 3 - type parameters and type members

**URL:** <https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472>\
**Category:** Language Design\
**Created:** [July 3, 2019, 1:09am UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472 "2019-07-03T01:09:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aboisvert](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/aboisvert/32/973_2.png) [@aboisvert](https://contributors.scala-lang.org/u/aboisvert)\
**Post date:** [July 3, 2019, 1:09am UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472/1 "2019-07-03T01:09:04Z")

</div>

There was mention in the past about some form of unification between type parameters and type members in Scala 3, as a means to simplify the language. I have not seen any recent mentions about this effort, nor does it seem featured in the Scala 3 roadmap.

I’m just wondering if this is still an ongoing research or whether it is something that was abandoned or turned out to be impractical, unsound or otherwise undesirable.

Thank you.

(Sorry, I looked for a reference to this effort but came up short with Google; I believe this was previously covered in one of Martin’s talks about Scala 3 / Dotty.)

---

<div class="post-metadata">

**Author:** ![bishabosha](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/bishabosha/32/3101_2.png) [@bishabosha](https://contributors.scala-lang.org/u/bishabosha)\
**Post date:** [July 3, 2019, 9:19am UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472/2 "2019-07-03T09:19:08Z")

</div>

Hello, type parameters are indeed encoded as abstract type members (with name mangling), you can read more in this paper:

[http://guillaume.martres.me/publications/dotty-hk.pdf](http://guillaume.martres.me/publications/dotty-hk.pdf),

Although this may be out of date again

---

<div class="post-metadata">

**Author:** ![odersky](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/odersky/32/42_2.png) [@odersky](https://contributors.scala-lang.org/u/odersky)\
**Post date:** [July 3, 2019, 11:28am UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472/3 "2019-07-03T11:28:10Z")

</div>

We went back having type parameters as first class feature. We learned a lot trying to do the encoding but in the end it was too brittle and too hard to make 100% backwards compatible, so we abandoned the effort.

---

<div class="post-metadata">

**Author:** ![tribbloid](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/tribbloid/32/1629_2.png) [@tribbloid](https://contributors.scala-lang.org/u/tribbloid)\
**Post date:** [January 6, 2023, 8:55pm UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472/4 "2023-01-06T20:55:07Z")

</div>

There are still 2 problems though:

1. The old design doc is still on the latest language reference ([Higher-Kinded Types in Dotty](https://dotty.epfl.ch/docs/internals/higher-kinded-v2.html)), and ranked pretty high on Google search.

2. Does the old design proposed a way to encode covariant/contravariant modifiers into type members? I was trying to manually convert it using type members:

before:

```auto
  object AsArg {

    trait P[+TT] {
      val vv: TT
    }

    trait P1 extends P[Product] {
      val vv: Product
    }
    trait P2 extends P1 with P[Tuple1[Int]] {
      val vv: Tuple1[Int]
    }
  }

```

after:

```auto
  object AsDependentType {

    trait P {
      type TT

      val vv: TT
    }

    trait P1 extends P {
      type TT <: Product

      val vv: Product
    }

    trait P2 extends P1 with P {
      type TT <: Tuple1[Int]

      val vv: Tuple1[Int]
    }
  }

```

But it never works and apparently is incompatible with the new type logic.

(main discussion: [scala - In Scala3, if generic type argument(s) is mapped to dependent type, how are covariant & contravariant modifiers mapped? - Stack Overflow](https://stackoverflow.com/questions/75035824/in-scala3-if-generic-type-arguments-is-mapped-to-dependent-type-how-are-cova))

---

<div class="post-metadata">

**Author:** ![sideeffffect](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sideeffffect/32/1466_2.png) [@sideeffffect](https://contributors.scala-lang.org/u/sideeffffect)\
**Post date:** [January 7, 2023, 2:25pm UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472/5 "2023-01-07T14:25:51Z")

</div>

In case somebody would find it helpful, here are slides that explain the history behind _encoding type parameters as type members_ and why it hasn’t worked out in the end:

> **[Implementing Higher-Kinded Types in Dotty](https://www.slideshare.net/Odersky/implementing-higherkinded-types-in-dotty)**
>
> Talk given at Scala Symposium 2016, Amsterdam

(sadly it seems like we don’t have recording from the talk)

> **[Implementing Higher-Kinded Types in Dotty (Scala 2016) - Scala 2016](https://conf.researchr.org/details/scala-2016/scala-2016/5/Implementing-Higher-Kinded-Types-in-Dotty)**
>
> Welcome to the Scala Symposium 2016! 
> Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional...

---

<div class="post-metadata">

**Author:** ![tribbloid](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/tribbloid/32/1629_2.png) [@tribbloid](https://contributors.scala-lang.org/u/tribbloid)\
**Post date:** [January 10, 2023, 5:09pm UTC](https://contributors.scala-lang.org/t/scala-3-type-parameters-and-type-members/3472/6 "2023-01-10T17:09:18Z")

</div>

Yeah its very helpful, never thought it would be tied to the predicativeness of the language.
