NewType

trait NewType[O, N] extends OldType[O, N]

The purpose of this type class is to give further application code a way to talk about this "new type" encoding. So that converting to and from the underlying type can be done with as little boilerplate as possible in inter-op with 3rd party libraries, and other classes.

The purpose of this type class is to give further application code a way to talk about this "new type" encoding. So that converting to and from the underlying type can be done with as little boilerplate as possible in inter-op with 3rd party libraries, and other classes.

Type Params
N

N for new type. i.e. the type that ought to live only in the compiler

O

O for old type. i.e. the underlying runtime type

See also

sprout.SproutShow as an example. We can easily provide a Show instance for N if the underlying representation has one. And it's opt in. This principle is then extended to a host of 3rd party libraries to eliminate boilerplate. See the sprout-interop github repo for many other examples.

Companion
object
trait OldType[O, N]
class Object
trait Matchable
class Any

Value members

Abstract methods

@inline
def newType(o: O): N

Inherited methods

@inline
def oldType(n: N): O
Inherited from
OldType
def symbolicName: String

Ought to be used only for pretty printing and debug messages, not intented to represent extremly precise and consistent values that can be relied on in mission critical code

Ought to be used only for pretty printing and debug messages, not intented to represent extremly precise and consistent values that can be relied on in mission critical code

Returns

e.g. object TestValue extends Sprout[Int] //which extends OldType type TestValue = TestValue.Type returns TestValue

Inherited from
OldType