Skip to content

Commit

Permalink
Submit a SIP on existential containers
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Dec 20, 2024
1 parent 4241422 commit 74c8f75
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions content/existential-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ In broad strokes, our solution generalizes the following possible implementation

```scala
trait AnyPolygon:
type Value
type Value: Polygon as witness
val value: Value
val witness: Polygon { type Self = Value }

def largest(xs: Seq[AnyPolygon]): Option[AnyPolygon] =
xs.maxByOption((a) => a.witness.area(a.value))
Expand Down Expand Up @@ -153,6 +152,11 @@ More specifically, given an existential container `c`, accessing `c.value` _open

Since no change in implicit resolution is needed, this proposal cannot create unforeseen negative interactions with existing features.

### Other concerns

This document has been written under the experimental modularity improvements for Scala 3.
Although the proposed feature is fully expressible without those changes, the encoding of existential containers can only work with the "old" (i.e., the one currently used in production) or "new" type class style.

### Open questions

One problem not addressed by the proposed encoding is the support of multiple type classes to form the interface of a specific container.
Expand Down

0 comments on commit 74c8f75

Please sign in to comment.