Functional Programming

AOP with F# – Memoization using higher-order functions

I touched on the topic of memoization in the past in relation to doing aspect-oriented programming with PostSharp, however, with functional languages like F#, Haskell or Erlang there is no such frameworks (although PostSharp should still work with F# to some extent) to help you. That’s not to say that you can’t do AOP in …

AOP with F# – Memoization using higher-order functions Read More »

F# – Enums vs Discriminated Unions

In my previous post on discriminated unions, I presented discriminated unions as an alternative to standard .Net classes to represent hierarchical data structures. However, in terms of data structure, discriminated unions share much more similarities with enums than they do classes – both allow you to define a set of named constants and associate some …

F# – Enums vs Discriminated Unions Read More »

F# – Referential equality for tuples, discriminated unions and records

By default, tuples, discriminated unions and records have what is known as structural equality – i.e. if two instances of these types have the same set of values then they are considered equal, just like value types – despite being reference types: Tuples Discriminated Unions Records To facilitate this form of equality, the F# compiler …

F# – Referential equality for tuples, discriminated unions and records Read More »

F# – Use Discriminated Unions instead of class hierarchies

When you consider the age old problem of representing different shapes (circle, triangle, square, rectangle, etc.) my OO fed developer brain naturally jumps to a class hierarchy along the line of: This is perfectly fine and legit, but it’s not the only way to approach things. Since I’ve been on a more varied diet of …

F# – Use Discriminated Unions instead of class hierarchies Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close