On 2009 Mar 23, at 23:02, Zachary Turner wrote:
That being said, is it as common as I expect it would be that the progarmmer unknowingly specifies a type that is not the most general type possible?  I would think this would be "bad", although not the end of the world or anything it would still be desirable to be as generic as possible.

One practical consideration is that the more general a function is, the more expensive it could be, either due to lack of optimization or a requirement to look up a typeclass instance at runtime.  You can avoid this by using GHC's SPECIALIZE pragma, but in many cases it's best to be just as generic as you require but not more so.

The monomorphism restriction is in fact a workaround for a common case of this:

    a = 5

Looking at that, one might expect its type to be Int, but without the monomorphism restriction it would be Num a => a and force runtime lookups everywhere a is directly or indirectly used.

-- 
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