opaque type PositiveInt <: Int = Int
def PositiveInt(x: Int): Option[PositiveInt] =
if x > 0 then Some(x) else None
cf http://dotty.epfl.ch/docs/reference/other-new-features/opaques.html#bounds-for-opaque-type-aliases
opaque type PositiveInt <: Int = Int
def PositiveInt(x: Int): Option[PositiveInt] =
if x > 0 then Some(x) else None
cf http://dotty.epfl.ch/docs/reference/other-new-features/opaques.html#bounds-for-opaque-type-aliases