Giter VIP home page Giter VIP logo

Comments (3)

gusty avatar gusty commented on May 16, 2024 1

Done here: dotnet/fsharp#7384

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

This is a consequence of another issue: type inference fails when liftM is implemented as map.
At the same time that issue is a consequence of an F# issue, since after doing some tests like changing the definition like this:

static member inline Lift (x:'``Monad<'T>``) = 
  if false then ListT (x >>= (result << List.singleton)) else ListT (map List.singleton x)

and then trying to call with the repro code it looks like type inference fails depending on the execution path (switch to true and it compiles fine).

This is clearly an F# bug, compilation shouldn't fail depending on the execution path.

TODO:

  • Find a minimal repro
  • Report it as a bug in the F# compiler project, then reference this issue and close it
  • If no one there is interested in solving it, try to fix it

In the meantime the best compromise is to re-re-introduce liftM this might lead to a slightly less optimised code for those cases where the map operation is more efficient but at least will work which is a minimal requirement.

If more efficient code is required it's always possible to replace the generic code with a more specific implementation, in the repro it will be:

let x = ListT (map List.singleton (State.put initialState))

from fsharpplus.

gusty avatar gusty commented on May 16, 2024

Reopening as this is still an issue

from fsharpplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.