Strange Loops

No Matter Where You Go, There You Are

Haskell QuickCheck

| Comments

Had some problems with the ghc I built from darwinports. Initially when I tried it with the QuickCheck module, it failed with a missing symbol (from a shared object I think). Downloaded the prebuilt binary package for my mac off the haskell website. QuickCheck is pretty cool and I think it would be a nice tool to have in the testing toolkit of most mainstream languages.

From the example below, floating point addition isn’t associative and QuickCheck figured that out after 2 tests. Haskell language features seem well suited to this sort of specification type testing, strongly statically typed and purely functional. Not a substitute for unit testing but a very handy tool. I think of it as assertions on steroids.

– GHCI session
*Main> :load “Test3.hs”
Compiling Main ( Test3.hs, interpreted )
Ok, modules loaded: Main.
*Main> quickCheck prop_Foo
OK, passed 100 tests.
*Main> quickCheck prop_FloatAddition
OK, passed 100 tests.
*Main> quickCheck prop_IntAddition
OK, passed 100 tests.
*Main> quickCheck prop_FloatAssociativeAddition
Falsifiable, after 2 tests:
3.5
-3.3333333
-1.25

– Testing out QuickCheck on GHC6.4
module Main where

import Test.QuickCheck

prop_IntAddition :: Integer -> Integer -> Bool
prop_IntAddition x y = x + y == y + x

prop_FloatAddition :: Float -> Float -> Bool
prop_FloatAddition x y = x + y == y + x

prop_FloatAssociativeAddition :: Float -> Float -> Float -> Bool
prop_FloatAssociativeAddition x y z = (x + y) + z == x + (y + z)

prop_Foo :: Bool
prop_Foo = foo == 1

foo :: Integer
foo = 1

Early to Bed, Early to ….

| Comments

Whilst bunking with E and S down in San Francisco, I slept early every night because both of them are early sleepers. Sleeping early meant waking up early and I felt more energetic and focused. Since getting back, I’ve been going to bed later and later (on average around 1am). If I slept earlier, I believe my days will be more productive.

Ruby Monads

| Comments

Inspired by this moonbase entry…

It would have been nice to just specify bind(f) but that didn’t seem to work as ruby parameters appear to be strictly evaluated.

irb(main):001:0> require 'monad'=> trueirb(main):002:0> def f(x); x + 1; end => nilirb(main):003:0> IdentityMonad.wrap(1).bind(method(:f)).bind{|x| x + 2}.value=> 4irb(main):004:0> 

class IdentityMonad
attr_reader :value
def initialize(value)
@value = value
end
def IdentityMonad::wrap(value)
new(value)
end
def pass
yield @value
end
def bind(p=nil,&blk)
if block_given?
IdentityMonad::wrap(blk.call(@value))
else
IdentityMonad::wrap(p.call(@value))
end
end
end

Feeling Bored…

| Comments

I can’t shake off the feeling. I’m bored. No longer interested in what I do. I came to this (not so) sudden realization this Monday afternoon at about 3:14 pm. It reminds of the line from the kurt vonnegut graduation speech hoax,

“The real troubles in your life are apt to be things
that never crossed your worried mind, the kind that blindside you
at 4 pm on some idle Tuesday.”

Cleaning up the html mockup made me realize that I’ve just become a very underutilized engineer. To put it bluntly, any monkey can do my work at the moment. It just requires me to grind through it and it is neither an interesting problem or intellectually stimulating. I’ve trained myself to deal with mind-numbing work but only for a limited period of time. I’m now past due. When that happens, I’m become both belligerent and unhappy. It’s taking me a greater amount of energy to put up my mask.

This boredom is causing me insomnia. I’m up late playing with little things that catch my interest (right now it’s ruby! go ruby!). I’m trying to go to bed by 11 but without any success.

I keep going through the different scenarios in my head. Quit or stay. There are some reasons for me to stay but …………. There are some tricks I can use to keep me moving but it’s getting harder to get up everyday. What are my options? I don’t know. I don’t know. I don’t know. <sigh>

Arrrr!

| Comments

Your pirate name is: Red Davy Kidd      

Passion is a big part of your life, which makes sense for a pirate.Even though you’re not always the traditional swaggering gallant, yoursteadiness and planning make you a fine, reliable pirate. Arr!

(Formatting got messed up, this is the best I could do. Take the quiz here)

Talking About a Revolution…

| Comments

With the dominance of XBox and PS2 over the GameCube, most people have counted Nintendo out. With the hype of the XBox 360 and PS3, the Nintendo Revolution might just surprise more than a few people. Check out this video of what the Revolution’s controller is supposed to do. I think it’s pretty frigging cool. Hopefully Nintendo will have the right games to take advantage of it.

I know I’m excited by this development.

A Tale of Two Apples…

| Comments


iPod Nano
Originally uploaded by signal11.

I brought the nano into the office this week and people have just been stunned by it. It’s hard to get a sense of the proportions when looking at photographs of it (even when it’s held next to the regular iPod). An amazing piece of engineering by the apple team. A bold gutsy business decision on their part to get rid of their best selling mini line in favor of a brand new product line.

I’m saddened by apple’s unstated policy of pushing it’s independent resellers out of business though. It’s depressing to see this happening from a company with great products. Is this what it takes to survive in business today?

Impulsive Impulsive!

| Comments

I may have been overly impulsive getting textdrive to do my hosting. After talking to a colleague today, I discovered nearlyfreespeech. If you’re looking for extremely low cost hosting that will ramp up with your needs, they have a pricing model that might suit your needs. You only pay for as much bandwidth and space as you need. There is also dreamhost which appears extremely generous with bandwidth and space (especially if you sign up for their two year plan).