FSharpPlus
FSharpPlus copied to clipboard
Revert "-BindReturn"
This reverts commit 78d883574ef40233605f1c178dd5efd5efaba80e.
The problem with reverting the commit is that some of the functionality breaks. See the #if APPLICATIVE_FIX sections.
This should be fine to merge once the F# issue:
https://github.com/dotnet/fsharp/issues/10379
Is fixed
Seems like there are still issues with compiling the code even after https://github.com/dotnet/fsharp/issues/10379
Although the F# compiler issue mentioned in the initial description was solved it seems there was another regression in 5.0 and the following script breaks:
#r "nuget: FSharpPlus"
open FSharpPlus
open FSharpPlus.Data
type DeriverBuilder<'``monad<'t>``> () =
inherit MonadFxBuilder<'``monad<'t>``> ()
member inline _.BindReturn (x : '``Monad<'T>``, f: 'T -> 'U) : '``Monad<'U>`` = FSharpPlus.Control.Map.Invoke f x
let monad<'``monad<'t>``> = new DeriverBuilder<'``monad<'t>``> ()
let lst1: StateT<string,_> = StateT.lift [1;2]
let lst2: StateT<string,_> = StateT.lift [4;5]
let m = monad {
let! x = lst1
let! y = lst2
do! modify String.toUpper
let! st = gets String.length
return (x, y + st) }
This works in 4.7 but as from 5.0 it throws:
apcrvfcj..fsx(21,5): error FS0071: Type constraint mismatch when applying the default type 'obj' for a type inference variable. No overloads match for method 'Return'.
Known return type: (int -> obj)
Known type parameters: < obj , Control.Return >
Available overloads:
- static member Control.Return.Return: 'a array * Control.Return -> ('a -> 'a array) // Argument at index 1 doesn't match
- static member Control.Return.Return: 'a list * Control.Return -> ('a -> 'a list) // Argument at index 1 doesn't match
- static member Control.Return.Return: 'a option * Control.Return -> ('a -> 'a option) // Argument at index 1 doesn't match
- static member Control.Return.Return: 'a seq * Internals.Default2 -> ('a -> 'a seq) // Argument at index 1 doesn't match
- static member Control.Return.Return: 'a voption * Control.Return -> ('a -> 'a voption) // Argument at index 1 doesn't match
- static member Control.Return.Return: ('r -> 'a) * Control.Return -> ('a -> 'r -> 'a) // Argument at index 1 doesn't match
- static member Control.Return.Return: (^m * 'a) * Control.Return -> ('a -> ^m * 'a) when (Control.Zero or ^m) : (static member Zero: ^m * Control.Zero -> ^m) // Argument at index 1 doesn't match
- static member Control.Return.Return: Async<'a> * Control.Return -> ('a -> Async<'a>) // Argument at index 1 doesn't match
- static member Control.Return.Return: Choice<'a,'e> * Control.Return -> ('a -> Choice<'a,'e>) // Argument at index 1 doesn't match
- static member Control.Return.Return: Internals.Set2<'a> * Control.Return -> ('a -> Internals.Set2<'a>) when 'a: comparison // Argument at index 1 doesn't match
- static member Control.Return.Return: NonEmptySeq<'a> * Internals.Default2 -> ('a -> NonEmptySeq<'a>) // Argument at index 1 doesn't match
- static member Control.Return.Return: Quotations.Expr<'a> * Control.Return -> ('a -> Quotations.Expr<'a>) // Argument at index 1 doesn't match
- static member Control.Return.Return: ResizeArray<'a> * Control.Return -> ('a -> ResizeArray<'a>) // Argument at index 1 doesn't match
- static member Control.Return.Return: Result<'a,'e> * Control.Return -> ('a -> Result<'a,'e>) // Argument at index 1 doesn't match
- static member Control.Return.Return: Set<'a> * Control.Return -> ('a -> Set<'a>) when 'a: comparison // Argument at index 1 doesn't match
- static member Control.Return.Return: System.Collections.Generic.IEnumerator<'a> * Internals.Default2 -> ('a -> System.Collections.Generic.IEnumerator<'a>) // Argument at index 1 doesn't match
- static member Control.Return.Return: System.Lazy<'a> * Control.Return -> ('a -> System.Lazy<'a>) // Argument at index 1 doesn't match
- static member Control.Return.Return: System.Text.StringBuilder * Control.Return -> (char -> System.Text.StringBuilder) // Argument at index 1 doesn't match
- static member Control.Return.Return: System.Threading.Tasks.Task<'T> * Control.Return -> ('T -> System.Threading.Tasks.Task<'T>) // Argument at index 1 doesn't match
- static member Control.Return.Return: System.Threading.Tasks.ValueTask<'T> * Control.Return -> ('T -> System.Threading.Tasks.ValueTask<'T>) // Argument at index 1 doesn't match
- static member Control.Return.Return: ^R * Internals.Default1 -> ('T -> ^R) when ^R: (static member Return: 'T -> ^R) // Argument at index 1 doesn't match
- static member Control.Return.Return: string * Control.Return -> (char -> string) // Argument at index 1 doesn't match
- static member Control.Return.Return: struct (^m * 'a) * Control.Return -> ('a -> struct (^m * 'a)) when (Control.Zero or ^m) : (static member Zero: ^m * Control.Zero -> ^m) // Argument at index 1 doesn't match Consider adding further type constraints
So, a minimal repro should be made in order to report this other regression that happened apparently also at 5.0