You are here

Haskell

The Haskell programming language

Oh Haskell

I built some code recently to generate SVG that could be transformed into PDF and then fed to a laser cutter along with a bamboo sheet to get markers for the Glass Plate Game. (This is why I cared about X DPI: I wanted to see what the markers would look like "actual size".)

Group/Project: 

A Logo demo in Haskell

Ran across the homepage of Berkeley Logo a few days ago. One of the things on there is this demo code

to choices :menu [:sofar []]
  if emptyp :menu [print :sofar stop]
  foreach first :menu [(choices butfirst :menu sentence :sofar ?)]
end

When invoked as

choices [[small medium large]
         [vanilla [ultra chocolate] lychee [rum raisin] ginger]
         [cone cup]]

we get a list of choices starting with

small vanilla cone
small vanilla cup
small ultra chocolate cone
small ultra chocolate cup
…

I got curious about how Haskell stacks up against Logo here…

Group/Project: 

Exploring Haskell's concatMap performance

I put some code and results up on BartForge yesterday. I've been exploring the performance of Haskell's concatMap function as part of learning how to write performant Haskell code. I saw some interesting things in the process: read the writeup for details. Fob

Group/Project: 

Huffman Encoding in Haskell

I guess that after doing run-length encoding, the next logical step was Huffman encoding. Find my project at BartForge. It encodes and decodes about 2M symbols per second on my fast box.

I'm slowly learning how to optimize Haskell. Bleah. Fob

Group/Project: 

Run-Length Encoding in Haskell

I was messing around with some code for run-length encoding and decoding over the past couple of days, and with the help of Jamey Sharp, Josh Triplett, and Jules Kongslie got it to be constant-time per symbol and fast.

Get the code at BartForge. Fob

Group/Project: 

Laziness weirds programming 2

This is a pretty clean definition of the Sieve of Eratosthenes in Haskell. Type it at the ghci command line and evaluate it to get a large list of primes before you get bored…

Group/Project: 

Laziness Weirds Programming

So I thought about it tonight and figured out that in Haskell I can generate the Fibonacci sequence using the definition

let l = [1,1] ++ zipWith (+) l (tail l)

If you type this at ghci you can say "take 20 l" and get

[1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765]

Laziness weirds programming. Fob

Group/Project: 

An Audio Compressor / Limiter

I posted an audio compressor / limiter written in Haskell to HackageDB and BartForge this weekend. I also posted its ancillary pure-Haskell WAVE file IO library, and my Haskell argument parsing library.

It all still needs a lot of work to be good, but it's usable now. Enjoy. Fob

Group/Project: 

In Haskell we say...

From this interesting blog post:

Where in C++ we might say:
  for (int x = 0; x < 10; x++) f(x)
in Haskell we would say:
  map f (take (10 [0..]))

Which is sadly all too often true. I'm definitely one of the ones who will tend not to find the much happier

map f [0..9]

Fob

Group/Project: 

CODE: Haskell non-transitive dice constructor

I'm slowly learning Haskell. Today's project was something that arguably should be way faster for a fluent Haskell programmer than for a C programmer. It wasn't for me, since I'm still learning the language.

The recent BoingBoing posting on "nontransitive dice" is something I'd seen before and found interesting…

Group/Project: 

Pages

Subscribe to RSS - Haskell