/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): Functor
{
return new self(
$this->desc,
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): Functor
{
return new self(
$this->action,
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): Functor
{
return new self(
$this->assertion,
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): Functor
{
return new self(
$this->str,
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): Functor
{
return new self(function ($x) use ($function) {
return $function(($this->processor)($x));
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): Functor
{
return $this;
}
interface Functor
{
/**
+ * map :: Functor f => (a -> b) -> f b
+ *
* @param callable $function
*
* @return self
*/
- public function map(callable $function);
+ public function map(callable $function): self;
}
/**
* @inheritdoc
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return $this;
}
/**
* @inheritdoc
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return self::of($this->bind($transformation));
}
*
* @inheritdoc
*/
- public function map(callable $go)
+ public function map(callable $go): FantasyLand\Functor
{
return new self(
$this->f->map($go)
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): FantasyLand\Functor
{
return self::of($function($this->value));
}
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): FantasyLand\Functor
{
return $this->bind(function ($value) use ($function) {
return static::of(function () use ($function, $value) {
/**
* @inheritdocus
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return static::of($this->bind($transformation));
}
/**
* @inheritdoc
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return self::of($this->bind($transformation));
}
/**
* @inheritdoc
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return $this;
}
});
}
- public function map(callable $function)
+ public function map(callable $function): FantasyLand\Functor
{
return self::of(function ($env) use ($function) {
return $function($this->runReader($env));
namespace Widmogrod\Monad;
use Widmogrod\Common;
-use Widmogrod\FantasyLand\Apply;
-use Widmogrod\FantasyLand\Monad;
+use Widmogrod\FantasyLand;
-class State implements Monad
+class State implements FantasyLand\Monad
{
const of = 'Widmogrod\Monad\State::of';
/**
* @inheritdoc
*/
- public function ap(Apply $b)
+ public function ap(FantasyLand\Apply $b)
{
return $this->bind(function ($f) use ($b) {
return $b->map($f);
/**
* @inheritdoc
*/
- public function map(callable $function)
+ public function map(callable $function): FantasyLand\Functor
{
return self::of(function ($state) use ($function) {
[$value, $newState] = $this->runState($state);
});
}
- public function map(callable $function)
+ public function map(callable $function): FantasyLand\Functor
{
return static::of($function($this->value), $this->side);
}
/**
* @inheritdoc
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return self::of(function () use ($transformation) {
[$head, $tail] = $this->headTail();
/**
* @inheritdoc
*/
- public function map(callable $transformation)
+ public function map(callable $transformation): FantasyLand\Functor
{
return $this;
}