[Haskell-beginners] Haskell Output Help

Brent Yorgey byorgey at seas.upenn.edu
Fri Oct 23 10:26:04 EDT 2009

On Thu, Oct 22, 2009 at 12:11:07PM -0700, Chandni Navani wrote:
> I have a list of lists which all contain strings.  [[String]].  I need to figure out how to print them so that after each individual string, there is a new line.
> If this is the initial list [["abc", "cde"] ["fgh", "ghi"]]
> [["abc"
>   "cde"]
>  ["fgh",
>   "ghi"]]
> Can anyone help me figure this out? Thanks.

Most of the other solutions I've seen people post would output something like


But if you actually want brackets and quotes etc. to show the
structure, you could do something like

putStrLn . bracket . intercalate ",\n " .  map (bracket . intercalate ",\n  " . map show)
  where bracket x = "[" ++ x ++ "]"

Just transform the list step-by-step into the particular String you want as output.


More information about the Beginners mailing list