[Haskell-cafe] Other instances of Integral

Miguel Mitrofanov miguelimo38 at yandex.ru
Fri Nov 27 08:17:13 EST 2009



Tsunkiet Man wrote:
> Hello,
>  
> I would like to ask wheter there are other instances of the class 
> Integral?

Lots of them. You can define a few of them yourself, you know.

> And I would like to ask what the difference is between the 
> following functions: SomeFunctionA :: (Integral a) => a -> a, 

Perfectly correct.

> SomeFunctionB (Integer a) => a -> a, SomeFunctionC (Int a) => a -> a.

Both incorrect.

Integral is a class, but Integer and Int are types.

> What I do know is, that the Int can have underflow and overflows, 
> however I don't actually see the difference (and I can't really find a 
> difference on Google as it gives me results that aren't really relevant 
> to my question) between prefering to use an Integral a when I've already 
> got an Integer.

Sorry, didn't understand your question.

> (Assuming I didn't missed the definiton of a Integral, 
> which has by definition (I looked it up on Google: 
> http://www.zvon.org/other/haskell/Outputprelude/Integral_c.html) has two 
> instances)

No. It makes no sense to say "by definition ... has that number of instances". Instances of class are not included in it's definition and could be defined separately.

> Can someone explain to me what kind of advantages and disadvantages I 
> would get when substituting SomeFunctionB for someFunctionA?

Working program would certainly be an advantage.

> Thank you for your help!
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list