-
Notifications
You must be signed in to change notification settings - Fork 50
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
[Feature] Introduce a task-based API and remove Result<'T, 'E> API friction #75
Comments
Is there a reason you don't want Or you could still explicitly namespace them (eg. Just as an aside, the likes of https://github.com/demystifyfp/FsToolkit.ErrorHandling has a separate package explicitly for |
I now had to work around So I absolutely welcome this initiative! If you introduce multiple namespaces or just add additional functions to the existing namespaces is a matter of taste. Maybe following @absolutejam's suggestion would provide better long-term maintainability, as those functions would live side-by-side and not in different files/modules. |
@absolutejam It is purely subjective on my end, there just aren't good names for these variants IMO! I think if you know which namespace you need, that you will forget about it in a minute or two to get going. Keeping the same functions also means that the analyzer will support the different namespaces without any code changes there so that is a big plus for me (and for the people who are actually using it) 😄 I have checked out FsToolkit.ErrorHandling and I think it overcomplicates things a bit, that's why I suggested to start off with one package, open the namespace you want and get things done. I am thinking this proposition has the least mental overhead but just like my initial API proposition, I might be wrong on that one too (which is I opened an issue to discuss) @aspnetde Thanks for the feedback! After looking at lots of Saturn code, I realized how much better the API would be when all the friction is removed 💯 Another reason why I opened this issue is hoping that someone would pick it up 😁 I would really really appreciate it, especially since it is a lot of copy-paste and writing tests for the different variants. Please let me know if you want to take a stab at it 🙏 🙇 |
Hehe. Yeah, I absolutely would like to look into it – if I wasn't running at 120% load at the moment. So I could give it a try, but I cannot say when that would be :-/. |
Yeah no worries, I am in the same boat. I will just leave it here for now for a while, it is not an urgent fix anyways 😄 |
Since it sounds pretty likely that F# vNext is going to get native Task/ValueTask support, does that change anything public facing or just the implementation (could potentially not use Ply when running under that version) ? |
What I see as the biggest - theoretical - downside to reusing the same fully qualified module name across packages is once some downstream package takes a dependency on one of the options you can't use another one in your app without running into type name ambiguities. F# doesn't have any |
I also like the idea with different namespaces, already seen it in other projects like SchlenkR.FsHttp as an example. By the way. NpgSql has a new major version. It still works, but I've seen some |
@ericsampson It doesn't change the public facing API, only the implementation and we can all migrate after F# supports tasks natively.
@NinoFloris I don't I'll encounter this issue because the idea is to keep one package and different namespaces
@vilinski Thanks for letting me know, then we can also bump up Npgsql dependency version with the feature 😄 |
Ah I read |
The main reason it's a different package entirely is because we support Fable and having |
As of v3.12 the library has implemented the namespace @vilinski Latest has now updated Npgsql to v5.0 and all existing tests worked without changes 😄 |
That's great news! I will give it a try as soon as possible. |
@Zaid-Ajaj tried out, refactored my small program to Tasks, works great! |
Today I finally found the two hours of time to make the switch to |
This is an attempt to tackle #64 right now, the functions
Sql.execute
,Sql.executeRow
,Sql.executeNonQuery
etc. return data in the form ofAsync<Result<'SomeType, exn>>
This is fine in many cases but it can cause friction when:
Result
and instead choose totry ... catch
the SQL code only on rare occasionstask
(for example in Saturn/Giraffe) and don't want the syntax and performance overhead of converting betweenasync
andtask
I propose to fix the problems above by introducing mutually exclusive namespaces within this same nuget package that offers different return types BUT with the exact API of the
Sql
functions:Npgsql.FSharp
stays the same and continue to returnAsync<Result<'T, exn>>
(package stays backward-compatible without breaking changes)Npgsql.FSharp.NoResult
exposes API functions that returnAsync<'T>
Npgsql.FSharp.Tasks
exposes API functions that returnTask<'T>
with the help of PlyYes, the downside is of course the duplication of code in each namespace but I think it is worth the effort of removing as much overhead as possible and of course we can extract the common parts in a module (the
RowReader
for example).What do you think @aspnetde @TheAngryByrd @baronfel @NinoFloris
The text was updated successfully, but these errors were encountered: