Unification (computer Science) - Type Inference

Type Inference

Unification is used during type inference, for instance in the functional programming language Haskell. On one hand, the programmer does not need to provide type information for every function, on the other hand it is used to detect typing errors. The Haskell expression 1: is not correctly typed, because the list construction function ":" is of type a->-> and for the first argument "1" the polymorphic type variable "a" has to denote the type Int whereas "" is of type, but "a" cannot be both Char and Int at the same time.

Like for prolog an algorithm for type inference can be given:

  1. Any type variable unifies with any type expression, and is instantiated to that expression. A specific theory might restrict this rule with an occurs check.
  2. Two type constants unify only if they are the same type.
  3. Two type constructions unify only if they are applications of the same type constructor and all of their component types recursively unify.

Due to its declarative nature, the order in a sequence of unifications is (usually) unimportant.

Note that in the terminology of first-order logic, an atom is a basic proposition and is unified similarly to a Prolog term.

Read more about this topic:  Unification (computer Science)

Famous quotes containing the words type and/or inference:

    Time has an undertaking establishment on every block and drives his coffin nails faster than the steam riveters rivet or the stenographers type or the tickers tick out fours and eights and dollar signs and ciphers.
    John Dos Passos (1896–1970)

    I have heard that whoever loves is in no condition old. I have heard that whenever the name of man is spoken, the doctrine of immortality is announced; it cleaves to his constitution. The mode of it baffles our wit, and no whisper comes to us from the other side. But the inference from the working of intellect, hiving knowledge, hiving skill,—at the end of life just ready to be born,—affirms the inspirations of affection and of the moral sentiment.
    Ralph Waldo Emerson (1803–1882)