[Haskell-beginners] Help with types

Thomas Davie tom.davie at gmail.com
Thu Apr 23 10:40:49 EDT 2009


On 23 Apr 2009, at 16:25, Daniel Carrera wrote:

> Thomas Davie wrote:
>>> It looks like (/) is happy with Num but doesn't like Int. This  
>>> surprises me. I would have thought that Fractional is a kind of  
>>> Num and Int is a kind of Fractional
>> Int isn't a Fractional because it can't represent fractional numbers.
>
> Sure, but any integer is trivially also a fraction, so I would think  
> that it would be an acceptable input for (/). On the other hand, if  
> it is at all possible for a Num to contain something that cannot be  
> converted to a fraction, then a Num should not be a valid input for  
> (/).

The problem here is that (/) also *outputs* that type – if you can't  
represent a fraction, how do you give the result of 1/4?

Bob


More information about the Beginners mailing list