lampepfl / dotty-feature-requests

Historical feature requests. Please create new feature requests at https://github.com/lampepfl/dotty/discussions/new?category=feature-requests
31 stars 2 forks source link

Support deriving opaque types #248

Closed bertlebee closed 1 year ago

bertlebee commented 3 years ago

I'd like to be able to derive instances of opaque types. This would enable derivations for types we don't control and permit alternative derivations where one already exists

Currently the following code will not compile (OpaqueTypes.OpaqueType is not a class type)

object OpaqueTypes:
  opaque type OpaqueType[A] = List[A]
  object OpaqueType:
    def derived[A]: OpaqueType[A] = Nil

import OpaqueTypes.OpaqueType
case class Boom[A](value: A) derives OpaqueType

Initial discussion here: https://github.com/lampepfl/dotty/issues/13808