Beginner: error when using multiple where stmts in hugs98

Wim-Jan Hilgenbos wimjan@xs4all.nl
Fri, 01 Dec 2000 15:49:13 +0100


This is a multi-part message in MIME format.
--------------F1E92FD1F075259053A3C4BA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

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.
(I work with hugs98 version september 1999 under Linux)

For example:

----------[ Mydiff.hs ]----------------------
module Mydiff where

mydiff f = f'
        where f' x = ( f (x+h) - f x) / h
                    h = 0.0001

----------[ end Mydiff.hs ]-------------------

When I try to load this module I get
    ERROR "Mydiff.hs" (line 5): Syntax error in input (unexpected `=')
line 5 is the line h = 0.0001

I tried other examples like this one, played around with line-breaks
white-space etc.
Rewriting the f' line to f' x = (f (x+0.0001) - f x) / 0.0001 does the
trick, but is not very
satisfying.

Can anyone help?
WJ

PS. I attached above example


-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Disclaimer:
"These opinions are my own, though for a small fee they be
 yours too."
 -- Dave Haynie



--------------F1E92FD1F075259053A3C4BA
Content-Type: text/plain; charset=us-ascii;
 name="Mydiff.hs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Mydiff.hs"

module Mydiff where

mydiff f = f'
	where f' x = ( f (x+h) - f x) / h
			 h = 0.0001

--------------F1E92FD1F075259053A3C4BA--