ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
391 stars 151 forks source link

Convert Result string Error Handling to Option Where Applicable #1199

Closed 1eyewonder closed 7 months ago

1eyewonder commented 7 months ago

WHAT

🤖 Generated by Copilot at da3703a

This pull request refactors the error handling logic in various modules of the FsAutoComplete project to use option types instead of result types and strings for errors. It also adds a new dependency to the FsToolkit.ErrorHandling library, which provides some utilities for functional error handling in F#. The main goal of this refactoring is to simplify the code and make it more consistent and expressive. The affected modules include Commands, CodeFixes, AdaptiveFSharpLspServer, and AdaptiveState. The affected files include src/FsAutoComplete.Core/Commands.fs, src/FsAutoComplete/CodeFixes.fs, src/FsAutoComplete/CodeFixes.fsi, src/FsAutoComplete/CodeFixes/RemoveUnusedOpens.fs, src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs, src/FsAutoComplete/LspServers/AdaptiveServerState.fs, src/FsAutoComplete/LspServers/AdaptiveServerState.fsi, paket.dependencies, src/FsAutoComplete.Core/paket.references, src/FsAutoComplete/CodeFixes/AddPrivateAccessModifier.fs, src/FsAutoComplete/CodeFixes/AddPrivateAccessModifier.fsi, and src/FsAutoComplete/LspServers/Common.fs.

🤖 Generated by Copilot at da3703a

We're sailing on the F# sea, with option types for free We've left behind the result strings, they only caused us trouble So heave away, me hearties, heave away with glee We're using FsToolkit.ErrorHandling, that's the library

📦🛠️🚀

WHY

HOW

🤖 Generated by Copilot at da3703a

1eyewonder commented 7 months ago

Closing because I realized I didn't pay attention towards the end of the Amplifying FSharp video. https://github.com/fsharp/FsAutoComplete/pull/1195 already tackles the main function I was refactoring but uses Result instead of Option. For my sanity I am going to close this PR and open a new one with different snippets I found during mind findings in this PR.