Contents tagged with Haskell
-
A Kick in the Monads – Writer Edition
In the past couple of Monads posts, we’ve talked briefly about the State and Reader Monads and their potential uses and misuses. Before this series completes, I have a few more to cover including the Writer, Continuation and eventually Observable monad. Today, we’ll get started looking at the Writer Monad and what it can do for us.
-
A Kick in the Monads – Creating Extended Builders Part III
So far in this series, we’ve covered some of the methods you can implement for custom computation expressions (aka Monads) in F# such as bind and return, as well as exception and resource management. For the last part in the series, we’ll take a look at looping constructs. As we know, F# is a pragmatic multi-paradigm language which supports not only functional features, but imperative ones as well, which include mutability, looping constructs and so on. Just as regular F# supports for and while loops, we have the ability to take advantage of them as well inside of our computation expressions by implementing two methods. Let’s start with the while loop.
-
Much Ado About Monads – Creating Extended Builders Part II
In this series, we’ve looked custom computation expressions, what they are, how they are applicable to development and how we might implement them in F#. In the previous post, we went over some of the basic methods you can include on your custom computation expression to allow for a more rich programmatic model than the linear style provided via both Bind and Return.
-
Much Ado About Monads – Creating Extended Builders
In the past two posts in this series, we’ve covered both the State Monad and Reader Monad, not only the motivations, but how you would implement them in F#. With defining the Return and Bind methods on our computation expression builders, we’re able to do composable linear programming. But, what we lack is an imperative programming model on top to allow for such things as if statements, for and while loops, and try/catch or try/finally blocks. Luckily, there is a programmatic model to follow to make these things possible inside of our expressions. Let’s cover each of these functions in turn and see what each one does and in the process implement them for the Reader Monad.
-
Much Ado About Monads – Reader Edition
In the previous post, we talked a bit about the State Monad, what it is and how you could use it today in your F# application. But, with any new piece of information such as this, it should be taken in context, and there are other patterns as well when dealing with a multi-paradigm language such as F#. We also talked about how the State Monad might not have been the best choice for modeling our web scripting DSL as our browser state is encapsulated in the Browser class, and once it is set, it doesn’t change. With that, we could turn our eyes to using the Reader Monad as we read from our environment.
-
Much Ado About Monads – State Edition
Over the past year, I’ve had the opportunity to be a technical reviewer of a number of books including Chris Smith’s Programming F# book. During my recent trips, I had the chance to sit down and read through the book once again, and in particular Chapter 10 on Computation Expressions (aka Monads). A section worth noting in here is the use of the State Monad in order to create a library for web scripting. In the past, I’ve had a series on Much Ado About Monads where I look at the basic Monads such as Maybe and List, but this time, let’s look at what we can do with the State Monad.
-
Functional Programming Fundamentals Lectures
Earlier this year, I had the privilege to record a Channel 9 video session covering functional programming basics with Erik Meijer and Charles Torre. We covered some of the basics, but at some point you need to go back to the fundamentals in order to truly learn this paradigm. With that, Erik with the help of Charles, have kicked off the Channel 9 lecture series on Functional Programming Fundamentals. This series is meant to be a journey into some of the ideas behind functional programming, following along with Graham Hutton’s excellent Programming in Haskell book. Many of the concepts described in this series are in Haskell first, but many apply as well to F#, and even C# and VB.NET. What better way to talk about Haskell and functional programming than to learn from one of the authors of the Haskell 98 Report. I highly encourage everyone to check out this series!
-
First Class Composable Events in F#
If you’ve been following me on Twitter lately, I’ve been playing a lot lately with event based programming in both F# events as well as the Reactive Framework (RX). Today, I’m going to start a series in event processing, starting from the elementary concept of first class events in F#.
-
Modeling DSLs with F# and Units of Measure
Very recently on Lambda the Ultimate, they had a really good post describing Soccer-Fun, a way to teach functional programming (pdf). The premise is very simple and is described as the following:
-
The “Anti-For” Campaign
Recently, there has been an effort launched called the “Anti-If Campaign” in which they deride the use of if statements and instead, focus on Object Oriented Principles in order to create more flexible designs. Now certainly, I have a sympathetic ear to this cause as I’ve seen code that literally walks off the side of the screen due to nesting of if statements. Pattern matching to me, especially at the top level of the function is actually quite beautiful in a way, such as the implementations in Haskell: