Friday, May 10, 2013

New Book: Parallel and Concurrent Haskell

I've finally gotten round to reading the draft for Simon Marlow's book Parallel and Concurrent Haskell all the way through.  I'd highly recommend it to anyone who's got intermediate experience with Haskell (read "groks monads and laziness well"), especially if they've never done any deep poking at multicore stuff. To list of some of the subjects: The Eval and Par monad, REPA is slated to be covered, obligatory forkIO/MVars, Chan, Async and the STM among others.

I think it's definitely worth the 40 bucks! Preorder it on OReilly

Monday, May 6, 2013

Things I wish I could tell FIRST Programmers

I just spent the weekend in St Louis and a few weeks ago was up in Duluth and at the University of Minnesota for FIRST Robotics.

This was tons of fun and I had a blast but I noticed a few things that really bugged me about the way that some of the other programmers handled developing their robot code. Because of this, I've decided to write a quick post about some things that I wish I could tell all of these programmers.

No one should see this as me criticizing their ideas/workflow, it's just my suggestions after 4 years of FIRST and 6ish years of programming.

Friday, April 26, 2013

JVM Dilemmas

Working at GroupLens means that I spend a lot of time in JVM land. For me, this isn't very much fun, I expect quite a bit more from my programming languages than what Java offers. Because of this, I've decided that picking up a JVM language this summer/fall would be good for my sanity.

Monday, April 1, 2013

Fun with the List Monad

The list monad is a fun little tool. It lets you do the moral equivalent of logic programming without actually using a real logic programming languages. How you may ask?

Well since every bind on a list of length n runs the computation n times you backtrack, however since Haskell is lazy, only necessary computations are recomputed.

How is this useful in the slightest?


{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.List
import qualified Data.Text as T --String is ungodly slow
import qualified Data.Text.IO as TIO
compute ls t = TIO.putStrLn.head $ search ls t 0
search _ t c | t == c = [T.pack $ show t]
search nums targ curr = do
  guard . not $ null nums
  n <- nums
  (op, name) <- [((+), "+"), ((-), "-"), (div, "/"), ((*), "*")]
  when (n == 0 || curr == 0) $ guard (name /= "div")
  res <- search (delete n nums) targ (curr `op` n)
  return $ T.concat [T.pack$show curr,name,T.pack$show n," =>\n", res]

(Yay for HsColour for outputting such pretty HTML)

Anyways, here's a quick example of a program which computes a way to use the simple arithmetic operators to compute a way to take a list of numbers and compute the target. Eg compute [1, 2, 3] 6 = "2 * 3" or "1 + 2 + 3"

Feel free to play with it, it's kinda fun.

How this actually works is dead simple. We have a running total of the current value, and when that equals are target, we return a Text representing our target.

Otherwise we take a number from our pool of remaining numbers, and grab an operator and modify our current value with num `op` current and recurse.

This is really all that's going on algorithmically. The list monad is haskell's answer to scheme's amb operator. And since it has the word monad in it it's much cooler ;)

Please question, comment, or respond.

Sunday, March 24, 2013

Random Haskell Code

I was having some trouble sleeping a few nights ago, so I wrote a chat server in Haskell shrug I figured it might be fun to share it so here goes!

Tuesday, March 19, 2013

PL Trivia

I just found this site today: http://www.malevole.com/mv/misc/killerquiz/

It shows various photos and you have to guess whether the person is a language designer... or a serial killer.

It's a little horrifying that I scored 6/10 but oh well...

Tuesday, March 12, 2013

The "I have no homework 423"

I had no homework tonight so here's a little 423 variation I decided to mess around with.

video

I look oddly angry... I promise I'm not.

Also this one
video