
Hi, I would like haskell to accept the following (currently illegal) expressions as syntactically valid prefix applications: f = id \ _ -> [] g = id let x = [] in x h = id case [] of [] -> [] i = id do [] j = id if True then [] else [] The rational is that expressions starting with a keyword should extend as far as possible (to the right and over several lines within their layout). In this case the above right hand sides (rhs) are unique juxtapositions of two expressions. (This extension should of course apply to more than two expressions, i. e. "f a do []") Furthermore the above rhs are all valid if written as infix expressions: f = id $ \ _ -> [] g = id $ let x = [] in x h = id $ case [] of [] -> [] i = id $ do [] j = id $ if True then [] else [] (In fact, maybe for haskell' "$" could be changed to a keyword.) Does this pose any problems that I haven't considered? I think only more (and shorter) illegal haskell programs will become legal. Cheers Christian Maybe someone else can work out the details for Haskell's grammar

Christian Maeder wrote:
Hi,
I would like haskell to accept the following (currently illegal) expressions as syntactically valid prefix applications:
f = id \ _ -> [] g = id let x = [] in x h = id case [] of [] -> [] i = id do [] j = id if True then [] else []
The rational is that expressions starting with a keyword should extend as far as possible (to the right and over several lines within their layout).
On page 15/16 of the H98 report I think this could be achieved by: exp10 ::= fexp fexp ::= [fexp] keyexp keyexp ::= \ apat ... -> exp | let ... | ... | aexp
(In fact, maybe for haskell' "$" could be changed to a keyword.)
Alternatively the # symbol could be removed from the pool of symbol chars and used to construct syntactic sugar so you could use f = id #$ \_ -> [] to mean exactly f = id (\_ -> []) I think when the idea of $ arose originally people didn't at that time know about the many cases where the use of $ is not semantically equivalent to explict brackets, since this knowledge probably only arose later with the introduction of rank-n polymorphism. (Of course the need for #$ would be fixed with impredicative types as in MLF.) Best regards, Brian.

Brian Hulley schrieb:
Christian Maeder wrote:
(In fact, maybe for haskell' "$" could be changed to a keyword.)
Alternatively the # symbol could be removed from the pool of symbol chars and used to construct syntactic sugar so you could use
f = id #$ \_ -> []
to mean exactly
f = id (\_ -> [])
For this case "#$" would not be needed when you could write: f = id \ _ -> [] A keyword "#$", if one really wanted it, would make sense to replace the infix application "id $ g x" with (the prefix expr) "id #$ g x", though. Cheers Christian
participants (2)
-
Brian Hulley
-
Christian Maeder