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.
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:
from path import path
p = path('/Users/tbrannon/Music')
dirs = p.walkdirs('*')
for d in dirs:
for f in d.files('*m3u'):
What would the Haskell look like?
If you look at the winning team's language list:
they listed C++ first. and Haskell second.
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.
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.
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.
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?
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: http://www.danga.com/memcached/
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 http://darcs.haskell.org/SoC/haskellnet/HaskellNet/Memcache.hs
BTW, after writing my code, I found another implementation of memcached client written in Haskell.
That's the way the world goes.
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:
"""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:
if i == 0:
elif l[i-1] == neg:
I know my eyes are going to water when I see that elegant, purefuly functional solution :)
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?