elmish / Elmish.WPF

Static WPF views for elmish programs
Other
421 stars 68 forks source link

Adding fully specified parameter lists to NewWindow.Core and FileDialogsCmdMsg.Core #567

Closed rfreytag closed 1 year ago

rfreytag commented 1 year ago

I found Sample/NewWindow.Core/App.fs hard to read. I have a version in my fork, branch: Adding_fully-specified_parameter_lists that I find more readable with the following changes:

I added fully-specified parameter lists to the remaining Sample/NewWindow.Core F# files while I was at it. And then for good measure I did the same to FileDialogsCmdMsg.Core.

Doing this helped me understand what was going on. I hope it will help others adopt Elmish.WPF. I will issue a pull request if you like where I'm going.

marner2 commented 1 year ago

@LyndonGingerich @TysonMN do you think we should we should do something similar with the rest of the examples?

rfreytag commented 1 year ago

@marner2 Yes, I do think this edit for readability would help with the other examples. I am adding these parameter lists and return values to Capabilities.Core now. Could you merge this request so I can branch from 'master' again?

marner2 commented 1 year ago

Ok sounds good. Please avoid any samples touched by #551 for now to avoid conflicts (until it gets merged in).

rfreytag commented 1 year ago

FileDialogsCmdMsg.Core changes were merged in with the commit; sorry. But I can stay away from:

I plan on next working on Capabilities.Core and perhaps merging in FileDialogsCmdMsg.Core.

TysonMN commented 1 year ago

@rfreytag, since this PR was already merged, can you create another PR that address my concerns?

LyndonGingerich commented 1 year ago

I don't think this change was thought through with a lot of nuance. I see lines such as let init : string = "", which doesn't need a type annotation.

Unless I misunderstand, the samples attempt to communicate simply and clearly with those who are used to idiomatic F#. We do not wish to require readers to learn a new set of idioms specific to Elmish.WPF; many probably need only one or two samples to browse. Since the reader is already trying to learn a new framework, he should not have to learn a new way of writing F# at the same time. For this reason, I propose that we do not introduce new idioms that F# developers cannot immediately understand and effortlessly remember.

Changes this PR makes:

On the other hand, we do use idioms in this sample that most F# developers probably wouldn't recognize:

LyndonGingerich commented 1 year ago

LyndonGingerich TysonMN do you think we should we should do something similar with the rest of the examples?

@marner2 Above post intends to answer your question.

marner2 commented 1 year ago

Yeah I think those suggestions in the last half of your comment make sense @LyndonGingerich, and we definitely should be more considered and deliberate with future sweeping updates of the samples.

I was ok with the update as-is because it's always valuable to get empirical feedback when someone unfamiliar with the project details their experience (and it was just a single file that was updated).

As far as explicitly specified types taking longer to read, while that may be true of production code, samples have a slightly different target. Which is again why I'm ok with liberal eta-expansion (especially of function to match) showing up in the samples. It just helps guide people who unfamiliar with the idioms. The other thing about these sample projects is that they are intentionally short, and generally in very small implementations you should err more on the side of verbosity. When you have a very large codebase where things get repeated a bunch, that's where the shortcuts start to kick in and pay off.

TysonMN commented 1 year ago

Adding more type annotations is typically fine. There were some in this PR that don't improve readability, and those can be removed.

LyndonGingerich commented 1 year ago

Here's my first effort at a low-complexity version of the sample program. I'm not making a PR because I'm intending to diff on the original, not the current version with this PR merged.

https://github.com/LyndonGingerich/Elmish.WPF/compare/070d311428042676f7f2b92fdd5f40c504c6e4d1...LyndonGingerich:Elmish.WPF:lyndon_suggested_simplifications_05-19-2023

@rfreytag , would these changes have made the code easier to read?

rfreytag commented 1 year ago

@TysonMN I will remove the changes to which you objected and reissue the PR. In my defense, I did offer my branch for review before issuing a pull request.

Glad to learn from this discussion.

TysonMN commented 1 year ago

Yes, no worries. You didn't do anything wrong. It is easy to change code (back).

rfreytag commented 1 year ago

As you have time would you review my fork, branch Adding_fully-specified_parameter_lists latest commit (6de8aae7)?

The commit note reads... "

If this doesn't suit I accept it might be best if I stay in my fork.

I'll issue the PR if you folks are satisfied.

rfreytag commented 1 year ago

@LyndonGingerich I have been rushing to revise/undo my prior PR. Will read your thoughts with interest as time allows.

TysonMN commented 1 year ago

Please first create a PR that only addresses the concerns I raised on this PR. After that is merged, we can look at your other improvement suggestions.