From abdbeb64d47425715938c07f08ab5f00de54dcf3 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 9 Nov 2024 16:48:03 +0100 Subject: [PATCH 1/4] deprecate the State monad --- CHANGELOG.md | 4 ++++ docs/structures/state.md | 3 +++ src/State.php | 1 + 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69f13ce..514b62b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ - Use `static` closures as much as possible to reduce the probability of creating circular references by capturing `$this` as it can lead to memory root buffer exhaustion. - Remove keeping intermediary values of a deferred `Sequence` that is referenced by no one. +### Deprecated + +- `Innmind\Immutable\State` + ### Fixed - Using `string`s or `int`s as a `Map` key type and then adding keys of different types was throwing an error. diff --git a/docs/structures/state.md b/docs/structures/state.md index 5326456..d01cbda 100644 --- a/docs/structures/state.md +++ b/docs/structures/state.md @@ -4,6 +4,9 @@ The `State` monad allows you to build a set of pure steps to compute a new state The state and value can be of any type. +??? warning "Deprecated" + `State` is deprecated and will be removed in the next major release. + ## `::of()` ```php diff --git a/src/State.php b/src/State.php index a91facf..a139b10 100644 --- a/src/State.php +++ b/src/State.php @@ -9,6 +9,7 @@ * @psalm-immutable * @template-covariant S * @template-covariant T + * @deprecated */ final class State { From 2d142e2bf6f87e5d2c6096ffe6a4c5ae29cdeabb Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 9 Nov 2024 16:52:37 +0100 Subject: [PATCH 2/4] deprecate the Fold monad --- CHANGELOG.md | 1 + docs/structures/fold.md | 3 +++ src/Fold.php | 1 + 3 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 514b62b..9d7a85f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Deprecated - `Innmind\Immutable\State` +- `Innmind\Immutable\Fold` ### Fixed diff --git a/docs/structures/fold.md b/docs/structures/fold.md index ef6bb4a..fb310d4 100644 --- a/docs/structures/fold.md +++ b/docs/structures/fold.md @@ -39,6 +39,9 @@ $fold->match( This example will read all lines from the socket until one line contains `quit\n` then the loop will stop and either dump all the lines to the output or `throw new RuntimeException('socket not reachable')`. +??? warning "Deprecated" + `Fold` is deprecated and will be removed in the next major release. + ## `::with()` This named constructor accepts a value with the notion that more elements are necessary to compute a result diff --git a/src/Fold.php b/src/Fold.php index 5e084bd..eaabfe6 100644 --- a/src/Fold.php +++ b/src/Fold.php @@ -15,6 +15,7 @@ * @template R Result * @template C Computation * @psalm-immutable + * @deprecated */ final class Fold { From 16905963d9dac29adb6a1c90cef172672b68423f Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 9 Nov 2024 16:53:23 +0100 Subject: [PATCH 3/4] move deprecations messages to the top for better visibility --- docs/structures/fold.md | 6 +++--- docs/structures/state.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/structures/fold.md b/docs/structures/fold.md index fb310d4..d6b9181 100644 --- a/docs/structures/fold.md +++ b/docs/structures/fold.md @@ -1,5 +1,8 @@ # `Fold` +??? warning "Deprecated" + `Fold` is deprecated and will be removed in the next major release. + The `Fold` monad is intented to work with _(infinite) stream of data_ by folding each element to a single value. This monad distinguishes between the type used to fold and the result type, this allows to inform the _stream_ that it's no longer necessary to extract elements as the folding is done. An example is reading from a socket as it's an infinite stream of strings: @@ -39,9 +42,6 @@ $fold->match( This example will read all lines from the socket until one line contains `quit\n` then the loop will stop and either dump all the lines to the output or `throw new RuntimeException('socket not reachable')`. -??? warning "Deprecated" - `Fold` is deprecated and will be removed in the next major release. - ## `::with()` This named constructor accepts a value with the notion that more elements are necessary to compute a result diff --git a/docs/structures/state.md b/docs/structures/state.md index d01cbda..811fdf5 100644 --- a/docs/structures/state.md +++ b/docs/structures/state.md @@ -1,12 +1,12 @@ # `State` +??? warning "Deprecated" + `State` is deprecated and will be removed in the next major release. + The `State` monad allows you to build a set of pure steps to compute a new state. Since the initial state is given when all the steps are built it means that all steps are lazy, this use function composition (so everything is kept in memory). The state and value can be of any type. -??? warning "Deprecated" - `State` is deprecated and will be removed in the next major release. - ## `::of()` ```php From 044461c49b0093529901a3ab4b701833db4fb78a Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 9 Nov 2024 17:06:25 +0100 Subject: [PATCH 4/4] fix deprecations --- src/Fold/Failure.php | 1 + src/Fold/Implementation.php | 1 + src/Fold/Result.php | 1 + src/Fold/With.php | 1 + src/State.php | 1 + src/State/Result.php | 1 + 6 files changed, 6 insertions(+) diff --git a/src/Fold/Failure.php b/src/Fold/Failure.php index d040665..991640a 100644 --- a/src/Fold/Failure.php +++ b/src/Fold/Failure.php @@ -16,6 +16,7 @@ * @implements Implementation * @psalm-immutable * @internal + * @psalm-suppress DeprecatedClass */ final class Failure implements Implementation { diff --git a/src/Fold/Implementation.php b/src/Fold/Implementation.php index 80e0d56..a56f260 100644 --- a/src/Fold/Implementation.php +++ b/src/Fold/Implementation.php @@ -15,6 +15,7 @@ * @template C Computation * @psalm-immutable * @internal + * @psalm-suppress DeprecatedClass */ interface Implementation { diff --git a/src/Fold/Result.php b/src/Fold/Result.php index 864f9bf..971bc7f 100644 --- a/src/Fold/Result.php +++ b/src/Fold/Result.php @@ -16,6 +16,7 @@ * @implements Implementation * @psalm-immutable * @internal + * @psalm-suppress DeprecatedClass */ final class Result implements Implementation { diff --git a/src/Fold/With.php b/src/Fold/With.php index f98f3d3..f84c770 100644 --- a/src/Fold/With.php +++ b/src/Fold/With.php @@ -16,6 +16,7 @@ * @implements Implementation * @psalm-immutable * @internal + * @psalm-suppress DeprecatedClass */ final class With implements Implementation { diff --git a/src/State.php b/src/State.php index a139b10..bc5a51f 100644 --- a/src/State.php +++ b/src/State.php @@ -10,6 +10,7 @@ * @template-covariant S * @template-covariant T * @deprecated + * @psalm-suppress DeprecatedClass */ final class State { diff --git a/src/State/Result.php b/src/State/Result.php index b085fdb..7162995 100644 --- a/src/State/Result.php +++ b/src/State/Result.php @@ -7,6 +7,7 @@ * @psalm-immutable * @template S * @template T + * @deprecated */ final class Result {