Skip to content

Curried Applicative issue #1072

Closed
Closed

Description

@irium

Description

This happened again :) As I can see that biggest pain in Fable is dealing with F# curried functions and Javascript. I've found one more issue with it, tests included : #1071

I've found workaround, but want to know is it neccessary, and if so - how to automate if somehow (having one single curry function to call. Maybe it'd be better to write in JS?)

Related information

  • Fable version (dotnet fable --version): Strangely I have clitool dotnet-fable 1.1.11, but dotnet fable --version returns 1.1.10. Nevertheless tests included are failing with latest Fable's sources.
  • Operating system:
    Windows 10 - x64

Activity

  1. alfonsogarciacaro commented on Jul 16, 2017

    @alfonsogarciacaro
    Member

    You're right, @irium. I'm always hoping we've covered all the issues with curried application, but it seems new cases always pop out from time to time... Sometimes I wonder if the uncurrying optimization was a good idea after all 😕

    The safest solution would be to make all lambdas dynamically curried but I'm not sure what would be the performance impact of this. Anyways, I'll try to fix this and let's pray the next case takes much longer to appear 😉 Thanks a lot for the tests! This is always the hardest part.

  2. alfonsogarciacaro commented on Jul 17, 2017

    @alfonsogarciacaro
    Member

    Ok, so the ad-hoc currying was working... but not for option function types, so I just added an extra check. Hopefully it should be fine now. I will publish the fix right away as version 1.1.12.

    BTW, about the version, there was an issue with the dependencies for 1.1.10 so I republished again manually and forgot to update the version literal (that's a task for the build script) 😅

  3. added a commit that references this issue on Jul 17, 2017
    fca926d
  4. irium commented on Jul 17, 2017

    @irium
    ContributorAuthor

    Thanks a lot! For now I've workarounded it by included in my sort of Prelude file the manual currying function and using it where appropriate.

    I agree that total auto-currying maybe not the best solution for all, so maybe just to expose mentioned to Fable.JS.Interop so everybody could use it to make curried functions? Such universal function is impossible to write in pure Fable F#.

  5. alfonsogarciacaro commented on Jul 17, 2017

    @alfonsogarciacaro
    Member

    Hmm, users shouldn't need to convert lambdas into dynamically curried functions by themselves (or even know that such a wrapper exists) Fable should do it automatically when needed. But it's true that maybe the only way to workaround an issue until a proper fix comes to Fable.

    Maybe the best solution is to add an importFromFableCore function as I've thinking so advanced users can import functions directly from fable-core JS files (assuming the risks those functions can change in future versions).

  6. irium commented on Jul 21, 2017

    @irium
    ContributorAuthor

    I saw code of your fix and it looks smart enough to be automatic in processing f option.

    But Option is just one of many monads. For example - Promise<'a> from Fable.PowerPack ;)
    Or async from FSharp itself. Someday somebody will get it, and the story will continue... :)

  7. alfonsogarciacaro commented on Jul 21, 2017

    @alfonsogarciacaro
    Member

    Good point! The main difference with of Option with other monads is options are erased in Fable, that's why we need to deal with functions and function options in the same way. For Promise and other monads the add-hoc currying should happen when the function is actually unwrapped.

    However, if you've time, it'd be very nice if you could PR a test for other monad types to check that this is actually working 👍

  8. irium commented on Jul 21, 2017

    @irium
    ContributorAuthor

    Good point too about special meaning of Option monad.
    As for writing more tests - I'll do, but somewhat later, when there will be time for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions