Joachim Breitner

Running Circle Packing in the Browser using Haste

Published 2013-07-11 in sections English, Haskell.

Half a year ago, I wrote a small Haskell library called circle-packing to pack circles in a tight arrangement. I used this to experiment with the fay compiler, which compiles Haskell to JavaScript, and the result was quite nice.

Recently, I was pointed to haste, another Haskell-to-JavaScript-compiler, and gave it a shot. It required no changes to my code, and after a bug in the compiler was fixed, I could successfully run the example compiled with haste. Some observations:

  • Haste provides more features that I consider necessary for it to be used seriously. In particular its support for Cabal (so I could just write haste-inst install circle-packing) and its support for a much larger subset of Haskell, including type classes, as it builds on GHC.
  • Interfacing with JavaScript is not as smooth as in fay. Especially having to write JS code in a separate helper file is annoying.
  • A quick unscientific comparison of the two results indicates that the code produced by haste is a bit faster (although I should maybe compile the fay variant with the latest version).


Have something to say? You can post a comment by sending an e-Mail to me at <>, and I will include it here.