What is the use of this scalaz.Ordering case?
Reading http://eed3si9n.com/learning-scalaz/Order.html :
scala> 1.0 ?|? 2.0
res10: scalaz.Ordering = LT
Everything that is stated in relation to the order:
"
scala> 1 > 2.0
res8: Boolean = false
scala> 1 gt 2.0
<console>:14: error: could not find implicit value for parameter F0: scalaz.Order[Any]
1 gt 2.0
^
scala> 1.0 ?|? 2.0
res10: scalaz.Ordering = LT
scala> 1.0 max 2.0
res11: Double = 2.0
Order enables ?|? syntax which returns Ordering: LT, GT, and EQ. It also enables lt, gt, lte, gte, min, and max operators by declaring order method. Similar to Equal, comparing Int and Doubl fails compilation.
"
What is the meaning of scalaz.Ordering in this case?
1.0 max 2.0 uses the standard Scala API max method and is not scalaz?
source to share
Scalaz provides this syntax for instance things Order
. You are correct in this case, which 1.0 max 2.0
will use max
from the standard library, however, since it is more specific (as you can quickly confirm by powering up with the :power
REPL and then typing something for example settings.processArgumentString("-print typer")
).
The best example in this case would be something like some(2.0) max some(1.0)
, since the standard library does not provide max
for Option[Double]
that hiding Scalaz's.
source to share
Tom Switzer summarizes in a related thread :
Instead of returning
Int
fromOrder#compare
, scalaz returnsscalaz.Ordering
.
source to share