object Or extends Subtype[Boolean]
- Alphabetic
- By Inheritance
- Or
- Subtype
- Newtype
- NewtypeVersionSpecific
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
macro
def
apply(value: Boolean, values: Boolean*): NonEmptyChunk[Type]
Converts multiple instances of the underlying type to NonEmptyChunk of instances of the newtype.
Converts multiple instances of the underlying type to NonEmptyChunk of instances of the newtype.
If there is a
def assertion(see assert), each value will be checked at compile-time.- Definition Classes
- Newtype
-
macro
def
apply(value: Boolean): Type
Converts an instance of the underlying type to an instance of the newtype.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
macro
def
assert(assertion: Assertion[Boolean]): QuotedAssertion[Boolean]
This method is used to generate Newtype that can be validated at compile-time.
This method is used to generate Newtype that can be validated at compile-time. This must wrap a Assertion and be assigned to
def assertion.For example, here is a refined Newtype for Natural numbers. Natural numbers are whole numbers greater than or equal to 0.
import zio.prelude.Subtype import zio.prelude.Assertion._ type Natural = Natural.Type object Natural extends Subtype[Int] { def assertion = assert(greaterThanOrEqualTo(0)) }
With this
assertiondefined,Natural.applywill check literal values at compile-time, failing with an error message if the Assertion is not satisfied.Natural(-10)would render "-10 failed to satisfy greaterThanOrEqualTo(10)"IMPORTANT: Due to the macro machinery powering this feature, you must be sure to NOT ANNOTATE
def assertionwith a type (QuotedAssertion). If you do so, the macro will not be able to run the provided assertion at compile-time and will fail with a message containing this very same information.- Definition Classes
- Newtype
-
macro
def
assertCustom(f: (Boolean) ⇒ Either[AssertionError, Unit]): QuotedAssertion[Boolean]
This method is used as an escape hatch for
assertto allow Newtypes to use custom functions.This method is used as an escape hatch for
assertto allow Newtypes to use custom functions. If at all possible, you should use assert instead.This will use whitebox.Context.eval under the hood, so all limitations of that function apply here. See here for details: https://github.com/scala/scala/blob/2.13.x/src/reflect/scala/reflect/macros/Evals.scala#L69
IMPORTANT: Due to the macro machinery powering this feature, you must be sure to NOT ANNOTATE
def assertionwith a type (QuotedAssertion). If you do so, the macro will not be able to run the provided assertion at compile-time and will fail with a message containing this very same information.- Definition Classes
- Newtype
-
def
assertion: QuotedAssertion[Boolean]
- Definition Classes
- Newtype
-
implicit
def
classTag(implicit underlying: ClassTag[Boolean]): ClassTag[Type]
- Definition Classes
- Newtype
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
derive[TypeClass[_]](implicit instance: TypeClass[Boolean]): TypeClass[Type]
Derives an instance of a type class for the new type given an instance of the type class for the underlying type.
Derives an instance of a type class for the new type given an instance of the type class for the underlying type. The caller is responsible for the type class being a valid instance for the new type.
- Attributes
- protected
- Definition Classes
- Newtype
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
macro
def
make(value: Boolean): Validation[String, Type]
- Definition Classes
- Newtype
-
macro
def
makeAll[F[+_]](value: F[Boolean])(implicit arg0: ForEach[F]): Validation[String, F[Type]]
- Definition Classes
- Newtype
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unapply(value: Type): Some[Boolean]
Allows pattern matching on newtype instances to convert them back to instances of the underlying type.
Allows pattern matching on newtype instances to convert them back to instances of the underlying type.
- Definition Classes
- Newtype
-
def
unwrap(value: Type): Boolean
Converts an instance of the newtype back to an instance of the underlying type.
Converts an instance of the newtype back to an instance of the underlying type.
- Definition Classes
- Newtype
-
def
unwrapAll[F[_]](value: F[Type]): F[Boolean]
Converts an instance of a type parameterized on the newtype back to an instance of a type parameterized on the underlying type.
Converts an instance of a type parameterized on the newtype back to an instance of a type parameterized on the underlying type. For example, this could be used to convert a list of instances of the newtype back to a list of instances of the underlying type.
- Definition Classes
- Newtype
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
wrap(value: Boolean): Type
Converts an instance of the underlying type to an instance of the newtype.
Converts an instance of the underlying type to an instance of the newtype. Ignores the assertion.
- Attributes
- protected
- Definition Classes
- Newtype
-
macro
def
wrapAll[F[_]](value: F[Boolean]): F[Type]
Converts an instance of a type parameterized on the underlying type to an instance of a type parameterized on the newtype.
Converts an instance of a type parameterized on the underlying type to an instance of a type parameterized on the newtype. For example, this could be used to convert a list of instances of the underlying type to a list of instances of the newtype.
Due to macro limitations, this method cannot with refined newtype and will thus issue a compiler error if you attempt to do so.
- Definition Classes
- Newtype