Skip to content

Commit

Permalink
correct traversable implementation for listLL
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosh committed Sep 28, 2023
1 parent 8fc58a4 commit 442683f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 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/).

## [3.0.1] - 2023-09-28

- fix `Traversable` instance for `ListL`

## [3.0.0] - 2023-09-27

- added `flake.nix` to provide a development environment
Expand Down
2 changes: 1 addition & 1 deletion src/Instances/ListL/ListTraversable.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function traverse(Applicative $applicative, callable $f, HK1 $a): HK1
* @param HK1<ListBrand, B> $t
* @return HK1<ListBrand, B>
*/
static fn (mixed $h, mixed $t): HK1 => ListL::fromBrand($t)->append($h),
static fn (mixed $h, mixed $t): HK1 => ListL::fromBrand($t)->prepend($h),
$f($c),
$d
),
Expand Down
4 changes: 2 additions & 2 deletions src/ListL.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function asNativeList(): array
* @param A $a
* @return ListL<A>
*/
public function append(mixed $a): self
public function prepend(mixed $a): self
{
return new self([...$this->list, ...[$a]]);
return new self([...[$a], ...$this->list]);
}

/**
Expand Down

0 comments on commit 442683f

Please sign in to comment.