When pitching functional programming to an imperative friend, the “map” function is the canonical example of the obvious advantages of the functional approach. And once our backwoods imperative friend has begrudgingly accepted “map” as a neat party trick, we can really amaze them by abstracting “map” [...]
So we know how to use a type parameter to statically constrain the length of a list. Let’s continue our exploration of type constraints and see if we can figure out how to constrain the return type of a data constructor.
We may not have proper type class constraint support in F#, but we can still make sure our ‘square’ function doesn’t blow up at runtime.
Passing the Dictionary of Operations Explicitly
In the comments of the last post, Cale Gibbard noted that the monad abstraction is pointless unless you can write code that works against the abstraction, instead of a particular instance.
Haskell let’s you write work with the monad abstraction through the use of type classes. This ad hoc form of polymorphism [...]
Although not strictly necessary, to be a good F# programmer you pretty much have to learn Haskell. It reminds me of the relationship between VB and C#. Sure, you don’t have to learn C#, but you miss out on so much good knowledge and know how if you don’t. Without C#, you can [...]