/newtypes

Zero-cost wrappers (newtypes) for Scala 3

Primary LanguageScalaApache License 2.0Apache-2.0

newtypes

Exploring zero-cost wrappers (aka newtypes) for Scala 3 built on top of opaque types.

import dev.profunktor.NewType

val Foo = NewType.of[Int]
type Foo = Foo.Type

def something(foo: Foo): Unit =
  println(foo.value)

something(Foo(22)) // prints out 22
something(123)     // fails to compile