So I wanted to make a program that prints out a ASCII triangle. The program asks you the height that you want your triangle to be and prints it out and does it until the number you put in is 7, then it draws the traingle of height 7 and the program stops. The trinagle that is print out is made out of '*' if the number is even and '#' if the number is odd. I wanted to do that by recursively calling the main function
triangle level character = draw level character 1
where draw level character accumulator
| level <=0 = putStr("")
| level > 0 = do
putStrLn (replicate level ' ' ++ replicate accumulator character)
draw (level-1) character (accumulator+2)
main = do
number <- readLn :: IO Int
if(number `mod` 2 == 0)
then
triangle number'*'
main
else if (number == 7)
then triangle number '#'
else triangle number '#'
main
The error i get is
• Couldn't match expected type ‘IO () -> IO ()’
with actual type ‘IO ()’
• The function ‘triangle’ is applied to three arguments,
but its type ‘Int -> Char -> IO ()’ has only two
In the expression: triangle number '*' main
In a stmt of a 'do' block:
if (number `mod` 2 == 0) then
triangle number '*' main
else
if (number == 7) then
triangle number '#'
else
triangle number '#' main