|
Scala example source code file (IsEmpty.scala)
The IsEmpty.scala Scala example source code
package scalaz
////
/**
* Typeclass that permits testing whether some type with an empty representation
* is in fact empty.
*/
////
trait IsEmpty[F[_]] extends PlusEmpty[F] { self =>
////
def isEmpty[A](fa: F[A]): Boolean
// derived functions
trait IsEmptyLaw extends EmptyLaw {
def emptyIsEmpty[A]: Boolean = isEmpty(empty[A])
def emptyPlusIdentity[A](f1: F[A], f2: F[A]): Boolean =
(isEmpty(f1) && isEmpty(f2)) == isEmpty(plus(f1, f2))
}
def isEmptyLaw = new IsEmptyLaw {}
////
val isEmptySyntax = new scalaz.syntax.IsEmptySyntax[F] { def F = IsEmpty.this }
}
object IsEmpty {
@inline def apply[F[_]](implicit F: IsEmpty[F]): IsEmpty[F] = F
////
////
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala IsEmpty.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.