my impression of The Haskell Road To Logic, Maths And Programming

Submitted by metaperl on Mon, 03/28/2005 - 9:32am.

[07:23] [metaperl] The Haskell Road To Logic, Maths And Programming has a very seductive intro and table of contents... I am starting to realize that I am going nowhere in Haskell unless I learn to thi\
nk and know functions well... humbling after 5 years as a well-paid Perl programmer
[07:23] [RemiTurk] false = \x y -> y
[07:23] [RemiTurk] if = id
[07:24] [RemiTurk] not = flip
[07:24] [shapr] metaperl: I realize I'm not learning much if I don't get humbled on a regular basis.
[07:24] [xerox] metaperl: I am reading it too!
[07:24] [metaperl] xerox, do you like it?
[07:24] [xerox] metaperl: I'm just at page 28, good so far.
[07:25] [shapr] is one good place to find humbleness. I also like to put forth my ideas in my blog and here on #haskell and ask people to poke holes. That mostly works.
[07:27] [xerox] metaperl: do you like it?
[07:27] [metaperl] I'm thinking about buying it
[07:28] [shapr] Isn't it free online?
[07:28] [metaperl] I think you are just playing with air until you lock in a rigourous command of logic and functions. And this book doesnt play around... it takes you right to the foundation and build\
s you up from there
[07:28] [metaperl] the first chapter and toc is
[07:28] [metaperl] all the other books give you a chance to fool yourself about knowing haskell --- not this one
[07:28] [metaperl] this book puts logic first and the language second
[07:28] [xerox] shapr: no it isn't :\
[07:29] [metaperl] all the others put the language first and hope you can build the logical reasoning... and it wont happen
[07:29] [shapr] Strange, I wonder where I got my ps.gz copy.
[07:29] [xerox] Its first example is a prime number test, it first prove to you some things -mathematecally- then implement it in Haskell, err, rewrites the proofs in Haskell :D
[07:30] [xerox] shapr: hm, it could be really.
[07:30] [xerox]

IRC snippets

Submitted by metaperl on Mon, 03/28/2005 - 8:32am.

[06:28] [autrijus] shapr: I'm changing the Pugs evaluator into a compiler
[06:28] [vegai] metaperl: yes
[06:28] [shapr] autrijus: yay!
[06:28] [autrijus] shapr: without touching a line in Eval.hs
[06:28] [shapr] wow
[06:28] [metaperl] ooooooooooooooooooooooooooooooooooooo
[06:28] [autrijus] shapr: simply by redefining the Eval monad and some TH magic

pumping out the functionality: language and community quality versus productivity

Submitted by metaperl on Mon, 03/28/2005 - 7:56am.

I think Haskell is the best computer programming language. I say so for two reasons. First, the community of people is excellent. I have yet to see one arrogant hothead anywhere. I have had discussions with some of the best Haskell programmers out there with absolutely no sense of them thinking they are better than me. Having been around Perl for 5-7 years, let me tell you, it is rough in Perl world. And there are plenty of arrogant, egotistical self-centered people in that community. In fact, I suppose being around them has made me that way as well. Haskell is also the best computer programming language because of it's wonderful mix of strong typing and pure functional approach. Finally, haskell is an amazing project to be the result of a community effort. How in the world could a group of people get together and not simply fight and bicker and never agree? Perl was a 1-man language. Emacs was a 1-man language. Ditto for Tcl, Python and I guess PHP. Unix was a 2-man project.

Anyway, now that I have said how great a _language_ Haskell is, let us note its chief deficiency. No available functionality. I remember 2 weeks ago Philippa was asking in #haskell about whether another person had a CGI extension to deal with cookies... Perl has had this since the dot-com era! Perl has, which is a huge library of modular functionality for a plethora of real-world scenarios.

Now, let's move on to PHP. From a purely linguistic perspective, PHP is a worse language than Perl: BUT from an application perspective, it outdoes Perl. I did not say from a modular/functionality perspective, but from the application perspective.

