Type_signature Type_signature

Type signature - Definition and Overview

Related Words: X, Accent, Acceptance, Accommodation, Acknowledgment, Affirmation, Approval, Arrangement, Article, Authentication, Authorization, Autograph, Back, Badge, Banner, Bar

A type signature is a feature in functional programming languages such as Haskell and ML.

It defines the inputs and outputs for a function. Type signatures may appear to be extremely restrictive but they allow for effortless code re-use, in that given a function that performs a certain task, it can reliably be swapped with any other code that matches this type signature and the overall functionality of the entire program can be assured (given that both functions operate properly).

A type signature in Haskell 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 arguments 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 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 -> ... -> a

Since Haskell supports higher-order functions, functions can be passed as arguments, and this is written as:

functionName :: (a->a) -> a

This function takes in a function with type signature a -> a, and returns data of type "a" out.

See also: method signature.

Example Usage of signature

daniel_lacey: RT @Jerrymcd: Gradkowski _ 20 of 33 308 yards, 3 TDs, zero interceptions . . . signature win for Cable regime.
YoungChef: @r18thletter signature Room @ The 95th, Ambria, Patrick's (which is now Hop Haus)
gaak99: UNFUCKNBELIEVABLE RT @Jerrymcd Gradkowski _ 20 of 33 308 yards, 3 TDs, zero interceptions . . . signature win for Cable regime.
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.