gvolpe / newtypes

Zero-cost wrappers (newtypes) for Scala 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Zero-cost wrappers (newtypes) for Scala 3

License:Apache License 2.0


Languages

Language:Scala 61.0%Language:Nix 39.0%