The MonadFilter type-class is equipped with an additional
operation which allows us to create an "Empty" value for the Monad
(for whatever "empty" makes sense for that particular monad). This
is of particular interest to us since it allows us to add a
filter method to a Monad, which is used when pattern matching or
using guards in for comprehensions.
The purpose of this type-class is to support the data-types in the
Monix library and it is considered a shim for a lawful type-class
to be supplied by libraries such as Cats or Scalaz or equivalent.
CREDITS: The type-class encoding has been inspired by the Scato
project by Aloïs Cochard and Scalaz 8
and the type has been extracted from Cats.
The
MonadFilter
type-class is equipped with an additional operation which allows us to create an "Empty" value for the Monad (for whatever "empty" makes sense for that particular monad). This is of particular interest to us since it allows us to add afilter
method to a Monad, which is used when pattern matching or using guards in for comprehensions.To implement
MonadFilter
:The purpose of this type-class is to support the data-types in the Monix library and it is considered a shim for a lawful type-class to be supplied by libraries such as Cats or Scalaz or equivalent.
CREDITS: The type-class encoding has been inspired by the Scato project by Aloïs Cochard and Scalaz 8 and the type has been extracted from Cats.