Reputation: 131
Hello I'm doing a program with haskell and need do something like that:
expo :: String -> String
expo "stuff" = " Doing something "
main = do
expo "stuff"
but when I try to run this, this happend:
Couldn't match expected type `IO t0' with actual type `String'
In the expression: main
When checking the type of the function `main'
Some one who can explain me ? ....
Upvotes: 0
Views: 258
Reputation: 27217
What do you want to happen to the return value of expo "stuff"
?
Let's assume you want to print it to the console:
main = do
putStrLn $ expo "Stuff"
All statements in a do block need to be of type IO something
(see also let
bindings) the last must be IO ()
. If this doesn't make sense to you then you have run into one of haskell's famous learning curves. Read a few more pages in the tutorials and it will become clear with practice. Keep Learning!
Upvotes: 3