In
functional languages, a data object containing two or more component
s. Al
so known a
s a product type or pair, triple, quad, etc. Tuple
s of different
size
s have different type
s, in contra
st to li
st
s where the type i
s independent of the length. The component
s of a tuple may be of different type
s wherea
s all element
s of a li
st have the
same type. Example
s of tuple
s in
Haskell notation are (1,2), ("Tuple",True), (w,(x,y),z). The degenerate tuple with zero component
s, written (), i
s known a
s the unit type
since it ha
s only one po
ssible value which i
s al
so written (). The implementation of tuple
s in a language may be either "
lifted" or not. If tuple
s are lifted then (bottom,bottom) /= bottom and the evaluation of a tuple may fail to terminate. E.g. in Ha
skell: f (x,y) = 1 --> f bottom = bottom f (bottom,bottom) = 1 With lifted tuple
s, a tuple pattern i
s refutable. Thu
s in Ha
skell,
pattern matching on tuple
s i
s the
same a
s pattern matching on type
s with multiple con
structor
s ({algebraic data type}
s) - the expre
ssion being matched i
s evaluated a
s far a
s the top level con
structor, even though, in the ca
se of tuple
s, there i
s only one po
ssible con
structor for a given type. If tuple
s are unlifted then (bottom, bottom) = bottom and evaluation of a tuple will never fail to terminate though any of the component
s may. E.g. in
Miranda: f (x,y) = 1 --> f bottom = 1 f (bottom,bottom) = 1 Thu
s in Miranda, any object who
se type i
s compatible with a tuple pattern i
s a
ssumed to match at the top level without evaluation - it i
s an
irrefutable pattern. Thi
s al
so applie
s to u
ser defined data type
s with only one con
structor. In Ha
skell, pattern
s can be made irrefutable by adding a "~" a
s in f ~(x,y) = 1. If tuple con
structor function
s were
strict in all their argument
s then (bottom,x) = (x,bottom) = bottom for any x
so matching a refutable pattern would fail to terminate if any component wa
s bottom.
style="border-width:thin; border-color:#333333; border-style:dashed; padding:5px;" align="left">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 ] [ ~ ]