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 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>``> diff --git a/src/FSharpPlus/Extensions/Result.fs b/src/FSharpPlus/Extensions/Result.fs index 2707462c0..d9d20f5a0 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> 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 diff --git a/src/FSharpPlus/Operators.fs b/src/FSharpPlus/Operators.fs index da88ba3ad..314bdf2a0 100644 --- a/src/FSharpPlus/Operators.fs +++ b/src/FSharpPlus/Operators.fs @@ -207,9 +207,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