[Haskell-cafe] Unwrapping long lines in text files

michael rice nowgate at yahoo.com
Sat Aug 14 09:41:25 EDT 2010

Hi Filipe, Bill

Your corrected version works, while the original didn't, but it still produces incorrect

However mean your life is, meet it and live it: do not shun it and call 
it hard names. Cultivate poverty like a garden herb, like sage. Do not t
rouble yourself much to get new things, whether clothes or friends. Thin
gs do not change, we change. Sell your clothes and keep your thoughts. G
od will see that you do want society.
Men have become the tools of their tools.
I know of no more encouraging fact than the unquestioned ability of a ma
n to elevate his life by conscious endeavor.
I once had a sparrow alight upon my shoulder for a moment, while I was h
oeing in a village garden, and I felt that I was more distinguished by t
hat circumstance that I should have been by any epaulet I could have wor

I don't want to break lines in the middle of words and I want to retain the original structure of the text with respect to blank lines between individual quotes. THe only thing in the input text that should change are the lines longer than 72 characters, and they should be reformatted to one or more lines less than or equal to 72 characters.


--- On Sat, 8/14/10, Felipe Lessa <felipe.lessa at gmail.com> wrote:

From: Felipe Lessa <felipe.lessa at gmail.com>
Subject: Re: [Haskell-cafe] Unwrapping long lines in text files
To: "Bill Atkins" <watkins at alum.rpi.edu>
Cc: "michael rice" <nowgate at yahoo.com>, haskell-cafe at haskell.org
Date: Saturday, August 14, 2010, 9:17 AM

On Sat, Aug 14, 2010 at 9:59 AM, Bill Atkins <watkins at alum.rpi.edu> wrote:
>  | otherwise                                        = let (line, rest) = splitAt maxLineLength line in
>                                                                 line : wrapLine rest

I haven't tested myself, but does this work at all?  If I am reading
it correctly, this is the same as

  let (foo, rest) = splitAt maxLineLength foo
  in foo : wrapLine rest

In other words, no mention of wrapLine's argument 'line', and a
recursive call that will bottom out and be the same as 'undefined' :).
 GHC would warn you, though, if you used -Wall.  That expression
should read:

  let (thisLine, rest) = splitAt maxLineLength line
  in thisLine : wrapLine rest



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100814/54ed2a97/attachment.html

More information about the Haskell-Cafe mailing list