Any need for a Python interface to Haskell?

Submitted by metaperl on Tue, 11/21/2006 - 3:57pm.

John Goerzen has created
a Haskell interface to Python and done a bang-up job.

However, it does not look like anyone has made Haskell available to Python.

I did get better search results using
Windows Live rather than Google. Thanks to Windows Live, I found epolyglot which employs Haskell Direct and demonstrates a possible route

Python - Haskell comparison: delete all files matching *m3u

Submitted by metaperl on Fri, 11/03/2006 - 5:24am.

Python is a not-bad language... much nicer than Perl. Not as rigid as Haskell. Many more libraries and applications than Haskell. And Python was used in this years winning ICFP as well. And Python stole list comprehensions for Python. And PYthon combined object, functional and imperative in a prettier more understandable way than Ocaml did.

Here is a script I whipped up in Python to remove all m3u files from my music dir... the shell 1-liner of

find ~/Music -name '*m3u' | xargs rm

failed because find did not properly escape spaces and parentheses.

So here's my script:

#!/usr/bin/env python

from path import path

p = path('/Users/tbrannon/Music')
print p

dirs = p.walkdirs('*')
print dirs

for d in dirs:
for f in d.files('*m3u'):
print f

What would the Haskell look like?

Languages for ICFP 2006 posted --- C++ wins? or Haskell

Submitted by metaperl on Wed, 10/18/2006 - 7:03am.

If you look at the winning team's language list:

they listed C++ first. and Haskell second.

Does large-scale software development in Haskell suffer from lack of objects?

Submitted by metaperl on Tue, 10/17/2006 - 1:08am.

Would someone with experience in designing large Haskell systems comment on whether it becomes difficult to manage or understand large Haskell programs due to lack of objects and the benefits of objects (such as inheritance).

I think type classes have polymorphism covered.

Python job or Perl job? The quandry is solved

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

Since all language suck more than Haskell and since you suck at haskell, just get the job that pays more.

I recently have had this thang for Python, swearing it was the greatest thing out there but now I realize where the real thing is.

So it's really just bread-winning unless I have finally earned a haskell job.

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.

to build wxHaskell, or what is the best GUI library on Haskell?

Submitted by jmuk on Fri, 10/13/2006 - 12:27am.

I just tried to build wxHaskell-0.9.4 on my GHC-6.6 system, but I failed.
The error message is follows:
Bad interface file: out/wx/imports/Graphics/UI/WXCore/Types.hi
Something is amiss; requested module wx:Graphics.UI.WXCore.Types differs from name found in the interface file wxcore:Graphics.UI.WXCore.Types

I am confused by this error message at first, but finally I understand. In GHC 6.6, a restriction that you cannot use two packages together if they contain a module with the same name has been removed. As the result, the package name is embedded into interface files (.hi files) too. Therefore, the interface files of wxcore package cannot be referred because they are different packages.

To solve this problem, you can install wxcore package at first, and then, build wx package with -package wxcore flag. The complete way is the followings.

1. edit makefile as follows:
1-a. -package-name $(WX) -> -package-name $(WX)-0.9.4 -package wxcore
1-b. -package-name $(WXCORE) -> -package-name $(WXCORE)-0.9.4
1-c. remove `wxcore' from the dependency of target `wx'
1-d. remove all dependencies of target `wx-install-files'
2. edit config/wxcore.pkg to eliminate dependencies of lang and concurrency because they are included in base(?)
3. make wxcore
4. sudo make wxcore-install-files wxcore-register
5. make wxcore-clean
6. make wx
7. sudo make wx-install-files wx-register

And then, I compiled some sample codes in wxHaskell, and confirmed they works.
The best way to fix this problem will be cabalization, but I did not try it.

By the way, is wxHaskell active? I see that they stops any actions. If it is inactive, what is the suitable GUI library for Haskell??

I tried to use gtk2hs, but I failed on my GHC 6.6 system. It uses obsolete Data.FiniteMap. I replaced it and corresponding functions as Data.Map, but other compile errors, for example `no such function: emptySet', occurs, and I gave up.

Are there any other libraries?

memcached client

Submitted by jmuk on Thu, 10/12/2006 - 9:07am.

I wrote two new modules on HaskellNet. One is JSON library and the other is memcached client.

Memcached is a distributed memory object caching system. see:

I take a look at the memcached protocol, and think it simple. So, I'd like to write them in Haskell. I have no confidence whether or not memcached client is suit to HaskellNet, but it will be something usable. I'll think later whether it should come with HaskellNet or not.

The code can be seen at

BTW, after writing my code, I found another implementation of memcached client written in Haskell.
That's the way the world goes.

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 :)

getContents with gnutls...

Submitted by jmuk on Sun, 08/20/2006 - 8:04pm.

GetContents like actions are hard to implement with gnutls. hsgnutls prepares `tlsRecv', but it blocks when there are nothing to be read. tlsCheckPending is said to check the lenth of `pending' (readable) buffer in gnutls, but it always returns 0.

I read `gnutls-cli', a telnet like gnutls command because it can read until there are something to be read. Then, I found that gnutls-cli uses select(2) to know whether reading is ready or not. Oops...

Next, I keep the Handle for tlsClient in TlsSession data structure, and use hReady :: Handle -> IO Bool to check if the tls session is readable. It seems to succeed when I test in ghci, but fails when using in other actions (like bsGetContents). The reason will be that the state of hReady cannot change so rapidly. For example,
*TLSStream> bsPutCrLf s (BS.pack "a001 CAPABILITY") >> hReady h >>= print
*TLSStream> hReady h >>= print

Then, I try to use hWaitForInput :: Handle -> Int -> IO Bool because it can wait some period. Now, it succeed to check with the waiting time of 500 miliseconds.

Are there any other (elegant) implementation of `GetContent' with gnutls?