views:

328

answers:

7

I know this question may sound silly, but I am learning (at least trying) Haskell for about 4 days. I've already finished to read http://learnyouahaskell.com/, and now I am investing time in: The Haskell Road to Logic, Math and Programming, and things got really complicated for me. I don't have experience in functional programming, just some basic knowledge on Lisp.

Even though I understand the concepts, when I have to write a not so basic piece of code, there's a total darkness and I cannot build a plan in my head. It seems that there are a lot of ways to accomplish a certain task, but I cannot express myself.

After 4 days of python, I could've write complex scripts (not 'pythonic', but they did work). After 4 days in haskell, I am ... almost blank.

Any suggestions on how to improve my functional skills ? How long did it take for you to fully grasp Haskell ?

+3  A: 

Well, after 2 years I still don't fully grasp everything about Haskell. I can write "advanced" programs (after ca. 2-3 months of starting to learn Haskell), but people keep coming up with new stuff to learn, which is part of the fun of Haskell :)

As for how best to learn, I always like to learn by doing. Browse through the code of something you're interested in on Hackage (something not to big) and then try to implement something like it yourself (or a subset). Pick a project you can keep adding more difficut layers to over time.

Phyx
+3  A: 

After a 150 hour functional programming course at university, we did

  • Sorting functions
  • Making binary tree's
  • Using/writing functions like map, filter, zip
  • .. might have forgotten something

So just basics I'd say, in about one month full time. Four days is nothing... I think you'll just have to write more code to get used to the functional programming way of thinking. Implementing everything from bottom to top, doing harder stuff as you gain experience.

Ishtar
+5  A: 

After about 2 years there are some parts of Haskell I know very well (Ptr stuff, vector libraries), some areas I know just enough to be dangerous (template haskell), and others I haven't touched (web frameworks, generics). Overall, though, I think I understand the language pretty well.

A large difficulty of learning Haskell is the (very steep IMO) learning curve. There are a lot of different inter-connected things you need to learn before you can be productive in the language, and because they're interconnected it's difficult to get a good sense of them without at least a few months of experience. My advice is to keep at it, and if you think you don't understand something, or that something deeper is happening, you're probably right. If you can't figure it out now, just move on and come back to it in a month or so. Eventually you'll make enough progress on multiple fronts that everything should become clear.

Like any language, the best way to make progress is to write code. It will take longer because Haskell is further away from the languages you already know, but it will be worth it.

John
+1  A: 

I think, the haskell learning curve is very strange. At the beginning, you understand almost nothing - more strange, at most points you want to apply your imperative knowledge (buffering, etc) you get told that you should simply forget anything about this.

After this phase, there comes usually the chapter in your book where you're teached the special flavors of haskell. At least at this point, your brain is supposed to burst and nearly nybod thinks:

How crazy can somebody be to develop something like monads???

But as soon, as you also grasped this, nothing stops you from understanding the rest, and you think soon, how difficult and verbose imperative programming was.

BTW, it took my 2 month to understand the basics, I started february 2010. But it took me again 4 month to understand some more difficult thinks like function paramters and resulting effects (specially the State monad was a miracle until I found a nice description on SO how IO works - just the same way ;), but I see quite new think everywhere.

FUZxxl
+1  A: 

It will be a while before Haskell will start making sense. I am in my second month of learning Haskell and this my second attempt in the last two years. This time around, I started off with The Little Schemer. Then I watched Giesel's videos. Reading the RWH for the first time was a disaster, but now it is making a bit of sense, so hopefully in another 6 months it would be clearer. The code I am able to write in Haskell is much more succinct.

Bottomline keep at it, it will take time, but it's worth it. BTW, IRC #haskell is a great resource to help you get up to speed.

My advice, find a small programming project and gnaw at it in Haskell. Don't worry too much about writing it the Haskelly way. Just start doing it Haskell..

Raghs
Did you try learnyouahaskell?
Peaker
+1  A: 

I studied at a Haskell-heavy university (Utrecht) and I liked Haskell a lot, so I took the following courses which all used Haskell:

  • Introductory FP (semester)
  • Grammars and Parsing with Haskell (semester)
  • Implementation of Programming Languages (semester)
  • Generic Programming (semester)
  • Software Construction (2 months)
  • Advanced Functional Programming (2 months)

I also was a TA (Teacher's Assistant) helping out with the practicals for Introductory and Implementation. And I wrote my M.Sc. on (Generic) Haskell.

So that seems like an awful lot, but I 'got' FP somewhere halfway in the Introductory course. Having a strong math background helped in my case, so I was already used in breaking down problems into simple functions. As for writing real programs, writing a Go program in Haskell was a fun exercise to learn to work with monads (the GUI was in TclHaskell, ugh!)

yatima2975
+1  A: 

I'm by no means a Haskell expert, but I have two suggestions:

  • Take the time to play around with pure lambda calculus (or even SKI, if you are brave). Basically Haskell allows you to do the same things a little bit more comfortable and type-safe
  • Try to solve common problems, e.g. from Project Euler. But don't stop there, try to compare your code with other people's solutions.

The given estimations of 1~3 months to grok the basics seem realistic to me.

Landei
Just don't try to learn Haskell only from Project Euler. It's not a very good set of exercises for learning more than list comprehensions and memoization. There's a lot more to programming than that.
Carl
True, but it helps to get the step away from explicit recursion to higher order functions and list comprehension. Learning the list and set API is an important step, given how different imperative lists/sets work. At the same time you learn that cute one-liners can be terrible slow if you don't pay enough attention to the mechanics of the underlying data structures.
Landei
@Landei: Got any pointers as to what can be used to "play around" with pure lambda calculus?
Daniel
I was even more "hard core", doing SKI with unlambda and Lazy K language, but if you are not already crazy before, you are after using that. So personally I just read about Lambda calculus. I never used it, but http://thyer.name/lambda-animator/ looks interesting, especially as you can see different evaluation strategies. Another interesting one is http://lci.sourceforge.net/ which seems to be closer to Haskell, while the former has a more "lispy" syntax.
Landei