[Haskell-cafe] Re: The Worker/Wrapper Transformation
jonathanccast at fastmail.fm
Thu Jan 3 11:18:17 EST 2008
On 3 Jan 2008, at 4:49 AM, Isaac Dupree wrote:
> Achim Schneider wrote:
>> Achim Schneider <barsoap at web.de> wrote:
>> I'm trying to grok that
>>  = id
>> ++ = .
>> in the context of Hughes lists.
> they are also known as "difference lists", and also used at type
> String in the Prelude as "ShowS", to help avoid quadratic behavior
> when making complicated Strings. the [a]->[a] is not an ordinary
> function -- it's expected not to examine its argument, just to use
> it exactly once (is there a formal way to say that?)
f xn = f  ++ xn
is the first thing off the top of my head.
OTOH, examining your argument (while, strictly speaking unsafe) is
pretty darn cool:
f  = "foo"
f (c:s) | isAlphaNum c = "foo "++c:s
| otherwise = "foo"++c:s
More information about the Haskell-Cafe