Re: [Haskell-cafe] :Trace has no history
The debugger only instruments interpreted code, so evaluations occurring inside library code do not show up in :trace. This is not a terrible problem in practice, since usually seeing the evaluations occurring in your code is what you need to debug the problem. But since :trace is not showing you any evaluations at all, I wonder if the problem might be that your code is not interpreted. In order to ensure that it is, delete all the *.hi and *.o temporary files lying around. You can also simply invoke ghci with the -fbyte-code command line option. If that fails, please complete the paste of your session below with your invocation of ghci. There might be something else going on. Thanks, pepe On Wednesday, September 1, 2010, Steve Severance st...@medwizard.net wrote: How do I tell? Does this mean that if the exception is occurring in a haskell library I can't get to it? I am trying to run down a Prelude.read: No Parse error and I need to see the value that it is failing to parse on. Thanks. Steve On Tue, Aug 31, 2010 at 11:05 AM, Pepe Iborra pepeibo...@gmail.com wrote: Hi Steve The debugger only traces calls in interpreted code. Perhaps the call to myMethod is being made from object code? Admittedly, the ghci debugger can take some effort to learn to use properly. Make sure that you give a look to the ghc user guide if you haven't done so yet. Best, pepe On Tuesday, August 31, 2010, Steve sseve...@gmail.com wrote: I am trying to debug a problem in GHCI. I invoke my method with trace but when it breaks on exception i can't get this history. Output is below. Thanks. relude Symbols :set -fbreak-on-exception Prelude Symbols :trace myMethod Loading package HUnit-1.2.2.1 ... linking ... done. Loading package syb-0.1.0.2 ... linking ... done. Loading package base-3.0.3.2 ... linking ... done. Loading package old-locale-1.0.0.2 ... linking ... done. Loading package time-1.1.4 ... linking ... done. Loading package random-1.0.0.2 ... linking ... done. Loading package QuickCheck-1.2.0.0 ... linking ... done. Loading package Decimal-0.1.0 ... linking ... done. Loading package array-0.3.0.0 ... linking ... done. Loading package Diff-0.1.2 ... linking ... done. Loading package bytestring-0.9.1.5 ... linking ... done. Loading package containers-0.3.0.0 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package old-time-1.0.0.3 ... linking ... done. Loading package convertible-1.0.9 ... linking ... done. Loading package utf8-string-0.3.4 ... linking ... done. Loading package HDBC-2.2.6 ... linking ... done. Loading package HDBC-mysql-0.6.3 ... linking ... done. Loading package parsec-2.1.0.1 ... linking ... done. Loading package network-2.2.1.7 ... linking ... done. Loading package HTTP-4000.0.9 ... linking ... done. Loading package binary-0.5.0.2 ... linking ... done. Loading package digest-0.0.0.8 ... linking ... done. Loading package filepath-1.1.0.3 ... linking ... done. Loading package unix-2.4.0.0 ... linking ... done. Loading package directory-1.0.1.0 ... linking ... done. Loading package pretty-1.0.1.1 ... linking ... done. Loading package zlib-0.5.2.0 ... linking ... done. Loading package zip-archive-0.1.1.6 ... linking ... done. Loading package Core-0.0.1 ... linking ... done. Beginning Update Stopped at exception thrown _exception :: e = GHC.Exception.SomeException (GHC.Exception.D:Exception _ (GHC.Show.D:Show ...) ) (GHC.IO.Exception.IOError Nothing GHC.IO.Exception.UserError ) [exception thrown] Prelude Symbols :history Empty history. Perhaps you forgot to use :trace? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- -- José Iborra http://www.dsic.upv.es/~jiborra -- UPV Valencia Telf. (+34) 96 387 00 00 (ext) 83529 -- Camino de Vera s/n. 46022 Valencia (Spain) -- Steve Severance c. 240.472.9645 e. st...@medwizard.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- -- José Iborrahttp://www.dsic.upv.es/~jiborra -- UPV Valencia Telf. (+34) 96 387 00 00 (ext) 83529 -- Camino de Vera s/n. 46022 Valencia (Spain) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] :Trace has no history
Hi Steve The debugger only traces calls in interpreted code. Perhaps the call to myMethod is being made from object code? Admittedly, the ghci debugger can take some effort to learn to use properly. Make sure that you give a look to the ghc user guide if you haven't done so yet. Best, pepe On Tuesday, August 31, 2010, Steve sseve...@gmail.com wrote: I am trying to debug a problem in GHCI. I invoke my method with trace but when it breaks on exception i can't get this history. Output is below. Thanks. relude Symbols :set -fbreak-on-exception Prelude Symbols :trace myMethod Loading package HUnit-1.2.2.1 ... linking ... done. Loading package syb-0.1.0.2 ... linking ... done. Loading package base-3.0.3.2 ... linking ... done. Loading package old-locale-1.0.0.2 ... linking ... done. Loading package time-1.1.4 ... linking ... done. Loading package random-1.0.0.2 ... linking ... done. Loading package QuickCheck-1.2.0.0 ... linking ... done. Loading package Decimal-0.1.0 ... linking ... done. Loading package array-0.3.0.0 ... linking ... done. Loading package Diff-0.1.2 ... linking ... done. Loading package bytestring-0.9.1.5 ... linking ... done. Loading package containers-0.3.0.0 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package old-time-1.0.0.3 ... linking ... done. Loading package convertible-1.0.9 ... linking ... done. Loading package utf8-string-0.3.4 ... linking ... done. Loading package HDBC-2.2.6 ... linking ... done. Loading package HDBC-mysql-0.6.3 ... linking ... done. Loading package parsec-2.1.0.1 ... linking ... done. Loading package network-2.2.1.7 ... linking ... done. Loading package HTTP-4000.0.9 ... linking ... done. Loading package binary-0.5.0.2 ... linking ... done. Loading package digest-0.0.0.8 ... linking ... done. Loading package filepath-1.1.0.3 ... linking ... done. Loading package unix-2.4.0.0 ... linking ... done. Loading package directory-1.0.1.0 ... linking ... done. Loading package pretty-1.0.1.1 ... linking ... done. Loading package zlib-0.5.2.0 ... linking ... done. Loading package zip-archive-0.1.1.6 ... linking ... done. Loading package Core-0.0.1 ... linking ... done. Beginning Update Stopped at exception thrown _exception :: e = GHC.Exception.SomeException (GHC.Exception.D:Exception _ (GHC.Show.D:Show ...) ) (GHC.IO.Exception.IOError Nothing GHC.IO.Exception.UserError ) [exception thrown] Prelude Symbols :history Empty history. Perhaps you forgot to use :trace? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- -- José Iborrahttp://www.dsic.upv.es/~jiborra -- UPV Valencia Telf. (+34) 96 387 00 00 (ext) 83529 -- Camino de Vera s/n. 46022 Valencia (Spain) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] putStrLn ß
Using the latest version (WinGHCi 1.0.6) and GHCi 6.12.3, I get: * Prelude* putStrLn ß ß * Prelude* print ß \223 * Prelude* putStr αγδ *** Exception: stdout: hPutChar: invalid argument (character is not in the code page) and this is consistent with output I get when using GHCi on a console on Windows. Cheers, Pepe 2010/8/13 Henk-Jan van Tuyl hjgt...@chello.nl L.S., When I try putStrLn ß (Eszett (sharp S)) in WinGhci, the interpreter seems to have disappeared; ctrl-C gives the message Interrupted in a separate window, but no new prompt. When I start GHCi in a shell, the interpreter displays: Prelude print ß \223 Is this a known issue? Other experiments with WinGhci: print αγδ a?d (Trying to print alpha, gamma, delta.) print β (Trying to print beta) interpreter hangs again. Details: - WinGhci 1.0.2 - GHCi, version 6.12.3 - Windows XP Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://van.tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ 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] Re: [Haskell] Woes on MacOS 10.6 - linking issues
(moving to the cafe) There is an incompatibility between the version of iconv in Mac Os and the one included in MacPorts. As the RTS of the build of ghc in the Haskell Platform is linked against Mac Os iconv, you cannot use it with the build of gtk2hs from MacPorts. This is a known issue already commented elsewhere, in case you haven't found it already: http://www.mail-archive.com/haskell-cafe@haskell.org/msg69139.html http://stackoverflow.com/questions/2726248/ghc-6-12-and-macports Cheers, On Fri, Jun 11, 2010 at 4:53 AM, Brett Giles brett.gi...@ucalgary.ca wrote: Hi Folks I seem to have Gtk2HS 0.11 installed, but not quite working. Interestingly, I can run a demo, such as the hello/World.hs example, directly in ghci. However, when I try to do a ghc --make on any code containing gtk2hs I get a link error like this: Undefined symbols: _iconv_close, referenced from: _hs_iconv_close in libHSbase-4.2.0.0.a(iconv.o) (maybe you meant: _hs_iconv_close) _iconv, referenced from: _hs_iconv in libHSbase-4.2.0.0.a(iconv.o) (maybe you meant: _hs_iconv_open, _hs_iconv , _hs_iconv_close ) _iconv_open, referenced from: _hs_iconv_open in libHSbase-4.2.0.0.a(iconv.o) (maybe you meant: _hs_iconv_open) ld: symbol(s) not found I do have libiconv installed as a universal library via macports. gtk, glade etc., are also universal installed via macports. I downloaded the OSX Haskell Platform package and am running ghc 6.12.1 Other programs seem to be having some issues as well though, For instance, a command line program seems to compile fine, but when it runs I get the message: $ emlqpl (--- My successfully compiled program - batch only, no gtk items) dyld: Library not loaded: /opt/local/lib/libgtk-quartz-2.0.0.dylib Referenced from: /usr/local/bin/emlqpl Reason: image not found Trace/BPT trap Does anyone have any suggestions? Brett Giles Grad Student, Formal Methods, Category Theory, University of Calgary brett.gi...@ucalgary.ca ___ Haskell mailing list hask...@haskell.org http://www.haskell.org/mailman/listinfo/haskell -- -- José Iborrahttp://www.dsic.upv.es/~jiborra -- UPV Valencia Telf. (+34) 96 387 00 00 (ext) 83529 -- Camino de Vera s/n. 46022 Valencia (Spain) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] WinGHCi stuck in a loop
WinGHCi options are stored under HKEY_CURRENT_USER\Software\Haskell\WinGhciversion in the Windows registry. Cheers, Pepe 2009/11/7 Henk-Jan van Tuyl hjgt...@chello.nl L.S., I changed the options in WinGHCi and now WinGHCi is stuck in a loop each time I start it; how can I edit the options? I cannot find them in the registry. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://van.tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ 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
Fwd: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows
-- Forwarded message -- From: Pepe Gallardo pepe.hask...@gmail.com Date: 2009/3/25 Subject: Re: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows To: Benjamin L.Russell dekudekup...@yahoo.com Hi Benjamin*,* ** The only requirement to run WinGhci is to have GHC installed and to have GHC bin directory on your path. The way to start the application is by executing winghci.exe. Install.exe is an small program that associates .hs files with WinGhci (it should be run from the same directory where WinGhci is installed). Note that this association is optional. I have added a wiki page on this. 2009/3/23 Benjamin L.Russell dekudekup...@yahoo.com Just another couple of thoughts for possible additional improvement: 1. It would be even nicer if WinGhci added a menu entry to the Start menu automatically, as WinHugs does. 2. For the proposed menu entry, it would also probably be a good idea if WinGhci added a folder for that menu entry, and included a link to a README file in there, as WinHugs does also. 3. In order to distinguish WinGhci from GHCi, it might also be helpful if WinGhci had a different icon; the current WinGhci icon is identical to the one for GHCi (perhaps use the forthcoming official Haskell logo here?). WinGhci icon is different (although quite similar) from GHCi icon, at least for medium to large icon sizes. Just my two cents for now -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 Furuike ya, kawazu tobikomu mizu no oto. -- Matsuo Basho^ ___ Haskell-Cafe mailing list Haskell Haskell-Cafe@haskell.org-c...@haskell.orgHaskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Haskell-Cafe@haskell.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Fwd: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows
2009/3/23 Andrew Butterfield andrew.butterfi...@cs.tcd.ie Benjamin L.Russell wrote: This is wonderful--just what I was waiting for! The application looks beautiful, and I'm very happy that GHCi now has a matching GUI application along the lines of WinHugs. Indeed - me too ! It would be even better if you could provide some installation/uninstallation information. I unzipped the contents of WinGhci-1.0-bin.zip into the C:\Documents and Settings\username\My Documents\ folder, but there was no README file. And version information - I tried it with GHC 6.4 and it died (Not Responding) What version of GHCi does it require? And no, I won't upgrade GHC just yet (this is the latest GHC/wxHaskell combo that works for me with GHCi...) I have tested it with GHC 6.10.1. The latest GHC version that I have currently installed is GHC 6.6, and it seems to work too. Do you have GHC bin directory on your path? -- Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 Foundations and Methods Research Group Director. School of Computer Science and Statistics, Room F.13, O'Reilly Institute, Trinity College, University of Dublin http://www.cs.tcd.ie/Andrew.Butterfield/ ___ 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: WinGhci, a GUI for GHCI on Windows
Hi, I am pleased to announce the first release of WinGhci. WinGhci is a simple GUI for GHCI on Windows. It is closely based on WinHugs, and provides similar functionality. WinGhci project web page: http://code.google.com/p/winghci/mhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://code.google.com/p/winghci/ Binaries: http://winghci.googlecode.com/files/WinGhci-1.0-bin.zipmhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://winghci.googlecode.com/files/WinGhci-1.0-bin.zip Sources: http://winghci.googlecode.com/files/WinGhci-1.0-src.zipmhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://winghci.googlecode.com/files/WinGhci-1.0-src.zip Acknowledgements Much of the code in WinGhci was taken from the Winhugs project. Many thanks to Neil Mitchell for giving us permission to use his code. mhtml:{5097F7F7-AA40-4661-A7CF-D5EEC38F084A}mid://0003/!x-usc:http://winghci.googlecode.com/files/WinGhci-1.0-bin.zip Pepe Gallardo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt
On 15/01/2009, at 23:27, Duncan Coutts wrote: On Thu, 2009-01-15 at 21:21 +, Andrew Coppin wrote: OK, well then my next question would be in what say is defining configuration files as a monoid superior to, uh, not defining them as a monoid? What does it allow you to do that you couldn't otherwise? I'm not seeing any obvious advantage, but you presumably did this for a reason... [ I know I'm repeating myself from elsewhere in this thread but this is the better question for the answer :-) ] By making a type an instance of Monoid instead of exporting emptyFoo, joinFoo functions it makes the API clearer because it shows that we are re-using an existing familiar concept rather than inventing a new one. It also means the user already knows that joinFoo must be associative and have unit emptyFoo without having to read the documentation. Perhaps it's what OO programmers would call a design pattern. Identify a pattern, give it a name and then when the pattern crops up again (and again) then the reader of the code will have an easier time because they are already familiar with that named pattern. Exactly, documenting knowledge was one of the benefits of design patterns. Monoid looks like the Composite pattern, one of the original GoF patterns. Is Composite is a better name for Monoid? I guess that when the GoF folks were writing the book they had to come up with quite a few names, and some came out better than others. If anything, the Haskell approach is more consistent. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Associative Commutative Unification
On Fri, Jul 11, 2008 at 2:39 PM, John D. Ramsdell [EMAIL PROTECTED] wrote: Are you aware of Term Rewriting and all That? It describes how to do associative commutative unification; whether it satisfies your 'obviously correct' criterion I don't know. Oh yes, I know about term rewriting. If your equations can be expressed as a set of confluent rewrite rules, one can use the Martelli and Montanari's formalization of unification to come up with an obviously correct equational unifier. Alas, that simple trick doesn't work for AC unification. Have you heard of Maude? I hear the next version will have support for AC unification. If I stay with Haskell, I'd have to use their support via interprocess communication. Yuck. http://maude.cs.uiuc.edu/ John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe You are surely aware that AC unification is much more difficult than syntactical unification. CIMe[1] might be useful to solve the generated diophantine equations. But I don't think you will be able to obtain obvious correctness, and probably performance neither. I don't know what you are planning to do, but perhaps you'd be better served by Maude than by Haskell. The Maude language is a joy to use and version 2.4 with AC unification is (expectedly) being released next week in RTA. Cheers pepe [1] - http://cime.lri.fr/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Shim: finding modules
On 16/04/2008, at 22:15, Graham Fawcett wrote: Hi folks, I'm a newbie, so please forgive any terminological mistakes. I've been using Shim in Emacs with great success, but there's one issue I've encountered, and I don't know if it's configuration problem or something fundamental. Consider a module 'App' and submodules 'App.Front' and 'App.Back'. When editing code in App that depends on the submodules, Shim works well at resolving the location of the submodules, and validates my code. But when editing App.Front, which depends on App.Back, Shim fails to validate -- my working directory is App.Front, and Shim doesn't seem able to find the location of App.Back. I'd like to be able to tell Shim that 'App' is the root of my project, and to locate modules from that root. Is this possible? Shim already does this. All it requires is that your project is a Cabal project. Shim will locate the Cabal descriptor and auto configure itself from there. Does that solve your problem ? Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] monadic debugging
On 16/04/2008, at 0:53, Galchin, Vasili wrote: Hello, I have an Linux executable of my Haskell library and test case. I see there are several debuggers, e.g. Buddha, Hat, etc. Which debugger is currently preferred for monadic (imperative) code? Thanks. Vasili For debugging IO code, I have used the GHCi debugger with great success in several occasions. Particularly, :steplocal is very useful in monadic code. Make sure you read at least the documentation in GHC docs, and the tutorial recently published in The Monad Reader. The latest version of the debugger in HEAD is extended to print the contents of IORefs automatically, which you may find useful too. Cheers, pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] retrospective on 'seq' - 'unsafeSeq' ?
On 14/04/2008, at 12:19, Simon Peyton-Jones wrote: | type constraints accordingly. (Analogously there could be an unsafeShow that | allows showing offending values in an 'error' without adding a Show | constraint to the type signature.) | | Ideally, unsafeShow could also show types as they are underneath, not | as a pretty-printing Show might show them. I have often wanted to | overload Show to print things in a readable way, but to have a showRaw | which shows things as they are, for debugging purposes. I have even | written such code for Yhc: | http://www.cs.york.ac.uk/fp/yhc/snapshot/docs/Yhc-Core-ShowRaw.html | | I think unsafeShow is a fantastic idea - and would be much more useful | to me than unsafeSeq - plus is a non-breaking change. I think Hugs | already has 90% of the code to support this, and GHCi's debugger I | think has a fair chunk of it, so it could be added given not too much | work. Yes, as you say, the debugger has most of the machinery. I just don't know what it'd take to make it a callable function. Pepe? Someone might want to make a feature-request ticket for this, with as much background and/or suggested design as poss. unsafeShow sounds quite useful, especially to avoid adding a Show constraint in function signatures only for debugging (of course a decent refactoring tool for Haskell would help with this too, so I hope the HaRe SoC project proposal gets accepted and done!). :print has the code for doing this, but it needs the type information collected by the compiler. In GHC API speak, it needs the HscEnv from the Session object. If we can expose the Session created for GHCi (how? exporting it from GHC.Main? in a thread-local object? FFI trickery?), then this would need nearly zero work, albeit it would print things only when working in GHCi of course. But you can still compile all your modules to object code and call main from GHCi, so I don't think this is a big restriction considering unsafeShow is only for debugging purposes. Another question is where in the package hierarchy would this function live. Since the code it would use is in the ghc package, it would introduce a dependency on it. And I am fairly sure that there is no package in the standard ghc distribution which depends on the ghc package. Ian, can it be made to live in ghc-prim without creating a dependency on the ghc package? Alternatively, with some effort one can create a type-agnostic version of unsafeShow, which would print things in a more raw format, but probably sufficient anyway. I don't think it would work with unboxed values in general, although it can be made to work with the standard types. Actually, Bernie Pope wrote some code for this [1, see GHC Heap Printing library] some time ago, although with the new primitives and changes made for :print in GHC 6.8, this would be way easier nowadays. No need to use StablePtrs, no need to turn on profiling, and above all, no C needed :) And as a bonus this would work out of GHCi too. If there is a clean way to access the Session object, the first option means less implementation work, less code to maintain in GHC, and better functionality. What does the GHC team think? [1] - http://www.cs.mu.oz.au/~bjpop/code.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] announce: Glome.hs raytracer
On 27/03/2008, at 3:49, Ian Lynagh wrote: On Wed, Mar 26, 2008 at 02:33:20PM -0700, Jim Snow wrote: -Memory consumption is atrocious: 146 megs to render a scene that's a 33k ascii file. Where does it all go? A heap profile reports the max heap size at a rather more reasonable 500k or so. (My architecture is 64 bit ubuntu on a dual-core amd.) I haven't looked properly yet, but it looks like something is leaking memory that shouldn't be. The attached Gloom.hs uses constant memory, but if you replace the map with the commented out (parMap rnf) then the memory use seems to keep increasing, even once it has run display once and is running it a second or third time. In my system the leak only appears with +RTS -N1 (which is the default). If I use -N2 or higher, then your version runs in constant memory with (parmap rnf). Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ST Monad - what's wrong?
The typechecker in 6.6.1 gets confused by the ($) and loses track of the 'freeness' of s (the thread variable) . The same code should work fine in 6.8.1, or alternatively in 6.6.1 without the ($). Cheers pepe On 09/12/2007, at 12:11, Nicu Ionita wrote: Hi, I'm trying to use the ST monad in order to turn an almost pure function into a pure one: reading a precalculated list of primes into a prime set. But the following code brings an error: primes :: Set Integer primes = runST $ getPrimes primes10h7.txt getPrimes :: String - (forall s. ST s (Set Integer)) getPrimes file = do cont - unsafeIOToST (readFile file) let set = fromList $ map read $ lines cont return set And here is the error: Couldn't match expected type `forall s. ST s a' against inferred type `ST s (Set Integer)' In the second argument of `($)', namely `getPrimes primes10h7.txt' In the expression: runST $ (getPrimes primes10h7.txt) In the definition of `primes': primes = runST $ (getPrimes primes10h7.txt) Compiled with GHC 6.6.1 with extensions activated. Nicu ___ 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] St. Petersburg Game
Hola Manolo, What you are trying to do is very easy in Haskell, but you'd better change the approach. In short, you are trying to use b as if it was a mutable variable, which it is not! One could rewrite your program using mutable variables, as below: import Data.IORef import Random import Control.Monad main1 = do b - newIORef 0 let loop = do c - randomRIO (1,2) unless (c == 1) (modifyIORef b increment loop) loop readIORef b Ugh, that's ugly (I have changed 'until' for 'unless', which is much more widely used). But as I said, this is not the right approach. What one would do in Haskell is to simply generate an infinite list of random numbers, and then operate on that, e.g. counting the number of consecutive heads of the coin. main2 = do gen - newStdGen let tosses = randomRs (1::Int,2) gen b = takeWhile ( /= 1) tosses return (length b) Hope that was of help. You can find more material on Haskell in the wiki :) http://haskell.org/haskellwiki/Learning_Haskell pepe otaku! PS: Puedo preguntarme qué hace este hombre aprendiendo Haskell? Viva! On 27/11/2007, at 14:27, [EMAIL PROTECTED] wrote: Hello, I'm trying to program an implementation of the St. Petersburg game in Haskell. There is a coin toss implied, and the random-number generation is driving me quite mad. So far, I've tried this: import Random increment :: Int - Int increment b = b + 1 main = do let b = 0 let c = randomRIO (1,2) until (c == 1) increment b return b This is intended to print the number of consecutive heads (i.e., 2) before the first tail, but I get the following error: ERROR StPetersburg.hs:8 - Type error in application *** Expression : until (c == 1) increment b *** Term : c == 1 *** Type : Bool *** Does not match : Int - Bool I don't really see what's going on, so any help will be more than welcome. I hope this is a suitable question for the Haskell Café list. I'm using Hugs in an Ubuntu box, in case that should be useful. Thanks, Manolo ___ 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] Embedding the GHC API
Austin Seipp has written about this in his blog: http://austin.youareinferior.net/?q=node/29 I will take this time to point out that using the GHC API in your applications results in *large* executables. The Interact example above when compiled with vanilla --make options resulted in a whopping 17mb executable. I've observed however you can mitigate this by an enormous amount using the tools strip and gzexe, taking it down to a light 2.5mb (a size reduction of about 85%) Cheers pepe On 31/10/2007, at 9:44, Joel Reymont wrote: Has anyone tried to embed GHC as a library recently? What is the size of the resulting binary? I'm assuming a bare minimum of needed libraries. Thanks, Joel -- http://wagerlabs.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] isWHNF :: a - IO Bool ?
Actually, in 6.8 we can build isWHNF on top of the GHC-API. First, you need to import the ghc package: ghci -package ghc GHCi, version 6.7: http://www.haskell.org/ghc/ :? for help Then, you can define the isWHNF function as follows: Prelude :m +RtClosureInspect Prelude RtClosureInspect let isWHNF = fmap (isConstr . tipe) . getClosureData Prelude RtClosureInspect :t isWHNF isWHNF :: a - IO Bool What the code above does is to inspect the info table associated to the value given, and check if the closure is a Constructor closure, i.e. in WHNF. We can put it to test now: Prelude RtClosureInspect let a = [1..10] Prelude RtClosureInspect isWHNF a False Prelude RtClosureInspect seq a () () Prelude RtClosureInspect isWHNF a True As a bonus because this code is included in GHC itself it should stay in sync with any changes in the GHC internal representations. Cheers pepe On 27/09/2007, at 14:51, Bernie Pope wrote: Hi Tristan, I've implemented it for earlier versions of GHC, by calling some C code which then peeps at the internal representation of a value. From memory, I needed to pass a stable pointer to the value to the C code, so that it can be polymorphic, without having to make it a primitive in GHC. Have a look at the reify code on this page: http:// www.cs.mu.oz.au/~bjpop/code.html - its more than what you want, but you can trim it down easily. Let me know if you get stuck. The internal representation in GHC tends to change between releases, so it might need a bit of polishing up. Cheers, Bernie. On 27/09/2007, at 10:07 PM, Tristan Allwood wrote: Hi, Does anyone know if there is a function that tells you if a haskell value has been forced or not? e.g. isWHNF :: a - IO Bool let x = (map succ [0..]) in do putStrLn . show (isWHNF x)-- False putStrLn . show . head $ x putStrLn . show (isWHNF x)-- True putStrLn . show (isWHNF (Just undefined)) -- True If not, would it be hard/easy/possible to implement on-top-of or using GHC? I'm happy (if it's possible) to have a stab at implementing it myself, so any pointers to right directions would be helpful. I'm thinking it could be useful to allow creation of sparse-check [1] like libraries without needing a separate logic encoding, or things along those lines / in that area. Cheers, Tris [1] http://www-users.cs.york.ac.uk/~mfn/sparsecheck/index.html#lim -- Tristan Allwood PhD Student Department of Computing Imperial College London ___ 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] isWHNF :: a - IO Bool ?
Very cool. This is much nicer than when I asked much the same question a few years back (and I can think of all sorts of interesting things I can learn from the interface in that module). But what about indirection chasing? Surely we want isWHNF to return True if we have an indirection to a WHNF. Possibly one wants something a bit like this (untested, and rather depends on GHC's indirection semantics): removingIndirections :: (forall c . c - IO b) - a - IO b removingIndirections k a = do closureData - getClosureData a if isConstr (tipe closureData) then removingIndirections (ptrs closureData ! 0) else k a simpleIsWHNF :: a - IO Boolean simpleIsWHNF = fmap (isConstr . tipe) . getClosureData isWHNF = removingIndirections simpleIsWHNF Very true, isWHNF needs to follow indirections indeed. To decide whether to recurse, you probably intended to test for Indirections and not for Constructors: removingIndirections :: (forall c . c - IO b) - a - IO b removingIndirections k a = do closureData - getClosureData a if isIndirection (tipe closureData) then removingIndirections (ptrs closureData ! 0) else k a Thanks, pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++
On 13/09/2007, at 0:06, Don Stewart wrote: ok: In Monad.Reader 8, Conrad Parker shows how to solve the Instant Insanity puzzle in the Haskell type system. Along the way he demonstrates very clearly something that was implicit in Mark Jones' Type Classes with Functional Dependencies paper if you read it very very carefully (which I hadn't, but on re-reading it is there). That is, Haskell types plus multiparameter type classes plus functional dependencies is a logic programming language. In fact it is a sufficiently powerful language to emulate any Turing machine calculation as a type checking problem. So we have C++ : imperative language whose type system is a Turing-complete functional language (with rather twisted syntax) Haskell: functional language whose type system is a Turing- complete logic programming language (with rather twisted syntax) Since not all Turing machines halt, and since the halting problem is undecidable, this means not only that some Haskell programs will make the type checker loop forever, but that there is no possible meta- checker that could warn us when that would happen. I've been told that functional dependencies are old hat and there is now something better. I suspect that better here means worse. Better here means better -- a functional language on the type system, to type a functional language on the value level. -- Don For a taste, see Instant Insanity transliterated in this functional language: http://hpaste.org/2689 NB: it took me 5 minutes, and that was my first piece of coding ever with Type families ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++
For a taste, see Instant Insanity transliterated in this functional language: http://hpaste.org/2689 I thought I'd better paste here the code for Instant Insanity with Type Families. Otherwise it will vanish in a short time. I took the opportunity to clean it up a bit. Although AT are not a supported feature, the code works in a 6.8.1 snapshot. But note that you cannot actually see the solution, as there is no way to ask GHCi to display the normalized types. My favorite bit is: * type instance Map f Nil = Nil * type instance Map f (x:::xs) = Apply f x ::: Map f xs \begin{code} import Prelude hiding (all, flip, map, filter) u = undefined data R -- Red data G -- Green data B -- Blue data W -- White data Cube u f r b l d type CubeRed = Cube R R R R R R type CubeBlue = Cube B B B B B B type Cube1 = Cube B G W G B R type Cube2 = Cube W G B W R R type Cube3 = Cube G W R B R R type Cube4 = Cube B R G G W W data True data False type family And b1 b2 type instance And True True = True type instance And True False= False type instance And False True = False type instance And False False= False data Nil data Cons x xs data x ::: xs infixr 5 ::: type family ListConcat l1 l2 type instance ListConcat Nil l = l type instance ListConcat (x:::xs) ys = x:::(ListConcat xs ys) type family Apply f a data Rotation data Twist data Flip type instance Apply Rotation (Cube u f r b l d) = Cube u r b l f d type instance Apply Twist(Cube u f r b l d) = Cube f r u l d b type instance Apply Flip (Cube u f r b l d) = Cube d l b r f u type family Map f xs type instance Map f Nil = Nil type instance Map f (x:::xs) = Apply f x ::: Map f xs type family Filter f xs type instance Filter f Nil = Nil type instance Filter f (x:::xs) = AppendIf (Apply f x) x (Filter f xs) type family AppendIf b x ys type instance AppendIf True x ys = x ::: ys type instance AppendIf False x ys = ys type family MapAppend f xs type instance MapAppend f Nil = Nil type instance MapAppend f (x:::xs) = ListConcat (x:::xs) (Map f (x:::xs)) type family MapAppend2 f xs type instance MapAppend2 f Nil = Nil type instance MapAppend2 f (x:::xs) = ListConcat (x:::xs) (MapAppend f (Map f (x:::xs))) type family MapAppend3 f xs type instance MapAppend3 f Nil = Nil type instance MapAppend3 f (x:::xs) = ListConcat xs (MapAppend2 f (Map f (x:::xs))) data Orientations type instance Apply Orientations c = MapAppend3 Rotation ( MapAppend2 Twist ( MapAppend Flip (c:::Nil))) type family NE x y type instance NE R R = False type instance NE R G = True type instance NE R B = True type instance NE R W = True type instance NE G R = True type instance NE G G = False type instance NE G B = True type instance NE G W = True type instance NE B R = True type instance NE B G = True type instance NE B B = False type instance NE B W = True type instance NE W R = True type instance NE W G = True type instance NE W B = True type instance NE W W = False type family All l type instance All Nil = True type instance All (False ::: xs) = False type instance All (True ::: xs) = All xs type family Compatible c1 c2 type instance Compatible (Cube u1 f1 r1 b1 l1 d1) (Cube u2 f2 r2 b2 l2 d2) = All (NE f1 f2 ::: NE r1 r2 ::: NE b1 b2 ::: NE l1 l2) type family Allowed c cs type instance Allowed c Nil = True type instance Allowed c (y ::: ys) = And (Compatible c y) (Allowed c ys) type family Solutions cs type instance Solutions Nil = (Nil ::: Nil) type instance Solutions (c ::: cs) = AllowedCombinations (Apply Orientations c) (Solutions cs) type family AllowedCombinations os sols type instance AllowedCombinations os Nil = Nil type instance AllowedCombinations os (s ::: sols) = ListConcat (AllowedCombinations os sols) (MatchingOrientations os s) type family MatchingOrientations os sol type instance MatchingOrientations Nil sol = Nil type instance MatchingOrientations (o ::: os) sol = AppendIf (Allowed o sol) (o:::sol) (MatchingOrientations os sol) type Cubes = (Cube1 ::: Cube2 ::: Cube3 ::: Cube4 ::: Nil) solution = u :: Solutions Cubes \end{code} ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Weird ghci behaviour?
I can give the following partial explanation. When you run ghc test.hs it compiles your test file and produces some auxiliar files at the same time. When you run ghci afterwards, if the mod. date of the auxiliar files is more recent than that of the source file, it directly loads the object code form of the source file. So it appears that ghci is having trouble when loading the object code version. Whereas if it's not, it loads the module interpreted. Of course, if you remove test.hi, ghci will always load the file interpreted, and so the problem doesn't manifest. Cheers pepe On 20/07/2007, at 23:12, Dan Piponi wrote: On Unix-like OSes: If I run ghc test.hs and then run ghci test.hs, ghci fails to load up my code. I have to touch test.hs and then run ghci. I can understand ghci refusing to recompile something it thinks it has already compiled. But it appears to refuse to load it into an interactive session - which is less useful. In fact, removing test.hi makes ghci work again. This is ghc 6.6. Anyone else seeing this? -- Dan ___ 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] Practical Haskell question.
There is a related discussion, with a lot of pointers, in a recent D.Piponi blog post: http://sigfpe.blogspot.com/2007/04/homeland-security-threat-level- monad.html On 25/06/2007, at 10:58, peterv wrote: I'm baffled. So using the Arrow abstraction (which I don't know yet) would solve this problem? How can (perfectActionB x) be checked with without ever executing performActionA which evaluates to x? This can only be done when x is a constant expression no? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tomasz Zielonka Sent: Monday, June 25, 2007 10:43 AM To: Henning Thielemann Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Practical Haskell question. On Mon, Jun 25, 2007 at 10:29:14AM +0200, Henning Thielemann wrote: Imagine all performActions contain their checks somehow. Let performActionB take an argument. do x - performActionA y - performActionB x z - performActionC return $ calculateStuff x y z Now performActionB and its included check depend on x. That is, the check relies formally on the result of performActionA and thus check B must be performed after performActionA. IIUC, this limitation of Monads was one of the reasons why John Hughes introduced the new Arrow abstraction. Best regards Tomek ___ 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] Shim missing Distribution.Verbosity
Thanks for the report. That was an error I introduced in a previous patch, just pushed the fix. By the way, there is a Shim mailing list at http://shim.haskellco.de Cheers pepe On 11/06/2007, at 9:22, Johan Grönqvist wrote: Hi, I am trying to install shim (http://shim.haskellco.de/trac/wiki) on windows XP (GHC 6.6.1). When I run ./Setup.lhs build, ghc tells me that the module Distribution.Verbosity can not be found. The module is imported by Shim.GhcCompat. ghcii also tells me that Distribution.Verbosity can not be found. When I look at http://www.haskell.org/ghc/docs/latest/html/ libraries/index.html, I do not see Distribution.Verbosity there either. I have no idea how to proceed. Thanks for any help, Johan ___ 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] Haskell on OS X
MacPorts works fine here, and the maintainer, Gregory Wright, is very supportive. If it works for you, I really recommend MacPorts. The only downside are the lengthy compile times, but this is not a big deal, you can just leave it installing overnight. Carbon Emacs flavour here instead of Aqua, but for no reason in particular. I sweeten it with Haskell mode + shim. On 19/05/2007, at 20:27, Tom Harper wrote: I use Aquamacs with the haskell mode from haskell.org. MacPorts wasn't being useful with ghc, I downloaded binaries, and they work fine. On 5/19/07, Johan Tibell [EMAIL PROTECTED] wrote: I just switched to OS X and was wondering if someone would like to share their setup. Install binaries from haskell.org or Mac Ports? Which emacs build? etc Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Tom Harper Computer Science Major '07 Syracuse University +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc ___ 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] Disadvantages of de Bruijn indicies?
On 13/05/2007, at 12:44, Neil Mitchell wrote: Hi Thanks for all the responses, I'm busy reading through them. I'm still trying to decide whether I should use them or not. They complicate things, are less intuitive than names. But on the other hand, the language I'm working in is untyped and has only letrec. These things make binding errors easier to occur, and harder to detect. Thanks for the helpful throughts, Neil The Calculus of Indexed Names and Named Indices (CINNI) [1] looks really neat: The Calculus of Indexed Names and Named Indices (CINNI) is a new calculus of explicit substitutions that combines names and indices in a uniform way. It contains the standard named notation used in logics and programming languages as well as de'Bruijn's indexed notation as sublanguages. Disclaimer: I haven't read the Epigram paper nor Berkling, so I don't know how it compares. And I can't really talk from my own experience, since I have not played myself with CINNI yet. I wish I had a build-a- language assignment, just so that I could put CINNI to work... [1] - http://formal.cs.uiuc.edu/stehr/cinni_eng.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parallel executing of actions
On 16/04/2007, at 12:30, Mitar wrote: Hi! On 4/16/07, Bertram Felgenhauer [EMAIL PROTECTED] wrote: Since all the threads block on a single MVar how do they run in parallel? The idea is that before the threads block on the MVar, they run their action x to completion. The rendering crashes. I will have to precompute the values in threads someway and then sequentially draw it? Any suggestion how to do that? Could it be that you are launching 400x300=120.000 new threads all at once? If you are not doing it already, it would be sensible to implement some pooling of threads. This is what I use myself, don't worry about the unsafeness IF you know that the sequence of computations doesn't matter: \begin{code} unsafeParMapM :: (a - IO b) - [a] - IO [b] unsafeParMapM f = return . parMap rwhnf (unsafePerformIO . f) unsafeParMapMn :: Integral bound = bound - (a - IO b) - [a] - IO [b] unsafeParMapMn max f xx = return (map (unsafePerformIO . f) xx `using` parListChunk (fromIntegral max) rwhnf) unsafeParSeqn :: Integral bound = bound - [IO a] - IO [a] unsafeParSeqn max cc = return ((map unsafePerformIO cc) `using` parListChunk (fromIntegral max) rwhnf) \begin{code} ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] MPTC and type classes issue (polymorphic '+')
input2 = [ InputDecs [ inp emaLength TyNumber (20 + 40) ] ] (untested). Imho the simple, dumb, best fix for this is to give a explicit type to those values. input2 = [ InputDecs [ inp emaLength TyNumber ((20::Integer) + (40::Integer)) ] ] This is just one way to fix it. You could also try to improve your instances or enable -foverlapping-instances. But in my experience MPTC and overlapping instances, though powerful, can become very confusing, very quickly. Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Binary I/O
On 02/04/2007, at 16:26, Daniel Brownridge wrote: Hello. I am a Computer Science student attempting to write an emulator using Haskell. One of my main design choices is how to deal with machine code. Clearly it is possible to represent 0's and 1's as ASCII characters, however it strikes me that it would be much nicer to the I/O using raw binary. I don't seem to be able to find much documentation on this. Does anybody know how it's done, or can point me in the direction of some resources. Imho, just read directly to an Array and work with that. Probably you want to look at the OmegaGB Gameboy Emulator project for examples. http://www.mutantlemon.com/omegagb The code for loading ROM images to an Array of Words: http://darcs.mutantlemon.com/omegagb/src/RomImage.hs After that, opcodes are easily parsed by pattern matching on the hexadecimal values, e.g. see the mcti function in the Cpu module: http://darcs.mutantlemon.com/omegagb/src/Cpu.hs It would be nicer to write a Data.Binary instance for the Instruction datatype and use that to do the parsing, but I don't think that loading ROM files is a major speed concern here. Another interesting resource you may want to look at for your emulator code can be ICFPC'06 Universal Machine implementations. Don Stewart has a page with a few highly performant implementations (and there are benchmarks too, yay!): http://www.cse.unsw.edu.au/~dons/um.html Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parallelism on concurrent?
On 13/03/2007, at 17:46, Jefferson Heard wrote: Simon will probably chime in on it as well, but his paper on the subject is the best there is: http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz It does work in GHC 6.6 very nicely. You can try it with the following naive fib function, extracted from the paper mentioned above: \begin{code} import Control.Parallel import System.Environment import Fib main = do (x:_) - getArgs print$ pfib (read x) pfib 0 = 1 pfib 1 = 1 pfib n = n1 `par` n2 `seq` n1+n2+1 where (n1,n2) = (pfib(n-1), pfib(n-2)) \end{code} pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded pep:~/code/snippets/Parallelism$ time src/Main 33 11405773 real0m1.444s user0m1.343s sys 0m0.020s pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2 11405773 real0m0.764s user0m1.367s sys 0m0.030s Got a speedup of 100%, and didn't use threads at all. Yay! pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parallelism on concurrent?
Excuse me, I read too quick. It works for forkIO too, although I'm not sure about forkOS. I don't have a demo around, but you can verify with the concurrency demos in the wiki: http://haskell.org/haskellwiki/Concurrency_demos/Zeta If it doesn't work, perhaps you are in an unsupported platform. Cheers pepe On 13/03/2007, at 18:10, Dusan Kolar wrote: Yes, it works for operator /par/. That's what I've reported. But should it work for forkIO and forkOS? Could anybody give more detailed answer than yes, no? :-) (Link to the Web is OK.) BTW, thanks for the link to the paper (moreover, I can see, that googling over haskell.org is not sufficient ;-) ). Regards, Dusan Pepe Iborra wrote: On 13/03/2007, at 17:46, Jefferson Heard wrote: Simon will probably chime in on it as well, but his paper on the subject is the best there is: http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz It does work in GHC 6.6 very nicely. You can try it with the following naive fib function, extracted from the paper mentioned above: \begin{code} import Control.Parallel import System.Environment import Fib main = do (x:_) - getArgs print$ pfib (read x) pfib 0 = 1 pfib 1 = 1 pfib n = n1 `par` n2 `seq` n1+n2+1 where (n1,n2) = (pfib(n-1), pfib(n-2)) \end{code} pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded pep:~/code/snippets/Parallelism$ time src/Main 33 11405773 real0m1.444s user0m1.343s sys 0m0.020s pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2 11405773 real0m0.764s user0m1.367s sys 0m0.030s Got a speedup of 100%, and didn't use threads at all. Yay! pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Dusan Kolartel: +420 54 114 1238 UIFS FIT VUT Brno fax: +420 54 114 1270 Bozetechova 2 e-mail: [EMAIL PROTECTED] Brno 612 66 Czech Republic -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: AT solution: rebinding = for restricted monads
Did anyone with knowledge of Associated Types pursue this solution? Where did you get this from. My haskell-cafe mail folder doesn't seem to have the thread you are replying to. Sorry I replied from gmane; I should have included a link to the original thread, but I really expected gmane to do that. The thread is at: http://www.haskell.org/pipermail/haskell-cafe/2006-December/020615.html It doesn't work with GHC head, and I can't really do anything about that. Mostly curiosity. The main reason this doesn't work with the head is because the implementation of associated type *synonyms* (as opposed to associated data types) is still incomplete. (See also http://haskell.org/haskellwiki/GHC/Indexed_types.) We are working at the implementation, but I just relocated from New York to Sydney, which is why not much happened in the last two months. But I also don't quite understand the intention of this code: I will try to fill in the details, but surely it is all expanded in the original thread. The idea is that we have an indexed/effectful monad where bind and return have a parameterized type: class WitnessMonad m where (=) :: m a b x - (x - m b c y) - m a c y return :: x - m a a x We can produce instances of WitnessMonad from an existing Monad using an adaptor newtype WitnessAdaptor m a b x = W {unW::m x} instance Monad m = WitnessMonad (WitnessAdaptor m) And rebind the do syntax to our WitnessMonad. But using vanilla Monads via this trick requires to lift and unlift every monadic action with the adaptor. An example in the IO monad: test1 :: IO String test1 = unW$ do msg - W getLine W$ putStrLn Thanks! return msg From here on the intent was on producing a solution using ATs that hides this explicit wrapping. I don't really know the details of the proposed solution. Thanks pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Safe lists with GADT's
I am really curious about this style of programming, and find myself playing with it from time to time. The example so far is very nice, but the funniest part is missing. That is, defining appendL. appendL :: List a t1 - List a t2 - List a t3 This says that the append of a list of length t1 and a list of length t2 is a list of whatever length t3 we want. Obviously this is not true and will not typecheck. After some healthy days of reading papers and theses, I've found at least three ways of defining it. First, via existentials: appendL1 :: List a t1 - List a t2 - exists t3. List a t3 Second, attaching a proof. Question: what would be the advantage of the proof here? data Add a b c where Base :: Add NilT a a ; Step :: Add a b c - Add (ConsT a) b (ConsT c) appendL2 :: List a t1 - List a t2 - exists t3. (Add t1 t2 t3, List a t3) Third, via Type Classes. \begin{code} class AddList a b c | a b - c where append :: List x a - List x b - List x c instance AddList NilT b b where append Nil x = x instance AddList a b c = AddList (ConsT a) b (ConsT c) where append (Cons x l) l' = Cons x (append l l') \end{code} Given the three methods, I wouldn't know which one should be preferred, and why. In the first one you pay the burden of programming with existentials. The second one in addition to that is the least efficient, as building the proof surely has a cost. Since we are building it, isn't there a way to use it to remove the existential? Finally, with the third one your compiler will produce error messages that will make you swear, apart from possible efficiency losses too. Thanks for reading, any hints will be appreciated pepe On 26/02/2007, at 15:26, David Roundy wrote: On Sun, Feb 25, 2007 at 10:40:13PM +, Neil Mitchell wrote: data ConsT a data NilT data List a t where Cons :: a - List a b - List a (ConsT b) Nil :: List a NilT ... Defining safeMap was trivial, but one thing I couldn't figure out was how to write something like fromList: fromList [] = Nil fromList (a:as) = Cons a (fromList as) fromList could obviously be anything such as reading from a file etc, where the input is not known in advance. Are there any techniques for this? My favorite ways to wrap an existential is with another GADT: data Existential a where Existential :: a b - a (Yes, properly speaking this isn't a GADT, just an existential ADT, but it's easier for me to understand this way.) Then fromList [] = Existential Nil fromList (a:as) = case fromList as of Existential as' - Existential (Cons a as') This is a pretty easy way to deal with the fromList. You'll now also want (which I don't think you mentioned in your example code) a GADT version of null, and perhaps other length operators: data NullT t where IsNull :: NullT NilT NotNull :: NullT (ConsT t) nullL :: List a t - NullT t so you can now actually use your head function on a dynamically generated list, by running something like (e.g. in a monad) do cs - readFile foo Existential cs' - return $ fromList cs -- note: we'll pattern-match fail on non-empty list here, which -- may not gain much, we'd use case statements in reality, or we'd -- catch failure within the monad, which is also safe-- provided you -- catch them, which the language doesn't force you to do! (Or if -- we're in a pure monad like Maybe.) NotNull - nullL cs' let c = headL cs' t = tailL cs' -- Now to illustrate the power of the GADT, a line that will fail -- at compile time: t' = tailL t return c -- David Roundy http://www.darcs.net ___ 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] Re: AT solution: rebinding = for restricted monads
David Roundy droundy at darcs.net writes: My latest attemp (which won't compile with the HEAD ghc that I just compiled, probably because I haven't figured out the synatax for guards with indexed types is: class WitnessMonad m where type W m :: * - * - * (=) :: (WitnessMonad m', WitnessMonad m'', w a b = W m', w b c = W m'', w a c = W m) = m' x - (x - m'' y) - m y () :: (WitnessMonad m', WitnessMonad m'', w a b = W m', w b c = W m'', w a c = W m) = m' x - m'' y - m y f g = f = const g return :: w a a = W m x = - m x fail :: String - m x data Witness a b instance Monad m = WitnessMonad m where W m = Witness () () (=) = Prelude.(=) () = Prelude.() return = Prelude.return fail = Prelude.fail which I think is quite pretty. It allows the Monadlike object to have kind * - *, while still allowing us to hide extra witness types inside and pull them out using the W function. Did anyone with knowledge of Associated Types pursue this solution? It doesn't work with GHC head, and I can't really do anything about that. Mostly curiosity. Thanks pepe Everything from here on is to convince GMane that, even if my message contains more quoted text than fresh text, it is a legitimate message and it should be ok to post it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for documentation on Control.Parallel.Strategies
There is also an excellent paper in tutorial style which imho is very useful to understand the interaction of lazyness with the Control.Parallel.Strategies combinators: Algorithm + Strategy = Parallelism Philip W. Trinder, Kevin Hammond, Hans-Wolfgang Loidl, and Simon L. Peyton Jones. Journal of Functional Programming, 8(1), Jan 1998. http://www.macs.hw.ac.uk/~dsg/gph/papers/abstracts/strategies.html On 16/02/2007, at 22:44, Jefferson Heard wrote: That's MUCH better, thanks. That's not what's directly available from haskell.org. It still doesn't give anything more general about using the combinators in actual programs, you know, like examples, but it's at least some clear documentation as to what each strategy does. Maybe one day, when I have a parallel program actually working, I could document that... On Friday 16 February 2007 16:26, Bjorn Bringert wrote: On Feb 16, 2007, at 21:16 , Jefferson Heard wrote: Is there anything that documents this further than the Haddock documentation available from Haskell.org or the GHC pages? I've gotten some basic parallelism to work using parMap and using || and |, but I had a fold and a map that I could logically compute at the same time. ... Maybe that's what you're looking at, but the darcs version has some more Haddock comments, see http://www.haskell.org/ghc/dist/current/ docs/libraries/base/Control-Parallel-Strategies.html /Björn ___ 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] Space Leak Help
hi Dominic Explicit recursion works just fine for me and keeps things simple: pad :: [Word8] - [Word8] pad xs = pad' xs 0 pad' (x:xs) l = x : pad' xs (succ l) pad' [] l = [0x80] ++ ps ++ lb where pl = (64-(l+9)) `mod` 64 ps = replicate pl 0x00 lb = i2osp 8 (8*l) at the cost of (very slightly) hiding data flow. Seems exactly what you were trying to avoid? Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ST and Transformers
Hi J Garrett, I don't see any problem in GHC 6.6. with: runTest c = runST (runErrorT c) *Main runTest (return True) Loading package mtl-1.0 ... linking ... done. Right True *Main On the other hand, I try to define it firstly as below and got the following error. runTest = runST . runErrorT Couldn't match expected type `forall t. Test t r' against inferred type `ErrorT e m a' Expected type: (forall t. Test t r) - forall s. ST s a1 Inferred type: ErrorT e m a - m (Either e a) In the second argument of `(.)', namely `runErrorT' In the expression: runST . runErrorT Rank-2 types seem to interact badly with (.) and ($), but my type theory educated neuron doesn't know why. I think this is folklore knowledge? Cheers pepe On 22/12/2006, at 18:26, J. Garrett Morris wrote: Hello everyone, I recently found myself attempting to use ST at the base of a stack of transformers, ala: type Test t r = ErrorT String (ST t) r I imagined, given the type of ST, that I would need a run function along the lines of: runTest :: (forall t. Test t r) - Either String r (which was, in fact, exactly what I wanted). Unfortunately, even with that type signature, I can't find a way to convince the compiler that the state thread is properly universal in the call to runST. Is it possible to write this function, or is ST (and other monads that use its style of threading) not transformable? Thanks, /g -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ 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] Composing monads (sort of)
Wait, there are two monads in scene here, IO and Maybe. The right solution is to compose them indeed. One could use the MaybeT monad transformer defined in the 'All about monads' tutorial [1], or we could just define the IOmaybe monad: import Data.Traversable (mapM) newtype IOMaybe a = IOM { iom :: IO (Maybe a) } instance Monad IOMaybe where return = IOM . return . Just c = f = IOM$ do mb_v - iom c mapM (iom.f) mb_v = return . join Now we can define: t1 = IOM . return . f1 t2 = IOM . f2 t3 = IOM . return . f3 traverse rec1 = t1 rec1 = t2 = t3 And this scheme lends itself very well to define any kind of traversal. Note that I used the more general version of mapM defined in Data.Traversable in the definition of the (=) combinator. A more conventional definition is given the 'All about monads' tutorial. Cheers pepe 1- http://www.nomaware.com/monads/html/index.html On 16/12/2006, at 15:35, Chris Eidhof wrote: Hey Mark, How can I concisely compose these functions without having to write a cascade of case statements such as: case f1 rec1 of Nothing - return Nothing Just id1 - do rec2 - f2 id2 return $ case rec2 of Nothing - return Nothing Just rec2' - case f3 rec2' of I understand that if I was just dealing with Maybe I could use the fact that Maybe is a monad. Yes, you can write like this: id2 - f1 rec1 rec2 - f2 id2 rec3 - f3 rec2 return rec3 or, even shorter: id2 - f1 rec1 rec2 - f2 id2 f3 rec2 The cool thing of the Maybe monad is that it combines a result in such a way that it removes the plumbing of constantly checking for Nothing. I can definitely recommand you the following tutorials: http://www.nomaware.com/monads/html/index.html http://uebb.cs.tu-berlin.de/~magr/pub/Transformers.en.html Those two tutorials really helped me. Good luck, Chris ___ 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] Refactoring recklessly
On 12/12/2006, at 20:31, Alec Berryman wrote: Greg Fitzgerald on 2006-12-12 11:24:58 -0800: I'd like to be able to reorganize my code and then verify that I didn't change any functionality. That is, the old and new code have precisely the same meaning. Also, I'd like to be able to change a function and verify that efficiency was the only thing affected. Are either of these possible in Haskell or any language? Use QuickCheck to generate parameters and compare return values for the old and the new functions. That is a great suggestion which works extremely well in my experience, but only for the second of Greg's requests. In the first case you don't need the additional validation, and probably you don't want to keep your unrefactored code around. ___ 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] Command line utility that shrinks/simplifies functions applications ?
On 30/11/2006, at 17:04, Spencer Janssen wrote: I believe you're talking about the `pl' plugin for lambdabot. Lambdabot has an offline mode, visit the homepage for the source: http://www.cse.unsw.edu.au/~dons/lambdabot.html There is also a web interface to lambdabot, but I can't seem to find the link. http://lambdabot.codersbase.com/ It's really nice, I use it all the time.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2
On 28/11/2006, at 12:25, Krasimir Angelov wrote: On 11/28/06, Johannes Waldmann [EMAIL PROTECTED] wrote: seriously, how hard would it be to adapt VH to Eclipse? the interfaces (for syntax highlighting, typechecking etc.) should be similar - in theory. Parsing and typechecking in VH is all done by GHC via the ghc-api. Thus strong interoperability support is needed. Ah, and about Eclipse. Visual Studio and Eclipse are very different platforms and you have to rewrite VSHaskell almost from scratch if you want an Eclipse port. Perhaps the only common parts will be Cabal GHC. Not only the interfaces are completely different, but an entirely new set of interoperability problems would need to be solved. The guys from EclipseFP have a document[1] about that topic. That said I would love being able to run an eclipsified VH in my Mac :) [1] - http://eclipsefp.sourceforge.net/haskell/ ExtendingEclipseInHaskell.pdf Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Debugging
Can you manage to compile GHC under Windows? Compiling GHC under Windows is known to be a bit tricky and time consuming, certainly not for the novice user, although the steps are well detailed in the GHC developer documentation. If so, I'd encourage you to play with the Ghci Debugger project. But beware, it is still in an experimental phase and there are some pending issues. If you want to try it I have set up the repository to point to the last good known version I have around. Just follow the instructions on how to get the patches in the wiki page. Otherwise, I'd advise you to stick to Debug.Trace and friends. Cheers pepe On 13/11/2006, at 17:29, Valentin Gjorgjioski wrote: On 13.11.2006 16:54 Valentin Gjorgjioski wrote: On 13.11.2006 16:48 Pepe Iborra wrote: Hi Valentin Please, take a look at the Haskell Wiki page for debugging. http://haskell.org/haskellwiki/Debugging You will find that thanks to Neil Mitchell there is a Windows version of Hat available. Perhaps you can add your experiences with it if it works for you. Oh silly me, I was looking that page, but I didn't notice this. Thanks a lot, pepe. I'll try, and I'll post feedback here. I install it, I tried it, and it doesn't work for me. ./Hat/DML.hs:535:66: Ambiguous type variable `a' in the constraint: `Integral a' arising from use of `*^' at ./Hat/DML.hs:535:66-69 Probable fix: add a type signature that fixes these type variable(s) And this is line 535 T.uapp2 p125v94v125v148 p125v147v125v147 p (+^) (*^) After that, I have in my code used operator ^, and I deleted that operator. Program finally compiled, but now, hat-observe reports me an error... this program has encountered a problem So, I will be really happy with something simple as Hugs.Observe if it works with floats. Some recommendation please? Valentin ___ 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] Sistema de Ecuaciones NO lineales
hi Sebastian I think that it would be more appropriate to use english when you post to this particular list. On non linear equations or jacobi, I'm sorry but I cannot help you. But hopefully someone else in this list may be able to. Saludos. Cheers. pepe. On 09/11/2006, at 4:52, Sebastian Gaviria wrote: hola como estan Quiero preguntar quien puede resolver el sistemas de ecuaciones NO lineales de Newton y el codigo de Jacobi en Haskell me ayudarian mucho al poder implementar ese codigo por Favor es con urgencia tener estos codigos!! muchas gracias !!! -- La sociedad debe juzgarse por su capacidad para hacer que la gente sea feliz. SEBASTIAN GAVIRIA J. INGENIERIA SISTEMAS UNIVERSIDAD EAFIT ___ 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] Howto Haskell in PocketPC?
This has been around for some time already. It used to work with PPC2003, hopefully it'll still do: http://www.comp.nus.edu.sg/~luzm/ppchugs/ Enjoy it :) On 14/10/2006, at 8:24, Iván Pérez Domínguez wrote: Hi. Here a simple question: Is there any haskell compiler/interpreter or similar for PocketPC? ___ 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] how do you debug programs?
On 07/09/2006, at 10:53, Tamas K Papp wrote: Dear Pepe, Thank you for the information. I finally ended up working with Debug.Trace, and found the bug very quickly. I also tried Hood, but couldn't load it in ghci: import Observe can't find the library, but % locate Observe /usr/lib/ghc-6.4.2/hslibs-imports/util/Observe.hi /usr/lib/ghc-6.4.2/hslibs-imports/util/Observe.p_hi /usr/lib/hugs/libraries/Hugs/Observe.hs /usr/lib/hugs/oldlib/Observe.hs Does importing from hslibs-imports require something special? Hi Tamas I'm glad to hear that you fixed it! GHC includes Observe (the hs-libs-imports file you are seeing) only in the hidden 'util' package, which I believe is deprecated or not present in 6.6. If you want to use it, launch ghci with the flag '- package util'. Or download Observe.hs from the Hood website and place it somewhere in the path. Hmm, it would be handy to have a Cabal Hood package... Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] how do you debug programs?
Hi Tamas There are several ways to debug a Haskell program. The most advanced ones are based in offline analysis of traces, I think Hat [1] is the most up-to-date tool for this. There is a Windows port of Hat at [5]. Another approach is to simply use Debug.Trace. A more powerful alternative for this approach is Hood [2]. Even if it hasn't been updated in some time, Hood works perfectly with the current ghc distribution. Even more, Hugs has it already integrated [3]. You can simply import Observe and use observations directly in your program. For instance: import Observe f' = observe f f f a b = And then in hugs the expression: f' 1 2 would output what you want. Finally, the GHCi debugger project [4] aims to bring dynamic breakpoints and intermediate values observation to GHCi in a near future. Right now the tool is only available from the site as a modified version of GHC, so unfortunately you will have to compile it yourself if you want to try it. Cheers pepe 1. www.haskell.org/hat 2. www.haskell.org/hood 3. http://cvs.haskell.org/Hugs/pages/users_guide/observe.html 4. http://haskell.org/haskellwiki/GHC/GHCiDebugger 5. http://www-users.cs.york.ac.uk/~ndm/projects/windows.php On 06/09/06, Tamas K Papp [EMAIL PROTECTED] wrote: Hi, I would like to learn a reasonable way (ie how others do it) to debug programs in Haskell. Is it possible to see what's going on when a function is evaluated? Eg in f a b = let c = a+b d = a*b in c+d evaluating f 1 2 would output something like f called with values 1 2 c is now (+) a b = (+) 1 2 = 3 d is now (*) a b = (*) 1 2 = 2 ... Or maybe I am thinking the wrong way, and functional programming has its own debugging style... Thanks, Tamas ___ 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] how do you debug programs?
Thanks for the suggestion Don, I started the wiki page at http://haskell.org/haskellwiki/Debugging On 06/09/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote: mnislaih: Hi Tamas There are several ways to debug a Haskell program. The most advanced ones are based in offline analysis of traces, I think Hat [1] is the most up-to-date tool for this. There is a Windows port of Hat at [5]. Another approach is to simply use Debug.Trace. A more powerful alternative for this approach is Hood [2]. Even if it hasn't been updated in some time, Hood works perfectly with the current ghc distribution. Even more, Hugs has it already integrated [3]. You can simply import Observe and use observations directly in your program. For instance: import Observe f' = observe f f f a b = And then in hugs the expression: f' 1 2 would output what you want. Finally, the GHCi debugger project [4] aims to bring dynamic breakpoints and intermediate values observation to GHCi in a near future. Right now the tool is only available from the site as a modified version of GHC, so unfortunately you will have to compile it yourself if you want to try it. Pepe, would you like to put up a page on the haskell.org wiki about debugging in Haskell? You could use the above mail as a start :) -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: how do you debug programs?
On 06/09/2006, at 17:10, Andrae Muys wrote:On 06/09/2006, at 8:22 PM, Neil Mitchell wrote:It's been my experience that debugging is a serious weakness ofHaskell - where even the poor mans printf debugging changes thesemantics! And everyone comes up with arguments why there is no needto debug a functional language - that sounds more like excuses aboutwhy we can't build a good lazy debugger :)[Sorry for the slight rant, but I've used Visual Studio C++ so I knowwhat a good debugger looks like, and how indispensable they are]I simply can't let this pass without comment. It's irrelevant if you're using a functional or imperative language, debuggers are invariably a waste of time. The only reason to use a debugger is because you need to inspect the contents of a processes address-space; so either you're using it as a disassembler, or you're using it to examine the consequences of heap/stack corruption. Consequently, if you're using Java, C#, Scheme, Haskell, Erlang, Smalltalk, or any one of a myriad of languages that don't permit direct memory access, there's no reason for you to be using a debugger.Jon understates it by implying this is a Functional/Haskell specific quality - it's not. Debuggers stopped being useful the day we finally delegated pointer handling to the compiler/vm author and got on with writing code that actually solves real problems.You seem to base everything on the assumption that a debugger is a program that lets you, and I quote your words below, "trace through individual lines of code".A debugger in the sense that this post regards it is any kind of program that helps you to understand a piece of code. A debugger is the program that tries to answer the following questions:"What information can we provide to the programmers about how a program is running?""What information will help the programmer most?"If it happens that traditionally debuggers are based in inspecting the memory, this is an unavoidable situation considering the history of programming languages. But certainly there are many other possibilities that can help a programmer to manage the complexity of a running program, and it seems as if you disregard them all completely in your argument !It's just that historically functional programmers have tended to already be experienced programmers who realise this. Why would they waste their time building a tool that no-one needs?This whole block is offensive to the rest of the world. Fortunately it has nothing to do with reality: - the recent GHC survey uncovered "some kind of debugger" as the most demanded tool - Other functional languages have seen magnificent efforts in the debugging camp, such as the awesome Ocaml debugger or the now sadly defunct ML Time-Travel debugger from A. Tolmach - The Lispish languages, which are arguably on the functional side too, have always enjoyed impressive online debugging tools.It's a truism to say if your code doesn't work it's because you don't understand it; clearly if you did understand it, you wouldn't have included the bug that's causing you difficulty.Therefore either1) The code is poorly structured and you need to restructure it to better represent your understanding of the problemor2) Your understanding of the problem is flawed, so you need to sit back and reexamine your thinking on this problem in light of the counter-example you have found (the bug).Spending your time tracing through individual lines of code is counter-productive in both cases.Andrae MuysP.S. It is worth noting that I am here talking about the sort of debugger raised in the original post. I am not talking about using a separate tool to extract a stracktrace from a core file in a C/C++ program or equivalent - I'm talking about runtime debugging with variable watches, breakpoints, and line-by-line stepping. -- Andrae Muys[EMAIL PROTECTED]Principal Kowari ConsultantNetymon Pty Ltd ___Haskell-Cafe mailing listHaskell-Cafe@haskell.orghttp://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] Why Haskell?
1) Lack of debugging support. Yes there are print statements and trace, but I would like to set a breakpoint. It would be nice to do so and launch the GHCi interpreter with all the variable context supported. A google search revealed that there is current work on this, but unfortunately the package is in cabal, which has spotty support in windows it seems. You can find more info about this project in the Haskell wiki at: http://haskell.org/haskellwiki/Ghci/Debugger All you'd need to do is to compile ghc-6.5 with a few patches (if you are in Windows you can use MinGW). But I am afraid you are right, this is a work in progress and we are in the process of polishing some serious issues right now. I can't really recommend it for now. Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] Why Haskell?
Bulat, now that Krasimir has resumed work on Visual Haskell, I have planned to pursue an integration of the ghc-api debugger with Visual Haskell as soon as possible. But as we get closer to having dynamic breakpoints working 100%, the plain ghci debugging support starts to look as a fairly nice addition to anyone's ghc toolkit. Of course, I agree with you that it's too early to recommend it for real work. On 23/07/06, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Pepe, Sunday, July 23, 2006, 5:23:18 PM, you wrote: 1) Lack of debugging support. Yes there are print statements and trace, You can find more info about this project in the Haskell wiki at: http://haskell.org/haskellwiki/Ghci/Debugger All you'd need to do is to compile ghc-6.5 with a few patches (if you are in Windows you can use MinGW). But I am afraid you are right, this is a work in progress and we are in the process of polishing some serious issues right now. I can't really recommend it for now. is this will be really usable without gui support? your project is really great, but i think it's too early to recommend it for real work (as opposite to hacking/integration with IDEs) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Google SoC
http://code.google.com/soc/ This is not news. SoC was presented a few days ago, and by now there are a lot of projects available, yet none(?) Haskell related :( This is a plea for Haskell FOSS project managers to apply as mentor organizations, so that we students can have a choice. Surely there are a lot of contributions that can be tackled by a motivated student in three months time. GHC related stuff, work in Visual Haskell, tasks in a given Haskell framework, Darcs stuff, you name it. Deadline for mentor organizations is May 1, but they might close it earlier if they get their hands full. pep ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: EclipseFP (Haskell IDE) 0.9.1 released
Graham Klyne [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] One of the features of Haskell that I like is that it doesn't require lots of IDE support to write complex programs... the compact syntax and clean separation of concerns that can be achieved make it iasy enough to program using nothing more than a regular text editor, and no long wait for the development environment to start up. I can imagine programming Haskell on a palm-top device. I do that on my PDA phone sometimes, usually when I'm having a coffee with some buddy discussing this or that algorithm :) Thanks to whoever ported Hugs for Windows CE (I don't remember the url now) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe