|
Scala example source code file (MonoidSyntax.scala)
The MonoidSyntax.scala Scala example source codepackage scalaz package syntax /** Wraps a value `self` and provides methods related to `Monoid` */ final class MonoidOps[F] private[syntax](val self: F)(implicit val F: Monoid[F]) extends Ops[F] { //// final def multiply(n: Int): F = F.multiply(self, n) final def ifEmpty[A](tv: => A)(fv: => A)(implicit e: Equal[F]): A = F.ifEmpty(self)(tv)(fv) final def isMZero(implicit e: Equal[F]): Boolean = F.isMZero(self) final def onNotEmpty[A](v: => A)(implicit ma: Monoid[A], e: Equal[F]): A = F.onNotEmpty(self)(v) final def onEmpty[A](v: => A)(implicit ma: Monoid[A], e: Equal[F]): A = F.onEmpty(self)(v) //// } trait ToMonoidOps extends ToSemigroupOps { implicit def ToMonoidOps[F](v: F)(implicit F0: Monoid[F]) = new MonoidOps[F](v) //// def mzero[F](implicit F: Monoid[F]): F = F.zero def ∅[F](implicit F: Monoid[F]): F = F.zero //// } trait MonoidSyntax[F] extends SemigroupSyntax[F] { implicit def ToMonoidOps(v: F): MonoidOps[F] = new MonoidOps[F](v)(MonoidSyntax.this.F) def F: Monoid[F] //// def mzero(implicit F: Monoid[F]): F = F.zero def ∅(implicit F: Monoid[F]): F = F.zero //// } Other Scala examples (source code examples)Here is a short list of links related to this Scala MonoidSyntax.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.