Speaking of n+k patterns, did anyone ever answer this question?

> Date:         Wed, 14 Apr 1993 11:24:54 +0000
> From: [EMAIL PROTECTED]
> Subject:      Successor patterns in bindings
> To: Multiple recipients of list HASKLD-L <[EMAIL PROTECTED]>
>
> I'm puzzled by a bit of the Haskell 1.2 report on page 36; can
> anyone clarify?
> 

> The BNF and the supprting text seem to disagree.
> 

> The BNF defines <lhs> as a <pat> or a <funlhs>, where <pat>
> cannot be a successor pattern.  But <funlhs> can be a successor
> pattern, since "+" is a <varop>.  So a successor pattern can only
> be parsed as a function binding, ie as a redefinition of "+".  It
> can never be parsed as a pattern binding.
> 

> In the supporting text the sentence beginning, "Top level n+k
> pattern bindings are explicitly disallowed" suggests that
> successor pattern bindings _are_ allowed in contexts other
> than the top level (ie in "where" or "let" constructs).  Is this
> the case?  If so, how is the ambiguity resolved?  Should the
> sentence begin, "Successor pattern bindings are explicitly
> disallowed?"
> 

> -Norman Paterson

The sentence Norman refers to is more precisely:

"Top level n+k pattern bindings are explicitly disallowed; otherwise,
programs such as x+2=3 could be parsed either as a definition of +
or as a pattern binding."

I think that Norman's suggested rewording is correct, but I suggest
that it be further modifed to read:

"n+k pattern bindings are explicitly disallowed; programs such as
x+2=3 are parsed as a definition of +."

Indeed, the Standard Prelude contains several such definitions in the
instance declarations for the class Num.

-Paul

Reply via email to