Re: [Haskell-cafe] library on common sub-expression elimination?
Wouldn't this be dependent upon your AST and thus not readily package-able as a library? Expression simplification has been a prime example for Strafunski style traversal libraries. You might be able to find examples that you can adapt to your own AST written with Uniplate or similar library. On 11 August 2011 05:00, Anton Kholomiov anton.kholom...@gmail.com wrote: Is there a library on common sub-expression elimination? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
On 11 August 2011 05:17, John Millikin jmilli...@gmail.com wrote: This is just a quick package I whipped up out of frustration with test-framework scrolling an error message out of sight, for the millionth time. Patches to make test-framework less noisy (either by default or with a flag) will be gratefully accepted, if anyone wants to give it a go :-) Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] library on common sub-expression elimination?
Thank you for the reference to Strafunski libraries, I read HaskellWiki, but I don't have a permission to visit their site. All links are forbidden. Can it be a function: fun :: Eq a = Tree a - [(Int, (a, [Int]))] where tuple codes nodes, and Int's code edges. 2011/8/11 Stephen Tetley stephen.tet...@gmail.com Wouldn't this be dependent upon your AST and thus not readily package-able as a library? Expression simplification has been a prime example for Strafunski style traversal libraries. You might be able to find examples that you can adapt to your own AST written with Uniplate or similar library. On 11 August 2011 05:00, Anton Kholomiov anton.kholom...@gmail.com wrote: Is there a library on common sub-expression elimination? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: yap-0.0 - yet another prelude
[switched to Cafe] On Wed, Aug 10, 2011 at 11:46 PM, Henning Thielemann lemm...@henning-thielemann.de wrote: On Wed, 10 Aug 2011, Paterson, Ross wrote: Yet another restructuring of the Prelude numeric classes on algebraic lines, proposed for a revision of the Haskell Prelude: http://hackage.haskell.org/package/yap-0.0 A nice lightweight design, both in terms of the use of type extensions and import dependencies, that should people encourage to use it, when they are afraid of changing to a more radical approach like numeric-prelude. I would have prefered the name AdditiveGroup to AbelianGroup, since with '+' and '-' and '0' I associate more than just the laws of an Abelian group. The multiplicative group of rational numbers is abelian, too. I'm curious: what laws do you have in mind for '+', '-', and '0' that do not hold in the multiplicative group of rational numbers with (+) = (*); (-) = (/); 0 = 1 ? Sebastian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: yap-0.0 - yet another prelude
On Thu, 11 Aug 2011, Sebastian Fischer wrote: [switched to Cafe] On Wed, Aug 10, 2011 at 11:46 PM, Henning Thielemann lemm...@henning-thielemann.de wrote: On Wed, 10 Aug 2011, Paterson, Ross wrote: Yet another restructuring of the Prelude numeric classes on algebraic lines, proposed for a revision of the Haskell Prelude: http://hackage.haskell.org/package/yap-0.0 A nice lightweight design, both in terms of the use of type extensions and import dependencies, that should people encourage to use it, when they are afraid of changing to a more radical approach like numeric-prelude. I would have prefered the name AdditiveGroup to AbelianGroup, since with '+' and '-' and '0' I associate more than just the laws of an Abelian group. The multiplicative group of rational numbers is abelian, too. I'm curious: what laws do you have in mind for '+', '-', and '0' that do not hold in the multiplicative group of rational numbers with (+) = (*); (-) = (/); 0 = 1 ? I do not associate more laws, but I expect to use zero for things that are somehow related to numbers. And I also do not want to use (+) and (-), say, for rational numbers to mean (*) and (/). That's not an algebraical reason, but a matter of error prevention and expectations. It's the same reason, why I would not want to define an Ord instance for Complex numbers. Complex numbers can be ordered, but a (b::Complex Rational) will be a mistake in many cases, I guess. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] library on common sub-expression elimination?
Strafunski and its successors (Uniplate, SYB, KURE) are really for working on trees. If you want to work on graphs you would probably be better of with something else. I think I overlooked that you want common sub-expression _elimination_, rather than expression simplification. There are libraries for observable sharing (Andy Gill's recent one is the state-of-the-art, its on Hackage but I've forgotten its name) - that are pertinent where you have built the expressions as an embedded DSL in Haskell and you want sharing in code you generate from the Haskell DSL. On 11 August 2011 08:57, Anton Kholomiov anton.kholom...@gmail.com wrote: Thank you for the reference to Strafunski libraries, I read HaskellWiki, but I don't have a permission to visit their site. All links are forbidden. Can it be a function: fun :: Eq a = Tree a - [(Int, (a, [Int]))] where tuple codes nodes, and Int's code edges. 2011/8/11 Stephen Tetley stephen.tet...@gmail.com Wouldn't this be dependent upon your AST and thus not readily package-able as a library? Expression simplification has been a prime example for Strafunski style traversal libraries. You might be able to find examples that you can adapt to your own AST written with Uniplate or similar library. On 11 August 2011 05:00, Anton Kholomiov anton.kholom...@gmail.com wrote: Is there a library on common sub-expression elimination? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New releases and BSD3 license
Thanks for the more permissive licenses. And most of all, thanks for all your great work on HDBC as maintainer. Thanks and good luck to Nicolas. Regards, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] library on common sub-expression elimination?
I guess you refer to data-reify: http://hackage.haskell.org/package/data-reify 2011/8/11 Stephen Tetley stephen.tet...@gmail.com: Strafunski and its successors (Uniplate, SYB, KURE) are really for working on trees. If you want to work on graphs you would probably be better of with something else. I think I overlooked that you want common sub-expression _elimination_, rather than expression simplification. There are libraries for observable sharing (Andy Gill's recent one is the state-of-the-art, its on Hackage but I've forgotten its name) - that are pertinent where you have built the expressions as an embedded DSL in Haskell and you want sharing in code you generate from the Haskell DSL. On 11 August 2011 08:57, Anton Kholomiov anton.kholom...@gmail.com wrote: Thank you for the reference to Strafunski libraries, I read HaskellWiki, but I don't have a permission to visit their site. All links are forbidden. Can it be a function: fun :: Eq a = Tree a - [(Int, (a, [Int]))] where tuple codes nodes, and Int's code edges. 2011/8/11 Stephen Tetley stephen.tet...@gmail.com Wouldn't this be dependent upon your AST and thus not readily package-able as a library? Expression simplification has been a prime example for Strafunski style traversal libraries. You might be able to find examples that you can adapt to your own AST written with Uniplate or similar library. On 11 August 2011 05:00, Anton Kholomiov anton.kholom...@gmail.com wrote: Is there a library on common sub-expression elimination? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Additional functions of GMP
GMP has a lot of functions, such as extracting roots, primality test, Legendre symbol, factorial and so on. These can be written in Haskell, of course, but isn't it better to use existing functions? They are also much faster than similar functions from NumericPrelude, I believe. I have heard GHC 7.2.1 now includes module named GHC.Integer.Logarithms, but I can't find its description anywhere. So, my question is: can I use full power of GMP's functions, and if I can — how? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: yap-0.0 - yet another prelude
Sebastian Fischer [fisc...@nii.ac.jp] wrote: I'm curious: what laws do you have in mind for '+', '-', and '0' that do not hold in the multiplicative group of rational numbers with (+) = (*); (-) = (/); 0 = 1 ? x - x = zero, for one. (with x the other 0) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Additional functions of GMP
On Thursday 11 August 2011, 14:06:21, Artyom Kazak wrote: GMP has a lot of functions, such as extracting roots, primality test, Legendre symbol, I'm writing a package (arithmoi) that will include reasonably fast implementations of those, but I never find the time to finish it :( factorial and so on. These can be written in Haskell, of course, but isn't it better to use existing functions? Not necessarily. But They are also much faster than similar functions from NumericPrelude, I believe. There's that. I have heard GHC 7.2.1 now includes module named GHC.Integer.Logarithms, but I can't find its description anywhere. http://haskell.org/ghc/docs/7.2.1/html/libraries/integer-gmp-0.3.0.0/GHC- Integer-Logarithms.html So, my question is: can I use full power of GMP's functions, and if I can — how? No, you can't, unfortunately (not easily, anyway). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Distributions link on Hackage
Hi, the home page of a package on Hackage links to various distributions to show which versions are available, i.e. Fedora, Debian, FreeBSD, etc. In NixOS, we have fairly up-to-date package set, and I would like to see that distribution included on Hackage. Now I wonder how to get that done? Can anyone advice on the procedure to add support for a distribution to Hackage? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Can I have a typeclass for topological spaces?
Hello! I just wonder whether it is possible to have a typeclass for topological spaces? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
Hi John, I am wondering if you have seen the hspec package? [1] It seems to solve all the problems you are with chell, including that it silences Hunit output. We are using it for all the Yesod tests now. Thanks, Greg Weber [1]: http://hackage.haskell.org/packages/archive/hspec/0.6.1/doc/html/Test-Hspec.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
I have, but it's not quite what I'm looking for: - I don't want to silence HUnit's output, I just don't want anything to show on the console when a test *passes*. Showing output on a failure is good. - I'm not interested in BDD. Not to say it's not useful, but it doesn't match my style of testing (which uses mostly pass/fail assertions and properties). On Thu, Aug 11, 2011 at 07:18, Greg Weber g...@gregweber.info wrote: Hi John, I am wondering if you have seen the hspec package? [1] It seems to solve all the problems you are with chell, including that it silences Hunit output. We are using it for all the Yesod tests now. Thanks, Greg Weber [1]: http://hackage.haskell.org/packages/archive/hspec/0.6.1/doc/html/Test-Hspec.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trouble with readProcess
Hi -cafe, I'm using readProcess and I don't know how to handle this issue: readProcess cmd [opt1,opt2] seems to execute the following: $ cmd opt1 opt2 That is usually fine, but I'm using an external program that doesn't understand the quotes, so I need to execute instead: $ cmd opt1 opt2 How should I do that? -- Cp ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
I tried, actually, but couldn't figure out how to separate running the test from printing its output. All the attempted patches turned into huge refactoring marathons. When given the choice between sending a huge replace all your code with my code patch, and just releasing a separate package, I prefer to do the second. There's usually a reason a library behaves as it does, and this way both behaviors are available to users (even if I find one frustrating). On Wed, Aug 10, 2011 at 23:51, Max Bolingbroke batterseapo...@hotmail.com wrote: On 11 August 2011 05:17, John Millikin jmilli...@gmail.com wrote: This is just a quick package I whipped up out of frustration with test-framework scrolling an error message out of sight, for the millionth time. Patches to make test-framework less noisy (either by default or with a flag) will be gratefully accepted, if anyone wants to give it a go :-) Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
It silences HUnit's output, but will tell you what happens when there is a failure- which I think is what you want. There are a few available output formatters if you don't like the default output, or you can write your own output formatter. BDD is really a red herring. Instead of using function names to name tests you can use strings, which are inherently more descriptive. In chell you already have `assertions numbers`, in hspec it would be `it numbers`. The preferred style it to remove `test test_Numbers and the test_Numbers definition` which are redundant in this case, and instead place that inline where you define the suite, although that is optional. So I really can't tell any difference betwee BDD and pass/fail assertions. You still just use assertions in hspec. On Thu, Aug 11, 2011 at 7:36 AM, John Millikin jmilli...@gmail.com wrote: I have, but it's not quite what I'm looking for: - I don't want to silence HUnit's output, I just don't want anything to show on the console when a test *passes*. Showing output on a failure is good. - I'm not interested in BDD. Not to say it's not useful, but it doesn't match my style of testing (which uses mostly pass/fail assertions and properties). On Thu, Aug 11, 2011 at 07:18, Greg Weber g...@gregweber.info wrote: Hi John, I am wondering if you have seen the hspec package? [1] It seems to solve all the problems you are with chell, including that it silences Hunit output. We are using it for all the Yesod tests now. Thanks, Greg Weber [1]: http://hackage.haskell.org/packages/archive/hspec/0.6.1/doc/html/Test-Hspec.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
On Thu, Aug 11, 2011 at 07:52, Greg Weber g...@gregweber.info wrote: It silences HUnit's output, but will tell you what happens when there is a failure- which I think is what you want. There are a few available output formatters if you don't like the default output, or you can write your own output formatter. I'm a bit confused. From what I can tell, HUnit does not output *anything* just from running a test -- the result has to be printed manually. What are you silencing? BDD is really a red herring. Instead of using function names to name tests you can use strings, which are inherently more descriptive. In chell you already have `assertions numbers`, in hspec it would be `it numbers`. The preferred style it to remove `test test_Numbers and the test_Numbers definition` which are redundant in this case, and instead place that inline where you define the suite, although that is optional. So I really can't tell any difference betwee BDD and pass/fail assertions. You still just use assertions in hspec. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Additional functions of GMP
I'm writing a package (arithmoi) that will include reasonably fast implementations of those, but I never find the time to finish it :( Package is great, but sometimes it is useful to have such functions out of box (for example, when solving SPOJ problems). No, you can't, unfortunately (not easily, anyway). I have found a manual on including additional primops in GHC (exactly this situation), but this requires modifying GHC's sources, which also does not allow using them with SPOJ. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble with readProcess
Quoth Charles-Pierre Astolfi c...@crans.org, readProcess cmd [opt1,opt2] seems to execute the following: $ cmd opt1 opt2 That is usually fine, but I'm using an external program that doesn't understand the quotes, so I need to execute instead: $ cmd opt1 opt2 How should I do that? I think your analysis is wrong. I don't know what to suggest, though if you follow up you probably should mention what platform you're running on. Maybe you could devise a simple test program that illustrates the problem? Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Can I have a typeclass for topological spaces?
Oh, I guess the class would look something like that: class TopologicalSpace a where ifOpen :: (Subset a) - Bool and Subset x is a type corresponding to subsets of x. 11.08.2011, 17:52, Grigory Sarnitskiy sargrig...@ya.ru: Hello! I just wonder whether it is possible to have a typeclass for topological spaces? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble with readProcess
Am 11.08.2011 16:45, schrieb Charles-Pierre Astolfi: Hi -cafe, I'm using readProcess and I don't know how to handle this issue: readProcess cmd [opt1,opt2] seems to execute the following: are you sure that your argument strings do not contain the quotes, possibly by calling show on arguments that are already strings. C. $ cmd opt1 opt2 That is usually fine, but I'm using an external program that doesn't understand the quotes, so I need to execute instead: $ cmd opt1 opt2 How should I do that? -- Cp ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
I am confused also, as to both what output you don't like that motivated chell and what exactly hspec silences :) Suffice to say I am able to get a small relevant error message on failure with hspec. I am adding the hspec maintainer to this e-mail- he can answer any of your questions. On Thu, Aug 11, 2011 at 8:03 AM, John Millikin jmilli...@gmail.com wrote: On Thu, Aug 11, 2011 at 07:52, Greg Weber g...@gregweber.info wrote: It silences HUnit's output, but will tell you what happens when there is a failure- which I think is what you want. There are a few available output formatters if you don't like the default output, or you can write your own output formatter. I'm a bit confused. From what I can tell, HUnit does not output *anything* just from running a test -- the result has to be printed manually. What are you silencing? BDD is really a red herring. Instead of using function names to name tests you can use strings, which are inherently more descriptive. In chell you already have `assertions numbers`, in hspec it would be `it numbers`. The preferred style it to remove `test test_Numbers and the test_Numbers definition` which are redundant in this case, and instead place that inline where you define the suite, although that is optional. So I really can't tell any difference betwee BDD and pass/fail assertions. You still just use assertions in hspec. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
On Thu, Aug 11, 2011 at 08:17, Greg Weber g...@gregweber.info wrote: I am confused also, as to both what output you don't like that motivated chell and what exactly hspec silences :) Suffice to say I am able to get a small relevant error message on failure with hspec. I am adding the hspec maintainer to this e-mail- he can answer any of your questions. The output I didn't like wasn't coming from HUnit, it was coming from the test aggregator I used (test-framework). It prints one line per test case run, whether it passed or failed. That means every time I ran my test suite, it would print *thousands* of lines to the terminal. Any failure immediately scrolled up and out of sight, so I'd have to either Ctrl-C and hunt it down, or wait for the final report when all the tests had finished running. Chell does the same thing as test-framework (aggregates tests into suites, runs them, reports results), but does so quietly. It only reports failed and aborted tests. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble with readProcess
I've found my mistake: I was calling readProcess cmd [-p -t] instead of readProcess cmd [-p,-t] Not sure what are the semantics of quotation in this case, though. And I'm pretty sure my analysis is wrong because of that :) -- Cp On Thu, Aug 11, 2011 at 16:05, Donn Cave d...@avvanta.com wrote: Quoth Charles-Pierre Astolfi c...@crans.org, readProcess cmd [opt1,opt2] seems to execute the following: $ cmd opt1 opt2 That is usually fine, but I'm using an external program that doesn't understand the quotes, so I need to execute instead: $ cmd opt1 opt2 How should I do that? I think your analysis is wrong. I don't know what to suggest, though if you follow up you probably should mention what platform you're running on. Maybe you could devise a simple test program that illustrates the problem? Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New releases and BSD3 license
Thanks, Jeremy -- appreciate it! -- John On 08/10/2011 02:57 PM, Jeremy Shaw wrote: Awesome! I believe MissingH includes some code that I contributed (or used to). That can all be licensed BSD3. - jeremy On Wed, Aug 10, 2011 at 2:14 PM, John Goerzenjgoer...@complete.org wrote: Hello, I would like to announce new versions of the following: hslogger convertible HDBC HDBC-odbc HDBC-postgresql HDBC-sqlite3 By popular, insistent, persistent, and patient requestgrin, all have been relicensed under the 3-clause BSD license. I am also working to make that happen with MissingH, but have to receive permission from a few third parties first. Additionally, this will be my last upload of the HDBC* packages. Nicolas Wu has kindly agreed to step in as HDBC maintainer. Nicolas has recently contributed a lot of good things towards HDBC and has more time to maintain it than I do. Thanks, -- John Goerzen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble with readProcess
Quoth Charles-Pierre Astolfi c...@crans.org, I've found my mistake: I was calling readProcess cmd [-p -t] instead of readProcess cmd [-p,-t] That would do it. Not sure what are the semantics of quotation in this case, though. And I'm pretty sure my analysis is wrong because of that :) The principle isn't complicated. In UNIX, anyway, quotes are for the shell - $ cmd a b is a string interpreted by the shell as a UNIX command (path, [args]). If an argument contains white space or something it needs to be quoted, and the shell supports all kinds of ways to do that. Of course it uses the quotes, the executed command doesn't see them. But when a Haskell process function's command takes a list of args, we infer that there isn't any shell interpretation, so no quotes. If you want a shell command, for example because you want a pipeline or something, then you may invoke the shell yourself, like readProcess /bin/sh [-c, cmd -p -t] Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Generics (SYB) with parametrized types
Hello, I'm banging my head against a wall there trying to use the syb generics schemes against the GHC API. I'm looking at implementing a search mechanism in the AST in the more direct way that what Scion does (creating an instance of a TypeClass for each AST node type). Since the GHC AST types derive from Data and Typeable, I thought it would be possible. So the problem is a follows: I have a start type, say TypecheckedSource, that derives from Data. What I'd like to do is to find all instances of the Located type inside that source that span a particular range. The problem is that Located is a parametrized type that wraps anything and just add location information. So the result of the search could be anything. Ideally, I'd like to restrict my search to Located instances that wrap an instance of Outputable, pretty print that and output only the result. So I'm looking to implement something that would have that signature: TypecheckedSource - (Line,Column) - [String] I have written code along these lines: everything (++) ([] `mkQ` overlap) ts where overlap :: forall b1 . (Outputable b1, Typeable b1) =Located b1 - [String] overlap (a::Located b1)= ... trivial code here finding if the location overlaps, and if it does, pretty print the object, otherwise returns [] And GHC complains: Ambiguous type variable `b10' in the constraints: (Outputable b10) arising from a use of `overlap' at ... (Typeable b10) arising from a use of `overlap' at ... So it doesn't like the fact that I don't know which types my Located instances wrap. But that's the point, I don't care, I just want to restrict my search to the ones I can pretty print. If I just try the code against simple non parametrized types it of course works. If I add some forall b1 . (Outputable ... in my main function signature it complains that I never use b1 anywhere else in the signature, of course. Is there a way to achieve what I want (-XOhPleaseDoWhatIwantEvenIfIamNotSureItMakesSense or something)? Thanks a million! -- JP Moresmau http://jpmoresmau.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
Is this different than the --hide-successes flag for test-framework? Looks like it was added a few months back: https://github.com/batterseapower/test-framework/commit/afd7eeced9a4777293af1e17eadab4bf485fd98f -n On Thu, Aug 11, 2011 at 8:21 AM, John Millikin jmilli...@gmail.com wrote: The output I didn't like wasn't coming from HUnit, it was coming from the test aggregator I used (test-framework). It prints one line per test case run, whether it passed or failed. That means every time I ran my test suite, it would print *thousands* of lines to the terminal. Any failure immediately scrolled up and out of sight, so I'd have to either Ctrl-C and hunt it down, or wait for the final report when all the tests had finished running. Chell does the same thing as test-framework (aggregates tests into suites, runs them, reports results), but does so quietly. It only reports failed and aborted tests. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to use cabal macros in .hsc files
On 08.08.2011 12:08, Bas van Dijk wrote: Hello, Currently it's not possible to use cabal macros like MIN_VERSION_base(x,y,z) in .hsc files: http://hackage.haskell.org/trac/hackage/ticket/870 Is there a workaround to get the same effect? Writing a plain Haskell module that contains the code that depends on the particular base-version? Usually I try to stay away from this preprocessor hackery, and this case seems to support my attempts. What I do is to add Hs-Source-Dirs depending on some Cabal flag, and connect it with a field like Build-Depends: base==3.*. http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Adapt_to_different_systems_without_CPP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help understanding Haskell runtime costs
On 09.08.2011 01:43, Thiago Negri wrote: Hello all, I'm relatively new to Haskell and trying to solve some online judge's problems in it. One of the problems is to say if a given sentence is a tautogram or not. A tautogram is just a sentence with all the words starting with the same letter. My first try (solution is ok) was to do it as haskeller as possible, trying to overcome my imperative mind. But it did bad at performance (0.30 secs of runtime, 4.6 mb of memory): -- code start import Data.Char (toLower) main = getContents= mapM_ (putStrLn . toStr . isTautogram . words) . takeWhile (/= *) . lines That's still imperative! :-) How about 'interact' and using 'unlines' instead of 'putStrLn' ? toStr :: Bool - [Char] You may want to write String instead of [Char] for clarity. toStr True = Y toStr False = N isTautogram :: [[Char]] - Bool isTautogram (x:[]) = True I assume this case is not necessary, since all [] == True anyway. isTautogram (x:xs) = all ((== firstChar) . toLower . head) xs where firstChar = toLower . head $ x It is maybe more elegant, not to compare all words with the first one, but to compare adjacent words in the list: all (zipWith (...) xs (drop 1 xs)) Note that the only thing that changed between the two tries was the main-loop. The second version runs faster (got 0.11 secs) and with less memory (3.6 mb) Can someone explain to me what is really going on? Maybe pointing out how I can achieve these optimizations using profiling information... Interesting observation. I do not see a problem quickly. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
Possible -- I ran into dependency conflicts between t-f/t-f-q/quickcheck when trying to migrate to test-framework 0.4, so I clamped all my test subprojects to 0.3. On Thu, Aug 11, 2011 at 09:09, Nathan Howell nathan.d.how...@gmail.com wrote: Is this different than the --hide-successes flag for test-framework? Looks like it was added a few months back: https://github.com/batterseapower/test-framework/commit/afd7eeced9a4777293af1e17eadab4bf485fd98f ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: GHC version 7.2.1
On 09.08.2011 22:01, Ian Lynagh wrote: The GHC Team is pleased to announce a new major release of GHC, 7.2.1. The 7.2 branch is intended to be more of a technology preview than normal GHC stable branches; in particular, it supports a significantly improved version of DPH, as well as new features such as compiler plugins and safe Haskell. The design of these new features may evolve as we get more experience with them. See the release notes for more details of what's new and what's changed. These sound like a lot of exciting news. The release notes also mention a VECTORISE pragma, that is not mentioned in http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/pragmas.html and not in the index. Is it about the planned GHC support for SSE/AltiVec vector units or is it about DPH? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Potential problem with AC-Vector-Fancy package
On 10/08/2011 11:04 PM, Dave Tapley wrote: Is anyone maintaining the AC-Vector-Fancy package? I haven't had a reply from the latest maintainer (Andrew Coppin) on Hackage, so I thought I'd open it up to cafe: Oh, right. I haven't checked my mailbox recently... I think I have found a problem with the union function: If you look here: http://hpaste.org/49889 You will see that line 4 gives a different result to lines 6, 8, 10; this shouldn't be the case because union is commutative. AC-Vector-Fancy is merely a fancy facard over AC-Vector. So the bug is actually with AC-Vector. Looking at my source code, the true bug is in Data.BoundingBox.Range [which provides the engine that all the other bounding box types use). The actual bug turns out to by face-slappingly stupid: it's a typo in one of the variable names. I'll go get that fixed... and then maybe write some QuickCheck properties. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: GHC version 7.2.1
VECTORISE is for Data Parallel Haskell. It's only relevant to GHC's internal vectorisation pass - I don't actually think there is any use case for it in user code at the moment, it's only used by the DPH libraries/special prelude, etc. On Thu, Aug 11, 2011 at 12:16 PM, Henning Thielemann schlepp...@henning-thielemann.de wrote: On 09.08.2011 22:01, Ian Lynagh wrote: The GHC Team is pleased to announce a new major release of GHC, 7.2.1. The 7.2 branch is intended to be more of a technology preview than normal GHC stable branches; in particular, it supports a significantly improved version of DPH, as well as new features such as compiler plugins and safe Haskell. The design of these new features may evolve as we get more experience with them. See the release notes for more details of what's new and what's changed. These sound like a lot of exciting news. The release notes also mention a VECTORISE pragma, that is not mentioned in http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/pragmas.html and not in the index. Is it about the planned GHC support for SSE/AltiVec vector units or is it about DPH? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Regards, Austin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
As Greg pointed out, HSpec does have an option to output just the failed tests. I looked at the example on the Chell project home page and converted the example tests into these hspec style specs: import Test.Hspec (Specs, descriptions, describe, it) import Test.Hspec.Runner (hHspecWithFormat) import Test.Hspec.Formatters (failed_examples) import Test.Hspec.HUnit import Test.HUnit import System.IO (stdout) -- some functions to test equal = (==) greater = () equalWithin = undefined equalLines = (==) specs :: IO Specs specs = descriptions [ describe number comparison module [ it can check for equality (assertBool 1 should equal 1 $ equal 1 1), it can compare order (assertBool 2 should be greater than 1 $ greater 2 1), it can compare eqauality with floating point numbers (assertBool 1.0001 should be close enough to 1.0 $ equalWithin 1.0001 1.0 0.01) ], describe text comparison module [ it can compare strings for equality (let str1 = foo\nbar\nbaz :: String str2 = foo\nbar\nqux :: String in assertBool foo\\nbar\\nbaz shouldn't equal foo\\nbar\\nqux $ equalLines str1 str2) ]] main = hHspecWithFormat (failed_examples True) stdout specs And when run, got the following output in red text since it's only reporting failures: ] x can compare eqauality with floating point numbers FAILED [1] ] x can compare strings for equality FAILED [2] ] ] 1) number comparison module can compare eqauality with floating point numbers FAILED ] Prelude.undefined ] ] 2) text comparison module can compare strings for equality FAILED ] foo\nbar\nbaz shouldn't equal foo\nbar\nqux ] ] Finished in 0. seconds ] ] 4 examples, 2 failures You can write provide your own formatter if that's not what you'd like to see. You also don't have to use the HUnit assertion text either; you could use the following function to make your specs even more like your Chell example, at the cost of losing the extra output description: assert = assertBool Hspec uses HUnit TestCases and assertions but also supports QuickCheck properties almost exactly the same way Chell does. The hspec project homepage (https://github.com/trystan/hspec) has more examples, including the specs for hspec itself. Trystan Spangler From: John Millikin jmilli...@gmail.com To: Greg Weber g...@gregweber.info Cc: trystan s trysta...@comcast.net, haskell-cafe@haskell.org Sent: Thursday, August 11, 2011 8:21:52 AM Subject: Re: ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework) On Thu, Aug 11, 2011 at 08:17, Greg Weber g...@gregweber.info wrote: I am confused also, as to both what output you don't like that motivated chell and what exactly hspec silences :) Suffice to say I am able to get a small relevant error message on failure with hspec. I am adding the hspec maintainer to this e-mail- he can answer any of your questions. The output I didn't like wasn't coming from HUnit, it was coming from the test aggregator I used (test-framework). It prints one line per test case run, whether it passed or failed. That means every time I ran my test suite, it would print *thousands* of lines to the terminal. Any failure immediately scrolled up and out of sight, so I'd have to either Ctrl-C and hunt it down, or wait for the final report when all the tests had finished running. Chell does the same thing as test-framework (aggregates tests into suites, runs them, reports results), but does so quietly. It only reports failed and aborted tests. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Chell: A quiet test runner (low-output alternative to test-framework)
On 11 August 2011 15:49, John Millikin jmilli...@gmail.com wrote: I tried, actually, but couldn't figure out how to separate running the test from printing its output. All the attempted patches turned into huge refactoring marathons. Just FYI test-framework already has exactly this split between running tests and printing their results. If you had wanted to change this you could have modified showImprovingTestResult in https://github.com/batterseapower/test-framework/blob/master/core/Test/Framework/Runners/Console/Run.hs. However, as someone else has already pointed out, the --hide-successes flag does what you want, and you can even make it the default for your particular testsuite by making your main be (do { args - getArgs; defaultMainWithArgs tests ([--hide-successes] ++ args) }) Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble with readProcess
On Thu, Aug 11, 2011 at 11:29, Charles-Pierre Astolfi c...@crans.org wrote: I've found my mistake: I was calling readProcess cmd [-p -t] instead of readProcess cmd [-p,-t] Not sure what are the semantics of quotation in this case, though. And I'm pretty sure my analysis is wrong because of that :) It's quite simple: readProcess uses the low level exec*() series of functions under the hood. Quoting is assumed to have already been dealt with; every parameter is a separate String (or (char *) in the C API) and passed literally. Quoting is used at the shell level (and shell-based APIs such as system()) to enable the shell to correctly generate a list of literal (char *) parameters. In general, if an exec-style API takes a list of strings (e.g. C execve(), Haskell readProcess, Perl's multiple-parameter form of system), it's using the exec()-based API and you should pass argument strings exactly as you want the program to see them; if its a single string, it's using a system()-based API and you need to worry about quoting. In this case, the tip-off is that the argument list is a [String] and not simply a String. -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help understanding Haskell runtime costs
So, thanks to Henning Thielemann I was able to make a code a little more functional. I did find ByteString module that really speed things up. I got 0.04 seconds with the following snippet: -- code start import qualified Data.ByteString.Char8 as BS import Data.Char (toLower) main :: IO () main = interact' $ unlines' . solveAll . takeWhile ((/= '*') . head') . lines' solveAll :: [String'] - [String'] solveAll = map $ toStr . solve toStr :: Bool - String' toStr True = makeString' Y toStr False = makeString' N solve :: String' - Bool solve = isTautogram . words' isTautogram :: [String'] - Bool isTautogram (x:xs) = all ((== firstChar) . normalizeHead) xs where firstChar = normalizeHead x normalizeHead :: String' - Char normalizeHead = toLower . head' -- optimizations type String' = BS.ByteString interact' = BS.interact unlines' = BS.unlines lines' = BS.lines head' = BS.head words' = BS.words makeString' = BS.pack -- code end Thanks all, Thiago. 2011/8/11 Henning Thielemann schlepp...@henning-thielemann.de: On 09.08.2011 01:43, Thiago Negri wrote: Hello all, I'm relatively new to Haskell and trying to solve some online judge's problems in it. One of the problems is to say if a given sentence is a tautogram or not. A tautogram is just a sentence with all the words starting with the same letter. My first try (solution is ok) was to do it as haskeller as possible, trying to overcome my imperative mind. But it did bad at performance (0.30 secs of runtime, 4.6 mb of memory): -- code start import Data.Char (toLower) main = getContents= mapM_ (putStrLn . toStr . isTautogram . words) . takeWhile (/= *) . lines That's still imperative! :-) How about 'interact' and using 'unlines' instead of 'putStrLn' ? toStr :: Bool - [Char] You may want to write String instead of [Char] for clarity. toStr True = Y toStr False = N isTautogram :: [[Char]] - Bool isTautogram (x:[]) = True I assume this case is not necessary, since all [] == True anyway. isTautogram (x:xs) = all ((== firstChar) . toLower . head) xs where firstChar = toLower . head $ x It is maybe more elegant, not to compare all words with the first one, but to compare adjacent words in the list: all (zipWith (...) xs (drop 1 xs)) Note that the only thing that changed between the two tries was the main-loop. The second version runs faster (got 0.11 secs) and with less memory (3.6 mb) Can someone explain to me what is really going on? Maybe pointing out how I can achieve these optimizations using profiling information... Interesting observation. I do not see a problem quickly. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe