You can think of a where as another way to write a let around the right hand sides that belong to a single match.
In your case, it is quite easy, as there is only a single right hand side. Hence, you wrote:
test bar = let foo = baz in let baz = bar-1 in foo
This is not going to work. I recommend to stick with either where or let, most idiomatic would be:
test bar = foo
where
foo = baz
baz = bar -1
Apart from that, when you only define baz
then baz'
will never be in scope.