A
A
Amigo20192019-12-09 15:17:54
Haskell
Amigo2019, 2019-12-09 15:17:54

Why is it showing an error? seems to be correct? and how to fix it?

Good afternoon!
Shows an error requires let and how to fix it?
The program is not entirely, the problem is in the block for checking the input of letters
. In this part, the block for checking letters and the block for checking numbers are the same, but it doesn’t swear on a digital one, but it swears on a letter check block ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-12-09
@Amigo2019

Move declarations and definitions of functions to the right place.

main = do
        putStrLn "Start point: "
        start <- getArg
        putStrLn "End point: "
        end <- getArg
        putStrLn "Max cost: "
        costStr <- getArgNum
        let cost = read costStr :: Double
        mapM_ putStr $ astar graph1 start end cost
        putStrLn " "
----------------CHECK BUKVI--------
getArg :: IO String -- И так все что ниже
getArg = do        
        line <- getLine

But you have other problems there.
getArgNum...
getArgNum :: IO Double
getArgNum = do
                line <- getLine
                if numOk line
                                then return (read line :: Double)
                                else do
                                putStrLn "Please input a proper number:"
                                getArgNum  -- У тебя было getArg

costStr <- getArg -- у тебя было getArgNum
let cost = read costStr :: Double

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question