Last active
April 11, 2018 07:28
-
-
Save afsalthaj/b07c2bbe1279e49d5c7085c4571164cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
implicit def genericValidation[A, R]( | |
implicit gen: Generic.Aux[A, R], env: Validation[R] | |
): Validation[A] = | |
new Validation[A] { | |
override def validate(b: A) = | |
env.validate(gen.to(b)).map(gen.from) | |
} | |
// Please note that Generic.Aux[A, R] === Generic[A] {type Repr = R} | |
// as we cannot do env: Validation[gen.Repr] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment