Re: [Haskell-cafe] Combining wl-pprint and ByteString?
Hi Ivan, Yes, I want it printed in a terminal window. I want to be able to run it from the command line in a terminal window, and have the text come up in colours (but very fast). My current version is already very fast, but I've heard everyone raving about how slow Strings were to use for I/O, so I wanted to _experiment_ with ByteStrings to see the performance difference. I'm experimenting with writing a Zork-like text adventure game and I just wanted to do some space/time profiling on different pieces of code and observe the results. I thought that ByteStrings might be the way to go, but can they be combined with the Doc type from the ansi-wl-pprint library? Mark On 09/11/2010, at 5:37 PM, Ivan Lazar Miljenovic wrote: On 9 November 2010 17:53, Mark Spezzano mark.spezz...@chariot.net.au wrote: Hi all, I want to do the following tasks in this order: 1. Read text from standard input (should this be stored internally in my program as a ByteString or as a String?) 2. Process the text via left justifying it and making it word-wrap (again, internally, should I store this as a ByteString or String?) 3. Format the text using the Wadler-Leijen Pretty Printer (to the best of my knowledge this only processes Strings, but not ByteStrings) 4. Print to Standard output the formatted (i.e. colourised, and justified) text (again, should this be as a ByteString or as a String?) I thought that the reason that most people use ByteString was for _performance_, but wl-pprint can only process Strings to the best of my knowledge. I would, ideally, like to use ByteStrings everywhere...all throughout my code. Is this possible with coloured text? I want to boost up the performance of my application dramatically, so in theory I could process everything as a String, then as the last second pack everything processed into a ByteString and print it out...I think that this might work. Then again it might not because of the types expected. Any help with this would be appreciated. Well, I'm currently working on a Text version of wl-pprint, which will probably suit your needs better than Bytestring. As for coloured text, there's ansi-wl-pprint, but it's more for terminals (how exactly do you want to output your results?). -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ 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] Combining wl-pprint and ByteString?
On 9 November 2010 19:01, Mark Spezzano mark.spezz...@chariot.net.au wrote: Hi Ivan, Yes, I want it printed in a terminal window. I want to be able to run it from the command line in a terminal window, and have the text come up in colours (but very fast). My current version is already very fast, but I've heard everyone raving about how slow Strings were to use for I/O, so I wanted to _experiment_ with ByteStrings to see the performance difference. I _think_ Bytestrings are more efficient when dealing with files, networks, etc.; I don't think there would be any noticeable improvement in efficiencies for terminal I/O (probably less, since I think - but am quite possibly wrong - that printing to stdout and reading from stdin still goes via String). I'm experimenting with writing a Zork-like text adventure game and I just wanted to do some space/time profiling on different pieces of code and observe the results. I thought that ByteStrings might be the way to go, but can they be combined with the Doc type from the ansi-wl-pprint library? Have you actually profiled your code to see if the I/O is indeed a bottleneck? And no, unless you fork and convert it, ansi-wl-pprint can't use Bytestrings. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-Cafe] Parsing bytestream
Hi, I've been trying to implement the RFB (VNC) protocol and I was exploring a neat way of parsing the protocol bytestream. The protocol specifies that the client first sends a byte that identifies the command then a sequence of word8, word16, word32 and paddings. I've tried to capture that logic with the function below. commandFormat :: Word8 - [Int] -- 0 for padding bytes commandFormat c | c == setPixelFormat = [0,0,0,1,1,1,1,2,2,2,1,1,1,0,0,0] | c == setEncodings = [0,2] | c == framebufferUpdateRequest = [0,2,2,2,2] | c == keyEvent = [1,2,4] | c == pointerEvent = [1,2,2] | c == clientCutText= [0,0,0,4] | otherwise = [] What I am struggling with is a function like this - parseCommand :: Word8 - ByteStream - [Int] parseCommand command byteStream = ... I want the function to use the commandFormat above and return me a list of integers -- for example - if the command is keyEvent and the bytestream is 1 0 2 0 0 0 3 The output should be - [1,2,3]!!! - That way, I can process it easily. I'd appreciate some help on this very much. -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
I'd use a parser combinator library that has word8 word16, word32 combinators. The latter should really have big and little endian versions word16be, word16le, word32be, word32le. Data.Binary should provide this and Attoparsec I think. Usually I roll my own, but only because I had my own libraries before these two existed. The idiom of a tag byte telling you what comes next is very common in binary formats. It means parsers can avoid backtracking altogether. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: Haskell Communities and Activities Report (19th ed., November 2010)
On behalf of all the contributors, I am pleased to announce that the Haskell Communities and Activities Report (19th edition, November 2010) is now available in PDF and HTML formats: http://haskell.org/communities/11-2010/report.pdf http://haskell.org/communities/11-2010/html/report.html Many thanks go to all the people that contributed to this report, both directly, by sending in descriptions, and indirectly, by doing all the interesting things that are reported. I hope you will find it as interesting a read as I did. If you have not encountered the Haskell Communities and Activities Reports before, you may like to know that the first of these reports was published in November 2001. Their goal is to improve the communication between the increasingly diverse groups, projects, and individuals working on, with, or inspired by Haskell. The idea behind these reports is simple: Every six months, a call goes out to all of you enjoying Haskell to contribute brief summaries of your own area of work. Many of you respond (eagerly, unprompted, and sometimes in time for the actual deadline ;-) to the call. The editor collects all the contributions into a single report and feeds that back to the community. When I try for the next update, six months from now, you might want to report on your own work, project, research area or group as well. So, please put the following into your diaries now: End of April 2011: target deadline for contributions to the May 2011 edition of the HCA Report Unfortunately, many Haskellers working on interesting projects are so busy with their work that they seem to have lost the time to follow the Haskell related mailing lists and newsgroups, and have trouble even finding time to report on their work. If you are a member, user or friend of a project so burdened, please find someone willing to make time to report and ask them to register with the editor for a simple e-mail reminder in April (you could point me to them as well, and I can then politely ask if they want to contribute, but it might work better if you do the initial asking). Of course, they will still have to find the ten to fifteen minutes to draw up their report, but maybe we can increase our coverage of all that is going on in the community. Feel free to circulate this announcement further in order to reach people who might otherwise not see it. Enjoy! Janis Voigtlaender hcar at haskell.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
Thanks Stephen, On Tue, Nov 9, 2010 at 2:53 PM, Stephen Tetley stephen.tet...@gmail.com wrote: I'd use a parser combinator library that has word8 word16, word32 combinators. The latter should really have big and little endian versions word16be, word16le, word32be, word32le. Data.Binary should provide this and Attoparsec I think. Usually I roll my own, but only because I had my own libraries before these two existed. The idiom of a tag byte telling you what comes next is very common in binary formats. It means parsers can avoid backtracking altogether. I'll take a look at attoparsec I was also trying to understand how I could do it myself also - Basically I've been using the Get Monad for getting out the word/8/16 etc out of a ByteStream - but I dont want to write a separate parsing routine for each command. So instead of doing something like this - parseCommand1 byteStream = runGet $ do b1 - getWord8 b2 - getWord16be return (b1,b2) parseCommand2 byteStream = runGet $ do b1 - getWord16be b2 - getWord16be return (b1,b2) I'd like to do this parse byteStream command = runGet $ do map (commandFormat command) --- or something like this - not exactly sure about this. Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
2010/11/9 C K Kashyap ckkash...@gmail.com: Thanks Stephen, On Tue, Nov 9, 2010 at 2:53 PM, Stephen Tetley stephen.tet...@gmail.com wrote: I'd use a parser combinator library that has word8 word16, word32 combinators. The latter should really have big and little endian versions word16be, word16le, word32be, word32le. Data.Binary should provide this and Attoparsec I think. Usually I roll my own, but only because I had my own libraries before these two existed. The idiom of a tag byte telling you what comes next is very common in binary formats. It means parsers can avoid backtracking altogether. I'll take a look at attoparsec I was also trying to understand how I could do it myself also - Basically I've been using the Get Monad for getting out the word/8/16 etc out of a ByteStream - but I dont want to write a separate parsing routine for each command. So instead of doing something like this - parseCommand1 byteStream = runGet $ do b1 - getWord8 b2 - getWord16be return (b1,b2) parseCommand2 byteStream = runGet $ do b1 - getWord16be b2 - getWord16be return (b1,b2) I'd like to do this parse byteStream command = runGet $ do map (commandFormat command) --- or something like this - not exactly sure about this. Hi, This doesn't seem a good idea to me. In the first case, when you have parsed your data, you end up with very specific data structures that can be processed later as-is. In the second case, you end up with a list for every kind of data, so you're bound to parse that list again to know what you're dealing with. In the first case, parsing wrong data is the only way to fail and you produce solid data you can work with. In the second case, you have a very weak representation that will need more work afterward, and that work is very similar to the parsing you do in the first place. Cheers, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
I think I can restate my problem like this --- If I have a list of actions as follows - import Data.Word import Data.Binary.Get data MyAction = A1 (Get Word8) | A2 (Get Word16) a = A1 getWord8 b = A2 getWord16be listOfActions = [a,b,a] How can I execute the listOfActions inside of a Get Monad and get the output as a list? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
2010/11/9 C K Kashyap ckkash...@gmail.com: I think I can restate my problem like this --- If I have a list of actions as follows - import Data.Word import Data.Binary.Get data MyAction = A1 (Get Word8) | A2 (Get Word16) a = A1 getWord8 b = A2 getWord16be listOfActions = [a,b,a] How can I execute the listOfActions inside of a Get Monad and get the output as a list? Since you want the result as a list, by somehow mapping over a list of action, and since lists are homogeneous in Haskell, you need each action to have the same result type. Something like: performAction :: MyAction - Get Int performAction A1 = getWord8 = return . someHypotheticalWordToIntYouWouldLike Notice that I have rewritten your data MyAction = A1 (Get Word8) as simply data MyAction = A1 because it seems your A1 action will always be getWord8. Now, you don't need specifically a list of MyAction and map performAction on it: you can achieve the same thing with: sequence [getWord8 = return . someHypotheticalWordToIntYouWouldLike, ...] Cheers, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
On Tue, Nov 9, 2010 at 8:10 AM, C K Kashyap ckkash...@gmail.com wrote: ] I think I can restate my problem like this --- ] ] If I have a list of actions as follows - ] ] import Data.Word ] import Data.Binary.Get ] ] data MyAction = A1 (Get Word8) | A2 (Get Word16) ] ] a = A1 getWord8 ] b = A2 getWord16be ] ] listOfActions = [a,b,a] ] ] How can I execute the listOfActions inside of a Get Monad and get ] the output as a list? Do you mean, something like this? import Control.Applicative (($)) data MyAction m = A1 (m Word8) | A2 (m Word16) a = A1 getWord8 b = A2 getWord16be listOfActions = [a,b,a] newtype Id a = Id a getAction :: MyAction Get - Get (MyAction Id) getAction (A1 act) = A1 . Id $ act getAction (A2 act) = A2 . Id $ act getActions :: [MyAction Get] - Get [MyAction Id] getActions = mapM getAction -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
If we change the code a bit, data MyAction = A1 Word8 | A2 Word16 a,b :: Get MyAction a = A1 $ getWord8 b = A2 $ getWord16be listOfActions :: [Get MyAction] listOfActions = [a,b,a] Now, we know how to execute the list of actions, and get the output as list. Using the following guys: sequence :: Monad m = [m a] - m [a] runGet :: Get a - ByteString - a Best, Ozgur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
2010/11/9 Ozgur Akgun ozgurak...@gmail.com: If we change the code a bit, data MyAction = A1 Word8 | A2 Word16 a,b :: Get MyAction a = A1 $ getWord8 b = A2 $ getWord16be listOfActions :: [Get MyAction] listOfActions = [a,b,a] Now, we know how to execute the list of actions, and get the output as list. Using the following guys: sequence :: Monad m = [m a] - m [a] runGet :: Get a - ByteString - a The original question was (I believe) how to drive the parsing with a list of Actions, not the result be a list of Actions. Cheers, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Combining wl-pprint and ByteString?
On 9 November 2010 08:01, Mark Spezzano mark.spezz...@chariot.net.au wrote: I want to be able to run it from the command line in a terminal window, and have the text come up in colours (but very fast). My current version is already very fast, but I've heard everyone raving about how slow Strings were to use for I/O, so I wanted to _experiment_ with ByteStrings to see the performance difference. I very much doubt that you will see a difference in performance between String and Text for the amounts of data that you can fit on a terminal window. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
The original question was (I believe) how to drive the parsing with a list of Actions, not the result be a list of Actions. Yes ... the result needs to be a list of plain values - Int's But I did not follow why you have dropped the word16 -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
Thanks Ozgur and Felipe, Could you also show how I could actually use it to parse a bytestring please? import qualified Data.ByteString.Lazy as BS import Control.Applicative (($)) import Data.Word import Data.Binary.Get data MyAction = A1 Word8 | A2 Word16 a,b :: Get MyAction a = A1 $ getWord8 b = A2 $ getWord16be listOfActions :: [Get MyAction] listOfActions = [a,b,a] --sequence :: Monad m = [m a] - m [a] --runGet :: Get a - ByteString - a bs = BS.pack [1,0,2] How exactly can I get back a list of integers from bs? -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure
What changed between GHC 6.12 and GHC 7.0? Is there a some solution besides using IncoherentInstances in every module that imports XMLGenerator? I just want to point out that IncoherentInstances is NOT a solution. It would probably make the files compile, but not at all with the semantics we want. /Niklas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
Okay, I think I got it .. I went with Ozgur's example - data MyAction m = A1 (m Word8) | A2 (m Word16) a = A1 getWord8 b = A2 getWord16be listOfActions = [a,b,a] newtype Id a = Id a getAction :: MyAction Get - Get (MyAction Id) getAction (A1 act) = A1 . Id $ act getAction (A2 act) = A2 . Id $ act getActions :: [MyAction Get] - Get [MyAction Id] getActions = mapM getAction bs = BS.pack [1,0,2,4] abc = map toVal $ runGet (getActions listOfActions) bs toVal (A1 (Id v)) = fromIntegral v :: Int toVal (A2 (Id v)) = fromIntegral v :: Int Kindly let me know if this is exactly how you intended it to be used? Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error installing hp2any-graph on Snow Leopard
From: Mark Spezzano mark.spezz...@chariot.net.au Hi, I get the following error when doing a 'cabal install hp2any-graph' (the profiling tool) Does anyone know why? (I'm running Snow Leopard and I've tried using other flags suggested...but with no success). GLUT is already installed via MacPorts and via cabal. Have you tried to build any Haskell programs using GLUT? Do they work? John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure
On 09/11/10 11:53, Neil Brown wrote: XMLGenerator.lhs:64:16: Overlapping instances for EmbedAsChild (IdentityT IO) (XMLGenT m (XML m)) arising from a use of `asChild' at XMLGenerator.lhs:64:16-22 Matching instances: instance [overlap ok] (XML m ~ x, XMLGen m) = EmbedAsChild m x -- Defined at XMLGenerator.lhs:37:11-52 instance [overlap ok] (EmbedAsChild m c) = EmbedAsChild m (XMLGenT m c) -- Defined at XMLGenerator.lhs:31:11-60 I think I should expand slightly more on this bit, especially since I chopped off the useful line The choice depends on the instantiation of `m'. The problem is that depending on the choice of m in the instance (the EmbedAsChild (IdentityT IO) (XMLGenT m (XML m)) part), you may or may not match the second overlapping instance. If you choose m=IdentityT IO then it matches the second instance, if you choose anything else then it won't, so GHC can't tell at this point which instance to choose. Which makes them not just overlapping, but also leaves no clear choice (which is why it prompts you to use IncoherentInstances). When you typed the genElement foo part explicitly and gave a type to the monad m, that fixed the ambiguity. So I think it's not even that you needed incoherent instances, you have an unresolvable ambiguity if the type of m is left to be inferred. So I still think the question is why the old instance with the ~ worked fine. (Does this help, or am I telling you what you've already worked out for yourself?) Thanks, Neil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Haskell is a scripting language inspired by Python.
Hello Gregg, Tuesday, November 9, 2010, 2:12:12 AM, you wrote: Doesn't COBOL have significant layout anyway as an inspiration to both? Yes and no. What it actually has relates strongly to punched cards and is more like assemblers of the day. i never programmed in COBOL, but afaik data structures usually was organized this way - together with level numbers at left. it was just easier to read it this way -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure
I'm not sure whether to reply to the list(s) or the ticket; maybe if you think my comments are valid they can be copied to the ticket. From looking, it seems to me that you do have overlapping instances, and I wonder if it's actually a 6.12 bug for accepting the code, not a 7 bug for rejecting it. I took your XMLGenerator.lhs file from the ticket and loaded it in GHC 6.12; it loaded fine. Then I looked through and squinted at this instance: instance (EmbedAsChild m c, m1 ~ m) = EmbedAsChild m (XMLGenT m1 c) That looked to me like a long-winded way of saying: instance (EmbedAsChild m c) = EmbedAsChild m (XMLGenT m c) Unless I'm missing something? So I made that change, then loaded it again. Suddenly I have overlapping instances in 6.12: XMLGenerator.lhs:64:16: Overlapping instances for EmbedAsChild (IdentityT IO) (XMLGenT m (XML m)) arising from a use of `asChild' at XMLGenerator.lhs:64:16-22 Matching instances: instance [overlap ok] (XML m ~ x, XMLGen m) = EmbedAsChild m x -- Defined at XMLGenerator.lhs:37:11-52 instance [overlap ok] (EmbedAsChild m c) = EmbedAsChild m (XMLGenT m c) -- Defined at XMLGenerator.lhs:31:11-60 It seems to me that the two instances can overlap; consider if I define an instance for XMLGen: data WhateverM instance XMLGen WhateverM where type XML WhateverM = XMLGenT WhateverM () At that point your instances would overlap if I want an instance for EmbedAsChild WhateverM (XMLGenT WhateverM ()). My understanding of the way type-classes are checked is that since that instance could exist somewhere in a different module, we must reject the two instances for EmbedAsChild. (Or rather: ignoring the head of the instance declarations, the instances can overlap.) But I may be wrong! So my guess is you've always had overlapping instances (assuming this code is representative of your original), and my hypothesis is that the use of ~ in one of the instances was somehow stopping GHC 6.12 from spotting this. Thoughts (and corrections!) welcome. Thanks, Neil. On 08/11/10 23:30, Jeremy Shaw wrote: Hello, I have narrowed this down further to a single file. And created a trac bug for it: http://hackage.haskell.org/trac/ghc/ticket/4485 This is (the only thing?) holding up HSP and happstack moving to GHC 7. - jeremy On Tue, Nov 2, 2010 at 5:36 PM, Jeremy Shawjer...@n-heptane.com wrote: Hello, I have a module, XMLGenerator, which has some overlapping instances. I have a second module, Test, which imports that module and also adds some more overlapping instances. Both modules contain {-# LANGUAGE OverlappingInstances #-} at the top. Under some old version of 6.13 (and probably 6.12), if I put both modules in the same directory and try to load Test.hs, it gets the error: Test.hs:16:15: Overlapping instances for EmbedAsChild (M IO) (XMLGenT m (XML m)) arising from a use of `asChild' at Test.hs:16:15-21 Matching instances: instance (m1 ~ m, EmbedAsChild m c) = EmbedAsChild m (XMLGenT m1 c) -- Defined at XMLGenerator.hs:16:10-68 instance (XML m ~ x, XMLGen m) = EmbedAsChild m x -- Defined at XMLGenerator.hs:19:10-51 In the first argument of `($)', namely `asChild' In the expression: asChild $ (genElement foo) In the definition of `asChild': asChild b = asChild $ (genElement foo) If I put the XMLGenerator module in a separate package, dummy-hsx, and the Test modules links against it, I still get the error. *but* if I add: Extensions: OverlappingInstances to the dummy-hsx.cabal file, then Test.hs compiles just fine! So, for starters, I do not understand why that happens. Under GHC 7.0rc1, modifying the .cabal file has no effect. Instead I always get the error: Test.hs:16:15: Overlapping instances for EmbedAsChild (M IO) (XMLGenT m (XML m)) arising from a use of `asChild' Matching instances: instance [overlap ok] (m1 ~ m, EmbedAsChild m c) = EmbedAsChild m (XMLGenT m1 c) -- Defined in XMLGenerator (The choice depends on the instantiation of `m' To pick the first instance above, use -XIncoherentInstances when compiling the other instance declarations) Adding the IncoherentInstances flag does make it compile -- but I have never enabled that flag and not regretted it. What changed between GHC 6.12 and GHC 7.0? Is there a some solution besides using IncoherentInstances in every module that imports XMLGenerator? I have attached XMLGenerator.hs, Test.hs, and dummy-hsx.cabal. thanks! - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org
Re: [Haskell-cafe] Error installing hp2any-graph on Snow Leopard
Hi John Yes, I finally got it (partly) working. I needed to add the --extra-lib-dirs=pathname and --extra-include-dirs=pathname flags to point to the necessary libraries. However, now the hp2any-manager won't install because of (other) dependencies. So I've given up on it for the time being because it's causing me too much trouble. Maybe I'll try again later. (Strangely it needs _earlier_ versions of cairo and pango and gtk etc, and doesn't recognise that I actually have these installed. But when I do this, other stuff breaks, and I need to reinstall cabal). Mark On 09/11/2010, at 10:24 PM, John Lato wrote: From: Mark Spezzano mark.spezz...@chariot.net.au Hi, I get the following error when doing a 'cabal install hp2any-graph' (the profiling tool) Does anyone know why? (I'm running Snow Leopard and I've tried using other flags suggested...but with no success). GLUT is already installed via MacPorts and via cabal. Have you tried to build any Haskell programs using GLUT? Do they work? John ___ 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] Re: change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure
instance (EmbedAsChild m c, m1 ~ m) = EmbedAsChild m (XMLGenT m1 c) That looked to me like a long-winded way of saying: instance (EmbedAsChild m c) = EmbedAsChild m (XMLGenT m c) Unless I'm missing something? These two instances are not equivalent: - the first matches even if m and m1 differ, causing a type-error. - the second matches only if m~m1 Claus {-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} class C a bwhere c :: a - b - Bool instance C a a where c _ _ = True instance C a b where c _ _ = False class D a b where d :: a - b - Bool instance a~b=D a b where d _ _ = True -- instance D a b where d _ _ = False -- would be a duplicate instance {- *Main c () () True *Main c () True False *Main d () () True *Main d () True interactive:1:0: Couldn't match expected type `Bool' against inferred type `()' When generalising the type(s) for `it' -} ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
Oops .. I made a mistake .. I had gone with Felipe's solution - getActions :: [MyAction Get] - Get [MyAction Id] getActions = mapM getAction -- Felipe. Felpe, could you please confirm if bs = BS.pack [1,0,2,4] toVal (A1 (Id v)) = fromIntegral v :: Int toVal (A2 (Id v)) = fromIntegral v :: Int abc = map toVal $ runGet (getActions listOfActions) bs is the right way of getting the values out? -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Printing of asynchronous exceptions to stderr
Hi! I have been spend some time to debug this in my program. ;-) Why is ThreadKilled not displayed by RTS when send to thread (and unhandled), but any other exception is? For example, I am using custom exceptions to signal different kinds of thread killing. Based on those my threads cleanup in different ways. But after they cleanup they keep running. Not really running as their computations were interrupted. But simply hanging there. And if then new custom exception arrives it is not handled anymore (as it is after my normal exception handlers already cleaned everything) and it is printed to stderr. Now I added `finally` throwIO ThreadKilled at the end of my cleanup computations to really kill the thread. So that possible later exceptions are not delivered anymore. Why it is not so that after all computations in a thread finish, thread is not killed/disposed of? Because it can be reused by some other computation? But then my exceptions could be delivered to wrong (new) thread while they were meant for old one? Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCE] csound-expression - csound combinator library
no, it's not here any more, but i've added tutorial. look for update http://hackage.haskell.org/package/csound-expression 2010/11/4 C K Kashyap ckkash...@gmail.com Hi Erik, This looks very interesting and seems to have quite comprehensive reference documentation. Unfortunately there doesn't seem to be any examples. Would it be possible to add some examples? Even trivial ones would be useful to get people started. Erik The examples at the bottom of 'CsoundExpr.Base.Types' page might help -- 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] ActionScript Byte Code backend ?
Is there a Flash ActionScript Byte Code generating backend for Haskell ? I know there was an older SWF 3 backend :- http://www.n-heptane.com/nhlab/repos/haskell-swf/ But is there anything more up to date ? Aaron ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] xml packages
First question. As I saw in sources, both hxt and haxml uses [Char]'s. this is very inefficient. I want to know, does any effective parser for haskell, written in haskell, exists. Efficient means using ByteString to store strings and possibly building representations that shares one string for all similiary named elements. If there is no, is anyone interested in writing one? Second question. I'd like to have a package for read-write-edit SVG graphics. I think, xslt (both transformations and formatting object) are interesting too. Is anyone considering writing such packages? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] xml packages
On Tue, 9 Nov 2010, Permjacov Evgeniy wrote: First question. As I saw in sources, both hxt and haxml uses [Char]'s. this is very inefficient. I want to know, does any effective parser for haskell, written in haskell, exists. Efficient means using ByteString to store strings and possibly building representations that shares one string for all similiary named elements. If there is no, is anyone interested in writing one? ByteString would be only useful for (undecoded) input. XML identifiers and text have to be Unicode, thus the 'text' library could be a replacement for String. In the pre-'text' era I tried to use ByteString as input and String for XML identifiers and text and got no significant speedup. Second question. I'd like to have a package for read-write-edit SVG graphics. I think, xslt (both transformations and formatting object) are interesting too. Is anyone considering writing such packages? It would be nice. We already have HPDF for PDF construction and hps for PostScript construction and cairo for construction of PDF, PS, SVG. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ActionScript Byte Code backend ?
Hello, I wrote the old backend. I have not (and will not) have the time to update to the newer SWF format. Unless things have changed, the format is well documented -- so you don't have to reverse engineer it if you want to make your own attempt. That said, if you are trying to generate actionscript bytecode, a better approach may be to use LLVM. That is what adobe does for Alchemy: http://labs.adobe.com/wiki/index.php/Alchemy:FAQ if the LLVM - actionscript code is public, then you can use the existing haskell-llvm bindings and get a bunch of optimizing for 'free'. - jeremy On Nov 9, 2010, at 11:40 AM, Aaron Gray wrote: Is there a Flash ActionScript Byte Code generating backend for Haskell ? I know there was an older SWF 3 backend :- http://www.n-heptane.com/nhlab/repos/haskell-swf/ But is there anything more up to date ? Aaron ___ 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] ANNOUNCE: The Fibon benchmark suite (v0.2.0)
I'm pleased to announce the release of the Fibon benchmark tools and suite. Fibon is a set of tools for running and analyzing benchmark programs in Haskell. Most importantly, it includes an optional set of benchmark programs including many programs taken from the Hackage open source repository. The source code for the tools and benchmarks are available on github https://github.com/dmpots/fibon http://github.com/dmpots/fibon-benchmarks The Fibon tools (without the benchmarks) are available on hackage. http://hackage.haskell.org/package/fibon The package needs to be unpacked and built in place to be able to run any benchmarks. It can be used with the official Fibon benchmarks or you can create your own suite and just use Fibon to run and analyze your benchmark programs. Some more documentation is available on the fibon wiki https://github.com/dmpots/fibon/wiki Fibon Tools === Fibon is a pure Haskell framework for running and analyzing benchmark programs. Cabal is used for building the benchmarks. The benchmark harness, configuration files, and benchmark descriptions are all written in Haskell. The benchmark descriptions and run configurations are all statically compiled into the benchmark runner to ensure that configuration errors are found at compile time. The Fibon tools are not tied to any compiler infrastructure and can build benchmarks using any compiler supported by cabal. However, there are some extra features available when using GHC to build the benchmarks: * Support in config files for using an inplace GHC HEAD build * Support in `fibon-run` for collecting GC stats from GHC compiled programs * Support in `fibon-analyse` for reading GC stats from Fibon result files The Fibon Benchmark Suite === The Fibon benchmark suite currently contains 34 benchmarks from a variety of sources. The individual benchmarks and lines of code are given below. Dph _DphLib316 Dotp 308 Qsort 236 QuickHull 680 Sumsq 72 -- TOTAL 1612 Hackage Agum 786 Bzlib 432 Cpsa 11582 Crypto4486 Fgl 3834 Fst 4532 Funsat 16085 Gf 23970 HaLeX 4035 Happy 5833 Hgalib 819 Palindromes496 Pappy 7313 QuickCheck4495 Regex 6873 Simgi 5134 TernaryTrees 722 Xsact 2783 -- TOTAL 104210 Repa _RepaLib 8775 Blur77 FFT2d 89 FFT3d 103 Laplace274 MMult 133 -- TOTAL 9451 Shootout BinaryTrees 63 ChameneosRedux 96 Fannkuch27 Mandelbrot 68 Nbody 192 Pidigits26 SpectralNorm97 -- TOTAL 569 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] xml packages
You might want to consider SVG only as an output format. As a graphics format it is very baroque with many special cases and sundry obscure corners. If you like grand challenges, round-tripping SVG might be interesting. Unfortunately this would likely consume all the effort that you would otherwise want to spend on actual graphics. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] ANNOUNCE: The Fibon benchmark suite (v0.2.0)
On Tue, Nov 9, 2010 at 1:24 PM, David Peixotto d...@rice.edu wrote: I'm pleased to announce the release of the Fibon benchmark tools and suite. Fibon is a set of tools for running and analyzing benchmark programs in Haskell. Most importantly, it includes an optional set of benchmark programs including many programs taken from the Hackage open source repository. The source code for the tools and benchmarks are available on github https://github.com/dmpots/fibon http://github.com/dmpots/fibon-benchmarks The Fibon tools (without the benchmarks) are available on hackage. http://hackage.haskell.org/package/fibon The package needs to be unpacked and built in place to be able to run any benchmarks. It can be used with the official Fibon benchmarks or you can create your own suite and just use Fibon to run and analyze your benchmark programs. Some more documentation is available on the fibon wiki https://github.com/dmpots/fibon/wiki Fibon Tools === Fibon is a pure Haskell framework for running and analyzing benchmark programs. Cabal is used for building the benchmarks. The benchmark harness, configuration files, and benchmark descriptions are all written in Haskell. The benchmark descriptions and run configurations are all statically compiled into the benchmark runner to ensure that configuration errors are found at compile time. The Fibon tools are not tied to any compiler infrastructure and can build benchmarks using any compiler supported by cabal. However, there are some extra features available when using GHC to build the benchmarks: * Support in config files for using an inplace GHC HEAD build * Support in `fibon-run` for collecting GC stats from GHC compiled programs * Support in `fibon-analyse` for reading GC stats from Fibon result files The Fibon Benchmark Suite === The Fibon benchmark suite currently contains 34 benchmarks from a variety of sources. The individual benchmarks and lines of code are given below. Congrats on the release! It looks like you've invested a lot of time and put in some hard work. I have a few questions: * What differentiates fibon from criterion? I see both use the statistics package. * Does it track memory statistics? I glanced at the FAQ but didn't see anything about it. * Are the numbers in the sample output seconds or milliseconds? What is the stddev (eg., what does the distribution of run-times look like)? Thanks, Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCE] csound-expression - csound combinator library
Anton Kholomiov wrote: no, it's not here any more, but i've added tutorial. look for update http://hackage.haskell.org/package/csound-expression Thanks for that, but wouldn't it be nicer to move the tutorial out of the library sources directoru src/ ? Cheers, Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] Haskell is a scripting language inspired by Python.
On 10/11/2010, at 12:50 AM, Bulat Ziganshin wrote: i never programmed in COBOL, but afaik data structures usually was organized this way - together with level numbers at left. it was just easier to read it this way The clue here is level numbers. In a declaration like 01 Thingy 03 Wotsit 05 Uggle PIC X(5) 05 Zonko PIC 9(4) USAGE COMPUTATIONAL 03 Snork 05 Name PIC X(20) 05 Price PIC V99 USAGE DISPLAY. the indentation is solely for the benefit of people. The compiler uses the *numbers* to figure out the structure. 01 Thingy 03 Wotsit 05 Uggle PIC X(5) 05 Zonko PIC 9(4) USAGE COMPUTATIONAL 03 Snork 05 Name PIC X(20) 05 Price PIC V99 USAGE DISPLAY. would work every bit as well. The same is true of PL/I, which also used level numbers for structuring. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ActionScript Byte Code backend ?
Excerpts from Aaron Gray's message of Tue Nov 09 18:40:47 +0100 2010: Is there a Flash ActionScript Byte Code generating backend for Haskell ? I know there was an older SWF 3 backend :- http://www.n-heptane.com/nhlab/repos/haskell-swf/ But is there anything more up to date ? There is another reference project: HaXe (its not Haskell. But it targets Flash 10) In theory AS3 is very close to JS. So the experimental JS targets could be a solution as well ... Marc Weber ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HTTP 4000.1.0 release
Hi, I've just released HTTP 4000.1.0 to hackage: - Fixed a bug that caused infinite loops for some URLs on some platforms (whether the URL was a trigger is probably related to the size of the returned data, and the affected platforms. Based on a patch by Daniel Wagner. - This is technically a breaking change (and hence there is an API version bump) as the fix introduces a new member to the HStream class which can be used to define a new payload type instead of String/ByteString, but I scanned hackage and noone actually seems to be doing that. - Applied a patch by Antoine Latter to fix a bug in the handling of 301 and 307 response codes. Here's his description of the change: *** The Network.Browser module is a convenience layer over the Network.Http modules offering many of the niceties one would expect in a web-browser - cookies, user authentication, and transparent handling of redirects. When using Network.Browser, previously (since version 4000.0.8) a redirect response code of 301 or 307 from the server would force the redirected request to be sent as a GET, even if the original request was of some other HTTP method. This behavior is only appropriate for a response code of 302 or 303 and has been fixed. *** The upstream repo is now on github: https://github.com/haskell/HTTP, though I may well switch back to darcs if I remain maintainer for long. I'd like to emphasise that I have no particular desire to maintain HTTP and if anyone else would like to take over they would be very welcome! Cheers, Ganesh ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] ANNOUNCE: The Fibon benchmark suite (v0.2.0)
On Nov 9, 2010, at 3:45 PM, Jason Dagit wrote: I have a few questions: * What differentiates fibon from criterion? I see both use the statistics package. I think the two packages have different benchmarking targets. Criterion allows you to easily test individual functions and gives some help with benchmarking in the presence of lazy evaluation. If some code does not execute for a long time it will run it multiple times to get sensible timings. Criterion does a much more sophisticated statistical analysis of the results, but I hope to incorporate that into the Fibon analysis in the future. Fibon is a more traditional benchmarking suite like SPEC or nofib. My interest is using it to test compiler optimizations. It can only benchmark at the whole program level by running an executable. It checks that the program produces the correct output, can collect extra metrics generated by the program, separates collecting results from analyzing results, and generates tables directly comparing the results from different benchmark runs. * Does it track memory statistics? I glanced at the FAQ but didn't see anything about it. Yes, it can read memory statistics dumped by the GHC runtime. It has built in support for reading the stats dumped by `+RTS -t --machine-readable` which includes things like bytes allocated and time spent in GC. * Are the numbers in the sample output seconds or milliseconds? What is the stddev (eg., what does the distribution of run-times look like)? I'm not sure which results you are referring to exactly (the numbers in the announcement were lines of code). I picked benchmarks that all ran for at least a second (and hopefully longer) with compiler optimizations enabled. On an 8-core Xeon, the median time over all benchmarks is 8.43 seconds, mean time is 12.57 seconds and standard deviation is 14.56 seconds. -David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] ANNOUNCE: The Fibon benchmark suite (v0.2.0)
On Tue, Nov 9, 2010 at 5:47 PM, David Peixotto d...@rice.edu wrote: On Nov 9, 2010, at 3:45 PM, Jason Dagit wrote: I have a few questions: * What differentiates fibon from criterion? I see both use the statistics package. I think the two packages have different benchmarking targets. Criterion allows you to easily test individual functions and gives some help with benchmarking in the presence of lazy evaluation. If some code does not execute for a long time it will run it multiple times to get sensible timings. Criterion does a much more sophisticated statistical analysis of the results, but I hope to incorporate that into the Fibon analysis in the future. Fibon is a more traditional benchmarking suite like SPEC or nofib. My interest is using it to test compiler optimizations. It can only benchmark at the whole program level by running an executable. It checks that the program produces the correct output, can collect extra metrics generated by the program, separates collecting results from analyzing results, and generates tables directly comparing the results from different benchmark runs. * Does it track memory statistics? I glanced at the FAQ but didn't see anything about it. Yes, it can read memory statistics dumped by the GHC runtime. It has built in support for reading the stats dumped by `+RTS -t --machine-readable` which includes things like bytes allocated and time spent in GC. Oh, I see. In that case, it's more similar to darcs-benchmark. Except that darcs-benchmark is tailored specifically at benchmarking darcs. Where they overlap is parsing the RTS statistics, running the whole program, and tabular reports. Darcs-benchmark adds to that an embedded DSL for specifying operations to do on the repository between benchmarks (and translating those operations to runnable shell snippets). I wonder if Fibon and darcs-benchmark could share common infrastructure beyond the statistics package. It sure sounds like it to me. Perhaps some collaboration is in order. * Are the numbers in the sample output seconds or milliseconds? What is the stddev (eg., what does the distribution of run-times look like)? I'm not sure which results you are referring to exactly (the numbers in the announcement were lines of code). I picked benchmarks that all ran for at least a second (and hopefully longer) with compiler optimizations enabled. On an 8-core Xeon, the median time over all benchmarks is 8.43 seconds, mean time is 12.57 seconds and standard deviation is 14.56 seconds. I probably read your email too fast, sorry. Thanks for the clarification. Thanks, Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Printing of asynchronous exceptions to stderr
On Tue, Nov 9, 2010 at 5:37 PM, Mitar mmi...@gmail.com wrote: Why is ThreadKilled not displayed by RTS when send to thread (and unhandled), but any other exception is? A ThreadKilled exception is not printed to stderr because it's not really an error and should not be reported as such. It is also clear how to handle a ThreadKilled: just abort the thread and silently terminate. All other exceptions raised in or thrown to the thread which are not handled by the thread itself should be considered errors and reported as such. To see what happens under the hood look at the implementation of forkIO by clicking on the 'Source' link next to the type signature: http://hackage.haskell.org/packages/archive/base/4.2.0.2/doc/html/Control-Concurrent.html#v%3AforkIO The 'action_plus' that is forked catches all exceptions and handles them with childHandler: ... where action_plus = catchException action childHandler childHandler in turn calls real_handler to handle the exception but registers an exception handler so that exceptions raised by the real_handler are handled again recursively: childHandler :: SomeException - IO () childHandler err = catchException (real_handler err) childHandler Now real_handler handles the exceptions BlockedIndefinitelyOnMVar, BlockedIndefinitelyOnSTM and ThreadKilled by just returning. All other exceptions are reported: real_handler :: SomeException - IO () real_handler se@(SomeException ex) = -- ignore thread GC and killThread exceptions: case cast ex of Just BlockedIndefinitelyOnMVar- return () _ - case cast ex of Just BlockedIndefinitelyOnSTM- return () _ - case cast ex of Just ThreadKilled - return () _ - case cast ex of -- report all others: Just StackOverflow - reportStackOverflow _ - reportError se For example, I am using custom exceptions to signal different kinds of thread killing. Based on those my threads cleanup in different ways. But after they cleanup they keep running. Not really running as their computations were interrupted. But simply hanging there. And if then new custom exception arrives it is not handled anymore (as it is after my normal exception handlers already cleaned everything) and it is printed to stderr. What do you mean by hanging there. Are they blocked on an MVar? Now I added `finally` throwIO ThreadKilled at the end of my cleanup computations to really kill the thread. So that possible later exceptions are not delivered anymore. That shouldn't be necessary. If the cleanup action is the last action of the thread then the thread will terminate when it has performed the cleanup. Why it is not so that after all computations in a thread finish, thread is not killed/disposed of? It actually should. I think any other behavior is a bug. It would help if you could show us your code (or parts of it). Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe