metaperl's blog

What advantage does Haskell have over a "typed" language like Java or C++

Submitted by metaperl on Fri, 09/02/2005 - 7:01am.

I was in a job interview for a Perl position and I volunteered some information about learning Haskell in my freetime since it has improved my Perl programming so much.

Then my boss asked me this: "what advantage does programming in Haskell have over Java or C++. They have strong typing don't they"

And my answer was: "they don't have type inferencing" --- but is not advantage, only something different it has. What would you say are the advantages of Haskell over Java or C++?

is darcs being maintained

Submitted by metaperl on Mon, 08/29/2005 - 3:31am.

I noticed some discussion on #haskell about darcs needing a new maintainer. Should I look at other options for version control that are better maintained and supported or is this just rumours about darcs? I hope they are.

Decoupling and Encapsulation: how do they interplay

Submitted by metaperl on Sat, 08/20/2005 - 6:38am.

I recently found a fascinating job but was dismayed when they said they expected people to use HTML::Mason (a jsp/could-fusion/php-like embedded HTML generator for Perl) and MySQL. Instead of verbalizing my dismay, I decided to finally write the ultimate document on why inline HTML generation and MySQL are Bad Choices ... that's right

In doing so,I had to be tongue in cheek about one thing. I value decoupled program elements and that's why I like Haskell... it gives one maximum ability to define small pieces and maximum operators for flexible composition, allowing one to form complex computation strategies from small, well-tested, well-understood pieces.

Of course, the problem becomes: decoupling means that you have weaker encapsulation.

So we arrive at the battle of the buzzwords... which is better: decoupled program elements or encapsulated ones?

any feedback on this simple financial calculator?

Submitted by metaperl on Fri, 08/19/2005 - 4:59am.

-- bills paid on the 15th of the month
on 15 = [100.00,110.00,60.00,52.00,100.00,150.00,450.00,240.00,68.45]

-- bills paid on the 30th of the month
on 30 = [300.00,75.00,150.00,125.00,125.00,150.00,100.00]

-- total paid on 15th of month
s 15 = sum (on 15)

-- total paid on 30th of month
s 30 = sum (on 15)

-- total monthly bills
tot = (s 15) + (s 30)

your code is not generalized until its types are

Submitted by metaperl on Fri, 08/12/2005 - 2:00pm.

I was staring at chapter 10 in SJT's text and realized that each time he created a more general function, it was done by creating a function which worked on any type whereas the original function was "hardcoded" to process only the type of data.

well, there goes 8 hours up in smoke

Submitted by metaperl on Fri, 08/12/2005 - 4:13am.

I took a day off work to get an eye exam and then headed to Jamba Juice to get 4 32-oz containers of fresh-squeezed juice. I headed home, ready to continue my Haskell explorations.

For some reason, I decided to take just a few minutes to try to get my old laptop ip masquerading to my main machine, since I had never managed this before.

Well, boy was that a mistake. I tried guarddog and guidedog. I tried google and IRC. I tried man route. I tried shorewall. 8 hours later:

- no better at Haskell
- no ip masquerading
- severely frustrated

The lesson: pick your battles. Linux is an experimenters toolbox. It is very free and open and configurable and you will often have to do research to get anything done (unlike Windows). This is great at times but tempting at others.

I need to realize that I am a software developer who wants to transition from Perl to Haskell and stay focused on that. I will never be as good at networking as the sysadmins at work and I dont need to waste my time in such efforts.

had I bought a wireless bridge like linksys tech support said, or had I tried out the wireless card I bought, I would have had an easy and predictable path through unknown territory.

I havent even mentioned that a normal ethernet cable doesnt work. If it had not been for the phone tech who came out to fix my "phone problem" (ok, ok, sorry my laundry disconnected my phone and it was buried under 4 feet of laundry so I never noticed it), ... anyway. the phone tech saw I was using Linux and told me about his 4-processor Itanium and how Microsoft charges 2700 for its Windows version for this machine. He noticed the wire running between my machiens and told me I needed something called a crossover cable... yet another unknown thing...

