diff options
author | Vlad Uspensky <v.uspenskiy@icloud.com> | 2017-10-20 14:38:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-20 14:38:42 -0700 |
commit | 0cb06d70bd91e1e6a4ab9d97851ef9db7aaedfd6 (patch) | |
tree | dd0d66174b6294251570ce24e8bd7b864beb561a /src/main/scala/xyz/driver/core/core.scala | |
parent | fa6716e0a3223fa0b15966f6bdfe5464e26d8fc2 (diff) | |
parent | ba2c214d2f8f9a1ba6d8265c55476a5281b8fd22 (diff) | |
download | driver-core-1.5.1.tar.gz driver-core-1.5.1.tar.bz2 driver-core-1.5.1.zip |
Merge pull request #76 from drivergroup/refinedv1.5.1
[RFC] Using "Refined" library (https://github.com/fthomas/refined) to…
Diffstat (limited to 'src/main/scala/xyz/driver/core/core.scala')
-rw-r--r-- | src/main/scala/xyz/driver/core/core.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/core/core.scala b/src/main/scala/xyz/driver/core/core.scala index 4747574..c405962 100644 --- a/src/main/scala/xyz/driver/core/core.scala +++ b/src/main/scala/xyz/driver/core/core.scala @@ -1,6 +1,8 @@ package xyz.driver import scalaz.{Equal, Monad, OptionT} +import eu.timepit.refined.api.Refined +import eu.timepit.refined.collection.NonEmpty package object core { @@ -83,6 +85,18 @@ package core { implicit def nameOrdering[T]: Ordering[Name[T]] = Ordering.by(_.value) } + final case class NonEmptyName[+Tag](value: String Refined NonEmpty) { + @inline def length: Int = value.value.length + override def toString: String = value.value + } + + object NonEmptyName { + implicit def nonEmptyNameEqual[T]: Equal[NonEmptyName[T]] = + Equal.equal[NonEmptyName[T]](_.value.value == _.value.value) + + implicit def nonEmptyNameOrdering[T]: Ordering[NonEmptyName[T]] = Ordering.by(_.value.value) + } + final case class Revision[T](id: String) object Revision { |