Haskell’s evaluation isn’t magic

One common complaint with lazy functional programming is that reasoning about the performance of your code is harder than in a strict language. Will an expression be repeatedly evaluated or a closure repeatedly accessed? Will code use up more or less heap space? For that matter, many people have no clue as to how lazy evaluation works in the first place.
Read the rest of this entry »

Semantic Editor Combinators - one of my favorite blog posts

I wanted to squeeze this blog post into my Best Haskell Papers of 2009 article, but it unfortunately was written in late 2008. For your enjoyment, here is the entry below. Read the rest of this entry »

Best Haskell Papers of 2009

As the year closed I reminisced on all the Haskell related papers I read in 2009. Some of them lifted my understanding to exciting new heights, while some others seemed impractical or overly tedious. The thought came upon me to present a list of the best of the best with the hope that these excellent papers might inspire and motivate others as they have me. Read the rest of this entry »

Applied Functional Programming: Part 1

This post begins a two part series designed to present functional programming concepts as they apply to real world programming. Using functional techniques, we’ll solve a problem that came up in a commercial project I’m working on. Read the rest of this entry »

Synchronous Events

It turns out that there’s a certain class of event transformers (Event a -> Event b) in Reactive that have some really neat and convenient properties. We’ll call this class synchronous event transformers. Read the rest of this entry »

Introducing Reactive: Behaviors

In the last post, Reactive’s Events were examined. While Events cover a lot of ground, Reactive’s Behaviors allow programmers to think beyond sampling when writing games and other interactive programs. This post introduces Behaviors and the functions that make them useful.

Read the rest of this entry »

Why is the Reactive Behavior tutorial taking so long? splitB

Writing the event tutorial brought out the need for several basic functions in Reactive, especially switchE. The behavior tutorial is also bringing with it a slew of necessary functions. The most surprisingly difficult to implement has been splitB.

-- |At every event occurrence, produce a behavior that is a combination of the
-- first and second where it acts like the first up to the event occurrence
-- and then acts like the second.
splitB :: Behavior a ->
          Behavior a ->
          Event b    -> 
          Event (b,Behavior a)

This post describes how this function was implemented. In doing so, we’ll explore internals of the Reactive library and come into contact with the tricky laziness issues that often come up when working with Reactive. Read the rest of this entry »

Introducing Reactive: Events

Reactive is Conal Elliott’s newest FRP (functional reactive programming) framework. In this series of blog posts, I’m going to introduce a set of examples by concept. These articles are intended to serve as tutorials and motivation for writing interactive programs using Reactive instead of the IO monad.

A basic knowledge of Haskell and the prelude functions, especially higher order functions like id and const, is all that is required.

Read the rest of this entry »

freeglut + Windows + HOpenGL + HGLUT

freeglut is a version of glut that is vastly superior to the one typically used with windows. Aside from being Open Source, it interacts well with ghci (see leaveMainLoop) and provides a rhombic dodecahedron primitive. This post walks through the somewhat complicated process of getting Freeglut and the haskell OpenGL and GLUT bindings installed and working on windows. This feat is accomplished using the brand new ghc 6.10.1. Read the rest of this entry »

Analysis of lazy-stream programs.

What’s the difference between the following two functions, a and b:

import Control.Monad.Instances
import Control.Arrow
 
a, b :: (Int->Int) -> (Int,Int) -> (Int,Int)
a = fmap
b = second

Can you figure it out? Read the rest of this entry »

←Older