"Ramaswamy, Vivek" <vivek.ramasw...@fmr.com> writes: > Hello All~ > > I have been reading the book ?Haskell for real programmers? and am presently > on > chapter 03. > > There was a small program demonstrated by the author on ?let?. The problem is > that when I cut and paste authors code into eclipse, the program works fine, > where as when I write my own copy of the program I am getting an error. I > figured out that when I remove the function any one function lend or bend, the > file compiles and runs fine. > > My question is why does the Haskell compiler complains, in the case 2 > functions > with the same signature and logic, even though their names are different. > > module Lending where > > {-- snippet lend --} > > lend amount balance = let reserve = 100 > > newBalance = balance - amount > > in if balance < reserve > > then Nothing > > else Just newBalance > > {-- /snippet lend --} > > bend amount balance = let reserver = 100 > > newBalance=balance-amount
The problem is here ^^^^ each element in a let clause should be indented to the same level, that is let foo = bar baz = qux is legal. foo and baz are both defined. But let foo = bar baz = qux is not legal, the compiler thinks baz = qux is part of the statement `foo = bar`, like `foo = bar baz = qux`. Also let foo = bar baz = qux is not legal, since the compiler thinks the let clause is over and expects the keyword `in` > > in if balance < reserver > > then Nothing > > else Just newBalance > > Regards > > -Vivek Ramaswamy- _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe