I have a type problem with this function
type Store = [(String, Float)]
evalParser :: String -> Store -> Float -- Boring function who returns a Float
programme :: Store -> IO()
programme store = do
putStr "@EvmInteractif:$> "
instruction <- getLine
putStrLn (show instruction)
if (estCommande (instruction) == True) then
do
res <- evalParser instruction store
putStrLn "TODO: execution de la commande"
programme store
And at the line of res's affectation I have this error :
Couldn't match expected type IO Float' with actual typeFloat'
In the return type of a call of `evalParser'
In a stmt of a 'do' block: v <- evalParser expr store
Can someone tell me the rigth syntax please ? Thanks
let res = ...instead ofres <- ...- luquiestCommande (instruction) == True~estCommande (instruction)- freestyleresisn't used anywhere, you can just delete the offending line. But only slightly tongue-in-cheek, as there's a lesson here, namely: I suspect you believe that merely callingevalParserwill "do something", but it won't. This smells like you have made a bit of a mistake; e.g. perhapsevalParsershould be returning an updated store to use in the later recursive call toprogramme, or perhaps you intended to print the result, or both. Or perhaps you did those in the original but cut them out to make a minimal example, in which case kudos! - Daniel Wagner