pure-lang-users Mailing List for Pure (Page 7)
Status: Beta
Brought to you by:
agraef
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(31) |
May
(422) |
Jun
(241) |
Jul
(268) |
Aug
(281) |
Sep
(109) |
Oct
(1) |
Nov
|
Dec
|
---|
From: Albert G. <Dr....@t-...> - 2008-08-28 17:43:31
|
David Baird wrote: > Okay, a quick update. I have figured out most of the details of > packaging Pure 0.5. Good news! > My plan was to do a request-for-sponsor on the debian-mentors list as > soon as I can resolve the errors from Lintian. Good luck with that. The Debian bureaucracy grinding makes the Catholic church look like a modern enterprise. ;-) So if that doesn't pan out so well, we'll just release your package on pure-lang.sf.net instead. It doesn't really matter how prospective Pure programmers get their Debian package as long as they can get it! But of course it would be nice to get it into the official distro as well. > Debian experimental has LLVM 2.3 whereas Debian unstable has only LLVM > 2.2. AFAICT, Pure 0.5 wants LLVM 2.3. I guess that means Pure 0.5 > will also have to be in experimental along with LLVM 2.3...? Yes. LLVM 2.2 is no go with Pure >= 0.5, unless someone wants to backport it to LLVM 2.2. (That shouldn't be difficult, though, the most annoying incompatibilities are in the IR Builder class. But the 2.2 JIT is awful, that's the main reason why I don't support 2.2 any more.) > E: pure: manpage-not-compressed usr/share/man/man1/pure.1 You're probably supposed to gzip the manpage, same on other distros. > E: pure: sharedobject-in-library-directory-missing-soname > usr/lib/libpure-0.5.so Debian has other packages containing libraries which don't follow the usual so.x.y.z versioning, so it must be possible to work around this. Or maybe you need to release the .so in a separate "library" package? That's how it works, e.g., on SUSE (see Toni Graffy's Pure packages on Packman). > E: pure: copyright-file-contains-full-gpl-license That sounds like it just wants a short copyright notice in that file. But what do I know? > Finished running lintian. Those package sanity checkers really go overboard sometimes. Guess that the bureaucratic types found their playground on Linux at last. A big thank you for your work on this! :) Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-08-28 17:29:52
|
On Thu, 2008-08-28 at 17:51 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > Actually the thingy I sent was bad. (m, setter) should have been (m, > > set) like in the following. Since set is local to matrix and we have > > lexical scoping, I see no problem. > > Yes, I missed that. But you could still simplify your definition, by > just making gsl_matrix_set promote integer arguments to double. I don't > see why you need that type argument to the setter function at all. > > Albert > Just have double and complex entries? e.r. |
From: Eddie R. <er...@bm...> - 2008-08-28 17:29:34
|
On Thu, 2008-08-28 at 19:14 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > > > I thought that was one of the points of using first class functions > > (ducking tomatoes) ;-) > > I knew that this was coming. ;-) Thanks for the explanation. e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-28 17:13:23
|
Eddie Rucker wrote: > On Thu, 2008-08-28 at 02:46 +0200, Albert Graef wrote: >> Albert Graef wrote: >>>> case type of >>>> int = gsl_matrix_int_alloc r c, gsl_matrix_int_set; >>>> double = gsl_matrix_alloc r c, gsl_matrix_set; >>>> end; > >> BTW, the above won't work in Haskell or ML either... That poor little >> int function doesn't like it if you toss it around as if it was some >> piece of silly data! ;-) > > I thought that was one of the points of using first class functions > (ducking tomatoes) ;-) I knew that this was coming. ;-) But of course you're right, functions are as good data as any other and in fact you can compare them with (===). The reason why you can't match against an ordinary (non-nullary) function symbol lies in the "head = function" rule. The "head = function" rule allowed me to get rid of the lexical distinction between function and variable symbols (which is one of Q's worst parts). This applies to all kinds of rewriting rules, not only 'case'. So, consider a rule like: foo bar (baz x) = x+1; The problem is how to decide which symbols on the lhs of that equation are literal (function or constant) symbols, and which are the variables which are to be bound by the equation. Note that Haskell employs the constructor discipline, and even lexically distinguishes constructor symbols, to figure out what the variables are. But for Pure there's no lexical distinction and we don't have (nor want) the constructor discipline either. But if you take another look at this equation, foo bar (baz x) = x+1; it's plain to see for a human reader that foo and baz are function symbols and that bar and x must either be variables or constant symbols since they're leaves of the lhs expression tree. There's no way to decide the latter question, however, without someone telling you, say, that bar is a constant, and x isn't, and that is what Pure's 'nullary' declarations are for. The "head = function" rule just makes precise that intuitive interpretation, so that the compiler can use it to parse the lhs of equations in an unabiguous way. It says that: - The head symbol of a function application, like foo in 'foo bar (baz x)' or baz in 'baz x', is always a literal (function) symbol. - All other symbols (bar and x in this case) are variables, *unless* they're explicitly declared as 'nullary' in which case they're literal (constant) symbols. That rule is just a convention, of course, but it seems perfectly reasonable and in fact it lines up nicely with term rewriting theory. Indeed, all those fixity and nullary declarations in the prelude and in your own programs are just what term rewriting theorists call the "signature" of an algebra, which is simply an "alphabet" of function symbols with their "arities" (number of arguments they expect), with function symbols of arity zero denoting the "constants" of that algebra. The only differences to standard TRS theory are that (1) in Pure you don't have to declare the arities of non-operator and non-nullary symbols, they're inferred automatically; (2) a symbol occuring as a leave on the lhs can denote a variable even if it's also used as a (non-nullary) function symbol elsewhere. Feature #2 is what actually bit you in your 'case' example, so you might argue that this is *not* a good idea. But if you insist that function symbols must never be used as variable names, then a rule like 'foo bla = bla+1' would suddenly change meaning if you happen to add a definition like 'bla x = x-1' somewhere else in your program! That would be very bad indeed and would give rise to horrible bugs almost impossible to avoid in bigger programs. Therefore, (2) is much preferable. In fact, Haskell treats this in exactly the same way. You can even write stuff like 'suck suck = suck+1' which will give you 'suck 99 => 100', in both Haskell and Pure. Try it! (NB: It might be tempting to just declare all your function or at least the constructor symbols 'nullary' to circumvent (2) above. Don't do that, it's a very bad idea for the reasons I just discussed. Nullary symbols should really be reserved for special kinds of atomic values, like [] and () in the prelude. If you really need to introduce nullary symbols, make them stand out or declare them as private symbols, at least if your code is supposed to be used as a library by others.) Back to your example: case type of int = gsl_matrix_int_alloc r c, gsl_matrix_int_set; double = gsl_matrix_alloc r c, gsl_matrix_set; end; It should be clear by now that the rule 'int = gsl_matrix_int_alloc ...' doesn't match against 'int' as a literal symbol, because 'int' is not nullary, so, by what I said above, 'int' is just a variable there! Ok, I hope that this finally clears up the mysteries surrounding Pure's symbol declarations and the "head = function" rule. :) Maybe someone could put this on the wiki, so that we finally have some content for the FAQ section there? HTH, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-08-28 15:50:26
|
Eddie Rucker wrote: > Actually the thingy I sent was bad. (m, setter) should have been (m, > set) like in the following. Since set is local to matrix and we have > lexical scoping, I see no problem. Yes, I missed that. But you could still simplify your definition, by just making gsl_matrix_set promote integer arguments to double. I don't see why you need that type argument to the setter function at all. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-08-28 15:40:52
|
Albert Graef wrote: > Eddie Rucker wrote: >> Something else that would be neat. Since matrices are created in gsl >> with an gsl_matrix_alloc command and freed by gsl_matrix_free command, >> it would be nice if we had some way to mark stuff so that the garbage >> collector would call gsl_matrix_free when a matrix is no longer in use. >> Is this possible? I noticed vectors and a bunch of other stuff allocated >> and deallocated this way. > > Yes, sentinels. They're on my TODO list for 0.6, which I started working > on today (yes, you can already find some nifty new stuff in svn ;-). Ok, these are implemented now, you can find them in primitives.pure. I named them "sentries" this time around, that's shorter and can't be confused with the well-established notion of the sentinel value. Usage is easy, see the fopen function in system.pure for a real-world example. I've rewritten that so that it returns a file pointer that takes care of closing itself when it gets garbage-collected. Let's see these in action: > using system; > let x = sentry (\x->puts $ "done: "+str x) (foo 99); > clear x done: foo 99 How about doing smart pointers: mymalloc size = sentry free (malloc size); One thing worth noting here is that 'sentry' takes the sentry function as its first argument, which makes it easy to curry it. Add minimal error checking: mymalloc size = if null p then p else sentry free p when p = malloc size end; If you also want to be able to free the pointer explicitly, the sentry must of course then be released from his duty: myfree p = clear_sentry p $$ free p; Note that only a single sentry per expression is supported by 'sentry', but since you can find an existing sentry with get_sentry, it's easy to chain them if you need more than one. Also note that sentries can only be placed at applications and pointer objects, but this should cover all cases where they're really needed. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-08-28 15:09:25
|
On Thu, 2008-08-28 at 16:54 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > On Thu, 2008-08-28 at 02:23 +0200, Albert Graef wrote: > >> Eddie Rucker wrote: > >>> Now, how do I convert string "k" to symbol k? > >> eval? > >> > > Yea. > > Is that for the GSL lib? I smell an awful hack there. ;-) > Nope, eval is too insecure for something like that. e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-28 14:52:33
|
Eddie Rucker wrote: > On Thu, 2008-08-28 at 02:23 +0200, Albert Graef wrote: >> Eddie Rucker wrote: >>> Now, how do I convert string "k" to symbol k? >> eval? >> > Yea. Is that for the GSL lib? I smell an awful hack there. ;-) -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-08-28 12:51:42
|
On Thu, 2008-08-28 at 02:46 +0200, Albert Graef wrote: > Albert Graef wrote: > >> case type of > >> int = gsl_matrix_int_alloc r c, gsl_matrix_int_set; > >> double = gsl_matrix_alloc r c, gsl_matrix_set; > >> end; > >> > BTW, the above won't work in Haskell or ML either... That poor little > int function doesn't like it if you toss it around as if it was some > piece of silly data! ;-) I thought that was one of the points of using first class functions (ducking tomatoes) ;-) e.r. |
From: Eddie R. <er...@bm...> - 2008-08-28 12:38:38
|
On Thu, 2008-08-28 at 02:37 +0200, Albert Graef wrote: > BTW, using 'set' for the setter is a bad idea, that's already used in > set.pure. Actually the thingy I sent was bad. (m, setter) should have been (m, set) like in the following. Since set is local to matrix and we have lexical scoping, I see no problem. I can see wherethe typo in the previous would lead you to believe set was global. matrix ys@(x:xs) = Matrix type (do (\i -> do (\j -> set m i j (type ((ys!i)!j))) (0..c-1)) (0..r-1) $$ m) when r = #ys; c = #x; type = if foldl1 (*) (map (\x -> all intp x) ys) then int else double; (m, set) = if type === int then gsl_matrix_int_alloc r c, gsl_matrix_int_set else gsl_matrix_alloc r c, gsl_matrix_set; end; > symbolic constants for the different types. Or you could just pass a > "witness" of the type and then match against _::int etc.) I'm thinking about this. The case type of would make for easier reading when I add the complex matrix type in. Hope you got some good sleep. e.r. |
From: Eddie R. <er...@bm...> - 2008-08-28 12:30:56
|
On Thu, 2008-08-28 at 02:23 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > Now, how do I convert string "k" to symbol k? > > eval? > Yea. e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-28 12:11:11
|
David Baird wrote: > How would you like these filled out? My default thought is this: I'm fine with your suggestion. It's also ok if you s/ä/ae/, I often do that myself when it might be better to stick to 7 bit ASCII. ;-) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: David B. <dh...@gm...> - 2008-08-28 06:37:40
|
On Mon, Aug 25, 2008 at 10:05 AM, David Baird <dh...@gm...> wrote: > On Sun, Aug 24, 2008 at 7:22 PM, Albert Graef <Dr....@t-...> wrote: >> If you have any additional questions about the build process just ask. > > Surely. Sorry this is taking me some time - there are a few other > things I am juggling right now. I'm going to set a goal to have some > packages (source and x86) ready by this coming weekend. Okay, a quick update. I have figured out most of the details of packaging Pure 0.5. I haven't contacted the Debian lists yet. My plan was to do a request-for-sponsor on the debian-mentors list as soon as I can resolve the errors from Lintian. Debian experimental has LLVM 2.3 whereas Debian unstable has only LLVM 2.2. AFAICT, Pure 0.5 wants LLVM 2.3. I guess that means Pure 0.5 will also have to be in experimental along with LLVM 2.3...? Lintian (Debian's sanity checking/validation program) is printing some errors that I'll have to deal with. I'll look at this more later (about to fall asleep now), but here are the messages just in case anyone is curious: Now running lintian... W: pure source: dh-make-template-in-source debian/cron.d.ex W: pure source: dh-make-template-in-source debian/pure.default.ex W: pure source: dh-make-template-in-source debian/init.d.lsb.ex W: pure source: dh-make-template-in-source debian/preinst.ex W: pure source: dh-make-template-in-source debian/pure.doc-base.EX W: pure source: dh-make-template-in-source debian/manpage.sgml.ex W: pure source: dh-make-template-in-source debian/postinst.ex W: pure source: dh-make-template-in-source debian/manpage.1.ex W: pure source: dh-make-template-in-source debian/postrm.ex W: pure source: dh-make-template-in-source debian/prerm.ex W: pure source: dh-make-template-in-source debian/emacsen-remove.ex W: pure source: dh-make-template-in-source debian/menu.ex W: pure source: dh-make-template-in-source debian/watch.ex W: pure source: dh-make-template-in-source debian/emacsen-startup.ex W: pure source: dh-make-template-in-source debian/emacsen-install.ex W: pure source: dh-make-template-in-source debian/manpage.xml.ex W: pure source: dh-make-template-in-source debian/init.d.ex W: pure source: out-of-date-standards-version 3.7.3 (current is 3.8.0) E: pure: manpage-not-compressed usr/share/man/man1/pure.1 W: pure: package-contains-empty-directory usr/sbin/ W: pure: readme-debian-contains-debmake-template E: pure: sharedobject-in-library-directory-missing-soname usr/lib/libpure-0.5.so E: pure: copyright-file-contains-full-gpl-license W: pure: copyright-lists-upstream-authors-with-dh_make-boilerplate W: pure: new-package-should-close-itp-bug W: pure: wrong-bug-number-in-closes l3:#nnnn Finished running lintian. I'll be happy to resolve these errors, as soon as I can figure out what some of them actually mean :-) -David |
From: David B. <dh...@gm...> - 2008-08-28 05:45:43
|
On Mon, Aug 25, 2008 at 10:05 AM, David Baird <dh...@gm...> wrote: > On Sun, Aug 24, 2008 at 7:22 PM, Albert Graef <Dr....@t-...> wrote: >> If you have any additional questions about the build process just ask. > > Surely. Sorry this is taking me some time - there are a few other > things I am juggling right now. I'm going to set a goal to have some > packages (source and x86) ready by this coming weekend. Okay, I am working out the debian files now. I have a question for the debian/copyright template: Upstream Author(s): <put author's name and email here> <likewise for another author> Copyright: <Copyright (C) YYYY Name OfAuthor> <likewise for another author> How would you like these filled out? My default thought is this: Upstream Author(s): Albert Gräf <Dr.Graef at t-online.de> Copyright: Copyright (C) 2008 Albert Gräf -David |
From: Albert G. <Dr....@t-...> - 2008-08-28 00:45:17
|
Albert Graef wrote: >> case type of >> int = gsl_matrix_int_alloc r c, gsl_matrix_int_set; >> double = gsl_matrix_alloc r c, gsl_matrix_set; >> end; >> >> but it seems that case uses (==) instead of (===). BTW, the above won't work in Haskell or ML either... That poor little int function doesn't like it if you toss it around as if it was some piece of silly data! ;-) You could also just do a if type===int then ... else if type==double ..., of course. G'night, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-08-28 00:36:11
|
Eddie Rucker wrote: > (do (\i -> do (\j -> set m i j (type ((ys!i)!j))) (0..c-1)) (0..r-1) That kind of abomination will hopefully soon become much easier. With the help of macros it should be easy to write an optimization rule for the void combinator so that void [set m i j; i = ...; j = ...] will just translate to a nested do automagically. BTW, using 'set' for the setter is a bad idea, that's already used in set.pure. > case type of > int = gsl_matrix_int_alloc r c, gsl_matrix_int_set; > double = gsl_matrix_alloc r c, gsl_matrix_set; > end; > > but it seems that case uses (==) instead of (===). No it doesn't. Sorry, it's too late again, so I won't rehash the manual here. The explanations of 'head = function' and 'nullary' symbols in the manual should help. (You can't match against an ordinary function symbol, it must be a constant. So you might want to define your own symbolic constants for the different types. Or you could just pass a "witness" of the type and then match against _::int etc.) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-08-28 00:22:23
|
Eddie Rucker wrote: > Now, how do I convert string "k" to symbol k? eval? -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-08-27 20:13:07
|
I'm probably just overlooking it. > str k; "k" Now, how do I convert string "k" to symbol k? e.r. |
From: Eddie R. <er...@bm...> - 2008-08-27 17:00:28
|
The following works fine except that I don't have a verify function yet to verify that all of the rows are the same length. Probably need to just find the longest row and then set undefined matrix cells to 0? But for the real question. matrix ys@(x:xs) = Matrix type (do (\i -> do (\j -> set m i j (type ((ys!i)!j))) (0..c-1)) (0..r-1) $$ m) when r = #ys; c = #x; type = if foldl1 (*) (map (\x -> all intp x) ys) then int else double; (m, setter) = if type === int then gsl_matrix_int_alloc r c, gsl_matrix_int_set else gsl_matrix_alloc r c, gsl_matrix_set; end; It would be nice if "(m, setter) = .." could be written case type of int = gsl_matrix_int_alloc r c, gsl_matrix_int_set; double = gsl_matrix_alloc r c, gsl_matrix_set; end; but it seems that case uses (==) instead of (===). e.r. |
From: Eddie R. <er...@bm...> - 2008-08-27 15:40:29
|
On Wed, 2008-08-27 at 17:21 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > Um... Is there some way from Pure to find out the byte sizeof ints, > > doubles, complex, etc? When the sizes change on different machines > > and/or compilers I'd like the library to automatically handle this. > > You can put some C functions for that in your wrapper, too. (On > non-antique hardware, double should always be 64 bit, int 32; the latter > might be aligned on 8 byte boundaries on some 64 bit systems, though.) Exactly, on my Linux box (64bit) I have 8 byte boundaries and on my Windows box (32bit) I have 4 byte boundaries. Can I always determine if a system is 32bit or 64bit from sysinfo? e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-27 15:20:13
|
Eddie Rucker wrote: > Um... Is there some way from Pure to find out the byte sizeof ints, > doubles, complex, etc? When the sizes change on different machines > and/or compilers I'd like the library to automatically handle this. You can put some C functions for that in your wrapper, too. (On non-antique hardware, double should always be 64 bit, int 32; the latter might be aligned on 8 byte boundaries on some 64 bit systems, though.) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-08-27 15:12:27
|
Eddie Rucker wrote: > On Wed, 2008-08-27 at 10:42 +0200, Albert Graef wrote: >> Sorry for the repeated posts. Looks like this message took a long detour >> to Mars or whatever. > > LOL LOL LOL LOL ... ;-) Don't laugh. I hear it that some guys must already be working on interplanetary TCP/IP. ;-) -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-08-27 14:24:30
|
On Tue, 2008-08-26 at 02:54 +0200, Albert Graef wrote: > - Accessing the fields of a struct through pointers in Pure is possible > (see the stuff at the end of primitives.pure), but probably > non-portable. You'd probably need some getter/setter functions in your > wrapper to do that in a safe way. Um... Is there some way from Pure to find out the byte sizeof ints, doubles, complex, etc? When the sizes change on different machines and/or compilers I'd like the library to automatically handle this. e.r. |
From: Eddie R. <er...@bm...> - 2008-08-27 12:25:03
|
On Wed, 2008-08-27 at 10:42 +0200, Albert Graef wrote: > Sorry for the repeated posts. Looks like this message took a long detour > to Mars or whatever. LOL LOL LOL LOL ... ;-) e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-27 08:51:04
|
Sorry for the repeated posts. Looks like this message took a long detour to Mars or whatever. -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |