InquiryLabs

Politics, Programming and Possibilities

Archive for the ‘Software Engineering’ Category

Haskell Pearls

I’ve been lurking on the Haskell mailing list recently, and occasionally asking a question or two.  I suppose you wouldn’t be surprised to know that I’ve found a treasure-trove of Haskell-related information and resources that I hadn’t been aware of.  Really though, the Haskell community has created quite a rich store of documentation for itself and others, perhaps more than I’ve seen in any other community (which is not to say that other communities do a poor job).  Here I’ve compiled a short list of these new pearls I’ve learned of, along with any other links that I’ve found useful:

1. Twin search engines Hoogle and Hayoo.  Note that you can search for type signatures as well as functions themselves.  Try searching for “(a -> Bool) -> [a] -> [a]” in Hoogle.  Hayoo covers all of the packages on hackage, while Hoogle seems to be limited to the base packages.
2. A remarkable summary of “who and what” is out there in the Haskell community.  The PDF is here.
3. The Glasgow Haskell Compiler (GHC) manual.
4. A (free) quarterly journal called the Monad.Reader that covers topics for beginners to experts.
5. “Visualizing the Haskell Universe” is a graph of all of the available (free) packages out there.  A huge SVG image is here.
6. The Haskell 98 Language Report which I wrote about last July has many answers to language-related questions.

Posted via email from Duane’s Quick Posts

Corrected: Example type search (thanks bonus)

Ruby Conf ‘09

The Mountain West Ruby Conference was a smash!  We covered a wide range of topics that really made me pleased to be a part of the community (at least in attendance!)  Some of my favorite presentations were Daniel Philpott’s “Tiger Team” and Jon Crosby’s introduction to Middleware (aka Rack).  It was also really cool to see James Britt’s “Wii” link-up and hear him play some wild MIDI instruments on his “air wand”.  I’m sure he’ll be tuning it in the near future :)

Oh, and if those presentations weren’t enough to make the conference worthwhile (they were!) I also discovered that everyone was Twittering there.  So I guess I know people who twitter now :)  I found out about twitterfall.com which was a great way to keep “up to date” on all things #mwrc.
I haven’t had a chance to look yet, but from what I’ve heard the conference will be available on video at confreaks.

Posted via email from Duane’s Quick Posts

RubyConf is Tomorrow!

I’m excited to attend the Mountain West RubyConf in SLC tomorrow (and Saturday). I hope to see you there!

I'm attending MountainWest RubyConf 2009!

The Haskell Rabbit Hole

As a programmer, curiosity is most often a helpful asset that leads to a grander and more unified understanding of computer science.  With Ruby, for example, I quickly learned about the usefulness of closures because the array methods like “map” and “select” were so helpful.  Closures became a new tool in my toolbox–something I could apply almost everywhere.

Haskell is teaching me things, but not in the same innocent way that Ruby did.  It is definitely pushing me to my limits–recently I feel like a wet-behind-the-ears programmer more often than I can remember.
I’m building a little game in Haskell using OpenGL.  Innocently, I found out about Functional Reactive Programming and suddenly I’m on a trail learning about a “generalization of Monads called Arrows”, as well as combinators and functional composition in “lifted” spaces.  I’m not even sure I’m using the right words to describe what I don’t understand :)  Next, I decided I’d try loading a VRML file that I had created in Wings3D.  Haskell doesn’t have a VRML (”.wrl”) parser that I know of… so I started looking up parsers in Haskell.  ”Hmmm,” I wondered, “What’s this ‘parsec‘ thing everyone is talking about?”  Oh, it’s a “monadic parser combinator in Haskell” that other languages have apparently tried to emulate.
All I can say at this point is, “Wow.”  There is so much out there that I do not understand.  I thought I knew a lot about programming through 6 years of university.  It turns out I had only scratched the surface.  Beware, there’s a rabbit hole underneath that grassy knoll!

Posted via email from Duane’s Quick Posts

Running Hipmunk Playground on Mac OS X

I’m experimenting with using Haskell for a 2D game project in one of my computer science classes.  It will probably involve the Chipmunk 2D physics engine (haskell has a binding to it called Hipmunk).  Hipmunk comes with a demo app called the Hipmunk Playground, and it is a wonderful little demo of OpenGL and Chipmunk in Haskell.