So: pick your battles, stick to your guns and cherish your free time for what you need to get done... even if that means iconifying your IRC client, being a bit dumb about a bunch of things not related to your goal... and I didnt mention the lady who I told I wanted a vegetarian plate at the restauranet. I lift up the scrambled egg and there staring at me if roasted beef... she tried to scrape it out of the bown and give it back to me.... and yes, there were still beef chunks in there after her attempt to save some dollars... and of course I would've been urling my guts out for hours had this vegetarian body accidentally taken in that garbage.

Rule #2: dont play in the fire unless you dont mind getting burnt. Pick vegetarian restaurants if you are a vegetarian. If they serve meat at all, then stay the hell out... unless you like carcass grease mixed in with your veggies. Or better yet, cook for yourself so you arent wondering what the cook did with his hands, or what tasty ingredients they added that due nothing but constipate and poision the body (ie. table salt, distilled vinegar, white flour, etc etc).

see what your task is a function of - it may be a chunk instead of just an element.

Submitted by metaperl on Wed, 08/10/2005 - 8:36pm.

One reason this task was so difficult for me is that you sort of had to switch gears... up to now in the book every problem involved moving through the list or making decisions about the list one element at a time. In this particular problem, a decision had to be made on a chunk of the input list not just one element.

So, this is the first case where I had to get a chunk of the string and develop code that operated as a function of a chunk of data as opposed to one piece.

my top-level description technique failed me

Submitted by metaperl on Tue, 08/09/2005 - 7:18pm.

I was trying to work problem 7.26 in Simon Thompson's "Craft of Functional Programming":

given a STRING search for SEARCH and replace with REPLACE

Now, having fallen in love with the ability to give top-down specs for things in Haskell, I tried this for starters:

substr search replace input = pre ++ sub ++ post

meaning given an input string, we have the unaltered pre and post parts and a conditionally altered sub part.

But I could not take this top-down description further without searching the string numerous times. John Goerzen was nice enough to come up with this solution for me:


I'd recurse over the string, dropping the first character on
each recursion
then I'd compare the first (length search) characters to (search)
If they're the same, I'd return (replace ++ xs)
otherwise return x:self xs


subst search@(s:ss) replace input@(i:is)
| chunkSearch search input = replace ++ (drop (length search) input)
| otherwise = i : subst search replace is

-- presumes length a < length b
chunkSearch a b = a == take (length a) b

Well, I like this solution, but I'm a bit worried that my top-down approach fell through on me. It's interesting how he simply builds the pre part on the fly and then pastes the post part in with replace

Spelunking Darcs for the Good of MissingH???

Submitted by metaperl on Thu, 07/28/2005 - 7:39pm.

I have not grokked the darcs source code, but from using it, I am willing to be that it has some very good file and i/o libraries that would be generally useful.

Has anyone considered factoring out this functionality into MissingH for re-use elsewhere?

Drupal is not Burger King!

Submitted by metaperl on Sun, 07/24/2005 - 11:06am.

The old motto of Burger King when I was growing up was: "Have it Your Way"

Drupal is a nice system, but note what I must do. I must visit this website, click on what I want to do and then fill out a bunch of forms to get my content up.

I have written two things recently. One on the Haskell pipeline paradigm:

And another on the ease with which top-down development is in Haskell:

But I did not savor the prospect of dealing with Drupal's limited HTML... in other words, I wanted to HAVE IT MY WAY.

Why couldn't I just open up a directory under a tree in a shell, code up my text and/or HTML and then have some sort of skulking process notice that a new directory was there and add the content to the system?

Maybe only after a darcs push was done should this happen so that you can develop and only publish when you push.

But at anyrate I envision a system that is built up from a large collection of handwritten directories without visiting websites and filling out forms, blah blah.