possible fsharp refactorings could be
DESCRIPTION
TRANSCRIPT
![Page 1: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/1.jpg)
F# refactoring possibilitiesBASIC REFACTORINGS THAT I WOULD LIKE TO HAVE IN VISUAL STUDIO IDE
![Page 2: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/2.jpg)
Purge tuples
Which is cleaner? It depends.
This is just a matter of clean code.
Also needed: Rename a variable/function/parameter
![Page 3: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/3.jpg)
Move discriminated union to subtype
Usually coder starts with the first one…
But the data (string*int) is so much easier to access in the later one!
Even later, it may not be clear that what sub-types belongs to where in the type hierarchy
![Page 4: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/4.jpg)
Convert to immutable
Usually you need either all or just one property to be changed to immutable/mutable
![Page 5: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/5.jpg)
Pattern match to If-else
Usually in case of booleans (or when-patterns)
Back-conversion not possible, if left-hand-side compare condition is not the same
![Page 6: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/6.jpg)
Move function parameters
![Page 7: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/7.jpg)
Move List, Seq or Array conversion in composition
![Page 8: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/8.jpg)
Extract Function-Composition
![Page 9: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/9.jpg)
Extract to active pattern
Longer code but sometimes better visibility of business logic intentions.
![Page 10: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/10.jpg)
Convert to Option-module
Option-module (bind, map, etc.) could be used more…
One step more would be List-module to recursion, or recursion to fold
![Page 11: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/11.jpg)
Strip un-used computation expression wrapping
Just minor cleanup if Async (or other monads) are not really used to bind any data to computation
![Page 12: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/12.jpg)
Basic object-oriented features
Generate a base class (and move some methods to there)
Create and/or Implement interface So that user doesn’t have to remember interface-syntax
![Page 13: Possible FSharp Refactorings could be](https://reader033.vdocument.in/reader033/viewer/2022051610/5495c0cbb479593d4d8b4df9/html5/thumbnails/13.jpg)
Simple pattern/snippet to make a simple MailboxProcessor
So that user doesn’t have to remember the whole syntax
Or a way to convert existing list/dictionary to a MailboxProcessor…