From jon at ffconsultancy.com Fri Jun 1 01:10:04 2007 From: jon at ffconsultancy.com (Jon Harrop) Date: Fri Jun 1 01:11:13 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: <465F287F.9060100@btinternet.com> References: <200705300704.32070.jon@ffconsultancy.com> <200705302356.30255.jon@ffconsultancy.com> <465F287F.9060100@btinternet.com> Message-ID: <200706010610.05130.jon@ffconsultancy.com> On Thursday 31 May 2007 20:56:47 Andrew Coppin wrote: > Jon Harrop wrote: > > If you write a simple, numerically-intensive program that runs in the > > Mathematica rewriter then its performance is about 100-1,000x slower than > > that of a native-code compiled language like Haskell. Mathematica is > > often 30x slower than interpreted OCaml bytecode. > > Is this before or after compiling the Mathematica code? The 100-1,000x slower is without compilation in Mathematica. I found the ray tracer to be 30x slower in compiled Mathematica compared to OCaml bytecode (OCaml native code is much faster still). So GHC will easily beat Mathematica on such tasks. Incidentally, once you've reimplemented the core Mathematica language in 4 days, you might like to reimplement their compiler. I believe their spec is freely available but you could just redo the whole thing yourself. You could probably extend it and optimise it quite easily. For example, it doesn't support recursion and I don't think it does type inference. > I don't know, I thought one of the big advantages of Mathematica was > supposed to be that it can transform problems into the most efficiently > solvable form, select between multiple algorithms, etc. On certain very specific problems, yes. So it might check to see if a matrix is symmetric and use a faster routine when possible. As far as the languange itself is concerned, it is fairly mundane. > And I mostly use it to do insane things like give me parametric > solutions to giant polynomials and so forth... ;-) I used it to take integrals, do lots of FFTs, some general data analysis and lots of graph plotting. There are plenty of other computer algebra packages that could handle the integrals (although I never found any were better than just doing it by hand) and general-purpose languages that are better suited to the analysis, so now I just use it as a graph plotter. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?e From stefan at cs.uu.nl Fri Jun 1 00:27:54 2007 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jun 1 01:37:33 2007 Subject: [Haskell-cafe] What puts False before True? In-Reply-To: <20070531205120.GA8785@heave.ugcs.caltech.edu> References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> <200705310731.49932.coeus@gmx.de> <7.0.1.0.0.20070531095635.01b70648@ntlworld.com> <20070531205120.GA8785@heave.ugcs.caltech.edu> Message-ID: <8E6D6640-CE65-46A7-AC79-7BF4F2251CAD@cs.uu.nl> Brandon, > If I'm reading the reports correctly, the Ord instance was > actually added in the Haskell 1.1 standard, by changing the > definition of Bool from > > data Bool = True | False > > to > > data Bool = True | False deriving (Eq, Ord, Ix, Enum, Text, Binary) It's data Bool = False | True > It seems like we actually get that order because deriving Ord makes > constructors earlier in the definition compare greater than later > constructors, and nobody was bothered by that ordering. It's the other way around: data T = Less | More deriving (Eq, Ord) gives you *Main> Less < More True Cheers, Stefan From adimri.iitkgp at gmail.com Fri Jun 1 01:48:32 2007 From: adimri.iitkgp at gmail.com (ashutosh dimri) Date: Fri Jun 1 01:44:13 2007 Subject: [Haskell-cafe] Haskell Quiry Message-ID: <86bc2fa10705312248l3419005fr2ace300504626cdd@mail.gmail.com> I want to read some data from a file "Signature.ken" , for that I have written a program but its showing some errors (the file "signature.ken" contains data of the type = (122,152) ) main = do j <- readFile "sig1.key" let (x,y) = (read j) putStrLn ("value=" ++ (show (x,y))) ERROR file:.\-as.hs:5 - Unresolved top-level overloading *** Binding : main *** Outstanding context : (Read c, Read b, Show c, Show b) From stefan at cs.uu.nl Fri Jun 1 01:57:19 2007 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jun 1 01:53:06 2007 Subject: [Haskell-cafe] Haskell Quiry In-Reply-To: <86bc2fa10705312248l3419005fr2ace300504626cdd@mail.gmail.com> References: <86bc2fa10705312248l3419005fr2ace300504626cdd@mail.gmail.com> Message-ID: <71E4F596-124A-4E01-B528-9AF1AAAD4572@cs.uu.nl> Ashutosh, > ERROR file:.\-as.hs:5 - Unresolved top-level overloading > *** Binding : main > *** Outstanding context : (Read c, Read b, Show c, Show b) Add an type annotation: main = do j <- readFile "sig1.key" let (x,y) = (read j) :: (Int, Int) -- <----- putStrLn ("value=" ++ (show (x,y))) Cheers, Stefan From alex at alexjacobson.com Fri Jun 1 05:38:53 2007 From: alex at alexjacobson.com (Alex Jacobson) Date: Fri Jun 1 05:34:43 2007 Subject: [Haskell-cafe] how do I pass customization items in syb code? Message-ID: <465FE92D.8050506@alexjacobson.com> I'm looking at the XML SYB example http://www.cs.vu.nl/boilerplate/testsuite/xmlish/Main.hs I'd like to find a way to pass other type customizations as arguments to data2content and content2data. I modified data2Content as follows: data2content f = element `ext1Q` list `extQ` string `extQ` f But I can't figure out how to give f a type such that (data2Content $ myFooElem `extQ` myBarElem) operates on both Foo and Bar elements. Right now I am giving f the type f::(a->[Content]) which compiles but causes the wrong behavior. Any recommendations on how to fix this? -Alex- From jon.fairbairn at cl.cam.ac.uk Fri Jun 1 05:54:28 2007 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Fri Jun 1 05:50:18 2007 Subject: [Haskell-cafe] Re: Just for a laugh... References: <465F2650.4070807@btinternet.com> <465F31A4.5060608@btinternet.com> <2d3641330705311406x1c572cb7pa92460b95b310ac6@mail.gmail.com> Message-ID: "Dougal Stanton" writes: > On 31 May 2007 21:52:33 +0100, > Jon Fairbairn wrote: > > Yes, but you didn't say that it's not only silly but > > demonstrates the opposite of expressiveness as it's all > > about breaking an abstraction and must be non-portable > > code (because it's definition is that it won't give the > > same results on different hardware), so such code should > > be *hard* to write in a good language. > > Well, I would suggest that maybe *good* is not completely > congruent with *expressive* (at least for this case). If I > want to write a program to learn how IEEE floats are > constructed, by destructing them, then I *should* be able > to. You can. Getting a notion of how they are constructed (independent of the precise hardware) is easy, (just try foo x = floatToDigits (floatRadix x) x foo (1/0) together with looking at floatDigits etc), getting the precise machine representation is harder (but possible). But then, if you want to do that, why shouldn't you use some assembler? It would be even more instructive, after all. > I have no solutions of my own though :-( I wait in eager > expectation.... Isn't the combination of the functions mentioned earlier in the thread enough for you to do it? (even disregarding unsafeCoerce). -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From bulat.ziganshin at gmail.com Fri Jun 1 06:07:30 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jun 1 06:07:40 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <465F2650.4070807@btinternet.com> References: <465F2650.4070807@btinternet.com> Message-ID: <1135681588.20070601140730@gmail.com> Hello Andrew, Thursday, May 31, 2007, 11:47:28 PM, you wrote: > (Otherwise... wasn't there some library somewhere for serialising values > in binary?) Binary, AltBinary (see latest HCAR), just an example using AltBinary: main = do let s = encode (1.1::Float) -- s has type String print (decode s::Float, s) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at cse.unsw.edu.au Fri Jun 1 06:32:41 2007 From: dons at cse.unsw.edu.au (Donald Bruce Stewart) Date: Fri Jun 1 06:28:24 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <1135681588.20070601140730@gmail.com> References: <465F2650.4070807@btinternet.com> <1135681588.20070601140730@gmail.com> Message-ID: <20070601103241.GB1740@cse.unsw.EDU.AU> bulat.ziganshin: > Hello Andrew, > > Thursday, May 31, 2007, 11:47:28 PM, you wrote: > > (Otherwise... wasn't there some library somewhere for serialising values > > in binary?) > > Binary, AltBinary (see latest HCAR), just an example using AltBinary: > > main = do > let s = encode (1.1::Float) -- s has type String > print (decode s::Float, s) > Data.Binary is on hackage, http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.3 encode :: (Binary a) => a -> ByteString decode :: (Binary a) => ByteString -> a > let s = encode (1.1 :: Float) > :t s s :: Data.ByteString.Lazy.ByteString > s LPS ["\NUL\NUL\140\204\205\255\255\255\255\255\255\255\233"] > decode s :: Float 1.1 See also the older NewBinary, http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary-0.1 -- Don From jules at jellybean.co.uk Fri Jun 1 07:02:33 2007 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Jun 1 06:58:16 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <20070601103241.GB1740@cse.unsw.EDU.AU> References: <465F2650.4070807@btinternet.com> <1135681588.20070601140730@gmail.com> <20070601103241.GB1740@cse.unsw.EDU.AU> Message-ID: <465FFCC9.8030503@jellybean.co.uk> Donald Bruce Stewart wrote: > > let s = encode (1.1 :: Float) > > :t s > s :: Data.ByteString.Lazy.ByteString > > s > LPS ["\NUL\NUL\140\204\205\255\255\255\255\255\255\255\233"] > > > decode s :: Float > 1.1 But doesn't Data.Binary serialise to a guaranteed representation, i.e. machine-independent? Whereas this (stupid) question explicitly asked for *your particular hardware's* floating point rep. Jules From claus.reinke at talk21.com Fri Jun 1 07:06:53 2007 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jun 1 07:02:38 2007 Subject: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate References: <465377AE.1000501@alexjacobson.com><46537C35.5020603@charter.net><026001c79ccd$7c57dc30$3b038351@cr3lt><4654A966.9070107@alexjacobson.com><01ed01c79d90$b034f2e0$541a7ad5@cr3lt> <009201c79de9$981767c0$060e7ad5@cr3lt> <465F7BF4.5010100@alexjacobson.com> Message-ID: <004e01c7a43c$f70ebe00$b90e8351@cr3lt> > Actually, standalone deriving doesn't really solve the boilerplate > boilerplate problem. My original complaint here is that I don't want to > explicitly declare a deriving (Data,Typeable) for every type used > somewhere inside a larger type I am using. In this particular case, I > am using SYB to autogenerate/autoparse XML. The Atom/RSS datatype has a > lot of elements in it. Having to do an explicit declaration of deriving > (Data,Typeable) for each of them is just a tremendous beat-down no > matter where I do it. > > A simple solution to the problem is just to have the compiler > automatically derive Data and Typeable for all classes. it still sounds as if you might want to follow Neil's suggestions about using Data.Derive, which does seem to have a derive-this-for-all feature. but one of the nice things about just separating data and deriving is that one can add derived instances without changing, or even having the source, and without having to add the individual derivings by hand. as i mentioned, we did such a scripted deriving, then based on the old DrIFT, for HaRe, over Programatica's data types for Haskell syntax. these days, one might use something like the two-liner sketched below. btw, i've found that even major publishers have trouble keeping their RSS feeds valid, not to mention the variety of standards, and the variety of (not) using those standards for recording essential information in those feeds. that frequently breaks strict XML processing, so if i had to do it again, i'd try a fast&loose heuristic approach instead, extracting the information from whereever it has been hidden in the feed, valid or broken.. claus $ ghc -e ':b Language.Haskell.Syntax' | \ > sed -n -e '/data/{s/^data\s*\([^=\r]*\).*$/deriving MyClass for ( \1 )/; p}' deriving MyClass for ( HsGuardedAlt ) deriving MyClass for ( HsGuardedAlts ) deriving MyClass for ( HsAlt ) deriving MyClass for ( HsFieldUpdate ) deriving MyClass for ( HsStmt ) deriving MyClass for ( HsPatField ) deriving MyClass for ( HsPat ) deriving MyClass for ( HsExp ) deriving MyClass for ( HsLiteral ) deriving MyClass for ( HsType ) deriving MyClass for ( HsQualType ) deriving MyClass for ( HsSafety ) deriving MyClass for ( HsGuardedRhs ) deriving MyClass for ( HsRhs ) deriving MyClass for ( HsBangType ) deriving MyClass for ( HsConDecl ) deriving MyClass for ( HsMatch ) deriving MyClass for ( HsDecl ) deriving MyClass for ( HsAssoc ) deriving MyClass for ( HsImportSpec ) deriving MyClass for ( HsImportDecl ) deriving MyClass for ( HsExportSpec ) deriving MyClass for ( HsModule ) deriving MyClass for ( HsCName ) deriving MyClass for ( HsOp ) deriving MyClass for ( HsQOp ) deriving MyClass for ( HsName ) deriving MyClass for ( HsQName ) deriving MyClass for ( HsSpecialCon ) deriving MyClass for ( SrcLoc ) From dons at cse.unsw.edu.au Fri Jun 1 07:09:25 2007 From: dons at cse.unsw.edu.au (Donald Bruce Stewart) Date: Fri Jun 1 07:05:13 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <465FFCC9.8030503@jellybean.co.uk> References: <465F2650.4070807@btinternet.com> <1135681588.20070601140730@gmail.com> <20070601103241.GB1740@cse.unsw.EDU.AU> <465FFCC9.8030503@jellybean.co.uk> Message-ID: <20070601110925.GA2444@cse.unsw.EDU.AU> jules: > Donald Bruce Stewart wrote: > > > let s = encode (1.1 :: Float) > > > :t s > > s :: Data.ByteString.Lazy.ByteString > > > s > > LPS ["\NUL\NUL\140\204\205\255\255\255\255\255\255\255\233"] > > > > > decode s :: Float > > 1.1 > > But doesn't Data.Binary serialise to a guaranteed representation, i.e. > machine-independent? Whereas this (stupid) question explicitly asked for > *your particular hardware's* floating point rep. > Ah right. Missed that. There was a long thread on the libraries@ mailing list on doing this (David Roundy suggested it, initially, iirc) a couple of months ago. Might be useful to read. -- Don From bulat.ziganshin at gmail.com Fri Jun 1 07:17:49 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jun 1 07:17:33 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <465FFCC9.8030503@jellybean.co.uk> References: <465F2650.4070807@btinternet.com> <1135681588.20070601140730@gmail.com> <20070601103241.GB1740@cse.unsw.EDU.AU> <465FFCC9.8030503@jellybean.co.uk> Message-ID: <1961348248.20070601151749@gmail.com> Hello Jules, Friday, June 1, 2007, 3:02:33 PM, you wrote: > machine-independent? Whereas this (stupid) question explicitly asked for > *your particular hardware's* floating point rep. there is castSTUArray function which is widely used exactly for this purpose. look for examples of its usage in haskell code -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From alex at alexjacobson.com Fri Jun 1 07:41:32 2007 From: alex at alexjacobson.com (Alex Jacobson) Date: Fri Jun 1 07:37:17 2007 Subject: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate In-Reply-To: <004e01c7a43c$f70ebe00$b90e8351@cr3lt> References: <465377AE.1000501@alexjacobson.com><46537C35.5020603@charter.net><026001c79ccd$7c57dc30$3b038351@cr3lt><4654A966.9070107@alexjacobson.com><01ed01c79d90$b034f2e0$541a7ad5@cr3lt> <009201c79de9$981767c0$060e7ad5@cr3lt> <465F7BF4.5010100@alexjacobson.com> <004e01c7a43c$f70ebe00$b90e8351@cr3lt> Message-ID: <466005EC.9010007@alexjacobson.com> Claus Reinke wrote: >> Actually, standalone deriving doesn't really solve the boilerplate >> boilerplate problem. My original complaint here is that I don't want >> to explicitly declare a deriving (Data,Typeable) for every type used >> somewhere inside a larger type I am using. In this particular case, >> I am using SYB to autogenerate/autoparse XML. The Atom/RSS datatype >> has a lot of elements in it. Having to do an explicit declaration of >> deriving (Data,Typeable) for each of them is just a tremendous >> beat-down no matter where I do it. >> >> A simple solution to the problem is just to have the compiler >> automatically derive Data and Typeable for all classes. > > it still sounds as if you might want to follow Neil's suggestions > about using > Data.Derive, which does seem to have a derive-this-for-all feature. > The problem with Data.Derive is that I now have a pre-processor cycle as part of my build process. Automatic and universal Data and Typeable instance deriving should just be built into Haskell. I totally agree that, if you don't have this deriving by default, it is totally useful to be able to derive in a location different from where the type is declared, but that is a separate issue. My main point is that Data and Typeable should always be there without extra futzing on the part of the programmer. Speaking of which, any thoughts on fixing my SYB code in the other thread? -Alex- From bortzmeyer at nic.fr Fri Jun 1 08:14:52 2007 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Fri Jun 1 08:10:33 2007 Subject: [Haskell-cafe] Re: What puts False before True? In-Reply-To: <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> <200705310731.49932.coeus@gmx.de> <7.0.1.0.0.20070531095635.01b70648@ntlworld.com> <20070531205120.GA8785@heave.ugcs.caltech.edu> <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> Message-ID: <20070601121451.GA1830@nic.fr> On Fri, Jun 01, 2007 at 03:33:41AM +0100, PR Stanley wrote a message of 19 lines which said: > The question, however, still remains: why False = 0 and True 1? Arbitrary decision? On a similar case, the ISO 5218 standard, representation of human gender (http://standards.iso.org/ittf/PubliclyAvailableStandards/c036266_ISO_IEC_5218_2004(E_F).zip) says: Data elements Code Not known 0 (zero) Male 1 (one) Female 2 (two) Not applicable 9 (nine) and warns: No significance is to be placed upon the fact that "Male" is coded "1" and "Female" is coded "2". This standard was developed based upon predominant practices of the countries involved and does not convey any meaning of importance, ranking or any other basis that could imply discrimination. From lemming at henning-thielemann.de Fri Jun 1 08:25:28 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jun 1 08:21:39 2007 Subject: [Haskell-cafe] What puts False before True? In-Reply-To: <465F940A.7020903@yale.edu> References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> <"200705310731.49 932.coeus"@gmx.de> <7.0.1.0.0.20070531095635.01b70648@ntlworld.com> <20070531205120.GA8785@heave.ugcs.caltech.edu> <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> <465F940A.7020903@yale.edu> Message-ID: On Thu, 31 May 2007, Paul Hudak wrote: > PR Stanley wrote: > >> I think so, too. In Boolean algebra (which predates computers, much less > >> C), FALSE has traditionally been associated with 0, and TRUE with 1. And > >> since 1 > 0, TRUE > FALSE. > > The question, however, still remains: why False = 0 and True 1? I > > appreciate that it's so in boolean algebra but why? Why not True = 0 > > and False = 1? > > Because if you take (&&) to be (*), and (||) to be (+), you get a > homomorphism between the two resulting algebras (assuming 1+1 = 1). It seems however, that if the number representations of False and True are flipped, then we only need to flip the interpretations of (&&) and (||). For me the choice fromEnum False == 0 && fromEnum True == 1 seems rather arbitrary. The conversion is certainly useful for writing Bool values to binary files. Maybe the Ord instance was introduced in order to be able to put Bools in Sets and Maps. However this confirms my doubts whether using Ord constraint for Sets and Maps was a good choice. http://www.haskell.org/pipermail/libraries/2007-April/007411.html From ndmitchell at gmail.com Fri Jun 1 08:28:38 2007 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Jun 1 08:24:17 2007 Subject: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate In-Reply-To: <466005EC.9010007@alexjacobson.com> References: <465377AE.1000501@alexjacobson.com> <026001c79ccd$7c57dc30$3b038351@cr3lt> <4654A966.9070107@alexjacobson.com> <01ed01c79d90$b034f2e0$541a7ad5@cr3lt> <009201c79de9$981767c0$060e7ad5@cr3lt> <465F7BF4.5010100@alexjacobson.com> <004e01c7a43c$f70ebe00$b90e8351@cr3lt> <466005EC.9010007@alexjacobson.com> Message-ID: <404396ef0706010528i32f2159ek5753fe3c9e7fed2a@mail.gmail.com> Hi Alex, > The problem with Data.Derive is that I now have a pre-processor cycle as > part of my build process. Automatic and universal Data and Typeable > instance deriving should just be built into Haskell. Not if you use the template haskell support. We don't currently have a "deriveAll" command, but I'm sure it could be added, which applied a given definition to every data type in that module. Thanks Neil From alex at alexjacobson.com Fri Jun 1 09:06:37 2007 From: alex at alexjacobson.com (Alex Jacobson) Date: Fri Jun 1 09:02:22 2007 Subject: [Haskell-cafe] RE: [Haskell] boilerplate boilerplate In-Reply-To: <404396ef0706010528i32f2159ek5753fe3c9e7fed2a@mail.gmail.com> References: <465377AE.1000501@alexjacobson.com> <026001c79ccd$7c57dc30$3b038351@cr3lt> <4654A966.9070107@alexjacobson.com> <01ed01c79d90$b034f2e0$541a7ad5@cr3lt> <009201c79de9$981767c0$060e7ad5@cr3lt> <465F7BF4.5010100@alexjacobson.com> <004e01c7a43c$f70ebe00$b90e8351@cr3lt> <466005EC.9010007@alexjacobson.com> <404396ef0706010528i32f2159ek5753fe3c9e7fed2a@mail.gmail.com> Message-ID: <466019DD.3000803@alexjacobson.com> I suppose a deriveAll command from template haskell would work. Is that really possible? -Alex- Neil Mitchell wrote: > Hi Alex, > >> The problem with Data.Derive is that I now have a pre-processor cycle as >> part of my build process. Automatic and universal Data and Typeable >> instance deriving should just be built into Haskell. > > Not if you use the template haskell support. We don't currently have a > "deriveAll" command, but I'm sure it could be added, which applied a > given definition to every data type in that module. > > Thanks > > Neil From carette at mcmaster.ca Fri Jun 1 10:07:44 2007 From: carette at mcmaster.ca (Jacques Carette) Date: Fri Jun 1 10:03:42 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: <465F2784.6050400@btinternet.com> References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> Message-ID: <46602830.3070105@mcmaster.ca> Andrew Coppin wrote: > Lennart Augustsson wrote: >> Why do you seem so in awe of Mathematica? > > Oh, well, I guess it is only the most powerful maths software ever > written... no biggie. No, it is one of several. In very little time I can find 20 things that Maple does better than Mathematica. In the same amount of time, I can find 20 things that Mathematica does better than Maple. [Actually, the most obvious is that its marketing is miles better; so good that it makes blind evangelists out of people who have not even tried the competitors]. >> It's just another language with a good set of libraries. Claims that >> it is the best, fastest, etc comes from Wolfram advertising, no >> doubt. :) > > The claim that it is the fastest clearly doesn't hold (much to my > surprise). The claim that it is the most powerful, well... I have yet > to see anything that can come close to the symbolic power of Mathematica. Give Maple a try. For example, you'll find that: 1) Maple's DE solver beats Mathematica hands-down 2) Mathematica's definite integrator beats Maples hands-down 3) Maple's symbolic non-linear equation solver is best 4) Mathematica's definite summation (ie finding closed forms) is best and on and on. [I don't know enough about the other systems to make similar comparison lists]. You got suckered by their marketing. Get your head out of the sand, and take a good look around what is available. Jacques From jgbailey at gmail.com Fri Jun 1 12:14:07 2007 From: jgbailey at gmail.com (Justin Bailey) Date: Fri Jun 1 12:09:46 2007 Subject: [Haskell-cafe] New (?) Partial Monad In-Reply-To: References: <20070501091807.9CA4D324432@www.haskell.org> Message-ID: Can you post any code using the monad? The article was interesting but I think it would make more sense if I saw some working code ... Justin From derek.a.elkins at gmail.com Fri Jun 1 12:42:19 2007 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Jun 1 12:39:02 2007 Subject: [Haskell-cafe] What puts False before True? In-Reply-To: References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> <"200705310731.49 932.coeus"@gmx.de> <7.0.1.0.0.20070531095635.01b70648@ntlworld.com> <20070531205120.GA8785@heave.ugcs.caltech.edu> <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> <465F940A.7020903@yale.edu> Message-ID: <46604C6B.5000603@gmail.com> Henning Thielemann wrote: > On Thu, 31 May 2007, Paul Hudak wrote: > >> PR Stanley wrote: >>>> I think so, too. In Boolean algebra (which predates computers, much less >>>> C), FALSE has traditionally been associated with 0, and TRUE with 1. And >>>> since 1 > 0, TRUE > FALSE. >>> The question, however, still remains: why False = 0 and True 1? I >>> appreciate that it's so in boolean algebra but why? Why not True = 0 >>> and False = 1? >> Because if you take (&&) to be (*), and (||) to be (+), you get a >> homomorphism between the two resulting algebras (assuming 1+1 = 1). > > It seems however, that if the number representations of False and True > are flipped, then we only need to flip the interpretations of (&&) and > (||). > For me the choice fromEnum False == 0 && fromEnum True == 1 seems rather > arbitrary. It -is- arbitrary, in boolean algebra as well. not is an automorphism between the two. However, we tend to think of 0 as associated with nothing/the empty set and that maps naturally to {x | False}. There are intuitive reasons why this choice was chosen, but no formal reasons. Obviously, there are pragmatic reasons to use this choice in programming languages, e.g. many languages use 0 to represent false and non-zero or 1 to represent true and this is consistent with that. From andrewcoppin at btinternet.com Fri Jun 1 14:27:21 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:23:00 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2C26.7030203@btinternet.com> Message-ID: <46606509.1030709@btinternet.com> jerzy.karczmarczuk@info.unicaen.fr wrote: > Andrew Coppin cites me and asks: >> I find that statement interesting. I have never come across *any* >> other package that can perform _symbolic_ mathematics. > >> (Sure, there are packages that can perform specific operations - >> solving certain kinds of equations, transforming matricies, >> rearranging formulas. But I have never seen any other package where >> you can just do *anything*.) > > You must be joking, but OK, I am naive, and I will answer as it were > serious. Really, haven't heard about Maple??? > http://www.maplesoft.com/ Last I heard, Maple is simply another fast number-chrunking engine. > Its limited library is integrated within Matlab Symbolic Toolbox, and if > you *have* Maple and Matlab, the latter can use the full force of the > former. Now Matlab I have heard of. (And I hate it with a passion.) > Maple is commercial as Mathematica, but there are perfectly > usable free packages as well, for example Axiom and Maxima (Macsyma > rekindled). > http://wiki.axiom-developer.org/FrontPage > http://maxima.sourceforge.net/ Now this actually looks vaguely promising. (Rather confused at this point as to what the relationship between Axiom, Maxima, Reduce and Sage is...) > The are more free stuff, GAP, MaCaulay,... In general, check > http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems I did indeed check that list a while back. I looked at a whole heap of systems listed, but... half of them didn't seem to exist any more, and the other half looked very clunky, had strange syntax, and only handled a few specific constructs. >> But yes - I have tried to implement that pattern matching engine a >> couple of times in Pascal. (Remember Pascal?) Getting it to work for >> a few test cases is easy. Getting it to *properly* handle >> associativity and commutivity is really nontrivial. (I mean *really* >> nontrivial! Or perhaps I am an inferior programmer - one of the two!) > > The mathematically sensitive matching/substitution is a hard task even if > you have at your disposal a reasonably full unifier. Forget Pascal, take > Prolog, which will save several days/weeks of the implementation of basic > stuff. Even then, it will be quite tedious to write a package able > say, to > reduce rational formulae, to reduce a polynomial modulo an ideal, to > implement the basic trig identities, find a reasonable common form for > expressions containing complex exponentials AND trigonometrics, etc. LOL! I did try to learn Prolog once... I never did understand how it was able to make impossible leaps of deduction like that. And yet, in other, similar cases, it couldn't figure out the result. Of course, now I know that the answer is a magic trick known as unification (although I still don't know much about that topic). Not really sure how a unifyer would help you manipulate symbolic expressions... If I get time, I might have another go at implementing the pattern matching algorithm in Haskell. Of course, even if it works, that's still a pretty small problem compared to finding a set of transformation rules that cover all the cases you care about, is reasonably efficient, produces the right answers...etc...etc... From andrewcoppin at btinternet.com Fri Jun 1 14:28:07 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:23:48 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <20070531230941.GK23075@abridgegame.org> References: <465F2650.4070807@btinternet.com> <20070531213654.GD3847@lambda> <20070531230941.GK23075@abridgegame.org> Message-ID: <46606537.7000400@btinternet.com> David Roundy wrote: > Note also that you can use unsafePerformIO to safely get pure functions > doing both these operations. > I've always been puzzled by this one... how does unsafePerformIO circumvent the type system? I don't understand. From trebla at vex.net Fri Jun 1 14:28:22 2007 From: trebla at vex.net (Albert Y. C. Lai) Date: Fri Jun 1 14:24:06 2007 Subject: [Haskell-cafe] What puts False before True? In-Reply-To: <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> <200705310731.49 932.coeus@gmx.de> <7.0.1.0.0.20070531095635.01b70648@ntlworld.com> <20070531205120.GA8785@heave.ugcs.caltech.edu> <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> Message-ID: <46606546.7040508@vex.net> PR Stanley wrote: > The question, however, still remains: why False = 0 and True 1? I > appreciate that it's so in boolean algebra but why? Why not True = 0 and > False = 1? > A Boolean value denotees veracity whereas an ordered value concerns > magnitude (priority), indeed, order!! Other members have mentioned how to do it either way. Certain people with strong convictions in philosophy, religion, or platonism are more happy to see "truth is greater than falsehood" than "falsehood is greater than truth". It would be nice if we could be user-friendly to them. From andrewcoppin at btinternet.com Fri Jun 1 14:32:31 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:28:11 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: References: <200705300704.32070.jon@ffconsultancy.com> <200705311650.40623.jon@ffconsultancy.com> Message-ID: <4660663F.8040403@btinternet.com> jerzy.karczmarczuk@info.unicaen.fr wrote: > PS. Somebody (A. Coppin?) said that Mathematica not without reason costs > 10000. > Weeeeelll, less than 2000, and for students there are much cheaper > possibi- > lities. I am the last to make free ads for Wolfram, I recommend the usage > of Axiom and Maxima to my students, but there is no need to say publicly > some dubious truths about commercial software. Yes, that was me. And there's no need for "debious truths" - anybody that wants to can check the price right now: http://store.wolfram.com/view/app/mathematica/ Mmm, that *is* interesting... The price has indeed changed to ?2,035. Ah well, it might as well be ?2,000,000 for all the difference it makes - I will never own anywhere near that kind of money. :-( PS. I wonder why it costs more on UNIX...? From droundy at darcs.net Fri Jun 1 14:36:46 2007 From: droundy at darcs.net (David Roundy) Date: Fri Jun 1 14:32:27 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <46606537.7000400@btinternet.com> References: <465F2650.4070807@btinternet.com> <20070531213654.GD3847@lambda> <20070531230941.GK23075@abridgegame.org> <46606537.7000400@btinternet.com> Message-ID: <20070601183642.GA5383@abridgegame.org> On Fri, Jun 01, 2007 at 07:28:07PM +0100, Andrew Coppin wrote: > David Roundy wrote: > >Note also that you can use unsafePerformIO to safely get pure functions > >doing both these operations. > > > > I've always been puzzled by this one... how does unsafePerformIO > circumvent the type system? I don't understand. It's a primitive. You couldn't implement it unless you're the compiler-writer. But it's a necesary primitive, if you wish to build efficient data types. You just need to carefully audit everywhere that unsafePerformIO is used. -- David Roundy Department of Physics Oregon State University From andrewcoppin at btinternet.com Fri Jun 1 14:36:53 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:32:35 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <20070601103241.GB1740@cse.unsw.EDU.AU> References: <465F2650.4070807@btinternet.com> <1135681588.20070601140730@gmail.com> <20070601103241.GB1740@cse.unsw.EDU.AU> Message-ID: <46606745.2000705@btinternet.com> Donald Bruce Stewart wrote: > See also the older NewBinary, > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary-0.1 > Now that's just ironic... Incidentally, I've been thinking. You *might* want the binary representation of things if you were going to, say, compress or encrypt data before putting it into a file or whatever. Actually in Java (bleeeh) you can wrap things around a stream so that data gets compressed and transformed between where the program writes it, and where it hits the endpoint. Haskell doesn't have a library for this, and I don't immediately see how to implement one. It would be darn useful to have a standard setup for this though. That way, when somebody wants to implement a new way to do zlib compression or a SHA-256 implementation or... there will already be a standardised way to access the binary representation of data without having to write it to a file. (If any of that made sense...)?) From andrewcoppin at btinternet.com Fri Jun 1 14:39:32 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:35:12 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <20070601183642.GA5383@abridgegame.org> References: <465F2650.4070807@btinternet.com> <20070531213654.GD3847@lambda> <20070531230941.GK23075@abridgegame.org> <46606537.7000400@btinternet.com> <20070601183642.GA5383@abridgegame.org> Message-ID: <466067E4.4020008@btinternet.com> David Roundy wrote: > On Fri, Jun 01, 2007 at 07:28:07PM +0100, Andrew Coppin wrote: > >> David Roundy wrote: >> >>> Note also that you can use unsafePerformIO to safely get pure functions >>> doing both these operations. >>> >>> >> I've always been puzzled by this one... how does unsafePerformIO >> circumvent the type system? I don't understand. >> > > It's a primitive. You couldn't implement it unless you're the > compiler-writer. But it's a necesary primitive, if you wish to build > efficient data types. You just need to carefully audit everywhere that > unsafePerformIO is used. > No, I mean... how could you use unsafePerformIO to perform a typecast? I don't see a way to do that. From andrewcoppin at btinternet.com Fri Jun 1 14:41:57 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:37:37 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: <46602830.3070105@mcmaster.ca> References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> <46602830.3070105@mcmaster.ca> Message-ID: <46606875.6010600@btinternet.com> Jacques Carette wrote: > Andrew Coppin wrote: >> Lennart Augustsson wrote: >>> Why do you seem so in awe of Mathematica? >> >> Oh, well, I guess it is only the most powerful maths software ever >> written... no biggie. > No, it is one of several. In very little time I can find 20 things > that Maple does better than Mathematica. In the same amount of time, > I can find 20 things that Mathematica does better than Maple. > [Actually, the most obvious is that its marketing is miles better; so > good that it makes blind evangelists out of people who have not even > tried the competitors]. If Wolfram want to claim that Mathematica has "redefined the face of computer science"... well I don't believe that for one second. If they want to claim it's a product that can do some amazing stuff... well I don't see much evidence to the contrary. > You got suckered by their marketing. Get your head out of the sand, > and take a good look around what is available. I looked, I didn't find anything interesting. From droundy at darcs.net Fri Jun 1 14:42:42 2007 From: droundy at darcs.net (David Roundy) Date: Fri Jun 1 14:38:23 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <466067E4.4020008@btinternet.com> References: <465F2650.4070807@btinternet.com> <20070531213654.GD3847@lambda> <20070531230941.GK23075@abridgegame.org> <46606537.7000400@btinternet.com> <20070601183642.GA5383@abridgegame.org> <466067E4.4020008@btinternet.com> Message-ID: <20070601184238.GB5383@abridgegame.org> On Fri, Jun 01, 2007 at 07:39:32PM +0100, Andrew Coppin wrote: > David Roundy wrote: > >On Fri, Jun 01, 2007 at 07:28:07PM +0100, Andrew Coppin wrote: > > > >>David Roundy wrote: > >> > >>>Note also that you can use unsafePerformIO to safely get pure functions > >>>doing both these operations. > >>> > >>> > >>I've always been puzzled by this one... how does unsafePerformIO > >>circumvent the type system? I don't understand. > >> > > > >It's a primitive. You couldn't implement it unless you're the > >compiler-writer. But it's a necesary primitive, if you wish to build > >efficient data types. You just need to carefully audit everywhere that > >unsafePerformIO is used. > > > > No, I mean... how could you use unsafePerformIO to perform a typecast? I > don't see a way to do that. Then I'm confused. What typecast are you talking about? -- David Roundy Department of Physics Oregon State University From andrewcoppin at btinternet.com Fri Jun 1 14:47:28 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jun 1 14:43:08 2007 Subject: [Haskell-cafe] Hardware Message-ID: <466069C0.9060909@btinternet.com> OK, so... If you were going to forget everything we humans know about digital computer design - the von Neuman architecture, the fetch/decode/execute loop, the whole shooting match - and design a computer *explicitly* for the purpose of executing Haskell programs... what would it look like? What design decisions would you make? Why? From dan.doel at gmail.com Fri Jun 1 15:11:19 2007 From: dan.doel at gmail.com (Dan Doel) Date: Fri Jun 1 15:04:52 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <46606537.7000400@btinternet.com> References: <465F2650.4070807@btinternet.com> <20070531230941.GK23075@abridgegame.org> <46606537.7000400@btinternet.com> Message-ID: <200706011511.19625.dan.doel@gmail.com> On Friday 01 June 2007, Andrew Coppin wrote: > David Roundy wrote: > > Note also that you can use unsafePerformIO to safely get pure functions > > doing both these operations. > > I've always been puzzled by this one... how does unsafePerformIO > circumvent the type system? I don't understand. import Data.IORef import System.IO.Unsafe ref :: IORef a ref = unsafePerformIO $ newIORef undefined cast :: a -> b cast a = unsafePerformIO $ do writeIORef ref a ; readIORef ref *Main> cast 2 :: Double -3.824225156758791e-48 *Main> -- Dan From rossberg at ps.uni-sb.de Fri Jun 1 15:14:37 2007 From: rossberg at ps.uni-sb.de (rossberg@ps.uni-sb.de) Date: Fri Jun 1 15:10:20 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <20070601184238.GB5383@abridgegame.org> References: <465F2650.4070807@btinternet.com> <20070531213654.GD3847@lambda> <20070531230941.GK23075@abridgegame.org> <46606537.7000400@btinternet.com> <20070601183642.GA5383@abridgegame.org> <466067E4.4020008@btinternet.com> <20070601184238.GB5383@abridgegame.org> Message-ID: <64347.84.165.182.157.1180725277.squirrel@www.ps.uni-sb.de> David Roundy wrote: > On Fri, Jun 01, 2007 at 07:39:32PM +0100, Andrew Coppin wrote: >> >> No, I mean... how could you use unsafePerformIO to perform a typecast? I >> don't see a way to do that. > > Then I'm confused. What typecast are you talking about? cast :: a -> b cast x = unsafePerformIO (do writeIORef r x; readIORef r) where r = unsafePerformIO (newIORef undefined) The problem is that the Hindley/Milner type inference algorithm is unsound in the presence of effects - r may not be given polymorphic type. That's exactly the reason for ML's dreaded value restriction. - Andreas From isaacdupree at charter.net Fri Jun 1 15:18:11 2007 From: isaacdupree at charter.net (Isaac Dupree) Date: Fri Jun 1 15:12:22 2007 Subject: [Haskell-cafe] Existentials and type var escaping In-Reply-To: References: <465F3AE5.2030904@di.unipi.it> <465F41D1.9060800@charter.net> Message-ID: <466070F3.1000101@charter.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David House wrote: > On 31/05/07, Isaac Dupree wrote: >> foo undefined = undefined > > That's not true. When you evaluate foo undefined, it matches the first > (irrefutable) pattern immediately, without any deconstruction of the > undefined argument (which is the entire point of it being a lazy > pattern). So it becomes the right hand side, C . Only when you > force that would you have to force the undefined argument, so > foo undefined = C undefined: > > *Main> foo undefined > C *** Exception: Prelude.undefined > Oh, I misinterpreted "must be non bottom" to be talking about becoming more strict, not less, compared to id, and then misanalysed the function :/ Now for the existential case... normally an existential "escaping" is useless, sometimes it seems to make sense. Looking at the GHC manual http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#existential-quantification I think this is the relevant explanatory paragraph: In general, you can only pattern-match on an existentially-quantified constructor in a case expression or in the patterns of a function definition. The reason for this restriction is really an implementation one. Type-checking binding groups is already a nightmare without existentials complicating the picture. Also an existential pattern binding at the top level of a module doesn't make sense, because it's not clear how to prevent the existentially-quantified type "escaping". So for now, there's a simple-to-state restriction. We'll see how annoying it is. It seems like an existential as returned by (case y of E x -> x) is ("should" be) just "anything" -- you can put it in an existential container, or you can "seq" it, but not much else. To seq, (case y of E x -> (x `seq`)) should work, so the difficulty is in transferring an existential from one place to another with weird strictness effects... Is (data E' = forall a . E' !a) allowed? I seem to remember some discussion about its oddness... Type-class contexts on the existentials make it more complicated. Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGYHDzHgcxvIWYTTURAn9oAJ45VLiD6W63ByUOrfpRILprPyKGdACbB+nu YIULFXH4KHDcbNmG/+cb5vI= =v2Co -----END PGP SIGNATURE----- From jeremy.shaw at linspireinc.com Fri Jun 1 15:30:05 2007 From: jeremy.shaw at linspireinc.com (Jeremy Shaw) Date: Fri Jun 1 15:25:49 2007 Subject: [Haskell-cafe] Hardware In-Reply-To: <466069C0.9060909@btinternet.com> References: <466069C0.9060909@btinternet.com> Message-ID: Hello, Did you see the recently announce reduceron project? (Or perhaps you are already involved in that project?) http://www-users.cs.york.ac.uk/~mfn/reduceron/index.html If you search scholar.google.com for graph reduction machine you should turn up a bunch of papers about attempts to build a processor for Haskell and Haskell-like languages. j. At Fri, 01 Jun 2007 19:47:28 +0100, Andrew Coppin wrote: > > OK, so... If you were going to forget everything we humans know about > digital computer design - the von Neuman architecture, the > fetch/decode/execute loop, the whole shooting match - and design a > computer *explicitly* for the purpose of executing Haskell programs... > what would it look like? > > What design decisions would you make? > > Why? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tomasz.zielonka at gmail.com Fri Jun 1 15:31:25 2007 From: tomasz.zielonka at gmail.com (Tomasz Zielonka) Date: Fri Jun 1 15:30:16 2007 Subject: [Haskell-cafe] What puts False before True? In-Reply-To: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> Message-ID: <20070601193125.GE3847@lambda> On Thu, May 31, 2007 at 04:52:57AM +0100, PR Stanley wrote: > What justifies False < True? This way we have only one person asking such question. If it was done the other way, there would be hundreds... ;-) BTW, your question provoked an interesting discussion and generated some nice answers (I liked the philosophical one from Albert Lai :-). Best regards Tomek From jon.fairbairn at cl.cam.ac.uk Fri Jun 1 15:17:07 2007 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Fri Jun 1 15:48:05 2007 Subject: [Haskell-cafe] Re: Hardware References: <466069C0.9060909@btinternet.com> Message-ID: Andrew Coppin writes: > OK, so... If you were going to forget everything we humans > know about digital computer design - the von Neuman > architecture, the fetch/decode/execute loop, the whole > shooting match - and design a computer *explicitly* for the > purpose of executing Haskell programs... what would it look > like? Back in the eighties (I don't remeber exactly when), Thomas Clarke, Stuart Wray and I got together to think this through (we had the possiblity of funding to make something). We had lots of ideas, but after much arguing back and forth the conclusion we reached was that anything we could do would either be slower than mainstream hardware or would be overtaken by it in a very short space of time. I'm not sure that the conclusion still holds because conventional architectures are approaching an impasse, but there's a lot of force left in the arguments: most of the improvements I can think of also benefit imperative languages, so if they're worthwhile they'll happen anyway. One of the things that is different now is the availability of parallelism, but the mainstream is working pretty hard on that. There's an opportunity there, in that functional languages have some nice properties when it comes to parallel execution, but to make an impact we'd have to get on with it pretty sharpish. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From chaddai.fouche at gmail.com Fri Jun 1 18:01:19 2007 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Fri Jun 1 17:56:58 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> <46602830.3070105@mcmaster.ca> <46606875.6010600@btinternet.com> Message-ID: ---------- Forwarded message ---------- From: Chadda? Fouch? Date: 2 juin 2007 00:00 Subject: Re: [Haskell-cafe] Implementing Mathematica To: Andrew Coppin 2007/6/1, Andrew Coppin : > I looked, I didn't find anything interesting. Well maybe you should look one more time with your brain on... Your claim that : > Last I heard, Maple is simply another fast number-chrunking engine. Show that you never even bothered to read the feature list of the software ! http://www.maplesoft.com/products/Maple11/academic/index.aspx?D=3040 I tried both Mathematica and Maple and while I'll be the first to admit the Mathematica interface was more attractive, it's the only obvious point I concede to it (and my version of Maple was quite old so this might not even be true anymore). As others who knows the subject have said, Mathematica and Maple are quite close and outperforms each other regularly in their fields of excellence. -- Jeda? From prstanley at ntlworld.com Fri Jun 1 18:14:11 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Fri Jun 1 18:09:42 2007 Subject: [Haskell-cafe] What puts False before True? In-Reply-To: <46606546.7040508@vex.net> References: <7.0.1.0.0.20070531044623.01b60480@ntlworld.com> <200705310731.49 932.coeus@gmx.de> <7.0.1.0.0.20070531095635.01b70648@ntlworld.com> <20070531205120.GA8785@heave.ugcs.caltech.edu> <7.0.1.0.0.20070601031811.01b61de8@ntlworld.com> <46606546.7040508@vex.net> Message-ID: <7.0.1.0.0.20070601212151.01b63cb8@ntlworld.com> >>P.S.: The question, however, still remains: why False = 0 and True >>1? I appreciate that it's so in boolean algebra but why? Why not >>True = 0 and False = 1? >>A Boolean value denotees veracity whereas an ordered value concerns >>magnitude (priority), indeed, order!! > >Other members have mentioned how to do it either way. > >Certain people with strong convictions in philosophy, religion, or >platonism are more happy to see "truth is greater than falsehood" >than "falsehood is greater than truth". It would be nice if we could >be user-friendly to them. >P.S.: If I'm not mistaken, in Zoroastrianism there is no ordinal >perspective on truth and falsehood. The lie, as it's called, is not >subordinate to truth. From claus.reinke at talk21.com Fri Jun 1 19:59:27 2007 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jun 1 19:55:11 2007 Subject: [Haskell-cafe] Re: Hardware References: <466069C0.9060909@btinternet.com> Message-ID: <01cc01c7a4a8$e41c4f30$b90e8351@cr3lt> > either be slower than mainstream hardware or would be > overtaken by it in a very short space of time. i'd like to underline the last of these two points, and i'm impressed that you came to that conclusion as early as the eighties. i'm not into hardware research myself, but while i was working on my MSc, a couple of PhD students in the same group were developing an abstract machine and a hardware realisation (that must have been very early nineties?) for a reduction language (purely functional). unlike earlier designs, the hardware only leaned toward functional, rather than being specific to it (mostly RISC, with large register files organised as very fast stack windows for a small number of stacks), and numbers from the hand-configured prototype suggested that it would be about twice as fast as contemporary standard hardware. which was great, until it became clear that, in the time it would have taken to go from that prototype to production, the next generation of that standard hardware would have been on the market, also twice as fast (with the next next generation already on its way).. for a non-fp example, see the one-laptop-per-child project: now that they're actually looking for firm orders, they have the first mainstream competitors, and anything those do, they tend to do with a lot of backup, and twice as well a short time later.. the suggestion that the mainstream might be running out of steam along one particular dimension is interesting, but in my naive view, there is still the difference between any one-shot research project and a snapshot in a development pipeline of great momentum (are they still running several overlapping teams to double the flow through that pipeline?). i wouldn't want to dishearten anyone, though. just try not to aim for a single piece of hardware, but for a suitable change to one of those mainstream development pipelines, perhaps? claus From dpiponi at gmail.com Fri Jun 1 21:33:38 2007 From: dpiponi at gmail.com (Dan Piponi) Date: Fri Jun 1 21:29:17 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> <46602830.3070105@mcmaster.ca> <46606875.6010600@btinternet.com> Message-ID: <625b74080706011833h67a8d2c2wee9ee7c1c38fd1a0@mail.gmail.com> On 6/1/07, Chadda? Fouch? wrote: > 2007/6/1, Andrew Coppin : > > I looked, I didn't find anything interesting. > > Well maybe you should look one more time with your brain on... Even my years old TI-89 calculator with a paltry Z80 processor and a few hundred K of RAM does symbolic algebra, including symbolically solving differential equations. Now if only I could run Haskell on a handheld that small. From dpiponi at gmail.com Fri Jun 1 21:45:48 2007 From: dpiponi at gmail.com (Dan Piponi) Date: Fri Jun 1 21:41:28 2007 Subject: [Haskell-cafe] OpenGL In-Reply-To: <465F333A.5060302@btinternet.com> References: <200705302359.45504.jon@ffconsultancy.com> <814617240705301609x446f9e16qf6a24f79ed3685dd@mail.gmail.com> <465F333A.5060302@btinternet.com> Message-ID: <625b74080706011845q1f00c92bo740860641daec296@mail.gmail.com> Jon asked: > Where should I go to get started with OpenGL and Haskell? Don't use the examples here: http://www.haskell.org/HOpenGL/ They don't work with recent versions of HOpenGL. But do use the examples here: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/GLUT/examples/RedBook/ They worked for me. -- Dan From mutjida at gmail.com Fri Jun 1 22:10:53 2007 From: mutjida at gmail.com (jeff p) Date: Fri Jun 1 22:06:32 2007 Subject: [Haskell-cafe] Re: Resolved: ffi linking problem In-Reply-To: <465EADC0.6060005@microsoft.com> References: <465EADC0.6060005@microsoft.com> Message-ID: Hello, > If -fvia-C fixes your problem, then your code has a bug, strictly speaking. If > your foreign call requires some information from a header file, then the right > way to call it is by making a small C wrapper function and calling that. > I tried to do this but couldn't. I could get GHC to compile and link with warnings of the form: Warning: resolving _my_fun@24 by linking to _my_fun But when I ran the executable, the system crashed at the point that a foreign function was called. > Bear in mind that we'll be deprecating -fvia-C in the future, and also that you > might want your code to work in GHCi too, which doesn't read any header files > when compiling foreign imports. > I am currently developing on a windows xp machine. After a week of fighting with FFI, I feel forced to conclude that FFI barely works with GHC (and seems to require -fvia-C) and doesn't work at all with GHCi (I think there is an unresolved bug about this). Am I wrong about the state of affairs for windows? thanks, Jeff From stefanor at cox.net Fri Jun 1 22:21:18 2007 From: stefanor at cox.net (Stefan O'Rear) Date: Fri Jun 1 22:16:57 2007 Subject: [Haskell-cafe] Re: Resolved: ffi linking problem In-Reply-To: References: <465EADC0.6060005@microsoft.com> Message-ID: <20070602022117.GA8605@localhost.localdomain> On Fri, Jun 01, 2007 at 10:10:53PM -0400, jeff p wrote: > Hello, > > >If -fvia-C fixes your problem, then your code has a bug, strictly > >speaking. If > >your foreign call requires some information from a header file, then the > >right > >way to call it is by making a small C wrapper function and calling that. > > > I tried to do this but couldn't. I could get GHC to compile and link > with warnings of the form: > > Warning: resolving _my_fun@24 by linking to _my_fun > > But when I ran the executable, the system crashed at the point that a > foreign function was called. > > >Bear in mind that we'll be deprecating -fvia-C in the future, and also > >that you > >might want your code to work in GHCi too, which doesn't read any header > >files > >when compiling foreign imports. > > > I am currently developing on a windows xp machine. After a week of > fighting with FFI, I feel forced to conclude that FFI barely works > with GHC (and seems to require -fvia-C) and doesn't work at all with > GHCi (I think there is an unresolved bug about this). Am I wrong about > the state of affairs for windows? No, it sounds like you're using the wrong import syntax. That linker warning is a dead givaway you should be using ccall, not stdcall. Stefan From dons at cse.unsw.edu.au Fri Jun 1 22:21:46 2007 From: dons at cse.unsw.edu.au (Donald Bruce Stewart) Date: Fri Jun 1 22:17:26 2007 Subject: [Haskell-cafe] Just for a laugh... In-Reply-To: <46606745.2000705@btinternet.com> References: <465F2650.4070807@btinternet.com> <1135681588.20070601140730@gmail.com> <20070601103241.GB1740@cse.unsw.EDU.AU> <46606745.2000705@btinternet.com> Message-ID: <20070602022145.GA1293@cse.unsw.EDU.AU> andrewcoppin: > Donald Bruce Stewart wrote: > >See also the older NewBinary, > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary-0.1 > > > > Now that's just ironic... > > > Incidentally, I've been thinking. You *might* want the binary > representation of things if you were going to, say, compress or encrypt > data before putting it into a file or whatever. Actually in Java > (bleeeh) you can wrap things around a stream so that data gets > compressed and transformed between where the program writes it, and > where it hits the endpoint. Haskell doesn't have a library for this, and > I don't immediately see how to implement one. It would be darn useful to > have a standard setup for this though. That way, when somebody wants to > implement a new way to do zlib compression or a SHA-256 implementation > or... there will already be a standardised way to access the binary > representation of data without having to write it to a file. > > (If any of that made sense...)?) Our zlib and bzlib2 bindings operate on in-memory lazy bytestrings. They thus provide: compress :: ByteString -> ByteString and its inverse. So you can chain them with decoding: writeFile "foo.gz" . compress . encode $ myvalue -- Don From mutjida at gmail.com Fri Jun 1 22:48:12 2007 From: mutjida at gmail.com (jeff p) Date: Fri Jun 1 22:43:51 2007 Subject: [Haskell-cafe] Re: Resolved: ffi linking problem In-Reply-To: <20070602022117.GA8605@localhost.localdomain> References: <465EADC0.6060005@microsoft.com> <20070602022117.GA8605@localhost.localdomain> Message-ID: Hello, > No, it sounds like you're using the wrong import syntax. > > That linker warning is a dead givaway you should be using ccall, not > stdcall. > Ok. I just tried changing this and now things work fairly well. I thought stdcall was the correct syntax for windows. This seems like a strange state of affairs. I have a C library I want to use. I can create an executable which links directly to the library by using stdcall and -fvia-C, but I can't get ghci to use anything which links directly to the library. Or, I can indirectly link to the library via my own C wrapper functions using ccall, no need for -fvia-C, and get either a standalone or a module which ghci will use. thanks for the help, Jeff From stefanor at cox.net Fri Jun 1 23:02:14 2007 From: stefanor at cox.net (Stefan O'Rear) Date: Fri Jun 1 22:57:53 2007 Subject: [Haskell-cafe] Re: Resolved: ffi linking problem In-Reply-To: References: <465EADC0.6060005@microsoft.com> <20070602022117.GA8605@localhost.localdomain> Message-ID: <20070602030214.GA8685@localhost.localdomain> On Fri, Jun 01, 2007 at 10:48:12PM -0400, jeff p wrote: > Hello, > > >No, it sounds like you're using the wrong import syntax. > > > >That linker warning is a dead givaway you should be using ccall, not > >stdcall. > > > Ok. I just tried changing this and now things work fairly well. > I thought stdcall was the correct syntax for windows. > > This seems like a strange state of affairs. I have a C library I want > to use. I can create an executable which links directly to the library > by using stdcall and -fvia-C, but I can't get ghci to use anything > which links directly to the library. Or, I can indirectly link to the > library via my own C wrapper functions using ccall, no need for > -fvia-C, and get either a standalone or a module which ghci will use. Actually it makes sense if you know a few of the subtle details. The C compiler, because it parses header files, will not be confused by an incorrect calling convention, in the special case of C. You should not rely on this behavior! ccall refers to the standard C calling convention, on any platform. The Windows API functions use a non-standard calling convention, confusingly named stdcall by Microsoft; GHC only follows established bad terminology. GHCi and -fasm do NOT use the C compiler, and require fully matched signatures. C wrapper functions are not needed to link to external ccall or stdcall library functions. They are only needed for weird calling conventions (like C++) and macros. Attempting to call a ccall function with a stdcall calling sequence, or conversely, will probably cause a crash with modern compilers. It may have worked on very old non-optimizing compilers, but the defaulting thing in your linker should have been removed long ago. Stefan From jon at ffconsultancy.com Sat Jun 2 01:18:40 2007 From: jon at ffconsultancy.com (Jon Harrop) Date: Sat Jun 2 01:19:43 2007 Subject: [Haskell-cafe] OpenGL In-Reply-To: <625b74080706011845q1f00c92bo740860641daec296@mail.gmail.com> References: <200705302359.45504.jon@ffconsultancy.com> <465F333A.5060302@btinternet.com> <625b74080706011845q1f00c92bo740860641daec296@mail.gmail.com> Message-ID: <200706020618.40732.jon@ffconsultancy.com> On Saturday 02 June 2007 02:45:48 Dan Piponi wrote: > But do use the examples here: > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/GLUT/examples/R >edBook/ They worked for me. Great, thanks. May I just ask, does ShadowMap.hs work on your machine? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?e From bulat.ziganshin at gmail.com Sat Jun 2 03:14:36 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jun 2 03:14:30 2007 Subject: [Haskell-cafe] Re: Hardware In-Reply-To: References: <466069C0.9060909@btinternet.com> Message-ID: <886781347.20070602111436@gmail.com> Hello Jon, Friday, June 1, 2007, 11:17:07 PM, you wrote: > (we had the possiblity of funding to make something). We > had lots of ideas, but after much arguing back and forth the > conclusion we reached was that anything we could do would > either be slower than mainstream hardware or would be this looks rather strange for me. it's well known that Neuman architecture is a bottleneck with only one operation executed each time. it was developed in 1946 because those times all programming was in binary code and simplicity of programming was favored but more efficient computational model exists. if cpu consists from huge amount of execution engines which synchronizes their operations only when one unit uses results produces by another then we got processor with huge level of natural parallelism and friendlier for FP programs. it seems that now we move right into this direction with GPUs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From semanticphilosopher at googlemail.com Sat Jun 2 04:28:19 2007 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Sat Jun 2 04:23:57 2007 Subject: [Haskell-cafe] Re: Hardware In-Reply-To: <886781347.20070602111436@gmail.com> References: <466069C0.9060909@btinternet.com> <886781347.20070602111436@gmail.com> Message-ID: <37c497340706020128t793c27f1n749dc69de6e2244e@mail.gmail.com> Bulat That was done to death as well in the '80s - data flow architectures where the execution was data-availability driven. The issue becomes one of getting the most of the available silicon area. Unfortunately with very small amounts of computation per work unit you: a) spend a lot of time/area making the matching decision - the what to do next b) the basic sequential blocks of code are too small - can't efficiently pipeline Locality is essential for performance. It is needed to hide all the (relatively large) latencies in fetching things. If anyone wants to build the new style of functional programming execution hardware, it is those issues that need to be sorted. Not to say that Haskell is the wrong beast to think about these things in. It's demand driven execution framework, and it's ability to perform multiple concurrent evaluations safely are the unique points. Neil PS if any of you really want to attack this seriously - do get in touch - I've got notes and stuff from the '80s when we (at Bristol) looked into this. I've also got evaluation frameworks for modeling communication behaviour and performance (which you'll need) - naturally all written in Haskell! On 02/06/07, Bulat Ziganshin wrote: > Hello Jon, > > Friday, June 1, 2007, 11:17:07 PM, you wrote: > > > (we had the possiblity of funding to make something). We > > had lots of ideas, but after much arguing back and forth the > > conclusion we reached was that anything we could do would > > either be slower than mainstream hardware or would be > > this looks rather strange for me. it's well known that Neuman > architecture is a bottleneck with only one operation executed each > time. it was developed in 1946 because those times all programming was > in binary code and simplicity of programming was favored > > but more efficient computational model exists. if cpu consists from > huge amount of execution engines which synchronizes their operations > only when one unit uses results produces by another then we got > processor with huge level of natural parallelism and friendlier for FP > programs. it seems that now we move right into this direction with GPUs > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From oleg at pobox.com Sat Jun 2 04:39:31 2007 From: oleg at pobox.com (oleg@pobox.com) Date: Sat Jun 2 04:37:29 2007 Subject: [Haskell-cafe] Re: Has anyone looked into adding subtyping... In-Reply-To: Message-ID: <20070602083931.27FE4AD43@Adric.metnet.fnmoc.navy.mil> > The last time I tried this code, I reported to haskell-cafe that > OOHaskell does not work when compiled as a library (at least under > GHC). For some reason the code that uses OOHaskell had to be compiled > along side it. Is this now fixed? It may be, I have to try. It should be mentioned that most of the OOHaskell functionality (extensible polymorphic records and variants) are actually in HList. Einar Karttunen has ported the latter to GHC 6.6 and package under Cabal. I think the version is available on Hackage. Anyway, the curious behavior requiring the presence of OOHaskell sources seems like a problem with GHC separate compilation. Could that be distilled to a small example so that we can file a GHC problem report? From jon.fairbairn at cl.cam.ac.uk Sat Jun 2 06:21:32 2007 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat Jun 2 06:17:46 2007 Subject: [Haskell-cafe] Re: Hardware References: <466069C0.9060909@btinternet.com> <01cc01c7a4a8$e41c4f30$b90e8351@cr3lt> Message-ID: "Claus Reinke" writes: > > either be slower than mainstream hardware or would be > > overtaken by it in a very short space of time. > > i'd like to underline the last of these two points, and i'm > impressed that you came to that conclusion as early as the > eighties. Well, Stuart and I had just been working on TIM, and Thomas Clarke was one of the folk who built SKIM, so we had a fair bit of relevant experience between us. It must have been between 1986 (when we'd finished TIM) and 1989 (when I got ill). > unlike earlier designs, the hardware only leaned toward > functional, rather than being specific to it (mostly RISC, > with large register files organised as very fast stack > windows for a small number of stacks), We had that sort of thing in mind -- my first implementation of TIM was on an ARM, so I knew something of what RISC had to offer. > and numbers from the hand-configured prototype suggested > that it would be about twice as fast as contemporary > standard hardware. which was great, until it became clear > that, in the time it would have taken to go from that > prototype to production, the next generation of that > standard hardware would have been on the market, also > twice as fast (with the next next generation already on > its way).. Yup, that's what we figured (we knew the ARM guys too, and knowing the rate at which they worked probably helped us see things quite clearly :-). > the suggestion that the mainstream might be running out of > steam along one particular dimension is interesting, but > in my naive view, there is still the difference between > any one-shot research project and a snapshot in a > development pipeline of great momentum Yes. I think the best bet is to get hold of prototypes and research fp implementations for them; my TIM implementation of Ponder must have been the first fp language on ARM, and the process of doing that probably informed much of the detailed design of TIM. Doing an fp implementatio for a huge number of cores strikes me as an exciting avenue. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From jon.fairbairn at cl.cam.ac.uk Sat Jun 2 06:26:36 2007 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat Jun 2 06:23:04 2007 Subject: [Haskell-cafe] Re: Hardware References: <466069C0.9060909@btinternet.com> <886781347.20070602111436@gmail.com> <37c497340706020128t793c27f1n749dc69de6e2244e@mail.gmail.com> Message-ID: "Neil Davies" writes: > Bulat > > That was done to death as well in the '80s - data flow architectures > where the execution was data-availability driven. The issue becomes > one of getting the most of the available silicon area. Unfortunately > with very small amounts of computation per work unit you: > a) spend a lot of time/area making the matching decision - the what > to do next > b) the basic sequential blocks of code are too small - can't > efficiently pipeline > > Locality is essential for performance. It is needed to hide all the > (relatively large) latencies in fetching things. > > If anyone wants to build the new style of functional programming > execution hardware, it is those issues that need to be sorted. Yes indeed, though a lot has changed (and a lot stayed the same) in hardware since then. There may be greater possibilities for integrating garbage collection in the memory, for example, and there's always the possibility that someone will come up with a new and radically different way of spreading a functional programme across multiple CPU cores. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From u.stenzel at web.de Sat Jun 2 07:30:02 2007 From: u.stenzel at web.de (Udo Stenzel) Date: Sat Jun 2 08:26:42 2007 Subject: [Haskell-cafe] Re: Just for a laugh... In-Reply-To: <465F31A4.5060608@btinternet.com> References: <465F2650.4070807@btinternet.com> <465F31A4.5060608@btinternet.com> Message-ID: <20070602113002.GA3007@web.de> Andrew Coppin wrote: > Note that the challenge asks for the "internal" bitmap representation of > an IEEE double-precision integer Actually it didn't. It asked for the machine's internal representation of a double precision float, and you are not guaranteed that this representation conforms to IEEE 7-whatsit. It is beyond me what you're going to do with that unspecified representation, though. > Did I mention that this is a silly challange yet? Silly, yes. Challenge, no. We can do the same the C++ guy did, it's only a question if we need to. Something close to this: | import Foreign.Marshal | import Foreign.Ptr | import Data.Word | | valueToBytes :: Storable a => a -> IO [Word8] | valueToBytes a = with a $ \p -> peekBytes (castPtr b) (sizeOf a) Reversing the list and hammering it down to single bits is trivial after that. -Udo -- Structure is _nothing_ if it is all you got. Skeletons _spook_ people if they try to walk around on their own. I really wonder why XML does not. -- Erik Naggum -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070602/10261bbe/attachment.bin From jerzy.karczmarczuk at info.unicaen.fr Sat Jun 2 09:13:18 2007 From: jerzy.karczmarczuk at info.unicaen.fr (jerzy.karczmarczuk@info.unicaen.fr) Date: Sat Jun 2 09:08:27 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: <4660663F.8040403@btinternet.com> References: <200705300704.32070.jon@ffconsultancy.com> <200705311650.40623.jon@ffconsultancy.com> <4660663F.8040403@btinternet.com> Message-ID: Andrew Coppin writes about my objection on the Mathematica price he mentioned : > ...And there's no need for "debious truths" - anybody that > wants to can check the price right now: > > http://store.wolfram.com/view/app/mathematica/ > > Mmm, that *is* interesting... The price has indeed changed to ?2,035. Ah > well, it might as well be ?2,000,000 for all the difference it makes - I > will never own anywhere near that kind of money. :-( Cool down. Take any Google-accessible site which sells Mathematica. Say, http://www.unisoftwareplus.com/products/mathematica/edu.html Single licence - 1345 with 1 year service. I admit that it still something an individual won't pay, this is for a university fellow who got a fat grant and doesn't know where to throw the money out. Check the students' offer: ClassA boxed : 128 dollars. Admit that this is more serious, although *not* for an average French student (1/3 of what he usually pays for his lodging). > PS. I wonder why it costs more on UNIX...? Simply because it is *easier* to make a deeply integrated, graphics-rich and securised software on Windows. Linux remains behind not because them folks are lazy, the progress *IS* considerable, but because of commercial support the Windows world moves forward a bit faster! Now, Haskell evolves in both worlds, but we have already seen that it was easier to link it with the graphical support on Windows... Such is life. Jerzy Karczmarczuk From jerzy.karczmarczuk at info.unicaen.fr Sat Jun 2 10:49:33 2007 From: jerzy.karczmarczuk at info.unicaen.fr (jerzy.karczmarczuk@info.unicaen.fr) Date: Sat Jun 2 10:44:41 2007 Subject: [Haskell-cafe] Implementing Mathematica In-Reply-To: <46606509.1030709@btinternet.com> References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2C26.7030203@btinternet.com> <46606509.1030709@btinternet.com> Message-ID: Andrew Coppin responds to my rhetorical question : >> Really, haven't heard about Maple??? >> http://www.maplesoft.com/ > > Last I heard, Maple is simply another fast number-chrunking engine. Heavens! Now, as a professional teacher, I should not get nervous too fast, but, sorry to say, you become annoying with your *complete* lack of understanding what is the situation in the domain which interests you. Stop "chrunking", please. Maple, Axiom, Derive, etc. are *symbolic/algebraic* packages, period. Number-crunching is NOT their main realm of activity, although some people use them for numerics, in order not to be obliged to shift from one soft to another. > Now Matlab I have heard of. (And I hate it with a passion.) Hatred, as we all know, is something which will permit you to make many friends and a lot of money. Good luck. But perhaps learn it first, since I am ready to bet a good deal that you don't know why you hate it. The matrix/vector-style, very compact notation is something which is quite popular, perhaps a bit more than a bit similar functional map/zip style. About other, free soft. > Now this actually looks vaguely promising. (Rather confused at this point > as to what the relationship between Axiom, Maxima, Reduce and Sage is...) What is the relationship between various brands of cars, motorcycles, etc.?? Why people agree to buy all of them and not "just the best"? As Jacques Carette said here, and others confirmed, for any reasonably mature product, say, Maple / Mathematica, etc., you will find that in some respects it suits you better than some others, and sometimes not, and either you choose the best/least-bad, or you combine. Axiom (and MuPAD, and also the semi-commercial, actively developed Australian package Magma!) are designed towards a TYPED approach towards mathematical structures - something found usually quite sexy by a typical Haskellian. Macsyma/Maxima, based originally on Lisp was much more dynamic and amorphous, easier to use by newbies. Maple is /par excellence/ procedural. Mathematica insists on rewriting. Sage ... you mean: http://sage.scipy.org/sage/ David Joyner, William Stein et al... , since Sage in the name of at least a dozen of different software products... well, Sage is quite dynamic, but first of all, as compared to the Mathusalem like Macsyma/Maxima, it is a baby! A baby with *all* its potentialities, and all its weaknesses. Scriptable in Python, so accessible on many platforms, and able to use the graphical support thereof, with the possibility to plug-in - as the authors say - the GAP/Pari/GMP algorithms in order to accelerate the low-level processing, etc., - well - *PERHAPS YOU* will tell us what you can do with, that Haskell doesn't give you. (Unfortunately, I couldn't test it thoroughly, since I have only 7 arms and 37 hours per day, but the interactive tutorial is nice). About other systems: > I did indeed check that list a while back. I looked at a whole heap of > systems listed, but... half of them didn't seem to exist any more, and the > other half looked very clunky, had strange syntax, and only handled a few > specific constructs. The situation evolves, the Internet sites are, true, too often obsolete. Instead of complaining, I test. From time to time you realize that most of the brands of washing machines on the market known to you as a child aren't there. Will you annoy us with the discovery of this highly non-trivial issue? And, concerning your "strange syntax", I don't buy it at all. === > LOL! I did try to learn Prolog once... I never did understand how it was > able to make impossible leaps of deduction like that. And yet, in other, > similar cases, it couldn't figure out the result. > > Of course, now I know that the answer is a magic trick known as > unification (although I still don't know much about that topic). Not > really sure how a unifyer would help you manipulate symbolic > expressions... Magic trick?? But this is something basic. ALL comp. sci. students are obliged to learn it, and learn also the clause reduction strategy known as the resolution. It is intuitive and not complicated at all. OK, from my personal perspective. I tried some time ago to offer to high- school pupils a crash-course in Prolog, showing the non-deterministic style of programming, and showing an example of a simple-minded simplifier and symbolic differentiator. The unification was presented as a powerful pattern-matcher, being able to instanciate logic variables, and test the coherence within patterns sharing the same elements (which is not possible in Haskell, and *much* less efficient than the Haskell pattern-matcher, for formal reasons). It *WORKED*. So, either you are 85 or more years old, or, you simply never tried to use efficiently your very, very (physically) young brain. A good deal of Prolog non-determinism can be efficiently and nicely simulated in Haskell using the list Monad. Our 3-nd year CompSci students are obliged to learn it. They survive it, so can you. This is my last public answer along these lines. Have fun. Jerzy Karczmarczuk Caen, France. From dpiponi at gmail.com Sat Jun 2 11:01:05 2007 From: dpiponi at gmail.com (Dan Piponi) Date: Sat Jun 2 10:56:50 2007 Subject: [Haskell-cafe] OpenGL In-Reply-To: <200706020618.40732.jon@ffconsultancy.com> References: <200705302359.45504.jon@ffconsultancy.com> <465F333A.5060302@btinternet.com> <625b74080706011845q1f00c92bo740860641daec296@mail.gmail.com> <200706020618.40732.jon@ffconsultancy.com> Message-ID: <625b74080706020801x54c060cdkc7b83c41348d2253@mail.gmail.com> On 6/1/07, Jon Harrop wrote: > On Saturday 02 June 2007 02:45:48 Dan Piponi wrote: > > But do use the examples here: > > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/GLUT/examples/R > >edBook/ They worked for me. > > Great, thanks. May I just ask, does ShadowMap.hs work on your machine? It compiles fine. Runs imperfectly. The shadow map matrix seems to be off so that shadows aren't quite being cast correctly. (ghc 6.6.1 on MacOSX with a GeForce FX Go5200 if that's relevant.) Additionally the main window lacks a title bar and doesn't receive keyboard events. I've no idea if the problems are with HOpenGL or the example code. -- Dan From jon at ffconsultancy.com Sat Jun 2 11:22:53 2007 From: jon at ffconsultancy.com (Jon Harrop) Date: Sat Jun 2 11:30:25 2007 Subject: [Haskell-cafe] OpenGL In-Reply-To: <625b74080706020801x54c060cdkc7b83c41348d2253@mail.gmail.com> References: <200705302359.45504.jon@ffconsultancy.com> <200706020618.40732.jon@ffconsultancy.com> <625b74080706020801x54c060cdkc7b83c41348d2253@mail.gmail.com> Message-ID: <200706021622.53376.jon@ffconsultancy.com> On Saturday 02 June 2007 16:01:05 Dan Piponi wrote: > On 6/1/07, Jon Harrop wrote: > > Great, thanks. May I just ask, does ShadowMap.hs work on your machine? > > It compiles fine. Runs imperfectly. The shadow map matrix seems to be > off so that shadows aren't quite being cast correctly. (ghc 6.6.1 on > MacOSX with a GeForce FX Go5200 if that's relevant.) Additionally the > main window lacks a title bar and doesn't receive keyboard events. > I've no idea if the problems are with HOpenGL or the example code. I had a suspicion that the problem might be my forcing antialiasing on globally using nvidia-settings. This has adversely affected my own code (OCaml, nothing to do with HOpenGL). But I tried turning it back off and the ShadowMap.hs demo still displays only a black screen here. I'm on Linux with a GF7900GX but it shouldn't make any difference. As long as it works on someone else's computer, I'll keep fiddling with it here. Thanks! BTW, the other OpenGL demos I've seen are fantastic - great work! -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?e From lane at downstairspeople.org Sat Jun 2 15:01:18 2007 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sat Jun 2 14:56:56 2007 Subject: [Haskell-cafe] New (?) Partial Monad In-Reply-To: References: <20070501091807.9CA4D324432@www.haskell.org> Message-ID: > Can you post any code using the monad? The article was interesting but > I think it would make more sense if I saw some working code ... > > Justin > Ok. I wrote a simple implementation of the procedural texture example. This just runs on the CLI, printing the color that would be drawn. (I don't have the patience right now to implement a graphical version, nifty though that would be, because I wrote Partial originally to do the same thing with models in OpenGL. But that example is too complicated to be pedagogical, and will probably take days or weeks to write and test, modulo free time.) The example is here, and recall that ".../partial/" is darcs gettable: http://www.downstairspeople.org/darcs/partial/ProceduralTextureExample.hs When run, it looks something like this: > testTexture blue Color {color_red = 0.0, color_green = 0.0, color_blue = 1.0} > testTexture $ lighten red Color {color_red = 1.0, color_green = 0.5, color_blue = 0.5} > testTexture $ checkerboard yellow blue Hmmm. It looks like this texture varies by coordinate. Enter an x coordinate: 0 Enter a y coordinate: 0 Color {color_red = 1.0, color_green = 1.0, color_blue = 0.0} > testTexture $ checkerboard yellow blue Hmmm. It looks like this texture varies by coordinate. Enter an x coordinate: 4 Enter a y coordinate: 3 Color {color_red = 0.0, color_green = 0.0, color_blue = 1.0} From monique.louise at gmail.com Sat Jun 2 15:12:44 2007 From: monique.louise at gmail.com (Monique Monteiro) Date: Sat Jun 2 15:08:20 2007 Subject: [Haskell-cafe] Failure in GHC compilation Message-ID: Hi, has anyone any idea about what may cause the following error in GHC compilation? c:\ghc\ghc-6.6.1\bin\ar.exe: creating libHSbase.a xargs: c:/ghc/ghc-6.6.1/bin/ar: Argument list too long make[2]: *** [libHSbase.a] Error 126 make[2]: *** Deleting file `libHSbase.a' Failed making all in base: 1 make[1]: *** [all] Error 1 make[1]: Leaving directory `/cygdrive/c/GHC6.6.1/ghc-6.6.1/libraries' make: *** [stage1] Error 2 Thanks in advance, -- __________________________________________________________ Monique Monteiro, MSc MCP .NET Framework 2.0 / SCJP / IBM OOAD Project Manager Recife Microsoft Innovation Center +55 81 34198137 http://www.cin.ufpe.br/~mlbm http://thespoke.net/blogs/moniquelouise/default.aspx monique@qualiti.com.br MSN: monique_louise@msn.com From ndmitchell at gmail.com Sat Jun 2 15:30:03 2007 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 2 15:25:38 2007 Subject: [Haskell-cafe] Failure in GHC compilation In-Reply-To: References: Message-ID: <404396ef0706021230ye8dee7bo4d0a5db0f5dab1d3@mail.gmail.com> Hi Monique, Unless you REALLY need to, I'd recommend using the precompiled binaries on Windows: http://haskell.org/ghc/download_ghc_661.html Thanks Neil On 6/2/07, Monique Monteiro wrote: > Hi, > > has anyone any idea about what may cause the following error in GHC > compilation? > > c:\ghc\ghc-6.6.1\bin\ar.exe: creating libHSbase.a > xargs: c:/ghc/ghc-6.6.1/bin/ar: Argument list too long > make[2]: *** [libHSbase.a] Error 126 > make[2]: *** Deleting file `libHSbase.a' > Failed making all in base: 1 > make[1]: *** [all] Error 1 > make[1]: Leaving directory `/cygdrive/c/GHC6.6.1/ghc-6.6.1/libraries' > make: *** [stage1] Error 2 > > Thanks in advance, > -- > __________________________________________________________ > Monique Monteiro, MSc > MCP .NET Framework 2.0 / SCJP / IBM OOAD > Project Manager > Recife Microsoft Innovation Center > +55 81 34198137 > http://www.cin.ufpe.br/~mlbm > http://thespoke.net/blogs/moniquelouise/default.aspx > monique@qualiti.com.br > MSN: monique_louise@msn.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From monique.louise at gmail.com Sat Jun 2 15:52:14 2007 From: monique.louise at gmail.com (Monique Monteiro) Date: Sat Jun 2 15:47:50 2007 Subject: [Haskell-cafe] Failure in GHC compilation In-Reply-To: <404396ef0706021230ye8dee7bo4d0a5db0f5dab1d3@mail.gmail.com> References: <404396ef0706021230ye8dee7bo4d0a5db0f5dab1d3@mail.gmail.com> Message-ID: Hi Neil, I'm extending GHC, so I really need to compile it. Monique On 6/2/07, Neil Mitchell wrote: > Hi Monique, > > Unless you REALLY need to, I'd recommend using the precompiled > binaries on Windows: > > http://haskell.org/ghc/download_ghc_661.html > > Thanks > > Neil > > On 6/2/07, Monique Monteiro wrote: > > Hi, > > > > has anyone any idea about what may cause the following error in GHC > > compilation? > > > > c:\ghc\ghc-6.6.1\bin\ar.exe: creating libHSbase.a > > xargs: c:/ghc/ghc-6.6.1/bin/ar: Argument list too long > > make[2]: *** [libHSbase.a] Error 126 > > make[2]: *** Deleting file `libHSbase.a' > > Failed making all in base: 1 > > make[1]: *** [all] Error 1 > > make[1]: Leaving directory `/cygdrive/c/GHC6.6.1/ghc-6.6.1/libraries' > > make: *** [stage1] Error 2 > > > > Thanks in advance, > > -- > > __________________________________________________________ > > Monique Monteiro, MSc > > MCP .NET Framework 2.0 / SCJP / IBM OOAD > > Project Manager > > Recife Microsoft Innovation Center > > +55 81 34198137 > > http://www.cin.ufpe.br/~mlbm > > http://thespoke.net/blogs/moniquelouise/default.aspx > > monique@qualiti.com.br > > MSN: monique_louise@msn.com > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -- __________________________________________________________ Monique Monteiro, MSc MCP .NET Framework 2.0 / SCJP / IBM OOAD Project Manager Recife Microsoft Innovation Center +55 81 34198137 http://www.cin.ufpe.br/~mlbm http://thespoke.net/blogs/moniquelouise/default.aspx monique@qualiti.com.br MSN: monique_louise@msn.com From eivuokko at gmail.com Sat Jun 2 16:09:25 2007 From: eivuokko at gmail.com (Esa Ilari Vuokko) Date: Sat Jun 2 16:05:01 2007 Subject: [Haskell-cafe] Failure in GHC compilation In-Reply-To: References: Message-ID: Hi, On 6/2/07, Monique Monteiro wrote: > has anyone any idea about what may cause the following error in GHC > compilation? It's exactly what it says...too long argument list (it's limited in Windows.) This is usually caused by having split-objs on, which causes *a lot* of object files being generated, all of them passed to ar or ld. > c:\ghc\ghc-6.6.1\bin\ar.exe: creating libHSbase.a > xargs: c:/ghc/ghc-6.6.1/bin/ar: Argument list too long > make[2]: *** [libHSbase.a] Error 126 > make[2]: *** Deleting file `libHSbase.a' > Failed making all in base: 1 > make[1]: *** [all] Error 1 > make[1]: Leaving directory `/cygdrive/c/GHC6.6.1/ghc-6.6.1/libraries' > make: *** [stage1] Error 2 Untested: setting SplitObjs=NO in build.mk might help (as there will be less object files to pass to ar. If ghc head is already using cabal, this problem is solved there. It might also be possible to extend ghc build machinery to pass parameters in file for ar and ld - but that requires new enough mingw toolchain. HTH, Esa From monique.louise at gmail.com Sat Jun 2 16:56:26 2007 From: monique.louise at gmail.com (Monique Monteiro) Date: Sat Jun 2 16:52:03 2007 Subject: [Haskell-cafe] Failure in GHC compilation In-Reply-To: References: Message-ID: On 6/2/07, Esa Ilari Vuokko wrote: > > Untested: setting SplitObjs=NO in build.mk might help (as there will be less > object files to pass to ar. Ok, it worked for me. Thanks for the tip! Monique From fruehr at willamette.edu Sat Jun 2 20:01:31 2007 From: fruehr at willamette.edu (Fritz Ruehr) Date: Sat Jun 2 19:57:10 2007 Subject: [Haskell-cafe] Haskell on a PDA (was "Implementing Mathematica") In-Reply-To: <625b74080706011833h67a8d2c2wee9ee7c1c38fd1a0@mail.gmail.com> References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> <46602830.3070105@mcmaster.ca> <46606875.6010600@btinternet.com> <625b74080706011833h67a8d2c2wee9ee7c1c38fd1a0@mail.gmail.com> Message-ID: <01D7D7DF-B6EC-4C32-810F-9D71EE2FC8D5@willamette.edu> I seem to recall that Aarne Ranta ran Hugs on a (Sharp) Zaurus PDA at one of the ICFPs a few years back. Aha, here in fact is a picture of his GF (Grammatical Framework), written in Haskell, running on a Zaurus: There seem to be more details available through his web page (a site- specific Google search for "zaurus" would seem appropriate). A broader Google search for "Haskell Zaurus" returns (for me) upwards of 1/2 a million hits, the first page of which look promising (although I can't believe all of them are!). I don't own a Zaurus (or any PDA) myself, although I must say I'm tempted now. So let me know if you find anything definitive. -- Fritz On Fri 1 Jun 07, at 6:33 pm, Dan Piponi wrote: > On 6/1/07, Chadda? Fouch? wrote: >> 2007/6/1, Andrew Coppin : >> > I looked, I didn't find anything interesting. >> >> Well maybe you should look one more time with your brain on... > > Even my years old TI-89 calculator with a paltry Z80 processor and a > few hundred K of RAM does symbolic algebra, including symbolically > solving differential equations. Now if only I could run Haskell on a > handheld that small. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ndmitchell at gmail.com Sat Jun 2 20:11:54 2007 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 2 20:07:29 2007 Subject: [Haskell-cafe] Haskell on a PDA (was "Implementing Mathematica") In-Reply-To: <01D7D7DF-B6EC-4C32-810F-9D71EE2FC8D5@willamette.edu> References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> <46602830.3070105@mcmaster.ca> <46606875.6010600@btinternet.com> <625b74080706011833h67a8d2c2wee9ee7c1c38fd1a0@mail.gmail.com> <01D7D7DF-B6EC-4C32-810F-9D71EE2FC8D5@willamette.edu> Message-ID: <404396ef0706021711k399089a0m9adcd17233009600@mail.gmail.com> Hi > I seem to recall that Aarne Ranta ran Hugs on a (Sharp) Zaurus PDA at > one of the ICFPs a few years back. Aha, here in fact is a picture of > his GF (Grammatical Framework), written in Haskell, running on a Zaurus: > > > > There seem to be more details available through his web page (a site- > specific Google search for "zaurus" would seem appropriate). http://haskell.org/communities/05-2007/html/report.html#handheld A port of Yhc to a handheld was apparently done - it shouldn't be that hard. Thanks Neil From aeyakovenko at gmail.com Sat Jun 2 21:37:32 2007 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sat Jun 2 21:33:07 2007 Subject: [Haskell-cafe] happs tutorial Message-ID: can someone help me get the first part of the tutorial working with happs 0.8.8 http://happs.org/HAppS/doc/tutorial.html this part at least : module Main where import HAppS import Control.Monad.State data MyState = MyState String deriving (Read, Show) instance StartState MyState where startStateM = return $ MyState "Hello World!" instance Serialize MyState where typeString _ = "MyState" encodeStringM = defaultEncodeStringM decodeStringM = defaultDecodeStringM app :: Method -> Host -> [String] -> Ev MyState Request Result app _ _ _ = do MyState message <- get sresult 200 message main = stdMain $ simpleHTTP "" [] app :*: End I am having a hard time getting everything to compile. Also, why is > :t HAppS.simpleHTTP HAppS.simpleHTTP :: forall st. [ServerPart (Ev st Request) Request IO Result] -> Conf -> Handler st but the type in this http://happs.org/auto/apidoc/HAppS-Protocols-SimpleHTTP.html#v%3AsimpleFileServe docs is simpleHTTP :: XSLPath -> [(String, String)] -> (Method -> Host -> [String] -> Ev st Request Result) -> Conf -> Handler st From Phlex at telenet.be Sun Jun 3 03:24:58 2007 From: Phlex at telenet.be (Phlex) Date: Sun Jun 3 03:20:37 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: References: Message-ID: <46626CCA.7090000@telenet.be> Hello all, I'm coming from the OO world, and there's something i don't quite understand in the way haskellers manipulate data (as all functional programmers i guess). Let's say i have a deep nested data structure. Universe containing galaxies, containing solar systems, containing planets, containing countries, containing inhabitants, containing ...whatever. Using the OO paradigm, once i get a reference to an inhabitant, i can update it quite easily (say by changing it's age), and that's the end of it. On the other side, using the functional paradigm, it seems to me that the function i use in order to create a _new_ inhabitant with a different age will need to have knowledge of the country over it, the planet ..and so on up to the universe...as i need to update all these structures to reflect the change. This is pretty bad and most probably doesn't need to be like this. So here I am hoping for you all to give me some pointers on how this is done "the functional way". Thanks in advance Sacha From dons at cse.unsw.edu.au Sun Jun 3 03:34:18 2007 From: dons at cse.unsw.edu.au (Donald Bruce Stewart) Date: Sun Jun 3 03:29:54 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <46626CCA.7090000@telenet.be> References: <46626CCA.7090000@telenet.be> Message-ID: <20070603073417.GF2241@cse.unsw.EDU.AU> Phlex: > Hello all, > > I'm coming from the OO world, and there's something i don't quite > understand in the way haskellers manipulate data (as all functional > programmers i guess). > > Let's say i have a deep nested data structure. > Universe containing galaxies, containing solar systems, containing > planets, containing countries, containing inhabitants, containing > ...whatever. > > Using the OO paradigm, once i get a reference to an inhabitant, i can > update it quite easily (say by changing it's age), and that's the end of it. > > On the other side, using the functional paradigm, it seems to me that > the function i use in order to create a _new_ inhabitant with a > different age will need to have knowledge of the country over it, the > planet ..and so on up to the universe...as i need to update all these > structures to reflect the change. This is pretty bad and most probably > doesn't need to be like this. > > So here I am hoping for you all to give me some pointers on how this is > done "the functional way". > Nope, its not done like that. You share as much of the original structure as you can, as a general principle. Imagine updating a node in a tree by just detaching and reattaching a pointer. [1] [1] / \ / \ [2] [3] update node 5 [2] [3] / \ with value 7 / \ [4] [5] [4] * and share the rest of the structure. Since the rest isn't mutable anyway, you can share all over. -- Don From Phlex at telenet.be Sun Jun 3 03:41:29 2007 From: Phlex at telenet.be (Phlex) Date: Sun Jun 3 03:37:00 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <20070603073417.GF2241@cse.unsw.EDU.AU> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> Message-ID: <466270A9.7030507@telenet.be> Donald Bruce Stewart wrote: > Phlex: > >> On the other side, using the functional paradigm, it seems to me that >> the function i use in order to create a _new_ inhabitant with a >> different age will need to have knowledge of the country over it, the >> planet ..and so on up to the universe...as i need to update all these >> structures to reflect the change. This is pretty bad and most probably >> doesn't need to be like this. >> > Nope, its not done like that. You share as much of the original > structure as you can, as a general principle. > > Imagine updating a node in a tree by just detaching and reattaching a > pointer. > > [1] [1] > / \ / \ > [2] [3] update node 5 [2] [3] > / \ with value 7 / \ > [4] [5] [4] * > > and share the rest of the structure. Since the rest isn't mutable > anyway, you can share all over. > > -- Don That's precisely the thing i don't understand. In order to update node 3 with a new pointer, i need to mutate it, so i need to recreate it, and so on up to node 1. Now in this exemple, it's ok since that's a regular tree and the process can be automated, but when each node has a different type, it can become quite hairy. Sacha From bulat.ziganshin at gmail.com Sun Jun 3 04:14:53 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jun 3 04:15:01 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <466270A9.7030507@telenet.be> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> Message-ID: <7810732724.20070603121453@gmail.com> Hello Phlex, Sunday, June 3, 2007, 11:41:29 AM, you wrote: > That's precisely the thing i don't understand. > In order to update node 3 with a new pointer, i need to mutate it, so i > need to recreate it, and so on up to node 1. yes, that's true > Now in this exemple, it's ok since that's a regular tree and the process > can be automated, but when each node has a different type, it can become > quite hairy. may be all that you need is structure update syntax? data Planet = Planet { age :: Double , weight :: Double ..... } updatePlanet p = p {age=(age p)*2} the same applies to updating nested structures. you just return updated structure on each level of processing -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From Phlex at telenet.be Sun Jun 3 04:34:26 2007 From: Phlex at telenet.be (Phlex) Date: Sun Jun 3 04:30:09 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <7810732724.20070603121453@gmail.com> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> <7810732724.20070603121453@gmail.com> Message-ID: <46627D12.4040607@telenet.be> Bulat Ziganshin wrote: > Hello Phlex, > > Sunday, June 3, 2007, 11:41:29 AM, you wrote: > >> That's precisely the thing i don't understand. >> In order to update node 3 with a new pointer, i need to mutate it, so i >> need to recreate it, and so on up to node 1. >> > > yes, that's true > > >> Now in this exemple, it's ok since that's a regular tree and the process >> can be automated, but when each node has a different type, it can become >> quite hairy. >> > > may be all that you need is structure update syntax? > > data Planet = Planet { age :: Double > , weight :: Double > ..... > } > > updatePlanet p = p {age=(age p)*2} > > > The thing is, now that i have my planet p... i want to change it's age ... and get back the new state of the universe... So i need to do something like this : changePlanetAge universe galaxy planet age = ...lots of code, returning a new universe And the same code for all functions updating any of the properties of my planet ... And the same code for all functions updating properties of a country on this planet... while in the OO paradigm, i only need to do changlePlanetAge planet age = ...just what you wrote I understand that the advantages of functional programming do come at a cost ... And i'm pretty sure you guys came up with some way to avoid expressing all that upward copying, although it must happen somehow. I'm not sure i'm being clear here. Carkos From apfelmus at quantentunnel.de Sun Jun 3 05:01:22 2007 From: apfelmus at quantentunnel.de (apfelmus) Date: Sun Jun 3 04:56:37 2007 Subject: [Haskell-cafe] Re: I just don't get it (data structures and OO) In-Reply-To: <466270A9.7030507@telenet.be> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> Message-ID: Phlex wrote: > Donald Bruce Stewart wrote: >> >> Imagine updating a node in a tree by just detaching and reattaching a >> pointer. >> >> [1] [1] >> / \ / \ >> [2] [3] update node 5 [2] [3] >> / \ with value 7 / \ >> [4] [5] [4] * >> >> and share the rest of the structure. Since the rest isn't mutable >> anyway, you can share all over. > > That's precisely the thing i don't understand. > In order to update node 3 with a new pointer, i need to mutate it, so i > need to recreate it, and so on up to node 1. Yes, that's correct, I think Dons shared a bit too much here :) [1] [1'] / \ / \ [2] [3] update node 5 [2] [3'] / \ / \ [4] [5] [4] [5'] You have to recreate all nodes that point directly or indirectly to 5, but you can share all the other nodes like 2 and 4 that have no forward pointers to 5. Note that creating new nodes is dead simple, there's no effort involved on the programmer's part. Here's an example that rotates the top of a binary tree: data Tree a = Leaf a | Node (Tree a) (Tree a) rotateRight :: Tree a -> Tree a rotateRight (Node (Node a b) c) = Node a (Node b c) The top two nodes are recreated with the constructor Node but a,b and c are shared. > Now in this example, it's ok since that's a regular tree and the process > can be automated, but when each node has a different type, it can become > quite hairy. Yes and no. The point is that if you can't automate it, you have to code it by hand anyway which constitutes most of the hairiness. But I know what you mean and there's a nice way to do that with multi-parameter type classes. Let's assume a data structure data Universe = Universe [Galaxy] data Galaxy = Galaxy [Planet] data Planet = Planet { name :: String, size :: Double } The insight is that in order to reference a planet inside the universe structure, you have to know the path from the top. In other words, you have to know that's it's the 2nd planet from the 4th galaxy before you look up its name. If you don't throw that information away, you can use it to update it as well. In effect, the Universe behaves like a finite map with composite keys. {-# OPTIONS_GHC -fglasgow-exts -#} import Prelude hiding (lookup) class Map map key a | map key -> a where lookup :: key -> map -> Maybe a adjust :: (a -> a) -> key -> map -> map instance Map [a] Int a where lookup 0 [x] = Just x lookup 0 _ = Nothing lookup k (x:xs) = lookup (k-1) xs lookup _ _ = Nothing adjust f 0 [x] = [f x] adjust _ 0 xs = error "Index out of range" adjust f k (x:xs) = x : adjust f (k-1) xs adjust f _ xs = error "Index out of range" instance Map Universe Int Galaxy where lookup k (Universe gs) = lookup k gs adjust f k (Universe gs) = Universe (adjust f k gs) instance Map Galaxy Int Planet where lookup k (Galaxy ps) = lookup k ps adjust f k (Galaxy ps) = Galaxy (adjust f k ps) instance (Map m k m', Map m' k' a) => Map m (k,k') a where lookup (k,k') m = lookup k m >>= lookup k' adjust f (k,k') m = adjust (adjust f k') k m You can lookup the 2nd planet in the 4th galaxy with lookup (4,2) universe :: Maybe Planet and you can update it via adjust (\planet -> planet {name = "Earth"}) (4,2) universe Thanks to type-classes and overloading, you can still access single galaxies with lookup 4 universe :: Maybe Galaxy Regards, apfelmus From dons at cse.unsw.edu.au Sun Jun 3 05:03:23 2007 From: dons at cse.unsw.edu.au (Donald Bruce Stewart) Date: Sun Jun 3 04:58:59 2007 Subject: [Haskell-cafe] Re: I just don't get it (data structures and OO) In-Reply-To: References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> Message-ID: <20070603090323.GA4679@cse.unsw.EDU.AU> apfelmus: > Phlex wrote: > > Donald Bruce Stewart wrote: > >> > >> Imagine updating a node in a tree by just detaching and reattaching a > >> pointer. > >> > >> [1] [1] > >> / \ / \ > >> [2] [3] update node 5 [2] [3] > >> / \ with value 7 / \ > >> [4] [5] [4] * > >> > >> and share the rest of the structure. Since the rest isn't mutable > >> anyway, you can share all over. > > > > That's precisely the thing i don't understand. > > In order to update node 3 with a new pointer, i need to mutate it, so i > > need to recreate it, and so on up to node 1. > > Yes, that's correct, I think Dons shared a bit too much here :) Spent too much time with zippers lately ;) -- Don From Malcolm.Wallace at cs.york.ac.uk Sun Jun 3 05:13:06 2007 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sun Jun 3 05:08:40 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <46627D12.4040607@telenet.be> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> <7810732724.20070603121453@gmail.com> <46627D12.4040607@telenet.be> Message-ID: <20070603101306.3b4f0db4.Malcolm.Wallace@cs.york.ac.uk> Phlex writes: > The thing is, now that i have my planet p... i want to change it's age > ... and get back the new state of the universe... It is true, there is often a significant amount of "boilerplate" code needed to wrap a simple planet-change nested deep within a universe structure. There has been lots of research into easing the pain of creating this outer traversal code - search for "Scrap your boilerplate", "compos", "Play", "generic traversal" (in conjunction with "Haskell"). Regards, Malcolm From bulat.ziganshin at gmail.com Sun Jun 3 05:14:43 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jun 3 05:15:19 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <46627D12.4040607@telenet.be> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> <7810732724.20070603121453@gmail.com> <46627D12.4040607@telenet.be> Message-ID: <1563454726.20070603131443@gmail.com> Hello Phlex, Sunday, June 3, 2007, 12:34:26 PM, you wrote: > So i need to do something like this : > changePlanetAge universe galaxy planet age = ...lots of code, returning > a new universe > And the same code for all functions updating any of the properties of my > planet ... > And the same code for all functions updating properties of a country on > this planet... > while in the OO paradigm, i only need to do > changlePlanetAge planet age = ...just what you wrote i think that problem is that you think in imperative paradigm. you want to update the whole universe structure each time when one children is born. the solution is to work on lower levels and change your algorithms to group changes in substructures together just one example: i parse config file in my program, i.e. i need function that returns setting given section and entry name: configData configFileContents sectionName entryName in imperative paradigm i will probably scan whole file each time i need an entry. in Haskell, i just split the whole config file into sections and extract entries from appropriate sections. imagine the opposite task, i will probably group entries together and concat them into sections and then concat sections into the whole config file while in imperative programming each new update will change the global structure change your mind, Neo! ;) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From Phlex at telenet.be Sun Jun 3 05:21:46 2007 From: Phlex at telenet.be (Phlex) Date: Sun Jun 3 05:17:21 2007 Subject: [Haskell-cafe] Re: I just don't get it (data structures and OO) In-Reply-To: References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> Message-ID: <4662882A.5000500@telenet.be> apfelmus wrote: > Phlex wrote: > >> Donald Bruce Stewart wrote: >> > Yes and no. The point is that if you can't automate it, you have to code > it by hand anyway which constitutes most of the hairiness. But I know > what you mean and there's a nice way to do that with multi-parameter > type classes. > > Let's assume a data structure > > data Universe = Universe [Galaxy] > data Galaxy = Galaxy [Planet] > data Planet = Planet { name :: String, size :: Double } > > The insight is that in order to reference a planet inside the universe > structure, you have to know the path from the top. In other words, you > have to know that's it's the 2nd planet from the 4th galaxy before you > look up its name. If you don't throw that information away, you can use > it to update it as well. In effect, the Universe behaves like a finite > map with composite keys. > > {-# OPTIONS_GHC -fglasgow-exts -#} > import Prelude hiding (lookup) > > class Map map key a | map key -> a where > lookup :: key -> map -> Maybe a > adjust :: (a -> a) -> key -> map -> map > > instance Map [a] Int a where > lookup 0 [x] = Just x > lookup 0 _ = Nothing > lookup k (x:xs) = lookup (k-1) xs > lookup _ _ = Nothing > > adjust f 0 [x] = [f x] > adjust _ 0 xs = error "Index out of range" > adjust f k (x:xs) = x : adjust f (k-1) xs > adjust f _ xs = error "Index out of range" > > instance Map Universe Int Galaxy where > lookup k (Universe gs) = lookup k gs > adjust f k (Universe gs) = Universe (adjust f k gs) > > instance Map Galaxy Int Planet where > lookup k (Galaxy ps) = lookup k ps > adjust f k (Galaxy ps) = Galaxy (adjust f k ps) > > instance (Map m k m', Map m' k' a) => Map m (k,k') a where > lookup (k,k') m = lookup k m >>= lookup k' > adjust f (k,k') m = adjust (adjust f k') k m > > > You can lookup the 2nd planet in the 4th galaxy with > > lookup (4,2) universe :: Maybe Planet > > and you can update it via > > adjust (\planet -> planet {name = "Earth"}) (4,2) universe > > Thanks to type-classes and overloading, you can still access single > galaxies with > > lookup 4 universe :: Maybe Galaxy > > Regards, > apfelmus This answers precisely my question. Hiding the access/update methods behind a common interface, that's the key ... Thanks a lot, Sacha From bulat.ziganshin at gmail.com Sun Jun 3 05:21:47 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jun 3 05:21:53 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <20070603101306.3b4f0db4.Malcolm.Wallace@cs.york.ac.uk> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> <7810732724.20070603121453@gmail.com> <46627D12.4040607@telenet.be> <20070603101306.3b4f0db4.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <1458541783.20070603132147@gmail.com> Hello Malcolm, Sunday, June 3, 2007, 1:13:06 PM, you wrote: >> The thing is, now that i have my planet p... i want to change it's age >> ... and get back the new state of the universe... > There has been lots of research into easing the pain of creating this > outer traversal code - search for "Scrap your boilerplate", "compos", > "Play", "generic traversal" (in conjunction with "Haskell"). yes, one more gentle haskell introduction LOL i think that this is one more example of pattern where we suggest to beginner advanced solution of problem. of course, problem still exists and from time to time we need to solve it. but ABSOLUTELY MOST of cases where beginners try to do something like this is when they don't groked FP programming style and try to use Haskell in the imperative way so, Phlex, don't listen to my opponents :) solution they suggest is not what you need nor that you can understand now -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From apfelmus at quantentunnel.de Sun Jun 3 05:42:45 2007 From: apfelmus at quantentunnel.de (apfelmus) Date: Sun Jun 3 05:38:08 2007 Subject: [Haskell-cafe] Re: I just don't get it (data structures and OO) In-Reply-To: References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> Message-ID: apfelmus wrote: > {-# OPTIONS_GHC -fglasgow-exts -#} > import Prelude hiding (lookup) > > class Map map key a | map key -> a where > lookup :: key -> map -> Maybe a > adjust :: (a -> a) -> key -> map -> map > > instance (Map m k m', Map m' k' a) => Map m (k,k') a where > lookup (k,k') m = lookup k m >>= lookup k' > adjust f (k,k') m = adjust (adjust f k') k m Uh, that actually needs -fundecidable-instances or something similar. Using explicit functor composition doesn't resolve the problem class Map map key | map -> key where lookup :: key -> map a -> Maybe a adjust :: (a -> a) -> key -> map a -> map a data O f g a = O (f (g a)) instance (Map m k, Map m' k') => Map (m `O` m') (k,k') a where ... -- but how to make ((m `O` m') a) a map for (m' a)? With associated type synonyms, this program can't even be formulated. Any ideas? For the time being, you can specialize the key-pairing for concrete maps in question. newtype UniverseF a = UniverseF [a] newtype GalaxyF a = GalaxyF [a] type Universe = UniverseF Galaxy type Galaxy = GalaxyF Planet data Planet = ... instance Map (UniverseF a) k a where ... instance Map m k a => Map (UniverseF m) (Int,k) a where ... Oh, and you need a dummy instance for Planets as "singleton"-maps. instance Map Planet () Planet where ... Regards, apfelmus From flippa at flippac.org Sun Jun 3 07:06:47 2007 From: flippa at flippac.org (Philippa Cowderoy) Date: Sun Jun 3 07:02:17 2007 Subject: [Haskell-cafe] Haskell on a PDA (was "Implementing Mathematica") In-Reply-To: <01D7D7DF-B6EC-4C32-810F-9D71EE2FC8D5@willamette.edu> References: <200705300704.32070.jon@ffconsultancy.com> <465DE98B.3050709@btinternet.com> <465F2784.6050400@btinternet.com> <46602830.3070105@mcmaster.ca> <46606875.6010600@btinternet.com> <625b74080706011833h67a8d2c2wee9ee7c1c38fd1a0@mail.gmail.com> <01D7D7DF-B6EC-4C32-810F-9D71EE2FC8D5@willamette.edu> Message-ID: On Sat, 2 Jun 2007, Fritz Ruehr wrote: > I seem to recall that Aarne Ranta ran Hugs on a (Sharp) Zaurus PDA at one of > the ICFPs a few years back. Aha, here in fact is a picture of his GF > (Grammatical Framework), written in Haskell, running on a Zaurus: > I've got Hugs and GHC both running under a debian image on my Zaurus (a C3200), for what it's worth. GHC's painfully slow though, sometime I should get round to cooperating some with everyone else looking at doing a registerised build on ARM to try producing a registerised GHC that runs natively on Sharp-derived ROMs. Not that that necessarily means I'll do it! -- flippa@flippac.org Ivanova is always right. I will listen to Ivanova. I will not ignore Ivanova's recomendations. Ivanova is God. And, if this ever happens again, Ivanova will personally rip your lungs out! From rendel at rbg.informatik.tu-darmstadt.de Sun Jun 3 07:27:21 2007 From: rendel at rbg.informatik.tu-darmstadt.de (Tillmann Rendel) Date: Sun Jun 3 07:22:57 2007 Subject: [Haskell-cafe] I just don't get it (data structures and OO) In-Reply-To: <46627D12.4040607@telenet.be> References: <46626CCA.7090000@telenet.be> <20070603073417.GF2241@cse.unsw.EDU.AU> <466270A9.7030507@telenet.be> <7810732724.20070603121453@gmail.com> <46627D12.4040607@telenet.be> Message-ID: <4662A599.8070807@rbg.informatik.tu-darmstadt.de> Hello, Phlex wrote: > changePlanetAge universe galaxy planet age = ...lots of code, returning > a new universe > And the same code for all functions updating any of the properties of my > planet ... > And the same code for all functions updating properties of a country on > this planet... In functional programming, problems of the kind "and the same code for all functions doing something related" are most often solved by introducing higher order functions. Let's try to decompose the problem as follows: (1) change an attribute (2) change a planet by changing one of it's attributes (3) change a galaxy by changing one of it's planets (4) change an universe by changing one of it's galaxies. (1) is done by functions of type (Attribute -> Attribute). We will construct them on the fly. For (2), we need functions for each attribute of a planet. type Name = String type Age = Integer data Planet = Planet Name Age -- lift name changer to planet changer changeName :: (Name -> Name) -> Planet -> Planet changeName f (Planet n a) = Planet (f n) a -- lift age changer to planet changer changeAge :: (Age -> Age) -> Planet -> Planet changeAge f (Planet n a) = Planet n (f a) we need one of these functions for each attribute of each o