PDA

View Full Version : what do => mean in haskell?



william2011
November 11th, 2011, 11:07 AM
what do => mean in haskell?

instance (Coarbitrary a, Arbitrary b) => Arbitrary (a -> b) where
arbitrary = promote (a -> coarbitrary a arbitrary)

Bachstelze
November 11th, 2011, 07:23 PM
http://en.wikibooks.org/wiki/Haskell/Classes_and_types

simeon87
November 11th, 2011, 07:38 PM
Short answer: it enforces constraints on what a and b can be. This is useful if you want your function to accept certain types but not all.

Long answer: read link above.

cgroza
November 12th, 2011, 12:16 AM
It gives a hint to the type checker that the types a b must have an instance of the a some class available.
For example, if you want to write a comparison function, your function may need types that have an Eq instance.

This kind of constraints are usually necessary only when the type checker does not have enough information to infer one.

schauerlich
November 12th, 2011, 01:46 AM
If you're familiar with Java interfaces, it's kind of like saying whatever type you have must implement a certain interface.