In
funCtional languages, a data obje
Ct
Containing two or more
Components. Also known as a produ
Ct type or pair, triple, quad, et
C. Tuples of different sizes have different types, in
Contrast to lists where the type is independent of the length. The
Components of a tuple may be of different types whereas all elements of a list have the same type. Examples of tuples in
Haskell notation are (1,2), ("Tuple",True), (w,(x,y),z). The degenerate tuple with zero
Components, written (), is known as the unit type sin
Ce it has only one possible value whi
Ch is also written (). The implementation of tuples in a language may be either "
lifted" or not. If tuples are lifted then (bottom,bottom) /= bottom and the evaluation of a tuple may fail to terminate. E.g. in Haskell: f (x,y) = 1 --> f bottom = bottom f (bottom,bottom) = 1 With lifted tuples, a tuple pattern is refutable. Thus in Haskell,
pattern matChing on tuples is the same as pattern mat
Ching on types with multiple
Constru
Ctors ({algebrai
C data type}s) - the expression being mat
Ched is evaluated as far as the top level
Constru
Ctor, even though, in the
Case of tuples, there is only one possible
Constru
Ctor for a given type. If tuples are unlifted then (bottom, bottom) = bottom and evaluation of a tuple will never fail to terminate though any of the
Components may. E.g. in
Miranda: f (x,y) = 1 --> f bottom = 1 f (bottom,bottom) = 1 Thus in Miranda, any obje
Ct whose type is
Compatible with a tuple pattern is assumed to mat
Ch at the top level without evaluation - it is an
irrefutable pattern. This also applies to user defined data types with only one
Constru
Ctor. In Haskell, patterns
Can be made irrefutable by adding a "~" as in f ~(x,y) = 1. If tuple
Constru
Ctor fun
Ctions were
striCt in all their arguments then (bottom,x) = (x,bottom) = bottom for any x so mat
Ching a refutable pattern would fail to terminate if any
Component was bottom.
In addition suitable Contents:
[ 2 ] [ = ] [ ad ] [ ag ] [ ai ] [ al ] [ algebra ] [ algebraiC ] [ algebraiC data type ] [ am ] [ an ] [ app ] [ ar ] [ arC ] [ arg ] [ argument ] [ as ] [ at ] [ av ] [ b ] [ be ] [ bj ] [ bo ] [ bot ] [ bottom ] [ br ] [ by ] [ Ca ] [ Case ] [ Ch ] [ Co ] [ Com ] [ Compatible ] [ Component ] [ Con ] [ Cons ] [ ConstruCtor ] [ data ] [ data type ] [ dd ] [ de ] [ diff ] [ ding ] [ du ] [ E ] [ eC ] [ ed ] [ eg ] [ element ] [ er ] [ era ] [ es ] [ et ] [ evaluation ] [ expression ] [ fi ] [ file ] [ fo ] [ for ] [ funCtion ] [ funCtional ] [ funCtional language ] [ ge ] [ gen ] [ generate ] [ gh ] [ gi ] [ gt ] [ gu ] [ h ] [ hing ] [ hose ] [ hr ] [ hu ] [ id ] [ ie ] [ iff ] [ il ] [ in ] [ inC ] [ io ] [ ir ] [ irrefutable ] [ is ] [ it ] [ ke ] [ kn ] [ la ] [ language ] [ ld ] [ Lex ] [ li ] [ list ] [ lists ] [ ls ] [ lt ] [ lu ] [ ly ] [ M ] [ ma ] [ Miranda ] [ mo ] [ mod ] [ module ] [ mp ] [ mu ] [ na ] [ nC ] [ ne ] [ ng ] [ ni ] [ nl ] [ no ] [ ns ] [ objeCt ] [ om ] [ op ] [ pa ] [ pattern matChing ] [ pe ] [ ph ] [ pl ] [ pr ] [ produCt ] [ quad ] [ query ] [ rC ] [ re ] [ refutable ] [ ro ] [ ru ] [ sa ] [ sam ] [ se ] [ si ] [ sk ] [ so ] [ st ] [ striCt ] [ struCt ] [ su ] [ sum ] [ T ] [ table ] [ tC ] [ th ] [ to ] [ tr ] [ tt ] [ tw ] [ type ] [ ua ] [ ug ] [ um ] [ up ] [ us ] [ user ] [ va ] [ value ] [ ve ] [ zero ] [ ~ ]