- Type signature
Type signature is a term that is used in computer programming.
A type signature defines the inputs and outputs for a function or method. A type signature includes at least the function name and the number of its parameters. In some programming languages, it may also specify the function's return type or the types of its parameters.
Haskell
A type signature in the Haskell programming language is written, generally, in the following format: functionName :: arg1Type -> arg2Type -> ... -> argNType
Notice that the final output can be regarded as an argument. This is a consequence of
currying . That is, given a function that had one argument supplied, but takes in two inputs, the function is "curried" and becomes a function of one argument -- the one that is not supplied.The actual type specifications can consist of an actual type, such as Integer, or a general
type variable that is used in parametric polymorphic functions, such as "a", or "b", or "anyType". So we can write something like: functionName :: a -> a -> ... -> aSince Haskell supports
higher-order function s, functions can be passed as arguments. This is written as: functionName :: (a -> a) -> aThis function takes in a function with type signature a -> a, and returns data of type "a" out.
Java
In the
Java virtual machine , "internal type signatures" are used to identify methods and classes at the level of the virtual machine code.Example:The method
String String.substring(int, int)
is represented as java/lang/String/substring(II)Ljava/lang/String;C
In C,
declaration reflects use ; thus afunction pointer that would be invoked ashas the signature
ee also
*
Method signature
Wikimedia Foundation. 2010.