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

Nxui + F# #21

Closed
AngelMunoz opened this issue May 29, 2023 · 6 comments
Closed

Nxui + F# #21

AngelMunoz opened this issue May 29, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@AngelMunoz
Copy link
Contributor

Hey there!

I managed to try out NXUI with F# and I think it may be a really good choice for F# devs, there are some aspects that are not so F#'ish which I think it is definitely expected and I personally don't mind.

I have a code sample here in case you want to check it out by yourself

https://github.com/AngelMunoz/NxuiFsharp

This is general feedback in my little tinkering and PoC I plan to actually use it further just to have a better feel

Overall I think it feels good, the ease of interop with observables is just lovely I'm going to dive deep with that I'm sure, it is quite simple to start composing the UIs here and I think it also lends itself to "UI widgets as functions" e.g. just have a function that calls the builders you need for that section of the screen and voila! you have something working cool and nice ready to work with.

One thing that is not so F#'ish is the use of out vars F# doesn't have that handy syntax to declare the out var and have it available at that point, so if you have to use those you need to create the mutable variable in advance e.g.

let mutable window = null

Window(&window)

Now, personally this is not a killer for me, I can live with it as F# tends to be quite explicit when you're doing mutable stuff like this and enforces rules to avoid doing the wrong thing (e.g. inref<'T>, outref<'T>, byref<'T>) but it can be something someone would point at as not "F#'ish enough"

That being said, one can also do

let window = Window()

window.content(TextBox.text(window.BindTitle())

So as I said, nothing to worry about, I guess with some guidance it can be avoided

The only main issue with NXUI as is to work smoothly with F# out of the box is the following

The suggestion is approved in principle and it should eventually get fixed if someone picks it up, in the meantime I don't know if the generator project can be adapted to produce an "FSharp" namespace with camelCased extensions or if we need to modify to generate a different assembly and publish that separately.

In any case I can take a look and attempt to do it if we agree to something

From there on I think I need to keep experimenting more to have a better feel but even with the type extensions thing

I really like this piece of work, kudos to you!

@wieslawsoltes wieslawsoltes added the enhancement New feature or request label May 29, 2023
@wieslawsoltes
Copy link
Owner

wieslawsoltes commented May 29, 2023

The suggestion is approved in principle and it should eventually get fixed if someone picks it up, in the meantime I don't know if the generator project can be adapted to produce an "FSharp" namespace with camelCased extensions or if we need to modify to generate a different assembly and publish that separately.

I think we can add some options to generator to create namespace with camelCased extensions for FSharp and create separate nuget.

@AngelMunoz
Copy link
Contributor Author

I also wonder does F# support implicit usings like C# ? https://github.com/AngelMunoz/NxuiFsharp/blob/3ae45981fa36669077c8772198f2004a2c4b82db/src/NxuiFSharp/Counter.fs#L4-L5

F# does not support implicit usings (due to shadowing behavior), there is one suggestion in the suggestions repo but nothing concrete and usable today.

@AngelMunoz
Copy link
Contributor Author

I think we should be able to close this for the moment I'll ping back if something else comes by
thank you!

@wieslawsoltes
Copy link
Owner

I think we should be able to close this for the moment I'll ping back if something else comes by thank you!

Ok

@smoothdeveloper
Copy link

@AngelMunoz future updates of dotnet SDK are likely to have the feature to resolve the extension methods (with --langversion:preview until next major release) as the feature got merged (dotnet/fsharp#16032).

Please consider if it would be worth preparing the ground the guidance provided to users of this repository, there are several strategies that could be discussed.

What would be most helpful to the compiler IMO would be to have the current generator issue an F# library that is compiled using the preview compiler, that would directly call in the extension methods, and have the methods decorated with obsolete attribute inviting NXUI users to use --langversion:preview / <LangVersion>preview</LangVersion> and use the originally intended cased extension methods.

We may wait for the tooling to consume a version of FCS that has the feature in it, just so the autocomplete shows both property and extension method.

Defining the migration steps in the documentation would also be necessary for this to be smooth to everyone.

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

No branches or pull requests

3 participants