home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (MonadPlusSyntax.scala)

This example Scala source code file (MonadPlusSyntax.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, toapplicativeplusops, tomonadplusops, tomonadplusops0, unapply

The MonadPlusSyntax.scala Scala example source code

package scalaz
package syntax

/** Wraps a value `self` and provides methods related to `MonadPlus` */
final class MonadPlusOps[F[_],A] private[syntax](val self: F[A])(implicit val F: MonadPlus[F]) extends Ops[F[A]] {
  import Leibniz.===

  def filter(f: A => Boolean) =

  def withFilter(f: A => Boolean) =

  final def uniteU[T](implicit T: Unapply[Foldable, A]): F[T.A] =

  def unite[T[_], B](implicit ev: A === T[B], T: Foldable[T]): F[B] = {
    val ftb: F[T[B]] = ev.subst(self)
    F.unite[T, B](ftb)

  final def separate[G[_, _], B, C](implicit ev: A === G[B, C], G: Bifoldable[G]): (F[B], F[C]) =


sealed trait ToMonadPlusOps0 {
  implicit def ToMonadPlusOpsUnapply[FA](v: FA)(implicit F0: Unapply[MonadPlus, FA]) =
    new MonadPlusOps[F0.M,F0.A](F0(v))(F0.TC)


trait ToMonadPlusOps extends ToMonadPlusOps0 with ToMonadOps with ToApplicativePlusOps {
  implicit def ToMonadPlusOps[F[_],A](v: F[A])(implicit F0: MonadPlus[F]) =
    new MonadPlusOps[F,A](v)



trait MonadPlusSyntax[F[_]] extends MonadSyntax[F] with ApplicativePlusSyntax[F] {
  implicit def ToMonadPlusOps[A](v: F[A]): MonadPlusOps[F, A] = new MonadPlusOps[F,A](v)(MonadPlusSyntax.this.F)

  def F: MonadPlus[F]


Other Scala examples (source code examples)

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

my book on functional programming


new blog posts


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