Returns a value of type T
wrapped in 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
wrapped in 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._ | 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.RefineAux[F, P]
, which has
an apply
method on it, allowing refine
to be called like in the
given example.
Macro that returns a value of type T
wrapped in F[T, P]
if it
satisfies the predicate P
, or fails to compile otherwise.
Macro that returns a value of type T
wrapped in 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.RefineMAux[F, P]
, which has
an apply
method on it, allowing refineM
to be called like in the
given example.
Type class that allows
F
to be used as result type of a refinement. The first type parameter ofF
is the 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
)