I'm not a Haskell expert but here the solution to your problem that I can think of. import Data.List prettyStr :: Int -> String -> IO () prettyStr maxlen str = do putStr ("\"" ++ head brokenStr) mapM_ (\str -> putStr ("\\\n\\" ++ str)) (tail brokenStr) putStr "\"\n" where brokenStr = map (snd.unzip) $ groupBy (\_ (i,_) -> i `mod` maxlen /= 0) $ zip [0..] str Ed On Sat, Sep 20, 2008 at 4:14 PM, Maurício <briqueabraque@yahoo.com> wrote:
Hi,
I'm using Language.Haskell.* and would like to know if it's possible to pretty-print big strings like this:
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
into something like this:
"aaaaaaaa\ \aaaaaaaa\ \aaaaaaaa\ \aaaaaaaa\ \aaaaaaaa\ \aaaaaaaa\ \aaaaaaaa"
to respect the limit on number of columns. Can you help me? Is it possible to do that?
Thanks, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe