F# 2 weeks later

F# 2 weeks later

21 Aug 2015

Since I’ve been without an assignment I’ve had the time to look into F# more.

Where did I find material?

Why did I start looking into F# again?

I share the office with Fredrik Forssen. I find his love of F# inspiring.

Things I’ve found that delighted me:

  • Less ceremony to declare classes, records, methods and functions (when you get used to how you write it)
  • Easier to compose things (for instance if you want to create a chain in order to use many different classes together for an import)
  • Monad support (and yes, I know that these things can very easily be abused)
  • Package manager and Build tool that works well together (paket and fake).
  • Records defined in F# are like hand coded readonly classes with IEquatable and IComparable implemented

I’ve previously found the following sweet when looking at the language:

  • Immutable by default
  • Language construct to create a clone of a record but with different values for some fields
  • Language construct to match more than hard coded strings, enums and integers
  • If you forget to add an equals sign to a type or module declaration you get weird compiler errors
  • Gui tooling is still a bit alpha (the command line version works great)
  • It’s easy to create a F# project where you need to manually edit the fsproj file in order to get it to work on mono and windows (this was a problem in the early days of NuGet)
  • Almost all the library methods in .net becomes a tuple parameter in F#, this is a bit confusing since it looks like an ordinary function call in C#
  • Exposing F# Option on your types makes it harder to interact with your F# code from C#
    using OptionalUrl = Microsoft.FSharp.Core.FSharpOption<Customers.Url>;
    ...
       var customer = new Customer(
          ...
          pictureUri: OptionalUrl.Some(new Url("http://someurl.com/something?some=asd"))
       );

Tags

  • F#

Comments

Do you want to send a comment or give me a hint about any issues with a blog post: Open up an issue on GitHub.

Do you want to fix an error or add a comment published on the blog? You can do a fork of this post and do a pull request on github.