Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: clarity and complexity of Haskell code? (David McBride) ---------------------------------------------------------------------- Message: 1 Date: Mon, 26 Sep 2011 04:28:42 -0400 From: David McBride <toa...@gmail.com> Subject: Re: [Haskell-beginners] clarity and complexity of Haskell code? To: cas...@istar.ca Cc: beginners@haskell.org Message-ID: <can+tr41hlfcovzglqghzbe_wgvktc4xy2cuunfyx-xt2eg8...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 As the guy that wrote that original snippet, II could always have done this in an imperative style using lazy IO and it would have been clearer. But this way is just superior in terms of resources and extensibility. Someone wanted to know what the best way to do this in haskell is and I think that is it. This is no different than using a library in another language. I will admit it took me awhile to learn how to use enumerator. But once I did I found it to be an absolutely amazing way to think about many common problems that I do. What I like about it is that in this case, I only needed to do one thing to the data. This took me about 2 minutes to write and it worked on the first try. If there were an database system that used the enumerator library, I would be able to do much of my daily workload in haskell. Do I wish the enumerator library would be a little easier to use? Yes I do. Is that even possible? I don't know. On Sun, Sep 25, 2011 at 5:07 PM, <cas...@istar.ca> wrote: > Haskell is designed for heavy computational lifting; your example is not an > example of major computational power. > > So, of course, Haskell code will not be short in ALL cases. :) > > > Quoting Ozgur Akgun <ozgurak...@gmail.com>: > >> Hi. >> >> On 25 September 2011 18:10, Brent Yorgey <byor...@seas.upenn.edu> wrote: >> >>> You must at least agree that it is short. >> >> >> Not trying to start language wars here, but it is not terribly short for >> what it does. The following code does the same thing in C#, and isn't far >> longer. And it has more or less a one-to-one correspondence to the given >> Haskell code; open a file for reading, open a file for writing, read some >> number of bytes, apply the transformation, write it to the output file. >> Flushing the input/output buffers and closing the files are handled by the >> using construct, similar to withFile in the Haskell example. >> >> int chunksize = 4096; >> using (var r = new BinaryReader(File.OpenRead("infile"))) >> ? ?using (var w = new BinaryWriter(File.OpenWrite("outfile"))) >> ? ? ? ?for (var buffer = r.ReadBytes(chunksize); buffer.Length > 0; buffer >> = r.ReadBytes(chunksize)) >> ? ? ? ? ? ?w.Write(Array.ConvertAll(buffer, p => (byte) ~p)); >> >> I think the habit of using quite a few operators in Haskell does make the >> learning curve steeper. >> >> I am not trying to say that the C# code is *better. *Just that the Haskell >> code is not terribly short in this case and it can be a bit cryptic for a >> newbie. >> >> Best, >> Ozgur >> > > > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 39, Issue 33 *****************************************