Take for example the fromIntegral function:
fromIntegral :: (Integral a, Num b) => a -> b
To check whether it is:
Integral
Num
We can use :info fromIntegral to find out.
It turns out it's standalone.
But why? Why wasn't it made to be part of either the Integral or Num typeclass (or some other typeclass)? Is there any good reason for it or is it more a matter of taste?
The answer for this example will help me answer the same question in general when designing my own custom type classes and functions.
fromIntegral is defined as
fromIntegral = fromInteger . toInteger
The two functions are in Num and Integral classes respectively. When you include a function in a class, you're saying that it might to be defined differently for different types. fromIntegral does not.  
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With