[Haskell-cafe] List as input
Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Thu Oct 16 01:15:29 EDT 2008
On 2008 Oct 16, at 0:53, leledumbo wrote:
>> The compiler doesn't know what kind of list you are trying to read,
> sort, and print.
>
> So, the type must be specific? Then why it's possible to call the
> sorting
> function with any list?
A function may have a polymorphic type; this allows its actual type to
be set by context.
A *program* must have fully determined types, which includes
polymorphic functions whose calls provide enough context to determine
the actual type at the call site. If there isn't enough information
to set a concrete type at the call, type inference fails. This is
what you get with strong typing.
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
More information about the Haskell-Cafe
mailing list