Crafting Code in F#

Howard Lewis wrote a nice post "Crafting Code in Clojure" about craftable code. He started with a rather ugly Java class and reached a lovely small Clojure solution. I was curious how it would be looked written in F#. Have a look at the result:

It's odd that F# core library does not contain Map.keys/Map.values functions. Otherwise, the code would be a bit more shorter.

However, maps aren't used in static languages like F# to represent domain types. Hence, the more idiomatic version:

(the Fact attribute is from xUnit.net library, and =? operator is from wonderful Unquote one).

Comments

Popular posts from this blog

Upcoming F# struct tuples: are they always faster?

Computing cryptography hashes: Rust, F#, D and Scala

Composing custom error types in F#