Functor

trait Functor[F[_]]

A type F is a Functor if it provides a function fmap which, given any types A and B lets you apply any function from ~A => B~ to turn an F[A] into an F[B], preserving the structure of F. Furthermore F needs to adhere to the following:

Identity

fa <#> identity == identity(fa)

Composition

(f compose g) `<$>` fa  == (map[F](f) compose map[F](g))(fa)
Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def fmap[A, B](f: A => B): F[A] => F[B]

Extensions

Extensions

extension (fa: F[A])
@targetName("voidLeft")
def $>[A, B](a: B): F[B]

Drop whatever value A on left and return F[B] on the right

Drop whatever value A on left and return F[B] on the right

Example
Option(1) `$>` 3 == Option(3)
@targetName("mapFlipped")
def <#>[A, B](f: A => B): F[B]

Usually fmap takes function first, mapFlipped takes data first

Usually fmap takes function first, mapFlipped takes data first

Example
fa <#> identity == identity(fa)
def map[A, B](f: A => B): F[B]
def void[A, B]: F[Unit]

Void F[A] and return F[Unit]

Void F[A] and return F[Unit]

Example
Option(2).void == Option(())