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

com.malliina.values.Readable.scala Maven / Gradle / Ivy

There is a newer version: 3.7.4
Show newest version
package com.malliina.values

trait Readable[R] {
  def read(key: String): Either[ErrorMessage, R]
  def map[S](f: R => S): Readable[S] = (s: String) => read(s).map(f)
  def flatMap[S](f: R => Either[ErrorMessage, S]): Readable[S] = (s: String) => read(s).flatMap(f)
}

object Readable {
  implicit val string: Readable[String] = (s: String) => Right(s)
  implicit val email: Readable[Email] = string.map(Email.apply)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy