Question about scope of 'let' and 'where'

Matt Hellige matt@immute.net
Mon, 17 Mar 2003 10:38:04 -0600


[Hal Daume III <hdaume@ISI.EDU>]
> No, that's not legal.  You'll get an unbound variable error on the use of
> 'a' in the definition of 'b'.  This doesn't really have anything to do
> with layout.  Consider the following definition:
> 
> > f x =
> >    case x of
> >      Nothing -> ...
> >      Just (y,z) -> let Just q = z
> >                    in  b
> >   where b = g q
> 
> does it really make sense to let the where clause look that deep into an
> expression to pull out a variable?  And what if you use the name 'q'
> multiple times in the expression?

Right, I understand that it's an illegal 'where' clause. That was the
point of the original post... I chose a bad example by using the
example from the original question, which we've already established as
illegal. My question has to do only with layout... Consider:

 f x = let ...
       in
          ...
          where
             ...

Assuming that all the ...s are legal, is this OK? Should it be? It
really makes the 'where' clause look like it's inside the 'let', when
in fact it can't be.

Sorry about the misunderstanding and lousy example...

Matt

-- 
Matt Hellige                  matt@immute.net
http://matt.immute.net