26Jan

Scientific Progress!

Posted by Elf Sternberg as Uncategorized

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not ‘Eureka!‘ (‘I found it!’) but rather ‘hmm….that’s funny…’” – Isaac Asimov

I had that very experience this evening.  It’s funny what gives you insight, what makes you understand.  I’ve been trying to wrap my head around the whole idea of Haskell’s type, typeclass, data, and instance, and just not getting it.  It wasn’t clicking for me at all.  I went back to chapter 2 (!) of Real World Haskell and started working through the problems again, and I hit this example:

ghci> lines "the quicknbrown foxnjumps"["the quick","brown fox","jumps"]

And being a good little student I meant to type:

ghci> :t lines

But being a lazy student I used keyboard shortcuts to summon the previous example. I ended up with this:

ghci> :t lines "the quicknbrown foxnjumps"
lines "the quicknbrown foxnjumps" :: [String]

And the lights totally went on. Because I realized that the expression to the left of the :: symbol is not “an lvalue”, it’s just a value. If you don’t understand Haskell, why that’s a big deal might not make sense to you. But I get some of it now.

Comment Form

Recent Comments