Haskell spacing problem.

Hi Haskell ppl, I'm trying to solve a problem that had been bothering me for a long time. I'm trying to create index and display the index in Hugs as well as an output text file. Below is my code. In Hugs, the index managed to get displayed well with nice alignments. However, for the text file, the alignment is off. The bracket with the numbers are messy. I really don't know why this would happen. Desired output: Anna [1] Ben [2] Shane [3] dispTable :: [([Int], Word)] -> String dispTable = unlines . map (\ (num,word) -> word ++ take (25 - (length word)) (repeat ' ') ++ show num) Did i do sth wrong? Thanks in advance.

that seems like the "wrong" way
check out prettyprint in the standard library
On 3/9/07, Frozz
Hi Haskell ppl,
I'm trying to solve a problem that had been bothering me for a long time. I'm trying to create index and display the index in Hugs as well as an output text file.
Below is my code. In Hugs, the index managed to get displayed well with nice alignments. However, for the text file, the alignment is off. The bracket with the numbers are messy. I really don't know why this would happen.
Desired output:
Anna [1] Ben [2] Shane [3]
dispTable :: [([Int], Word)] -> String dispTable = unlines . map (\ (num,word) -> word ++ take (25 - (length word)) (repeat ' ') ++ show num)
Did i do sth wrong? Thanks in advance.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

prettyPrint seems complicated..
Dan Mead
that seems like the "wrong" waycheck out prettyprint in the standard library
On 3/9/07, Frozz < dj_frozz <at> hotmail.com> wrote:Hi Haskell ppl,I'm trying to solve a
trying to create index and display the index in Hugs as well as an output textfile.Below is my code. In Hugs, the index managed to get displayed well with nicealignments. However, for the text file, the alignment is off. The bracket with the numbers are messy. I really don't know why this would happen.Desired output:Anna [1]Ben [2]Shane [3]dispTable :: [([Int], Word)] -> StringdispTable = unlines . map (\ (num,word) -> word ++ take (25 - (length word)) (repeat ' ') ++ show num)Did i do sth wrong? Thanks in advance._______________________________________________Haskell-Cafe mailing
problem that had been bothering me for a long time. I'm list
Haskell-Cafe <at> haskell.orghttp://www.haskell.org/mailman/listinfo/haskell- cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 09/03/07, Frozz
Hi Haskell ppl,
I'm trying to solve a problem that had been bothering me for a long time. I'm trying to create index and display the index in Hugs as well as an output text file.
dispTable is a pure function so you'll get the same result irrespective of what you do with the resulting string (ie. display it in Hugs or write it to a file). Are you _sure_ you're giving this function the same input (eg, is there maybe some extra whitespace or non-printable characters) ? - Joe
participants (3)
-
Dan Mead
-
Frozz
-
Joe Thornber