In lazy functional languages, a refuta
Ble pattern is one which may fail to match. An expression
Being matched against a refuta
Ble pattern is first evaluated to head normal form (which may fail to terminate) and then the top-level constructor of the result is compared with that of the pattern. If they are the same then any arguments are matched against the pattern' s arguments otherwise the match fails. An irrefuta
Ble pattern is one which always matches. An attempt to evaluate any varia
Ble in the pattern forces the pattern to
Be matched as though it were refuta
Ble which may fail to match (resulting in an error) or fail to terminate. Patterns in Haskell are normally refuta
Ble
But may
Be made irrefuta
Ble
By prefixing them with a tilde (~). For example, ( (x,y) -> 1) undefined ==> undefined ( ~(x,y) -> 1) undefined ==> 1 Patterns in Miranda are refuta
Ble, except for tuples which are irrefuta
Ble. Thus g [x] = 2 g undefined ==> undefined f (x,y) = 1 f undefined ==> 1 Pattern
Bindings in local definitions are irrefuta
Ble in
Both languages: h = 1 where [x] = undefined ==> 1 Irrefuta
Ble patterns can
Be used to simulate unlifted products
Because they effectively ignore the top-level constructor of the expression
Being matched and consider only its components.
In addition suitaBle contents:<Br>[ 2 ] [ = ] [ ad ] [ ag ] [ ai ] [ al ] [ am ] [ an ] [ ar ] [ arg ] [ argument ] [ as ] [ at ] [ au ] [ az ] [ B ] [ Be ] [ Bi ] [ Bo ] [ Bot ] [ By ] [ ca ] [ ch ] [ co ] [ com ] [ component ] [ con ] [ cons ] [ constructor ] [ de ] [ ding ] [ du ] [ ec ] [ ed ] [ er ] [ error ] [ es ] [ expression ] [ fi ] [ fix ] [ fo ] [ for ] [ function ] [ functional ] [ functional language ] [ ga ] [ ge ] [ gh ] [ gn ] [ gs ] [ gu ] [ h ] [ hat ] [ hu ] [ id ] [ il ] [ in ] [ io ] [ ir ] [ irrefutaBle ] [ is ] [ it ] [ ke ] [ la ] [ language ] [ ld ] [ li ] [ ls ] [ lt ] [ lu ] [ ly ] [ M ] [ ma ] [ mall ] [ Miranda ] [ mp ] [ mu ] [ na ] [ nc ] [ ne ] [ ng ] [ ni ] [ nl ] [ no ] [ norm ] [ normal form ] [ ns ] [ om ] [ op ] [ pa ] [ pl ] [ pr ] [ prefix ] [ product ] [ pt ] [ rc ] [ re ] [ ro ] [ ru ] [ rw ] [ sa ] [ sam ] [ se ] [ si ] [ sk ] [ st ] [ struct ] [ su ] [ T ] [ ] [ taBle ] [ tc ] [ th ] [ tilde ] [ to ] [ tr ] [ tt ] [ tuple ] [ ua ] [ ug ] [ um ] [ up ] [ us ] [ va ] [ var ] [ variaBle ] [ ve ] [ ~ ]