Unfortunately, Mac OS X has some austere requirements for graphical applications.  When I first ran Hipmunk Playground, the window would not respond properly to my keyboard and mouse inputs.  The solution, it seems, is to wrap the Haskell-generated executable inside a well-formed “.app” directory.  The (unrelated) wxHaskell library provides a nice shell script called macosx-app to generate the .app directory automatically.  Here is a sample Makefile that I now use to build Hipmunk Playground and put it inside the wrapper directory:
# Make the Hipmunk Playground application for Mac OS X
MacPlayground: Playground
utils/macosx-app Playground
Playground: Playground.hs
ghc –make Playground.hs
RunPlayground: MacPlayground
open Playground.app

Posted via email from Duane’s Quick Posts

Getting Started with Haskell: Cabal

Most languages have a nice package management system that helps install new software or libraries—Ruby has the “gem” system, Perl has cpan, etc. In Haskell, it’s “cabal”, and here is how you install it:

darcs get http://darcs.haskell.org/cabal-install
cd cabal-install
sh bootstrap.sh

In addition, you should occasionally use the “update” command to sync your local package listing with the centralized one:

cabal update

To install a remote package, simply use “cabal install “. For example:

cabal install happstack

Also noteworthy is that you can use cabal to install a package from the local directory. For example, if you’ve fetched something using darcs, you could procede to install it like this:

darcs get --lazy http://code.haskell.org/yi/
cd yi
cabal install

Update: To install yi above, I also had to install a package called “alex” which is outside the cabal system at this point. I used MacPorts, i.e. “sudo port install alex”.

Improvements to download-files command

I added a few improvements to the Ubiquity “download-files” command. It now checks everything on the page, including frames and iframes. Also, it walks through all of the CSS files and downloads image assets if they match the pattern you specify.

Visit Ubiquity Download Files on GitHub to see the code, or this gist to subscribe.

Ruby 1.9 is here

The first stable release of Ruby 1.9 is out… I’m downloading it now.  There is a nice comparison of Ruby 1.8 and 1.9 here.

Posted via email from Duane’s Quick Posts

What the Internet is Doing to My Mind

You know how teachers shifted from teaching rote memorization to teaching concepts sometime during the 19th or 20th century?  I think the Internet is causing me to shift in a similar way with regard to facts themselves.  I’m not sure if it’s all a good thing, but I just noticed for the first time that instead of thinking about facts, I tend to think about search terms.  In other words, my use of memory has been abstracted to a higher level: I don’t recall what I need to know, I recall what will lead me to what I need to know.

Is the (known) world becoming so big that we can’t contain it all in our heads?  Or are we just lazier now that there is a means to offload what we would otherwise have to memorize?  It’s probably some combination of both.
As my memory of details declines and my construction of queries improves, at least I have the innovations of the InnerSpace Foundation to look forward to.

Posted via email from Duane’s Quick Posts

Installing HappS

The premiere Haskell web application stack, HappS, is getting a considerable boost this week. Several Haskell developers are getting together to tidy things up and improve the packaging and documentation. I’m on the documentation team even though I don’t know anything about it. We’ll see if I can add any value :)

Anyway, I had a really difficult time installing the “HappS-Tutorial” package and wanted to lay down a few pointers for anyone else who may be having difficulty. After finding, downloading and installing Cabal (Haskell’s package distribution system) on my Mac, I tried to install the HappS-Tutorial package:

$ cabal install happs-tutorial


Unfortunately, there are some dependency problems in the tutorial as it currently stands but I didn’t find that out until after I had removed the “.cabal” directory in my home directory. Apparently that messed up some dependencies on my own system and caused cabal to think that packages were installed when they weren’t.

So, to make a long story short, if you get an error message like this:

Crypto/PBKDF2.hs:20:7:
    Could not find module `Data.Binary':
      Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
PBKDF2-0.3 failed during the building phase. The exception was:
exit: ExitFailure 1


You may have to go through the dependencies one by one (using the remarkable hoogle search utility) and manually reinstall packages like this:

$ cabal --reinstall install binary


Where “binary” is the particular package I needed in this case.

In case anyone has to go through the dependency hunting process like I did, here is a list of the HappS Tutorial dependencies.