gusty / FsControl

[ARCHIVED] FsControl in now included in FSharpPlus https://fsprojects.github.io/FSharpPlus
Apache License 2.0
105 stars 16 forks source link

Merge FsControl into F#+ #71

Closed gusty closed 7 years ago

gusty commented 7 years ago

Many people wonder why FsControl and F#+ are 2 separate projects.

FsControl is basically an overload repository organized into 'Invokable Types' and F#+ are F# Extensions, not necessarily related to overloads.

However, F#+ could include the overloads as part of the extensions it offers.

The problem was that before it was intended to facilitate integration between 'monadic' projects that don't want to depend on F#+ but remain compatible. Then these projects only needed to depend on FsControl.

But now, with the so called 'friendly signatures' there's no need to depend on any project at all. The only thing a 'monadic' library should do in order to be able to integrate with generic operators is to add a static method with the right signature, which will not contain any class from FsControl. Before they needed to contain a dummy parameter from FsControl within the Invokable.

Advantages of Merging both projects

Open questions:

mausch commented 7 years ago

Hi, I haven't been following the project too closely lately, could you quickly illustrate the 'friendly signatures' with a link to an example? Thanks!

gusty commented 7 years ago

Hi @mausch and welcome back !

What I called friendly signatures were implemented a while ago as an alternative convention for external classes that want to implement an instance of an Invokable.

For example, Functors were expected to have this signature:

static member Map (x: TypeX<_>, f, impl:Map) = <implementation>

where impl is a dummy parameter of type Map which is defined in FsControl. That is exactly the signature used for primitive types.

But now, you can use a better (friendly) signature for externals, for functors it's simply:

static member Map (x: TypeX<_>, f) = <implementation>

This started as an experimental alternative, but in the end it worked fine and actually it allowed me to decouple the Monad Transformers and move them to F#+.

It worked so well that I started adding the overload for the friendly signature everywhere and I also include them in the readme.

The only downside was that the compile time increased even more, but that will not be a problem with F# 4.1.

Apart from the nicer signature the other great benefit is that you don't need to ship FsControl with your monadic project, it will fully integrate with the generic map through duck typing.

There is a unit test where it integrates automatically with Math.NET. If you have a look, generic functions like signum' work on types from Math.NET like BigRational because they have the right signature.

I should call the friendly signature the 'external signature' instead.

So, for instance if you want to be able to use a monad from FSharpX you just have to add in that project a Bind and Return static methods with the right signature. Then everything will work, even applicatives and functors by using the default instances.

mausch commented 7 years ago

Brilliant. Seems relevant for https://github.com/mausch/Fleece/issues/15 . I can't comment much on the tradeoffs for merging FsControl and FSharpPlus, but I can see that it would make maintenance easier and that IMHO is already a huge benefit.

gusty commented 7 years ago

Yes, everytime something is changed in FsControl needs to be re-synchronized with FSharpPlus since it uses all the operators. Not to count duplicating of documentation, testing and deployment.

BTW, I did a PR for Fleece a while ago which makes uses of this technique to avoid having a dummy parameter in the FromJson method. I wonder if you had a look at that. I'm also wanting to add 'real' JSON lenses somewhere and was thinking of doing it in Fleece rather that in F#+.

quant1729 commented 7 years ago

I think merging is a really good idea. 'friendly signatures' is a game changing feature.

gusty commented 7 years ago

Thanks @quant1729 I will try to close as much issues as possible before merging and then migrate the remaining issues with the project.

Offtopic: I see in your profile that you are in Zürich. Where are you working there? I used to go to the Zurich F# User Group talks from Meetup, organized by Mark. Have you been there? From time to time I think it might be interesting to organize a meetup there to present this library and some related work.

quant1729 commented 7 years ago

Hey, yes - I have heard about this group, but never attended any of its meetups. I agree it would be interesting to have such a meeting one day.

gusty commented 7 years ago

Closing the issue. ... and closing the project ;)

Thanks for your feedback. I'm convinced it will be better now that is integrated into FSharpPlus.

ghost commented 7 years ago

Great news. Thank you! BTW F#+ build is red.

gusty commented 7 years ago

Thanks for pointing it. I messed in the last commit but now it's ok.