I am trying to print all Pythagorean triplets in haskell and while the logic is correct, i get error in parsing in line: funcp :: Int Int Int -> IO ()
. Can someone help me find the issue? I am very new to haskell
checkp :: Int->Int-> IO()
checkp nn m= do
let n=1
if n<m
then funcp m n nn
else checkp nn (m 1)
funcp :: Int Int Int -> IO ()
CodePudding user response:
You have wrong indentation:
checkp :: Int->Int-> IO()
checkp nn m= do
let n=1
here:
-- *
if n<m
then funcp m n nn
else checkp nn (m 1)
while your error probably points you to the following statement after that:
funcp :: Int Int Int -> IO ()
....
Syntactically, this if
must start at the same column as the preceding line, namely here, let
.
For more, check out the "do notation".
Of course the following is also an indentation error, at the very start of your code:
checkp :: Int->Int-> IO()
checkp nn m= do
-- ^^^
They too must start at the same indentation level.