Original-Via: uk.ac.ox.prg; Mon, 23 Sep 91 14:38:38 BST Here are two relatively straightforward extensions to the syntax that might be worth considering for future versions of Haskell. Both are straightforward to implement (I know because I've experimented with adding them to Gofer). EXTENDED SYNTAX FOR INFIX OPERATORS: Some languages (e.g. Orwell) allow identifier to be used as operator symbols by prefixing them with a special character (e.g. $elem). The same effect is achieved in Haskell by enclosing the identifier between a pair of backquotes (e.g. `elem`). We can make better use of the trailing backquote by generalising the syntax: e.g. replace varop --> avarop | `avarid` by varop --> avarop | ` exp10 ` This is useful for writing parameterised infix operators (examples of which often occur in squigol). Here is an excerpt from a (non-standard) session with Gofer using this extension to generate a list of fibonacci numbers: ? fibs where fibs = 0 : 1 : fibs `zipWith (+)` tail fibs [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ^C{Interrupted!} (53 reductions, 177 cells) ? One problem with this: what is the associativity and precedence of an expression of this kind? My suggestion would be infix 9, although that would mean that parens were needed in an expression such as: [1..] `zipWith (+)` [2..] `zipWith (+)` [3..] SYNTAX FOR GUARDED EQUATIONS [Similar suggestions have been posted in the past; this is perhaps a little more concrete...] Prompted by a suggestion from Bernard Sufrin, I have realised that the syntax for guarded right hand sides of a function definition can be extended with two simple productions: gdrhs --> gd = exp [gdrhs] | exp , exp [gdrhs] | exp , "if" exp [gdrhs] With this extension to the parser (which doesn't require any additional changes elsewhere), Haskell would be able to accept definitions such as: filt p [] = [] filt p (x:xs) = x : rest, if p x = rest, otherwise where rest = filt p xs for those who prefer Orwell style guards, as used in `Introduction to functional programming'. In other words, this would result in a subset of Haskell which is very close to Orwell, without breaking any Haskell programs already in existence. One sad thing is that it would not be easy to make the corresponding extension to the syntax of case expressions without changing part of the Haskell syntax for expressions and hence breaking some existing programs. [My yacc based parser cannot tell whether the `->' symbol in case e of { c1, e1 :: T a -> t2; c2, e2 } is part of a type expression T a->t2, or part of a second alternative a -> t2.] Comments welcome! Mark