[Haskell-cafe] Haskell's prefix exprs

Christian Maeder Christian.Maeder at dfki.de
Mon Jul 9 09:55:52 EDT 2007


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-prime "$" 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

(I've posted this message to glasgow-haskell-users before, but it
applies to every Haskell implementation and should be discussed here.)



More information about the Haskell-Cafe mailing list