[GHC] #3115: mark ghc.cabal so that unsuspecting newbies don't try to edit it
#3115: mark ghc.cabal so that unsuspecting newbies don't try to edit it -+-- Reporter: nr| Owner: Type: feature request | Status: new Priority: normal| Component: Build System Version: 6.11 | Severity: minor Keywords:| Testcase: Os: Unknown/Multiple | Architecture: Unknown/Multiple -+-- Please change the configure/build system so that (a) ghc.cabal is not writable and (b) it contains a comment at the top saying that people wishing to add source files to the compiler should extend file ghc.cabal.in and re-run ../configure; they should ''not'' edit ghc.cabal directly. I know of two people who have fallen into this pit; let's not have any more. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3115 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #2812: For ghci, drop editline in favour of haskeline
#2812: For ghci, drop editline in favour of haskeline -+-- Reporter: igloo |Owner: Type: task | Status: new Priority: high |Milestone: 6.12 branch Component: GHCi | Version: 6.10.1 Severity: normal| Resolution: Keywords:| Difficulty: Unknown Testcase:| Os: Unknown/Multiple Architecture: Unknown/Multiple | -+-- Changes (by korpios): * cc: korp...@korpios.com (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2812#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
How do I add new dependencies and source files into the build system?
I have added a subdirectory named verify to the compiler directory, and made a change to simplCore to call functions from it. I have managed to get it to compile by editing ghc.cabal in the compiler directory (after some problems with cabal which are now sorted). But I think this is not the correct way to do it, as ./configure rebuilds this file, it seems. Where should I be doing this? -- Colin Adams Preston Lancashire ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: How do I add new dependencies and source files into the build system?
Donnie == Donnie Jones don...@darthik.com writes: Donnie Hello Colin, I believe you should edit Donnie compiler/ghc.cabal.in -- I believe this file is the input Donnie for cabal and used to create the ghc.cabal which gets Donnie re-created at ./configure. Donnie Also, you may want to look into Ways Donnie (compiler/main/StaticFlags.hs and mk/config.mk.in) if you Donnie plan on adding any compile-time (static) flags. Donnie Hope that helps. -- Donnie Jones Yes, thanks. -- Colin Adams Preston Lancashire ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
mkIfThenElse
This function has disappeard from CoreUtils in recent release(s). I am portfing some code which uses this function (just once). What should I be looking to use instead? -- Colin Adams Preston Lancashire ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: mkIfThenElse
It moved to MkCore: mkIfThenElse :: CoreExpr - CoreExpr - CoreExpr - CoreExpr mkIfThenElse guard then_expr else_expr -- Not going to be refining, so okay to take the type of the then clause = mkWildCase guard boolTy (exprType then_expr) [ (DataAlt falseDataCon, [], else_expr), -- Increasing order of tag! (DataAlt trueDataCon, [], then_expr) ] Cheers, Max 2009/3/22 Colin Paul Adams co...@colina.demon.co.uk: This function has disappeard from CoreUtils in recent release(s). I am portfing some code which uses this function (just once). What should I be looking to use instead? -- Colin Adams Preston Lancashire ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: mkIfThenElse
Max == Max Bolingbroke batterseapo...@hotmail.com writes: Max It moved to MkCore Thanks. What about mkWildId from Id.lhs? That one seems to have vanished. -- Colin Adams Preston Lancashire ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: mkIfThenElse
2009/3/22 Colin Paul Adams co...@colina.demon.co.uk: Max == Max Bolingbroke batterseapo...@hotmail.com writes: Max It moved to MkCore Thanks. What about mkWildId from Id.lhs? That one seems to have vanished. Looks that might be the same deal (moved to MkCore), assuming this is what you wanted: -- | Make a /wildcard binder/. This is typically used when you need a binder -- that you expect to use only at a *binding* site. Do not use it at -- occurrence sites because it has a single, fixed unique, and it's very -- easy to get into difficulties with shadowing. That's why it is used so little. mkWildBinder :: Type - Id mkWildBinder ty = mkSysLocal (fsLit wild) (mkBuiltinUnique 1) ty Cheers, Max ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] ANNOUNCE: jhc 0.6.0 Haskell Compiler
On Sat, Mar 21, 2009 at 10:00:33AM -0700, Don Stewart wrote: john: Hi, I am pleased to announce jhc 0.6.0, It has been a long time since an official release, so there have been a lot of changes. Jhc is an optimizing haskell compiler that focuses on creating fast and portable code. Jhc is still mainly of interest to jhc hackers and developers than the general haskell public, but it is starting to see use in embedded development with haskell so I decided to make more public announcements of major releases in the future. Hey John, I get the following build error: /usr/bin/ghc -fbang-patterns -O -ignore-package lang -W -fno-warn-unused-matches -fwarn-type-defaults -i -i./drift_processed -i./. -i. -odir . -hidir . -package mtl -package unix -ignore-package lang -package utf8-string -package binary -package zlib -fallow-undecidable-instances -fglasgow-exts -fallow-overlapping-instances --make Main.hs StringTable/StringTable_cbits.o cbits/md5sum.o -o jhc on the commandline: Warning: -fbang-patterns is deprecated: use -XBangPatterns or pragma {-# LANGUAGE BangPatterns#-} instead on the commandline: Warning: -fallow-undecidable-instances is deprecated: use -XUndecidableInstances or pragma {-# LANGUAGE UndecidableInstances#-} instead on the commandline: Warning: -fallow-overlapping-instances is deprecated: use -XOverlappingInstances or pragma {-# LANGUAGE OverlappingInstances#-} instead Util/Gen.hs:6:7: Could not find module `Control.Monad.Identity': it was found in multiple packages: transformers-0.1.1.0 mtl-1.1.0.2 make[1]: *** [jhc] Error 1 I *think* you have to -hide-all-packages then enable the ones you want one-by-one (check whatever commandline cabal emits here). Hmm... what version of ghc are you using? I tested against ghc 6.8 since that is all I have available on my machines so it is possible the bugs are because you are using ghc 6.10. If the -hide-all-packages trick works for 6.8 too then I will do that always. I dropped 6.6 compatability at some point, but want to keep 6.8 in addition to 6.10 since that is among other things what amazon ec2 instances come with (since they are based on fedora core 8). Man. those high CPU ec2 instances are great for plowing through regression tests. :) John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [jhc] Re: [Haskell] ANNOUNCE: jhc 0.6.0 Haskell Compiler
On Thu, Mar 19, 2009 at 03:22:33PM +0100, Alberto G. Corona wrote: The last version still uses a region inference algoritm instead of a garbage collector?. It turns out the choice of garbage collector is fairly independent of the rest of the compiler, so there is a flag to decide on what garbage collector to use (or none). Right now, however, there isn't really a universally good choice, the boehm gc will work, but it is quite slow. I am working on a middle of the road solution between full static analysis and garbage collection based on the mercury garbage collector for compilation to C, but of course, when compiling to something like llvm or C--, a different garbage collector might be in order. So, It is likely jhc will have multiple choices when it comes to garbage collection for a while until an obviously correct answer emerges. In the meantime, improving the static analysis (such as full region inference will do) helps all back ends so I will likely spend some time focusing on that. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Google Summer of Code: Is this idea useful for the community?
The main thing about reddit is the community, not the underlying code, and while I'm sure a SoC project could do something with the code, I don't see how you could build such a community. And if you did build a big community, then I think it would spiral out of control with only a summers work to do it. One related idea that might be more useful is a Content Management System on top of happstack. Most other languages have these kind of things, and you could certain give features to your CMS that makes it a reddit-a-like with certain configurations, without loosing the CMS bits for everyone else. You could then as an example host a haskell-redit-a-like, but it wouldn't be the main focus. Thanks Neil On Sat, Mar 21, 2009 at 10:50 PM, fallintothis fall.into.t...@gmail.com wrote: I'm planning on applying for the Google Summer of Code and the more I think about it, the more excited I am over a Haskell reddit-alike[1]. I'm interested in web programming, Haskell, and reddit (being an addict for some years now). There's plenty of work to be done on such a project, there are existing code bases to help along with ideas, and it doesn't require the deepest knowledge of Haskell or, say, GHC's guts (not that I don't find those interesting, I'm just no expert). The hang-up I see is that there's not too much of an immediate community benefit if reddit already exists (which, I have on good authority, it does), other than in the interest of eating (or customizing) your own dog food. Any members of the Haskell community (more involved than I am) care to comment? Would the project be useful or otherwise good as a Summer of Code idea? If people don't get too sick of my pestering, I'm also considering opening it up as a ticket on the trac to see if it gets feedback there. Thanks! [1] http://www.reddit.com/r/haskell_proposals/comments/7u48x/a_simple_redditlike_happsbased_proposal_voting/ ___ 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] SoC idea: interactive profiling
Hello all, I entered a little proposal in the issue tracker: http://hackage.haskell.org/trac/summer-of-code/ticket/1570 As I see it, the graphical part could be a warm-up exercise with an already useful product, and interaction with the rts would be the actual challenge. Reasoning about laziness is far from trivial (at least I often feel lost when trying to grok all the interaction within Reactive ;), and being able to browse profiler output on the spot is something I felt the need for a few times already. Eventually, this could be a contribution to an IDE project, even though it could as well remain a standalone application for all the emacs/vi folk. Profiling tools for parallel programs are in the make already, but I haven't seen anything more convenient than hp2ps and little add hoc solutions for analysing resource usage patterns. How do you all go about profiling? Gergely -- http://www.fastmail.fm - Does exactly what it says on the tin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
OK, I got it installed, but build warned me of duplicate dylibs, and running my program gave a bus error. So I port uninstalled gtk2, so now it compiled without warnings, but the program won't run because I had been forced to uninstall pangoft to uninstall gtk2. So now I need to uninstall the gtk framework - how do I do that? Then i can re-install the macports version and have a working system again. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
On 22 Mar 2009, at 10:28, Colin Adams wrote: OK, I got it installed, but build warned me of duplicate dylibs, and running my program gave a bus error. So I port uninstalled gtk2, so now it compiled without warnings, but the program won't run because I had been forced to uninstall pangoft to uninstall gtk2. So now I need to uninstall the gtk framework - how do I do that? Then i can re-install the macports version and have a working system again. You might move it out of the way: sudo mv /opt /opt1 and then move it back. To get rid of ports altogether, sudo rm -rf /opt (But be careful so you type right when removing as root, as errors can screw up the whole installation.) I looked up my records - I compiled gtk2hs, and as was remarked, the one in MacPorts (but not gtk2 alone) insists on installing its own GHC. When taking down the sources (external to MacPorts) of gtk2hs, the .tgz ones worked, but the sources from the archive caused some problems with autoconf - despite intense discussions also on the gtk2hs list, this problem was left unresolved. The libraries might cause problems when compiling, because even if a libpath is included in the compile, if there are system ones available, then may be used - a GCC quirk. So in such cases, one might have to edit the libpath so that the system libraries are not at all there, moving selected one out of the way, using libtools or something. This is very technical, though. Hans Aberg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Completely confused by cabal
[co...@susannah ghc]$ ghc-pkg list /usr/local/lib/ghc-6.11.20090319/./package.conf: Cabal-1.7.0, array-0.2.0.1, base-3.0.3.0, base-4.0.0.0, bytestring-0.9.1.4, containers-0.2.0.1, directory-1.0.0.2, (dph-base-0.4.0), (dph-par-0.4.0), (dph-prim-interface-0.4.0), (dph-prim-par-0.4.0), (dph-prim-seq-0.4.0), (dph-seq-0.4.0), editline-0.2.1.0, ffi-1.0, filepath-1.1.0.1, gconf-0.10.0, (ghc-6.11.20090319), ghc-prim-0.1.0.0, gio-0.10.0, glib-0.10.0, haskell98-1.0.1.0, hpc-0.5.0.2, integer-0.1.0.0, old-locale-1.0.0.1, old-time-1.0.0.1, packedstring-0.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, rts-1.0, syb-0.1.0.0, template-haskell-2.3.0.0, unix-2.3.1.0 /home/colin/.ghc/x86_64-linux-6.11.20090319/package.conf: EdisonAPI-1.2.1, EdisonCore-1.2.1.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, cairo-0.10.0, game-tree-0.1.0.0, gconf-0.10.0, gio-0.10.0, glade-0.10.0, glib-0.10.0, gnomevfs-0.10.0, gstreamer-0.10.0, gtk-0.10.0, gtkglext-0.10.0, mozembed-0.10.0, mtl-1.1.0.2, parallel-1.1.0.0, parsec-2.1.0.1, parsec-3.0.0, soegtk-0.10.0, sourceview-0.10.0, svgcairo-0.10.0, time-1.1.2.3 [co...@susannah ghc]$ su -c 'cabal install parsec --global' Password: Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal update' to download it. cabal: There is no package named parsec [co...@susannah ghc]$ su -c 'cabal install parsec-2.0.0 --global' Password: Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal update' to download it. cabal: There is no package named parsec [co...@susannah ghc]$ cabal update Downloading the latest package list from hackage.haskell.org [co...@susannah ghc]$ su -c 'cabal install parsec-2.0.0 --global' Password: Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal update' to download it. cabal: There is no package named parsec [co...@susannah ghc]$ cabal update --global unrecognized option `--global' Why does cabal install nearly everything in the user repository rather than the global repository? -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
I tried issuing the sudo port install command on the wiki page. After some time running it failed with: To fully complete your installation and make python 2.5 the default, please run sudo port install python_select sudo python_select python25 --- Cleaning python25 --- Fetching py25-hashlib --- Attempting to fetch Python-2.5.2.tar.bz2 from http://www.python.org/ftp/python/2.5.2/ --- Verifying checksum(s) for py25-hashlib --- Extracting py25-hashlib --- Configuring py25-hashlib --- Building py25-hashlib with target build Error: Target org.macports.build returned: shell command cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py25-hashlib/work/Python-2.5.2/Modules /opt/local/bin/python2.5 setup.py build returned error 1 Command output: running build running build_ext building '_hashlib' extension creating build creating build/temp.macosx-10.3-i386-2.5 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o unable to execute -DNDEBUG: No such file or directory error: command '-DNDEBUG' failed with exit status 1 Error: The following dependencies failed to build: gtk-doc gnome-doc-utils iso-codes py25-hashlib libxslt py25-gobject py25-libxml2 py25-numeric rarian getopt gtk2 cairo jasper pango hicolor-icon-theme libgnomeui gnome-icon-theme icon-naming-utils p5-xml-simple p5-xml-namespacesupport p5-xml-sax gnome-keyring autoconf help2man p5-locale-gettext m4 gconf libgcrypt libgpg-error libtasn1 libbonoboui gnome-vfs libglade2 libgnome esound libgnomecanvas Error: Status 1 encountered during processing. Which is singularly uninformative to me. It looks like I am not going to be able to do any haskell programming next week when I am away with only a macbook. 2009/3/22 Hans Aberg hab...@math.su.se: On 22 Mar 2009, at 10:28, Colin Adams wrote: OK, I got it installed, but build warned me of duplicate dylibs, and running my program gave a bus error. So I port uninstalled gtk2, so now it compiled without warnings, but the program won't run because I had been forced to uninstall pangoft to uninstall gtk2. So now I need to uninstall the gtk framework - how do I do that? Then i can re-install the macports version and have a working system again. You might move it out of the way: sudo mv /opt /opt1 and then move it back. To get rid of ports altogether, sudo rm -rf /opt (But be careful so you type right when removing as root, as errors can screw up the whole installation.) I looked up my records - I compiled gtk2hs, and as was remarked, the one in MacPorts (but not gtk2 alone) insists on installing its own GHC. When taking down the sources (external to MacPorts) of gtk2hs, the .tgz ones worked, but the sources from the archive caused some problems with autoconf - despite intense discussions also on the gtk2hs list, this problem was left unresolved. The libraries might cause problems when compiling, because even if a libpath is included in the compile, if there are system ones available, then may be used - a GCC quirk. So in such cases, one might have to edit the libpath so that the system libraries are not at all there, moving selected one out of the way, using libtools or something. This is very technical, though. Hans Aberg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
Achim == Achim Schneider bars...@web.de writes: Achim Colin Paul Adams co...@colina.demon.co.uk wrote: Why does cabal install nearly everything in the user repository rather than the global repository? Achim uh... because you're a mere user and don't have the rights to do so? No, I own the machine. Achim try su -, then cabal update to fill root's $HOME/.cabal Achim with the needed info, then proceed as usual. Achim TBH, though, I wouldn't use cabal as root, directly, use Achim your distro's package management system instead. Installing I can't. It doesn't provide up-to-date ghc and things. Achim programs with your user account, inside your home Achim directory, is perfectly acceptable (and traditional) under Achim unix. But it means I have to install everyhting twice - once as --user, once as --global. -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Ease of Haskell development on OS X?
Colin Adams colinpaulad...@googlemail.com wrote: -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o unable to execute -DNDEBUG: No such file or directory That's just flags, preceded by no command (or, rather, -DNDEBUG is interpreted as a command, which doesn't make much sense). My crystal ball says that the build script is dodgy and just tries to execute $(CC) or something, which isn't set. You can investigate the script and fix it, or complain with the python (or macports, whatever is appropriate) guys. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: A guess on stack-overflows - thunksbuild-upandtail recursion
I just found out about GHood through this thread, and since it impressed me very much to see something so cool, I feel bad making this comment... but I am always disturbed by the flickering effect produced by java applets in my browser (FF 3.0) while scrolling. From an implementation standpoint this is obviously a nitpick, but from a designer standpoint it nearly single-handedly kills any prospect of my putting it up on a page. No problem, but thanks for qualifying the criticism!-) I notice little of that in Opera, but generally, yes, Java is a bit heavyweight for the job. But it got the job done when alternatives were few and still does until someone provides a lightweight viewer. Here are a couple more examples, from this thread and from the recent Safe Lazy IO announcement, for those who have just found out about GHood and are following this thread: 1. chaining readFile In http://www.haskell.org/pipermail/haskell-cafe/2009-March/058205.html , the motivating example of countLines is used. GHood can't observe when file handles are closed (that would have needed reliable Haskell finalizers, the lack of which led to me abandoning further development of GHood), but if we optimistically assume that file handles are closed when the file contents have been observed in full, to the closing [], we can observe the other relevant aspects of the discussion. import Debug.Observe import System.Environment readFileO f = observe (readFile ++f) readFile f countLines1 = runO $ print . observe length length . lines . concat = mapM readFileO = getArgs countLines2 = runO $ print . observe sum sum = mapM (fmap (length . lines) . readFileO) = getArgs countLines3 = runO $ print . observe sum sum = mapM (((return$!) . length . lines =) . readFileO) = getArgs The animations for these instrumented versions should be fairly self-explanatory if you stare at them long enough:-) Compare, eg, ghc -e ':set args a b' -e countLines2 RF ghc -e ':set args a b' -e countLines3 RF with a couple of _small_ input files (since we do not depend on running out of handles to observe the effects we're interested in, two files are sufficient, and large input files would only obscure the animation): $ cat a b a1 a2 a3 b1 b2 b3 2. tail recursion and strictness, if an external data structure is in the way Taking Data.IntMap as an example, because it tends to come up often, the first problem we run into is defining an instance of Observable. That is usually straightforward boilerplate code, but IntMap's representation is not exported, so we have to make do with an abstract observer: import qualified Data.IntMap as IM import Debug.Observe import Data.List instance Observable a = Observable (IM.IntMap a) where observer im = send IntMap (return IM.fromList IM.toList im) Now, the problem at hand is that while IntMap is strict in its structure and keys, it isn't strict in its values, so if we just wrap the usual strict foldl' around Data.IntMap.insert, we do not get the intended effect (assuming here that the intention was to evaluate all parts of the IntMaps). The standard workaround for IntMaps is to hook the evaluation of the values to some part of the data structure that is certain to be evaluated, in this case the keys. Then the construction of the IntMap forces the keys, which forces the values. This can be observed in the animations for these two variants: f k = 2*k version1 = runO $ print $ observe foldl' foldl' (\m (k,v)-IM.insert k v m) IM.empty $ [(i,observe f f i)|i-[1,2]] version2 = runO $ print $ observe foldl' foldl' (\m (k,v)-(IM.insert k $! v) m) IM.empty $ [(i,observe f f i)|i-[1,2]] Observations of higher-order functions take some getting used to, so have a look at event 97/130 for version1 to get your bearings before diving into the details of the animation (you might want to enlarge the window or scale down the visualization). The observation of foldl' reveals a function that takes a function as first parameter, an empty IntMap as second parameter, and a two-element list as a third parameter, producing a two-element IntMap as its result. The first parameter of foldl' is a function (the lambda abstraction with IM.insert in the code) that has been called two times at this stage (two children of one FUN node), once to map an empty IntMap and a pair to a one-element IntMap, and a second time to map the one-element IntMap and a pair to a two-element IntMap. At this point, the IntMaps and their keys have been evaluated, but none of their values have. In fact, the function computing the values, f, has not been called once. That is all going to happen now, as printing the result forces the values. One can almost see the chains of demand in the animation, as thunks (red) get inspected (yellow), leading to further inspection elsewhere, leading to results (black) elsewhere, leading to results replacing the original thunks. It is this feel for the dynamics of
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
On 22 Mar 2009, at 11:32, Colin Adams wrote: creating build/temp.macosx-10.3-i386-2.5 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o unable to execute -DNDEBUG: No such file or directory error: command '-DNDEBUG' failed with exit status 1 A search on the Apple site says it is a compile option used to remove assert(): http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/assert.3.html The first line mentions macosx-10.3 - do you have a compiler for an old system, or something? And I have a fairly recent python: $ python --version Python 2.5.1 $ which python /usr/bin/python Make sure to sign up (for free) as a developer at developer.apple.com and take down latest Xcode (mine is Version 3.1.2, though I do not know if it is the absolutely latest). Hans Aberg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Completely confused by cabal
Colin Paul Adams co...@colina.demon.co.uk wrote: Why does cabal install nearly everything in the user repository rather than the global repository? uh... because you're a mere user and don't have the rights to do so? try su -, then cabal update to fill root's $HOME/.cabal with the needed info, then proceed as usual. TBH, though, I wouldn't use cabal as root, directly, use your distro's package management system instead. Installing programs with your user account, inside your home directory, is perfectly acceptable (and traditional) under unix. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Completely confused by cabal
Colin Paul Adams co...@colina.demon.co.uk wrote: Achim uh... because you're a mere user and don't have the rights Achim to do so? No, I own the machine. Well, but it neither knows nor cares, unless you log in as root. colin isn't allowed to write to /usr/local/lib/ghc-6.11.20090319/ . root's and colin's home directories are distinct, as well, that's why both need to do cabal update to install stuff: Users can't read root (or any other user's) home directories; root could read colin's home directory, but musn't trust any data in it, as colin could use that trust to weasel root access. I can't. It doesn't provide up-to-date ghc and things. insert snappy switch-to-gentoo comment here Achim programs with your user account, inside your home Achim directory, is perfectly acceptable (and traditional) under Achim unix. But it means I have to install everyhting twice - once as --user, once as --global. No, you don't, the database ghc uses to compile stuff is a union of both databases, user installs overriding global installs. Assuming that you're the machine's only user, you only ever need to install stuff as that user: k...@solaris ~ % ghc-pkg list /usr/lib64/ghc-6.10.1/./package.conf: Cabal-1.6.0.1, HTTP-3001.1.4, QuickCheck-1.2.0.0, QuickCheck-2.1.0.1, X11-1.4.4, X11-xft-0.3, array-0.2.0.0, base-3.0.3.0, base-4.0.0.0, binary-0.4.4, bytestring-0.9.1.4, cairo-0.10.0, containers-0.2.0.0, directory-1.0.0.2, editline-0.2.1.0, filepath-1.1.0.0, filepath-1.1.0.1, gconf-0.10.0, (ghc-6.10.1), ghc-paths-0.1.0.5, ghc-prim-0.1.0.0, glade-0.10.0, glib-0.10.0, gtk-0.10.0, gtkglext-0.10.0, gtksourceview2-0.10.0, haddock-2.4.1, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.2, html-1.0.1.2, integer-0.1.0.0, mozembed-0.10.0, mtl-1.1.0.2, network-2.2.0.1, old-locale-1.0.0.1, old-time-1.0.0.1, packedstring-0.1.0.1, parsec-3.0.0, pretty-1.0.1.0, process-1.0.1.0, random-1.0.0.1, readline-1.0.1.0, regex-base-0.93.1, regex-compat-0.92, regex-posix-0.93.2, rts-1.0, soegtk-0.10.0, stm-2.1.1.2, svgcairo-0.10.0, syb-0.1.0.0, template-haskell-2.3.0.0, unix-2.3.1.0, utf8-string-0.3.3, zlib-0.5.0.0 /home/ksf/.ghc/x86_64-linux-6.10.1/package.conf: MemoTrie-0.4.3, bytestring-mmap-0.2.0, bytestring-trie-0.1.4, extensible-exceptions-0.1.1.0, ipprint-0.3, iteratee-0.1.1, mmap-0.2, regex-posix-0.72.0.3 I basically did emerge cabal-install to bootstrap my installation, then emerge gtk2hs as it's not available via hackage. Then, I install what I need to hack as user using cabal install. (I recently nuked my ~/.cabal and ~/.ghc, that's why the user database is that small). Installing ghc as user works equally well. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
So why doesn't it find packages then, when they are installed? -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
No. It's all recent. 2009/3/22 Hans Aberg hab...@math.su.se: On 22 Mar 2009, at 11:32, Colin Adams wrote: creating build/temp.macosx-10.3-i386-2.5 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o unable to execute -DNDEBUG: No such file or directory error: command '-DNDEBUG' failed with exit status 1 A search on the Apple site says it is a compile option used to remove assert(): http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/assert.3.html The first line mentions macosx-10.3 - do you have a compiler for an old system, or something? And I have a fairly recent python: $ python --version Python 2.5.1 $ which python /usr/bin/python Make sure to sign up (for free) as a developer at developer.apple.com and take down latest Xcode (mine is Version 3.1.2, though I do not know if it is the absolutely latest). Hans Aberg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Completely confused by cabal
Colin Paul Adams co...@colina.demon.co.uk wrote: So why doesn't it find packages then, when they are installed? I've got no idea, what exactly are you trying to do, and how? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
Achim == Achim Schneider bars...@web.de writes: Achim Colin Paul Adams co...@colina.demon.co.uk wrote: So why doesn't it find packages then, when they are installed? Achim I've got no idea, what exactly are you trying to do, and Achim how? I'm trying to re-compile ghc 6.11 and it doesn't find parsec. -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
On Sun, Mar 22, 2009 at 12:51 PM, Colin Paul Adams co...@colina.demon.co.uk wrote: Achim == Achim Schneider bars...@web.de writes: Achim Colin Paul Adams co...@colina.demon.co.uk wrote: So why doesn't it find packages then, when they are installed? Achim I've got no idea, what exactly are you trying to do, and Achim how? I'm trying to re-compile ghc 6.11 and it doesn't find parsec. when cabal is invoked by root, like in su -c cabal ... or su -c runghc Setup ..., it won't see the user packagedb, but there's rarely a reason to do so. Usually only the install phase needs to be done as root, while building and configuring can be done as user. For ghc you'd want to run ./configure and make as user and make install as root. For normal packages, if you want to install them system wide, you'd use something like cabal install --global --root-cmd=sudo foo You can make those flags the default with user-install: False root-cmd: sudo in ~/.cabal/config If you still have problems it'd be interesting to see what are the initial commands that were failing in your attemt to build ghc-6.11. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
I should clarify that cabal install --global won't see the packages installed in the user db, even if not run as root. But it at least will take into consideration the available packages' cache and the config file in ~/.cabal/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
On 22 Mar 2009, at 12:45, Colin Adams wrote: No. It's all recent. And MacPorts installs its own gcc. Achim Scheider pointed out that the compiler name is missing, so the shell tries to execute '-DNDEBUG' as a program. When I try it, I get: $ sudo port install python_select Password: --- Fetching python_select --- Attempting to fetch select-0.2.1.tar.gz from http://arn.se.distfiles.macports.org/python_select --- Verifying checksum(s) for python_select --- Extracting python_select --- Configuring python_select --- Building python_select --- Staging python_select into destroot --- Installing python_select @0.2.1_0+darwin_9 --- Activating python_select @0.2.1_0+darwin_9 --- Cleaning python_select $ sudo python_select python25 Selecting version python25 for python Which perhaps only means that I already have it installed. But I also get this: $ which python /opt/local/bin/python $ python --version Python 2.5.1 $ /usr/bin/python --version Python 2.5.1 The version you tried to install is 2.5.2 - perhaps there is a script problem, then. Hans ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell syntax highlighting support for Trac
Hi. I have noted that with Haskell projects that make use of Trac for issue tracking, it is not possible to have syntax highlighting for Haskell code. http://hackage.haskell.org/trac/hackage/wiki/WikiProcessors Is someone working on this? I can try to write a Trac plugin or patch to solve this. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
On 22 Mar 2009, at 11:32, Colin Adams wrote: I tried issuing the sudo port install command on the wiki page. What did you try to install? ... After some time running it failed with: To fully complete your installation and make python 2.5 the default, please run sudo port install python_select sudo python_select python25 ...The thing is that when I removed python_select and python, there remains a $ /opt/local/bin/python --version Python 2.5.1 So your package somehow needs 2.5.2, which may be the culprit. Hans ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
On Sun, 2009-03-22 at 11:51 +, Colin Paul Adams wrote: Achim == Achim Schneider bars...@web.de writes: Achim Colin Paul Adams co...@colina.demon.co.uk wrote: So why doesn't it find packages then, when they are installed? Achim I've got no idea, what exactly are you trying to do, and Achim how? I'm trying to re-compile ghc 6.11 and it doesn't find parsec. The ghc build system is fairly self contained. I'm not sure if it cares if your bootstrapping compiler has parsec or not. If the ghc build system is looking for the parsec modules then I very much doubt it is going to be looking in any parsec package that your bootstrapping compiler might have registered (either globally or per-user). It'll be looking for the sources that it comes bundled with. A quick look in my ghc source tree reveals: ghc/utils/ext-core/Language/Core/ParsecParser.hs ghc/libraries/parsec/Text/ParserCombinators/Parsec.hs The first one, utils/ext-core is importing parsec. Is that what you're trying to build? The parsec package is an extralib so wouldn't be present unless you did ./darcs-all --extra get If you can't get the ghc build going try asking on the ghc users mailing list. Give as much detail as you can about what you did so people can give you more helpful advice. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
Andrea == Andrea Vezzosi sanzhi...@gmail.com writes: Andrea On Sun, Mar 22, 2009 at 12:51 PM, Colin Paul Adams Andrea co...@colina.demon.co.uk wrote: Achim == Achim Schneider bars...@web.de writes: Achim Colin Paul Adams co...@colina.demon.co.uk wrote: So why doesn't it find packages then, when they are installed? Achim I've got no idea, what exactly are you trying to do, and Achim how? I'm trying to re-compile ghc 6.11 and it doesn't find parsec. Andrea when cabal is invoked by root, like in su -c cabal ... Andrea or su -c runghc Setup ..., it won't see the user Andrea packagedb, but there's rarely a reason to do so. Usually Andrea only the install phase needs to be done as root, while Andrea building and configuring can be done as user. For ghc Andrea you'd want to run ./configure and make as user and make Andrea install as root. For normal packages, if you want to Andrea install them system wide, you'd use something like cabal Andrea install --global --root-cmd=sudo foo OK. I did: cabal install parsec --global --root-cmd=sudo and now when I try to make ghc I get: verify/SimplIface.lhs:16:7: Could not find module `Text.ParserCombinators.Parsec.Language': it is a member of the hidden package `parsec-2.1.0.1' Use -v to see a list of the files searched for. so I've managed to get parsec installed. Now I think I have to add it to a .cabal file somewhere. verify is a directory I added as a sub-directory of compiler, so i tried adding the following line to compiler/ghc.cabal: Build-Depends: parsec = 2 3 but it made no difference. -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Completely confused by cabal
Duncan == Duncan Coutts duncan.cou...@worc.ox.ac.uk writes: Duncan On Sun, 2009-03-22 at 11:51 +, Colin Paul Adams wrote: Achim == Achim Schneider bars...@web.de writes: Achim Colin Paul Adams co...@colina.demon.co.uk wrote: So why doesn't it find packages then, when they are installed? Achim I've got no idea, what exactly are you trying to do, and Achim how? I'm trying to re-compile ghc 6.11 and it doesn't find parsec. Duncan The ghc build system is fairly self contained. I'm not Duncan sure if it cares if your bootstrapping compiler has parsec Duncan or not. If the ghc build system is looking for the parsec Duncan modules then I very much doubt it is going to be looking Duncan in any parsec package that your bootstrapping compiler Duncan might have registered (either globally or per-user). It'll Duncan be looking for the sources that it comes bundled with. Duncan A quick look in my ghc source tree reveals: Duncan ghc/utils/ext-core/Language/Core/ParsecParser.hs Duncan ghc/libraries/parsec/Text/ParserCombinators/Parsec.hs Duncan The first one, utils/ext-core is importing parsec. Is that Duncan what you're trying to build? The parsec package is an No. I assumed that would be built anyway. Duncan extralib so wouldn't be present unless you did ./darcs-all Duncan --extra get Duncan If you can't get the ghc build going try asking on the ghc Duncan users mailing list. Give as much detail as you can about Duncan what you did so people can give you more helpful advice. -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
2009/3/22 Hans Aberg hab...@math.su.se: On 22 Mar 2009, at 11:32, Colin Adams wrote: I tried issuing the sudo port install command on the wiki page. What did you try to install? ... Just what it says on the wiki page: sudo port install glade3 libglade2 gstreamer gst-plugins-base gtksourceview cairo librsvg gtkglext firefox After some time running it failed with: To fully complete your installation and make python 2.5 the default, please run sudo port install python_select sudo python_select python25 ...The thing is that when I removed python_select and python, there remains a $ /opt/local/bin/python --version Python 2.5.1 So your package somehow needs 2.5.2, which may be the culprit. Which package? None of them are mine. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Function to cast types
Hello, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String this is a cast function to cast an Int to a String. I know such function exist, however let's assume it didn't exist. How would I write such function? Cause I have no idea, because there are infinity possibilities if I do it like: fromIntToString x | x == 1 = 1 | x == 2 = 2 -- And so on... I've also thinked about defining the defining the data types Int and String (I know you cannot redefine them, at least I think so), however I've no succes. Thank you in advance for answering my question! PS: if possible please do not use any casting functions that are predefined. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SoC idea: interactive profiling
yep, sounds great to me :-) although with some hacks one can already have a poor mans real time interface for heap profiling: http://www.haskell.org/ghc/docs/latest/html/users_guide/hp2ps.html#id2677301 I agree that the effect of laziness can be very hard to grasp, sometimes it even feels that I traded the annoying side effects from imperative programming to lazy effects in functional programming... Can't seem to have my cake and lazily eat it :-) On Sun, Mar 22, 2009 at 10:03 AM, Patai Gergely patai_gerg...@fastmail.fmwrote: Hello all, I entered a little proposal in the issue tracker: http://hackage.haskell.org/trac/summer-of-code/ticket/1570 As I see it, the graphical part could be a warm-up exercise with an already useful product, and interaction with the rts would be the actual challenge. Reasoning about laziness is far from trivial (at least I often feel lost when trying to grok all the interaction within Reactive ;), and being able to browse profiler output on the spot is something I felt the need for a few times already. Eventually, this could be a contribution to an IDE project, even though it could as well remain a standalone application for all the emacs/vi folk. Profiling tools for parallel programs are in the make already, but I haven't seen anything more convenient than hp2ps and little add hoc solutions for analysing resource usage patterns. How do you all go about profiling? Gergely -- http://www.fastmail.fm - Does exactly what it says on the tin ___ 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: Ease of Haskell development on OS X?
On 22 Mar 2009, at 13:42, Colin Adams wrote: After some time running it failed with: To fully complete your installation and make python 2.5 the default, please run sudo port install python_select sudo python_select python25 ...The thing is that when I removed python_select and python, there remains a $ /opt/local/bin/python --version Python 2.5.1 So your package somehow needs 2.5.2, which may be the culprit. Which package? None of them are mine. One of the packages you tried to install asked for this, in this list: Just what it says on the wiki page: sudo port install glade3 libglade2 gstreamer gst-plugins-base gtksourceview cairo librsvg gtkglext firefox Looking into your post: --- Cleaning python25 --- Fetching py25-hashlib --- Attempting to fetch Python-2.5.2.tar.bz2 from http://www.python.org/ftp/python/2.5.2/ --- Verifying checksum(s) for py25-hashlib --- Extracting py25-hashlib --- Configuring py25-hashlib --- Building py25-hashlib with target build Error: Target org.macports.build returned: shell command cd it is py25-hashlib that is the culprit. I was able to install it. Then I got a later Python: --- Attempting to fetch Python-2.5.4.tar.bz2 from http://arn.se.distfiles.macports.org/python25 The procedure followed was (do a 'sudo -s' so save writing: First uninstall python25 and dependencies: # port uninstall python25 --- Unable to uninstall python25 2.5.2_5+darwin_8, the following ports depend on it: --- py25-gobject --- py25-numeric --- gstreamer # port uninstall gstrea...@0.10.19_0 --- Deactivating gstreamer @0.10.19_0 --- Uninstalling gstreamer @0.10.19_0 # port uninstall gstrea...@0.10.8_0 --- Uninstalling gstreamer @0.10.8_0 # port uninstall py25-gobject --- Deactivating py25-gobject @2.14.2_0 --- Uninstalling py25-gobject @2.14.2_0 # port uninstall py25-numeric --- Deactivating py25-numeric @24.2_1+macosx --- Uninstalling py25-numeric @24.2_1+macosx # sudo port uninstall python25 Then I noticed there was an unregistered python - those seems to confuse MacPorts. OS move it: # cd /opt/local/bin/ # mv python python1 Then I installed python_select and python25: # port install python_select --- Fetching python_select --- Verifying checksum(s) for python_select --- Extracting python_select --- Configuring python_select --- Building python_select --- Staging python_select into destroot --- Installing python_select @0.2.1_0+darwin_9 --- Activating python_select @0.2.1_0+darwin_9 --- Cleaning python_select bash-3.2# port install python25 --- Fetching python25 --- Attempting to fetch Python-2.5.4.tar.bz2 from http://arn.se.distfiles.macports.org/python25 --- Verifying checksum(s) for python25 --- Extracting python25 --- Applying patches to python25 --- Configuring python25 --- Building python25 --- Staging python25 into destroot --- Installing python25 @2.5.4_0+darwin_9+macosx --- Activating python25 @2.5.4_0+darwin_9+macosx To fully complete your installation and make python 2.5 the default, please run sudo port install python_select sudo python_select python25 --- Cleaning python25 After that follow the instructions: # sudo port install python_select Skipping org.macports.activate (python_select +darwin_9) since this port is already active --- Cleaning python_select # sudo python_select python25 Selecting version python25 for python And finally to py25-hashlib: # port install py25-hashlib Portfile changed since last build; discarding previous state. --- Fetching openssl --- Attempting to fetch openssl-0.9.8j.tar.gz from http://arn.se.distfiles.macports.org/openssl --- Verifying checksum(s) for openssl --- Extracting openssl --- Applying patches to openssl --- Configuring openssl --- Building openssl --- Staging openssl into destroot --- Installing openssl @0.9.8j_0 --- Activating openssl @0.9.8j_0 Error: Target org.macports.activate returned: Image error: /opt/local/ share/man/man3/bn_print.3.gz already exists and does not belong to a registered port. Unable to activate port openssl. Error: The following dependencies failed to build: openssl Error: Status 1 encountered during processing. So here I just remove the unregistered file: # rm /opt/local/share/man/man3/bn_print.3.gz # port activate openssl @0.9.8j_0 --- Activating openssl @0.9.8j_0 So now it worked. Try py25-hashlib again: # port install py25-hashlib --- Fetching py25-hashlib --- Verifying checksum(s) for py25-hashlib --- Extracting py25-hashlib --- Configuring py25-hashlib --- Building py25-hashlib --- Staging py25-hashlib into destroot --- Installing py25-hashlib @2.5.4_0 --- Activating py25-hashlib @2.5.4_0 --- Cleaning py25-hashlib So now I git t installed. - I got beyond the point where you got stuck. Hans ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org
[Haskell-cafe] Re: Function to cast types
Anonymous Anonymous temp.pub...@gmail.com wrote: Hello, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String this is a cast function to cast an Int to a String. I know such function exist, however let's assume it didn't exist. How would I write such function? I have no Idea, but this one works: intOfChar c | c = '0' c = '9' = fromEnum c - fromEnum '0' intOfChar _ = undefined intOfString = sum . map (uncurry (*)) . zip (map (10^) [0..]) . map intOfChar . reverse ...assuming that 0..9 are consecutive in the Char Enum, which they are. Reading intOfString backwards, you get: reverse the string, change each digit to its integer value, pair it up with the right power of 10, multiply those pairs, and finally sum everything up. You can replace map f . zip with zipWith f , but that doesn't change much. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String this is a cast function to cast an Int to a String. I'll assume that by a cast you mean a conversion from one type to another where no information is lost. -- Let's assume that we can represent every Int using a String intToString :: Int - String intToString n = ... -- Not every member of String can be interpreted as an Int, for -- example aabc is nonsense when viewed as an Int. stringToInt :: String - Maybe Int stringToInt s = ... -- This property should hold for every Int. It states that given some -- Int called n we can convert it to a string and back without losing -- information. prop_intString :: Int - Bool prop_intString n = maybe False (== n) . stringToInt . intToString $ n Using such a property can be really useful to test your implementation of intToString and stringToInt. I know such function exist, however let's assume it didn't exist. How would I write such function? Cause I have no idea, because there are infinity possibilities if I do it like: fromIntToString x | x == 1 = 1 | x == 2 = 2 -- And so on... It might be useful to first write this function first: intToDigits :: Int - [Int] intToDigits n = ... It should convert an integer to a list of its digits (using normal base 10): intToDigits 123 == [1, 2, 3] Then you can write a function which takes such a list and converts it to a string. (Hint: use 'map' in combination with a function of type 'Int - Char') You have to take extra care if you also want to support negative numbers. I've also thinked about defining the defining the data types Int and String (I know you cannot redefine them, at least I think so), however I've no succes. You can create your own datatypes which behave roughly the same as Int and String. You will never be able to create something which behaves exactly as a String because it is treated a bit special (it has its own syntax). import Data.String data MyInt = ... data MyString = ... instance Num MyInt where ... instance IsString MyString where ... By creating an instance of Num for your own type MyInt you'll be able to use the familiar operators +, - etc... If you want all the functionality that normal Ints have for your own type you'll also need instances of Bounded, Enum, Eq, Integral, Num, Ord, Read, Real, Show and Ix. I might have forgotten a few :-) Some of those can be automatically derived for you. (data MyInt = ... deriving Show, for example) I hope some of this is useful to you. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Function to cast types
Achim Schneider bars...@web.de wrote: Anonymous Anonymous temp.pub...@gmail.com wrote: fromIntToString :: Int - String intOfString = sum . map (uncurry (*)) . zip (map (10^) [0..]) . map intOfChar . reverse /me hides under a stone and tries again, this time with the correct problem: import Data.List charOfInt :: Int - Char charOfInt c | c = 0 c = 9 = toEnum (c + fromEnum '0') charOfInt _ = undefined stringOfInt :: Int - String stringOfInt = let f (-1) = Nothing f n = let (r,c) = n `divMod` 10 in Just $ if r == 0 then (c, (-1)) else (c, r) in map charOfInt . reverse . unfoldr f That -1 thing is clearly inelegant, but I don't feel like struggling with off-by-one errors, right now. Negative numbers are left as an exercise. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: regex-tdfa 1.1.1
This is both a bug fix release and a feature release. The bug fix is a bit embarrassing, the indices were correct but the captured text was wrong in version 1.1.0. Oops. As of version 1.1.1 the following GNU extensions are recognized, all anchors: \` at beginning of entire text \' at end of entire text \ at beginning of word \ at end of word \b at either beginning or end of word \B at neither beginning nor end of word There is a newSyntax field of CompOptions that can enable/disable this syntax. These were requested by users of the Yi project. The home page is on the wiki and UPDATED a bit at http://haskell.org/haskellwiki/Regular_expressions#regex-tdfa The HADDOCK fails on hackage for now, but is up at http://darcs.haskell.org/packages/regex-unstable/regex-tdfa/doc/html/regex-tdfa/Text-Regex-TDFA.html The released code is on hackage at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-tdfa The darcs repository is at http://darcs.haskell.org/packages/regex-unstable/regex-tdfa/ Cheers, Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
Anonymous Anonymous temp.pub...@gmail.com writes: fromIntToString :: Int - String ... PS: if possible please do not use any casting functions that are predefined. This is a rather simplified version of the Show instance of Int from the libs: itos :: Int - String itos x | x 0 = '-' : itos (negate x) | x 10= 0123456789 !! x : | otherwise = let (q, r) = x `quotRem` 10 in itos q ++ itos r -- Gökhan San ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
Anonymous One, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String Is this a homework assignment, perchance? Please take a look at http://www.haskell.org/haskellwiki/Homework_help Everyone here is glad to help, but we're also sensitive on academic honesty. With that said, you've done the first step, which is writing down the function's type. You don't want to iterate over all possible Int values, so maybe a recursive definition is in order. What are the cases to consider? Like, what happens if you have a negative number... this is a cast function to cast an Int to a String. I know such function By the way, cast is probably the wrong word for what you want. You're building a string representation of an Integer; in my view it's not just a type conversion. Good luck, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
Thank you all for your answers, you've all been a great help to me! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
Hello, an answer from me, this is NOT the homework assignment. For my own homework assignment, I had to create custom data types and convert a string containing my datatype into my datatype. I will not expose my datatype, but it is something with logical operators. My approach would be using operator recognition, I've written a function that can search those operators. However I was wondering how they would do it with intergers because intergers are in a infinity set! But I couldn't figure it out =(. Thanks for answering you all! 2009/3/22 John Dorsey hask...@colquitt.org Anonymous One, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String Is this a homework assignment, perchance? Please take a look at http://www.haskell.org/haskellwiki/Homework_help Everyone here is glad to help, but we're also sensitive on academic honesty. With that said, you've done the first step, which is writing down the function's type. You don't want to iterate over all possible Int values, so maybe a recursive definition is in order. What are the cases to consider? Like, what happens if you have a negative number... this is a cast function to cast an Int to a String. I know such function By the way, cast is probably the wrong word for what you want. You're building a string representation of an Integer; in my view it's not just a type conversion. Good luck, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
John Dorsey wrote: Anonymous One, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String Is this a homework assignment, perchance? Please take a look at http://www.haskell.org/haskellwiki/Homework_help Everyone here is glad to help, but we're also sensitive on academic honesty. This e-mail is offtopic, but I suppose being a little offtopic every now and then isn't that bad, specially if the subject is interesting. So, here I go. The only reason people would want the answer of an assignment instead of actually doing it themselves is if they don't care about actually doing it. That is, they don't want to learn haskell, they just want to pass a class. In that case, do we really want to _make_ them learn? You could argue that helping someone pass some class without learning is not worth your time. I wouldn't try to convince you otherwise. But if you thought the assignment was interesting and you did it yourself, I see no problem with sharing that with the person who asked it. The bottom line is that I don't believe in making people learn things they are not interested in learning in the first place. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] about beta NF in lambda calculus
If above is true, I am confused why we have to distinguish the terms which have NF and be in NF? isn't the terms have NF will eventually become in NF? or there are some way to avoid them becoming in NF? Another way to think about it: what about terms which have no NF? And given both kinds of terms, how do you distinguish them? By normal-order reduction, but that is a semi-decision procedure: if a term has a NF, normal-order reduction will eventually reach it, but if a term has no NF, there may not be a way to tell. There is a trivial decision procedure for whether a term is in NF, but none for whether a term has a NF. That is enough of a difference to warrant the distinction, in most cases;-) Btw, NF (as in: no redices) is rather extreme, so you might want to look up HNF (head normal form: no head redices), which is useful for actually assigning meaning to terms, and WHNF (weak head normal form: no head redices outside of lambda abstraction), which is what implementations of languages like Haskell use during evaluation. Normal-order reduction reaches these forms in order, if they exist: term-WHNF-HNF-NF. Claus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SoC idea: interactive profiling
Hello PG == Patai Gergely writes: PG Hello all, I entered a little proposal in the issue tracker: PG http://hackage.haskell.org/trac/summer-of-code/ticket/1570 PG As I see it, the graphical part could be a warm-up exercise with an PG already useful product, and interaction with the rts would be the PG actual challenge. Reasoning about laziness is far from trivial (at PG least I often feel lost when trying to grok all the interaction within PG Reactive ;), and being able to browse profiler output on the spot is PG something I felt the need for a few times already. Eventually, this PG could be a contribution to an IDE project, even though it could as PG well remain a standalone application for all the emacs/vi folk. PG Profiling tools for parallel programs are in the make already, but I PG haven't seen anything more convenient than hp2ps and little add hoc PG solutions for analysing resource usage patterns. How do you all go PG about profiling? May be providing profiling information for kcachegrind will be a good solution? For example, there are tools for PHP, that allow to view collected information in kcachegrind, and get interactive zooming, etc. -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://xtalk.msk.su/~ott/ http://alexott-ru.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to cast types
Rafael Cunha de Almeida wrote: This e-mail is offtopic, but I suppose being a little offtopic every now and then isn't that bad, specially if the subject is interesting. So, here I go. It's the cafe'. Very little is strictly off-topic here, and certainly not this. I'm happy to help anyone who's trying to learn, but I will not willingly subvert anyone's classroom rules, as a matter of academic honesty. I think that matters at any level of school. I accept that it can't be enforced perfectly, or anywhere near so. I didn't mean to accuse the original poster, and I trust I didn't come accross that way. I don't think it's a bad idea to point out that an anonymous question like this one may look suspicious, or that many instructors follow this forum. None of that should give offense. But I also provided some hints. I think a good and fun way to help with problems like that is to iteratively guide someone to their answer, instead of giving it to them straight-up. Just to be clear, I also have no criticism of the other replies. Anyone giving voluntary help should and will apply their own rules. The only reason people would want the answer of an assignment instead of actually doing it themselves is if they don't care about actually doing it. That is, they don't want to learn haskell, they just want to pass a class. In that case, do we really want to _make_ them learn? In that case I have no interest in forcing them to learn or in helping them get a grade. But I'm always optimistic that someone's willing to learn. I've been proven wrong, but not often. Cheers, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
On 2009 Mar 22, at 6:32, Colin Adams wrote: creating build/temp.macosx-10.3-i386-2.5 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o unable to execute -DNDEBUG: No such file or directory error: command '-DNDEBUG' failed with exit status 1 I recall seeing that with an old version of MacPorts; have you run sudo port sync recently? (Or better, sudo port selfupdate.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
No, I haven't done that - I forgot about that command since I first installed macports nearly a year ago. :-( Bit I DID manage to get the ports all installed (thanks to lots of help from Hans, and lots of individual port uninstalls followed by port installs). And configured gtk2hs ok. But when I type make, I get (after a lot of compiling): No rule to make target `glib/System/Glib/GObject_stub.p_o needed by' ... I shall try again without enmabling profiling support. 2009/3/22 Brandon S. Allbery KF8NH allb...@ece.cmu.edu: On 2009 Mar 22, at 6:32, Colin Adams wrote: creating build/temp.macosx-10.3-i386-2.5 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o unable to execute -DNDEBUG: No such file or directory error: command '-DNDEBUG' failed with exit status 1 I recall seeing that with an old version of MacPorts; have you run sudo port sync recently? (Or better, sudo port selfupdate.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SoC idea: interactive profiling
Hello Gergely, Last Summer, I also proposed a Google SOC project for profiling, called Parallel Profiling Support for GHC. This project was denied for the Google SOC mostly due to the scope of the project and the concern that the project would take far longer than the Summer. As this project was/is for my Master's thesis, I am still working on it and we have made a lot of progress, but the Haskell mentors were correct in saying it would take much longer. My recommendation to you would be to define your scope to something that is clearly feasible in the time-frame allotted for Google SOC. Also, you probably want to familiarize yourself with the work we've done to improve profiling in GHC. ThreadScope (Pre-Announcement, Request for Features): http://www.nabble.com/ThreadScope:-Request-for-features-for-the-performance-tuning-of-parallel-and-concurrent-Haskell-programs-td22455073.html ThreadScope: http://raintown.org/?page_id=132 The EventLog framework (used by ThreadScope) is now available in the GHC RTS ($GHC_ROOT/rts/eventlog) and has been committed to GHC HEAD. Download GHC HEAD, build GHC, then compile a Haskell program with -eventlog and execute with +RTS -l -RTS to output a prog_name.eventlog binary file. We also have available a visualizer agnostic library that parses the binary eventlog files to be used by any visualizer. I will be releasing that soon as a cabal package called ghc-events (but it is available now on http://code.haskell.org/ghc-events as a darcs repository) Caveat: we are still working on all of these components, so there may be changes to come. Of course, we expect to keep the ghc-events library in-step with changes to the GHC RTS eventlog framework to ensure ghc-events can be used as a library. I'm not sure if any of this could be useful to you directly for your Google SOC project, but I wanted to be sure you were aware of the updates to GHC for profiling. Just to reiterate, make sure that the scope of your project is well-defined. :) If you have any questions, feel free to ask. Best of luck. -- Donnie Jones On Sun, Mar 22, 2009 at 4:03 AM, Patai Gergely patai_gerg...@fastmail.fm wrote: Hello all, I entered a little proposal in the issue tracker: http://hackage.haskell.org/trac/summer-of-code/ticket/1570 As I see it, the graphical part could be a warm-up exercise with an already useful product, and interaction with the rts would be the actual challenge. Reasoning about laziness is far from trivial (at least I often feel lost when trying to grok all the interaction within Reactive ;), and being able to browse profiler output on the spot is something I felt the need for a few times already. Eventually, this could be a contribution to an IDE project, even though it could as well remain a standalone application for all the emacs/vi folk. Profiling tools for parallel programs are in the make already, but I haven't seen anything more convenient than hp2ps and little add hoc solutions for analysing resource usage patterns. How do you all go about profiling? Gergely -- http://www.fastmail.fm - Does exactly what it says on the tin ___ 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] SoC idea: interactive profiling
although with some hacks one can already have a poor mans real time interface for heap profiling: http://www.haskell.org/ghc/docs/latest/html/users_guide/hp2ps.html#id2677301 I'm aware of that, even did it myself a few times. That's part of the reason why I want something better. ;) I agree that the effect of laziness can be very hard to grasp, sometimes it even feels that I traded the annoying side effects from imperative programming to lazy effects in functional programming... Can't seem to have my cake and lazily eat it :-) It's still less painful than old-fashioned side effects. You can always look at it as an opportunity to better understand your code, at least for me it was always enlightening in some way when I found the right spot for a `seq`. Gergely -- http://www.fastmail.fm - And now for something completely different ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ACM Task for C++ and Java programmers in Haskell. How to make code faster?
Hi! Recently I've found interesting ACM research on C++ and Java efficiency. This task also was been solved on lisp/scheme and is described on http://www.flownet.com/ron/papers/lisp-java/ I tried to solve this task on Haskell but stuck with efficiency problems (approx in 1000 times slower and takes 20 times more memory). I hope the approach, I've used is correct and problem with data structures and implementation. It took more than 81% of time for garbage collection. I tried to use ByteStrings instead of Strings, but unfortunately it didn't help. The entire code I placed on http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2764 The original instructions are on: http://www.flownet.com/ron/papers/lisp-java/instructions.html Dictionary file could be downloaded from: http://www.flownet.com/ron/papers/lisp-java/dictionary. Input data: http://www.flownet.com/ron/papers/lisp-java/input.txt Expected output: http://www.flownet.com/ron/papers/lisp-java/output.txt Could someone help me to make this code faster? I'd like to see solution that will be elegant and fast, without heavy optimizations, that will make code unreadable. Also, if it possible, prepare the program to support SMP parallelism. Very thanks in advance. Hope you'll enjoy this task :) -- Best regards, Vasyl Pasternak ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Function to cast types
It never looked like a homework assignment to me, if someone puts as much original thought into a mail than the OP, it's hard to believe he wouldn't have mentioned the fact in case it was indeed homework. Speaking of it, I don't really care whether something is homework or not, what I care about is the willingness to figure out stuff by oneself. I just don't like talking to TV sets. Not being able to explain your own code and/or not being able to describe how you came up with it is a dead give-away to capable instructors, anyway. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SoC idea: interactive profiling
Last Summer, I also proposed a Google SOC project for profiling, called Parallel Profiling Support for GHC. This project was denied for the Google SOC mostly due to the scope of the project and the concern that the project would take far longer than the Summer. Yes, I'm aware of that trap. However, I think the ideas I proposed (rather vaguely, I have to admit) could be handled in three months, especially since I can familiarise myself with the relevant parts of the rts before actual work starts, and the first part of the task doesn't even require significant changes, if any. ThreadScope: http://raintown.org/?page_id=132 I know about that one, that's another reason why I wanted to explore the area of more user-friendly space profiling instead: it seems somewhat neglected. Of course that might be because people don't feel an urgent need for more powerful tools, but I can't tell that without asking the community. The EventLog framework (used by ThreadScope) is now available in the GHC RTS ($GHC_ROOT/rts/eventlog) and has been committed to GHC HEAD. Thanks for the pointer, I'll check it out. Just to reiterate, make sure that the scope of your project is well-defined. :) Of course I intend to list some specific subtasks in my proposal, preferably the kind that makes life much easier with minimal changes to the codebase. :) If you have any questions, feel free to ask. I'll see if I have some after looking at the code. For the time being there's only the one I'd ask anyone: how do you think space profiling could be made more convenient? Gergely -- http://www.fastmail.fm - Access your email from home and the web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell
Excerpts from Henning Thielemann's message of Sat Mar 21 22:27:08 +0100 2009: On Fri, 20 Mar 2009, Nicolas Pouillard wrote: Hi folks, We have good news (nevertheless we hope) for all the lazy guys standing there. Since their birth, lazy IOs have been a great way to modularly leverage all the good things we have with *pure*, *lazy*, *Haskell* functions to the real world of files. Maybe you know of my packages lazy-io and explicit-exception which also aim at lazy I/O and asynchronous exception handling. I was indeed aware of these two packages but I think they hold orthogonal ideas. About the lazy-io package, as explained in the documentation one has to carefully choose which operations can be lifted. In safe-lazy-io I try to choose a set of well behaving combinators to replace 'getContents' in the IO monad. Moreover if I take the three problems of standard lazy IO in turn: 1/ Control of resources: One advantage over standard lazy IO is that the file opening can also be done lazily, avoiding an immediate resource exhaustion. However one still relies on evaluation and garbage collection to take care of closing handles, which is not satisfying since handles are scarce resources. 2/ Control of exceptions: If one writes a 'getContents' function such that it no longer hides I/O errors during reading, how do you guarantee that exceptions will happen during the LazyIO.run and not after? 3/ Determinism: when freely combining multiple inputs one risks the problem mentioned by Oleg [1], when using your package it will depend on the 'getContents' function we use: a) if we 'liftIO' the standard 'getContents' function, we can have the issue. b) if we write a new 'getContents' as below [2], then (if I got right your lazy IO monad) all reads are chained. And then one has to process inputs in the same order. However I've found the underlying idea of your monad brilliant. I've tried a little to use something similar as a base for the implementation but didn't succeed. With lazy-io, you are able to write more complicated things than getContents. I needed this for HTTP communication that is run by demand. That is when the HTTP response header is requested, then the function could send a HTTP request first. Is it possible and sensible to combine this with safe-lazy-io? While currently focusing only on reading file handles, the long term purpose for this technique is to have new primitives like reading on sockets, using bytestrings... I have also code that demonstrates the usage of explicit asynchronous exceptions. I have however still not a set of combinators that makes working with asynchronous exceptions as simple as working with synchronous ones: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/spreadsheet I also think that explicit asynchronous exceptions could be part of the equation, however I currently don't know how to mix them well. Best regards, [1]: http://www.haskell.org/pipermail/haskell/2009-March/021064.html [2] hGetContents :: Handle - LIO.T String hGetContents h = lazyRead where lazyRead = do isEOF - liftIO $ hIsEOF h if isEOF then do unit - liftIO $ hClose h return $ unit `seq` [] else do c - liftIO $ hGetChar h cs- lazyRead return $ c : cs -- Nicolas Pouillard ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ACM Task for C++ and Java programmers in Haskell. How to make code faster?
Hello Vasyl, Sunday, March 22, 2009, 8:25:02 PM, you wrote: i believe that i already seen this problem here a few years ago :) what search structure you was used? i think that immutable hash (represented as array of lists) would be useful here Hi! Recently I've found interesting ACM research on C++ and Java efficiency. This task also was been solved on lisp/scheme and is described on http://www.flownet.com/ron/papers/lisp-java/ I tried to solve this task on Haskell but stuck with efficiency problems (approx in 1000 times slower and takes 20 times more memory). I hope the approach, I've used is correct and problem with data structures and implementation. It took more than 81% of time for garbage collection. I tried to use ByteStrings instead of Strings, but unfortunately it didn't help. The entire code I placed on http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2764 The original instructions are on: http://www.flownet.com/ron/papers/lisp-java/instructions.html Dictionary file could be downloaded from: http://www.flownet.com/ron/papers/lisp-java/dictionary. Input data: http://www.flownet.com/ron/papers/lisp-java/input.txt Expected output: http://www.flownet.com/ron/papers/lisp-java/output.txt Could someone help me to make this code faster? I'd like to see solution that will be elegant and fast, without heavy optimizations, that will make code unreadable. Also, if it possible, prepare the program to support SMP parallelism. Very thanks in advance. Hope you'll enjoy this task :) -- 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] Haskell syntax highlighting support for Trac
I'm not sure what your problem is. I downloaded Trac not long ago, and Haskell highlighting worked out of the box for me after installing Pygments. Here's the proof (this is the wiki of a course I'm teaching): http://kfarkas.iit.bme.hu/trac/bfp/wiki/EloadasAbsztrakciok1 The code to activate it is the following: {{{ #!hs main = print Hello world! }}} Gergely -- http://www.fastmail.fm - One of many happy users: http://www.fastmail.fm/docs/quotes.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ease of Haskell development on OS X?
2009/3/22 Colin Adams colinpaulad...@googlemail.com: No, I haven't done that - I forgot about that command since I first installed macports nearly a year ago. :-( Bit I DID manage to get the ports all installed (thanks to lots of help from Hans, and lots of individual port uninstalls followed by port installs). And configured gtk2hs ok. But when I type make, I get (after a lot of compiling): No rule to make target `glib/System/Glib/GObject_stub.p_o needed by' ... I shall try again without enmabling profiling support. It's all working now. And I don't need profiling support on the mac anyway. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell syntax highlighting support for Trac
Patai Gergely ha scritto: I'm not sure what your problem is. Yes, haskell support is available in recent versions of Trac. I was trying with the Trac instance for Hackage/Cabal. [...] Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re: [Haskell-cafe] [Haskell-beginners] appropriateness of haskell for GUIs
Brandon S. Allbery KF8NH wrote: Glade works fine if all you want is to place widgets; but it won't generate template code in Haskell (it will for C and C++) to connect the widgets together, which is what I understand from you have to type everything yourself. I use Template Haskell to extract information from .glade files and produce some haskell glue on the fly. So you need to declare stuff only once (in glade file). Regards, San. -- View this message in context: http://www.nabble.com/Re%3A--Haskell-beginners--appropriateness-of-haskell-for-GUIs-tp22636852p22644320.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Transforming XML using HXT, I'm confused.
Hello, I'm trying to transform a fragment of XML using HXT, specifically I'm trying to strip out any disallowed content while retaining as much as possible. For example I might be given barevilblah/evil/bar. I want to get rid of the 'evil' element but retain it's content resulting in barblah/bar, rather than just bar/bar. My basic theory was to do a bottom up traversal replacing any invalid elements with their children. Unfortunately I've got myself thoroughly confused. The code below shows what I've tried so far (except the many random permutations of collapseInvalids I've tried!). I think one problem is that validElements is choosing based on the parent element but processing will just be given the child. Also I think some inputs will require multiple passes over the children during the traversal, eg given ...bazs6bars7/bar/baz... I'd like ...bazs6s7/baz... but when processing the bar it is valid, it's only once you're processing the baz you see that you need to pull the s7 up. I'd really appreciate any advice, and I'm not wedded to the current code so feel free to throw it all out! :) Thanks P. ps: Is it possible to render an XmlTree as String without invoking IO? I've just been doing runLA (hread collapseInvalids) frag1 and looking at the nodes. module Test where import Text.XML.HXT.Arrow --collapseInvalids = processBottomUp (processChildren ((getChildren `whenNot` validElements) `orElse` this)) -- foo can contain foo, bar or baz, not text validInFoo :: (ArrowXml a) = a XmlTree XmlTree validInFoo = foldr1 orElse ( map hasName [foo, bar, baz] ) -- bar can contain foo, baz or text, not foo validInBar :: (ArrowXml a) = a XmlTree XmlTree validInBar = foldr1 orElse ( isText : map hasName [foo, baz] ) -- baz can only contain text validInBaz :: (ArrowXml a) = a XmlTree XmlTree validInBaz = foldr1 orElse ( isText : []) validElements :: (ArrowXml a) = a XmlTree XmlTree validElements = choiceA ( hasName foo :- validInFoo : hasName bar :- validInBar : hasName baz :- validInBaz : isText:- this : []) frag1 = concat ( s1 : foo : bar : s2 : evil : s3 : baz : s4 : /baz : s5 : /evil : s6 : /bar : /foo : s7 : []) result1 = concat ( s1 : foo : bar : s2s3 : baz : s4 : /baz : s5s6 : /bar : /foo : s7 : []) frag2 = concat ( s1 : foo : s2 : evil : s3 : /evil : bar : s4 : evil : s5 : baz : s6 : bar : s7 : /bar : /baz : s8 : bar : s9 : /bar : /evil : s10 : /bar : /foo : s11 : []) result2 = concat ( s1 : foo : bar : s4 : evil : s5 : baz : s6 : bar : s7 : /bar : /baz : s8 : bar : s9 : /bar : /evil : s10 : /bar : /foo : s11 : []) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SoC idea: interactive profiling
Hello Gergely, 2009/3/22 Patai Gergely patai_gerg...@fastmail.fm: Last Summer, I also proposed a Google SOC project for profiling, called Parallel Profiling Support for GHC. This project was denied for the Google SOC mostly due to the scope of the project and the concern that the project would take far longer than the Summer. Yes, I'm aware of that trap. However, I think the ideas I proposed (rather vaguely, I have to admit) could be handled in three months, especially since I can familiarise myself with the relevant parts of the rts before actual work starts, and the first part of the task doesn't even require significant changes, if any. ThreadScope: http://raintown.org/?page_id=132 I know about that one, that's another reason why I wanted to explore the area of more user-friendly space profiling instead: it seems somewhat neglected. Of course that might be because people don't feel an urgent need for more powerful tools, but I can't tell that without asking the community. I do agree that a visualizer would be useful for space profiling (and all areas of profiling for that matter). The EventLog framework (used by ThreadScope) is now available in the GHC RTS ($GHC_ROOT/rts/eventlog) and has been committed to GHC HEAD. Thanks for the pointer, I'll check it out. Just to reiterate, make sure that the scope of your project is well-defined. :) Of course I intend to list some specific subtasks in my proposal, preferably the kind that makes life much easier with minimal changes to the codebase. :) Be sure to include a schedule too. I think there was an example Google SOC project to follow as a guideline. If you have any questions, feel free to ask. I'll see if I have some after looking at the code. For the time being there's only the one I'd ask anyone: how do you think space profiling could be made more convenient? As I said above, I do think a visualizer for space profiling would be an improvement over the current log file output. I'll let you know if I think of some other suggestions. -- Donnie Jones ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANN] salvia-0.1, salvia-extras-0.1
Hi all, I am pleased to announce a new version of Salvia, the lightweight Haskell Web Server Framework with modular support for serving static files, directories indices, default error responses, connection counting and logging, HEAD and PUT requests, keep-alives, custom banner printing, default handler environments for parsing request and printing responses, dispatching based on request methods, URI, paths and filename extension, URI rewriting and redirection, virtual hosting, cookie, session and user management and more... Changes since previous version: - Some more advanced, non-fundamental handlers have been moved to their own package salvia-extras. This helps pruning the dependencies a bit. - The package now has some default handler environments that simplify setting up a server application. - The server now has support for keep-alive, significantly increasing the performance. - The library functions are now almost fully documented instead of no- documentation-at-all in the previous versions. - Salvia now also works on windows (I heard). - Lots of code cleanups throughout the code. - Lots of minor bug fixes. To install: use cabal. Thanks to the people that helped me with suggestions and bug-reports! -- Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell
On Sun, 22 Mar 2009, nicolas.pouillard wrote: Excerpts from Henning Thielemann's message of Sat Mar 21 22:27:08 +0100 2009: Maybe you know of my packages lazy-io and explicit-exception which also aim at lazy I/O and asynchronous exception handling. I was indeed aware of these two packages but I think they hold orthogonal ideas. About the lazy-io package, as explained in the documentation one has to carefully choose which operations can be lifted. In safe-lazy-io I try to choose a set of well behaving combinators to replace 'getContents' in the IO monad. Moreover if I take the three problems of standard lazy IO in turn: 1/ Control of resources: One advantage over standard lazy IO is that the file opening can also be done lazily, avoiding an immediate resource exhaustion. However one still relies on evaluation and garbage collection to take care of closing handles, which is not satisfying since handles are scarce resources. 2/ Control of exceptions: If one writes a 'getContents' function such that it no longer hides I/O errors during reading, how do you guarantee that exceptions will happen during the LazyIO.run and not after? Currently I cannot guarantee anything. However my idea is to stay away from built-in exceptions in IO. In explicit-exception there is an experimental hidden module which provides an IO monad wrapper called SIO which cannot throw any IO exception. http://code.haskell.org/explicit-exception/src/System/IO/Straight.hs Actually, I think it's the wrong way round to build an exception-free monad on top of one with exceptions. Instead IO should be built on top of SIO, but that's not possible for historical reasons. The only safe operation to get into SIO is ioToExceptionalSIO :: IO a - ExceptionalT IOException SIO a That is, it makes exceptions explicit and SIO operations can never throw IO exceptions. You should convert synchronous explicit exceptions of atomic operations like getChar into asynchronous explicit exceptions, combine them lazily to big operations like getContents. Then you get getContents :: SIO (Asynchronous.Exception IOException String) If you run lazy SIO operations you can't become surprised by exceptions. 3/ Determinism: when freely combining multiple inputs one risks the problem mentioned by Oleg [1], when using your package it will depend on the 'getContents' function we use: a) if we 'liftIO' the standard 'getContents' function, we can have the issue. b) if we write a new 'getContents' as below [2], then (if I got right your lazy IO monad) all reads are chained. And then one has to process inputs in the same order. I wouldn't build hClose into getContents, because you never know, whether the file is read until it's end. If you call a LazyIO.getContents twice, the contents are read sequential. In order to read file contents simultaneously you must call (LazyIO.run LazyIO.getContents) twice in the IO monad. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ACM Task for C++ and Java programmers in Haskell. How to make code faster?
Thanks for the point. I've found haskell solution there http://www.haskell.org/haskellwiki/Phone_number The second (shorter) solution is fantastic, it beats all other languages, but I'll never wrote such code in reasonable time :) 2009/3/22 Bulat Ziganshin bulat.zigans...@gmail.com: Hello Vasyl, Sunday, March 22, 2009, 8:25:02 PM, you wrote: i believe that i already seen this problem here a few years ago :) what search structure you was used? i think that immutable hash (represented as array of lists) would be useful here Hi! Recently I've found interesting ACM research on C++ and Java efficiency. This task also was been solved on lisp/scheme and is described on http://www.flownet.com/ron/papers/lisp-java/ I tried to solve this task on Haskell but stuck with efficiency problems (approx in 1000 times slower and takes 20 times more memory). I hope the approach, I've used is correct and problem with data structures and implementation. It took more than 81% of time for garbage collection. I tried to use ByteStrings instead of Strings, but unfortunately it didn't help. The entire code I placed on http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2764 The original instructions are on: http://www.flownet.com/ron/papers/lisp-java/instructions.html Dictionary file could be downloaded from: http://www.flownet.com/ron/papers/lisp-java/dictionary. Input data: http://www.flownet.com/ron/papers/lisp-java/input.txt Expected output: http://www.flownet.com/ron/papers/lisp-java/output.txt Could someone help me to make this code faster? I'd like to see solution that will be elegant and fast, without heavy optimizations, that will make code unreadable. Also, if it possible, prepare the program to support SMP parallelism. Very thanks in advance. Hope you'll enjoy this task :) -- Best regards, Bulatmailto:bulat.zigans...@gmail.com -- Best regards, Vasyl Pasternak ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell
Excerpts from Henning Thielemann's message of Sun Mar 22 22:52:48 +0100 2009: On Sun, 22 Mar 2009, nicolas.pouillard wrote: Excerpts from Henning Thielemann's message of Sat Mar 21 22:27:08 +0100 2009: Maybe you know of my packages lazy-io and explicit-exception which also aim at lazy I/O and asynchronous exception handling. I was indeed aware of these two packages but I think they hold orthogonal ideas. About the lazy-io package, as explained in the documentation one has to carefully choose which operations can be lifted. In safe-lazy-io I try to choose a set of well behaving combinators to replace 'getContents' in the IO monad. Moreover if I take the three problems of standard lazy IO in turn: 1/ Control of resources: One advantage over standard lazy IO is that the file opening can also be done lazily, avoiding an immediate resource exhaustion. However one still relies on evaluation and garbage collection to take care of closing handles, which is not satisfying since handles are scarce resources. 2/ Control of exceptions: If one writes a 'getContents' function such that it no longer hides I/O errors during reading, how do you guarantee that exceptions will happen during the LazyIO.run and not after? Currently I cannot guarantee anything. However my idea is to stay away from built-in exceptions in IO. In explicit-exception there is an experimental hidden module which provides an IO monad wrapper called SIO which cannot throw any IO exception. http://code.haskell.org/explicit-exception/src/System/IO/Straight.hs Actually, I think it's the wrong way round to build an exception-free monad on top of one with exceptions. Instead IO should be built on top of SIO, but that's not possible for historical reasons. The only safe operation to get into SIO is ioToExceptionalSIO :: IO a - ExceptionalT IOException SIO a That is, it makes exceptions explicit and SIO operations can never throw IO exceptions. You should convert synchronous explicit exceptions of atomic operations like getChar into asynchronous explicit exceptions, combine them lazily to big operations like getContents. Then you get getContents :: SIO (Asynchronous.Exception IOException String) If you run lazy SIO operations you can't become surprised by exceptions. It sounds like a nice idea, it would be great to have a straight-io package to play a bit more with explicit exceptions in things like 'IO'. For safe-lazy-io I wanted to keep the exception management as light as possible. In particular when writing programs where most of the 'IO' errors are considered fatals---EOF is not fatal of course but using getContents one do not see it. 3/ Determinism: when freely combining multiple inputs one risks the problem mentioned by Oleg [1], when using your package it will depend on the 'getContents' function we use: a) if we 'liftIO' the standard 'getContents' function, we can have the issue. b) if we write a new 'getContents' as below [2], then (if I got right your lazy IO monad) all reads are chained. And then one has to process inputs in the same order. I wouldn't build hClose into getContents, because you never know, whether the file is read until it's end. If you call a LazyIO.getContents twice, the contents are read sequential. In order to read file contents simultaneously you must call (LazyIO.run LazyIO.getContents) twice in the IO monad. Right but one of the purposes of safe-lazy-io is to provides a good management of file handles in particular closing them. Actually the implementation of lazy inputs focus particularly on that---through the 'Finalized' values. http://hackage.haskell.org/packages/archive/safe-lazy-io/0.1/doc/html/src/System-IO-Lazy-Input-Internals.html -- Nicolas Pouillard ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Safe Lazy IO in Haskell
On Sun, 22 Mar 2009, nicolas.pouillard wrote: It sounds like a nice idea, it would be great to have a straight-io package to play a bit more with explicit exceptions in things like 'IO'. Maybe I should then restrict lifting to LazyIO to SIO actions. That would not make LazyIO safe, but reduces surprises. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Sometimes I wish there was a global variable
Maurício wrote: Notice that rotX, rotY and pos are meant to be used as comunication between the keyboardMouse and display functions. They need to be set as 0 first, so display won't do anything. Only when they user press a few buttons that those values change, so display behaves accordanly. In a state-based language I would place display and keyboardMouse in one module and let them communcate to each other like they want. In haskell, I'm not quite sure how to do it except by that parameter passing style. In one module, you can write: -- giveMeFunctions = do { newIORef ... newIORef ... newIORef ... (...) let f1 = ... let f2 = ... return (f1,f2) -- and in the main: (keyboardMouse,display) - giveMeFunctions Doing it like that I could have all the definitions in one module, but it doesn't solve another important problem: keyboardMouse and display functions have to have as many parameters as there are IORefs. In my particular case, since I find out what key the use has pressed through pattern matching, keyboardMouse has several definitions. So adding a new IORef means adding a wildcard parameter to each keyboardMouse definition. As well as a new parameter to the display function. Which looks a bit clumbersome to me. In a state-based language I'd have something in the lines of: switch (key) { case LEFT_KEY : /* using var1 ... */ case RIGHT_KEY : /* using var2 ... */ } then, handling a new case would be a matter of adding a global variable and adding a new case in the end of the function containing the switch. Whereas in Haskell I would have something like keyboard var1 _ LeftKey = ... keyboard _ var2 RightKey = ... If I wanted to add a new IORef I'd have to do something like: keyboard var1 _ _ LeftKey = ... keyboard _ var2 _ RightKey = ... keyboard _ _ var3 RightKey = ... So, I had to change all previous definitions. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Sometimes I wish there was a global variable
On Sun, Mar 22, 2009 at 08:10:28PM -0300, Rafael Cunha de Almeida wrote: Doing it like that I could have all the definitions in one module, but it doesn't solve another important problem: keyboardMouse and display functions have to have as many parameters as there are IORefs. You may always create a new data type. Whereas in Haskell I would have something like keyboard var1 _ LeftKey = ... keyboard _ var2 RightKey = ... If I wanted to add a new IORef I'd have to do something like: keyboard var1 _ _ LeftKey = ... keyboard _ var2 _ RightKey = ... keyboard _ _ var3 RightKey = ... So, I had to change all previous definitions. Initial code: data Vars = Vars {var1 :: {-# UNPACK #-} !(IORef Type1) ,var2 :: {-# UNPACK #-} !(IORef Type2)} keyboard v LeftKey = ... (var1 v) ... keyboard v RightKey = ... (var2 v) ... Modified code: data Vars = Vars {var1 :: {-# UNPACK #-} !(IORef Type1) ,var2 :: {-# UNPACK #-} !(IORef Type2) ,var3 :: {-# UNPACK #-} !(IORef Type3)} keyboard v LeftKey = ... (var1 v) ... -- unchanged keyboard v RightKey = ... (var2 v) ... -- unchanged keyboard v OtherKey = ... (var3 v) ... Note that the UNPACKs aren't really necessary. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Function to cast types
On Sun, 22 Mar 2009, Achim Schneider wrote: Anonymous Anonymous temp.pub...@gmail.com wrote: Hello, I'm new to haskell, I'm wondering how can you write a function that will do the following: fromIntToString :: Int - String this is a cast function to cast an Int to a String. I know such function exist, however let's assume it didn't exist. How would I write such function? I have no Idea, but this one works: intOfChar c | c = '0' c = '9' = fromEnum c - fromEnum '0' intOfChar _ = undefined this is 'digitToInt' from Char module ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ACM Task for C++ and Java programmers in Haskell. How to make code faster?
Vasyl Pasternak wrote: The entire code I placed on http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2764 Could someone help me to make this code faster? I'd like to see solution that will be elegant and fast, without heavy optimizations, that will make code unreadable. Also, if it possible, prepare the program to support SMP parallelism. The solution's already been posted, but to make this particular code faster, I recommend using Data.Trie instead of Data.Map ByteString. Tries are faster for lookup since they don't redundantly check the prefix of the query; also they're better for memory usage because they don't store redundant copies of the prefixes. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Sometimes I wish there was a global variable
On 2009 Mar 22, at 19:10, Rafael Cunha de Almeida wrote: Doing it like that I could have all the definitions in one module, but it doesn't solve another important problem: keyboardMouse and display functions have to have as many parameters as there are IORefs. Or a single argument which holds all IORefs. Or record-style pattern matching: If I wanted to add a new IORef I'd have to do something like: keyboard var1 _ _ LeftKey = ... keyboard _ var2 _ RightKey = ... keyboard _ _ var3 RightKey = ... keyboard {v = var1} LeftKey = ... keyboard {v = var2} RightKey = ... -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: hranker: Basic utility for ranking a list of items (e.g. for the logo poll)
hranker is a fun little command-line utility I have written to help a user rank a list of items (of any type implementing Show, Eq and Ord). I hope the code is sufficiently clear that it could also serve as an educational piece of code, especially for people wanting to learn how to use the HCL library. It is now available on hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hranker Just typing hranker or hranker --help will yield a usage message. Here is an example usage of the program: In the unlikely event that anyone else wants to use it to help them prepare their votes in the Haskell logo poll (which is what I used it for just now), here is what to do: 1. cabal install hranker (or download it and runhaskell Setup.lhs etc.) 2. hranker 113 (because 113 is the number of items in the poll) 3. IMPORTANT: Read the warnings the program prints on startup! 4. To control the program, enter the first character of the command you wish to perform, and then press Enter. The command you have chosen may ask you for further information. Commands generally operate on the next unranked item, apart from annotate (which can operate on ranked or unranked items), remove (which always operates on ranked items), and quit. I recommend you use the annotate command a lot - it is really helpful for this kind of situation where you have a lot of numbered items to rank. If you use the remove command, don't remove *all* ranked items, because if you do you it may terminate. 5. If you rank *everything* somehow (remember, ties are allowed), the program will print an inverse mapping (items to ranks, instead of ranks to items) before terminating. If you choose to quit before that point, you won't get that inverse mapping, unless you explicitly invoke the mapping command. There is obvious room for improvement: apart from fixing the remove bug mentioned above, there is currently no simple way to remove or annotate just *one* item at a rank when multiple items are tied at that rank. Have fun! There are some hilarious entries in the logo poll, if you haven't yet voted. -- Robin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Sometimes I wish there was a global variable
Ok, replying to the list this time. Darn Thunderbird not reading my mind again. Rafael Cunha de Almeida wrote: Maurício wrote: In one module, you can write: -- giveMeFunctions = do { newIORef ... newIORef ... newIORef ... (...) let f1 = ... let f2 = ... return (f1,f2) -- and in the main: (keyboardMouse,display) - giveMeFunctions Doing it like that I could have all the definitions in one module, but it doesn't solve another important problem: keyboardMouse and display functions have to have as many parameters as there are IORefs. I don't think so. I think M means the two functions are closures capturing all the IORefs, i.e. they know which IORefs they refer to. In OO terms, the two functions together are the two methods of an object that contains the IORefs as fields, and you needn't pass those IORefs in. Note that calling giveMeFunctions twice will get you two distinct objects, not the same one twice. -- src/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to send signal from Xmonad to my app?
Hi, I have a little program, which shows a message box when gets 'USR1' signal. This works fine when I `kill -USR1 $PID`. But my code in xmonad.hs does not work. No error throws out. And as I inspected, the pid is right. Only nothing happened in my app. So I wonder what is wrong? 28 , ((mod4Mask, xK_x), sendSignal2PIDinFile sigUSR1 .sidebar.pid) 31 sendSignal2PIDinFile signal pidfile = io $ do 32 pid - readFile pidfile 33 signalProcess signal $ read pid -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe