F#un with Phantom Types

With Halloween tomorrow, now is the perfect time to take a look at phantom types in F#.  So what are phantom types?  Think of them as a way to embed a constraint into the type system of a language.  Here’s a great example of using them [...]

Active Patterns as Computations

So how can we match over abstract data types in a more palatable manner? 

 

Active Patterns

 

Pattern Matching for Dummies

The pattern matching syntax of F# will change the way you write code.  Of all the reasons to begin the move from VB to F#, the declarative style of pattern matching is reason number one.  The days of the “nested if” are numbered and blood pressures [...]

Type Classes vs Template Expansion : How to write a generic square function?

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

Type Classes for the .Net Underclass

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 [...]

Haskell’s Binding Operator (>>=) Simple For F# Programmers

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 [...]

The Maybe Monad in F#

When learning something new I like to focus on the things that I can’t do with my current programming skill set.  The first time I skimmed through Expert F# I realized there’s a whole lot of skill set that I don’t have.  Of particular interest was the concept of monads/computations/workflows.

I can’t [...]

A Prime Number Generator in Visual Basic

To generate a list of Fibonacci numbers, we created a generator class that emulates the behavior of the c# yield statement.  We’ll expand on this generator in another blog to enable us to write LINQ methods, but for right now we’ll use if for a similar task, generate a list or primes.