In
functional languages, a data o
Bject containing two or more components. Also known as a product type or pair, triple, quad, etc. 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 since it has only one possi
Ble value which 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 refuta
Ble. Thus in Haskell,
pattern matching on tuples is the same as pattern matching on types with multiple constructors ({alge
Braic data type}s) - the expression
Being matched is evaluated as far as the top level constructor, even though, in the case of tuples, there is only one possi
Ble constructor 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 o
Bject whose type is compati
Ble with a tuple pattern is assumed to match at the top level without evaluation - it is an
irrefutaBle pattern. This also applies to user defined data types with only one constructor. In Haskell, patterns can
Be made irrefuta
Ble
By adding a "~" as in f ~(x,y) = 1. If tuple constructor functions were
strict in all their arguments then (
Bottom,x) = (x,
Bottom) =
Bottom for any x so matching a refuta
Ble pattern would fail to terminate if any component was
Bottom.
In addition suitaBle contents:<Br>[ 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 ] [ ~ ]