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

eidos_2.11.0.1.1.source-code.Build.scala Maven / Gradle / Ivy

The newest version!
package eidos
package id

sealed trait Build[A] {
  type Out
  def build(s: String, l: Label[A]): Out
}

object Build {
  private[id] type Aux[I, O] = Build[I] { type Out = O }

  private[id] def default[A]: Aux[A, Id[A]] = new Build[A] {
    type Out = Id[A]
    override def build(v: String, l: Label[A]): Out = Id.unsafeCreate(v, l)
  }

  trait Validated[A] extends Build[A] {
    final override type Out = Option[Id[A]]
    final override def build(s: String, l: Label[A]): Out =
      validate(s).map(valid => Id.unsafeCreate(valid, l))

    def validate(s: String): Option[String]
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy