Skip to content

Commit

Permalink
Changed toOption to match in order to support previous scala versions
Browse files Browse the repository at this point in the history
  • Loading branch information
umbreak committed Mar 19, 2018
1 parent 3c3b9cc commit d825a2e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eu.timepit.refined.shapeless

import _root_.shapeless.Typeable
import eu.timepit.refined.api.{RefType, Validate}
import scala.util.Right

package object typeable {

Expand All @@ -14,7 +15,12 @@ package object typeable {
P: Typeable[P]): Typeable[F[T, P]] =
new Typeable[F[T, P]] {
override def cast(t: Any): Option[F[T, P]] =
T.cast(t).flatMap(v => rt.refine[P](v).toOption)
T.cast(t)
.flatMap(casted =>
rt.refine[P](casted) match {
case Right(v) => Some(v)
case _ => None
})
override def describe: String = s"Refined[${T.describe}, ${P.describe}]"
}
}

0 comments on commit d825a2e

Please sign in to comment.