[Haskell-cafe] IO() and other datatypes
k.clees at web.de
Sun Mar 4 19:41:43 CET 2012
Dear Haskell programmers,
I'm very confused, because I really don't know how to handle with IO's and other datatypes, such as Int or String.
If I want to build a haskell program can I only use IO() method outputs ? How can I "give" a Int result from a different method back to the main?
Would this mean that I have to create only IO() outputs? Is this correct?
-- A User has to choose something, so I need a IO() datatype
main :: IO()
main = do
let listtournementTime = [8,20,10,15]
-- This is wrong: Couldn't match expected type `IO t0' with actual type `Int'
-- The results of the method dauer is a Int. Do I have to transform the method to an IO() Output
a <- Dauer listtournementTime
-- the methods
dauer:: [Int] -> Int
| laenge(x:xs) == 1 = 0
| mod (laenge (x:xs)) 2 == 0 = (tmp x xs) + dauer xs
| mod (laenge (x:xs)) 2 /= 0 = dauer xs
| otherwise = 999999 -- failure
tmp:: Int -> [Int] -> Int
tmp y (x:xs) = x-y
laenge :: [a] -> Integer
laenge  = 0
laenge (x:xs) = 1 + laenge xs
The last three methods are working correct, if I directly put some data into the methods, like:
Thank you for any help
Best greetings from Namibia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe