*** Welcome to piglix ***

Type annotation


In computer science, a type signature or type annotation defines the inputs and outputs for a function, subroutine or method. A type signature includes the number of arguments, the types of arguments and the order of the arguments contained by a function. A type signature is typically used during overload resolution for choosing the correct definition of a function to be called among many overloaded forms.

In C and C++, the type signature is declared by what is commonly known as a function prototype. In C/C++, a function declaration reflects its use; for example, a function pointer that would be invoked as:

has the signature:

In Erlang, type signatures may be optionally declared, as:

For example:

A type signature in the Haskell programming language is generally written in the following format:

Notice that the type of the result can be regarded as everything past the first supplied argument. This is a consequence of currying, which is made possible by Haskell's support for first-class functions; this function requires two inputs where one argument supplied and the function is "curried" to produce a function for the argument not supplied. Thus calling f x, where f :: a -> b -> c, yields a new function f2 :: b -> c that can be called f2 b to produce c.


...
Wikipedia

...