All Downloads are FREE. Search and download functionalities are using the official Maven repository.

poly.algebra.hkt.ConcatenativeMonad.scala Maven / Gradle / Ivy

package poly.algebra.hkt

import scala.language.higherKinds

/**
 * Typeclass for concatenative monads. This is analogous to the Haskell typeclass `MonadPlus`.
 * @author Tongfei Chen
 * @since 0.2.1
 */
trait ConcatenativeMonad[M[_]] extends Monad[M] with ConcatenativeMonoidKind[M] {

  def filter[X](mx: M[X])(f: X => Boolean) = flatMap(mx)(e => if (f(e)) id(e) else empty[X])

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy