[Haskell-cafe] New New newbie question/help

Brent Yorgey 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)
> and
> 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
type class.

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.

Good luck!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070627/d74c5aa8/attachment.htm

More information about the Haskell-Cafe mailing list