Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Commit

Permalink
Add utilities Read / Write
Browse files Browse the repository at this point in the history
  • Loading branch information
jto committed Aug 4, 2016
1 parent 6ebf764 commit c7f223c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions validation-core/src/main/scala/Rule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,11 @@ object Rule {
: FunctorSyntaxObs[Rule[I, ?], O] =
new FunctorSyntaxObs[Rule[I, ?], O](r)(fcb)
}

object Read {
sealed trait Deferred[O] {
def apply[I](i: I)(implicit r: RuleLike[I, O]) = r.validate(i)
}

def apply[O] = new Deferred[O]{}
}
6 changes: 6 additions & 0 deletions validation-core/src/main/scala/Write.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ object Write {
def writes(i: I) = w(i)
}

sealed trait Deferred[O] {
def apply[I](i: I)(implicit w: WriteLike[I, O]) = w.writes(i)
}

def apply[O] = new Deferred[O]{}

def of[I, O](implicit w: Write[I, O]): Write[I, O] = w

def toWrite[I, O](r: WriteLike[I, O]): Write[I, O] =
Expand Down

0 comments on commit c7f223c

Please sign in to comment.