Re: [Haskell-cafe] Help optimising a Haskell program
On 22 March 2011 02:00, Jesper Louis Andersen jesper.louis.ander...@gmail.com wrote: On Tue, Mar 22, 2011 at 00:59, David MacIver da...@drmaciver.com wrote: It's for rank aggregation - taking a bunch of partial rankings of some items from users and turning them into an overall ranking (aka That thing that Hammer Principle does). Two questions immediately begs themselves: * Can we go parallel? :P Maybe. A lot of this is inherently sequential. Some bits are parallelisable, but my initial attempts at exploiting that made very little performance difference. I'd rather exhaust what I can from single-core performance first. * What does +RTS -s -RTS say? Specifically, what is the current productivity? ./rank +RTS -s 3,466,696,368 bytes allocated in the heap 212,888,240 bytes copied during GC 51,949,568 bytes maximum residency (10 sample(s)) 5,477,016 bytes maximum slop 105 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 6546 collections, 0 parallel, 0.93s, 0.93s elapsed Generation 1:10 collections, 0 parallel, 0.32s, 0.32s elapsed INIT time0.00s ( 0.00s elapsed) MUT time7.11s ( 7.12s elapsed) GCtime1.25s ( 1.25s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time8.37s ( 8.37s elapsed) %GC time 15.0% (15.0% elapsed) Alloc rate487,319,292 bytes per MUT second Productivity 85.0% of total user, 85.0% of total elapsed So if I'm reading this right, my hypothesis that allocation was most of the cost seems to be wrong? I don't know how much of that MUT time is allocation, but I'd expect it to be GC time. Do we get an improvement with +RTS -A2m -H128m -RTS ? (Force the heap to be somewhat up there from day one, perhaps try -H256m. This seems to consistently give about a 0.4s improvement, which isn't nothing but isn't a particularly interesting chunck of 8s (actually it's 8.4s - 8s). Setting it to 256M doesn't make any difference. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Loops and ray casting with GPipe?
Greetings, With OpenGL shaders it is possible to write code utilizing loops with unknown number of iterations, I'm wondering if the same can be done with GPipe? Fractals would be one use case and implicit surfaces another. Fragment Floats had to be compared with IfB from Data.Boolean, so I tried something recursive like foo x = boolean x (foo (x * 0.9)) (x * 1) which compiles fine but seems to concentrate on eating stack space while running :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Asynchronous Arrows need Type Specialization - Help!
David, On 21/03/2011, at 4:18 PM, David Barbour wrote: I was giving Control.Arrow a try for a reactive programming system. The arrows are agents that communicate by sending and returning time-varying state. Different agents may live in different 'vats' (event-driven threads) to roughly model distributed computing. For the most part, the state varies asynchronously - i.e. a file updates at a different rate than the mouse position. Anyhow, I ran into a problem: The (***) and () operations, as specified in Control.Arrow, are inherently synchronization points. Indeed. Take a look here: http://www.haskell.org/haskellwiki/Research_papers/Monads_and_arrows#Arrows In particular, ProdArrows -- Arrows for Fudgets by Magnus Carlsson. cheers peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mime / Mail library
On Sun, Mar 20, 2011 at 10:50 AM, Christopher Done chrisd...@googlemail.com wrote: On 20 March 2011 15:05, Pieter Laeremans pie...@laeremans.org wrote: Hi all, The MIME package that can be found on hackage, uses String as input. Would i be considered better if there would be a version based on Text, or ByteString ? I think the solution to this problem is a generic `string' package which just provides a few classes. The MIME library would export an interface that only deals with instances of these classes, and whether you're using Text, String, ByteString/Lazy/Char8, ropes, whatever, it's not the library writer's concern or assumptions to make. We already have: http://hackage.haskell.org/packages/archive/string-combinators/0.6/doc/html/Data-String-Combinators.html http://hackage.haskell.org/packages/archive/string-combinators/0.6/doc/html/Data-String-Combinators.html Which works on Monoid and IsString, but there needs to be a class like can be read/outputted via IO and one for read/show/serialize, both of which are important for speed. One possible extension to the Data-String-Combinators approach can be found in my new incremental-parser package ( http://hackage.haskell.org/package/incremental-parser-0.1), which I should soon announce. It relies on three Data.Monoid subclasses, all plain Haskell 98, that allow monoids to be decomposed and parsed. There are instances for lists, ByteString, and Text. It's a different approach from ListLike, because it abstracts away the Char type. Like with any abstraction, though, there is performance cost for some operations. It could be minimized by adding more defaulted methods to the FactorialMonoid class, but for the first release I concentrated on what the parser needed. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Loops and ray casting with GPipe?
Hi, Am Dienstag, den 22.03.2011, 11:07 +0200 schrieb Jarkko Vilhunen: which compiles fine but seems to concentrate on eating stack space while running :) „if it compiles, it works“. Nobody ever said what exactly it would work on. Greetings, Joachim -- Joachim nomeata Breitner mail: m...@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nome...@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nome...@debian.org signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Loops and ray casting with GPipe?
On Tue, 22 Mar 2011, Jarkko Vilhunen wrote: Greetings, With OpenGL shaders it is possible to write code utilizing loops with unknown number of iterations, I'm wondering if the same can be done with GPipe? Fractals would be one use case and implicit surfaces another. Fragment Floats had to be compared with IfB from Data.Boolean, so I tried something recursive like foo x = boolean x (foo (x * 0.9)) (x * 1) This is not tail-recursive - could that be the problem? I also assume that GPipe is an EDSL and thus your expression just produces infinitely code in the shader language instead of running it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: incremental-parser library package
The first version of incremental-parser has been released on Hackage [1]. It's yet another parser combinator library, providing the usual set of Applicative and Monad combinators. Apart from this, it has three twists that make it unique. First, the parser is incremental. That means it can be fed its input in chunks, and in proper circumstances it can also provide the parsed output in chunks. For this to be possible the result type must be a Monoid. The complete parsing result is then a concatenation of the partial results. In order to make the incremental parsing easier, the combinator set is optimized for monoidal results. The usual combinator many1, for example, assumes the result type is a monoid and concatenates its components instead of constructing a list. In Parsec: many1 :: Stream s m t = ParsecT s u m a - ParsecT s u m [a] In incremental-parser: many1 :: (Monoid s, Monoid r) = Parser s r - Parser s r The second weirdness is that the the parser is generic in its input stream type, but this type is parameterized in a holistic way. There is no separate token type. Primitive parsers that need to peek into the input require its type to be an instance of a monoid subclass. In Parsec: string :: Stream s m Char = String - ParsecT s u m String char :: Stream s m Char = Char - ParsecT s u m Char anyToken :: (Stream s m t, Show t) = ParsecT s u m t In Attoparsec: string :: ByteString - Parser ByteString word8 :: Word8 - Parser Word8 anyWord8 :: Parser Word8 In incremental-parser: string :: (LeftCancellativeMonoid s, MonoidNull s) = s - Parser s s token :: (Eq s, FactorialMonoid s) = s - Parser s s anyToken :: FactorialMonoid s = Parser s s The monoid subclasses referenced above provide methods for analyzing and subdividing the input stream. The classes are not particularly demanding, and any reasonable input stream should be able to accommodate them easily. The library comes with instances for lists, ByteString, and Text. class Monoid m = MonoidNull m where mnull :: m - Bool class Monoid m = LeftCancellativeMonoid m where mstripPrefix :: m - m - Maybe m class Monoid m = FactorialMonoid m where factors :: m - [m] primePrefix :: m - m ... Finally, the library being implemented on the basis of Brzozowski derivatives, it can provide both the symmetric and the left-biased choice, | and |. This is the same design choice made by Text.ParserCombinators.ReadP and uu-parsinglib. Parsec and its progeny on the other hand provide only the faster left-biased choice, at some cost to the expressiveness of the combinator language. [1] http://hackage.haskell.org/package/incremental-parser-0.1 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: incremental-parser library package
On Tue, Mar 22, 2011 at 3:14 PM, Mario Blažević mblaze...@stilo.com wrote: The first version of incremental-parser has been released on Hackage [1]. It's yet another parser combinator library, providing the usual set of Applicative and Monad combinators. Apart from this, it has three twists that make it unique. First, the parser is incremental. That means it can be fed its input in chunks, and in proper circumstances it can also provide the parsed output in chunks. For this to be possible the result type must be a Monoid. The complete parsing result is then a concatenation of the partial results. In order to make the incremental parsing easier, the combinator set is optimized for monoidal results. The usual combinator many1, for example, assumes the result type is a monoid and concatenates its components instead of constructing a list. In Parsec: many1 :: Stream s m t = ParsecT s u m a - ParsecT s u m [a] In incremental-parser: many1 :: (Monoid s, Monoid r) = Parser s r - Parser s r The second weirdness is that the the parser is generic in its input stream type, but this type is parameterized in a holistic way. There is no separate token type. Primitive parsers that need to peek into the input require its type to be an instance of a monoid subclass. In Parsec: string :: Stream s m Char = String - ParsecT s u m String char :: Stream s m Char = Char - ParsecT s u m Char anyToken :: (Stream s m t, Show t) = ParsecT s u m t In Attoparsec: string :: ByteString - Parser ByteString word8 :: Word8 - Parser Word8 anyWord8 :: Parser Word8 In incremental-parser: string :: (LeftCancellativeMonoid s, MonoidNull s) = s - Parser s s token :: (Eq s, FactorialMonoid s) = s - Parser s s anyToken :: FactorialMonoid s = Parser s s The monoid subclasses referenced above provide methods for analyzing and subdividing the input stream. The classes are not particularly demanding, and any reasonable input stream should be able to accommodate them easily. The library comes with instances for lists, ByteString, and Text. class Monoid m = MonoidNull m where mnull :: m - Bool class Monoid m = LeftCancellativeMonoid m where mstripPrefix :: m - m - Maybe m class Monoid m = FactorialMonoid m where factors :: m - [m] primePrefix :: m - m ... Finally, the library being implemented on the basis of Brzozowski derivatives, it can provide both the symmetric and the left-biased choice, | and |. This is the same design choice made by Text.ParserCombinators.ReadP and uu-parsinglib. Parsec and its progeny on the other hand provide only the faster left-biased choice, at some cost to the expressiveness of the combinator language. [1] http://hackage.haskell.org/package/incremental-parser-0.1 This seems very interesting. One question: The MonadPlus and the Alternative instance differ: the former's mplus combinator equals the asymmetric | choice. Why? ___ Libraries mailing list librar...@haskell.org http://www.haskell.org/mailman/listinfo/libraries -- Work is punishment for failing to procrastinate effectively. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help optimising a Haskell program
On Tue, Mar 22, 2011 at 09:11, David MacIver da...@drmaciver.com wrote: Productivity 85.0% of total user, 85.0% of total elapsed That is somewhat ok. So much for hoping GC tuning would yield an improvement. -- J. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help optimising a Haskell program
On Tue, Mar 22, 2011 at 1:11 AM, David MacIver da...@drmaciver.com wrote: On 22 March 2011 02:00, Jesper Louis Andersen jesper.louis.ander...@gmail.com wrote: On Tue, Mar 22, 2011 at 00:59, David MacIver da...@drmaciver.com wrote: It's for rank aggregation - taking a bunch of partial rankings of some items from users and turning them into an overall ranking (aka That thing that Hammer Principle does). Two questions immediately begs themselves: * Can we go parallel? :P Maybe. A lot of this is inherently sequential. Some bits are parallelisable, but my initial attempts at exploiting that made very little performance difference. I'd rather exhaust what I can from single-core performance first. * What does +RTS -s -RTS say? Specifically, what is the current productivity? ./rank +RTS -s 3,466,696,368 bytes allocated in the heap 212,888,240 bytes copied during GC 51,949,568 bytes maximum residency (10 sample(s)) 5,477,016 bytes maximum slop 105 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 6546 collections, 0 parallel, 0.93s, 0.93s elapsed Generation 1:10 collections, 0 parallel, 0.32s, 0.32s elapsed INIT time0.00s ( 0.00s elapsed) MUT time7.11s ( 7.12s elapsed) GCtime1.25s ( 1.25s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time8.37s ( 8.37s elapsed) %GC time 15.0% (15.0% elapsed) Alloc rate487,319,292 bytes per MUT second Productivity 85.0% of total user, 85.0% of total elapsed So if I'm reading this right, my hypothesis that allocation was most of the cost seems to be wrong? I don't know how much of that MUT time is allocation, but I'd expect it to be GC time. Do we get an improvement with +RTS -A2m -H128m -RTS ? (Force the heap to be somewhat up there from day one, perhaps try -H256m. This seems to consistently give about a 0.4s improvement, which isn't nothing but isn't a particularly interesting chunck of 8s (actually it's 8.4s - 8s). Setting it to 256M doesn't make any difference. You should use criterion to make sure that your assessments of the performance difference are grounded in statistically robust reasoning :) Progression may also help. GHC 7 has a new rts option, +RTS -H -RTS that gives you a good high default for these memory numbers. You might give it ago, but I doubt it's going to help much here. One thing I noticed was that you calculate the length of elts more than once inside aggregate. It's probably not going to account for a big boost, but I'd recommend doing it only once. Something like: let lenelts = length elts Then use lenelts everywhere. Also, it seems like you use Data.Set to sort and uniquify the input then you throw away the Set, that's potentially costly. There are probably better types for aggregate than [[a]] - [a]. You use Arrays, but it's possible that a different vector library such as Data.Vector gives better performance here. Or, perhaps you want that instead of lists everywhere. For example, you build an index and a reverse index. It seems like with an array or vector you could eliminate at least one index and have O(1) lookup time instead of Data.Map's O(log n) lookup time. I hope that helps, Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Berlin Haskell Meeting
Hi all! It's been some time since the last Berlin Haskell Meeting, but we're doing it again: Date: Wednesday, March 30th Time: from 20:00 Location: c-base, Rungestrasse 20, 10179 Berlin If you're in Berlin and interested in Haskell, save the date! Cheers, Sönke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Looking for feedback on my attempt at a tree construction edsl
Hi, With my edsl, one can describe a tree like this - import TreeEdsl import Data.Tree createTree :: TreeContext String () createTree = do insertSubTree Fruits $ do insertLeaf Apple insertLeaf Mango insertSubTree Arbitrary $ do insertSubTree Numbers $ do insertLeaf 1 insertLeaf 2 insertLeaf 3 insertSubTree Letters $ do insertLeaf A insertLeaf B insertLeaf C return () main = do tree - process root createTree putStrLn (drawTree (fmap show tree)) return () and get a tree like this - root | +- Arbitrary | | | +- Letters | | | | | +- C | | | | | +- B | | | | | `- A | | | `- Numbers | | | +- 3 | | | +- 2 | | | `- 1 | `- Fruits | +- Mango | `- Apple My code is here https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs I'd appreciate your feedback on this. Does this qualify to be a edsl? Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Install GTK on Windows
I have installed successfully the gtk package on Windows. GTK version: 2.16 gtk package version: 0.12.0 Haskell Platform version: 2010.2.0.0 I have detailed my steps (very similar to Mark Shroyer steps) here: http://deltadiaz.blogspot.com/2011/03/on-windows-how-to-install-gtk.html It seems that my error comes from an space in the path of gtk, and later, from my version of the Haskell Platform (cabal version, I guess). In brief: 1) Install Haskell Platform, version 2010.2.0.0. 2) Download and unpack gtk all-in-one bundle, version 2.16. Path without spaces. 3) Add gtk/bin and mingw/bin to the PATH environment variable. 4) Install gtk2hs-buildtools. 5) Install gtk. And it works! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for feedback on my attempt at a tree construction edsl
You could turn 'insertSubTree' into and operator, and shorten insertLeaf createTree = do Fruits + do leaf Apple leaf Mango Arbitrary + do leaf 1 -- and so on... It's a little bit more concise. But I fail to see the use of TreeContext being an instance of Monad. 2011/3/22 C K Kashyap ckkash...@gmail.com Hi, With my edsl, one can describe a tree like this - import TreeEdsl import Data.Tree createTree :: TreeContext String () createTree = do insertSubTree Fruits $ do insertLeaf Apple insertLeaf Mango insertSubTree Arbitrary $ do insertSubTree Numbers $ do insertLeaf 1 insertLeaf 2 insertLeaf 3 insertSubTree Letters $ do insertLeaf A insertLeaf B insertLeaf C return () main = do tree - process root createTree putStrLn (drawTree (fmap show tree)) return () and get a tree like this - root | +- Arbitrary | | | +- Letters | | | | | +- C | | | | | +- B | | | | | `- A | | | `- Numbers | | | +- 3 | | | +- 2 | | | `- 1 | `- Fruits | +- Mango | `- Apple My code is here https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs I'd appreciate your feedback on this. Does this qualify to be a edsl? Regards, Kashyap ___ 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: incremental-parser library package
This seems very interesting. One question: The MonadPlus and the Alternative instance differ: the former's mplus combinator equals the asymmetric | choice. Why? Good question. Basically, I see MonadPlus as a union of Monad and Alternative. The class should not exist at all. But as long as it does, I figured I should provide an instance, and I made it different from the Monoid+Alternative combination because otherwise it would be useless. My second choice would be to remove the instance completely. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: clash-0.1.3.0 (Functional Hardware Descriptions)
Hello, I am pleased to announce an incremental update to CLaSH, version 0.1.3.0. CLaSH can translate a (semantic) subset of Haskell to RTL-style VHDL. Instead of being an embedded DSL like Lava or ForSyDe, CLaSH takes are more 'traditional' approach to synthesis/compilation. It uses the GHC API as a front-end for parsing, type-checking and desugaring the Haskell source. It then exhaustively applies a list of meaning-preserving transformations to the intermediate GHC Core representation until it is in the desired normal form. The normalized Core/System Fc is then 'trivially' translated to RTL-style VHDL. The new version of CLaSH has the following updates: - Support for simulation and synthesis of multi-clock hardware [6] - Significant synthesis speed-up (4x to 10x) CLaSH already supported synthesis of: - User-defined Higher-Order functions [1] - User-defined ADTs (GADTs are not tested, but *might* work) - All of Haskell's choice constructs (Guards, Pattern Matching, etc.) - Lambda-abstraction / Anonymous Functions You can use CLaSH as a library, but the use of the adapted GHC interpreter (added the :vhdl command) is recommended. The interpreter can be found on the CLaSH website [2], where you will also find examples, papers, tutorials, etc. The library can be downloaded from Hackage [3]. I recently gave a demo of CLaSH at the DATE'11 conference in grenoble, this demo already made use of the multi-clock feature (and is actually the only reference if you want to experiment with multi-clock hardware yourself). The source for the demo (audio spectrum analyzer programmed on an Altera Cyclone II FPGA board) can be downloaded from my github page [4]. Do note that CLaSH only works when you have the 6.12.* branch of GHC installed! I am currently analyzing the impact of the GHC API changes made in the 7.0.* brach, and hope to make the transition to the new API within the next month. Although the compiler is already used by 2 other phd's in our group [5], it is not a thoroughly tested product, so your coding style might not be anticipated by the current version of CLaSH ;-) -- Christiaan Baaij [1] There is hard-coded support for a set of recursively defined higher-order functions such as map, fold, zipWith, etc. [2] http://clash.ewi.utwente.nl [3] http://hackage.haskell.org/package/clash-0.1.3.0 [4] http://github.com/christiaanb/DE1-Cyclone-II-FPGA-Board-Support-Package [5] http://caes.ewi.utwente.nl [6] Simulation does not show meta-stability, you will have to take care of synchronization (dual flipflop) yourself ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: incremental-parser library package
2011/3/22 Mario Blažević mblaze...@stilo.com This seems very interesting. One question: The MonadPlus and the Alternative instance differ: the former's mplus combinator equals the asymmetric | choice. Why? Good question. Basically, I see MonadPlus as a union of Monad and Alternative. The class should not exist at all. But as long as it does, I figured I should provide an instance, and I made it different from the Monoid+Alternative combination because otherwise it would be useless. My second choice would be to remove the instance completely. I have to admit I really do not like having Applicative and MonadPlus with different behavior. Yes, one is redundant, but that is more an artifact of language evolution, than an intentional opportunity for diverging behavior. Every library I am aware of to date, save of course this one, has maintained their compatibility. If the instance for Alternative satisfies the underspecified MonadPlus laws, I'd just as soon have the 'useless redundant' instance. The power of MonadPlus is in the combinators that are built on top of it. Not in the primitives themselves. If the Alternative instance would not be a legal MonadPlus instance, then I'd feel much less queasy with your second scenario, and it simply removed. -Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: incremental-parser library package
2011/3/22 Philippa Cowderoy postmas...@flippac.org This is what newtypes are for, no? I did not think of that approach. I'm not sure how well it would work out, but it would solve another problem I have, which is the duplication of combinators many, some, and optional. Each of these could exist in two forms, the lazy one and the greedy one, and the only difference is the underlying choice combinator, (|) vs. (|). I'm not aware of any other parsing library taking this road, though, and there must be a good reason. I'll try and see. 2011/3/22 Mario Blažević mblaze...@stilo.com This seems very interesting. One question: The MonadPlus and the Alternative instance differ: the former's mplus combinator equals the asymmetric | choice. Why? Good question. Basically, I see MonadPlus as a union of Monad and Alternative. The class should not exist at all. But as long as it does, I figured I should provide an instance, and I made it different from the Monoid+Alternative combination because otherwise it would be useless. My second choice would be to remove the instance completely. I have to admit I really do not like having Applicative and MonadPlus with different behavior. Yes, one is redundant, but that is more an artifact of language evolution, than an intentional opportunity for diverging behavior. Every library I am aware of to date, save of course this one, has maintained their compatibility. If the instance for Alternative satisfies the underspecified MonadPlus laws, I'd just as soon have the 'useless redundant' instance. The power of MonadPlus is in the combinators that are built on top of it. Not in the primitives themselves. If the Alternative instance would not be a legal MonadPlus instance, then I'd feel much less queasy with your second scenario, and it simply removed. -Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: incremental-parser library package
I have to admit I really do not like having Applicative and MonadPlus with different behavior. Yes, one is redundant, but that is more an artifact of language evolution, than an intentional opportunity for diverging behavior. Every library I am aware of to date, save of course this one, has maintained their compatibility. Another way of thinking about it is that for the different behaviours to be useful, a programmer has to know about them and intentionally use one or the other. And then the person reading it later has to be aware of that difference and keep in mind the different behaviour implied by the use of different classes. That's a pretty subtle thing to have to be aware of. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for feedback on my attempt at a tree construction edsl
If you add an instance of IsString to handle leaf construction you can get it down to Fruits + do Apple Mango Arbitrary + do 1 ... But I also don't see the point of doing this in a monad. -Edward On Tue, Mar 22, 2011 at 1:15 PM, Yves Parès limestr...@gmail.com wrote: You could turn 'insertSubTree' into and operator, and shorten insertLeaf createTree = do Fruits + do leaf Apple leaf Mango Arbitrary + do leaf 1 -- and so on... It's a little bit more concise. But I fail to see the use of TreeContext being an instance of Monad. 2011/3/22 C K Kashyap ckkash...@gmail.com Hi, With my edsl, one can describe a tree like this - import TreeEdsl import Data.Tree createTree :: TreeContext String () createTree = do insertSubTree Fruits $ do insertLeaf Apple insertLeaf Mango insertSubTree Arbitrary $ do insertSubTree Numbers $ do insertLeaf 1 insertLeaf 2 insertLeaf 3 insertSubTree Letters $ do insertLeaf A insertLeaf B insertLeaf C return () main = do tree - process root createTree putStrLn (drawTree (fmap show tree)) return () and get a tree like this - root | +- Arbitrary | | | +- Letters | | | | | +- C | | | | | +- B | | | | | `- A | | | `- Numbers | | | +- 3 | | | +- 2 | | | `- 1 | `- Fruits | +- Mango | `- Apple My code is here https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs I'd appreciate your feedback on this. Does this qualify to be a edsl? Regards, Kashyap ___ 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] Uncertainty analysis library?
I moved all of my repositories over to github back around June: http://twitter.com/#!/kmett/status/16174477854 I should update that link. -Edward On Mon, Mar 21, 2011 at 6:02 PM, Carter Schonwald carter.schonw...@gmail.com wrote: i'm now seeing that they've been moved to github, never mind! On Mon, Mar 21, 2011 at 6:01 PM, Carter Schonwald carter.schonw...@gmail.com wrote: by the way, the link to the patch-tag repo for your intervals lib seems to be dead / patch-tag gets confused, is it that the link is outdated or that there are problems on patch-tag? -Carter On Mon, Mar 21, 2011 at 4:57 PM, Edward Kmett ekm...@gmail.com wrote: On Mon, Mar 21, 2011 at 2:42 PM, Edward Amsden eca7...@cs.rit.eduwrote: So I'm feeling a bit elated that I've sparked my first theoretical discussion in cafe, though I don't have much to contribute. :\ However in the interests of the original question, I guess I should clarify. What we do in our physics class seems to be what is being called interval analysis in this discussion. We have experimental values with absolute uncertainties, and we need to propagate those uncertainties in a deterministic way through formulas. I don't think my professor would take kindly to a random sampling approach. The intervals library seemed a bit like what I'm looking for, except that it appears to be broken for the later ghc 6 versions and ghc 7. The package should build fine, but hackage was flipping out because I commented out a pattern guard, and it looked like a misplaced haddock comment. I've pushed a new version of intervals to mollify hackage. It (or the old version) should cabal install just fine. -Edward Kmett ___ 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] wrong backquote in haskell 2010 report Prelude
Hi Albert, Thanks for spotting this, it definitely looks wrong. On the line above I also see the ^ characters have got corrupted. I've emailed it onwards to the current report editor (Malcolm Wallace) Thanks, Neil On Thu, Mar 17, 2011 at 4:57 PM, Albert Y. C. Lai tre...@vex.net wrote: Haskell 2010 report chapter 9 Standard Prelude uses a wrong backquote, e.g., infixl 7 ⋆, /, ‘quot‘, ‘rem‘, ‘div‘, ‘mod‘ Those are U+2018. The grammar (Chapter 3) requires U+0060 and accepts no substitutes, e.g., varop → varsym | ` varid ` ___ 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] Looking for feedback on my attempt at a tree construction edsl
Andy Gill uses a monad in his Dot library to allow graphs to have references as they are built. It's a pattern I like a lot and has been very useful for my graphics kit Wumpus. That said, while it's a good technique for graphs, its use is more equivocal for trees where nesting is more prominent. I use a reference monad for tree building/drawing at the moment (references are essential) but I'd switch to a technique that is better with nesting if I could think of one. At the moment the Tree EDSL doesn't use references, so I'd third the notion that the code would be simpler if it was pure. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for feedback on my attempt at a tree construction edsl
On Tue, Mar 22, 2011 at 2:20 PM, Edward Kmett ekm...@gmail.com wrote: If you add an instance of IsString to handle leaf construction you can get it down to Fruits + do Apple Mango Arbitrary + do 1 ... But I also don't see the point of doing this in a monad. Having it in a monad has the same benefit as blaze-html being built in a monad: the square braces and comas for the list are gone. Although it does leave you with an awkward type parameter hanging around. And the same as the Binary Put monad vs. the Binary Builder type. I prefer the monoid interface vs. the monad interface to both of these, but I can see the appeal. Antoine -Edward On Tue, Mar 22, 2011 at 1:15 PM, Yves Parès limestr...@gmail.com wrote: You could turn 'insertSubTree' into and operator, and shorten insertLeaf createTree = do Fruits + do leaf Apple leaf Mango Arbitrary + do leaf 1 -- and so on... It's a little bit more concise. But I fail to see the use of TreeContext being an instance of Monad. 2011/3/22 C K Kashyap ckkash...@gmail.com Hi, With my edsl, one can describe a tree like this - import TreeEdsl import Data.Tree createTree :: TreeContext String () createTree = do insertSubTree Fruits $ do insertLeaf Apple insertLeaf Mango insertSubTree Arbitrary $ do insertSubTree Numbers $ do insertLeaf 1 insertLeaf 2 insertLeaf 3 insertSubTree Letters $ do insertLeaf A insertLeaf B insertLeaf C return () main = do tree - process root createTree putStrLn (drawTree (fmap show tree)) return () and get a tree like this - root | +- Arbitrary | | | +- Letters | | | | | +- C | | | | | +- B | | | | | `- A | | | `- Numbers | | | +- 3 | | | +- 2 | | | `- 1 | `- Fruits | +- Mango | `- Apple My code is here https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs I'd appreciate your feedback on this. Does this qualify to be a edsl? Regards, Kashyap ___ 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] Bamse package virus false positive
We have realized that a file in the Bamse distribution in Hackage is being flagged by some virus scanners as malicious, including Symantec and McAfee. We have worked with Microsoft, Symantec, and McAfee to analyze the data. All parties have concluded that this file is not malicious, but we wanted to let the community know in case you run across a similar issue. We have notified the maintainer. Symantec and McAfee have updated their rules accordingly and will no longer flag this file, but other virus scanners might continue to flag it. Note that if you use Bamse to build MSI packages, inclusion of this file could cause some scanners to flag the package. The details of this file are as follows: File name: Folder.exe File Size: 83249 byte MD5: 9f939a06344af9b242a7b43849defb40 SHA1: a9faf0915d1ea142b161bec57792ef2ca379ce5b URL: http://hackage.haskell.org/package/bamse From the package description: Bamse is a framework for building Windows Installers for your Windows applications, giving you a comprehensive set of features to put together MSIs using Haskell. peace, isaac smime.p7s Description: S/MIME Cryptographic Signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell and friends in Spanish
Dear Haskellers, I have tried to compile from my own work and from several sources a university-level course in functional and logic programming, and the result is a prospect of a book (*right now only in Spanish*), which I have entitled Programación declarativa. Perhaps someone could be interested in giving it a look. The book is big (more than 400pp and 2Mb) and eclectic wrt declarative topics (ranging from Scheme to Prolog), but Haskell has an ample treatment. Some parts of the book are even unfinished, but I think the book may be valuable for some Spanish-speaking people wishing to learn declarative programming through functional programming and Prolog. The book can be downloaded from: http://sites.google.com/site/writingsmhg/haskell/SpanishDeclarativeProgramming.pdf?attredirects=0d=1 Corrections and suggestions are welcome. Bests, -- Dr Manuel Hernández Gutiérrez Profesor-Investigador, Oficina num. 14 Coordinador del Doctorado en Tecnologías de Cómputo Aplicado. Área de Estudios de Posgrado. Instituto de Computación Universidad Tecnológica de la Mixteca Km 2.5 de la Carretera a Acatlima Huajuapan de León, Oaxaca, México 69000 Tel. +52 (953) 53 2 03 99 extensión 200 Fax +52 (953) 53 2 02 14 www.utm.mx ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Computing the multiplication table of a group using the GHC inliner ; )
Hello, turns out that you can define the group operation of the symmetric group on 3 elements in this abstract way (via the isomorphism to the group of bijective functions from a three-element type to itself): s3mult g2 g1 = fromFun (toFun g2 . toFun g1) and convince GHC to compile it down to a nested case statement. It even somehow made the left multiplication with the identity non-strict. Just thought it's neat ;) $ ghc-core S3.hs -funfolding-use-threshold=64 ... -- identifiers manually un-qualified for readability s3mult = \ (g2_ahA :: S3) (g1_ahB :: S3) - case g2_ahA of _ { S3abc - g1_ahB; S3bca - case g1_ahB of _ { S3abc - S3bca; S3bca - S3cab; S3cab - S3abc; S3acb - S3bac; S3bac - S3cba; S3cba - S3acb }; S3cab - case g1_ahB of _ { S3abc - S3cab; S3bca - S3abc; S3cab - S3bca; S3acb - S3cba; S3bac - S3acb; S3cba - S3bac }; S3acb - case g1_ahB of _ { S3abc - S3acb; S3bca - S3cba; S3cab - S3bac; S3acb - S3abc; S3bac - S3cab; S3cba - S3bca }; S3bac - case g1_ahB of _ { S3abc - S3bac; S3bca - S3acb; S3cab - S3cba; S3acb - S3bca; S3bac - S3abc; S3cba - S3cab }; S3cba - case g1_ahB of _ { S3abc - S3cba; S3bca - S3bac; S3cab - S3acb; S3acb - S3cab; S3bac - S3bca; S3cba - S3abc } } -- inverse s3inv = \ (g_ahC :: S3) - case g_ahC of _ { S3abc - S3abc; S3bca - S3cab; S3cab - S3bca; S3acb - S3acb; S3bac - S3bac; S3cba - S3cba } --- end core --- --- source --- module S3 where -- | Symmetric group / permutation group on 3 elements data S3 = S3abc | S3bca | S3cab | S3acb | S3bac | S3cba deriving(Eq) -- | Returns an element of S3 satisfying the given predicate s3the :: (S3 - Bool) - S3 s3the p | p S3abc = S3abc | p S3acb = S3acb | p S3bac = S3bac | p S3bca = S3bca | p S3cba = S3cba | p S3cab = S3cab | otherwise = error s3the: no element satisfies the predicate data ABC = A | B | C deriving(Eq) toFun :: S3 - ABC - ABC toFun g = case g of S3abc - mkFun A B C S3bca - mkFun B C A S3cab - mkFun C A B S3acb - mkFun A C B S3bac - mkFun B A C S3cba - mkFun C B A where mkFun imA _ _ A = imA mkFun _ imB _ B = imB mkFun _ _ imC _ = imC fromFun :: (ABC - ABC) - S3 fromFun f = s3the (\g - toFun g A == f A toFun g B == f B) s3mult :: S3 - S3 - S3 s3mult g2 g1 = fromFun (toFun g2 . toFun g1) s3inv g = s3the (\g' - s3mult g' g == S3abc) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Install GTK on Windows
Daniel Díaz danield...@asofilak.es writes: I have installed successfully the gtk package on Windows. GTK version: 2.16 gtk package version: 0.12.0 Haskell Platform version: 2010.2.0.0 I have detailed my steps (very similar to Mark Shroyer steps) here: http://deltadiaz.blogspot.com/2011/03/on-windows-how-to-install-gtk.html It seems that my error comes from an space in the path of gtk, and later, from my version of the Haskell Platform (cabal version, I guess). In brief: 1) Install Haskell Platform, version 2010.2.0.0. 2) Download and unpack gtk all-in-one bundle, version 2.16. Path without spaces. 3) Add gtk/bin and mingw/bin to the PATH environment variable. 4) Install gtk2hs-buildtools. 5) Install gtk. And it works! Great! :) -- Andy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Computing the multiplication table of a group using the GHC inliner ; )
2011/3/22 Daniel Schüssler anotheraddr...@gmx.de: Hello, turns out that you can define the group operation of the symmetric group on 3 elements in this abstract way (via the isomorphism to the group of bijective functions from a three-element type to itself): s3mult g2 g1 = fromFun (toFun g2 . toFun g1) and convince GHC to compile it down to a nested case statement. It even somehow made the left multiplication with the identity non-strict. Just thought it's neat ;) That's quite fantastic. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for feedback on my attempt at a tree construction edsl
Hi, I've tried a non-monadic version based on the suggestions here - https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeWithoutMonad.hs This implementation seems to lack the indentation based approach that the do syntax allows. Would I be right if I said that the non-monadic version is shallow embedding and the monadic approach is deep embedding? Can we do deep embedding without using monads? Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe