#Scala: validation using cats.
Stop doing:
(validator1(a) |@| validator2(a)).map{case _ => a}
Start doing:
validator1(a) *> validator2(a)
-
-
urgh, yep because code duplication is "readable"
1 reply 1 retweet 3 likes -
(validator1 *> validator2)(a)
1 reply 0 retweets 5 likes -
Replying to @dibblego
you mean it would be nicer if it worked this way too? asking b/c that code doesn't work
@puffnfresh @paul_snively@DanielaSfregola2 replies 0 retweets 0 likes -
Replying to @lambdista @dibblego and
OTHA, this one would work: (validator1(_) andThen validator2)(a)
1 reply 0 retweets 0 likes
It works coz applicatives compose, Function1[T,_] is applicative, but needs decorating
2:03 PM - 13 Mar 2017
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.