<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<span class="Apple-style-span" style="font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; "><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; ">Hi, I just started learning Haskell. But I have been having a problem with defining functions. For example,</font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><br style="line-height: 17px; "></font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; ">diff :: Float-> Float </font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; ">diff = if x>= y then x-y else y-x</font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><br style="line-height: 17px; "></font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><interactive>:1:29: parse error on input `='</font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><br style="line-height: 17px; "></font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; ">It is rather weird as I have checked quite a few websites and this was supposed to work.</font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><br style="line-height: 17px; "></font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; ">The same occurs when I try for guarded rules, except that it is now for |.</font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><br style="line-height: 17px; "></font></div><div style="line-height: 17px; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="line-height: normal; "><div style="line-height: 17px; ">diff :: Float -> Float -> Float</div><div style="line-height: 17px; ">diff x y | x >= y = x - y</div><div style="line-height: 17px; ">| otherwise = y - x</div><div style="line-height: 17px; "><br style="line-height: 17px; "></div><div style="line-height: 17px; "><interactive>:1:42: parse error on input `|'</div><div style="line-height: 17px; "><br style="line-height: 17px; "></div><div style="line-height: 17px; ">Please do help!</div><div style="line-height: 17px; "><br style="line-height: 17px; "></div><div style="line-height: 17px; ">Thanks a lot.</div></font></div></span><div><div dir="ltr">                                            </div></div>                                            </div></body>
</html>