Returns a value of type T
refined as F[T, P]
on the right if
it satisfies the predicate P
, or an error message on the left
otherwise.
Returns a value of type T
refined as F[T, P]
on the right if
it satisfies the predicate P
, or an error message on the left
otherwise.
Example:
scala> import eu.timepit.refined.api._ | import eu.timepit.refined.numeric._ scala> RefType[Refined].refine[Positive](10) res1: Either[String, Refined[Int, Positive]] = Right(Refined(10))
Note: The return type is internal.RefinePartiallyApplied[F, P]
,
which has an apply
method on it, allowing the type T
to be
inferred from its argument.
Macro that returns a value of type T
refined as F[T, P]
if
it satisfies the predicate P
, or fails to compile otherwise.
Macro that returns a value of type T
refined as F[T, P]
if
it satisfies the predicate P
, or fails to compile otherwise.
Example:
scala> import eu.timepit.refined._ | import eu.timepit.refined.numeric._ scala> RefType[Refined].refineM[Positive](10) res1: Refined[Int, Positive] = Refined(10)
Note: M
stands for macro.
Note: The return type is internal.RefineMPartiallyApplied[F, P]
,
which has an apply
method on it, allowing the type T
to be
inferred from its argument.
Macro that returns a value of type T
refined as F[T, P]
if
it satisfies the predicate P
, or fails to compile otherwise.
Macro that returns a value of type T
refined as F[T, P]
if
it satisfies the predicate P
, or fails to compile otherwise.
Example:
scala> import eu.timepit.refined._ | import eu.timepit.refined.numeric._ scala> RefType[Refined].refineMF[Long, Positive](10) res1: Refined[Long, Positive] = Refined(10)
Note: M
stands for macro and F
for fully applied.
Note: The return type is internal.RefineMFullyApplied[F, T, P]
,
which has an apply
method on it, allowing refineMF
to be called
like in the given example. In contrast to refineM
, the type
T
needs to be specified before apply
can be called.
Type class that allows
F
to be used as carrier type of a refinement. The first type parameter ofF
is the base type that is being refined by its second type parameter which is the type-level predicate that denotes the refinement. Consequently,F[T, P]
is a phantom type that only contains a value of typeT
.The library provides instances of
RefType
forRefined
value classshapeless.tag.@@
which is a subtype of its first parameter (i.e.(T @@ P) <: T
)