Return type overloading in Haskell

Function overloading is very common in many programming languages like C# but most of the languages that I have used only support overloading based on function arguments. For example in C# there are several overloads on the String.IndexOf function where … Continue reading →

0

Prime Factorization using Unfold in Haskell

I randomly yesterday started thinking about the unfoldr function in Haskell while working out at the gym (how nerdy is that, I am lifting iron but thinking of functional programming). Unfoldr take a single and an unfolding function and turns it into a list (the opposite of fold).  At the gym I was thinking about…

3

Parameterized State Transformer Monad in F#?

I have have been playing around with F# and I decided to create a state monad.  This worked out really well since I was able to leverage the F# computation expressions.  I then decided to try to extend this and make it more general by creating a parameterized state transformer monad.  This is a state…

2

Writing a Regular Expression parser in Haskell: Part 4

With the previous two modules in place we are now set up to use a DFA to match against a string.  In my implementation I support either a greedy match or an short match.  In a full featured regular expression engine this ability to choose greedy or not would be per operator but for simplicity…

1

Writing a Regular Expression parser in Haskell: Part 3

The third module in the simple regular expression parser is called: NFAtoDFA.  Which as you might have guessed, takes the NFA that resulted from the first module and converts it into a DFA.  The structure that the DFA uses is the same that the NFA uses since they are both finite state machines. Converting an NFA…

1

Writing a Regular Expression parser in Haskell: Part 1

A few weeks ago I read this article about writing a simple regular expression parser.  That article does a really good job of explaining the theory behind regular expression.  It then goes step by step into how to write a program (he uses C++) to parse a regular expression, convert it into a NFA, convert…

0

Breadth First Tree Traversal in Haskell

As my interest in functional languages has grown, I have become increasingly interested in using them to implement algorithms which I can already write with imperative languages. For example, I was taught to implement (and I assume most other people as well)  a breadth first traversal of a tree using a queue and a loop. …

1

When I am finally starting to get a handle on Monads...

When I am finally starting to get a handle on Monads I discovered Arrows and I am thrown back into confusion.  At least that is how it feels.  In my exploration of Haskell I have spent a good deal of time trying to completely grasp and understand Monads.  I have read much about it and…

0

Lazy Prime Number Sieve in C#

In my last post I talked about a Stream class for creating efficient lazy lists in C#.  In addition, I showed several classic functional methods I ported to C# to be used on the lazy lists.  As I mentioned in that post, I will now talk about an example I included in the source code…

3

Digging deeper into C# Lazy Lists

One of the most interesting aspects of the Haskell language is the fact that features lazy evaluation.  My interest in lazy evaluation led me to a post on Wes Dyers blog about lazy lists in C#.  In his blog post he talks describes how to create a lazy list class in C# and demonstrates some…

2