Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "-BindReturn" #428

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

wallymathieu
Copy link
Member

@wallymathieu wallymathieu commented Feb 23, 2021

This reverts commit 78d8835.

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:

dotnet/fsharp#10379

Is fixed

@wallymathieu
Copy link
Member Author

Seems like there are still issues with compiling the code even after
dotnet/fsharp#10379

@gusty gusty force-pushed the master branch 6 times, most recently from 9b34ece to b2f3c8c Compare October 15, 2023 05:01
@gusty
Copy link
Member

gusty commented Dec 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants