Haskell is a lazily evaluated, strongly typed functional programming language. It’s awesome.
Haskell is a lazily evaluated, strongly typed functional programming language. It’s awesome.
New to the series? Go to the beginning. We’ve talked about how we open (evaluate) presents (thunks) in the Haskell Heap: we use IO. But where do all of these presents come from? Today we introduce where all these presents come from, the Ghost-o-matic machine (a function in a Haskell program). Using a function involves [...]
New to the series? Go to the beginning. Here is a simple implementation of all of the parts of the Haskell heap we have discussed up until now, ghosts and all. heap = {} # global # ---------------------------------------------------------------------# class Present(object): # Thunk def __init__(self, ghost): self.ghost = ghost # Ghost haunting the present self.opened = [...]
New to the series? Go to the beginning. In today’s post, we focus on you, the unwitting person rooting around the Haskell heap to open a present. After all, presents in the Haskell heap do not spontaneously unwrap themselves. Someone has to open the first present. If the Haskell heap doesn’t interact with the outside [...]
New to the series? Go to the beginning. The Ghost of the Christmas Present In today’s post, we’ll do a brief survey of the various things that can happen when you open haunted presents in the Haskell heap. Asides from constants and things that have already been evaluated, mostly everything on the Haskell heap is [...]
The Haskell heap is a rather strange place. It’s not like the heap of a traditional, strictly evaluated language... ...which contains a lot of junk! (Plain old data.) In the Haskell heap, every item is wrapped up nicely in a box: the Haskell heap is a heap of presents (thunks). When you actually want what’s [...]
It is often said that the factorial function is the “Hello World!” of the functional programming language world. Indeed, factorial is a singularly useful way of testing the pattern matching and recursive facilities of FP languages: we don’t bother with such “petty” concerns as input-output. In this blog post, we’re going to trace the compilation [...]
I was supposed to have another post about Hoopl today, but it got scuttled when an example program I had written triggered what I think is a bug in Hoopl (if it’s not a bug, then my mental model of how Hoopl works internally is seriously wrong, and I ought not write about it anyway.) [...]
The imperative. When should you create a custom data type, as opposed to reusing pre-existing data types such as Either, Maybe or tuples? Here are some reasons you should reuse a generic type: It saves typing (both in declaration and in pattern matching), making it good for one-off affairs, It gives you a library of [...]
This is a collection of WTFs due to misuse of mutable state. We'll start off with some Java. What do you expect this snippet of code to do? Sensor Accel = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); Sensor Orient = sm.getDefaultSensor(Sensor.TYPE_ORIENTATION); sm.registerListener((SensorEventListener) this, Accel, sm.SENSOR_DELAY_FASTEST); Ostensibly, it registers the current object to receive just accelerometer updates. But what if I [...]
They say that one doesn’t discover advanced type system extensions: rather, the type system extensions discover you! Nevertheless, it’s worthwhile to know what the tech tree for GHC’s type extensions are, so you can decide how much power (and the correspondingly headache inducing error messages) you need. I’ve organized the relations in the following diagram [...]