[Haskell-cafe] Code review request - using ErrorT

2012-08-31 Thread C K Kashyap
Dear gentle Haskellers, I'd appreciate it very much if you could please take a look the my code here and give me some feedback - https://github.com/ckkashyap/haskell-websocket/blob/master/src/lib/Net/WebSocket/Request.hs I am particularly looking for advice around what would be a good type for

Re: [Haskell-cafe] code review?

2011-05-25 Thread Niklas Broberg
On Tue, May 24, 2011 at 7:18 PM, Neil Mitchell ndmitch...@gmail.com wrote: Before doing a code review I always demand that the author runs over the code with HLint (http://community.haskell.org/~ndm/hlint) - they Very good point. In fact you just inspired me to finally download it and

Re: [Haskell-cafe] code review?

2011-05-25 Thread Neil Mitchell
Hi Niklas, I use Uniplate inside HLint, and it's invaluable - there are a lot of times when List Comp + universeBi really hits the spot. +1 on that, I use uniplate for pretty much all my haskell-src-exts tasks these days, works like a charm! I'd love to include some standard traversal

Re: [Haskell-cafe] code review?

2011-05-24 Thread Evan Laforge
On Mon, May 23, 2011 at 12:02 PM, Neil Mitchell ndmitch...@gmail.com wrote: 'if all == False then return False else return True' is a pretty confusing way to say 'return all'.  In fact, any time you see 'x == True' you can just remove the '== True'.  The whole postAll thing would be clearer as

Re: [Haskell-cafe] code review?

2011-05-24 Thread Johannes Waldmann
Evan Laforge qdunkan at gmail.com writes: [...] a tool that wanted to traverse deep data structures as produced by haskell-src-exts. [...] I heard uniplate was pretty easy to use, and was pretty pleased to turn the entire thing into a single line. Please post that line here - J.W.

Re: [Haskell-cafe] code review?

2011-05-24 Thread Evan Laforge
On Tue, May 24, 2011 at 6:47 AM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Evan Laforge qdunkan at gmail.com writes: [...] a tool that wanted to traverse deep data structures as produced by haskell-src-exts. [...] I heard uniplate was pretty easy to use, and was pretty pleased to

Re: [Haskell-cafe] code review?

2011-05-24 Thread Neil Mitchell
Before doing a code review I always demand that the author runs over the code with HLint (http://community.haskell.org/~ndm/hlint) - they Very good point.  In fact you just inspired me to finally download it and run it on my own code.  Thanks for the great tool! Glad you like it. While I'm

Re: [Haskell-cafe] code review?

2011-05-24 Thread Henning Thielemann
Evan Laforge schrieb: I'd keep the line length down to 80 chars, and not use ';'s. You can find more programming tips in http://www.haskell.org/haskellwiki/Haskell_programming_tips and in other articles of the Haskell Wiki, e.g. in Category:Idioms, Category:Style, Category:FAQ.

Re: [Haskell-cafe] code review?

2011-05-23 Thread Neil Mitchell
'if all == False then return False else return True' is a pretty confusing way to say 'return all'.  In fact, any time you see 'x == True' you can just remove the '== True'.  The whole postAll thing would be clearer as Before doing a code review I always demand that the author runs over the

[Haskell-cafe] code review?

2011-05-22 Thread Chris Bolton
Hey guys. Pretty new to haskell here. I've started off by writing a small command-line interface to plurk.. I was just wondering if anyone would be willing to give everything a look-over and lemme know what kinds of things I should be looking to improve upon, style-wise. Not sure I'm currently

Re: [Haskell-cafe] code review?

2011-05-22 Thread Evan Laforge
I'd keep the line length down to 80 chars, and not use ';'s. All of that fiddling with buffering, printing, reading results could be more clearly put into a couple of functions. 'if all == False then return False else return True' is a pretty confusing way to say 'return all'. In fact, any time

Re: [Haskell-cafe] code review?

2011-05-22 Thread Alexander Solla
Good points. Here are a few more. Use more explicit types. You can cut down on if-then-else's by using pattern matching and guards. (For example, the first if-then-else in postStatus can be turned into: newtype PostToAllNetworks = PostToAll Bool newtype FirstPost = FirstPost Bool

[Haskell-cafe] Code review of text-xml-generic

2010-06-11 Thread Oscar Finnsson
Hi, I've been working on a (de)serialization package from/to XML (using SYB) and wondering if anyone feels like giving me a quick code review before I upload it to hackagedb. The source code can be found at http://github.com/finnsson/Text.XML.Generic It is *heavily* inspired by

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-05 Thread Tim Newsham
On Sat, Aug 2, 2008 at 10:13 PM, Tim Newsham [EMAIL PROTECTED] wrote: http://www.thenewsh.com/%7Enewsham/store/Server5.hs You should try profiling this. I can see a few possible problems (such as reading String from a socket, instead of a ByteString), but it's difficult to predict what might

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-04 Thread Bryan O'Sullivan
On Sat, Aug 2, 2008 at 10:13 PM, Tim Newsham [EMAIL PROTECTED] wrote: Anyone interested in critiquing some code? I'm looking for ideas for making it faster and/or simpler: http://www.thenewsh.com/%7Enewsham/store/Server5.hs The code looks fairly reasonable, although most of your strictness

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-04 Thread Tim Newsham
You should try profiling this. I can see a few possible problems (such as reading String from a socket, instead of a ByteString), but it's difficult to predict what might be causing your code to be so slow. Haskell code ought to be much more competitive with C for an application like this. I

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-04 Thread Brandon S. Allbery KF8NH
On 2008 Aug 4, at 23:45, Tim Newsham wrote: Anyway, I haven't yet used any ByteString IO functions. I ran some tests when I was starting and it seems that using Handle IO functions was a bit slower than using the Socket IO functions directly. It looks like there are a bunch of Handle IO

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-03 Thread Tim Newsham
newsham: Anyone interested in critiquing some code? I'm looking for ideas for making it faster and/or simpler: What optimisation and runtime flags did you use (-threaded or not?) currently ghc -O --make $ -o $@. For some measurements I tried -threaded which seemed to have a slight slowdown

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-03 Thread Duncan Coutts
On Sat, 2008-08-02 at 19:13 -1000, Tim Newsham wrote: My measurements show that a simple dummy server (accept, forkio, recv byte) handles roughly 7500 requests/connects per second, the server/client that do real messages do about 4500 req and connections per second. If all requests are on

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-03 Thread Tim Newsham
What kind of performance do you actually need? Can your network connection actually sustain the bandwidth of your synthetic benchmarks? This is just an exercise at the moment, so no particular performance goal beyond how fast can it go. (tested using apache-bench, loopback interface, amd64 @

[Haskell-cafe] code review? store server, 220loc.

2008-08-02 Thread Tim Newsham
Anyone interested in critiquing some code? I'm looking for ideas for making it faster and/or simpler: http://www.thenewsh.com/%7Enewsham/store/Server5.hs This is an exercise to see how well a server in Haskell would perform. My goals are roughly: - retargetability to other server types

Re: [Haskell-cafe] code review? store server, 220loc.

2008-08-02 Thread Don Stewart
newsham: Anyone interested in critiquing some code? I'm looking for ideas for making it faster and/or simpler: http://www.thenewsh.com/%7Enewsham/store/Server5.hs This is an exercise to see how well a server in Haskell would perform. My goals are roughly: - retargetability to

[Haskell-cafe] Code review: initial factoring for sequences and other structures

2006-08-03 Thread Brian Hulley
Hi - I've started work on an initial factoring of sequence ops into classes, and already I've run into some major design issues which stand like a mountain in the way of progress. The classes are below: -- all code below standard BSD3 licence :-) module Duma.Data.Class.Foldable (

Re: [Haskell-cafe] Code review: initial factoring for sequences andother structures

2006-08-03 Thread Brian Hulley
Brian Hulley wrote: Hi - I've started work on an initial factoring of sequence ops into [snip] class Foldable c a | c - a where foldR :: (a - b - b) - b - c - b [snip] There is a general problem that when the element type needs to be specified along with the type of the overall

Re: [Haskell-cafe] Code review: efficiency question

2006-05-03 Thread Brian Hulley
Bulat Ziganshin wrote: [ideas including reverseMapM_] you will laugh, but speed of your two solutions depends on so many factors (including size of CPU cache) that noone can say that is better in general. although for small lists reverseMapM_ should be faster than reverse+mapM. what will be

Re: [Haskell-cafe] Code review: efficiency question

2006-05-03 Thread Josef Svenningsson
Brian, You might also want to take a look at the list fusion functionality in GHC which often can help optimize your programs when programming with lists. http://www.haskell.org/ghc/docs/latest/html/users_guide/rewrite-rules.html#id3153234 It doesn't help in your particular program but it might

Re: [Haskell-cafe] Code review: efficiency question

2006-05-02 Thread Brian Hulley
Evan Martin wrote: I remember reading a tutorial that pointed out that you can often avoid explicit recusion in Haskell and instead use higher-level operators. For your code, I think drawModals = foldr (flip ()) (return ()) . map drawModal works(?). I think it would be foldl so that the

Re: [Haskell-cafe] Code review: efficiency question

2006-05-02 Thread Bulat Ziganshin
Hello Brian, Tuesday, May 2, 2006, 3:12:48 AM, you wrote: -- Prolog style coding... drawModals :: [Control] - ManagerM () drawModals [] = return () drawModals (c:cs) = do drawModals cs

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-16 Thread Daniel Fischer
I have added 'solve method F', aka X-wing, swordfish... (www.sudokusolver.co.uk) to my solver, that reduced the number of puzzles needing guesses to 5306, so I suppose that's it. I haven't yet implemented it efficiently, so it was devastating for performance - and solving thirteen puzzles more

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-14 Thread Chris Kuklewicz
I believe if you change the representation of puzzles from [(pos,range)] to an Array, you'll get a significant speedup yet because I only recently removed a logic bug that slowed down the search instead of speading it up; ..). so the more interesting bit is that our solvers disagree on which

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-11 Thread Chris Kuklewicz
Daniel Fischer wrote: My IDE is kate/kwrite + ghci + hugs, if you know a better one (which doesn't involve loading down a 99MB thing like eclipse), I'd be interested to try it out. (I already knew emacs, so using haskell-mode is my choice) I changed the output format to a line per puzzle

Re[2]: [Haskell-cafe] Code Review: Sudoku solver

2006-04-11 Thread Bulat Ziganshin
Hello Daniel, Tuesday, April 11, 2006, 3:26:06 AM, you wrote: Today, I wrote a version using IOArray, hoping to get incredibly fast in-place updating, and explicitly making copies via freeze and thaw when guessing is required, but no luck (maybe I just don't know how to do it properly), spent

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-10 Thread Claus Reinke
Mine's even faster now (at least on my computer, would you care to test it on your's? If you don't want to get EnumSet, just change DiffArray to Array, worked wonders for me), I'll dig into yours tomorrow to see what I can get out of it to improve my algorithm. Unforunately, no new inference

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-10 Thread Daniel Fischer
Moin Claus, Am Montag, 10. April 2006 10:11 schrieben Sie: Mine's even faster now (at least on my computer, would you care to test it on your's? If you don't want to get EnumSet, just change DiffArray to Array, worked wonders for me), I'll dig into yours tomorrow to see what I can get out

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-09 Thread Chris Kuklewicz
I just ran a simple metric for the dancing-links solver. The only real metric I could use was the number of coverOthers calls which counts the number of selections made (there is no distinction between certainty and guessing). So the minimum # of selections is 81 (of which 17 are the free hints,

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-09 Thread Daniel Fischer
Am Samstag, 8. April 2006 10:21 schrieb Chris Kuklewicz: Daniel Fischer wrote: But, lo and behold, I also tried how plain Array fared in comparison to DiffArray and ... reduced the running time to under ten minutes (a little above for the list version), 5% GC time without -AxM, 1.2% with

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-08 Thread Chris Kuklewicz
Daniel Fischer wrote: But, lo and behold, I also tried how plai Array fared in comparison to DiffArray and ... reduced the running time to under ten minutes (a little above for the list version), 5% GC time without -AxM, 1.2% with -A8M. And I thought, DiffArrays were supposed to be fast!

Re[2]: [Haskell-cafe] Code Review: Sudoku solver

2006-04-08 Thread Bulat Ziganshin
Hello Daniel, Saturday, April 8, 2006, 3:06:03 AM, you wrote: And I thought, DiffArrays were supposed to be fast! 1. your arrays are too small (8 elements only) 2. DiffArray use internally MVars. with IORefs they will be a lot faster -- Best regards, Bulat

Re[2]: [Haskell-cafe] Code Review: Sudoku solver

2006-04-08 Thread Bulat Ziganshin
Hello Chris, Saturday, April 8, 2006, 12:21:07 PM, you wrote: backtracking. And I can use STRef's to build it, instead of MVars. may be it's better to use unboxed arrays/references? -- Best regards, Bulatmailto:[EMAIL PROTECTED]

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-08 Thread Chris Kuklewicz
I have finished my cleanup of the dancing links based solver for Sudoku. I don't have time to compare performance with the other programs that have been posted recently, or to do more profiling of my code. For those who will say It is ugly, imperative, and ugly! please remember this is a

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-08 Thread Daniel Fischer
Am Samstag, 8. April 2006 02:20 schrieb Daniel Fischer: Am Freitag, 7. April 2006 17:33 schrieben Sie: Just out of curiosity, speed was not the objective when I wrote my solver, I wanted to avoid guesswork (as much as possible), but in comparison with Cale Gibbard's and Alson Kemp's

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-08 Thread Daniel Fischer
Am Samstag, 8. April 2006 20:28 schrieb Chris Kuklewicz: I have finished my cleanup of the dancing links based solver for Sudoku. I don't have time to compare performance with the other programs that have been posted recently, or to do more profiling of my code. Your dancing links: ckSud

Re[2]: [Haskell-cafe] Code Review: Sudoku solver

2006-04-07 Thread Bulat Ziganshin
Hello Daniel, Friday, April 7, 2006, 2:05:03 AM, you wrote: I've cleaned up my solver, removed a lot of redundant inference steps and made the board a DiffArray (is that really faster?). btw, DiffArray implementation can be made significantly faster by using IORefs instead of MVars -- Best

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-07 Thread Claus Reinke
Just out of curiosity, speed was not the objective when I wrote my solver, I wanted to avoid guesswork (as much as possible), but in comparison with Cale Gibbard's and Alson Kemp's solvers (which are much more beautifully coded), it turned out that mine is blazingly fast, so are there faster

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-07 Thread Daniel Fischer
Am Freitag, 7. April 2006 01:50 schrieben Sie: On Apr 6, 2006, at 6:05 PM, Daniel Fischer wrote: I've also written a version using David F. Place's EnumSet instead of [Int], that takes less MUT time, but more GC time, so is slower on the 36,628 test, but faster for a single puzzle.

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-07 Thread Daniel Fischer
Am Freitag, 7. April 2006 17:33 schrieben Sie: Just out of curiosity, speed was not the objective when I wrote my solver, I wanted to avoid guesswork (as much as possible), but in comparison with Cale Gibbard's and Alson Kemp's solvers (which are much more beautifully coded), it turned out

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-06 Thread Claus Reinke
Curry does not have a constraint solver of its own. It simply delegates all constraints to the FD solver of SICStus Prolog. or that of SWI Prolog (which prompted my attempt to install Curry). which was implemented by..hi, again!-) (*) The all_different constraint subsumes the rules that

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-06 Thread Tom Schrijvers
On Thu, 6 Apr 2006, Claus Reinke wrote: Curry does not have a constraint solver of its own. It simply delegates all constraints to the FD solver of SICStus Prolog. or that of SWI Prolog (which prompted my attempt to install Curry). which was implemented by..hi, again!-) (*) The

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-06 Thread Daniel Fischer
Am Mittwoch, 5. April 2006 15:09 schrieb Chris Kuklewicz: Henning Thielemann wrote: On Mon, 3 Apr 2006, Jared Updike wrote: or ambiguously) with your Sudoku solver? A rough mesaure of the difficulty of the unsolved puzzle could be how long the solver took to solve it (number of steps)

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-06 Thread David F. Place
On Apr 6, 2006, at 6:05 PM, Daniel Fischer wrote:I've also written a version using David F. Place's EnumSet instead of [Int], that takes less MUT time, but more GC time, so is slower on the 36,628 test,  but faster for a single puzzle. That's a curious result.  Did you compile with optimization? 

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-05 Thread Henning Thielemann
On Mon, 3 Apr 2006, Jared Updike wrote: or ambiguously) with your Sudoku solver? A rough mesaure of the difficulty of the unsolved puzzle could be how long the solver took to solve it (number of steps) (and the number of possible solutions)? Are puzzles with multiple solutions usually

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-05 Thread Chris Kuklewicz
Henning Thielemann wrote: On Mon, 3 Apr 2006, Jared Updike wrote: or ambiguously) with your Sudoku solver? A rough mesaure of the difficulty of the unsolved puzzle could be how long the solver took to solve it (number of steps) (and the number of possible solutions)? Are puzzles with

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-04 Thread Jared Updike
On 4/3/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote: It would also be nice to see some example sudoku solvers posted on an `Idioms' page on haskell.org: http://www.haskell.org/haskellwiki/Category:Idioms someone could just create a new page 'Sudoku' and add the phrase

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Claus Reinke
It solves sudoku puzzles. (What pleasure do people get by doing these in their heads?!?) probably the same you get from writing programs?-) figuring out the rules, not getting lost in complexity, making something difficult work.. They are probably asking the same question: why take hours

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Chris Kuklewicz
Claus Reinke wrote: It solves sudoku puzzles. (What pleasure do people get by doing these in their heads?!?) probably the same you get from writing programs?-) figuring out the rules, not getting lost in complexity, making something difficult work.. From a human standpoint, there are

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Jared Updike
Chris wrote: You need more than 5 examples. The truly evil puzzles are rarer than that. Go get the set of minimal puzzles and see how far your logic takes you. Chris elucidated some of my questions before I finished writing my email... Claus wrote: (*) actually, that was a bit

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Tom Schrijvers
since I haven't factored out the constraint propagation into a general module, the core of my code is a lot longer than the Curry version (about 60 additional lines, though I'm sure one could reduce that;-). the only negative point I can find about the Curry example is that it isn't obvious

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Chris Kuklewicz
Jared Updike wrote: Chris wrote: You need more than 5 examples. The truly evil puzzles are rarer than that. Go get the set of minimal puzzles and see how far your logic takes you. Chris elucidated some of my questions before I finished writing my email... Claus wrote: (*) actually,

Re[2]: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Bulat Ziganshin
Hello it seems that sudoku solver may be a good candidate for nofib suite / language comparison shootout -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Donald Bruce Stewart
bulat.ziganshin: Hello it seems that sudoku solver may be a good candidate for nofib suite / language comparison shootout It would also be nice to see some example sudoku solvers posted on an `Idioms' page on haskell.org: http://www.haskell.org/haskellwiki/Category:Idioms someone could

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-04-03 Thread Daniel Fischer
Am Montag, 3. April 2006 18:52 schrieb Chris Kuklewicz: Claus Reinke wrote: It solves sudoku puzzles. (What pleasure do people get by doing these in their heads?!?) probably the same you get from writing programs?-) figuring out the rules, not getting lost in complexity, making

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-23 Thread Michael Hanus
Jared Updike wrote: On 3/22/06, David F. Place [EMAIL PROTECTED] wrote: ... It solves sudoku puzzles. (What pleasure do people get by doing these in their heads?!?) They are probably asking the same question: why take hours to write a program to do it when with my mad sudoku solving

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-23 Thread David F. Place
Thanks for your helpful suggestions. I took them to heart and incorporated many of them in a new version. sudoku.hs Description: Binary data David F. Place mailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing

[Haskell-cafe] Code Review: Sudoku solver

2006-03-22 Thread David F. Place
Hi All, I really appreciate all the help I received when I asked you to critique my PrefixMap module a few weeks ago. I think I am making good progress in correcting the lisp in my Haskell programming. I'll be very grateful to anyone who can take a glance at the attached short program

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-22 Thread Jared Updike
On 3/22/06, David F. Place [EMAIL PROTECTED] wrote: Hi All, I really appreciate all the help I received when I asked you to critique my PrefixMap module a few weeks ago. I think I am making good progress in correcting the lisp in my Haskell programming. I'll be very grateful to anyone who

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-22 Thread Robert Dockins
On Mar 22, 2006, at 2:16 PM, David F. Place wrote: Hi All, I really appreciate all the help I received when I asked you to critique my PrefixMap module a few weeks ago. I think I am making good progress in correcting the lisp in my Haskell programming. I'll be very grateful to anyone

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-22 Thread Chris Kuklewicz
Robert Dockins wrote: On Mar 22, 2006, at 2:16 PM, David F. Place wrote: Hi All, I really appreciate all the help I received when I asked you to critique my PrefixMap module a few weeks ago. I think I am making good progress in correcting the lisp in my Haskell programming. The style