metaperl's blog

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
here

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.