From 4b97aae1a2305fc02e5f6617bd16f1ff89b5a83a Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sun, 5 Feb 2023 09:32:26 +0100 Subject: [PATCH 1/5] Add >>= and >=> for Reader --- src/FSharpPlus/Data/Reader.fs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/FSharpPlus/Data/Reader.fs b/src/FSharpPlus/Data/Reader.fs index a95a2c4be..104367ff7 100644 --- a/src/FSharpPlus/Data/Reader.fs +++ b/src/FSharpPlus/Data/Reader.fs @@ -155,8 +155,18 @@ type ReaderT<'r,'``monad<'t>``> with /// Applicative static member inline (<* ) (x: ReaderT<'R, '``Monad<'U>``>, y: ReaderT<'R, '``Monad<'T>``>) : ReaderT<'R, '``Monad<'U>``> = ((fun (k: 'U) (_: 'T) -> k ) x : ReaderT<'R, '``Monad<'T->'U>``>) y + /// + /// Takes a Reader value and a function from a plain type to a Reader value, and returns a new Reader value. + /// + /// Monad static member inline (>>=) (x: ReaderT<_,'``Monad<'T>``>, f: 'T->ReaderT<'R,'``Monad<'U>``>) = ReaderT.bind f x : ReaderT<'R, '``Monad<'U>``> - + + /// + /// Composes left-to-right two Reader functions (Kleisli composition). + /// + /// Monad + static member inline (>=>) (f: 'T -> ReaderT<_,'``Monad<'U>``>, g: 'U -> ReaderT<'R,'``Monad<'V>``>) : 'T -> ReaderT<'R,'``Monad<'V>``> = fun x -> ReaderT.bind g (f x) + static member inline get_Empty () = ReaderT (fun _ -> getEmpty ()) : ReaderT<'R, '``MonadPlus<'T>``> static member inline (<|>) (ReaderT m, ReaderT n) = ReaderT (fun r -> m r <|> n r) : ReaderT<'R, '``MonadPlus<'T>``> From 26d5a2fba7ce8edaa393eec8a5685457c48a8220 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sun, 5 Feb 2023 09:33:50 +0100 Subject: [PATCH 2/5] Add note --- src/FSharpPlus/Extensions/Result.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FSharpPlus/Extensions/Result.fs b/src/FSharpPlus/Extensions/Result.fs index ad4f8b51c..85075d5a3 100644 --- a/src/FSharpPlus/Extensions/Result.fs +++ b/src/FSharpPlus/Extensions/Result.fs @@ -78,6 +78,7 @@ module Result = /// flatten is equivalent to bind id. let flatten source : Result<'T,'Error> = match source with Ok (Ok v) -> Ok v | Ok (Error e) | Error e -> Error e + // Note: To be fixed in F#+ 2. Arguments should be flipped in order to match the generic catch. [] let inline catch f = function Ok v -> Ok v | Error e -> (f: 't->_) e : Result<'v,'e> From 594327ab6689203d030774308ef0a6b726241919 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sun, 5 Feb 2023 09:34:31 +0100 Subject: [PATCH 3/5] + ValueOption.toOption --- src/FSharpPlus/Extensions/ValueOption.fs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/FSharpPlus/Extensions/ValueOption.fs b/src/FSharpPlus/Extensions/ValueOption.fs index 83dac16b0..3a5ef1c93 100644 --- a/src/FSharpPlus/Extensions/ValueOption.fs +++ b/src/FSharpPlus/Extensions/ValueOption.fs @@ -70,3 +70,8 @@ module ValueOption = match pair with | true, x -> ValueSome x | false, _ -> ValueNone + + let toOption x = + match x with + | ValueSome x -> Some x + | ValueNone -> None From a2b5e772f274ae4d7436499b97a06498f8c8f1c3 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sun, 5 Feb 2023 09:36:04 +0100 Subject: [PATCH 4/5] Deprecate <**> --- src/FSharpPlus/Operators.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/FSharpPlus/Operators.fs b/src/FSharpPlus/Operators.fs index d5ca08edb..b76ec9d42 100644 --- a/src/FSharpPlus/Operators.fs +++ b/src/FSharpPlus/Operators.fs @@ -206,9 +206,7 @@ module Operators = /// Applicative let inline (<* ) (x: '``Applicative<'U>``) (y: '``Applicative<'T>``) : '``Applicative<'U>`` = ((fun (k: 'U) (_: 'T) -> k ) x : '``Applicative<'T->'U>``) <*> y - /// - /// Apply a lifted argument to a lifted function (flipped): arg <**> f - /// + [) instead.")>] /// Applicative let inline (<**>) (x: '``Applicative<'T>``) : '``Applicative<'T -> 'U>``->'``Applicative<'U>`` = flip (<*>) x From 50dbb7b079cc048868d977297212c72931146097 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sun, 5 Feb 2023 09:41:56 +0100 Subject: [PATCH 5/5] Update release notes for 1.3.3 --- RELEASE_NOTES.md | 5 ++++- RELEASE_NOTES.txt | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 02bb6fff6..1b1b569fb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,8 @@ -#### 1.3.3 - February 4 2023 +#### 1.3.3 - February 5 2023 - Fix missing zero overload for voption + - Add (>>=) and (>=>) to ReaderT + - Add ValueOption.toOption + - Deprecate (<**>) #### 1.3.2 - December 2 2022 - Applicative Computation Expressions diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 6586388a8..29b23f3f8 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,4 +1,7 @@ -Release Notes for FSharpPlus 1.3.3 - February 4 2023 +Release Notes for FSharpPlus 1.3.3 - February 5 2023 ----------------------------------------------------- -Fix missing zero overload for voption \ No newline at end of file +Fix missing zero overload for voption +Add (>>=) and (>=>) to ReaderT +Add ValueOption.toOption +Deprecate (<**>) \ No newline at end of file