Applications are tools that are ready to run. Modules are pluggable units of functionality to build applications. Functions are even smaller units of pluggable functionality to build applications. Abstractly, applications, modules and functions all fill a gap. Applications fill the largest gap, modules fill the medium gap and functions fill the smallest gap. The relation between immediate ability to fill a gap and language quality is inversely proportional. Or, concretely: PHP sucks as a language, but rules in filling the biggest gap in apps. Haskell rules as a language, but sucks in filling application and modular gaps. And Perl is right in the middle. It is a decent language with great ability to fill in the middle gaps. It is not as composable as haskell and thus cannot compete in filling in small gaps. It lacks good, out-of-the-box applications like phpMyAdmin and Drupal and postNuke, and phpBB.

/me dons flame-retardant vest.

The Essence of Functional Programming by Wadler

Submitted by metaperl on Tue, 03/22/2005 - 4:47am.

This article by Wadler is really quite astounding:

He shows how to create variations of an interpreter using monads and discusses the superiority of the monadic approach of the CPS approach.

Here is

Citeseer reference to the article

Parsec sample problems

Submitted by metaperl on Tue, 03/22/2005 - 3:29am.

I need some parsec help... the Main.hs in the intro examples has some issues. First it required an import Char for the digitToInt function... I added that... now the function factor is calling a function parens but there is no such function... changing parens to matching (another function) does no good as it yields type errors... the Parsec distro Main.hs is

Fun with sections

Submitted by boggle on Mon, 03/21/2005 - 6:14pm.

Still being quite a haskell newbie, I just got a lesson about sections and argument order. I wrote something like the following code in a small program for calculation the maximume queueing time of packets on a CAN bus system. Try out for a mild smile:

some_list = [0..5]

pifilter p i = filter (p (some_list !! i))

main = do
{ putStrLn $ show $ pifilter (<) i some_list;
putStrLn $ show $ filter (< si) some_list
} where i = 2; si = some_list !! i

While at first glance the two lines look like they should do the same, they include two inverse filter predicates (si <) and (< si).

BTW why does indentation get messed up inside <code></code> blocks?

the important thing when programming in Haskell is to be sure to do nothing

Submitted by metaperl on Sat, 03/19/2005 - 2:00pm.

Spend your time defining and composing. If you are trying to get something done in 2 lines, then you are trying too hard and have not separated out the task fully.

It's hard for imperative-trained programmers to grasp this, but it is vitally important.

Haskell can only do one thing at a time... so relax

Submitted by metaperl on Thu, 03/17/2005 - 4:34pm.

Unlike an imperative language, Haskell is purely functional. This means when you look at something, it will (a) always return the same output for certain input (b) only return output based on the input you are looking at (c) do nothing but return output.

This means each expression is Haskell is referentially transparent and stands on its own. Understand the function in an expression and you understand the expression.

Haskell puts the complexity of programming in the right place

Submitted by metaperl on Sun, 03/13/2005 - 8:39am.

Every useful programming language has an area of complexity that you must overcome to become comfortable with the language. For Perl, you need to relax your ideas about regularity and consistency and learn to read and write Perl instinctively and trust that all of the exceptions and special cases will make as much sense in Perl as in English.

Haskell is very much a "back-end" language. What I mean is that the language just sits back and waits until you have everything lined up in a clean chain of well-typed functions. It won't do anything but keep spitting back your code at your until you have your problem reduced to something expressible in expressions.

This means you spend a lot of time with the type checker. And possibly a lot of time with making sure that your IO can make it through the snake's tube of a Monad before getting into yor program.

So, Haskell can be a big turn-off to someone who needs a language which, by Haskell standards, oversteps it bounds. If you want to mix IO and your program, If you want to quickly setup a webshop and need easy CGI processing, or any of a number of things that are highly available in languages like Perl, Python, Ruby, Tcl, PHP, then Haskell seems like a huge stumbling block.

But the way that Haskell quarantines I/O. The hurdles that it puts you through are there for some very very good reasons. The more experienced you become with it's advanced features such as Monads and combinators, the more you see how to crisply and accurately separate wheat from chaff, cause from effect, and smoke from fire.