|
Scala example source code file (Function2Ops.scala)
The Function2Ops.scala Scala example source codepackage scalaz package syntax package std final class Function2Ops[T1, T2, R](val self: (T1, T2) => R) extends AnyVal { def flip: (T2, T1) => R = (v2: T2, v1: T1) => self(v1, v2) def on[X](f: (R, R) => X, t1: (T1, T1), t2: (T2, T2)): X = f(self(t1._1, t2._1), self(t1._2, t2._2)) def contramap[TT](f: TT => T1)(implicit ev: T1 =:= T2): (TT, TT) => R = (t1, t2) => self(f(t1), ev(f(t2))) def lift[F[_]](implicit F: Applicative[F]): (F[T1], F[T2]) => F[R] = F.lift2(self) def byName: (=> T1, => T2) => R = (t1, t2) => self(t1, t2) } trait ToFunction2Ops { implicit def ToFunction2Ops[T1, T2, R](f: (T1, T2) => R) = new Function2Ops(f) } Other Scala examples (source code examples)Here is a short list of links related to this Scala Function2Ops.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.