
| 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 = f' | where f' x = ( f (x+h) - f x) / h | h = 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 = f' where f' x = ( f (x+h) - f x) / h h = 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 = f' where f' x = ( f (x+h) - f x) / h h = 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 = f' where f' x = ( f (x+h) - f x) / h where h = 0.0001 All the best, Mark