I am curious where the method scalaz.Bind.bind
is implemented? Thanks
trait Bind[F[_]] extends Apply[F] { self =>
////
/** Equivalent to `join(map(fa)(f))`. */
def bind[A, B](fa: F[A])(f: A => F[B]): F[B]
...
I am looking at 7.3.0-SNAPSHOT source.
Bind
follows typeclass pattern, and those tend to have multiple implementations for different types that support operations defined by them. That implementations called typeclass instances. Most of the Scalaz typeclass instances for Scala standard library classes reside in scalaz.std
package. Examples:
Bind[List]
: listInstances
implicit value in scalaz.std.ListInstaces
trait, defined in scalaz/std/List.scala. It can be imported via scalaz.std.list
object (in the same file) or scalaz.Scalaz
object (in scalaz/Scalaz.scala), both of which extend the ListInstances
trait.
Bind[Option]
: optionInstances
implicit value in sclaaz.std.OptionInstances
, defined in scalaz/std/Option.scala. It can be imported via scalaz.std.option
object (in the same file) or scalaz.Scalaz
object (in scalaz/Scalaz.scala), both of which extend the OptionInstances
trait.
You can also create Scalaz typeclass instances for your own types by creating implicit values or conversions that implement one or more corresponding traits. To be visible, implicits must be imported into your context.