scala - Why is there no >=> semigroup for A => M[A] in Scalaz? -
this followup previous question
kleisli defines 2 operators <=< (compose) , >=> (andthen). >=> looks natural me , don't understand how <=< can useful.
moreover, looks there no >=> semigroup a => m[a] <=< semigroup exist.
what rationale behind ?
compose (or <=<) little more natural when translating between point-free , non point-free styles. example, if have these functions:
val f: int => int = _ + 1 val g: int => int = _ * 10 we following equivalences:
scala> (f andthen g)(3) == g(f(3)) res0: boolean = true scala> (f compose g)(3) == f(g(3)) res1: boolean = true in compose case f , g in same order on both sides of equation.
unfortunately scala's type inference makes andthen (or >=>) more convenient, , tends more used compose. case mathematical conventions , quirks of scala's type inference system @ odds. scalaz (not surprisingly, given culture of project) chooses math side.
Comments
Post a Comment