Inside 736-131

Existential Pontification and Generalized Abstract Digressions


Modelling IO: MonadIO and beyond

The MonadIO problem is, at the surface, a simple one: we would like to take some function signature that contains IO, and replace all instances of IO with some other IO-backed monad m. The MonadIO typeclass itself allows us to transform a value of form IO a to m a (and, by composition, any function […]

  • January 24, 2012

monad-control is tricky

Editor's note. I've toned down some of the rhetoric in this post. The original title was "monad-control is unsound". MonadBaseControl and MonadTransControl, from the monad-control package, specify an appealing way to automatically lift functions in IO that take "callbacks" to arbitrary monad stacks based on IO. Their appeal comes from the fact that they seem […]

  • January 23, 2012

Problem Set: The Codensity Transformation

Have you ever wondered how the codensity transformation, a surprisingly general trick for speeding up the execution of certain types of monads, worked, but never could understand the paper or Edward Kmett's blog posts on the subject? Look no further: below is a problem set for learning how this transformation works. The idea behind these […]

  • January 7, 2012

Why iteratees are hard to understand

There are two primary reasons why the low-level implementations of iteratees, enumerators and enumeratees tend to be hard to understand: purely functional implementation and inversion of control. The strangeness of these features is further exacerbated by the fact that users are encouraged to think of iteratees as sinks, enumerators as sources, and enumeratees as transformers. […]

  • January 4, 2012

Accessing lazy structures from C

Someone recently asked on haskell-beginners how to access an lazy (and potentially infinite) data structure in C. I failed to find some example code on how to do this, so I wrote some myself. May this help you in your C calling Haskell endeavours! The main file Main.hs: {-# LANGUAGE ForeignFunctionInterface #-} import Foreign.C.Types import […]

  • December 15, 2011

How to read Haskell like Python

tl;dr — Save this page for future reference. Have you ever been in the situation where you need to quickly understand what a piece of code in some unfamiliar language does? If the language looks a lot like what you’re comfortable with, you can usually guess what large amounts of the code does; even if […]

  • November 14, 2011

Let’s play a game

Ever wondered how Haskellers are magically able to figure out the implementation of functions just by looking at their type signature? Well, now you can learn this ability too. Let’s play a game. You are an inventor, world renowned for your ability to make machines that transform things into other things. You are a proposer. […]

  • September 5, 2011

8 ways to report errors in Haskell revisited

In 2007, Eric Kidd wrote a quite popular article named 8 ways to report errors in Haskell. However, it has been four years since the original publication of the article. Does this affect the veracity of the original article? Some names have changed, and some of the original advice given may have been a bit... […]

  • August 29, 2011

Joseph and the Amazing Technicolor Box

Consider the following data type in Haskell: data Box a = B a How many computable functions of type Box a -> Box a are there? If we strictly use denotational semantics, there are seven: But if we furthermore distinguish the source of the bottom (a very operational notion), some functions with the same denotation […]

  • August 23, 2011

Changes to IntMap

As it stands, it is impossible to define certain value-strict operations on IntMaps with the current containers API. The reader is invited, for example, to try efficiently implementing map :: (a -> b) -> IntMap a -> IntMap b, in such a way that for a non-bottom and non-empty map m, (\_ -> undefined) […]

  • August 1, 2011