Skip to content

Commit

Permalink
Reorder PHPDoc properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol authored and marcosh committed Oct 21, 2021
1 parent e13ef91 commit 4e56301
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 127 deletions.
57 changes: 17 additions & 40 deletions src/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
use Marcosh\LamPHPda\Typeclass\Traversable;

/**
* @psalm-immutable
*
* @template A
*
* @implements DefaultMonad<IdentityBrand, A>
* @implements DefaultTraversable<IdentityBrand, A>
*
* @psalm-immutable
*/
final class Identity implements DefaultMonad, DefaultTraversable
{
Expand All @@ -46,27 +46,23 @@ private function __construct($value)
}

/**
* @psalm-pure
*
* @template B
*
* @param B $value
*
* @return Identity<B>
*
* @psalm-pure
*/
public static function wrap($value): Identity
{
return new self($value);
}

/**
* @psalm-pure
*
* @template B
*
* @param HK1<IdentityBrand, B> $b
*
* @return Identity<B>
*
* @psalm-pure
*/
public static function fromBrand(HK1 $b): Identity
{
Expand All @@ -84,21 +80,19 @@ public function unwrap()

/**
* @template B
*
* @param Functor<IdentityBrand> $functor
* @param callable(A): B $f
*
* @return Identity<B>
*
* @psalm-suppress ArgumentTypeCoercion
*/
public function imap(Functor $functor, callable $f): Identity
{
/** @psalm-suppress ArgumentTypeCoercion */
return self::fromBrand($functor->map($f, $this));
}

/**
* @template B
*
* @param callable(A): B $f
* @return Identity<B>
*
Expand All @@ -111,21 +105,19 @@ public function map(callable $f): Identity

/**
* @template B
*
* @param Apply<IdentityBrand> $apply
* @param HK1<IdentityBrand, callable(A): B> $f
*
* @return Identity<B>
*
* @psalm-suppress ArgumentTypeCoercion
*/
public function iapply(Apply $apply, HK1 $f): Identity
{
/** @psalm-suppress ArgumentTypeCoercion */
return self::fromBrand($apply->apply($f, $this));
}

/**
* @template B
*
* @param HK1<IdentityBrand, callable(A): B> $f
* @return Identity<B>
*
Expand All @@ -138,10 +130,8 @@ public function apply(HK1 $f): Identity

/**
* @template B
*
* @param Applicative<IdentityBrand> $applicative
* @param B $a
*
* @return Identity<B>
*/
public static function ipure(Applicative $applicative, $a): Identity
Expand All @@ -151,9 +141,7 @@ public static function ipure(Applicative $applicative, $a): Identity

/**
* @template B
*
* @param B $a
*
* @return Identity<B>
*
* @psalm-suppress LessSpecificImplementedReturnType
Expand All @@ -165,23 +153,20 @@ public static function pure($a): Identity

/**
* @template B
*
* @param Monad<IdentityBrand> $monad
* @param callable(A): HK1<IdentityBrand, B> $f
*
* @return Identity<B>
*
* @psalm-suppress ArgumentTypeCoercion
*/
public function ibind(Monad $monad, callable $f): Identity
{
/** @psalm-suppress ArgumentTypeCoercion */
return self::fromBrand($monad->bind($this, $f));
}

/**
* @template B
*
* @param callable(A): HK1<IdentityBrand, B> $f
*
* @return Identity<B>
*
* @psalm-suppress LessSpecificImplementedReturnType
Expand All @@ -193,25 +178,22 @@ public function bind(callable $f): Identity

/**
* @template B
*
* @param Foldable<IdentityBrand> $foldable
* @param callable(A, B): B $f
* @param B $b
*
* @return B
*
* @psalm-suppress ArgumentTypeCoercion
*/
public function ifoldr(Foldable $foldable, callable $f, $b)
{
/** @psalm-suppress ArgumentTypeCoercion */
return $foldable->foldr($f, $b, $this);
}

/**
* @template B
*
* @param callable(A, B): B $f
* @param B $b
*
* @return B
*/
public function foldr(callable $f, $b)
Expand All @@ -222,29 +204,24 @@ public function foldr(callable $f, $b)
/**
* @template F of Brand
* @template B
*
* @param Traversable<IdentityBrand> $traversable
* @param Applicative<F> $applicative
* @param callable(A): HK1<F, B> $f
*
* @return HK1<F, Identity<B>>
*
* @psalm-suppress InvalidArgument
* @psalm-suppress ArgumentTypeCoercion
*/
public function itraverse(Traversable $traversable, Applicative $applicative, callable $f): HK1
{
/**
* @psalm-suppress InvalidArgument
* @psalm-suppress ArgumentTypeCoercion
*/
return $applicative->map([Identity::class, 'fromBrand'], $traversable->traverse($applicative, $f, $this));
}

/**
* @template F of Brand
* @template B
*
* @param Applicative<F> $applicative
* @param callable(A): HK1<F, B> $f
*
* @return HK1<F, Identity<B>>
*
* @psalm-suppress LessSpecificImplementedReturnType
Expand Down
34 changes: 14 additions & 20 deletions src/Instances/Identity/IdentityApplicative.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,52 @@
use Marcosh\LamPHPda\Typeclass\Applicative;

/**
* @psalm-immutable
*
* @implements Applicative<IdentityBrand>
*
* @psalm-immutable
*/
final class IdentityApplicative implements Applicative
{
/**
* @psalm-suppress LessSpecificImplementedReturnType
*
* @psalm-pure
*
* @template A
* @template B
*
* @param callable(A): B $f
* @param HK1<IdentityBrand, A> $a
*
* @return Identity<B>
*
* @psalm-pure
*
* @psalm-suppress LessSpecificImplementedReturnType
*/
public function map(callable $f, $a): Identity
{
return (new IdentityFunctor())->map($f, $a);
}

/**
* @psalm-suppress LessSpecificImplementedReturnType
*
* @psalm-pure
*
* @template A
* @template B
*
* @param HK1<IdentityBrand, callable(A): B> $f
* @param HK1<IdentityBrand, A> $a
*
* @return Identity<B>
*
* @psalm-pure
*
* @psalm-suppress LessSpecificImplementedReturnType
*/
public function apply(HK1 $f, HK1 $a): Identity
{
return (new IdentityApply())->apply($f, $a);
}

/**
* @psalm-suppress LessSpecificImplementedReturnType
*
* @psalm-pure
*
* @template A
*
* @param A $a
*
* @return Identity<A>
*
* @psalm-pure
*
* @psalm-suppress LessSpecificImplementedReturnType
*/
public function pure($a): Identity
{
Expand Down
24 changes: 10 additions & 14 deletions src/Instances/Identity/IdentityApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,38 @@
use Marcosh\LamPHPda\Typeclass\Apply;

/**
* @psalm-immutable
*
* @implements Apply<IdentityBrand>
*
* @psalm-immutable
*/
final class IdentityApply implements Apply
{
/**
* @psalm-suppress LessSpecificImplementedReturnType
*
* @psalm-pure
*
* @template A
* @template B
*
* @param callable(A): B $f
* @param HK1<IdentityBrand, A> $a
*
* @return Identity<B>
*
* @psalm-pure
*
* @psalm-suppress LessSpecificImplementedReturnType
*/
public function map(callable $f, $a): Identity
{
return (new IdentityFunctor())->map($f, $a);
}

/**
* @psalm-suppress LessSpecificImplementedReturnType
*
* @psalm-pure
*
* @template A
* @template B
*
* @param HK1<IdentityBrand, callable(A): B> $f
* @param HK1<IdentityBrand, A> $a
*
* @return Identity<B>
*
* @psalm-pure
*
* @psalm-suppress LessSpecificImplementedReturnType
*/
public function apply(HK1 $f, HK1 $a): Identity
{
Expand Down
6 changes: 2 additions & 4 deletions src/Instances/Identity/IdentityFoldable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
use Marcosh\LamPHPda\Typeclass\Foldable;

/**
* @psalm-immutable
*
* @implements Foldable<IdentityBrand>
*
* @psalm-immutable
*/
final class IdentityFoldable implements Foldable
{
/**
* @template A
* @template B
*
* @param callable(A, B): B $f
* @param B $b
* @param HK1<IdentityBrand, A> $a
*
* @return B
*/
public function foldr(callable $f, $b, HK1 $a)
Expand Down
14 changes: 6 additions & 8 deletions src/Instances/Identity/IdentityFunctor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@
use Marcosh\LamPHPda\Typeclass\Functor;

/**
* @psalm-immutable
*
* @implements Functor<IdentityBrand>
*
* @psalm-immutable
*/
final class IdentityFunctor implements Functor
{
/**
* @psalm-suppress LessSpecificImplementedReturnType
*
* @psalm-pure
*
* @template A
* @template B
*
* @param callable(A): B $f
* @param HK1<IdentityBrand, A> $a
*
* @return Identity<B>
*
* @psalm-pure
*
* @psalm-suppress LessSpecificImplementedReturnType
*/
public function map(callable $f, $a): Identity
{
Expand Down
Loading

0 comments on commit 4e56301

Please sign in to comment.