2
I want the function to draw a number and, if it is larger than 7, send an approval message and call this add function. However, my function only falls in the 'Else'. The "failed" message appears. I believe it is the typing of IO Float with Float. How to solve?
sortear :: Float -> Int
sortear x = ceiling(10 * x)
numeroSorteado :: IO ()
numeroSorteado = do
num <- randomIO :: IO Float
print $ sortear num
if(num >= 7) then
do
putStrLn ("Aprovado!" ++ "\n") >> adicionar
else
do
putStrLn "Reprovado!"
adicionar = do
putStrLn "Nome:"
nome <- getLine
putStrLn "Sobrenome:"
sobrenome <- getLine
putStrLn "CPF:"
cpf <- getLine
putStrLn "Idade:"
idade <- getLine
putStrLn "Salario:"
salario <- getLine
putStrLn "Cargo (Estagiario, Analista, Gerente, Diretor, VicePresidente ou Presidente) :"
cargo <- getLine
let new = (nome ++ " "++ sobrenome ++ " " ++ cpf ++ " " ++ idade ++ " " ++ salario ++ " " ++ cargo ++ "\n")
appendFile "funcionarios.txt" new
putStrLn "Funcionario Salvo!"
The function
adicionar
It doesn’t seem important to reproduce your problem. It is recommended that you only enter the code of what matters, and delete the rest to avoid distractions. This is called minimum example: https://answall.com/help/mcve– luispauloml