Update interface of Functor
authorwidmogrod <widmogrod@gmail.com>
Sat, 23 Dec 2017 20:46:32 +0000 (21:46 +0100)
committerwidmogrod <widmogrod@gmail.com>
Sat, 23 Dec 2017 20:46:32 +0000 (21:46 +0100)
16 files changed:
example/FreeBddStyleDSLTest.php
example/FreeMonadTest.php
src/FantasyLand/Functor.php
src/Monad/Either/Left.php
src/Monad/Either/Right.php
src/Monad/Free/Free.php
src/Monad/Free/Pure.php
src/Monad/IO.php
src/Monad/Identity.php
src/Monad/Maybe/Just.php
src/Monad/Maybe/Nothing.php
src/Monad/Reader.php
src/Monad/State.php
src/Monad/Writer.php
src/Primitive/ListtCons.php
src/Primitive/ListtNil.php

index bb3964b..61a3956 100644 (file)
@@ -35,7 +35,7 @@ class Given implements ScenarioF
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): Functor
     {
         return new self(
             $this->desc,
@@ -59,7 +59,7 @@ class When implements ScenarioF
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): Functor
     {
         return new self(
             $this->action,
@@ -82,7 +82,7 @@ class Then implements ScenarioF
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): Functor
     {
         return new self(
             $this->assertion,
index 52b9418..89d15cc 100644 (file)
@@ -34,7 +34,7 @@ class PutStrLn implements TeletypeF
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): Functor
     {
         return new self(
             $this->str,
@@ -58,7 +58,7 @@ class GetLine implements TeletypeF
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): Functor
     {
         return new self(function ($x) use ($function) {
             return $function(($this->processor)($x));
@@ -71,7 +71,7 @@ class ExitSuccess implements TeletypeF
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): Functor
     {
         return $this;
     }
index c8619a2..d38b17e 100644 (file)
@@ -7,9 +7,11 @@ namespace Widmogrod\FantasyLand;
 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;
 }
index aa8e7f4..6122f36 100644 (file)
@@ -25,7 +25,7 @@ class Left implements Either
     /**
      * @inheritdoc
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return $this;
     }
index 421d78e..b817ba9 100644 (file)
@@ -25,7 +25,7 @@ class Right implements Either
     /**
      * @inheritdoc
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return self::of($this->bind($transformation));
     }
index d254e76..53234ae 100644 (file)
@@ -97,7 +97,7 @@ class Free implements MonadFree
      *
      * @inheritdoc
      */
-    public function map(callable $go)
+    public function map(callable $go): FantasyLand\Functor
     {
         return new self(
             $this->f->map($go)
index 5fb710c..820872e 100644 (file)
@@ -32,7 +32,7 @@ class Pure implements MonadFree
     /**
      * @inheritdoc
      */
-    public function map(callable $function)
+    public function map(callable $function): FantasyLand\Functor
     {
         return self::of($function($this->value));
     }
index d554902..3196a36 100644 (file)
@@ -56,7 +56,7 @@ class IO implements
     /**
      * @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) {
index a7afe10..deb280c 100644 (file)
@@ -19,7 +19,7 @@ class Identity implements
     /**
      * @inheritdocus
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return static::of($this->bind($transformation));
     }
index 35efaa6..530eef9 100644 (file)
@@ -25,7 +25,7 @@ class Just implements Maybe
     /**
      * @inheritdoc
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return self::of($this->bind($transformation));
     }
index 2b41dae..10cc52a 100644 (file)
@@ -29,7 +29,7 @@ class Nothing implements Maybe
     /**
      * @inheritdoc
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return $this;
     }
index 63a80a7..0315761 100644 (file)
@@ -35,7 +35,7 @@ class Reader implements FantasyLand\Monad
         });
     }
 
-    public function map(callable $function)
+    public function map(callable $function): FantasyLand\Functor
     {
         return self::of(function ($env) use ($function) {
             return $function($this->runReader($env));
index d540736..76a1c2e 100644 (file)
@@ -5,10 +5,9 @@ declare(strict_types=1);
 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';
 
@@ -25,7 +24,7 @@ class State implements Monad
     /**
      * @inheritdoc
      */
-    public function ap(Apply $b)
+    public function ap(FantasyLand\Apply $b)
     {
         return $this->bind(function ($f) use ($b) {
             return $b->map($f);
@@ -50,7 +49,7 @@ class State implements Monad
     /**
      * @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);
index 90b1068..fa3992b 100644 (file)
@@ -46,7 +46,7 @@ class Writer implements FantasyLand\Monad
         });
     }
 
-    public function map(callable $function)
+    public function map(callable $function): FantasyLand\Functor
     {
         return static::of($function($this->value), $this->side);
     }
index 6c69cfd..96c6d78 100644 (file)
@@ -42,7 +42,7 @@ class ListtCons implements Listt, \IteratorAggregate
     /**
      * @inheritdoc
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return self::of(function () use ($transformation) {
             [$head, $tail] = $this->headTail();
index 604fa54..726c7ae 100644 (file)
@@ -20,7 +20,7 @@ class ListtNil implements Listt
     /**
      * @inheritdoc
      */
-    public function map(callable $transformation)
+    public function map(callable $transformation): FantasyLand\Functor
     {
         return $this;
     }