Skip to content

Commit

Permalink
add voidRight in ExtraFunctor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosh committed Sep 28, 2023
1 parent 442683f commit 2c440e5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic versioning](http://semver.org/).

## [unreleased]

- add `voidRight` in `ExtraFunctor`

## [3.0.1] - 2023-09-28

- fix `Traversable` instance for `ListL`
Expand Down
43 changes: 43 additions & 0 deletions src/Typeclass/Extra/ExtraFunctor.php
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
);
}
}

0 comments on commit 2c440e5

Please sign in to comment.