[Haskell-cafe] New New newbie question/help
byorgey at gmail.com
Wed Jun 27 11:46:27 EDT 2007
> Is it proper/ok to defines them as :
> fromIntegral :: (a::Integral) -> (b::Num)
> round :: (a::RealFrac) -> (b::Integral) ?
No; Integral, Num and RealFrac are type classes, not types. Think of a type
class as a "set of types" which all support certain operations. For
example, anything in the Num class must implement +, -, *, and a few other
things. So a type signature like (Integral a) => a means "any type a, as
long as it is in the type class Integral".
Is RealFrac is-a Num ?
Yes, any type which is in the RealFrac type class must also be in the Num
Does the order matters in (Num b,Integral a) => a -> b or
> (Integral a,Num b) => a -> b
No, the order of type class constraints doesn't matter.
With your encouragements, I'll keep pluuging. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe