# Beginner: error when using multiple where stmts in hugs98

**Mark P Jones
**
mpj@cse.ogi.edu

*Fri, 1 Dec 2000 10:48:47 -0800*

|* I've been trying some examples in functional programming. Most things
*|* work fine, but I have trouble with expressions with 'where' clauses
*|* that define more then one local definition.
*|* ...
*|* For example:
*|* ...
*|* mydiff f =3D f'
*|* where f' x =3D ( f (x+h) - f x) / h
*|* h =3D 0.0001
*
The second line in the where clause (your attempt to define local
variable h) will be treated as if it were part of the first definition
(for the variable f'). Why? Because that's what the layout/indentation
in your code specifies. In fact, to a Haskell compiler, your input
looks a lot like the following, clearly incorrect definition:
mydiff f =3D f'
where f' x =3D ( f (x+h) - f x) / h h =3D 0.0001
If you want h to be defined as a local variable at the same level as f',
then you should make sure the two definitions start with the same
indentation:
mydiff f =3D f'
where f' x =3D ( f (x+h) - f x) / h
h =3D 0.0001
The indentation you've actually used suggests that you might have =
intended
the definition of h to be local to f'. In that case, you should add an
extra "where" keyword:
mydiff f =3D f'
where f' x =3D ( f (x+h) - f x) / h
where h =3D 0.0001
All the best,
Mark