alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (OrderSyntax.scala)

This example Scala source code file (OrderSyntax.scala) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Scala by Example" TM.

Learn more about this Scala project at its project page.

Java - Scala tags/keywords

boolean, equalsyntax, order, ordering, ordersyntax, toequalops, toorderops

The OrderSyntax.scala Scala example source code

package scalaz
package syntax

/** Wraps a value `self` and provides methods related to `Order` */
final class OrderOps[F] private[syntax](val self: F)(implicit val F: Order[F]) extends Ops[F] {
  ////
  final def <(other: F): Boolean = F.lessThan(self, other)
  final def <=(other: F): Boolean = F.lessThanOrEqual(self, other)
  final def >(other: F): Boolean = F.greaterThan(self, other)
  final def >=(other: F): Boolean = F.greaterThanOrEqual(self, other)
  final def max(other: F): F = F.max(self, other)
  final def min(other: F): F = F.min(self, other)
  final def cmp(other: F): Ordering = F.order(self, other)
  final def ?|?(other: F): Ordering = F.order(self, other)
  final def lte(other: F): Boolean = F.lessThanOrEqual(self, other)
  final def gte(other: F): Boolean = F.greaterThanOrEqual(self, other)
  final def lt(other: F): Boolean = F.lessThan(self, other)
  final def gt(other: F): Boolean = F.greaterThan(self, other)
  ////
}

trait ToOrderOps extends ToEqualOps {
  implicit def ToOrderOps[F](v: F)(implicit F0: Order[F]) =
    new OrderOps[F](v)

  ////

  ////
}

trait OrderSyntax[F] extends EqualSyntax[F] {
  implicit def ToOrderOps(v: F): OrderOps[F] = new OrderOps[F](v)(OrderSyntax.this.F)

  def F: Order[F]
  ////

  ////
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala OrderSyntax.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.