Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Problem with Applicative CEs and 'Zero' #10379

Closed

Description

@gusty

Repro steps

This script works fine, but when we uncomment the BindReturn member it fails because it seems it doesn't use the Zero method.

type Builder () =
    member        __.ReturnFrom (expr) = expr                                  : seq<'T>
    member inline __.Return (x: 'T) = Seq.singleton x                          : seq<'T>
    member inline __.Yield  (x: 'T) = Seq.singleton x                          : seq<'T>
    member inline __.Bind (p: seq<'T>, rest: 'T->seq<'U>) = Seq.collect rest p : seq<'U>

    member inline __.Delay (expr: _->seq<'T>) = Seq.delay expr : seq<'T>
    member        __.Run f = f : seq<'T>

    member inline __.Zero () = Seq.empty : seq<'T>

    // member inline __.BindReturn   (x : seq<'T>, f: 'T -> 'U) : seq<'U> = Seq.map f x

let seqbuilder= new Builder ()

let _pythags = seqbuilder {
  let! z = seq [1..50]
  let! x = seq [1..z]
  let! y = seq [x..z]
  if (x*x + y*y = z*z) then return (x, y, z) }

Expected behavior

Compile fine with the BindReturn member

Actual behavior

Doesn't compile with the BindReturn member

Known workarounds

Add an else branch. but still looks like a regression.

Related information

F# 5.0

Activity

  1. dsyme commented on Dec 1, 2020

    @dsyme
    Contributor

    Yes, this code (with the BindReturn uncommented) compiles with --langversion:4.7 but not --langversion:5.0

  2. self-assigned this
    on Dec 1, 2020
  3. added
    Impact-High
    on Dec 1, 2020
  4. changed the title [-]Possible regression with Applicative CEs[/-] [+]Regression with Applicative CEs and 'Zero'[/+] on Dec 1, 2020
  5. added this to the Backlog milestone on Dec 1, 2020
  6. dsyme commented on Dec 11, 2020

    @dsyme
    Contributor

    @cartermp I guess this isn't totally a regression (or at least not such a severe one), since we don't really expect BindReturn methods to be present unless people are using 5.0. So it's more a bug in the applicatives feature.

    I'll fix it now neverthelss but change the priority

  7. added
    Impact-Medium
    and removed
    Impact-High
    on Dec 11, 2020
  8. gusty commented on Dec 11, 2020

    @gusty
    ContributorAuthor

    @dsyme It's true that it's not 100% a regression, but it hit us. In F#+ we started using it, and it worked fine.

    But suddenly, our CIs upgraded to F# 5 and some tests started failing, then we realized that by shipping this optimization we included a breaking change. So we did an emergency release to take it out for the moment.

  9. gusty commented on Jun 4, 2021

    @gusty
    ContributorAuthor

    @dsyme @cartermp Any update on this ?
    F# 5 is a thing now.

  10. modified the milestones: Backlog, 17.0 on Jun 6, 2021
  11. 4 remaining items

  12. changed the title [-]Regression with Applicative CEs and 'Zero'[/-] [+]Problem with Applicative CEs and 'Zero'[/+] on Mar 4, 2022
  13. added
    Area-ComputationExpressions
    and removed on Apr 4, 2022
  14. gusty commented on Sep 6, 2022

    @gusty
    ContributorAuthor

    @dsyme just curious why did you remove the Regression label?

    As per your comments above

    Yes, this code (with the BindReturn uncommented) compiles with --langversion:4.7 but not --langversion:5.0

    Is there any chance this will be fixed anytime soon ? 🤔

  15. T-Gro commented on Dec 29, 2022

    @T-Gro
    Member

    @dsyme just curious why did you remove the Regression label?

    As per your comments above

    Yes, this code (with the BindReturn uncommented) compiles with --langversion:4.7 but not --langversion:5.0

    Is there any chance this will be fixed anytime soon ? 🤔

    I will check what is needed for a fix.
    I might get stuck, so cannot give a promise yet.

  16. assigned and unassigned on Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-ComputationExpressionsBugImpact-Medium

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions