Skip to content

Conversation

fdornak
Copy link
Contributor

@fdornak fdornak commented Feb 8, 2025

My first PR here 😉

Created a new submodule Validation.Result which uses Result type instead of Choice and marked Validation as obsolete.

Any suggestions are welcome

Resolves #428

@gdziadkiewicz
Copy link
Collaborator

Thanks for contributing! I skimmed through it and it looks OK. I will enable the CI run now and do a detailed check this week.

namespace FSharpx

[<System.Obsolete("This module is deprecated. Use Validation.Result instead.")>]
module Validation =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: During review check if the obsolete warning works as expected (bugs old code users and leaves new code users alone).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked, works as expected.

@gdziadkiewicz
Copy link
Collaborator

@fdornak The build failed due to usage of the obsolete code in csharpcompat. Can you check if it is possible to optout from this warning in those parts?

Replace Validation active pattern usage in ChoiceTests
@fdornak
Copy link
Contributor Author

fdornak commented Feb 9, 2025

I have added #nowarn pragmas which should fix the build. However it seems that they have file-wide effect and I haven't found a way around it. I found quite recent PR which might add scoped pragmas feature in the future dotnet/fsharp#18049

actions |> Choice.foldM folder startingPosition

match finalPosition with
| Validation.Success (x,y) ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to stop using the active pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to stop using the active pattern?

Currently the active pattern is in old "Choice" Validation module and this place is the only one in ChoiceTests that uses Validation module. My reasoning was that instead of marking #nowarn the whole ChoiceTests file it can be replaced with Choice1Of2 and avoid the dependency altogether.

I am ok with either approach. We could also move the active pattern in Choice module, which personally I like the most and then It would make more sense to use in ChoiceTests.

Let me know what you think

@gdziadkiewicz
Copy link
Collaborator

gdziadkiewicz commented Feb 11, 2025

Hi Filip, I went through the code and noticed that if you use Result.returnM instead of a direct call to Ok, the code will be the same as the old one (the only function that is different is apa). Theoretically, it should be possible to parametrise the code with it and avoid code duplication, but given that we will remove the old code at some point, it is not justified.
image

Bear with me a moment longer while I do the check from the note :)

Edit: There is also the map call.

@gdziadkiewicz
Copy link
Collaborator

I like it and I'm willing to merge it. The only question I have is the one about the active pattern.

@gdziadkiewicz gdziadkiewicz merged commit fb5156e into fsprojects:master Feb 11, 2025
3 checks passed
@gdziadkiewicz
Copy link
Collaborator

@fdornak Thank you very much for the contribution! I will release a new version this week :)

@gdziadkiewicz
Copy link
Collaborator

I will release it this week.

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

Successfully merging this pull request may close these issues.

It's a bit confusing that Validation uses Choice instead of Result
2 participants