Changes between Version 24 and Version 25 of PatternSynonyms
 Timestamp:
 Dec 1, 2013 5:11:29 AM (19 months ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

PatternSynonyms
v24 v25 68 68 The simplest form of pattern synonyms is the one from the examples above. The grammar rule is: 69 69 70 `pattern` ''conid'' ''varid,,1,,'' ... ''varid,,n,,'' ` >` ''pat''71 72 `pattern` ''varid,,1,,'' ''consym'' ''varid,,2,,'' ` >` ''pat''70 `pattern` ''conid'' ''varid,,1,,'' ... ''varid,,n,,'' `<` ''pat'' 71 72 `pattern` ''varid,,1,,'' ''consym'' ''varid,,2,,'' `<` ''pat'' 73 73 74 74 * Each of the variables on the left hand side must occur exactly once on the right hand side … … 105 105 {{{ 106 106 pattern Arrow :: Type > Type > Type 107 pattern Arrow t1 t2 >App ">" [t1, t2]107 pattern Arrow t1 t2 < App ">" [t1, t2] 108 108 }}} 109 109 … … 113 113 import qualified Data.Sequence as Seq 114 114 115 pattern Empty >(Seq.viewl > Seq.EmptyL)116 pattern x :< xs >(Seq.viewl > x Seq.:< xs)117 pattern xs :> x >(Seq.viewr > xs Seq.:> x)115 pattern Empty < (Seq.viewl > Seq.EmptyL) 116 pattern x :< xs < (Seq.viewl > x Seq.:< xs) 117 pattern xs :> x < (Seq.viewr > xs Seq.:> x) 118 118 }}} 119 119 … … 151 151 152 152 {{{ 153 pattern Succ n >n1  let n = n1 1, n >= 0153 pattern Succ n < n1  let n = n1 1, n >= 0 154 154 }}} 155 155 … … 158 158 This is the rationale for the most complicated synonyms, the bidirectional ones. They provide two expansions, one for patterns and one for expressions. 159 159 160 `pattern` ''conid'' ''varid,,1,,'' ... ''varid,,n,,'' ` >` ''pat'' `where` ''cfunlhs'' ''rhs''160 `pattern` ''conid'' ''varid,,1,,'' ... ''varid,,n,,'' `<` ''pat'' `where` ''cfunlhs'' ''rhs'' 161 161 162 162 where ''cfunlhs'' is like ''funlhs'', except that the functions symbol is a ''conid'' instead of a ''varid''. … … 164 164 Example: 165 165 {{{ 166 pattern Succ n >n1  let n = n11, n >= 0 where166 pattern Succ n < n1  let n = n11, n >= 0 where 167 167 Succ n = n + 1 168 168 }}}