metaperl's blog

not everyone can dine at the Beverly Hills Social Club of Programming Languages

Submitted by metaperl on Mon, 10/16/2006 - 6:56am.

If you have adequate savoire faire, then yes, you can drive a rolls royce, eat caviar, listen to the best of music and dine with the most beautiful of women.

But most of us have to get buy of frozen tv dinners, pickup trucks and rock and roll.

Haskell is truly the creme de la creme of programming languages. But not everyone has a tight enough brain to deal with such elegance and quality. And Haskell, being the refined aristocrastic snob that it is, will not reduce its standards to suit the mere commoner. Relax my type checking? NEVER! Compute things that won't be in the final result? NEVER!

Average joes can do average things with their language but there's only one language which has taken first prize 3 years in a row in what might be the most hotly contested competition on Planet Earth... and only the Rolls Royce of languages could do it and that language is Haskell.

How to rewrite this list in Haskell?

Submitted by metaperl on Fri, 09/29/2006 - 9:51am.

I really miss haskell. But Python is not bad. It's easier to read than Ocaml. Not as fast as OCaml. But many more libraries. Haskell is for people who can think. I never quite made it over the hump with Haskell for some reason.

But anyway, I was wondering what a Haskell solution to this would look like. I'm sure it's just a one-liner making use of concatMap() and a binary decision function that returns a list as a function of it's inputs:

def retokenize(l):
"""Given a list consisting of terms and the negation symbol, retokenize() creates a list which
(1) changes negation symbols to AND NOT and
(2) inserts AND between two terms without an interceding
conjunction symbol. Examples:

>>> sqlgen.retokenize( sqlgen.tokenize("cancer drug").asList() )
['cancer', 'AND', 'drug']
>>> sqlgen.retokenize( sqlgen.tokenize("cancer - drug").asList() )
['cancer', 'AND NOT', 'drug']
>>> sqlgen.retokenize( sqlgen.tokenize("cancer drug therapy").asList() )
['cancer', 'AND', 'drug', 'AND', 'therapy']
>>> sqlgen.retokenize( sqlgen.tokenize("cancer - drug - therapy").asList() )
['cancer', 'AND NOT', 'drug', 'AND NOT', 'therapy']


o = []
for i, tok in enumerate(l):
if tok == neg:
o.append('AND NOT')
if i == 0:
elif l[i-1] == neg:

return o

I know my eyes are going to water when I see that elegant, purefuly functional solution :)

When perfect all-encompassing systems get the rug pulled out from under them...

Submitted by metaperl on Sun, 07/16/2006 - 1:31pm.

So I'm here at home, pissed. I really want to crank out a website, but dont want to be limited to generating HTML. Some website generators produce PDF files. And some allow for adding validation. And some allow for tagging of document parts so that you can re-navigate the documented based on some combination of tags. And unfortunately, the perfect document system was written before the web came out: LaTeX.

So LaTeX's idea of device independant did not include the web device. And that excellent system of document references, BibTeX did not include any concept of hypertext media types.


And now we get to Haskell. Is it the perfect language for building websites automatically? If so, then why is this site done in Drupal instead of in Haskell?

"no more complex statement in any language"

Submitted by metaperl on Fri, 07/07/2006 - 7:14am.

My instructor here again made a stimulating statement: "the most complex statement in any language is the SELECT statement: you can group, multiply, format and more"


"You don't learn programming by theory, you learn it by hacking"

Submitted by metaperl on Wed, 07/05/2006 - 2:13pm.

I'm in a training course for MS SQL Server 2005, and the teacher said: "how did I learn programming? I went to a magazine and typed in some code and watched it run. You don't learn programming by theory, you learn it by hacking."

I bit my tongue because I'm sure many Haskellers (mathematician like Cale and physicists like David Roundy) did learn Haskell by placing theoretical expectations on how the language should work from a theoretical perspective and then seeing how haskell implemented their theoretical expectations.

What is meant by "cores" in microprocessor terminology?

Submitted by metaperl on Tue, 07/04/2006 - 3:01pm.

This post is somewhat off-topic, but I think it relates to Haskell enough to post here, so please indulge me.

I was reading an article on Erlang. In the section entitled Scalable Is the New Fast, it was said:

These days, you’re much less likely to get a chip that’s twice as fast, but you may get one with twice as many cores.

So my question is: what is a core and how does it affect hardware performance?

And to bring this post into Haskell context, is there some way for Haskell programs to execute faster as the machine it runs on gains cores?

hot snippets

Submitted by metaperl on Fri, 06/02/2006 - 3:26pm.

6/2/06 [14:23]

sequence [] = [];
sequence (x:xs) = do x' <- x;
xs' <- sequence xs;
return (x' : xs')

Does Haskell naturally break off into multi-tiered development?

Submitted by metaperl on Fri, 06/02/2006 - 11:11am.

It seems that Haskell's ethic for putting a gate between I/O and its referentially transparent and strongly-typed functions means that the concept of
multi-tiered architectures is something of a no-brainer.

There are a few web frameworks and web apps in Haskell - HApps, Flippi... do these map naturally and easily onto multiple tiers?

Are there other examples of multiple-tiered apps for Haskell?

Haskell - guardian of functional purity but violator of software engineering purity?

Submitted by metaperl on Sat, 05/13/2006 - 2:07pm.

Yesterday, after 1 year of studying Haskell, I tried to write my first program involving I/O. I decided to convert a Perl program that I had written which provides lookup of state names via their 2-letter code and vice-versa. A day later, I had something written, but was worried because all of my functions were using fmap to pull things out of the IO monad. In other words, my entire library reeked of I/O.

The next day, Cale Gibbard wrote a very nice version of my program which relegated the IO to a single function.

But the thing is, you still have to use my module from the main program with the awareness that the data is coming from an IO source. Now, a basic principle of software engineering is to separate the interface from the implementation. There is no way to use the Haskell implementation of my module without full knowledge that said module is returning me data that is coming from I/O... outside of using something called unsafeIO which I know nothing about.

why does this matter?
Let's say I have a function which does something to a list of functions of type (String -> String) but one of the functions has to open a file to get its string:

sfnProc :: [(String -> String)] -> [Int]
sfnProc = map (\f -> length f)

so the problem becomes that the one function that returns a string via I/O cannot be used opaquely: the referential transparency of Haskell is killing need for opaque API of software engineering.

Data ByteString Lazy is sweet

Submitted by metaperl on Sat, 05/13/2006 - 1:26pm.

outdoes sed and probably Perl too:
check it out it's great for processing huge data files that won't fit in memory.