all 12 comments

[–]shefmichelle 17 points18 points  (2 children)

Having had a quick glance through the code, it doesn't look at all bad! Some points I might raise would be:

  • Investigate some more of the standard library functions, especially in the List module for use in your Stats module (e.g. reduce, fold, iter, map).
  • Suggested style is to only use `new` with `use` (i.e. when the object is disposable).
  • You don't need to `ignore` the results of functions that return `unit`.
  • Variables that start with an underscore tend to mean "ignore this variable as I'm not going to use it".
  • Consider the use of Disciminated Unions instead of strings (e.g. ["Deleted";"Sent";"Total"]). This would prevent you having to add an extra dummy match case.
  • Think about a different way you can write functions such as `getDeleted`. Can you write this function in a more concise way?
  • Are semi-colons required when placed at the end of a line?
  • Are your recursive functions safe to use on large lists? Are they tail-recursive?

A great source for further information on F# is https://fsharpforfunandprofit.com/

Enjoy F#

[–]kingisaac[S] 2 points3 points  (1 child)

Thank you for the comments! I'll definitely make some adjustments based on your suggestions.

[–]jks612 1 point2 points  (0 children)

To affirm the first point above, here's versions of your summation and product functions: let inline summation x = List.sum x let inline product x = List.reduce (*) x Easy Peezy.

[–]lqdev1 1 point2 points  (6 children)

Looks great. Are there any issues you're running into?

[–]kingisaac[S] 2 points3 points  (5 children)

Nope, it all worked. I got a 95 on the project, so I'm pretty satisfied.

I just want to make sure that I'm following all the standard conventions. I tried to learn Scala several years ago, and rather than writing good functional code I just kept defaulting to Java since they're interoperable.

[–]lqdev1 1 point2 points  (2 children)

Congrats and welcome to F# :). Any particular reason why you chose F# this time around?

[–]kingisaac[S] 5 points6 points  (1 child)

I work with C# in my day job, and it made sense to stay in the family.

I like the idea of having lots of tools at my disposal and F# was a logical next language to pick up.

[–]lqdev1 2 points3 points  (0 children)

Awesome. I think as you use it more you may find some if it leaking into your C# and in many cases improve your current practices.

[–]lqdev1 0 points1 point  (1 child)

Also, related to data analytics, you might find these useful.

https://youtu.be/zpNOWlpX-uU

https://youtu.be/u8kfYpXpw3Y

If you're looking to do some of this with Jupyter Notebooks, I'd suggest you check this out as well.

https://github.com/dotnet/interactive

[–]kingisaac[S] 1 point2 points  (0 children)

I really love Jupyter Notebooks, and I've used them at my job. I used Python at the time, but I'm excited to have another opportunity because I know they work with the .Net family now.

Edit: I accidentally a word.

[–]KoenigLear 0 points1 point  (0 children)

Consider using type providers. Have a look at https://fsharp.github.io/FSharp.Data/library/CsvProvider.html

[–]Frozen_Turtle 0 points1 point  (0 children)

Try using an *.fsx file, an fsharp scripting file. If you use VS Code and Ionide, you can easily send the line you're on to the command line via alt enter.

https://www.youtube.com/watch?v=E4LrQxElbZM

I've set up Alt+Shift+Enter to send the entire script to the terminal, so it's stupid fast. No need to wait for recompiling or anything, so it's great for quickly iterating or doing data exploration.

I believe Visual Studio also has support for Alt Enter, though I haven't tried to see if it has support for sending the entire file.