the dreaded offside rule

Simon Marlow simonmar at
Thu Mar 9 11:53:52 EST 2006

On 09 March 2006 14:40, Simon Marlow wrote:

> On 09 March 2006 14:33, Ian Lynagh wrote:
>> On Wed, Mar 08, 2006 at 10:27:48PM +0100, Doaitse Swierstra wrote:
>>> It is with some hesitation that I want to bring up another point, in
>>> which Haskell' could be an improvement above Haskell: the offside
>>> rule.
>> This is something I would have brought up too, except I don't think
>> I'll have time to look into it properly in the advertised timescale.
>> I conjecture that with a suitable set of bracketing keywords and
>> symbols (if/then, let/in, [/], ...) the "parse error => close
>> implicit block" rule could be dropped without significantly altering
>> the set of acceptable programs (just rejecting programs that people
>> really oughtn't be writing anyway (IMNSHO), like Lennart's examples).
> I once conjectured this too, and I even went so far as to measure how
> many times the parse-error rule was actually used, as opposed to
> simple bracketting, in all the code I could get my hands on. 
> Conclusion: it was a handful of times in several 10000 LOC, mostly
> for things like '(case x of p -> e, 42)'.
> But ISTR I later discovered a reason that counting brackets wouldn't
> work so well, but for now it escapes me.  I'll try to dig it up.

I remember now: the problem is that 'let' does not always have a
matching 'in', e.g. when it is used in 'do', pattern guards or list
comprehensions.  So you can't consistently treat let/in as brackets.  I
don't know a way around this.


More information about the Haskell-prime mailing list