-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from veewee/export-interfaces
Export interfaces for Lenses and Isos
- Loading branch information
Showing
7 changed files
with
149 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace VeeWee\Reflecta\Iso; | ||
|
||
use Psl\Result\ResultInterface; | ||
use VeeWee\Reflecta\Lens\LensInterface; | ||
|
||
/** | ||
* @template S | ||
* @template A | ||
* | ||
* @psalm-immutable | ||
*/ | ||
interface IsoInterface | ||
{ | ||
/** | ||
* @param S $s | ||
* @return A | ||
*/ | ||
public function to($s); | ||
|
||
/** | ||
* @param S $s | ||
* @return ResultInterface<A> | ||
*/ | ||
public function tryTo($s): ResultInterface; | ||
|
||
/** | ||
* @param A $a | ||
* @return S | ||
*/ | ||
public function from($a); | ||
|
||
/** | ||
* @param A $a | ||
* @return ResultInterface<S> | ||
*/ | ||
public function tryFrom($a): ResultInterface; | ||
|
||
/** | ||
* @return LensInterface<S, A> | ||
*/ | ||
public function asLens(): LensInterface; | ||
|
||
/** | ||
* @return IsoInterface<A, S> | ||
*/ | ||
public function inverse(): self; | ||
|
||
/** | ||
* @template S2 | ||
* @template A2 | ||
* @param IsoInterface<S2, A2> $that | ||
* @return IsoInterface<S, A2> | ||
*/ | ||
public function compose(self $that): self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace VeeWee\Reflecta\Lens; | ||
|
||
use Psl\Result\ResultInterface; | ||
|
||
/** | ||
* @template S | ||
* @template A | ||
* | ||
* @psalm-immutable | ||
*/ | ||
interface LensInterface | ||
{ | ||
/** | ||
* @param S $s | ||
* @return A | ||
*/ | ||
public function get($s); | ||
|
||
/** | ||
* @param S $s | ||
* @return ResultInterface<A> | ||
*/ | ||
public function tryGet($s): ResultInterface; | ||
|
||
/** | ||
* @param S $s | ||
* @param A $a | ||
* @return S | ||
*/ | ||
public function set($s, $a); | ||
|
||
/** | ||
* @param S $s | ||
* @param A $a | ||
* @return ResultInterface<S> | ||
*/ | ||
public function trySet($s, $a): ResultInterface; | ||
|
||
/** | ||
* @param S $s | ||
* @param callable(A): A $f | ||
* @return S | ||
*/ | ||
public function update($s, callable $f); | ||
|
||
/** | ||
* @param S $s | ||
* @param callable(A): A $f | ||
* @return ResultInterface<S> | ||
*/ | ||
public function tryUpdate($s, callable $f): ResultInterface; | ||
|
||
/** | ||
* @return LensInterface<S, A|null> | ||
*/ | ||
public function optional(): LensInterface; | ||
|
||
/** | ||
* @template S2 | ||
* @template A2 | ||
* @param LensInterface<S2, A2> $that | ||
* @return LensInterface<S, A2> | ||
*/ | ||
public function compose(LensInterface $that): LensInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters