[Haskell-beginners] Functions in "where" block.
Jacek Dudek
jzdudek at gmail.com
Tue Jun 24 16:44:34 UTC 2014
{- Hi Venu,
the problem is incorrect indentation. The line that defines ep must
have the same (or greater) indentation than the line that defines op.
Also, it is recommended that you use strictly spaces for indentation.
In some editors, for example Vim, you can set an option that
automatically converts your tab keystrokes into spaces.
Copy this email as is with the code below to see one possible
convention for writing where clauses. To recreate the same error
again, move the line that defines ep back one space.
By the way, your email landed in my spam box for some reason, so you
might not be getting any replies to subsequent emails.
-}
myFun :: Integer -> Integer
myFun x = op x + ep x
where
op x = 99
ep x = 1
On 6/11/14, Venu Chakravorty <c.venu at aol.com> wrote:
> Hello everyone,
> I can't figure out why the following function does not work:
>
>
>
>
> myFun :: Integer -> Integer
> myFun x = op x + ep x
> where op x = 99
> ep x = 1 -- squawks here
>
>
>
> Yeah it's a stupid function, but I was just trying to declare two functions
> in the "where" block. I expected
> this to work and always return 100.
>
>
> This is the error I get while compiling:
>
> ==================
> Prelude> :l fun.hs
> [1 of 1] Compiling Main ( fun.hs, interpreted )
>
>
> fun.hs:4:15: parse error on input `='
> Failed, modules loaded: none.
>
> ==================
>
>
> Could someone please tell me where I am going wrong?
> Thanks in advance.
>
>
>
> Regards,
> Venu Chakravorty.
>
>
>
>
>
More information about the Beginners
mailing list