On 2009 Mar 20, at 20:14, Brandon S. Allbery KF8NH wrote:
On 2009 Mar 20, at 20:07, Zachary Turner wrote:
2009/3/20 Brandon S. Allbery KF8NH <allbery@ece.cmu.edu>
...but there is (%) :: (Integral a) => a -> a -> Ratio a

Prelude Data.Ratio> let y = truncate (x%3)
Prelude Data.Ratio> :t y
y :: Integer

Why does y now have the type Integer instead of Int? 

Because of the monomorphism restriction and defaulting.  Actually use it somewhere and it will take the appropriate (Integral) type.

uh, clarification:  because y has no arguments, the monomorphism restriction comes into play; if you define y as above in a program it will also end up defaulting to Integer.  The expression "truncate (x%3)", on the other hand, is of type "Integral a => a" (as long as it's not placed into a context that triggers monomorphism).

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH