You are not logged in.

#1 2010-05-03 02:36:16

absolutezero1287
Member
Registered: 2008-11-13
Posts: 133

Haskell help

Hi all. I changed majors to computer science and learned Java last semester. However, after reading about haskell and trying it out a bit I pretty much fell in love with the language. That having been said, I am struggling with haskell. Are there any haskell tutorials aimed at people with Java experience? I've read the others and they don't really help. It also doesn't help that I'm not familiar with discrete math (I take that course next semester).

Offline

#2 2010-05-03 02:57:59

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: Haskell help

I supposed you already check this page and this.

Offline

#3 2010-05-03 03:32:42

absolutezero1287
Member
Registered: 2008-11-13
Posts: 133

Re: Haskell help

n0dix wrote:

I supposed you already check this page and this.

Yep. I've also read "Learn You A Haskell For Great Good." I find myself having trouble grasping certain concepts. I also have some issues with indentation. Whenever I write a program ghc will complain about indentation issues 99% of the time. Its quite maddening.

Just one of the things that confuse me:
A-  gauss :: (Int, Int) -> Int
B-  gauss :: Int -> Int -> Int
**Why is A different from B?

**Here's the actual function: guass min max = ((min + max) * max) `div` 2

Offline

#4 2010-05-03 04:02:14

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: Haskell help

A-  gauss :: (Int, Int) -> Int
B-  gauss :: Int -> Int -> Int


In A you are using Tuples to pass just an argument. http://en.wikibooks.org/wiki/Haskell/Li … les#Tuples
In B you are using two arguments. Your example uses this method.

Offline

#5 2010-05-03 05:33:40

absolutezero1287
Member
Registered: 2008-11-13
Posts: 133

Re: Haskell help

Ah, I understand now. I think I'll read the wikibooks entry. That is one resource that I have yet to try. It seems better organized.

One last question, though: Can Haskell be object-oriented?

Offline

#6 2010-05-03 11:12:44

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: Haskell help

That's a tricky question: it depends on exactly what you take to constitute being object-oriented. You won't naturally encounter people referring to any functional languages (or the functional idioms of mixed languages) as object-oriented. People tend to regard those as contrasting paradigms. On the other hand, there are some salient similarities between OO programming and functional programming in general, and even more salient similarities between OO programming and Haskell type classes in particular.

So short answer is probably: no, but in practice we might have understood OO slightly differently so that the answer was yes.

Offline

#7 2010-05-03 13:09:01

absolutezero1287
Member
Registered: 2008-11-13
Posts: 133

Re: Haskell help

I read some of the classes tutorial from the haskell site (A gentle intro to Haskell, sec. 5). Type classes seem fairly interesting but its a far cry from the object-oriented programming I'm used to in Java. I was always under the impression that OO and functional programming weren't mutually exclusive.

Offline

#8 2010-05-03 14:16:16

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: Haskell help

absolutezero1287 wrote:

I was always under the impression that OO and functional programming weren't mutually exclusive.

Two interesting links:
1. http://www.haskell.org/haskellwiki/The_ … rogramming.
2. http://www.haskell.org/haskellwiki/OOP_vs_type_classes.

Offline

Board footer

Powered by FluxBB