[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pattern bindings



To: haskell@cs.glasgow.ac.uk
Subject: Pattern bindings
Date: Fri, 01 Mar 91 17:12:21 +0000
From: Simon L Peyton Jones <simonpj@cs.glasgow.ac.uk>
Sender: haskell-request@cs.glasgow.ac.uk


Folks,


I think we should make a scoping issue clear for guards in Haskell.

The question is: JUST WHAT VARIABLES ARE IN SCOPE IN A GUARD?

It is pretty clear what the following means, and indeed I have used
this sort of construct myself:

	f x = y where
		  y | x>0 = 3
		    | x<0 = 1

But what about this:

	... where  y | y>2 = 3
		     | y<2 = 1

It is patent nonsense for y to be in scope in its own guard, because
both alternatives are "self-fulfilling".  



I THEREFORE PROPOSE to state that in pattern bindings the variables being
bound are not in scope in the guard.  In function bindings the function
arguments, but not the function itself, are in scope.

Any comments?		

Simon