This repository has been archived by the owner on Jun 15, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor FunctionalBuilder to improve Formatting errors
FunctionalBuilder is splitted into FunctorSyntax, ContravariantSyntax, and InvariantSyntax, used respectivery for the Rule, Write and Format ~ syntax. As a result, error messages are much nicer, and the trailing _ after the .apply and .unapply is no longer mendatory.
- Loading branch information
1 parent
6509c2b
commit 357b877
Showing
7 changed files
with
140 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package jto.validation | ||
|
||
case class ~[A, B](_1: A, _2: B) | ||
|
||
trait SyntaxCombine[M[_]] { | ||
def apply[A, B](ma: M[A], mb: M[B]): M[A ~ B] | ||
} | ||
|
||
class InvariantSyntaxObs[M[_], A](ma: M[A])(implicit combine: SyntaxCombine[M]) { | ||
def ~[B](mb: M[B]): InvariantSyntax[M]#InvariantSyntax2[A, B] = { | ||
val b = new InvariantSyntax(combine) | ||
new b.InvariantSyntax2[A, B](ma, mb) | ||
} | ||
} | ||
|
||
class FunctorSyntaxObs[M[_], A](ma: M[A])(implicit combine: SyntaxCombine[M]) { | ||
def ~[B](mb: M[B]): FunctorSyntax[M]#FunctorSyntax2[A, B] = { | ||
val b = new FunctorSyntax(combine) | ||
new b.FunctorSyntax2[A, B](ma, mb) | ||
} | ||
} | ||
|
||
class ContravariantSyntaxObs[M[_], A](ma: M[A])(implicit combine: SyntaxCombine[M]) { | ||
def ~[B](mb: M[B]): ContravariantSyntax[M]#ContravariantSyntax2[A, B] = { | ||
val b = new ContravariantSyntax(combine) | ||
new b.ContravariantSyntax2[A, B](ma, mb) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters