TypeWrapper

neotype.TypeWrapper
sealed abstract class TypeWrapper[A]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Newtype[A]
class Subtype[A]

Members list

Type members

Types

type Type

Value members

Abstract methods

inline def unsafeMake(inline input: A): Type

WARNING! Creates a new instance of the newtype without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

WARNING! Creates a new instance of the newtype without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

This method should be used with caution, as it bypasses any validation defined in the validate method. It is recommended to use the apply method instead, which performs compile-time validation of the input.

Attributes

inline def unsafeMakeF[F[_]](inline input: F[A]): F[Type]

WARNING! This casts an F[A] to an F[Type] without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

WARNING! This casts an F[A] to an F[Type] without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

If, for instance, you have a List[A] and you want to convert it to a List[Type], you can use this method to do so.

Attributes

Concrete methods

inline def apply(inline input: A): Type

Creates a new instance of the newtype.

Creates a new instance of the newtype.

If the validate method is not defined for this, it will simply wrap the input in the neotype.

If validate is defined, it will be called at compile-time to check if the input is valid. If it fails, it will raise a compile-time error. input should be a literal or a constant expression, a compile-time known value—otherwise, you should use the make method instead.

Attributes

inline def applyAll(inline values: A*): List[Type]

Creates a list of newtype instances.

Creates a list of newtype instances.

This will essentially call apply for each value in the list, performing the same compile-time validation for each element.

If any of the elements fail validation, it will raise a compile-time error. Otherwise, it will return a list of newtype instances.

Attributes

def validate(input: A): Boolean | String

Validates the input and returns a boolean or an error message.

Validates the input and returns a boolean or an error message.

Attributes