All the Perl that's Practical to Extract and Report

Navigation

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

That is, the function sq is defined for all values a, such that a is an instance of the type class Num. Remember, Haskell is strongly typed, and this function is defined on all kinds of numbers (machine integers, bignums, floats, doubles, complex, etc.). Furthermore, it will be defined on all types you define that are also instances of Num.

This is a contrived example, but it does demonstrate type inference. That is, it avoids the Java problem where a function like sq needs to be redefined for every numeric type you want to square (primitive numbers and user defined numeric types). All with a single definition.