

It will hold the number which is to be checked whether it is positive or negative. Step 3 − The variable named, “n” is being initialized. Finally, we print the result to the console using putStrLn. In the main function, we bind the value -3 to the variable n, and then call the isPositive function with n as an argument. The main() function has whole control of the program. Step 2 − Program execution will be started from main function. IsPositive n = if n > 0 then "Positive" else if n = 0 then "Zero" else "Negative". Step 1 − The isPositive function is defined as, If n is less than 0, it returns the string "Negative". If n is equal to 0, it returns the string "Zero". If n is greater than 0, the function returns the string "Positive". The function uses a pattern match to determine if n is greater than 0, equal to 0, or less than 0. In the following examples, the function isPositive takes an Integer argument n, and returns a string indicating whether the number is positive, negative, or zero. And in the second example, we are going to use (isPositive n = if n > 0 then "Positive" else if n = 0 then "Zero" else "Negative") function. In the first example, we are going to use (isPositive n | n > 0 = "Positive" | n = 0 = "Zero" | otherwise = "Negative") function. In Haskell, we can Check Whether a Number is Positive or Negative by using comparison operators and if-else statements.
