From bf3 at telenet.be Tue Jan 1 05:59:05 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Tue Jan 1 05:53:20 2008 Subject: [Haskell-cafe] Compiler backend question Message-ID: <477A1CF9.90001@telenet.be> If I understand it correctly, the GHC compiler either directly generates machinecode, or it uses C as an intermediate language. I also read somewhere that C is not the most efficient intermediate representation for functional languages, and that one gets better performance when generating native machine code. However, from the discussions in this list, I could conclude that the low level machine code optimizer of GHC is far from state-of-the-art compared to industry standard C/C++ compilers. I was wondering, why doesn't GHC use the GCC (or any other standard compiler) backend intermediate code? The backend of GCC generates highly optimized code no? Or is the intermediate code format of GCC (or other compilers) not suitable for Haskell? Another question regarding the backend: a cool feature of the Microsoft Visual C++ (MVC) compiler is its ability to perform "LTCG" (link-time-code-generation), performing whole program optimization. It something like this possible with Haskell / (or the GCC backend?). Would it be possible to feed all the generated C code of the GHC compiler into the MVC compiler, to generate one big MVC / LTCG generated executable? It would be interesting to see how much the whole program optimization approach (which can do analysis on the program as if it was a single module) would improve performance... Cheers, Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080101/4f032697/attachment.htm From ndmitchell at gmail.com Tue Jan 1 08:37:23 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jan 1 08:31:25 2008 Subject: [Haskell-cafe] Compiler backend question In-Reply-To: <477A1CF9.90001@telenet.be> References: <477A1CF9.90001@telenet.be> Message-ID: <404396ef0801010537o41f292fmd1833ade9b3f73ea@mail.gmail.com> Hi > If I understand it correctly, the GHC compiler either directly generates > machinecode, or it uses C as an intermediate language. > > I also read somewhere that C is not the most efficient intermediate > representation for functional languages, and that one gets better > performance when generating native machine code. > > However, from the discussions in this list, I could conclude that the low > level machine code optimizer of GHC is far from state-of-the-art compared to > industry standard C/C++ compilers. These all seem fair comments, based on my understanding. One other thing to remember is that the GHC people know this, and much work has been done, and will continue to be done until the back end is up to the standard of the front end. > I was wondering, why doesn't GHC use the GCC (or any other standard > compiler) backend intermediate code? The backend of GCC generates highly > optimized code no? Or is the intermediate code format of GCC (or other > compilers) not suitable for Haskell? GCC is optimised for dealing with code that comes from C, and the back end language is much like C. GCC is also not really set up to be used by bolting different front ends on to different back ends - part of this is a license issue - if the front and back ends were well split and available separately you could write a commerical backend onto a GPL front end. > Another question regarding the backend: a cool feature of the Microsoft > Visual C++ (MVC) compiler is its ability to perform "LTCG" > (link-time-code-generation), performing whole program optimization. It > something like this possible with Haskell / (or the GCC backend?). Would it > be possible to feed all the generated C code of the GHC compiler into the > MVC compiler, to generate one big MVC / LTCG generated executable? It would > be interesting to see how much the whole program optimization approach > (which can do analysis on the program as if it was a single module) would > improve performance... You would get much better improvements on whole program at the Haskell level. By the time you get to the generated C you have obfustcated all the structure of the program, and are unlikely to benefit that much. Thanks Neil From benja.fallenstein at gmail.com Tue Jan 1 09:52:56 2008 From: benja.fallenstein at gmail.com (Benja Fallenstein) Date: Tue Jan 1 09:46:58 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> Message-ID: On Dec 31, 2007 7:17 AM, wrote: > This declaration states that there's a bijection between the elements of > Foo and the elements of 2^Foo, which by Cantor's diagonal theorem cannot > be true for any set. That's because we only allow computable functions, Nit the nit: Or (more commonly, I think) all continuous functions. > and Foo -> Bool is actually an exponential object in the category Hask. - Benja From gale at sefer.org Tue Jan 1 10:33:14 2008 From: gale at sefer.org (Yitzchak Gale) Date: Tue Jan 1 10:27:20 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> Message-ID: <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> Andrew Bromage wrote: > [*] Theoretical nit: It's not technically a "set". > > Consider the data type: > > data Foo = Foo (Foo -> Bool) > > This declaration states that there's a bijection between the elements of > Foo and the elements of 2^Foo, which by Cantor's diagonal theorem cannot > be true for any set. That's because we only allow computable functions, > and Foo -> Bool is actually an exponential object in the category Hask. Data types consist only of computable elements. Since there are only countably many computable functions, every data type has at most countably many elements. In particular, it is a set. The least fixed point under these restrictions is not a bijection between Foo and 2^Foo. It is only a bijection between Foo and the subset of computable 2^Foo. -Yitz From gale at sefer.org Tue Jan 1 10:43:18 2008 From: gale at sefer.org (Yitzchak Gale) Date: Tue Jan 1 10:37:19 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> Message-ID: <2608b8a80801010743m33409e52w97ba1ad8da9518d9@mail.gmail.com> Andrew Bromage wrote: >> [*] Theoretical nit: It's not technically a "set". >> >> Consider the data type: >> >> data Foo = Foo (Foo -> Bool) >> >> This declaration states that there's a bijection between the elements of >> Foo and the elements of 2^Foo, which by Cantor's diagonal theorem cannot >> be true for any set. That's because we only allow computable functions, >> and Foo -> Bool is actually an exponential object in the category Hask. I wrote: > Data types consist only of computable elements. Since there > are only countably many computable functions, What I meant by that is that there are only countably many lambdas, and we can define a "computable value" as a lambda. The classical definition of "general recursive function" refers to functions in Integer -> Integer to begin with, so there can only be countably many values by construction. > every data type > has at most countably many elements. In particular, it is a set. > > The least fixed point under these restrictions is not a bijection > between Foo and 2^Foo. It is only a bijection between Foo and > the subset of computable 2^Foo. -Yitz From barsoap at web.de Tue Jan 1 12:44:46 2008 From: barsoap at web.de (Achim Schneider) Date: Tue Jan 1 12:39:11 2008 Subject: [Haskell-cafe] Re: Compiler backend question References: <477A1CF9.90001@telenet.be> Message-ID: <20080101184446.7500417a@solaris.tower> Peter Verswyvelen wrote: > Another question regarding the backend: a cool feature of the > Microsoft Visual C++ (MVC) compiler is its ability to perform "LTCG" > (link-time-code-generation), performing whole program optimization. > It something like this possible with Haskell / (or the GCC backend?). > Would it be possible to feed all the generated C code of the GHC > compiler into the MVC compiler, to generate one big MVC / LTCG > generated executable? It would be interesting to see how much the > whole program optimization approach (which can do analysis on the > program as if it was a single module) would improve performance... > jhc does that. Or rather, it doesn't compile Haskell modules separately but throws them together (presumably) in the first pass. Regarding C, it's actually only a high-level assembly language, with compiler optimisations only optimising heavily if you use those idioms... say inlining, loop-unrolling. If your compiler backend outputs something that is already close to some generalisation of different assembly languages, containing no superfluous code and compile-time evaluable expressions and looking generally like a mess of mov's and jmp's, nothing much more than optimisating register allocation and pipeline usage optimisation can be done, which are both highly processor-specific bastards, and likely to be hard to write better than . I figure it's being lazy in the right way(TM) -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From r.kelsall at millstream.com Tue Jan 1 14:43:30 2008 From: r.kelsall at millstream.com (Richard Kelsall) Date: Tue Jan 1 14:37:35 2008 Subject: [Haskell-cafe] Compiler backend question In-Reply-To: <477A1CF9.90001@telenet.be> References: <477A1CF9.90001@telenet.be> Message-ID: <477A97E2.70803@millstream.com> Peter Verswyvelen wrote: ... > I was wondering, why doesn't GHC use the GCC (or any other standard > compiler) backend intermediate code? The backend of GCC generates highly > optimized code no? Or is the intermediate code format of GCC (or other > compilers) not suitable for Haskell? ... My guess is that there is scope for producing assembly code that out-performs GCC. I speak as someone who has no actual knowledge of how GCC works :) I have a theory that the back-end of most compilers, including GCC, are an accretion of many hand-coded hard-coded functions to perform very specific optimisations for particular instructions for particular processors. These have been developed over the years by relatively ad-hoc timings of the precise assembly code the individual who wrote the function wanted to improve. So what's wrong with this approach? When a new processor is introduced it needs a different set of optimisations, which take time to develop, which means the compiler is sub-optimal for a while for new processors. Also, the number of processors we would like the compiler optimised for is large if we're really trying to get the last few percent from every processor. Modern processors aren't simple things like the old 6502 or Z80 which had definite, easily predictable, timings. Think different cache sizes, multiple pipelines, branch prediction etc. "The microarchitecture of Intel and AMD CPU?s: An optimization guide for assembly programmers and compiler makers" here http://www.agner.org/optimize/ It seems unlikely therefore that the code generation for every modern processor variant will be hand-optimised to account for all the small details. Even in GCC, which no doubt has a huge amount of continuous effort applied to it by many clever people, they are never going to hand-code every complexity of every processor. Take a small example : integer multiplication. Looking at the table in the conclusion of the microarchitecture PDF we see that different x86 processors have different relative speed of adding and multiplying. Something like this Execution latencies, typical AMD64 P4E PM Core2 integer addition 1 1 1 1 integer multiplication 3 10 4 3 We can compute 4 * 371 faster on P4E by doing 371 + 371 + 371 + 371 but on Core2 and AMD64 we should do 4 * 371 and on PM it might depend on other factors, I don't know. Now supposing we allow powers of two by shifting as well as integer addition, can we immediately say the best way of multiplying two integers on all these processors? Maybe roughly, but do we always get the absolute fastest code? For example it will depend on the values of the integers. If we know one of them in advance as I've assumed above, or if we know they frequently have particular values we might handle them first etc. This is just one small optimisation out of many. And the optimisations might interact. So the inevitable conclusion is that the precise assembly code optimisations must not be hand-coded directly into the back-end of the compiler, as I expect they are currently in most compilers, but that they need to be expressed at a higher level "repeated addition is equivalent to multiplication" and adapted down to particular processors and situations based on extensive, genetic algorithm guided, timing runs. Anyway, that's my wild idea thrown in the pot. Might be a nice research paper in there for someone :) Richard. From bf3 at telenet.be Tue Jan 1 15:18:21 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Tue Jan 1 15:12:51 2008 Subject: [Haskell-cafe] Compiler backend question In-Reply-To: <404396ef0801010537o41f292fmd1833ade9b3f73ea@mail.gmail.com> References: <477A1CF9.90001@telenet.be> <404396ef0801010537o41f292fmd1833ade9b3f73ea@mail.gmail.com> Message-ID: <000c01c84cb3$74651e20$5d2f5a60$@be> Neil Mitchell wrote: > GCC is optimised for dealing with code that comes from C, and the back > end language is much like C. GCC is also not really set up to be used > by bolting different front ends on to different back ends - part of > this is a license issue - if the front and back ends were well split > and available separately you could write a commerical backend onto a > GPL front end. Well, I don't know about the licensing, but according to http://en.wikipedia.org/wiki/GNU_Compiler_Collection#Front_ends, a new cleaner intermediate language was created in 2005 for GCC, which might be more "general"? > You would get much better improvements on whole program at the Haskell > level. By the time you get to the generated C you have obfustcated all > the structure of the program, and are unlikely to benefit that much. Yes that would be great! Or even at JIT time ;-) But, given the time GHC takes to optimize a single module, I guess it would not really be practical to let those optimization take place on the full program? It would take ages no? I just wanted to see if it is *possible* to feed just all the C code from GHC into a C compiler, and then generate a single executable from that C code (including the GHC runtime). For example, for the XBOX DEVKIT, Microsoft shipped LTCG versions for all the core libraries, which gave a nice performance improvement for free (if I'm not mistaking, this gives 10% to 15% faster code). Actually this LTCG thingy was first supported by the Intel compiler I believe. Thanks, Peter From bos at serpentine.com Tue Jan 1 15:44:23 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Jan 1 15:38:24 2008 Subject: [Haskell-cafe] Compiler backend question In-Reply-To: <000c01c84cb3$74651e20$5d2f5a60$@be> References: <477A1CF9.90001@telenet.be> <404396ef0801010537o41f292fmd1833ade9b3f73ea@mail.gmail.com> <000c01c84cb3$74651e20$5d2f5a60$@be> Message-ID: <477AA627.5000008@serpentine.com> Peter Verswyvelen wrote: > Well, I don't know about the licensing, but according to > http://en.wikipedia.org/wiki/GNU_Compiler_Collection#Front_ends, a new > cleaner intermediate language was created in 2005 for GCC, which might be > more "general"? It's still very difficult to work with GCC from the perspective of an external tool. Its current IR is still targeted towards the languages it currently supports and the needs of its back end, so it omits a fair bit of information that third-party tools would find useful. > I just wanted to see if it is *possible* to feed just all the C code from > GHC into a C compiler, and then generate a single executable from that C > code (including the GHC runtime). It would be a fair bit of work. My recollection is that GHC "knows" that it is talking to GCC when you go through -fvia-c, so it uses some gcc extensions to handle things like register reservation. A few compilers support some of those gcc extensions, so you might have some level of success with those. The Intel and PathScale compilers do, for example, and LLVM's clang front end has some level of gcc compatibility already. In the case of the PathScale compiler (which I used to work on), when invoked in whole-program mode it emits files that look like regular .o files, but are in fact just the serialised IR for a compilation unit. It's also open source, so it would be easier to tinker with than the Intel compiler. > Actually this LTCG thingy was first supported by the > Intel compiler I believe. No, that kind of whole-program optimisation long predates its inclusion in the Intel compiler. The earliest I saw it in deployment was in MIPS compilers circa 1992, and I don't recall it being a new idea at the time. Anyway, the point about GCC being an unsuitable vehicle for this sort of thing remains. You'd do better looking at LLVM, for which I've lately been working on nice Haskell bindings: darcs get http://darcs.serpentine.com/llvm References: <4774E022.8070201@btinternet.com> <117f2cc80712280655w70bdcdfet6e11dcb4e2a66bb2@mail.gmail.com> <6BD267D89E66B9499514F119920E583C0203DBCC@usctmx1110.merck.com> Message-ID: <8dde104f0801011429t123450cfjc19c3842bab4ba2@mail.gmail.com> On Dec 28, 2007 11:40 PM, Mitar wrote: > Would not it be interesting and useful (but not really efficient) to > have patterns something like: > > foo :: Eq a => a -> ... > foo (_{4}'b') = ... > > which would match a list with four elements ending with an element 'b'. Or: > > foo (_+';'_+';'_) = ... > > which would match a list with embedded two ';' elements. (Last _ > matched the remaining of the list.) > I suggest you take at look at HaRP, Haskell Regular Patterns: http://www.cs.chalmers.se/~d00nibro/harp/ It hasn't been updated for a while but it should still be useable. Cheers, Josef From lrpalmer at gmail.com Tue Jan 1 18:57:20 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Jan 1 18:51:20 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <2608b8a80801010743m33409e52w97ba1ad8da9518d9@mail.gmail.com> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> <2608b8a80801010743m33409e52w97ba1ad8da9518d9@mail.gmail.com> Message-ID: <7ca3f0160801011557x8fc901bv795da1d81662dacb@mail.gmail.com> On Jan 1, 2008 3:43 PM, Yitzchak Gale wrote: > The classical definition of "general recursive function" > refers to functions in Integer -> Integer to begin > with, so there can only be countably many values by > construction. Except that there are uncountably many (2^Aleph_0) functions in Integer -> Integer. That doesn't change the fact that there are countably many computable functions, as you guys have been saying. But I think you need to refer to the LC or Turing machine definition to get countability. Luke From sulzmann at comp.nus.edu.sg Tue Jan 1 21:49:53 2008 From: sulzmann at comp.nus.edu.sg (Martin Sulzmann) Date: Tue Jan 1 21:43:59 2008 Subject: [Haskell-cafe] Missing join and split In-Reply-To: <8dde104f0801011429t123450cfjc19c3842bab4ba2@mail.gmail.com> References: <4774E022.8070201@btinternet.com> <117f2cc80712280655w70bdcdfet6e11dcb4e2a66bb2@mail.gmail.com> <6BD267D89E66B9499514F119920E583C0203DBCC@usctmx1110.merck.com> <8dde104f0801011429t123450cfjc19c3842bab4ba2@mail.gmail.com> Message-ID: <18298.64465.426876.674664@suna0.comp.nus.edu.sg> Josef Svenningsson writes: > On Dec 28, 2007 11:40 PM, Mitar wrote: > > Would not it be interesting and useful (but not really efficient) to > > have patterns something like: > > > > foo :: Eq a => a -> ... > > foo (_{4}'b') = ... > > > > which would match a list with four elements ending with an element 'b'. Or: > > > > foo (_+';'_+';'_) = ... > > > > which would match a list with embedded two ';' elements. (Last _ > > matched the remaining of the list.) > > > I suggest you take at look at HaRP, Haskell Regular Patterns: > http://www.cs.chalmers.se/~d00nibro/harp/ > > It hasn't been updated for a while but it should still be useable. > Also of interest might be XHaskell http://taichi.ddns.comp.nus.edu.sg/taichiwiki/XhaskellHomePage which adds XDuce style regular expression pattern matching to Haskell. Martin From gale at sefer.org Wed Jan 2 04:34:02 2008 From: gale at sefer.org (Yitzchak Gale) Date: Wed Jan 2 04:28:10 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <7ca3f0160801011557x8fc901bv795da1d81662dacb@mail.gmail.com> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> <2608b8a80801010743m33409e52w97ba1ad8da9518d9@mail.gmail.com> <7ca3f0160801011557x8fc901bv795da1d81662dacb@mail.gmail.com> Message-ID: <2608b8a80801020134y584f52f2t612554f44364365a@mail.gmail.com> I wrote: >> The classical definition of "general recursive function" >> refers to functions in Integer -> Integer to begin >> with, so there can only be countably many values by >> construction. Luke Palmer wrote: > Except that there are uncountably many (2^Aleph_0) functions in > Integer -> Integer. No, only countably many. By the type expression Integer -> Integer we mean all Haskell functions mapping Integers to Integers. There are only countably many of those. Of course, you can sometimes use Haskell-like notation for discussing other mathematical concepts. In that context, you might mean to include uncomputable functions in your types. (Hey, there's a fun idea - how would you write the infinite injury algorithm in Haskell?) But that was not the context in this thread. The category Hask that we often mention in discussions about Haskell the programming language is most certainly a small category. -Yitz From emmanuel.delaborde at citycampus.com Wed Jan 2 05:13:29 2008 From: emmanuel.delaborde at citycampus.com (manu) Date: Wed Jan 2 05:07:31 2008 Subject: [Haskell-cafe] Problem building hdbc-sqlite3 with ghc 6.8.2 Message-ID: <49E913CA-C853-451A-9E6C-FA460EFC6B39@citycampus.com> hello, has anybody managed to build hdbc-sqlite3 with ghc 6.8.2 ? I get the following error : Macintosh:HDBC-sqlite3-1.1.3.0 manu$ runhaskell Setup.lhs build Preprocessing library HDBC-sqlite3-1.1.3.0... ghc-6.8.2: unrecognised flags: -F/Users/manu/Library/Frameworks Usage: For basic information, try the `--help' option. compiling dist/build/Database/HDBC/Sqlite3/Statement_hsc_make.c failed command was: /usr/local/bin/ghc -c -package base-3.0.1.0 -package mtl-1.1.0.0 -package HDBC-1.1.3 -I. -F/Users/manu/Library/Frameworks dist/build/Database/HDBC/Sqlite3/Statement_hsc_make.c -o dist/build/ Database/HDBC/Sqlite3/Statement_hsc_make.o if somebody has an idea... Thanks E.D From ajb at spamcop.net Wed Jan 2 06:15:02 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Wed Jan 2 06:09:01 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> Message-ID: <20080102061502.otgf2n7m040owcow@webmail.spamcop.net> G'day all. Quoting Yitzchak Gale : > Data types consist only of computable elements. Since there > are only countably many computable functions, every data type > has at most countably many elements. In particular, it is a set. I still say it "isn't a set" in the same way that a group "isn't a set". Haskell data types have structure that is respected by Haskell homomorphisms. Sets don't. Cheers, Andrew Bromage From bf3 at telenet.be Wed Jan 2 06:50:46 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Wed Jan 2 06:44:45 2008 Subject: [Haskell-cafe] Consensus about databases / serialization Message-ID: <000a01c84d35$b64d3de0$22e7b9a0$@be> As I'm a selfmade man, I never really studied relational databases in detail. My intuition told me that the "relational" part was not really suitable for the 3D data, 2D images, animation curves, state machines, and other data I encountered in the videogame and animation business. I could always get away with files, and for the applications I needed to deploy, plugging in a couple of extra gigabytes of RAM and serializing the "object" state to disk was more practical, cheaper and faster. However, a couple of years ago I started studying computer science (I seem to do the theory after the practice, weird behavior ;-) at the Open University, and one of the exams I did was about databases. Initially this course convinced me that databases are actually very nice, but the course ended with a topic on object oriented databases, which were designed to make storing data like "3D models, graphs, networks, and complex datastructures" more practical. Duh. Since then, I did deploy a few commercial applications for customers using databases, which worked fine for the typical "simple/flat" database data. I hated embedding a dynamic untyped language like SQL, as much as I hated embedding code in HTML or XML. IMHO it feels UGLY and unsafe. Regarding the other popular data storage format - XML - I did use that a lot, but it seems like going back to the stone ages, when hierarchical stores/databases got invented (and ditched?) Now, initially after an introduction to Microsoft's LINQ, and recently having read a very brief overview of HAppS, it seems I'm not the only one with those "feelings". Ouch, this introduction got way to long, sorry about that ;-) Finally some practical questions: . regarding Haskell and databases, the page http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces describes a few, but which are the ones that are stable and practical? Any user experiences? . HApps is not listed in the page above, because it does not use databases? Is HApps reliable or experimental, and does it scale well? Any success stories? . regarding Haskell and serialization, I don't think that implementing Read/Show is a good way for real serialization, so what other options exist? I could find some libraries at http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Data, but again which are the most practical and stable? When programming in C++/MFC and C#/.NET, I tended to develop my own serialization frameworks because I used that for many things, like logging commands to disk, performing undo/redo, intra and inter process cut/copy/paste, save/load, etc. . Regarding serialization, I'm kinda curious how ADTs and even GADTs are stored and retrieved in a relational database? I guess it could be done using BLOBs and serialization to ByteStrings, so bypassing a lot of the database table structures? . If I would want to experiment with say HAppS, the way I understand it, I first would first have to study "Scratch your boilerplate" and Template Haskell, and maybe some other language features? I'm still new to Haskell, and the road to understanding all language elements and extensions is very long, so sequentially learning it would be insane I guess. I have no practical experience with TH, but I spent a long time trying to do "aspect oriented programming" in C# without success, so TH looks uber to me. Thanks a lot and best wishes for 2008? Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/46a08795/attachment.htm From kirby81 at gmail.com Wed Jan 2 07:20:26 2008 From: kirby81 at gmail.com (Salvatore Insalaco) Date: Wed Jan 2 07:14:27 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: <000a01c84d35$b64d3de0$22e7b9a0$@be> References: <000a01c84d35$b64d3de0$22e7b9a0$@be> Message-ID: <5a376f550801020420m715a5b29q2ec880889b01f865@mail.gmail.com> > ? regarding Haskell and databases, the page > http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces > describes a few, but which are the ones that are stable and practical? Any > user experiences? During my experiments I found Takusen (http://darcs.haskell.org/takusen/) and HDBC (http://software.complete.org/hdbc) very useful, even if I liked Takusen interface more. > ? regarding Haskell and serialization, I don't think that > implementing Read/Show is a good way for real serialization, so what other > options exist? I could suggest Data.Binary (http://code.haskell.org/binary/), that is very well performing and supported. There are ways to generate instances of Binary automatically. I like the "Derive" approach most (http://www.cs.york.ac.uk/fp/darcs/derive/derive.htm), as it uses Template Haskell and does not require separate pre-processing. From jlw501 at cs.york.ac.uk Wed Jan 2 07:32:00 2008 From: jlw501 at cs.york.ac.uk (jlw501) Date: Wed Jan 2 07:26:02 2008 Subject: [Haskell-cafe] Knowledge In-Reply-To: <404396ef0712191341p59cde996s1014e68c6eb59ea5@mail.gmail.com> References: <14423007.post@talk.nabble.com> <7ca3f0160712191328s700a1655l14a900fd177d8c07@mail.gmail.com> <404396ef0712191341p59cde996s1014e68c6eb59ea5@mail.gmail.com> Message-ID: <14577605.post@talk.nabble.com> Good point. By fold/unfold transformation you get the following: contains = flip elem [Eureka] = contains xs e = flip elem xs e [Expose data structures] = contains [] e = False contains (x:xs) e = flip elem (x:xs) e [Instantiate] = contains [] e = False contains (x:xs) e = elem e x:[] || flip elem xs e [Unfold flip one step] = contains [] e = False contains (x:xs) e = elem e x:[] || contains xs e [Fold back to original defintion] = contains [] e = False contains (x:xs) = e==x || contains xs e [Substitute] Apparently, the fold/unfold transformation law will always yield an equally or more efficient computation. So this begs the question... contains [] e = False contains (x:xs) = e==x || contains xs e OR contains = flip elem Neil Mitchell wrote: > > Hi > >> > contains :: Eq a => [a]->a->Bool >> > contains [] e = False >> > contains (x:xs) e = if x==e then True else contains xs e >> >> contains = flip elem > > And even if not using the elem function, the expression: > > if x==e then True else contains xs e > > can be written as: > > x==e || contains xs e > > Thanks > > Neil > _______________________________________________ > 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/Knowledge-tp14423007p14577605.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From gale at sefer.org Wed Jan 2 08:49:42 2008 From: gale at sefer.org (Yitzchak Gale) Date: Wed Jan 2 08:43:42 2008 Subject: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors) Message-ID: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> Hi Andrew, Andrew Bromage wrote: > I still say it "isn't a set" in the same way that a group "isn't a set". > Haskell data types have structure that is respected by Haskell > homomorphisms. Sets don't. Ah, that's certainly true. But what is that additional structure? In categories that have a forgetful functor to Set, the interesting part of their structure comes from the fact that their morphisms are only a proper subset of the morphisms in Set. So in what way are Set morphisms restricted from being Hask morphisms? In two ways, I think: 1. They must be computable. 2. They must satisfy certain strictness criteria involving undefined and seq. (1) can be rather boring, since computability is rarely is an issue in real-life programming problems. It seems that some people using concepts from categories in Haskell would prefer to ignore (2) as well. If so, we have been reduced to viewing Hask as more or less the same as a small subcategory of Set, with no additional structure that is of interest. In this view, there is nothing special about Haskell, except for the fact that category-theoretic concepts are a bit easier to express in Haskell than in many other languages. So perhaps a better name for this category would be Turing. I don't think that ignoring (2) is the right approach. I would like Hask to reflect the non-strict nature of Haskell, which is one of its most interesting features. Some people are worried that this version of Hask is missing certain nice properties that one would like to have. For example, it was recently claimed on this list that tuples are not products in that category. (Or some such. I would be interested to see a demonstration of that.) I am not impressed by those complaints. As usual in category theory, you define corresponding notions in Hask, and prove that they are preserved under the appropriate functors. That should always be easy. And if ever it is not, then you have discovered an interesting non-trivial consequence of laziness that deserves study. For example: I think that "monads" in Haskell should satisfy the monad laws in Hask, not just after applying the forgetful functor to Turing. That means that (>>=) must be strict in its second argument. That would very likely not break any existing programs, yet almost none of the existing monads satisfy this, not even IO. Regards, Yitz From cristian.baboi at gmail.com Wed Jan 2 09:18:19 2008 From: cristian.baboi at gmail.com (Cristian Baboi) Date: Wed Jan 2 09:11:58 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: <000a01c84d35$b64d3de0$22e7b9a0$@be> References: <000a01c84d35$b64d3de0$22e7b9a0$@be> Message-ID: I recommend you read "Extending the database relational model to capture more meaning" by E.F. Codd. On Wed, 02 Jan 2008 13:50:46 +0200, Peter Verswyvelen wrote: > As I'm a selfmade man, I never really studied relational databases in > detail. My intuition told me that the "relational" part was not really > suitable for the 3D data, 2D images, animation curves, state machines, > and > other data I encountered in the videogame and animation business. I could > always get away with files, and for the applications I needed to deploy, > plugging in a couple of extra gigabytes of RAM and serializing the > "object" > state to disk was more practical, cheaper and faster. > > > However, a couple of years ago I started studying computer science (I > seem > to do the theory after the practice, weird behavior ;-) at the Open > University, and one of the exams I did was about databases. Initially > this > course convinced me that databases are actually very nice, but the course > ended with a topic on object oriented databases, which were designed to > make > storing data like "3D models, graphs, networks, and complex > datastructures" > more practical. Duh. > > > Since then, I did deploy a few commercial applications for customers > using > databases, which worked fine for the typical "simple/flat" database > data. I > hated embedding a dynamic untyped language like SQL, as much as I hated > embedding code in HTML or XML. IMHO it feels UGLY and unsafe. Regarding > the > other popular data storage format - XML - I did use that a lot, but it > seems > like going back to the stone ages, when hierarchical stores/databases got > invented (and ditched?) > > > Now, initially after an introduction to Microsoft's LINQ, and recently > having read a very brief overview of HAppS, it seems I'm not the only one > with those "feelings". > > > Ouch, this introduction got way to long, sorry about that ;-) > > > Finally some practical questions: > > . regarding Haskell and databases, the page > http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces > describes a few, but which are the ones that are stable and practical? > Any > user experiences? > > . HApps is not listed in the page above, because it does not use > databases? Is HApps reliable or experimental, and does it scale well? Any > success stories? > > . regarding Haskell and serialization, I don't think that > implementing Read/Show is a good way for real serialization, so what > other > options exist? I could find some libraries at > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Data, but > again which are the most practical and stable? When programming in > C++/MFC > and C#/.NET, I tended to develop my own serialization frameworks because > I > used that for many things, like logging commands to disk, performing > undo/redo, intra and inter process cut/copy/paste, save/load, etc. > > . Regarding serialization, I'm kinda curious how ADTs and even > GADTs > are stored and retrieved in a relational database? I guess it could be > done > using BLOBs and serialization to ByteStrings, so bypassing a lot of the > database table structures? > > . If I would want to experiment with say HAppS, the way I > understand > it, I first would first have to study "Scratch your boilerplate" and > Template Haskell, and maybe some other language features? I'm still new > to > Haskell, and the road to understanding all language elements and > extensions > is very long, so sequentially learning it would be insane I guess. I > have no > practical experience with TH, but I spent a long time trying to do > "aspect > oriented programming" in C# without success, so TH looks uber to me. > > > Thanks a lot and best wishes for 2008? > > > Peter > From benja.fallenstein at gmail.com Wed Jan 2 09:38:56 2008 From: benja.fallenstein at gmail.com (Benja Fallenstein) Date: Wed Jan 2 09:32:54 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: <2608b8a80801020134y584f52f2t612554f44364365a@mail.gmail.com> References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> <2608b8a80801010743m33409e52w97ba1ad8da9518d9@mail.gmail.com> <7ca3f0160801011557x8fc901bv795da1d81662dacb@mail.gmail.com> <2608b8a80801020134y584f52f2t612554f44364365a@mail.gmail.com> Message-ID: Hi Yitz, On Jan 2, 2008 10:34 AM, Yitzchak Gale wrote: > No, only countably many. By the type expression Integer -> Integer > we mean all Haskell functions mapping Integers to Integers. > There are only countably many of those. ... > But that was not the context in this thread. The category > Hask that we often mention in discussions about Haskell > the programming language is most certainly a small category. I don't know. My understanding has been that at least part of the benefit of denotational semantics is that you can define what an expression means without referring back to the syntactic construction or the operational semantics of that expression -- and thus use the denotational semantics to check whether the operational semantics are "right." But if you start with "all Haskell functions," you already have to know what a Haskell function *is*. I think it should be "allowed" to think of the semantics of Haskell as being defined independently of the (relatively operational) notion of "computable function," and then define "computable function" to be that subset of the functions in the model that you can actually write in Haskell. And the only explicit non-syntactic constructions of models for Haskell-like languages that I'm familiar with aren't countable (they contain all continuous functions, which in the case of (Integer -> Integer) comes out to all monotonous functions). So I disagree that the function types of Hask should automatically be taken to be countable. If you want to assume it for some given purpose, sure, fine, but IMO that's an additional assumption, not something inherent in the Haskell language. Best, - Benja From Christian.Maeder at dfki.de Wed Jan 2 09:39:36 2008 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Jan 2 09:33:37 2008 Subject: [Haskell-cafe] Re: Problem building hdbc-sqlite3 with ghc 6.8.2 In-Reply-To: <49E913CA-C853-451A-9E6C-FA460EFC6B39@citycampus.com> References: <49E913CA-C853-451A-9E6C-FA460EFC6B39@citycampus.com> Message-ID: <477BA228.9030406@dfki.de> manu wrote: > hello, > > has anybody managed to build hdbc-sqlite3 with ghc 6.8.2 ? > > I get the following error : > > Macintosh:HDBC-sqlite3-1.1.3.0 manu$ runhaskell Setup.lhs build > Preprocessing library HDBC-sqlite3-1.1.3.0... > ghc-6.8.2: unrecognised flags: -F/Users/manu/Library/Frameworks > Usage: For basic information, try the `--help' option. > compiling dist/build/Database/HDBC/Sqlite3/Statement_hsc_make.c failed > command was: /usr/local/bin/ghc -c -package base-3.0.1.0 -package > mtl-1.1.0.0 -package HDBC-1.1.3 -I. -F/Users/manu/Library/Frameworks > dist/build/Database/HDBC/Sqlite3/Statement_hsc_make.c -o > dist/build/Database/HDBC/Sqlite3/Statement_hsc_make.o > > > if somebody has an idea... I seems you used my binary dist that I made with a modified utils/hsc2hs/Main.hs http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/13583 http://hackage.haskell.org/trac/ghc/ticket/1395 hsc2hs only worked for me when gcc was used instead ghc (when bootstrapping ghc-6.8.2 itself). Maybe I should build new binary-dists. Is it for ppc or x86? Cheers Christian From jeff.polakow at db.com Wed Jan 2 09:54:31 2008 From: jeff.polakow at db.com (Jeff Polakow) Date: Wed Jan 2 09:48:37 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: <000a01c84d35$b64d3de0$22e7b9a0$@be> Message-ID: Hello, I use HDBC for ODBC database access, and HAppS as a web server. I am fairly happy with both. Here are some further thoughts... > Finally some practical questions: > ? regarding Haskell and databases, the page http://haskell. > org/haskellwiki/Libraries_and_tools/Database_interfaces describes a > few, but which are the ones that are stable and practical? Any user > experiences? > HDBC is fairly stable (although its ODBC driver crashes ghc 6.8 on windows). I think HSQL is similarly stable. Takusen offers a slightly higher-level interface and some performance guarantees; it is a nice system but lacks support for ODBC (supposedly this is in the works). HaskelDB is probably the ideal database access system for Haskell, however the distribution was in bad shape (no documentation, hard to compile, etc.) the last I looked maybe 6 months ago. > ? HApps is not listed in the page above, because it does not > use databases? Is HApps reliable or experimental, and does it scale > well? Any success stories? > HAppS is a general server framework for Haskell. HAppS is very appealing because it allows you to dynamically create pages directly with Haskell. HAppS encourages storing your server state in memory, but it is easy to read in state on the fly from external sources. The only caveat with HAppS is that the system has been in active development for the past few months is just starting (I hope) to settle down; thus useful documentation/examples are hard to find, but the HAppS developers are pretty good at replying to help requests on the HAppS IRC and the HAppS mailing list. I am currently using an old (and stable) version of HAppS but expect to upgrade to the latest version soon. > ? If I would want to experiment with say HAppS, the way I > understand it, I first would first have to study ?Scratch your > boilerplate? and Template Haskell, and maybe some other language > features? I?m still new to Haskell, and the road to understanding > all language elements and extensions is very long, so sequentially > learning it would be insane I guess. I have no practical experience > with TH, but I spent a long time trying to do ?aspect oriented > programming? in C# without success, so TH looks uber to me? > While HAppS does use SYB and TH, you don't need to understand them to effectively use HAppS; of course you'll need to understand them, at least basic TH, to understand the details of what HAppS is doing. hope that helps, Jeff --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/61713847/attachment-0001.htm From jonathanccast at fastmail.fm Wed Jan 2 10:26:37 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Jan 2 10:20:41 2008 Subject: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors) In-Reply-To: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> Message-ID: <25C23866-F3AB-4510-9DDD-48A50B72835B@fastmail.fm> On 2 Jan 2008, at 5:49 AM, Yitzchak Gale wrote: > Hi Andrew, > > Andrew Bromage wrote: >> I still say it "isn't a set" in the same way that a group "isn't a >> set". >> Haskell data types have structure that is respected by Haskell >> homomorphisms. Sets don't. > > Ah, that's certainly true. But what is that additional structure? > > In categories that have a forgetful functor to Set, the interesting > part of their structure comes from the fact that their > morphisms are only a proper subset of the morphisms > in Set. > > So in what way are Set morphisms restricted from being > Hask morphisms? The normal view taken by Haskellers is that the denotations of Haskell types are CPPOs. So: (1) Must be monotone (2) Must be continuous (Needn't be strict, even though that messes up the resulting category substantially). jcc From simonmarhaskell at gmail.com Wed Jan 2 10:30:02 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Wed Jan 2 10:24:06 2008 Subject: [Haskell-cafe] Re: Haskell performance In-Reply-To: <20071222061434.u21waxhcms8wwwc4@webmail.spamcop.net> References: <1197707105.479.2.camel@localhost.localdomain> <20071220190214.GF29838@scytale.galois.com> <200712201919.33104.jon@ffconsultancy.com> <20071222061434.u21waxhcms8wwwc4@webmail.spamcop.net> Message-ID: <477BADFA.1080505@microsoft.com> ajb@spamcop.net wrote: > G'day all. > > Quoting Jon Harrop : > >> I would recommend adding: >> >> 1. FFT. >> >> 2. Graph traversal, e.g. "n"th-nearest neighbor. > > I'd like to put in a request for Pseudoknot. Does anyone still have it? This is it, I think: http://darcs.haskell.org/nofib/spectral/hartel/nucleic2 Cheers, Simon From h._h._h._ at hotmail.com Wed Jan 2 11:00:26 2008 From: h._h._h._ at hotmail.com (H. Mayer) Date: Wed Jan 2 10:54:25 2008 Subject: [Haskell-cafe] Escape Codes Message-ID: Hello, Some days ago I needed escape codes on Win32. I didn't find any library for that, so I wrote a simple one. I thought, perhaps someone else will have the same problem, so I put it on my website:http://0hc.net/?what=downloads_sup_AWin32Console I've tested it with the ghc 6.6.1, and everything works as I expected it. I would be happy if someone else could test it and/or report if some important escape codes are missing. --Sincerely H. _________________________________________________________________ Erweitere dein digitales Leben. Hol dir jetzt gratis das neue Windows Live. http://get.live.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/5a16c57d/attachment.htm From ndmitchell at gmail.com Wed Jan 2 11:21:50 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jan 2 11:15:49 2008 Subject: [Haskell-cafe] Escape Codes In-Reply-To: References: Message-ID: <404396ef0801020821j185f4b6eoe2f14462eb154b62@mail.gmail.com> Hi > Some days ago I needed escape codes on Win32. I didn't find any library for > that, so I wrote a simple one. I have a simple module which does them as part of Hoogle: http://www.cs.york.ac.uk/fp/darcs/hoogle/src/General/Type.hs - see TagStr, the type for defining text with basic formatting and outputting it to the console. It doesn't attempt to be comprehensive at all, and probably solves a different problem from your one. > I thought, perhaps someone else will have the same problem, so I put it on > my website: > http://0hc.net/?what=downloads_sup_AWin32Console It would be nice if you could package this and release it on hackage. http://hackage.haskell.org/packages/hackage.html Thanks Neil From simonmarhaskell at gmail.com Wed Jan 2 11:21:51 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Wed Jan 2 11:15:56 2008 Subject: [Haskell-cafe] Re: [16/16] SBM: Discussion and Conclusion In-Reply-To: <20071222091730.D01201604896C@csmtp2.b-one.net> References: <20071222091730.D01201604896C@csmtp2.b-one.net> Message-ID: <477BBA1F.7010606@microsoft.com> Peter Firefly Brodersen Lund wrote: > Using top together with huge input files convinced me that -sstderr was > untrustworthy so I developed the pause-at-end preloading hack. Paranoia paid > off big time there. In what way did you find -sstderr untrustworthy? Perhaps it is because the "memory in use" figure only counts memory that the RTS knows about, and doesn't include malloc()'d memory. If it's anything else, I need to know about it. > o can the core/stg code be made easier to read? By all means - submit tickets with specific suggestions, or better still send patches. Cheers, Simon From stevelihn at gmail.com Wed Jan 2 11:23:13 2008 From: stevelihn at gmail.com (Steve Lihn) Date: Wed Jan 2 11:17:18 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: References: <000a01c84d35$b64d3de0$22e7b9a0$@be> Message-ID: I have started documenting the Database Wikibook, in particular, about HDBC. It is still very rough at this time, but something is better than nothing :-) If you want to add more content, certainly welcome! http://en.wikibooks.org/wiki/Haskell/Database On 1/2/08, Jeff Polakow wrote: > Hello, > I use HDBC for ODBC database access, and HAppS as a web server. I am fairly happy with both. Here are some further thoughts... > > Finally some practical questions: > > ? regarding Haskell and databases, the page http://haskell. > > org/haskellwiki/Libraries_and_tools/Database_interfaces describes a > > few, but which are the ones that are stable and practical? Any user > > experiences? > > > HDBC is fairly stable (although its ODBC driver crashes ghc 6.8 on windows). I think HSQL is similarly stable. Takusen offers a slightly higher-level interface and some performance guarantees; it is a nice system but lacks support for ODBC (supposedly this is in the works). HaskelDB is probably the ideal database access system for Haskell, however the distribution was in bad shape (no documentation, hard to compile, etc.) the last I looked maybe 6 months ago. From ndmitchell at gmail.com Wed Jan 2 11:30:21 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jan 2 11:24:19 2008 Subject: [Haskell-cafe] Hackage web page Message-ID: <404396ef0801020830t7a6f8bc3ydf01ca829a2af778@mail.gmail.com> Hi, The hackage web page confuses me: http://hackage.haskell.org/packages/hackage.html As a user, when I go to that page, I would be seeking one of four pieces of information: 1) How to install a cabal package 2) How to create and upload a cabal package 3) What packages are on hackage 4) What is hackage The first paragraph answers question 4, before pointing off at the trac pages, which contain similar and overlapping information, as well as completely other stuff. The second paragraph basically answers 3 and 1, but in rather roundabout ways, not including a link to the answer to 3, but including a link about CabalInstall which you can't use yet. The rest of the page is notes for the hackage developers. I just went to hackage looking for the answer to question 2. I can't find it. I have a rough idea where some of the information might be hiding, but we really need a walkthrough tutorial - and I'm sure I've seen one of these before. I would think something more like the style of this might work better: http://www-users.york.ac.uk/~socs235/welcome.htm Hackage has now graduated from being a nice idea to being a critial user-focused thingy, which is great. Perhaps the website needs a little bit of thought along those lines. This isn't intended to be a complaint at all - just a new perspective to the people who develop it and probably don't read the web page at all. Thanks Neil From Malcolm.Wallace at cs.york.ac.uk Wed Jan 2 11:32:14 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed Jan 2 11:26:45 2008 Subject: [Haskell-cafe] Newbie question: can laziness lead to space compression? In-Reply-To: References: Message-ID: <20080102163214.029f1701.Malcolm.Wallace@cs.york.ac.uk> Brian Hurt wrote: > But I was wondering if it is possible that lazy evaluation > could lead to space compression, especially under heavily persistant > usage patterns? > > Note that the benefit isn't *big*- we're talking about 40 words of > memory when the main data structure is taking up 5K plus words of > memory- so it's less than 1% different. But there is a (small) > upside in memory usage at least occassionally, right? Actually, a lazy evaluation strategy can sometimes change the entire complexity class of space usage, not just the constant factors. For instance, lazy streaming algorithms (where the data is produced and consumed in lock-step) may use a small constant amount of memory, independent of the size of the data, whereas an eager strategy would use memory linearly proportional to the dataset size. Regards, Malcolm From simonmarhaskell at gmail.com Wed Jan 2 11:39:36 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Wed Jan 2 11:33:38 2008 Subject: [Haskell-cafe] Re: Importing Data.Char speeds up ghc around 70% In-Reply-To: References: <200712222038.01632.daniel.is.fischer@web.de> <200712222155.30842.daniel.is.fischer@web.de> <404396ef0712221434i56fb5677sfb71662ccc6a356f@mail.gmail.com> Message-ID: <477BBE48.1030300@microsoft.com> Joost Behrends wrote: > Neil Mitchell gmail.com> writes: > >> If it can be reproduced on anyones machine, it is a bug. If you can >> bundle up two programs which don't read from stdin (i.e. no getLine >> calls) or the standard arguments (i.e. getArgs) which differ only by >> the Data.Char import, and have massive speed difiference, then report >> a bug. >> >> You should probably also give your GHC versions and platforms etc. > > Thanks for your attention too ! > > Now i tried a version without input (just computing the primefactors of the > constant 2^61+1, what it did correctly in spite of its bugginess). And it > didn't have the Data.Char bug (and Data.List bug) too. > > As my original code hasn't on Linux also it seems. > > Thus it happens only in an exotic configuration. Windows will stay exotic > in the Haskell community. Before should noone > has reproduced it at least on Windows (XPpro SP2 is my version), i will do > nothing more. > > The hardware is Intel Celeron 2.2GHZ, 512 MB Ram. ghc 6.8.1 lives on > D:\\Programme (not on the system drive C:, which poses problems to Cabal, > told aside). Even if it only happens on Windows, if it isn't specific to your hardware then it could still be a bug. I have seen strange artifacts like this before that turned out to be caused by one of two things: - bad cache interactions, e.g. we just happen to have laid out the code in such a way that frequently accessed code sequences push each other out of the cache, or the relative position of the heap and stack have a bad interaction. This happens less frequently these days with 4-way and 8-way associative caches on most CPUs. - alignment issues, such as storing or loading a lot of misaligned Doubles in the second case, I've seen the same program run +/- 50% in performance from run to run, just based on random alignment of the stack. But it's not likely to be the issue here, I'm guessing. If it is code misalignment, that's something we can easily fix (but I don't *think* we're doing anything wrong in that respect). I have an Opteron box here that regularly gives +/- 20% from run to run of the same program with no other load on the machine. I have no idea why... Cheers, Simon From Nicholls.Mark at mtvne.com Wed Jan 2 11:40:31 2008 From: Nicholls.Mark at mtvne.com (Nicholls, Mark) Date: Wed Jan 2 11:35:52 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> Message-ID: I'm trying to translate some standard C# constucts into Haskell... some of this seems easy.... Specifically 1) Interface IX { } 2) Interface IX { } 3) Interface IX Where A : IY { } 4) Interface IX : IZ Where A : IY { } I can take a punt at the first 2....but then it all falls apart From duncan.coutts at worc.ox.ac.uk Wed Jan 2 12:20:04 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jan 2 12:14:02 2008 Subject: [Haskell-cafe] Re: Hackage web page In-Reply-To: <404396ef0801020830t7a6f8bc3ydf01ca829a2af778@mail.gmail.com> Message-ID: <20080102172004.3C121A8002@webmail223.herald.ox.ac.uk> In message <404396ef0801020830t7a6f8bc3ydf01ca829a2af778@mail.gmail.com> "Neil Mitchell" writes: > Hi, > > The hackage web page confuses me: > http://hackage.haskell.org/packages/hackage.html > Hackage has now graduated from being a nice idea to being a critial > user-focused thingy, which is great. Perhaps the website needs a > little bit of thought along those lines. This isn't intended to be a > complaint at all - just a new perspective to the people who develop it > and probably don't read the web page at all. You're quite right. We'd welcome a rewrite. You or anyone else is most welcome to send us a new version in .html or any other format. If there are no immediate volunteers then someone should file a bug against the HackageDB component in our tracker so we do not forget. http://hackage.haskell.org/trac/hackage Duncan From ryani.spam at gmail.com Wed Jan 2 12:40:53 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jan 2 12:34:51 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> Message-ID: <2f9b2d30801020940g228f5fa3h2a7d6592d5c16acd@mail.gmail.com> Of course it depends what's inside the braces, and what you want to do with it, but I'd be inclined to do something like this: 1) data IX a = IX { constructor :: Int -> a, ... } 2) data IX a b = IX { constructor :: Int -> b, func :: a -> b, ... } 3) data IX a b = IX { iy :: IY a, ... } 4) data IX a b = IX { iz :: IZ b, iy :: IY a, ... } Can you specify more clearly what the goal of the conversion is? If you want "OO" style behavior the thing that is most important is existential quantification. -- ryan On 1/2/08, Nicholls, Mark wrote: > > I'm trying to translate some standard C# constucts into Haskell... some > of this seems easy.... > > Specifically > > 1) > > Interface IX > { > } > > 2) > > Interface IX > { > } > > 3) > > Interface IX > Where A : IY > { > } > > 4) > > Interface IX : IZ > Where A : IY > { > } > > > I can take a punt at the first 2....but then it all falls apart > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/f4a0d716/attachment.htm From bulat.ziganshin at gmail.com Wed Jan 2 12:10:29 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jan 2 14:00:54 2008 Subject: [Haskell-cafe] Hackage web page In-Reply-To: <404396ef0801020830t7a6f8bc3ydf01ca829a2af778@mail.gmail.com> References: <404396ef0801020830t7a6f8bc3ydf01ca829a2af778@mail.gmail.com> Message-ID: <918353021.20080102201029@gmail.com> Hello Neil, Wednesday, January 2, 2008, 7:30:21 PM, you wrote: > The hackage web page confuses me: > http://hackage.haskell.org/packages/hackage.html btw, i very like idea of using wiki pages which allows all users to participate in development of docs. may be it will be better to wikify this page too -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From vigalchin at gmail.com Wed Jan 2 14:18:46 2008 From: vigalchin at gmail.com (Galchin Vasili) Date: Wed Jan 2 14:12:45 2008 Subject: [Haskell-cafe] I am looking for the source code for STM implementation ... Message-ID: <5ae4f2ba0801021118w2bfc5fd6hb96684ca0944234e@mail.gmail.com> Hello, I found STM.c(lower layer), but cannot find the top layer code written Haskell.?? Vasya -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/b38539fe/attachment.htm From ryani.spam at gmail.com Wed Jan 2 15:22:55 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jan 2 15:16:53 2008 Subject: [Haskell-cafe] I am looking for the source code for STM implementation ... In-Reply-To: <5ae4f2ba0801021118w2bfc5fd6hb96684ca0944234e@mail.gmail.com> References: <5ae4f2ba0801021118w2bfc5fd6hb96684ca0944234e@mail.gmail.com> Message-ID: <2f9b2d30801021222p478eaf66s51cded69c90134fe@mail.gmail.com> http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/GHC-Conc.html -- ryan On 1/2/08, Galchin Vasili wrote: > > Hello, > > I found STM.c(lower layer), but cannot find the top layer code written > Haskell.?? > > > Vasya > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/63fa50e9/attachment.htm From bulat.ziganshin at gmail.com Wed Jan 2 15:29:21 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jan 2 15:28:30 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> Message-ID: <1965805939.20080102232921@gmail.com> Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: > I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bf3 at telenet.be Wed Jan 2 15:35:15 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Wed Jan 2 15:29:13 2008 Subject: FW: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Message-ID: <005501c84d7e$fb0a8d90$f11fa8b0$@be> I'm also new to Haskell, but I'm a C++/C# veteran, so I'll give it a shot. C#'s interfaces look a bit like Haskell's type classes. Although not exactly the same, you could try something like this: -- C#: interface IX1 { String foo1(int); } class IX1 obj where foo1 :: Int -> obj -> String -- C#: interface IX2 { String foo2(A); } class IX2 obj a where foo2 :: a -> obj -> String --C#: interface IX3 where A : IY { String foo3(A); } class IY a where {- ... -} class IY a => IX3 obj a where foo3 :: a -> obj -> String --C#: interface IX4 : IZ where A : IY class IZ a where {- ... -} class (IY a, IZ obj) => IX4 obj a where foo4 :: a -> obj -> String The C# "class" is called an "instance" in Haskell, so to implement an interface, you would do e.g. data X2 = X2 { x2Bla :: String, ... } instance IX2 X2 String where foo2 s o = (x2Bla o) ++ s This assumes your "objects" are immutable, otherwise you would have to return (obj,String) instead of just String and then you most likely want to use the state monad and "do notation" to make functional programming look more like imperative programming. You really have to drop the OO way of thinking, which I find the hardest :) Haskell's type classes are more powerful in some sense than C# interfaces; for example, in C# you can't attach an interface to any class (take for example the Point struct), it has to be your own class, while in Haskell, you can implement an instance of a type class for any datatype! Hope this helps a bit. As I'm new myself to Haskell, so take this with a "grain of salt". Once you bite the bullet, I found Haskell a lot more fun than C#, although C# of course comes with a gigantic .NET framework and tools... Peter -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy.... Specifically 1) Interface IX { } 2) Interface IX { } 3) Interface IX Where A : IY { } 4) Interface IX : IZ Where A : IY { } I can take a punt at the first 2....but then it all falls apart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From moonlite at dtek.chalmers.se Wed Jan 2 16:36:36 2008 From: moonlite at dtek.chalmers.se (Mattias Bengtsson) Date: Wed Jan 2 18:04:21 2008 Subject: [Haskell-cafe] Re: Web server continued In-Reply-To: References: Message-ID: <1199309796.16506.8.camel@localhost.localdomain> On Mon, 2007-12-31 at 12:36 +0000, Joost Behrends wrote: > And concerning SQL: I like the parts of the language - all capitalized - as > landmarks in my code, even in modified forms like: > > "SELECT number, customer FROM " ++ currcols ++ .... > > Here i see from afar, what the code around this line does. And the backside of treating SQL as strings, like you do here, is that you are able to construct malformed SQL and the errors you get from this can only be handled at runtime. This is the reason HaskellDB (and other similar projects?) exists. I too am not sure that HaskellDB is the perfect solution though. It provides both type safety and an abstraction. Personally i'd be fine with just the type safety. Not sure if it's feasible to embed the whole SQL-syntax in Haskell using just ADT's and combinators though. Mattias -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080102/ac76a147/attachment.bin From jgbailey at gmail.com Wed Jan 2 18:22:08 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Wed Jan 2 18:16:07 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: <000a01c84d35$b64d3de0$22e7b9a0$@be> References: <000a01c84d35$b64d3de0$22e7b9a0$@be> Message-ID: I can speak to haskelldb a little, see below: On Jan 2, 2008 3:50 AM, Peter Verswyvelen wrote: > ? regarding Haskell and databases, the page > http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces > describes a few, but which are the ones that are stable and practical? Any > user experiences? I started looking at haskell database libraries to generate SQL for me. Haskelldb does this well - it uses a higher-level representation of queries based on "relational algebra" (also the basis of SQL) which is pretty easy to understand if you know SQL. It takes care of a lof the details of generating SQL strings, and does it in a mostly type-safe way. It is a bit complicated to install the library and all its dependencies, because it can work with 3+ (mysql, postgres, odbc) databases using two different backends (hdbc and hsql). I chose to go with HDBC because it compiled on Windows and postgres because thats what we have at my workplace. Once I got it built and installed its worked well for me. Until the most recent versions though, it added a "distinct" operator to all select statements. I submitted a patch which was accepted and now that behavior is no longer the default. It is semi-actively maintained by the original authors and Bjorn, at least, has been very responsive to my queries on the haskelldb-users mailing list. He also has made minor updates to keep it compiling with the latest GHC and Cabal. Hope that helps! Justin From bjorn.buckwalter at gmail.com Wed Jan 2 21:08:31 2008 From: bjorn.buckwalter at gmail.com (Bjorn Buckwalter) Date: Wed Jan 2 21:02:33 2008 Subject: [Haskell-cafe] ANN: Dimensional 0.7.2 Message-ID: <8b2a1a960801021808k4f91b871j1158e49b1c6dae66@mail.gmail.com> Dear all, I've released version 0.7.2 of the Dimensional library. The only change from version 0.7.1 is that the CGS module has been re-enabled. Unless you use the CGS module there is no need to upgrade from 0.7.1. Note that this version is incompatible with GHC 6.8.1 due to bug #1919 (introduced in GHC 6.8.1 and fixed in 6.8.2). For GHC 6.8.1 use version Dimensional 0.7.1 which lacks the CGS module. Thanks, Bjorn Buckwalter http://dimensional.googlecode.com http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dimensional On Nov 23, 2007 8:32 AM, Bjorn Buckwalter wrote: > Dear all, > > The Dimensional library has been ported to GHC 6.8.1 (it remains > backwards-compatible with GHC 6.6.1, and also with Cabal 1.1.6 I > believe). The new version number is 0.7.1. > > Due to a GHC 6.8.1 bug (#1919) the CGS module will not compile and has > been disabled. > > Thanks, > Bjorn Buckwalter > > http://dimensional.googlecode.com > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dimensional > http://hackage.haskell.org/trac/ghc/ticket/1919 > From dons at galois.com Thu Jan 3 02:38:51 2008 From: dons at galois.com (Don Stewart) Date: Thu Jan 3 02:32:51 2008 Subject: [Haskell-cafe] Re: [16/16] SBM: Discussion and Conclusion In-Reply-To: <477BBA1F.7010606@microsoft.com> References: <20071222091730.D01201604896C@csmtp2.b-one.net> <477BBA1F.7010606@microsoft.com> Message-ID: <20080103073851.GD3148@scytale.galois.com> simonmarhaskell: > Peter Firefly Brodersen Lund wrote: > > >Using top together with huge input files convinced me that -sstderr was > >untrustworthy so I developed the pause-at-end preloading hack. Paranoia > >paid > >off big time there. > > In what way did you find -sstderr untrustworthy? Perhaps it is because the > "memory in use" figure only counts memory that the RTS knows about, and > doesn't include malloc()'d memory. If it's anything else, I need to know > about it. > > > o can the core/stg code be made easier to read? > > By all means - submit tickets with specific suggestions, or better still > send patches. It's also easier to read if you pipe it into hscolour. A little trick I use to get dynamic syntax highlighting of core: ghc A.hs -O2 -ddump-simpl --make | HsColour -tty | less -r will give you coloured, scrollable syntax highlighted core. -- Don From gale at sefer.org Thu Jan 3 03:33:14 2008 From: gale at sefer.org (Yitzchak Gale) Date: Thu Jan 3 03:27:11 2008 Subject: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors) In-Reply-To: <25C23866-F3AB-4510-9DDD-48A50B72835B@fastmail.fm> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <25C23866-F3AB-4510-9DDD-48A50B72835B@fastmail.fm> Message-ID: <2608b8a80801030033g184cb3e5sb51056b92ae67355@mail.gmail.com> Hi Jonathan, I wrote: >> So in what way are Set morphisms restricted from being >> Hask morphisms? Jonathan Cast wrote: > The normal view taken by Haskellers is that the denotations of > Haskell types are CPPOs. CPPO? > So: > > (1) Must be monotone > (2) Must be continuous Could you please define what you mean by those terms in this context? > (Needn't be strict, even though that messes up the resulting category > substantially). I'm not convinced that the category is all that "messed up". Thanks, Yitz From Nicholls.Mark at mtvne.com Thu Jan 3 04:55:23 2008 From: Nicholls.Mark at mtvne.com (Nicholls, Mark) Date: Thu Jan 3 04:51:21 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: <2f9b2d30801020940g228f5fa3h2a7d6592d5c16acd@mail.gmail.com> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <2f9b2d30801020940g228f5fa3h2a7d6592d5c16acd@mail.gmail.com> Message-ID: I was thinking more along type classes....and then I was going to throw some spanners in the works.... ________________________________ From: Ryan Ingram [mailto:ryani.spam@gmail.com] Sent: 02 January 2008 17:41 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Of course it depends what's inside the braces, and what you want to do with it, but I'd be inclined to do something like this: 1) data IX a = IX { constructor :: Int -> a, ... } 2) data IX a b = IX { constructor :: Int -> b, func :: a -> b, ... } 3) data IX a b = IX { iy :: IY a, ... } 4) data IX a b = IX { iz :: IZ b, iy :: IY a, ... } Can you specify more clearly what the goal of the conversion is? If you want "OO" style behavior the thing that is most important is existential quantification. -- ryan On 1/2/08, Nicholls, Mark wrote: I'm trying to translate some standard C# constucts into Haskell... some of this seems easy.... Specifically 1) Interface IX { } 2) Interface IX { } 3) Interface IX Where A : IY { } 4) Interface IX : IZ Where A : IY { } I can take a punt at the first 2....but then it all falls apart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080103/09a59005/attachment.htm From barsoap at web.de Thu Jan 3 04:59:16 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jan 3 04:53:21 2008 Subject: [Haskell-cafe] The Worker/Wrapper Transformation Message-ID: <20080103105916.7d562d17@solaris.tower> ...is a paper about automatic specialisation of functions by unboxing arguments, one could say. I'm only on page 6, but already survived the first formalisms, which is bound to mean that the rest of the paper is likewise accessible, as hinted on at ltu. http://www.cs.nott.ac.uk/~gmh/wrapper.pdf The transformation itself is mindbogglingly easy, which makes this a good start: You only have to understand the formalisms, not so much what the formalisms are representing. To quote spj: It usually turns out to be more interesting and challenging than it seemed at first. I'm tempted to write that this is a paper for everyone trying to figure out what the heck Jonathan is talking about. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From Nicholls.Mark at mtvne.com Thu Jan 3 05:06:25 2008 From: Nicholls.Mark at mtvne.com (Nicholls, Mark) Date: Thu Jan 3 05:01:08 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: <004a01c84d7e$556a3160$003e9420$@vers@telenet.be> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <004a01c84d7e$556a3160$003e9420$@vers@telenet.be> Message-ID: [snip] >-- C#: interface IX1 { String foo1(int); } >class IX1 obj where > foo1 :: Int -> obj -> String Yep...I think that's what I'd do....though I would have done... "foo1 :: obj -> Int -> String" Does that matter? >-- C#: interface IX2 { String foo2(A); } >class IX2 obj a where > foo2 :: a -> obj -> String Ok same here >--C#: interface IX3 where A : IY { String foo3(A); } >class IY a where {- ... -} >class IY a => IX3 obj a where > foo3 :: a -> obj -> String Yep I think again I would have guessed at that >--C#: interface IX4 : IZ where A : IY >class IZ a where {- ... -} >class (IY a, IZ obj) => IX4 obj a where > foo4 :: a -> obj -> String Hmmmm...this would have been one of my guesses....but let me have a go... >This assumes your "objects" are immutable, otherwise you would have to >return (obj,String) instead of just String and then you most likely want to >use the state monad and "do notation" to make functional programming look >more like imperative programming. This is fine....my oop is largely immutable. >You really have to drop the OO way of thinking, >which I find the hardest :) >Haskell's type classes are more powerful in some sense than C# interfaces; >for example, in C# you can't attach an interface to any class (take for >example the Point struct), it has to be your own class, while in Haskell, >you can implement an instance of a type class for any datatype! OK but I was going to go onto Interface IX where A : IX { } And Interface IX where A : B { } Where I cannot see a way to do the above in Haskell at all....as interfaces effectively operator on type classes not types....which seems inherently more powerful But if these could be done in Haskell the see what could be made of stuff like....which is obviously problematic in C# it obviously doesn't work....but potentially does make 'sense'. Interface IX : A { } >Hope this helps a bit. As I'm new myself to Haskell, so take this with a >"grain of salt". It does...I will have a go with your sample answers. >Once you bite the bullet, I found Haskell a lot more fun than C#, although >C# of course comes with a gigantic .NET framework and tools... I'm looking at Haskell because of the formality of it's type system....but I'm actually not convinced it is as powerful as an OO one....i.e. OO ones operatate principally (in Haskell speak) on "type classes" not "types" >Peter -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy.... Specifically 1) Interface IX { } 2) Interface IX { } 3) Interface IX Where A : IY { } 4) Interface IX : IZ Where A : IY { } I can take a punt at the first 2....but then it all falls apart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From Nicholls.Mark at mtvne.com Thu Jan 3 05:22:26 2008 From: Nicholls.Mark at mtvne.com (Nicholls, Mark) Date: Thu Jan 3 05:16:40 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: <1965805939.20080102232921@gmail.com> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <1965805939.20080102232921@gmail.com> Message-ID: Can you give me a summary of why it's meaningless.....both would seem to describe/construct values/objects....they may not be equivalent, but I would expect some considerable overlap. -----Original Message----- From: Bulat Ziganshin [mailto:bulat.ziganshin@gmail.com] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: > I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Jan 3 05:54:18 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jan 3 05:53:37 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <1965805939.20080102232921@gmail.com> Message-ID: <915864007.20080103135418@gmail.com> Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. > Can you give me a summary of why it's meaningless.....both would seem to > describe/construct values/objects....they may not be equivalent, but I > would expect some considerable overlap. > -----Original Message----- > From: Bulat Ziganshin [mailto:bulat.ziganshin@gmail.com] > Sent: 02 January 2008 20:29 > To: Nicholls, Mark > Cc: haskell-cafe@haskell.org > Subject: Re: [Haskell-cafe] Is there anyone out there who can translate > C# generics into Haskell? > Hello Mark, > Wednesday, January 2, 2008, 7:40:31 PM, you wrote: >> I'm trying to translate some standard C# constucts into Haskell... > some > it's meaningless. read > http://haskell.org/haskellwiki/OOP_vs_type_classes > and especially papers mentioned in the References -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lemming at henning-thielemann.de Thu Jan 3 06:06:11 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jan 3 06:00:09 2008 Subject: [Haskell-cafe] Re: check if program uses haskell 98 only? In-Reply-To: References: Message-ID: On Thu, 6 Dec 2007, Henning Thielemann wrote: > On Thu, 6 Dec 2007, Thomas Hartman wrote: > > > On a related note... is there some easy way to be sure that a program I am > > compiling uses only haskell 98? (Because any pure haskell 98 should always > > compile on yhc... right?) > > You can for instance use 'haskell98' as dependent package instead of > 'base' in the Cabal description. If you import other modules, I don't know > how to check that these are Haskell 98. I weakly remember corner cases > where GHC accepts more than Haskell 98 in Haskell 98 mode. (At least it > sometimes suggests fixes for errors that are not Haskell 98, e.g. class > constraints in signatures. :-) Now I have an example: GHC-6.4.1 accepts multi parameter type class constraints without '-fglasgow-exts'. > > I compile this with ghc, no options, and iIt doesn't have any {-#-#} > > options, so according to what I understand, it is using pure haskell 98. > > So I might think this was a candidate for using on yhc. > > I could not always pass a GHC-certified module to Hugs or even Haddock. I > remember there is some difference with respect to the trailing 'where' in > the 'instance' head, if the instance declaration is empty. Haddock expect > some spaces in infix operators (I believe ( # ) instead of (#)), which are > not required by Hugs and GHC. From barsoap at web.de Thu Jan 3 06:08:47 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jan 3 06:02:53 2008 Subject: [Haskell-cafe] Re: The Worker/Wrapper Transformation References: <20080103105916.7d562d17@solaris.tower> Message-ID: <20080103120847.13725ce6@solaris.tower> Achim Schneider wrote: > [...] I'm trying to grok that [] = id ++ = . in the context of Hughes lists. I guess it would stop to slip away if I knew what : corresponds to. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From simonmarhaskell at gmail.com Thu Jan 3 06:11:40 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Thu Jan 3 06:05:40 2008 Subject: [Haskell-cafe] Re: announcing darcs 2.0.0pre2 In-Reply-To: <20071221143254.GO11036@darcs.net> References: <20071216211722.GI11101@darcs.net> <47666BA0.2080408@microsoft.com> <20071221143254.GO11036@darcs.net> Message-ID: <477CC2EC.2030302@microsoft.com> David Roundy wrote: > Anyhow, could you retry this test with the above change in methodology, and > let me know if (a) the pull is still slow the first time and (b) if it's > much faster the second time (after the reverse unpull/pull)? I think I've done it in both directions now, and it got faster, but still much slower than darcs1: $ time darcs2 unpull --from-tag 2007-09-25 -a Finished unpulling. 58.68s real 50.64s user 6.36s system 97% darcs2 unpull --from-tag 2007-09-25 -a $ time darcs2 pull -a ../ghc-darcs2 Pulling from "../ghc-darcs2"... Finished pulling and applying. 53.28s real 44.62s user 7.10s system 97% darcs2 pull -a ../ghc-darcs2 This is still an order of magnitude slower than darcs1 for the same operation. (these times are now on the local filesystem, BTW) Cheers, Simon From Nicholls.Mark at mtvne.com Thu Jan 3 06:13:08 2008 From: Nicholls.Mark at mtvne.com (Nicholls, Mark) Date: Thu Jan 3 06:07:07 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: <915864007.20080103135418@gmail.com> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <1965805939.20080102232921@gmail.com> <915864007.20080103135418@gmail.com> Message-ID: I loosely do understand....but very loosely....but I'm not, as yet, convinced it is completely relevant. The implementation may differ, but that does not mean that there is no overlap....I am not expecting one model to be a superset of the other, but I am expecting some sort of overlap between 'interface' implementation and type class instance declaration. -----Original Message----- From: Bulat Ziganshin [mailto:bulat.ziganshin@gmail.com] Sent: 03 January 2008 10:54 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. > Can you give me a summary of why it's meaningless.....both would seem to > describe/construct values/objects....they may not be equivalent, but I > would expect some considerable overlap. > -----Original Message----- > From: Bulat Ziganshin [mailto:bulat.ziganshin@gmail.com] > Sent: 02 January 2008 20:29 > To: Nicholls, Mark > Cc: haskell-cafe@haskell.org > Subject: Re: [Haskell-cafe] Is there anyone out there who can translate > C# generics into Haskell? > Hello Mark, > Wednesday, January 2, 2008, 7:40:31 PM, you wrote: >> I'm trying to translate some standard C# constucts into Haskell... > some > it's meaningless. read > http://haskell.org/haskellwiki/OOP_vs_type_classes > and especially papers mentioned in the References -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jens.blanck at gmail.com Thu Jan 3 06:40:01 2008 From: jens.blanck at gmail.com (Jens Blanck) Date: Thu Jan 3 06:33:58 2008 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 53, Issue 2 In-Reply-To: <20080103101645.90F9F3242E7@www.haskell.org> References: <20080103101645.90F9F3242E7@www.haskell.org> Message-ID: <7b1ffbe0801030340j2676fe2x272b9a836c59773f@mail.gmail.com> > The normal view taken by Haskellers is that the denotations of > > Haskell types are CPPOs. > > CPPO? > > > So: > > > > (1) Must be monotone > > (2) Must be continuous > > Could you please define what you mean by those terms > in this context? > > > (Needn't be strict, even though that messes up the resulting category > > substantially). > > I'm not convinced that the category is all that "messed up". > > The extra P would stand for "pointed" (has a least element, bottom), this is common in some communities. To me though, a cpo (complete partial order) is closed under directed suprema and the empty set is directed so bottom is already required. The category of cpos in not cartesian closed. For denotational semantics I believe the subcategory of Scott domains are what is usually considered. Continuous functions on cpos are by definition monotone and they respect directed suprema. Jens -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080103/069257f7/attachment.htm From bos at serpentine.com Thu Jan 3 06:43:49 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Jan 3 06:37:45 2008 Subject: [Haskell-cafe] ANN / CFP - LLVM bindings for Haskell Message-ID: <477CCA75.4090101@serpentine.com> This is an early release of Haskell bindings for the popular LLVM compiler infrastructure project. If you don't know what LLVM is, it's a wonderful toybox of compiler components, from a complete toolchain supporting multiple architectures through a set of well-defined APIs and IR formats that are designed for building interesting software with. The official LLVM home page is here: http://llvm.org/ The Haskell bindings are based on Gordon Henriksen's C bindings. The C bindings are almost untyped, but the Haskell bindings re-add type safety to prevent runtime crashes and general badness. Currently, the entire code generation system is implemented, with most LLVM data types supported (notably absent are structs). Also plugged in is JIT support, so you can generate code at runtime from Haskell and run it immediately. I've attached an example. Please join in the hacking fun! darcs get http://darcs.serpentine.com/llvm If you want a source tarball, fetch it from here: http://darcs.serpentine.com/llvm/llvm-0.0.2.tar.gz (Hackage can't host code that uses GHC 6.8.2's language extension names yet.) There's very light documentation at present, but it ought to be enough to get you going. :1 [#uses=1] br i1 %1, label %return, label %recurse return: ; preds = %entry ret i32 1 recurse: ; preds = %entry sub i32 %0, 1 ; :2 [#uses=1] call i32 @fib( i32 %2 ) ; :3 [#uses=1] sub i32 %0, 2 ; :4 [#uses=1] call i32 @fib( i32 %4 ) ; :5 [#uses=1] add i32 %3, %5 ; :6 [#uses=1] ret i32 %6 } fib 10 = 55 From byorgey at gmail.com Thu Jan 3 06:54:04 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Thu Jan 3 06:48:00 2008 Subject: [Haskell-cafe] Re: The Worker/Wrapper Transformation In-Reply-To: <20080103120847.13725ce6@solaris.tower> References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> Message-ID: <22fcbd520801030354x5e0211f6m45eb6220785acaab@mail.gmail.com> On Jan 3, 2008 6:08 AM, Achim Schneider wrote: > Achim Schneider wrote: > > > [...] > > I'm trying to grok that > > [] = id > ++ = . > > in the context of Hughes lists. > > I guess it would stop to slip away if I knew what : corresponds to. > Well, (:) has type a -> [a] -> [a], so a function corresponding to (:) for Hughes lists should have type foo :: a -> H a -> H a that is, foo :: a -> ([a] -> [a]) -> [a] -> [a] so it can be written foo x h = (x:) . h which lambdabot informs me can also be written as (.) . (:). But in the end I'm not sure how helpful that is for understanding Hughes lists! I think the key sentence from the paper is this: "by representing a list xs as the function (xs ++) that appends this list to another list that has still to be supplied." If you understand that sentence, then you can understand why [] is id and (++) is (.). -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080103/b48a6e3f/attachment.htm From bf3 at telenet.be Thu Jan 3 07:02:07 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Thu Jan 3 06:56:02 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <004a01c84d7e$556a3160$003e9420$@vers@telenet.be> Message-ID: <002c01c84e00$76b74d30$6425e790$@be> Hi Mark, >> "foo1 :: Int -> obj -> String" > Yep...I think that's what I'd do....though I would have done... > "foo1 :: obj -> Int -> String" > Does that matter? Well, it's a good habit in Haskell to move the "most important" parameter to the end of the argument list. See e.g. http://www.haskell.org/haskellwiki/Parameter_order. > OK but I was going to go onto > Interface IX where A : IX {} > and > Interface IX where A : B {} No, I would not know how to that in Haskell using type classes. It seems Haskell does not allow cycles in type class definitions. But as I'm new, this does not mean it's not possible. It's more important to know *what* you are trying to do, than to give a solution in a different language, since OO and FP are kind of orthogonal languages. > Where I cannot see a way to do the above in Haskell at all....as > interfaces effectively operator on type classes not types....which seems > inherently more powerful Yeah, kind of makes sense. I liked interfaces in C# a lot, but when I started doing everything with interfaces, I found the lack of support for "mixins" or "default implementations" problematic. This ended up in a lot of copy/paste or encapsulating the implementations into a static class with plain functions, a mess. > But if these could be done in Haskell the see what could be made of > stuff like....which is obviously problematic in C# it obviously doesn't > work....but potentially does make 'sense'. > Interface IX : A {} Ah! That's one of the bigger restrictions in C# yes! C++ can do that; ATL uses it a lot, and I also like that approach. You can emulate "mixins" with that, and still stay in the single inheritance paradigm. In Haskell you don't do that at all of course, since you avoid thinking about "objects and inheritance" in the first place. OO is strange. They offer you the nice concept of inheritance, and then the guidelines tell you: "don't use too many levels of inheritance"... Although I've build huge projects using OO, it always felt a bit like unsafe hacking. I don't really have that feeling with Haskell, but that could also be because I'm too new to the language ;-) > I'm looking at Haskell because of the formality of it's type > system....but I'm actually not convinced it is as powerful as an OO > one....i.e. OO ones operatate principally (in Haskell speak) on "type > classes" not "types" Maybe you are right, I don't know, my theoritical skills are not high enough to answer that. Haskell just "feels" better to me, although the lack of a friendly productive IDE and large standard framework remains a bit of a burden. Good luck, Peter -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy.... Specifically 1) Interface IX { } 2) Interface IX { } 3) Interface IX Where A : IY { } 4) Interface IX : IZ Where A : IY { } I can take a punt at the first 2....but then it all falls apart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From barsoap at web.de Thu Jan 3 07:15:15 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jan 3 07:09:27 2008 Subject: [Haskell-cafe] Re: The Worker/Wrapper Transformation References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> <22fcbd520801030354x5e0211f6m45eb6220785acaab@mail.gmail.com> Message-ID: <20080103131515.17058b6a@solaris.tower> "Brent Yorgey" wrote: > > Well, (:) has type a -> [a] -> [a], so a function corresponding to > (:) for Hughes lists should have type > > foo :: a -> H a -> H a > > [...] > I think the key sentence from the paper is this: "by > representing a list xs as the function (xs ++) that appends this list > to another list that has still to be supplied." If you understand > that sentence, then you can understand why [] is id and (++) is (.). > Yes, I did. They key was not thinking that : has type (:) :: a -> a -> [a] , or, put differently, beat the lisp out of me, thanks. The problem is merely that Haskell and lisp are too similar in a much too different way. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From barsoap at web.de Thu Jan 3 07:34:26 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jan 3 07:28:35 2008 Subject: [Haskell-cafe] Re: The Worker/Wrapper Transformation References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> <22fcbd520801030354x5e0211f6m45eb6220785acaab@mail.gmail.com> <20080103131515.17058b6a@solaris.tower> Message-ID: <20080103133426.4d9bc0b9@solaris.tower> Achim Schneider wrote: > "Brent Yorgey" wrote: > > > > > Well, (:) has type a -> [a] -> [a], so a function corresponding to > > (:) for Hughes lists should have type > > > > foo :: a -> H a -> H a > > > > [...] > > I think the key sentence from the paper is this: "by > > representing a list xs as the function (xs ++) that appends this > > list to another list that has still to be supplied." If you > > understand that sentence, then you can understand why [] is id and > > (++) is (.). > > > Yes, I did. > > They key was not thinking that : has type > > (:) :: a -> a -> [a] > > , or, put differently, beat the lisp out of me, thanks. > What the hell am I talking about? (define (cons x y) (lambda (m) (m x y))) (define (car z) (z (lambda (p q) p))) (define (cdr z) (z (lambda (p q) q))) : is, in a sense, \. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From isaacdupree at charter.net Thu Jan 3 07:46:32 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jan 3 07:40:28 2008 Subject: [Haskell-cafe] The Worker/Wrapper Transformation In-Reply-To: <20080103105916.7d562d17@solaris.tower> References: <20080103105916.7d562d17@solaris.tower> Message-ID: <477CD928.20706@charter.net> Achim Schneider wrote: > ...is a paper about automatic specialisation of functions by unboxing > arguments, one could say. I'm only on page 6, but already survived the > first formalisms, which is bound to mean that the rest of the paper is > likewise accessible, as hinted on at ltu. > > http://www.cs.nott.ac.uk/~gmh/wrapper.pdf > > The transformation itself is mindbogglingly easy, which makes this a > good start: You only have to understand the formalisms, not so much what > the formalisms are representing. To quote spj: It usually turns out to > be more interesting and challenging than it seemed at first. > > I'm tempted to write that this is a paper for everyone trying to figure > out what the heck Jonathan is talking about. > I like it! Of course the technique itself doesn't provide guidance on what type you want to transform a function to. on page 6, stronger vs weaker seemed backwards to me... isn't (wrap ? unwrap = idA) a stronger condition than (wrap ? unwrap ? body = body), because it tells you more, and is true in fewer cases? (which is also why you want to assume (wrap ? unwrap = idA) when you can, because it's the most useful one for subsequent program transformation) and then the inevitable minor copy-editing :-) p. 22. intentional properties --> intensional (right?) p. 27. typo 'unwarp' for 'unwrap' BTW. GHC currently does allow e.g. (I# (1# +# 2#)), not just (case (1# +# 2#) of n# -> I# n#) -- the strictness implications seem pretty straightforwards (it's trivial to transform away). p. 29. "in both these system" -> systems ~Isaac From Nicholls.Mark at mtvne.com Thu Jan 3 07:48:17 2008 From: Nicholls.Mark at mtvne.com (Nicholls, Mark) Date: Thu Jan 3 07:42:25 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: <002c01c84e00$76b74d30$6425e790$@be> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <004a01c84d7e$556a3160$003e9420$@vers@telenet.be> <002c01c84e00$76b74d30$6425e790$@be> Message-ID: Ahh ok I see what is meant by the parameter order.... -----Original Message----- From: Peter Verswyvelen [mailto:peter.vers@telenet.be] On Behalf Of Peter Verswyvelen Sent: 03 January 2008 12:02 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hi Mark, >> "foo1 :: Int -> obj -> String" > Yep...I think that's what I'd do....though I would have done... > "foo1 :: obj -> Int -> String" > Does that matter? Well, it's a good habit in Haskell to move the "most important" parameter to the end of the argument list. See e.g. http://www.haskell.org/haskellwiki/Parameter_order. > OK but I was going to go onto > Interface IX where A : IX {} > and > Interface IX where A : B {} No, I would not know how to that in Haskell using type classes. It seems Haskell does not allow cycles in type class definitions. But as I'm new, this does not mean it's not possible. It's more important to know *what* you are trying to do, than to give a solution in a different language, since OO and FP are kind of orthogonal languages. > Where I cannot see a way to do the above in Haskell at all....as > interfaces effectively operator on type classes not types....which seems > inherently more powerful Yeah, kind of makes sense. I liked interfaces in C# a lot, but when I started doing everything with interfaces, I found the lack of support for "mixins" or "default implementations" problematic. This ended up in a lot of copy/paste or encapsulating the implementations into a static class with plain functions, a mess. > But if these could be done in Haskell the see what could be made of > stuff like....which is obviously problematic in C# it obviously doesn't > work....but potentially does make 'sense'. > Interface IX : A {} Ah! That's one of the bigger restrictions in C# yes! C++ can do that; ATL uses it a lot, and I also like that approach. You can emulate "mixins" with that, and still stay in the single inheritance paradigm. In Haskell you don't do that at all of course, since you avoid thinking about "objects and inheritance" in the first place. OO is strange. They offer you the nice concept of inheritance, and then the guidelines tell you: "don't use too many levels of inheritance"... Although I've build huge projects using OO, it always felt a bit like unsafe hacking. I don't really have that feeling with Haskell, but that could also be because I'm too new to the language ;-) > I'm looking at Haskell because of the formality of it's type > system....but I'm actually not convinced it is as powerful as an OO > one....i.e. OO ones operatate principally (in Haskell speak) on "type > classes" not "types" Maybe you are right, I don't know, my theoritical skills are not high enough to answer that. Haskell just "feels" better to me, although the lack of a friendly productive IDE and large standard framework remains a bit of a burden. Good luck, Peter -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy.... Specifically 1) Interface IX { } 2) Interface IX { } 3) Interface IX Where A : IY { } 4) Interface IX : IZ Where A : IY { } I can take a punt at the first 2....but then it all falls apart _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From isaacdupree at charter.net Thu Jan 3 07:49:36 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jan 3 07:43:31 2008 Subject: [Haskell-cafe] Re: The Worker/Wrapper Transformation In-Reply-To: <20080103120847.13725ce6@solaris.tower> References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> Message-ID: <477CD9E0.6060604@charter.net> Achim Schneider wrote: > Achim Schneider wrote: > >> [...] > > I'm trying to grok that > > [] = id > ++ = . > > in the context of Hughes lists. they are also known as "difference lists", and also used at type String in the Prelude as "ShowS", to help avoid quadratic behavior when making complicated Strings. the [a]->[a] is not an ordinary function -- it's expected not to examine its argument, just to use it exactly once (is there a formal way to say that?) ~Isaac From barsoap at web.de Thu Jan 3 08:21:09 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jan 3 08:15:12 2008 Subject: [Haskell-cafe] Re: The Worker/Wrapper Transformation References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> <22fcbd520801030354x5e0211f6m45eb6220785acaab@mail.gmail.com> <20080103131515.17058b6a@solaris.tower> <20080103133426.4d9bc0b9@solaris.tower> Message-ID: <20080103142109.6d3de8ee@solaris.tower> Achim Schneider wrote: > (define (cons x y) > (lambda (m) (m x y))) > > (define (car z) > (z (lambda (p q) p))) > > (define (cdr z) > (z (lambda (p q) q))) > , which, just for completeness, can be of course also be done in Haskell: cons :: a -> b -> (a -> b -> c) -> c cons x y m = m x y car :: ((a -> b -> a) -> c) -> c car z = z $ \p q -> p cdr :: ((a -> b -> b) -> c) -> c cdr z = z $ \p q -> q Prelude> car $ cdr $ cdr $ cons 1 $ cons 2 $ cons 3 () 3 -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From lemming at henning-thielemann.de Thu Jan 3 08:48:58 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jan 3 08:42:54 2008 Subject: [Haskell-cafe] Difference lists and ShowS (Was: The Worker/Wrapper Transformation) In-Reply-To: <477CD9E0.6060604@charter.net> References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> <477CD9E0.6060604@charter.net> Message-ID: On Thu, 3 Jan 2008, Isaac Dupree wrote: > Achim Schneider wrote: > > Achim Schneider wrote: > > > >> [...] > > > > I'm trying to grok that > > > > [] = id > > ++ = . > > > > in the context of Hughes lists. > > they are also known as "difference lists", and also used at type String > in the Prelude as "ShowS", to help avoid quadratic behavior when making > complicated Strings. Sometimes I believed that I understand this reason, but then again I do not understand. I see that left-associative (++) like in ((a0 ++ a1) ++ a2) ++ a3 would cause quadratic time. But (++) is right-associative and 'concat' is 'foldr'. They should not scan the leading lists more than once. Also http://en.wikipedia.org/wiki/Difference_list doesn't answer this question. Where exactly is the problem? From bf3 at telenet.be Thu Jan 3 08:58:47 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Thu Jan 3 08:52:57 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: References: <000a01c84d35$b64d3de0$22e7b9a0$@be> Message-ID: <477CEA17.2090306@telenet.be> Looks good! I liked relational algebra much much more than SQL, so I'll certainly have to look into that. Thanks, Peter Justin Bailey wrote: > I can speak to haskelldb a little, see below: > > On Jan 2, 2008 3:50 AM, Peter Verswyvelen wrote: > >> ? regarding Haskell and databases, the page >> http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces >> describes a few, but which are the ones that are stable and practical? Any >> user experiences? >> > > I started looking at haskell database libraries to generate SQL for > me. Haskelldb does this well - it uses a higher-level representation > of queries based on "relational algebra" (also the basis of SQL) which > is pretty easy to understand if you know SQL. It takes care of a lof > the details of generating SQL strings, and does it in a mostly > type-safe way. > > It is a bit complicated to install the library and all its > dependencies, because it can work with 3+ (mysql, postgres, odbc) > databases using two different backends (hdbc and hsql). I chose to go > with HDBC because it compiled on Windows and postgres because thats > what we have at my workplace. Once I got it built and installed its > worked well for me. > > Until the most recent versions though, it added a "distinct" operator > to all select statements. I submitted a patch which was accepted and > now that behavior is no longer the default. It is semi-actively > maintained by the original authors and Bjorn, at least, has been very > responsive to my queries on the haskelldb-users mailing list. He also > has made minor updates to keep it compiling with the latest GHC and > Cabal. > > Hope that helps! > > Justin > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080103/c544602a/attachment.htm From gale at sefer.org Thu Jan 3 09:25:08 2008 From: gale at sefer.org (Yitzchak Gale) Date: Thu Jan 3 09:19:04 2008 Subject: [Haskell-cafe] Basic question concerning data constructors In-Reply-To: References: <49a77b7a0712301219y6959db9y967a9cb75427443d@mail.gmail.com> <20071231011748.sq6ryegp6o8cg4c0@webmail.spamcop.net> <2608b8a80801010733q3f5f4a6ewfba794151757578a@mail.gmail.com> <2608b8a80801010743m33409e52w97ba1ad8da9518d9@mail.gmail.com> <7ca3f0160801011557x8fc901bv795da1d81662dacb@mail.gmail.com> <2608b8a80801020134y584f52f2t612554f44364365a@mail.gmail.com> Message-ID: <2608b8a80801030625s2a8b3eebh69db2efbc26600e9@mail.gmail.com> Hi Benja, I wrote: >> By the type expression Integer -> Integer >> we mean all Haskell functions mapping Integers to Integers. >> There are only countably many of those. > ... >> But that was not the context in this thread. The category >> Hask that we often mention in discussions about Haskell >> the programming language is most certainly a small category. Benja Fallenstein wrote: > I don't know. My understanding has been that at least part of the > benefit of denotational semantics is that you can define what an > expression means without referring back to the syntactic construction > or the operational semantics of that expression -- and thus use the > denotational semantics to check whether the operational semantics are > "right." But if you start with "all Haskell functions," you already > have to know what a Haskell function *is*. Denotational semantics maps expressions in a language - hence, syntax - into something that represents their semantics. You can choose different such mappings to represent different semantics of the same expressions. The Haskell Report clearly defines what a Haskell function is in terms of syntax. So my semantics are well-defined, and they represent what I understand when I read a Haskell program. In fact, these semantics do not really depend on all aspects of the syntax - only the existence of certain primitive functions, and certain constructions such as function definition, pattern matching, ADTs, etc. The same assumptions are made for any semantics of Haskell. Benja Fallenstein wrote: > I think it should be "allowed" to think of the semantics of Haskell as > being defined independently of the (relatively operational) notion of > "computable function," and then define "computable function" to be > that subset of the functions in the model that you can actually write > in Haskell. "Computable function" is not operational - it just means functions that are lambdas, if you'd like. It just so happens that, so far, those are the only functions we know how to compute operationally. Maybe that quantum stuff... But yes, sure you can do that. That seems to be the approach in some papers. In particular, the one by Reynolds in which he proves that Haskell types cannot be represented by sets. Sounds like strong evidence that those are the wrong semantics to choose when studying Haskell as a programming language. Though it is certainly interesting to do so in a theoretical setting. > And the only explicit non-syntactic constructions of > models for Haskell-like languages that I'm familiar with aren't > countable (they contain all continuous functions, which in the case of > (Integer -> Integer) comes out to all monotonous functions). It is not any less syntactic than mine. It only differs in the semantics assigned to the symbol Integer -> Integer. > So I disagree that the function types of Hask should automatically be > taken to be countable. No, I agree with you. It's not automatic. It depends on your choice of semantics. > If you want to assume it for some given > purpose, sure, fine, but IMO that's an additional assumption, not > something inherent in the Haskell language. Agreed. Thanks, Yitz From h._h._h._ at hotmail.com Thu Jan 3 09:29:30 2008 From: h._h._h._ at hotmail.com (H.) Date: Thu Jan 3 09:23:34 2008 Subject: [Haskell-cafe] Re: Escape Codes References: <404396ef0801020821j185f4b6eoe2f14462eb154b62@mail.gmail.com> Message-ID: Hi, > It would be nice if you could package this and release it on hackage. > http://hackage.haskell.org/packages/hackage.html I packaged it, perhaps you can have a look at it, if it is, what you thought... When I get a username, I'll put it on hackage :) -- H. From gale at sefer.org Thu Jan 3 09:32:44 2008 From: gale at sefer.org (Yitzchak Gale) Date: Thu Jan 3 09:26:39 2008 Subject: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors) In-Reply-To: <2608b8a80801030033g184cb3e5sb51056b92ae67355@mail.gmail.com> References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <25C23866-F3AB-4510-9DDD-48A50B72835B@fastmail.fm> <2608b8a80801030033g184cb3e5sb51056b92ae67355@mail.gmail.com> Message-ID: <2608b8a80801030632v1c731c06x8b4327a4dbec12e6@mail.gmail.com> Jonathan Cast wrote: >>> The normal view taken by Haskellers is that the denotations of >>> Haskell types are CPPOs. I wrote: >> CPPO? >>> (1) Must be monotone >>> (2) Must be continuous >> Could you please define what you mean by those terms >> in this context? Jens Blanck wrote: > The extra P would stand for "pointed" (has a least element, bottom), this is > common in some communities. To me though, a cpo (complete partial order) is > closed under directed suprema and the empty set is directed so bottom is > already required. The category of cpos in not cartesian closed. For > denotational semantics I believe the subcategory of Scott domains are what > is usually considered. > > Continuous functions on cpos are by definition monotone and they respect > directed suprema. Thanks! Yitz From bulat.ziganshin at gmail.com Thu Jan 3 09:38:43 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jan 3 09:35:02 2008 Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? In-Reply-To: References: <2608b8a80801020549k1fe4f756q8e7337b81c032a6e@mail.gmail.com> <1965805939.20080102232921@gmail.com> <915864007.20080103135418@gmail.com> Message-ID: <8627368.20080103173843@gmail.com> Hello Mark, Thursday, January 3, 2008, 2:13:08 PM, you wrote: of course *some* overlap exists but in order to understand it you should know exact shape of both methods when i tried to develop complex library without understanding t.c. implementation, i constantly goes into the troubles - things that i (using my OOP experience) considered as possible, was really impossible in Haskell so i'm really wonder why you don't want to learn the topic thoroughly > I loosely do understand....but very loosely....but I'm not, as yet, > convinced it is completely relevant. > The implementation may differ, but that does not mean that there is no > overlap....I am not expecting one model to be a superset of the other, > but I am expecting some sort of overlap between 'interface' > implementation and type class instance declaration. > -----Original Message----- > From: Bulat Ziganshin [mailto:bulat.ziganshin@gmail.com] > Sent: 03 January 2008 10:54 > To: Nicholls, Mark > Cc: Bulat Ziganshin; haskell-cafe@haskell.org > Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can > translate C# generics into Haskell? > Hello Mark, > Thursday, January 3, 2008, 1:22:26 PM, you wrote: > because they have different models. i recommend you to start from > learning this model, otherwise you will don't understand how Haskell > really works and erroneously apply your OOP knowledge to Haskell data > structures. > shortly said, there are 3 ways to polymorphism: > 1) C++ templates - type-specific code generated at compile time > 2) OOP classes - every object carries VMT which allows to select > type-specific operation > 3) type classes - dictionary of type-specific operations is given as > additional hidden argument to each function > Haskell uses t.c. and its abilities are dictated by this > implementation. there is no simple and direct mapping between > features provided by OOP and t.c. >> Can you give me a summary of why it's meaningless.....both would seem > to >> describe/construct values/objects....they may not be equivalent, but I >> would expect some considerable overlap. >> -----Original Message----- >> From: Bulat Ziganshin [mailto:bulat.ziganshin@gmail.com] >> Sent: 02 January 2008 20:29 >> To: Nicholls, Mark >> Cc: haskell-cafe@haskell.org >> Subject: Re: [Haskell-cafe] Is there anyone out there who can > translate >> C# generics into Haskell? >> Hello Mark, >> Wednesday, January 2, 2008, 7:40:31 PM, you wrote: >>> I'm trying to translate some standard C# constucts into Haskell... >> some >> it's meaningless. read >> http://haskell.org/haskellwiki/OOP_vs_type_classes >> and especially papers mentioned in the References -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From barsoap at web.de Thu Jan 3 09:41:15 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jan 3 09:35:20 2008 Subject: [Haskell-cafe] Re: Difference lists and ShowS (Was: The Worker/Wrapper Transformation) References: <20080103105916.7d562d17@solaris.tower> <20080103120847.13725ce6@solaris.tower> <477CD9E0.6060604@charter.net> Message-ID: <20080103154115.28a84ce3@solaris.tower> Henning Thielemann wrote: > Sometimes I believed that I understand this reason, but then again I > do not understand. I see that left-associative (++) like in > ((a0 ++ a1) ++ a2) ++ a3 > would cause quadratic time. But (++) is right-associative and > 'concat' is 'foldr'. They should not scan the leading lists more than > once. Also > http://en.wikipedia.org/wiki/Difference_list > doesn't answer this question. Where exactly is the problem? > | The shows functions return a function that prepends the output String | to an existing String. This allows constant-time concatenation of | results using function composition. I figure it's (constant vs. linear) vs. (linear vs. quadratic), for more involved examples. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From gale at sefer.org Thu Jan 3 09:45:42 2008 From: gale at sefer.org (Yitzchak Gale) Date: Thu Jan 3 09:39:39 2008 Subject: [Haskell-cafe] Consensus about databases / serialization In-Reply-To: <477CEA17.2090306@telenet.be> References: <000a01c84d35$b64d3de0$22e7b9a0$@be> <477CEA17.2090306@telenet.be> Message-ID: <2608b8a80801030645w1581fde6pe87b72497555b396@mail.gmail.com> Peter Verswyvelen wrote: > Looks good! I liked relational algebra much much more than SQL, so I'll > certainly have to look into that. I agree. I have not tried haskelldb yet, but I would like to. My impression from some previous posts is that because of the high-level approach, it is difficult to control the precise SQL that is generated. In practice, y