|
Scala example source code file (OrderingInstances.scala)
The OrderingInstances.scala Scala example source codepackage scalaz package std package math import scala.math.{Ordering => SOrdering} import scalaz.Ordering trait OrderingInstances { def orderingMonoid[A] = new Monoid[SOrdering[A]] { def append(f1: SOrdering[A], f2: => SOrdering[A]) = new SOrdering[A] { def compare(x: A, y: A): Int = f1.compare(x, y) match { case 0 => f2.compare(x, y) case o => o } } def zero = new SOrdering[A] { def compare(x: A, y: A): Int = 0 } } } trait OrderingFunctions { final def ToScalazOrderFromOrdering[A](oa: SOrdering[A]): scalaz.Order[A] = new scalaz.Order[A] { def order(x: A, y: A): Ordering = Ordering.fromInt(oa.compare(x, y)) } } object ordering extends OrderingInstances Other Scala examples (source code examples)Here is a short list of links related to this Scala OrderingInstances.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.