[Haskell-beginners] Explicit specification of function types

Zachary Turner divisortheory at gmail.com
Mon Mar 23 22:02:56 EDT 2009


Everything I've read has said that it's generally considered good practice
to specify the full type of a function before the definition.  Why is this?
It almost seems to go against the principles of type inference.  Why let the
compiler infer types if you're just going to tell it what types to use for
everything?  Ok well, not really for everything, you don't typically specify
types for local bindings, but still why the inconsistency?  I have a little
experience with ML and F# and there you're encouraged to -not- specify types
explicitly, and let the compiler infer them for you.  In fact, it seems like
it would be fairly common where you specify a type that is -less- general
than the type that the compiler would infer for you, because the most
general type might involve a combination of type classes used in various
ways, and it may not always be obvious to the programmer how to specify it
correctly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090323/e6ffd34e/attachment.htm


More information about the Beginners mailing list