-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Marcosh\LamPHPda\Typeclass\Extra; | ||
|
||
use Marcosh\LamPHPda\Brand\Brand; | ||
use Marcosh\LamPHPda\HK\HK1; | ||
use Marcosh\LamPHPda\Typeclass\Functor; | ||
|
||
/** | ||
* @template F of Brand | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class ExtraFunctor | ||
{ | ||
/** @var Functor<F> */ | ||
private Functor $functor; | ||
|
||
/** | ||
* @param Functor<F> $functor | ||
*/ | ||
public function __construct(Functor $functor) | ||
{ | ||
$this->functor = $functor; | ||
} | ||
|
||
/** | ||
* @template A | ||
* @template B | ||
* @param A $a | ||
* @param HK1<F, B> $hk | ||
* @return HK1<F, A> | ||
*/ | ||
public function voidRight($a, HK1 $hk): HK1 | ||
{ | ||
return $this->functor->map( | ||
static fn ($_) => $a, | ||
$hk | ||
); | ||
} | ||
} |