RE: [Haskell-cafe] Re: Weird ghci behaviour?
| Dan, can you suggest any words we could add to the | documentation that would have prevented you stumbling? | | I guess the thing that would have helped best would have been an error | message like 'x' not in scope, use -fforce-recomp to see all symbols | when running interactively in ghci with a previously compiled top | level module. I agree that an informative error message is worth 100 manual pages. The trouble is that at this stage GHCi doesn't even *know* that 'x' ever existed, because it's not mentioned in the interface file, so it's hard to do even give the error message you suggest. (I forgot to mention that GHCi will let you run code in modules that are only available in compiled form, such as ones from other packages -- there is no source code to consult.) I can think of some other possibilities: (a) It would be possible to record in the .hi file the fact that there originally *was* a top-level 'x', and so produce the message you suggest. But it'd be one more thing to implement, document, and maintain. (b) We could decide *never* to use compiled modules (M.o) for home-package modules, but only for other-package modules. Then at least all the home-package modules would have their names in scope. So the home package would be always interpreted. (The home package is the modules of your current project, not installed as a package.) This'd be pretty easy. (c) The last thing I can think of is that we could *read the source code* for home-package modules M (to find the top-level definitions), but still use the M.o files if they exist (to get faster execution). Then we could produce the message you suggest. If any of this seems important enough to you to be worth doing, would you like to create a feature-request ticket for it, and summarise the discussion and alternatives? Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: let vs. where
John Lato wrote: Hello, I know there are several important differences between let-expressions and where-clauses regarding scoping and the restriction of where to a top-level definition. However, frequently I write code in which either one would be allowed, and I was wondering if there were any guidelines or preferences for one structure over the other. Currently my choice is guided by aesthetics more than anything else ( I prefer the look and ordering of a where clause). Is there anything else I should consider? What do veteran Haskell programmers prefer? I prefer the expression style. And I also like to order my definitions in a file bottom-up (basics first). But it may be more didactic to do it all top-down. Imports should be placed at the bottom of the file then, too. My cent, Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Renaming constructors for readability
Dougal Stanton wrote: I wonder, is there an equivalent of the 'type' keyword for constructors? An example: -- create a pseudo-C pointer type -- which can point to a value or a -- null. type Pointer a = Maybe a -- int a = 3; -- int *pa = a; ampersand :: t - Pointer t ampersand a = Just a -- int b = *pa. star :: Pointer a - a star (Just a) = a -- note this function behaves -- in an 'authentic' fashion ;-) To really complete the illusion it would be nice to replace the names Just and Nothing with PointerTo and Null. Then the constructors would really mean something. Is there a solution? The thing you want is called views. See http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns#Relatedwork for more. Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] let vs. where
Hi Chris, this could be captured nicely in a where clause: exp = (fst blah, snd blah) where blah = gg 1000 But a let would have to be placed in both elements of the tuple exp = (let blah = g 1000 in fst blah, let blah = g 1000 in snd blah) Why not: exp = let blah = g 1000 in (fst blah, snd blah) Where's always get desugared to let's, so where's are never more efficient. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Re: Weird ghci behaviour?
Hello Simon, Wednesday, November 14, 2007, 11:28:23 AM, you wrote: I can think of some other possibilities: (a) It would be possible to record in the .hi file the fact that there originally *was* a top-level 'x', and so produce the message you suggest. But it'd be one more thing to implement, document, and maintain. and this will increase amount of recompilation for large projects (b) We could decide *never* to use compiled modules (M.o) for home-package modules, but only for other-package modules. Then at least all the home-package modules would have their names in scope. So the home package would be always interpreted. (The home package is the modules of your current project, not installed as a package.) This'd be pretty easy. it may be great if such behavior enabled by some option, such as -force-recomp. in many cases, we need to run compiled code inside ghci how about such variant? d) when printing message about undefined symbol, add note about reloading sources: Symbol `x` undefined; if it's a top-level symbol in some loaded module M, please reload this module source-wise: :load M.hs and implement directive :load M.hs as interpreted loading of the module -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] let vs. where
Hi David, A let clause would work fine here: someFunction ls a b c = let listLen = length ls someAuxFunction x y = ... listLen ... someOtherFunction x y = ... listLen ... in ... listLen ... it's just that you don't want to mix let and where clauses, because then things get confusing. Even if it worked with both, noone would know the binding rules. Possibly in that case, but there are cases where I believe they are not the same. For example: gg n = ([1..,10^6*n], [1..10^6*n]) exp = (fst $ gg 1000, snd $ gg 1000) this could be captured nicely in a where clause: exp = (fst blah, snd blah) where blah = gg 1000 But a let would have to be placed in both elements of the tuple - and therefore being evaluated twice (unless the implementation is smart enough to work out they can be shared?): exp = (let blah = g 1000 in fst blah, let blah = g 1000 in snd blah) Kind regards, Chris. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why are OCaml and Haskell being used at these companies?
On Nov 13, 2007 5:03 PM, Laurent Deniau [EMAIL PROTECTED] wrote: snip If your program is written in Java (resp. C) but the JIT is written in C (resp. OCaml), in which language is your code? I'd say it's written in Java. If you have a bug where would you correct it? If someone would like to see the code of your program what would you show him/her? Your Java program is a code that is executed by a (virtual) machine that just happens to delegate most work to another machine. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] let vs. where
Hi Neil, Why not: exp = let blah = g 1000 in (fst blah, snd blah) Yes, fair enough. Where's always get desugared to let's, so where's are never more efficient. Interesting. I'm thinking a where-to-let refactoring and its converse may make useful routine refactorings for HaRe. Cheers, Chris. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More good performance results for ghc 6.8
On Wednesday 14 November 2007 00:14, Don Stewart wrote: Trying out some of the great language shootout programs with ghc 6.8 is producing nice results. For example, our classic cache-hammering, bitwise sieve benchmark is out of the box 10% faster with the new compiler. The (already rather good) benchmark is here (the same speed as the OCaml version under ghc 6.6): http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebitslang=al l And timing with old and new ghc: ghc 6.6.1 Primes up to 8192 4774995 Primes up to 4096 2488465 Primes up to 2048 1299069 ./A66 13 4.50s user 0.02s system 100% cpu 4.515 total ghc 6.8.1 Primes up to 8192 4774995 Primes up to 4096 2488465 Primes up to 2048 1299069 ./A68 13 4.13s user 0.01s system 99% cpu 4.142 total Lovely work GHC HQ, when low level, highly tuned code like this gets magically faster! Once 6.8 is in Gentoo (or earlier...) we should see similar improvements across a range of shootout programs. I get slightly different results on our 2.2GHz Athlon64 X2 machines but they are only up to 20% slower than C++ for OCaml and Haskell: F# 1.9.2.9: 2.125s on 32-bit Windows XP GHC 6.8:1.414s on 64-bit Debian Lenny GHC 6.6:1.387s on 64-bit Debian Lenny OCaml 3.10: 1.278s on 64-bit Debian Lenny g++ 4.2.3: 1.176s on 64-bit Debian Lenny Interestingly, GHC 6.8 does not improve over GHC 6.6 on this machine. Regardless, the performance in absolute terms is incredible (IMHO). Also, I took the liberty of optimizing the OCaml: open Printf open Bigarray let rec clear (a : (int, int8_unsigned_elt, c_layout) Bigarray.Array1.t) n i = let j = ref (2 * i) in while !j = n do let ic = !j lsr 3 in let bit = a.{ic} land lnot(1 lsl (!j land 0x7)) in if a.{ic} bit then a.{ic} - bit; j := !j + i done let nsieve n = let a = Array1.create int8_unsigned c_layout ((n lsr 3) + 2) in Array1.fill a 0xFF; let count = ref 0 in for i = 2 to n do if a.{i lsr 3} land (1 lsl (i land 0x7)) 0 then begin incr count; if i*i = n then clear a n i end done; !count let test n = printf Primes up to %8i %8i\n%! n (nsieve n) let () = match Sys.argv with | [|_; n|] - let n = int_of_string n in List.iter (fun n - if n0 then test ((1 lsl n) * 1)) [n; n-1; n-2] | _ - printf Usage: ./sieve n\n%! -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why are OCaml and Haskell being used at these companies?
Jon Harrop wrote: On Tuesday 13 November 2007 16:03, Laurent Deniau wrote: OCaml was used to write a meta-program which applies heuristics to minimize the runtime of the critical C code (i.e. the butterflies). This has nothing to do with FFT computation No. The sole purpose of the OCaml code is to symbolically simplify the FFT computations and generate C code implementing the best results. Which is not needed by default. 'Standard' codelets are already present in the source distribution and far enough for most uses. I have been installing FFTW on a dozen of archs over the past 10 years and I have never used the OCaml code (in fact I did it once to play with it). FFTW doesn't need any OCaml compiler or lib to be compiled and installed. No. FFTW contains around 13,000 lines of OCaml source code and you need the OCaml compiler to compile that. Yes you need a OCaml compiler to compile the OCaml code. But you don't need the OCaml code to install FFTW, except if you want to generate your own codelets which remains an exceptional case. If you don't believe me, perhaps you will believe Steven G. Johnson (one of the authors of FFTW) when someone tried to tell him that he hadn't written his software in OCaml: http://groups.google.co.uk/group/fa.caml/msg/cfd08423c22ccff5 I am not saying that the FFTW distribution doesn't have OCaml code nor this code is negligeable/useless! I just say that it is useful to build the codelet for unsupported size or to tune them for a given arch. The libfftw itself, the only part meaningful for your program performance and used by MATLAB, is entirely made of compiled C and asm code. Just to quote the doc: [ section 8.4 Generating your own code The directory genfft contains the programs that were used to generate FFTW’s “codelets,” which are hard-coded transforms of small sizes. We do not expect casual users to employ the generator, which is a rather sophisticated program that generates directed acyclic graphs of FFT algorithms and performs algebraic simplifications on them. It was written in Objective Caml, a dialect of ML, which is available at http://pauillac.inria.fr/ocaml/. ] So your assertion the FFT routines in MATLAB (FFTW: written in OCaml) is simply wrong or at least an ambiguous shortcut. MATLAB doesn't run OCaml code in its FFT routines. That OCaml code has millions of industrial users worldwide and is one of the most widely used pieces of software written in a statically typed functional programming language. And OCaml was (still is?) the language learnt by French students in the 90's in the 'classes preparatoires'. At least when I was teaching scientific computing. I am not a language fanatic, so this kind of argument is simply meaningless for me. It is important only if am developing projects with long lifetime, high portability or sparse resources. a+, ld. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Weird ghci behaviour?
Claim: The ghci modulename and :load modulename command are confusing because they have two behaviors. Short form of my proposal: Make two separate commands that each have a predictable behavior. Make ghci modulename default to source loading, and require a flag to load a binary. I don't give a bikeshed what they are called. I don't care if the magic :load stays or goes or ends up with only one behavior. This is different/orthogonal to the .o or .hs file extension sensitive proposal. My arguments: I run into annoyances because I often poke at things in ghci when trying to get my package to compile. So depending on which modules succeeded or failed to compile I get different behavior when loading into ghci. I am no longer confused by this, but just annoyed. I would say that the user gets surprised which leads to feeling that there is a lack of control. The '*' in the '*Main' versus 'Main' prompt is a UI feature for experts, not for new users. Making this more obvious or verbose or better documented does not fix the lack of control the user feels. The only flags that the user can easily find are those listed by --help: chrisk$ ghci --help Usage: ghci [command-line-options-and-input-files] The kinds of input files that can be given on the command-line include: - Haskell source files (.hs or .lhs suffix) - Object files (.o suffix, or .obj on Windows) - Dynamic libraries (.so suffix, or .dll on Windows) In addition, ghci accepts most of the command-line options that plain GHC does. Some of the options that are commonly used are: -fglasgow-exts Allow Glasgow extensions (unboxed types, etc.) -idir Search for imported modules in the directory dir. -H32m Increase GHC's default heap size to 32m -cppEnable CPP processing of source files Full details can be found in the User's Guide, an online copy of which can be found here: http://www.haskell.org/ghc/documentation.html The -fforce-recomp and -fno-force-recomp flags only exist in the User's Guide. Thus they are hard to find. Is there a ticket open for adding at least a list of the recognized flags to ghc and ghci usage messages? Ideally, I want a :load modulename to get the source and a :bin modulename to get the binary (and a :m ... to get the binary). I want ghci modulename to get the source and ghch -bin modulename to get the binary. Simple and predictable and no surprises. Cheers, Chris K ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why are OCaml and Haskell being used at these companies?
well, I generally read more than post on the list, but being in investment banking ( for 20 years), this one is too hard to resist... The kind of job these guys do is highly mathematical ( quantitative analysis) as opposed to traditional banking or Back Offices where th job is (not so clever) record crunching... buying software packge also make little sense for them, because the very nature of the job is to develop new models to play around market inefficiencies, or just against competitors models... if everybody would have the same ( model, package), they would be out of business... time to market is key, reliability too , and the kind of guy they hire ( quant analyst) have the brain to learn new languages , so this is not the same problem as turning an army of cobolist into java. also, the very expressive nature of functiunal programming blends very wells with maths, better than record crunching... if you add on top grid computing and parralelism... ( monte carlo is not only a casino in the south of france. for these guys...) so they are small elite teams..that fits well with visionary products... do not expect it to be a lead to mass expansion for tommorow, these people are already living in a ivory tower compared to their peers retail-bankers... -- View this message in context: http://www.nabble.com/Why-are-OCaml-and-Haskell-being-used-at-these-companies--tf4793477.html#a13744123 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
Re: [Haskell-cafe] Why are OCaml and Haskell being used at these companies?
On Wednesday 14 November 2007 10:55, luc.taesch wrote: do not expect it to be a lead to mass expansion for tommorow... I think the functional programming market is far from saturated though: there are still many inroads to make into areas like technical computing that stand to benefit a lot from functional languages but require unconventional characteristics (like complex literals, vector and matrix routines, visualization etc.). When functional languages achieve these goals I believe the total number of users will increase dramatically as scientists and engineers adopt them alongside their standard tools. Bioinformaticians are among the first to adopt functional programming languages but I believe more mainstream natural sciences will follow. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Weird ghci behaviour?
I was also bitten by this. I consider it to be a serious problem with the UI for ghci. My vote is: o The default should be to make all symbols available whenever possible. o It should be easy for experts, like Aaron Denney, to get the current behavior. (E.g., a flag, that can be turned on or off at the ghci command, during a session, or as the local default in dot-ghci.) o Whenever it is not possible to make all symbols available, give the user a clear warning. I don't think it's necessary to go overboard with details in the warning. A simple, clear, generic warning at load time is enough. For example: If we looked for the source code and did not find it, this might be a beginner who accidentally deleted it. So we say: Module 'Foo' loaded. Warning: Source code not found for 'Foo', so only its exported symbols are available. If it was requested, we say: Module 'Foo' loaded. Only the compiled module was loaded, as requested, so only its exported symbols are available. So someone who requested this in error will realize that. Experts should be able to turn off this message - but not the previous one - and rely upon the subtle hint in the command prompt. These give enough information that anyone who gets into the wrong situation by mistake will know (or be able to figure out) exactly what happened. Thanks, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Screen scraping with an interactive process: Buffering problems?
On Nov 7, 2007 4:44 PM, David Benbennick [EMAIL PROTECTED] wrote: And once you do hGetContents, you have read all the data that will ever exist on that handle, so there's nothing to read from it later on. I completely misunderstood how hGetContents works. This now makes sense. I first thought hGetContents would return everything you could read from the stream right now as a string. From reading the the haddock documentation for System.IO.hGetContents, I failed to understand that the string it returns will contain characters that haven't even been written to the (interactive) stream by the time of the call to hGetContents. I'm not sure if the hGetContents documentation could easily be made to make that fact more salient, but I'd be willing to submit a patch, if other people have been confused. Assuming that each call to ACL2 produces exactly one of either Proof succeeded or attempt has failed, you can get a list of results like this (where aclOutput :: String is the result of hGetContents): let results = map (\l - if l == Proof succeeded then True else False) $ filter (\l - elem l [Proof succeeded, attempt has failed]) $ lines aclOutput Then results :: [Bool], and results !! n is True if the nth call succeeded. Just make sure not to inspect results !! n until after making the nth call to ACL2, or it will block. I used a minor modification of this approach (Proof succeeded is not on a line by itself), and it worked famously. Thanks for the help, David! -- Denis ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Weird ghci behaviour?
On Nov 14, 2007, at 3:28 , Simon Peyton-Jones wrote: I agree that an informative error message is worth 100 manual pages. The trouble is that at this stage GHCi doesn't even *know* that 'x' ever existed, because it's not mentioned in the interface file, so it's hard to do even give the error message you suggest. Not really. Include the hint on the first symbol not found error after loading a binary module as a Perhaps you need to -fforce- recomp?; it doesn't really matter if it turns out the symbol-not- found was actually e.g. a typo. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Renaming constructors for readability
Henning Thielemann wrote: On Tue, 13 Nov 2007, Dougal Stanton wrote: On 13/11/2007, Henning Thielemann [EMAIL PROTECTED] wrote: On Tue, 13 Nov 2007, Dougal Stanton wrote: -- int a = 3; -- int *pa = a; ampersand :: t - Pointer t ampersand a = Just a What's bad about using 'ampersand' function as replacement for the constructor 'Just'? I also wanted to use it in pattern matching but have the advantage of all the stuff already written for Maybe. No problem, write a function like 'maybe' to inspect the data. Instead of 'f m' with f :: Maybe T - S f (Just x) = g x f Nothing = h Yes. It is a problem. Do you write all your code using higher-order functions, never matching explicitly on constructors? I don't. Matching explicitly on constructors is an elegant and easy-to-read way to write programs. It's annoying to have to choose between (a) nicely named constructors and (b) being able to re-use library functions defined for Maybe. Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Renaming constructors for readability
On Wed, 14 Nov 2007, Jules Bean wrote: Henning Thielemann wrote: No problem, write a function like 'maybe' to inspect the data. Instead of 'f m' with f :: Maybe T - S f (Just x) = g x f Nothing = h Yes. It is a problem. Do you write all your code using higher-order functions, never matching explicitly on constructors? I don't. I do it more and more, because it let me switch the underlying data structure more easily. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why are OCaml and Haskell being used at these companies?
Jon Harrop wrote: When functional languages achieve these goals I believe the total number of users will increase dramatically as scientists and engineers adopt them alongside their standard tools. Bioinformaticians are among the first to adopt functional programming languages but I believe more mainstream natural sciences will follow. FWIW, a few years ago, when I was stubbornly unemployed[*], I wrangled a fifteen-minute informational interview with Kenan Sahin[**]. He advised me to look for work related to medical devices, on the grounds that as the US population got older there would be greater and greater demand for medical equipment, and software is becoming a more and more important component of these devices. [*] I had been working for Whitehead on the Human Genome Project, thinking that an academic job would be the perfect place to ride out the dot-com crash. Then they finished sequencing the human genome and didn't need so many programmers. So much for academic job security. [**] Sahin had founded of a company that I had worked for, which he had sold to Lucent for 1.5 gigabucks shortly *before* the dot-com crash. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal problem?
I have problems building X11. I just installed ghc 6.8 but I got the same behaviour when asking it to use the old compiler. Jens runghc Setup.hs configure Configuring X11-1.3.0.2007... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -E checking for X... libraries /usr/X11R6/lib64, headers /usr/X11R6/include checking for gethostbyname... yes checking for connect... yes checking for remove... yes checking for shmat... yes checking for IceConnectionNumber in -lICE... yes checking whether to build Xinerama... yes checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking X11/extensions/Xinerama.h usability... yes checking X11/extensions/Xinerama.h presence... yes checking for X11/extensions/Xinerama.h... yes configure: creating ./config.status config.status: creating config.mk config.status: creating X11.buildinfo config.status: creating include/HsX11Config.h config.status: include/HsX11Config.h is unchanged config.status: creating include/X11_extras_config.h config.status: include/X11_extras_config.h is unchanged runghc Setup.hs build Preprocessing library X11-1.3.0.2007... Building X11-1.3.0.2007... [ 1 of 17] Compiling Graphics.X11.Xlib.Types ( dist/build/Graphics/X11/Xlib/Types.hs, dist/build/Graphics/X11/Xlib/Types.o ) [ 2 of 17] Compiling Graphics.X11.Types ( dist/build/Graphics/X11/Types.hs, dist/build/Graphics/X11/Types.o ) [ 3 of 17] Compiling Graphics.X11.Xlib.Atom ( dist/build/Graphics/X11/Xlib/Atom.hs, dist/build/Graphics/X11/Xlib/Atom.o ) [ 4 of 17] Compiling Graphics.X11.Xlib.Color ( Graphics/X11/Xlib/Color.hs, dist/build/Graphics/X11/Xlib/Color.o ) [ 5 of 17] Compiling Graphics.X11.Xlib.Context ( Graphics/X11/Xlib/Context.hs, dist/build/Graphics/X11/Xlib/Context.o ) [ 6 of 17] Compiling Graphics.X11.Xlib.Display ( Graphics/X11/Xlib/Display.hs, dist/build/Graphics/X11/Xlib/Display.o ) [ 7 of 17] Compiling Graphics.X11.Xlib.Event ( dist/build/Graphics/X11/Xlib/Event.hs, dist/build/Graphics/X11/Xlib/Event.o ) [ 8 of 17] Compiling Graphics.X11.Xlib.Font ( dist/build/Graphics/X11/Xlib/Font.hs, dist/build/Graphics/X11/Xlib/Font.o ) [ 9 of 17] Compiling Graphics.X11.Xlib.Misc ( dist/build/Graphics/X11/Xlib/Misc.hs, dist/build/Graphics/X11/Xlib/Misc.o ) [10 of 17] Compiling Graphics.X11.Xlib.Region ( Graphics/X11/Xlib/Region.hs, dist/build/Graphics/X11/Xlib/Region.o ) [11 of 17] Compiling Graphics.X11.Xlib.Screen ( Graphics/X11/Xlib/Screen.hs, dist/build/Graphics/X11/Xlib/Screen.o ) [12 of 17] Compiling Graphics.X11.Xlib.Window ( Graphics/X11/Xlib/Window.hs, dist/build/Graphics/X11/Xlib/Window.o ) [13 of 17] Compiling Graphics.X11.Xlib.Image ( Graphics/X11/Xlib/Image.hs, dist/build/Graphics/X11/Xlib/Image.o ) [14 of 17] Compiling Graphics.X11.Xlib ( Graphics/X11/Xlib.hs, dist/build/Graphics/X11/Xlib.o ) [15 of 17] Compiling Graphics.X11.Xlib.Extras ( dist/build/Graphics/X11/Xlib/Extras.hs, dist/build/Graphics/X11/Xlib/Extras.o ) Warning: orphan instances: instance base:GHC.Read.Read [ X11-1.3.0.2007:Graphics.X11.Xlib.Types.Rectangle] = $f1 [16 of 17] Compiling Graphics.X11.Xinerama ( dist/build/Graphics/X11/Xinerama.hs, dist/build/Graphics/X11/Xinerama.o ) [17 of 17] Compiling Graphics.X11 ( Graphics/X11.hs, dist/build/Graphics/X11.o ) /usr/bin/ar: creating dist/build/libHSX11-1.3.0.2007.a sudo runghc Setup.hs install root's password: Setup.hs: Warning: Unknown field 'build-type' Setup.hs: error reading ./.setup-config; run setup configure command? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal problem?
jens.blanck: I have problems building X11. I just installed ghc 6.8 but I got the same behaviour when asking it to use the old compiler. Jens runghc Setup.hs configure Configuring X11-1.3.0.2007... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -E checking for X... libraries /usr/X11R6/lib64, headers /usr/X11R6/include checking for gethostbyname... yes checking for connect... yes checking for remove... yes checking for shmat... yes checking for IceConnectionNumber in -lICE... yes checking whether to build Xinerama... yes checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking X11/extensions/Xinerama.h usability... yes checking X11/extensions/Xinerama.h presence... yes checking for X11/extensions/Xinerama.h... yes configure: creating ./config.status config.status: creating [1]config.mk config.status: creating X11.buildinfo config.status: creating include/HsX11Config.h config.status: include/HsX11Config.h is unchanged config.status: creating include/X11_extras_config.h config.status: include/X11_extras_config.h is unchanged runghc Setup.hs build Preprocessing library X11-1.3.0.2007... Building X11-1.3.0.2007... [ 1 of 17] Compiling Graphics.X11.Xlib.Types ( dist/build/Graphics/X11/Xlib/Types.hs, dist/build/Graphics/X11/Xlib/Types.o ) [ 2 of 17] Compiling Graphics.X11.Types ( dist/build/Graphics/X11/Types.hs, dist/build/Graphics/X11/Types.o ) [ 3 of 17] Compiling Graphics.X11.Xlib.Atom ( dist/build/Graphics/X11/Xlib/Atom.hs, dist/build/Graphics/X11/Xlib/Atom.o ) [ 4 of 17] Compiling Graphics.X11.Xlib.Color ( Graphics/X11/Xlib/Color.hs, dist/build/Graphics/X11/Xlib/Color.o ) [ 5 of 17] Compiling Graphics.X11.Xlib.Context ( Graphics/X11/Xlib/Context.hs, dist/build/Graphics/X11/Xlib/Context.o ) [ 6 of 17] Compiling Graphics.X11.Xlib.Display ( Graphics/X11/Xlib/Display.hs, dist/build/Graphics/X11/Xlib/Display.o ) [ 7 of 17] Compiling Graphics.X11.Xlib.Event ( dist/build/Graphics/X11/Xlib/Event.hs, dist/build/Graphics/X11/Xlib/Event.o ) [ 8 of 17] Compiling Graphics.X11.Xlib.Font ( dist/build/Graphics/X11/Xlib/Font.hs, dist/build/Graphics/X11/Xlib/Font.o ) [ 9 of 17] Compiling Graphics.X11.Xlib.Misc ( dist/build/Graphics/X11/Xlib/Misc.hs, dist/build/Graphics/X11/Xlib/Misc.o ) [10 of 17] Compiling Graphics.X11.Xlib.Region ( Graphics/X11/Xlib/Region.hs, dist/build/Graphics/X11/Xlib/Region.o ) [11 of 17] Compiling Graphics.X11.Xlib.Screen ( Graphics/X11/Xlib/Screen.hs, dist/build/Graphics/X11/Xlib/Screen.o ) [12 of 17] Compiling Graphics.X11.Xlib.Window ( Graphics/X11/Xlib/Window.hs, dist/build/Graphics/X11/Xlib/Window.o ) [13 of 17] Compiling Graphics.X11.Xlib.Image ( Graphics/X11/Xlib/Image.hs, dist/build/Graphics/X11/Xlib/Image.o ) [14 of 17] Compiling Graphics.X11.Xlib ( Graphics/X11/Xlib.hs, dist/build/Graphics/X11/Xlib.o ) [15 of 17] Compiling Graphics.X11.Xlib.Extras ( dist/build/Graphics/X11/Xlib/Extras.hs, dist/build/Graphics/X11/Xlib/Extras.o ) Warning: orphan instances: instance base:GHC.Read.Read [X11-1.3.0.2007:Graphics.X11.Xlib.Types.Rectangle] = $f1 [16 of 17] Compiling Graphics.X11.Xinerama ( dist/build/Graphics/X11/Xinerama.hs, dist/build/Graphics/X11/Xinerama.o ) [17 of 17] Compiling Graphics.X11 ( Graphics/X11.hs, dist/build/Graphics/X11.o ) /usr/bin/ar: creating dist/build/libHSX11-1.3.0.2007.a sudo runghc Setup.hs install root's password: Setup.hs : Warning: Unknown field 'build-type' Setup.hs: error reading ./.setup-config; run setup configure command? I'm not sure what's going on here: I just ran runhaskell Setup.hs install myself and got the same error: $ runhaskell Setup.hs install Setup.hs: error reading dist/setup-config; run setup configure command? Rerunning the configure/build/install process fixed it. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal problem?
On Wed, 2007-11-14 at 16:16 +, Jens Blanck wrote: sudo runghc Setup.hs install root's password: Setup.hs : Warning: Unknown field 'build-type' Setup.hs: error reading ./.setup-config; run setup configure command? I suspect your path is different for your root user, so it's picking up an old ghc and an old cabal version. You can tell it's an old version (probably 1.1.x) because it doesn't know about the new build-type field. You can work around it using: ghc --make Setup.hs -o setup sudo ./setup install Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Brazilian Haskellers ?
Hi brazilian haskellers, How about trying to form a HUG-BR ? Maybe even something along the lines of FringeDC (http://www.lisperati.com/fringedc.html). I only know about 4 people that would join the cause, that's why I'm recruiting ;-) Feel free to contact me (I'm posting this from the Nabble interface, so I'm not sure my e-mail will show up ... just in case: [EMAIL PROTECTED]) -- Ricardo Guimarães Herrmann In a concurrent world, imperative is the wrong default! -- Tim Sweeney (Epic Games) -- View this message in context: http://www.nabble.com/Brazilian-Haskellers---tf4806561.html#a13751455 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
Re: [Haskell-cafe] Brazilian Haskellers ?
Just created: http://groups.google.com/group/hug-br Ricardo Herrmann wrote: Hi brazilian haskellers, How about trying to form a HUG-BR ? Maybe even something along the lines of FringeDC (http://www.lisperati.com/fringedc.html). I only know about 4 people that would join the cause, that's why I'm recruiting ;-) Feel free to contact me (I'm posting this from the Nabble interface, so I'm not sure my e-mail will show up ... just in case: [EMAIL PROTECTED]) -- Ricardo Guimarães Herrmann In a concurrent world, imperative is the wrong default! -- Tim Sweeney (Epic Games) -- View this message in context: http://www.nabble.com/Brazilian-Haskellers---tf4806561.html#a13751760 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] List of all powers
As part of a solution I'm working on for Project Euler problem 119, I wanted to create an ordered list of all powers of all positive integers (starting with squares). This is what I came up with: powers = ( uniq . map fst . iterate next ) ( 1, ( 0, powertable ) ) powertable = map (\ n - map (\ p - n ^ p ) [ 2 .. ] ) [ 2 .. ] next ( _, ( lim, ps ) ) = ( p, ( lim', ps' ) ) where ( c, p ) = minimumBy ( compare `on` snd ) . zip [ 0 .. lim ] . head . transpose $ ps lim' = lim + ( if c == lim then 1 else 0 ) ( front, b : back ) = splitAt c ps ps' = front ++ ( tail b : back ) -- like the unix utility uniq [] = [] uniq [x] = [x] uniq (x:y:ys) | x == y= uniq (y:ys) | otherwise = x : uniq (y:ys) Basically, think of a grid of numbers, each row is the list of powers for one integer. To find the next power in the sequence, look at the the first number in each row (since that will be the smallest number in the row), up to limit number of rows. The limit is calculated as the number of rows that we've already taken one number from, plus one. This exploits the fact that the row heads are initially ordered. If we use a number from a row, shift that row down to remove the number used. It does pretty well, but I'd welcome any comments, or even suggestions of a completely different algorithm (for this little exercise, or problem 119). Thanks. Kurt Hutchinson ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] List of all powers
On Nov 14, 2007 12:32 PM, Kurt Hutchinson [EMAIL PROTECTED] wrote: As part of a solution I'm working on for Project Euler problem 119, I wanted to create an ordered list of all powers of all positive integers (starting with squares). This is what I came up with: powers = ( uniq . map fst . iterate next ) ( 1, ( 0, powertable ) ) powertable = map (\ n - map (\ p - n ^ p ) [ 2 .. ] ) [ 2 .. ] next ( _, ( lim, ps ) ) = ( p, ( lim', ps' ) ) where ( c, p ) = minimumBy ( compare `on` snd ) . zip [ 0 .. lim ] . head . transpose $ ps lim' = lim + ( if c == lim then 1 else 0 ) ( front, b : back ) = splitAt c ps ps' = front ++ ( tail b : back ) -- like the unix utility uniq [] = [] uniq [x] = [x] uniq (x:y:ys) | x == y= uniq (y:ys) | otherwise = x : uniq (y:ys) Basically, think of a grid of numbers, each row is the list of powers for one integer. To find the next power in the sequence, look at the the first number in each row (since that will be the smallest number in the row), up to limit number of rows. The limit is calculated as the number of rows that we've already taken one number from, plus one. This exploits the fact that the row heads are initially ordered. If we use a number from a row, shift that row down to remove the number used. It does pretty well, but I'd welcome any comments, or even suggestions of a completely different algorithm (for this little exercise, or problem 119). Thanks. The merging can be done much more simply and efficiently (this is code I wrote when computing squarefree numbers in a blog posthttp://byorgey.wordpress.com/2007/09/01/squarefree-numbers-in-haskell/a few months ago): -- merge two nondecreasing lists. ( # ) :: (Ord a) = [a] - [a] - [a] [] # ys = ys xs # [] = xs xs@(x:xt) # ys@(y:yt) | x y = x : (xt # ys) | x y = y : (xs # yt) | otherwise = x : (xt # yt) -- merge an infinite list of lists, assuming that each list -- is nondecreasing and the lists occur in order of their first -- element. mergeAll :: (Ord a) = [[a]] - [a] mergeAll ([] : zs) = mergeAll zs mergeAll (xxs@(x:xs) : yys@(y:ys) : zs) | x y = x : mergeAll (xs : yys : zs) | otherwise = mergeAll ((xxs # yys) : zs) Then you can simply define powers = 1 : mergeAll powertable I wrote some code to sum the first n powers and print the result, and compiled (using -O2) first with your method, then with mergeAll. Summing the first 7000 powers took ~8s and ~0.1s respectively, so that's a pretty big speedup. Based on seeing how the times scale, I suspect that your code is O(n^2) or something of that sort, whereas mergeAll is essentially linear, although without scrutinizing your code more closely I'm not exactly sure why that would be the case. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Brazilian Haskellers ?
Hallo, Rich Neswold escreveu: On Nov 14, 2007 10:59 AM, Ricardo Herrmann [EMAIL PROTECTED] wrote: Hi brazilian haskellers, Wow! I knew the Haskell community has been growing... but there's a brazillian of us? Well, we are more than one. :-) Cheers, -alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Brazilian Haskellers ?
Alex Sandro Queiroz e Silva writes: Rich Neswold escreveu: On Nov 14, 2007 10:59 AM, Ricardo Herrmann [EMAIL PROTECTED] wrote: Hi brazilian haskellers, Wow! I knew the Haskell community has been growing... but there's a brazillian of us? Well, we are more than one. :-) Cheers, -alex Nos somos todos Brasileiros. Ou quase... Jerzy Karczmarczuk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Brazilian Haskellers ?
Hi brazilian haskellers, Wow! I knew the Haskell community has been growing... but there's a brazillian of us? -- Rich A mini UN, that's us. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] List of all powers
On Wed, 14 Nov 2007, Kurt Hutchinson wrote: As part of a solution I'm working on for Project Euler problem 119, I wanted to create an ordered list of all powers of all positive integers (starting with squares). This is what I came up with: powers = ( uniq . map fst . iterate next ) ( 1, ( 0, powertable ) ) powertable = map (\ n - map (\ p - n ^ p ) [ 2 .. ] ) [ 2 .. ] iterate (n*) (n^2) should be much more efficient. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Brazilian Haskellers ?
rherrmann: Hi brazilian haskellers, How about trying to form a HUG-BR ? Maybe even something along the lines of FringeDC (http://www.lisperati.com/fringedc.html). I only know about 4 people that would join the cause, that's why I'm recruiting ;-) Feel free to contact me (I'm posting this from the Nabble interface, so I'm not sure my e-mail will show up ... just in case: [EMAIL PROTECTED]) Added to: http://haskell.org/haskellwiki/User_groups ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Brazilian Haskellers ?
Thanks. I also put in that page a link pointing to the haskellers map in Frappr, in order to encourage new HUGs. I believe most of us are lazy enough (in the good Haskell way) to plot them in xearth ;-) Don Stewart-2 wrote: rherrmann: Hi brazilian haskellers, How about trying to form a HUG-BR ? Maybe even something along the lines of FringeDC (http://www.lisperati.com/fringedc.html). I only know about 4 people that would join the cause, that's why I'm recruiting ;-) Feel free to contact me (I'm posting this from the Nabble interface, so I'm not sure my e-mail will show up ... just in case: [EMAIL PROTECTED]) Added to: http://haskell.org/haskellwiki/User_groups ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- View this message in context: http://www.nabble.com/Brazilian-Haskellers---tf4806561.html#a13754985 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
Re: [Haskell-cafe] List of all powers
On Nov 14, 2007 1:06 PM, Brent Yorgey [EMAIL PROTECTED] wrote: On Nov 14, 2007 12:32 PM, Kurt Hutchinson [EMAIL PROTECTED] wrote: The merging can be done much more simply and efficiently (this is code I wrote when computing squarefree numbers in a blog post a few months ago): Wow, thanks for the tip. That really is a huge speed-up. I attempted something like this, but just tried doing a fold of the simple merge over the list of lists. That didn't work (not lazy enough?), which is what sent me down the complicated path above. Kurt ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] List of all powers
On Nov 14, 2007 2:57 PM, Kurt Hutchinson [EMAIL PROTECTED] wrote: On Nov 14, 2007 1:06 PM, Brent Yorgey [EMAIL PROTECTED] wrote: On Nov 14, 2007 12:32 PM, Kurt Hutchinson [EMAIL PROTECTED] wrote: The merging can be done much more simply and efficiently (this is code I wrote when computing squarefree numbers in a blog post a few months ago): Wow, thanks for the tip. That really is a huge speed-up. I attempted something like this, but just tried doing a fold of the simple merge over the list of lists. That didn't work (not lazy enough?), which is what sent me down the complicated path above. Exactly. A standard fold of merges will never get around to generating any elements, since it must inspect the first element of each of the (infinitely many) lists in order to decide which is the smallest. Of course, this doesn't take advantage of the fact that the lists are guaranteed to be ordered in nondecreasing order of their first elements. mergeAll takes advantage of this by producing as many elements from the head of the first list as possible before merging. The fact that the lists are ordered by first element means that any elements from the first list which are less than the head of the second list are guaranteed to be less than everything else, and can be immediately produced as the beginning of the output list, without inspecting any more of the input lists. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: List of all powers
Brent Yorgey wrote: Kurt Hutchinson wrote: As part of a solution I'm working on for Project Euler problem 119, I wanted to create an ordered list of all powers of all positive integers (starting with squares). The merging can be done much more simply and efficiently (this is code I wrote when computing squarefree numbers in a blog posthttp://byorgey.wordpress.com/2007/09/01/squarefree-numbers-in-haskell/a few months ago): -- merge two nondecreasing lists. ( # ) :: (Ord a) = [a] - [a] - [a] [] # ys = ys xs # [] = xs xs@(x:xt) # ys@(y:yt) | x y = x : (xt # ys) | x y = y : (xs # yt) | otherwise = x : (xt # yt) -- merge an infinite list of lists, assuming that each list -- is nondecreasing and the lists occur in order of their first -- element. mergeAll :: (Ord a) = [[a]] - [a] mergeAll ([] : zs) = mergeAll zs mergeAll (xxs@(x:xs) : yys@(y:ys) : zs) | x y = x : mergeAll (xs : yys : zs) | otherwise = mergeAll ((xxs # yys) : zs) Then you can simply define powers = 1 : mergeAll powertable I wrote some code to sum the first n powers and print the result, and compiled (using -O2) first with your method, then with mergeAll. Summing the first 7000 powers took ~8s and ~0.1s respectively, so that's a pretty big speedup. Based on seeing how the times scale, I suspect that your code is O(n^2) or something of that sort, whereas mergeAll is essentially linear, although without scrutinizing your code more closely I'm not exactly sure why that would be the case. In principle, both Kurt's and even your mergeAll are O(n^2), but that depends on the actual distribution of the numbers in the powertable. In both cases, the optimization over a naive implementation is to increase the number of rows to be considered only if the next output came from the last row. This is ok since of the last row, only the head element was considered so far and the non-considered elements all have to be bigger than this. Kurt's code is slower because it takes the minimum over _all_ the considered rows at every step. This is unnecessary since only one element changed, many comparisons can be cached. In other words, this calls for a heap. Brent's code does not produce a heap, but I it's still able to cache lots of comparisons. Kurt may want to transpose the powertable to 2^2 3^2 4^2 5^2 .. 2^3 3^3 4^3 5^3 .. 2^4 3^4 4^4 .. .. instead of the current 2^2 2^3 2^4 2^5 .. 3^2 3^3 3^4 3^5 .. 4^2 4^3 4^4 .. .. since the first elements of the rows of the former grows far steeper than the ones of the latter. This means that only few rows are to be considered each turn. However, Brent may not want to transpose the powertable since the steep increase in every single row (as opposed to across rows) is exactly what makes his code fast. During evaluation, his tower of calls to # will compare something like the following numbers: 2^5 3^4 4^3 5^2 Thanks the form of the tower, the comparisons of the first elements are cached. It looks like mergeAll $ (2^5:(__ # 3^4:__) # 4^3:__) : (5^2:xs) : __ The winner is 5^2 and mergeAll will proceeds by expecting the head of xs . But this one will first be compared to 2^5 = minimum [2^5,3^4,4^3] that's what I mean with cached. Similarly, the winner 3^4 = minimum [2^5,3^4] is cached, too. In other words, the minimum of every initial segment of the numbers considered is cached. The crucial point now is that those initial numbers quickly become very large (2^7 jumps exponentially to 2^8 and so on) and the winners are mostly to be found at the end of the list. With the caching, this is cheap to check. If Brent were to transpose the powertable , winners are more to the front of the list and the caching is useless, most likely rendering his implementation inferior to Kurt's one. Now, back to the heap and O(n*log n). There is no need to use an explicit heap data structure, it's possible to arrange the merges to form an implicit heap, i.e. using the best form of caching. Here's an explanation of the technique with mergesort http://www.mail-archive.com/[EMAIL PROTECTED]/msg19980.html (Hm, does gmane gradually forget old messages?). The only problem is to make this work on an infinite list. Dave Bayer discovered a great way to do this, here's an explanation http://thread.gmane.org/gmane.comp.lang.haskell.cafe/26426/focus=26493 Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Brazilian Haskellers ?
On Nov 14, 2007 4:38 PM, [EMAIL PROTECTED] wrote: Nos somos todos Brasileiros. Ou quase... Falou e disse! =) I'm giving some Haskell classes based on the Wikibook to some of my friends at the university (I think I've said something about it before), and they're very very excited. I'll point them to this new list. BTW, here's our group http://groups.google.com/group/haskell-unb . Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: List of all powers
apfelmus, does someone pay you to write so many thorough, insightful and well-explained analyses on haskell-cafe? I'm guessing the answer is 'no', but clearly someone should! =) thanks! -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: List of all powers
On 11/14/2007 03:19 PM,, Brent Yorgey wrote: apfelmus, does someone pay you to write so many thorough, insightful and well-explained analyses on haskell-cafe? I'm guessing the answer is 'no', but clearly someone should! =) Agreed. I really look forward to apfelmus' consistently outstanding explanations on haskell-cafe. If some of the especially good ones were bundled up as book -- *Intermediate/Advanced Functional Programming with Haskell* -- I would buy it sight unseen (hint, hint). -calvin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: List of all powers
byorgey: apfelmus, does someone pay you to write so many thorough, insightful and well-explained analyses on haskell-cafe? I'm guessing the answer is 'no', but clearly someone should! =) Having met apfelmus last month in Freiburg I can inform the cafe that he is thorough and insightful not just in writing, but in person too :) -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What is the role of $!?
Hi What is the role of $! ? As far as I can gather it's something to do with strict application. Could someone explain what it is meant by the term strict application please? Thanks, Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the role of $!?
It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is not strictly evaluated (i.e., f x) I don't believe. Justin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the role of $!?
On Nov 14, 2007 4:27 PM, Justin Bailey [EMAIL PROTECTED] wrote: It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is not strictly evaluated (i.e., f x) I don't believe. Unless you mean f -- which I still don't think would do much -- it wouldn't make sense to evaluate (f x) strictly. (x `seq` x) is equivalent to (x), for any x (including (f x)). (Right?) Shachaf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the role of $!?
On Wed, 2007-11-14 at 16:27 -0800, Justin Bailey wrote: It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is not strictly evaluated (i.e., f x) I don't believe. Application is strict so f is forced and id is strict so f x is forced. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the role of $!?
On 14 Nov 2007, at 4:32 PM, Shachaf Ben-Kiki wrote: On Nov 14, 2007 4:27 PM, Justin Bailey [EMAIL PROTECTED] wrote: It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is not strictly evaluated (i.e., f x) I don't believe. Unless you mean f -- which I still don't think would do much -- it wouldn't make sense to evaluate (f x) strictly. Right. (f x) evaluates f and then applies it to x. (f $! x) evaluates x, evaluates f, and then applies f to x. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: some links broken in 6.8.1 documentation
Hi Daniil, On Mon, Nov 12, 2007 at 07:56:23PM +0300, Daniil Elovkov wrote: Do I understand it right that the idea of the split was letting all packages (possibly apart from base) emerge more or less independently from ghc releases? It's possible to install a newer version of a bootlib, and for all the libraries other than base and ghc it ought to be easy. So, can package version numbers increase under the same 6.8.1 directory over time? And, if a package is updated between two ghc releases, will the extralibs tarball be updated (and precompiled binary ghc packages, for that matter) ? We won't be making updated 6.8.1 bindists (or Windows installers). Bindists (and the Windows installer) for other releases in the 6.8 branch may well contain different versions of some extralibs, and some extralibs may be added to or removed from the set included. We make very few promises about extralibs, and we don't consider them part of the release. Thanks Ian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] why PArr slower than list ?
I read the GHC/Data Parallel Haskell/GHC.PArr page http://haskell.org/haskellwiki/Data_Parallel_Haskell/GHC.PArr and make a simple test to compare the speed of PArr against List: {-# OPTIONS -fparr -fglasgow-exts #-} module Main where import GHC.PArr import System.CPUTime dotp :: Num a = [:a:] - [:a:] - a dotp xs ys = sumP [:x * y | x - xs | y - ys:] main = do t1 - getCPUTime print $ sum [x*y|x-[1..9]|y-[1..9]] t2 - getCPUTime print $ dotp [:1..9:] [:1..9:] t3 - getCPUTime print $ t2 - t1 print $ t3 - t2 and I get the result: *Main main 243004050015000 243004050015000 38454000 170184100 My laptop is macbook macosx 10.4.8 and ghc-6.8 , anything wrong or I missed ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why PArr slower than list ?
On Nov 14, 2007, at 21:50 , Albert Lee wrote: dotp :: Num a = [:a:] - [:a:] - a You're forcing Num a = a here, whereas the list one probably specializes to Integer. Seems like a bad way to go to me; polymorphism is expensive. (Whether it's *that* expensive, I couldn't tell you.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why PArr slower than list ?
Albert Lee: I read the GHC/Data Parallel Haskell/GHC.PArr page http://haskell.org/haskellwiki/Data_Parallel_Haskell/GHC.PArr and make a simple test to compare the speed of PArr against List: On the wiki page GHC.PArr is described under the heading Convenience without the speed. You'd usually still expect it not to be slower than lists. However, lists are optimised by GHC (buildr/fold fusion), where the implementation of GHC.PArr at this point is complete naive. Manuel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Flymake Haskell
Dear Stefan and Haskell-Cafe, Thanks to keeping your interest to the flymake-mode for Haskell. Stefan wrote: Could you explain to me what flycheck_haskell.pl does, and give an example of a problematic situation solved by the use of flycheck_haskell.pl. Sure. The perl script flycheck_haskell.pl, which is presented at EmacsWiki, http://www.emacswiki.org/cgi-bin/emacs/FlymakeHaskell edits the warning and error messages as an one line from the output of ghc. Now I'll describe how to solve the perl script the problem for using the flymake-mode with ghc. Here is an example of an error message by ghc. Foo.hs:4:4: No instance for (Num Char) arising from the literal `0' at Foo.hs:4:4 Possible fix: add an instance declaration for (Num Char) In the expression: 0 In the definition of `i': i = 0 where the Foo.hs has an explicit error as follows: module Foo where i :: Char -- a type error here i = 0 The perl script removes newlines and white spaces from the error message from ghc and then print it as follows (long one line): Foo.hs:4:4: No instance for (Num Char) arising from the literal `0'... The reason why I needed the perl script is that the current flymake-mode assumes that the syntax checker must print warning/error messages as an 'one' line for each and the message must have the following information: - filename(required) - line number (required) - column number (optional) - warning/error message (required) The above requirement is the problem when we meet to use flymake-mode with ghc alone. If you want to know the detail about the original flymake-mode, please read the definition of two functions - 'flymake-parse-err-lines - 'flymake-parse-line instead of asking me more further. I'm a pragmatic programmer who knows a few about EmacsLisp and can't explain the flymake-mode clearly. However, I greatly appreciate any discussion about the flymake-mode for Haskell here. Note that it will not work in the future, since the flymake-mode has been developed so actively. Huh? Where? I forgot to write the following sentence in the previous email: the flymake-mode has been developed so actively at not the official site http://flymake.sourceforge.net/ but http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/progmodes/flymake.el The latest changes had done on 2 weeks and 4 days ago. I would like to thank Don Stewart for his kindly comments on IRC and that he introduced Flymake Emacs at the latest Haskell news. Gwern Branwen helps me a lot and add a section about Flymake Haskell to the Haskell wiki. http://haskell.org/haskellwiki/Haskell_mode_for_Emacs I would like to thank also anonymous reviewers on EmacsWiki. Best wishes, ike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Using Data.Binary for compression
Hi, I'd like to be able to use Data.Binary (or similar) for compression. Say I have an abstract type Symbol, and for each value of Symbol I have a representation in terms of some number of bits. For compression to be efficient, commonly-used Symbols should have very short representations, while less common ones can be longer. Since an encoding like [Bool] would be really inefficient for this (at least I think it would, though some fancy fusion tricks might be able to help), I was thinking a reasonable approach might be to use Word8 (for example), and then specify a number of bits n, indicating that only the first n bits are to be written to the compressed representation. I was looking at the internals of Data.Binary, and saw it seems that PutM could be used for this purpose (was something like this its original purpose?). Today, I put this together: type BitRep = Word8 type NBits = Int type MyBits = (BitRep, NBits) (#) :: MyBits - MyBits - PutM MyBits (a, m) # (b, n) = case (a .|. (b `shiftR` m), m + n) of ans@(ab, s) - if s 8 then return ans else putWord8 ab return (b `shiftL` (8 - m), s - 8) Then, it would be easy enough to map [Symbol] - [MyBits], and then use something like foldM (#) to get into the PutM monad. A couple of questions: (1) Am I reinventing the wheel? I haven't seen anything like this, but it would be nice to be a bit more certain. (2) This seems like it will work ok, but the feel is not as clean as the current Data.Binary interface. Is there something I'm missing that might make it easier to integrate this? (3) Right now this is just proof of concept, but eventually I'd like to do some performance tuning, and it would be nice to have a representation that's amenable to this. Any thoughts on speeding this up while keeping the interface reasonably clean would be much appreciated. Thanks! -Chad ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using Data.Binary for compression
On Wed, Nov 14, 2007 at 10:03:52PM -0800, Chad Scherrer wrote: Hi, I'd like to be able to use Data.Binary (or similar) for compression. Say I have an abstract type Symbol, and for each value of Symbol I have a representation in terms of some number of bits. For compression to be efficient, commonly-used Symbols should have very short representations, while less common ones can be longer. ... (1) Am I reinventing the wheel? I haven't seen anything like this, but it would be nice to be a bit more certain. (2) This seems like it will work ok, but the feel is not as clean as the current Data.Binary interface. Is there something I'm missing that might make it easier to integrate this? (3) Right now this is just proof of concept, but eventually I'd like to do some performance tuning, and it would be nice to have a representation that's amenable to this. Any thoughts on speeding this up while keeping the interface reasonably clean would be much appreciated. Almost all 'real users' just use Codec.Compression.GZip. It's very fast, very compositional, and (perhaps suprisingly) almost as effective as application-specific schemes. Stefan signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using Data.Binary for compression
stefanor: On Wed, Nov 14, 2007 at 10:03:52PM -0800, Chad Scherrer wrote: Hi, I'd like to be able to use Data.Binary (or similar) for compression. Say I have an abstract type Symbol, and for each value of Symbol I have a representation in terms of some number of bits. For compression to be efficient, commonly-used Symbols should have very short representations, while less common ones can be longer. ... (1) Am I reinventing the wheel? I haven't seen anything like this, but it would be nice to be a bit more certain. (2) This seems like it will work ok, but the feel is not as clean as the current Data.Binary interface. Is there something I'm missing that might make it easier to integrate this? (3) Right now this is just proof of concept, but eventually I'd like to do some performance tuning, and it would be nice to have a representation that's amenable to this. Any thoughts on speeding this up while keeping the interface reasonably clean would be much appreciated. Almost all 'real users' just use Codec.Compression.GZip. It's very fast, very compositional, and (perhaps suprisingly) almost as effective as application-specific schemes. I was about to say the same thing. So so much simpler to use Duncan's carefully written zlib binding, import Data.Binary import Codec.Compression.GZip import qualified Data.ByteString.Lazy as L main = L.writeFile log.gz . compress . encode $ [1..10::Int] Simple, purely functional, fast. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Chart plotting libraries
don: jon: I'd like some free software to help me plot charts like the one from the ray tracer language comparison: A quick search of hackage.haskell.org, http://dockerz.net/twd/HaskellCharts I need to update the package to build under ghc-6.8.1, though I think it's just a change to the cabal config, rather than any to any code. As of 6.8.1 it needs to depends on the new package called old-locale-1.0.0.0. Presumably this API is intended to become deprecated, though I don't see a replacement. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Chart plotting libraries
I'd like some free software to help me plot charts like the one from the ray tracer language comparison: http://www.ffconsultancy.com/languages/ray_tracer/results.html I was using Mathematica but its stopped working and an upgrade is £2,000. Are there Haskell bindings to any free libraries or even Haskell implementations that would make something like this painless? There isn't anything for OCaml (that I'm not still writing ;-) so this might be a good opportunity to force me to do a little more Haskell. :-) -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Chart plotting libraries
jon: I'd like some free software to help me plot charts like the one from the ray tracer language comparison: http://www.ffconsultancy.com/languages/ray_tracer/results.html I was using Mathematica but its stopped working and an upgrade is £2,000. Are there Haskell bindings to any free libraries or even Haskell implementations that would make something like this painless? There isn't anything for OCaml (that I'm not still writing ;-) so this might be a good opportunity to force me to do a little more Haskell. :-) A quick search of hackage.haskell.org, http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Chart-2007.8.8 Using gtk and cairo. Homepage here: http://dockerz.net/twd/HaskellCharts -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe