[Haskell-cafe] Where's the error in this snippet of code?

Duncan Coutts duncan.coutts at worcester.oxford.ac.uk
Wed Mar 24 18:38:04 EST 2004

On Wed, 2004-03-24 at 18:00, Alex Gontcharov wrote:
> I don't want to hide it within the function, I need the functions
> to have file scope.

Oh, ok. I assumed from the indentation (you see layout matters!) that it
was a nested function.

Haskell (like Python) is layout sensitive, the indentation makes a
difference. All function definitions in the same scope have to line up
in the same column. So for global/file scope functions they should not
be indented at all.

So the problem with your example was that your second function was


globalFunc1 = ...
globalFunc2 = ...

and not:

globalFunc1 = ...
  globalFunc2 = ...

> So, If you want to call a function from another function b I have to
> nest it using where?

No, only if you want it nested rather than whole file scope.


More information about the Haskell-Cafe mailing list