PDA

View Full Version : Haskell Beginner Question


Baalthazaq
11-27-2003, 11:37 AM
Alright,

I don't want to make too many new topics and flood the boards with questions, so I'll just extend this every time I have a new Haskell question instead.

Just wondering what the difference between => and -> is in Haskell.
I'm not finding much useful stuff. It's been thrown into a practical excercise without any explanation. I don't think we're expected to know what it does yet, and just use it but I'd rather know.

Am I right in concluding it has something to do with polymorphism? That's about as much as I can gather.

Thanks in advance for any help.

The context is the following:
eq_Pair :: (Eq a, Eq b) => Pair a b -> Pair a b -> Bool

Baalthazaq
11-27-2003, 11:42 AM
In reply to my own question:

I think it basically means "if we can".

Basically it looks at the first part of the statement, and "if we can do it" it moves on to the rest of the statement. It's usually used for comparing things if I'm not mistaken.

Anyone want to correct me if I'm wrong?

sicarius
11-27-2003, 11:33 PM
no. what it is doing is saying that the variables a and b are of type Eq.

Therefore your Pair are made up of two Eqs.

This just allows you to specify the type for the arguments being used in the Pair constructor, otherwise you would be implying that they were of a generic type.

jemfinch
12-31-2003, 07:16 AM
sicarius: s/type/typeclass/ and you're right. Eq isn't a type, but a typeclass.

Jeremy