On Wed, 27 Feb 2002, Juan M. Duran wrote: > I got a function with type :: IO [[Double]], and what I want is write this > output in a file, how can I do it... I mean, I cannot doit by just using > writeFile.... (snip)
Does something like this help at all? myfn :: IO [[Double]] myfn = return [[1.346, 4.144], [5.143, 2.453]] format_doubles :: [[Double]] -> String format_doubles x = foldr (++) "" (map format_line x) format_line :: [Double] -> String format_line [] = "\n" format_line x = foldr1 (\x y -> x ++ ", " ++ y) (map show x) ++ "\n" main = myfn >>= (\x -> return $ format_doubles x) >>= putStr Okay, it's not the most readable bit of code, but I'm guessing it covers the bit that's confusing you. All the best, Mark _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe