All Downloads are FREE. Search and download functionalities are using the official Maven repository.

urldsl.vocabulary.FromStringWithNumeric.scala Maven / Gradle / Ivy

The newest version!
package urldsl.vocabulary

import urldsl.errors.ErrorFromThrowable

trait FromStringWithNumeric {

  implicit def numericFromString[T, A](
      implicit num: Numeric[T],
      fromThrowable: ErrorFromThrowable[A]
  ): FromString[T, A] = FromString.factory(
    s =>
      num.parseString(s) match {
        case Some(t) => Right(t)
        case None    => Left(fromThrowable.fromThrowable(new Exception(s"$s is not numeric")))
      }
  )

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy