From vigalchin at gmail.com Tue Jul 1 00:21:47 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jul 1 00:12:58 2008 Subject: [Haskell-cafe] http://www.haskell.org/ghc/reportabug In-Reply-To: <178793749.20080630191909@gmail.com> References: <5ae4f2ba0806290009l5ad4bd12s1123906ec3c59aed@mail.gmail.com> <178793749.20080630191909@gmail.com> Message-ID: <5ae4f2ba0806302121rd582c49s23db835ca2350b38@mail.gmail.com> Hi Bulat and others, Basically I am testing my Posix timer bindings. When a timer is created via timer_create( http://www.opengroup.org/onlinepubs/009695399/functions/timer_create.html), it is possible to pass a sigevent struct. When I specify sigev_notify as NONE OR SIGNAL, all is well. When I specify sigev_notify as THREAD which causes a callback to a Haskell function that I specify, then sometimes I get a core dump due to SIGABRT or an internal error in the Haskell run time library. Many times when I run as sigev_notify==THREAD every thing seems to be OK. I am trying to come up with ideas of what is wrong. I know there are constraints on what can be called from a sigevent callback function. Unfortunately I don't know anything about the ghc runtime model. ??? Vasili On Mon, Jun 30, 2008 at 10:19 AM, Bulat Ziganshin wrote: > Hello Vasili, > > Sunday, June 29, 2008, 11:09:51 AM, you wrote: > > > When I run my test case, I get > > > timer: internal error: scavenge: unimplemented/strange closure type 60 @ > 0x76a28400 > > if you run low-level code that directly modifies memory via FFI > functions, it's more probable that error is just in your code > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080630/70a74a34/attachment.htm From vigalchin at gmail.com Tue Jul 1 03:42:26 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jul 1 03:33:37 2008 Subject: [Haskell-cafe] POSIX AIO (asych I/O) ... Message-ID: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> Hello, I am also testing my aio support. The aio_write binding seems to work ok .. as well as aio_error, Aio_return is a problem child. I think I wrote a really simple binding. I always receive nbytes as 0. I have been staring at the code hoping to catch a stupid mistake. I put putStrLn's in the code. .....Here is the code ... aioReturn :: AIOCB -> IO (AIOCB, ByteCount) aioReturn aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return p_aiocb) aiocb <- peek p_aiocb return (aiocb, fromIntegral count) foreign import ccall safe "aio.h aio_return" c_aio_return :: Ptr AIOCB -> IO CInt Maybe someone can spot something that I haven't. Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/4fbec950/attachment.htm From bulat.ziganshin at gmail.com Tue Jul 1 03:48:14 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jul 1 03:41:22 2008 Subject: [Haskell-cafe] POSIX AIO (asych I/O) ... In-Reply-To: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> Message-ID: <848319321.20080701114814@gmail.com> Hello Vasili, Tuesday, July 1, 2008, 11:42:26 AM, you wrote: looks ok, show us your peek/poke code > Hello, > ?????? I am also testing my aio support. The aio_write binding > seems to work ok .. as well as aio_error, Aio_return is a problem > child. I think I wrote a really simple binding. I always receive > nbytes as 0. I have been staring at the code hoping to catch a > stupid mistake. I put putStrLn's in the code. .....Here is the code ... > > aioReturn :: AIOCB -> IO (AIOCB, ByteCount) > aioReturn aiocb = do > ?? allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > ????? poke p_aiocb aiocb > ????? count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return? p_aiocb) > ????? aiocb <- peek p_aiocb > ????? return (aiocb, fromIntegral count) > foreign import ccall safe "aio.h aio_return" > ??? c_aio_return :: Ptr AIOCB -> IO CInt > Maybe someone can spot something that I haven't. > > Thanks, Vasili > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From agentzh at gmail.com Tue Jul 1 04:39:50 2008 From: agentzh at gmail.com (Agent Zhang) Date: Tue Jul 1 04:31:01 2008 Subject: [Haskell-cafe] The ping method in HDBC In-Reply-To: <4868E04C.7050900@complete.org> References: <4868E04C.7050900@complete.org> Message-ID: On Mon, Jun 30, 2008 at 9:31 PM, John Goerzen wrote: > > run dbh "SELECT 1" [] > > I note from the Perl DBI documentation that it is not guaranteed that > its ping function actually does anything. Okay, thanks :) > > I am pondering connection pools in HDBC for the future, if I have the > need for it. > That'll be great ;) Best, -agentzh From mail at joachim-breitner.de Tue Jul 1 04:51:37 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue Jul 1 04:42:58 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> Message-ID: <1214902297.3261.12.camel@otto.ehbuehl.net> Hi, thanks for your comments. Am Montag, den 30.06.2008, 16:54 -0700 schrieb Ryan Ingram: > 1) unsafeInterleaveIO seems like a big hammer to use for this problem, > and there are a lot of gotchas involved that you may not have fully > thought out. But you do meet the main criteria (file being read is > assumed to be constant for a single run of the program). Any other gotcha? Anyways, is this really worse than the similary lazy readFile? Using that would not safe the call to open, but at least the reading and processing, in the same situations. > If you have the ability to store metadata about the computation along > with the computation results, maybe that would be a better solution? Not sure what you mean here, sorry. Can you elaborate? > 2) I agree with Luke that this "smells" more like an applicative > functor. But getting to monad syntax is quite nice if you can do so. > As an applicative functor you would have "writeFileOD :: Filename -> > ODIO ByteString -> ODIO ()"; then writeFile can handle all the > necessary figuring out of timestamps itself, and you get the bonus > guarantee that the contents of the files read by the "ODIO ByteString" > argument won't affect the filename you are going to output to. I thought about this (without having the applicative abstraction in mind). This would then look like: main = do f1 <- readFileOD "infile1" ? f2 <- readFileOD "infile2" writeFileOD "outfile1" $ someFunc <$> f1 <*> f2 writeFileOD "outfile2" $ someOtherFunc <$> f1 right? Will it still work so that if both outfiles need to be generated, f1 is read only once? > 3) Instead of (Read,Show), look into Data.Binary instead, if you > actually care about efficiency. Parsing text at read time will almost > never be faster than just performing the computation on the source > data again. I assume it?s still faster than, e.g., running an external program to read the exif tags, but you are right, Data.Binary is nicer for this. Thanks, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/293dd6ca/attachment.bin From vigalchin at gmail.com Tue Jul 1 05:07:03 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jul 1 04:58:14 2008 Subject: [Haskell-cafe] POSIX AIO (asych I/O) ... In-Reply-To: <848319321.20080701114814@gmail.com> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <848319321.20080701114814@gmail.com> Message-ID: <5ae4f2ba0807010207k5273a5d3ifddbda8a34d3d95f@mail.gmail.com> instance Storable AIOCB where sizeOf _ = (#const sizeof (struct aiocb)) alignment _ = 1 poke p_AIOCB (AIOCB aioFd aioLioOpcode aioReqPrio aioOffset aioBuf aioBytes aioSigevent) = do (#poke struct aiocb, aio_fildes) p_AIOCB aioFd (#poke struct aiocb, aio_lio_opcode) p_AIOCB aioLioOpcode (#poke struct aiocb, aio_reqprio) p_AIOCB aioReqPrio (#poke struct aiocb, aio_offset) p_AIOCB aioOffset (#poke struct aiocb, aio_buf) p_AIOCB aioBuf (#poke struct aiocb, aio_nbytes) p_AIOCB aioBytes (#poke struct aiocb, aio_sigevent) p_AIOCB aioSigevent peek p_AIOCB = do aioFd <- (#peek struct aiocb, aio_fildes) p_AIOCB aioLioOpcode <- (#peek struct aiocb, aio_lio_opcode) p_AIOCB aioReqPrio <- (#peek struct aiocb, aio_reqprio) p_AIOCB aioOffset <- (#peek struct aiocb, aio_offset) p_AIOCB aioBuf <- (#peek struct aiocb, aio_buf) p_AIOCB aioBytes <- (#peek struct aiocb, aio_nbytes) p_AIOCB aioSigevent <- (#peek struct aiocb, aio_sigevent) p_AIOCB return (AIOCB aioFd aioLioOpcode aioReqPrio aioOffset aioBuf aioBytes aioSigevent) On Tue, Jul 1, 2008 at 2:48 AM, Bulat Ziganshin wrote: > Hello Vasili, > > Tuesday, July 1, 2008, 11:42:26 AM, you wrote: > > looks ok, show us your peek/poke code > > > > Hello, > > > I am also testing my aio support. The aio_write binding > > seems to work ok .. as well as aio_error, Aio_return is a problem > > child. I think I wrote a really simple binding. I always receive > > nbytes as 0. I have been staring at the code hoping to catch a > > stupid mistake. I put putStrLn's in the code. .....Here is the code ... > > > > aioReturn :: AIOCB -> IO (AIOCB, ByteCount) > > aioReturn aiocb = do > > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > > poke p_aiocb aiocb > > count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return p_aiocb) > > aiocb <- peek p_aiocb > > return (aiocb, fromIntegral count) > > > foreign import ccall safe "aio.h aio_return" > > c_aio_return :: Ptr AIOCB -> IO CInt > > > Maybe someone can spot something that I haven't. > > > > Thanks, Vasili > > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/5eb2dfd8/attachment.htm From ketil at malde.org Tue Jul 1 05:53:46 2008 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 1 05:44:22 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <1214902297.3261.12.camel@otto.ehbuehl.net> (Joachim Breitner's message of "Tue\, 01 Jul 2008 10\:51\:37 +0200") References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> Message-ID: <87iqvq6ic5.fsf@malde.org> Joachim Breitner writes: >> 1) unsafeInterleaveIO seems like a big hammer to use for this problem, >> and there are a lot of gotchas involved that you may not have fully >> thought out. But you do meet the main criteria (file being read is >> assumed to be constant for a single run of the program). > Any other gotcha? The one that springs to mind is that you might run out of file handles. At least on Linux, that's a precious resource. -k -- If I haven't seen further, it is by standing in the footprints of giants From mail at joachim-breitner.de Tue Jul 1 06:22:35 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue Jul 1 06:13:57 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <87iqvq6ic5.fsf@malde.org> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> <87iqvq6ic5.fsf@malde.org> Message-ID: <1214907755.3261.28.camel@otto.ehbuehl.net> Hi, Am Dienstag, den 01.07.2008, 11:53 +0200 schrieb Ketil Malde: > Joachim Breitner writes: > > >> 1) unsafeInterleaveIO seems like a big hammer to use for this problem, > >> and there are a lot of gotchas involved that you may not have fully > >> thought out. But you do meet the main criteria (file being read is > >> assumed to be constant for a single run of the program). > > > Any other gotcha? > > The one that springs to mind is that you might run out of file > handles. At least on Linux, that's a precious resource. but at least then, (unsafeInterleaveIO readFile) is actually better than (readFile), because if I consume the files in sequence and complete, they will be opened and closed in sequence with the first one, but be opened all at once with the second. At least it won?t be worse, because the file will not be closed later, and possibly opened later. Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/195b2dac/attachment.bin From matthew at wellquite.org Tue Jul 1 08:15:47 2008 From: matthew at wellquite.org (Matthew Sackman) Date: Tue Jul 1 08:06:57 2008 Subject: [Haskell-cafe] Anglo Haskell 2008 Message-ID: <20080701121546.GC1808@arkansas.doc.ic.ac.uk> Anglo Haskell is a gathering of all people Haskell-related from beginners, to seasoned hackers to academic giants. All and more are welcomed by large fuzzy green lambdas. Anglo Haskell has happened for the last two years and we see no reason why it should not happen again this year. For the last two years they've tended to have talks on Fridays and then Other Things on the Saturday (including Punting and Group Hacking, some or more of which may have happened in Pubs). We're proposing the same general format this year. In contrast to the last two years which have been held at MSR Cambridge (UK), we're this year proposing to hold the event at Imperial College, London. London is probably easier to get to and from (though more tedious to get across) than Cambridge and we hope this will attract people who previously have not been able to get out to Cambridge. The proposed dates are Friday the 8th and Saturday the 9th of August. More details are available on the wikipage: http://www.haskell.org/haskellwiki/AngloHaskell/2008 Please feel free to add to this page. If you're at all interested in coming along then please add your name to the wikipage. If you're interested in giving a talk - on literally anything Haskell related: this is not a solely theory day or solely a practical day; anything goes which is Haskell related - then similarly add yourself to the list of speakers. Schedule and other details will be confirmed soon. Lodging, travel and all other related matters will be discussed on the irc channel (and will eventually migrate to the wikipage) #anglohaskell. If you're free that weekend then please come along! Also, if you'd really like to come but can't make those dates and there are many of you then please shout loudly and things could potentially be moved, though with the lack of time left before the event, we'd prefer to avoid this. Matthew From arthurvl at cs.uu.nl Tue Jul 1 08:26:36 2008 From: arthurvl at cs.uu.nl (Arthur van Leeuwen) Date: Tue Jul 1 08:17:46 2008 Subject: [Haskell-cafe] lhs syntax highlighting in vim In-Reply-To: <20080611102935.GA14493@matrix.chaos.earth.li> References: <2e58fd390806101723p3e74c6cfkce28786e9325afbd@mail.gmail.com> <20080611102935.GA14493@matrix.chaos.earth.li> Message-ID: On 11 jun 2008, at 12:29, Ian Lynagh wrote: > On Wed, Jun 11, 2008 at 01:23:58AM +0100, Eric Stansifer wrote: >> >> The syntax highlighting file for literate haskell in vim says that >> its >> maintainer is haskell-cafe@haskell.org, so hopefully one of you will >> find this relevant. >> >> In literate haskell files, vim optionally highlights the non-code >> text >> according to TeX markup. The syntax highlighting file looks for key >> phrases (e.g., "\documentclass") to decide whether to use TeX markup >> highlighting; but it (erroneously, in my opinion, and at variance >> with the documentation) will use TeX markup highlighting on any lhs >> file that contains the '%' character anywhere in it. The bug is in >> line 74 of version 1.01 of the lhaskell.vim syntax highlighting file. > > I agree that this is wrong. It used to only look at the first 20 > lines, > so we were covering the case where a TeX file began with some TeX > comments. We'd also look for ^\s*%, rather than a % anywhere. If we > are > going to look at the whole file then checking for comments isn't > necessary. Unfortunately that scan is not necesarily compatible with people dynamically turning on syntax highlighting. But just searching for % is *dead* wrong, I fully agree. I've modified the search code and submitted a patch to the Vim maintainers. With kind regards, Arthur van Leeuwen. -- /\ / | arthurvl@cs.uu.nl | Work like you don't need the money /__\ / | A friend is someone with whom | Love like you have never been hurt / \/__ | you can dare to be yourself | Dance like there's nobody watching From droundy at darcs.net Tue Jul 1 08:41:31 2008 From: droundy at darcs.net (David Roundy) Date: Tue Jul 1 08:32:34 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <1214907755.3261.28.camel@otto.ehbuehl.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> <87iqvq6ic5.fsf@malde.org> <1214907755.3261.28.camel@otto.ehbuehl.net> Message-ID: <20080701124130.GA8669@darcs.net> On Tue, Jul 01, 2008 at 10:22:35AM +0000, Joachim Breitner wrote: > Hi, > > Am Dienstag, den 01.07.2008, 11:53 +0200 schrieb Ketil Malde: > > Joachim Breitner writes: > > > > >> 1) unsafeInterleaveIO seems like a big hammer to use for this problem, > > >> and there are a lot of gotchas involved that you may not have fully > > >> thought out. But you do meet the main criteria (file being read is > > >> assumed to be constant for a single run of the program). > > > > > Any other gotcha? > > > > The one that springs to mind is that you might run out of file > > handles. At least on Linux, that's a precious resource. > > but at least then, (unsafeInterleaveIO readFile) is actually better than > (readFile), because if I consume the files in sequence and complete, > they will be opened and closed in sequence with the first one, but be > opened all at once with the second. At least it won?t be worse, because > the file will not be closed later, and possibly opened later. Indeed, the best option (in my opinion) would be unsafeInterleaveIO readFileStrict (where you might need to write readFileStrict). In darcs, we use lazy IO a lot, but never lazily read a file, precisely due to the open file handle issue. This works pretty well, and your scenario is precisely the one in which unsafeInterleaveIO shines. David -------------- 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/20080701/478887dc/attachment.bin From lemming at henning-thielemann.de Tue Jul 1 08:55:41 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jul 1 08:46:58 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <20080701124130.GA8669@darcs.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> <87iqvq6ic5.fsf@malde.org> <1214907755.3261.28.camel@otto.ehbuehl.net> <20080701124130.GA8669@darcs.net> Message-ID: On Tue, 1 Jul 2008, David Roundy wrote: > Indeed, the best option (in my opinion) would be > > unsafeInterleaveIO readFileStrict How about ByteString.readFile ? This is strict and efficient. From loup.vaillant at gmail.com Tue Jul 1 10:57:38 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Tue Jul 1 10:48:49 2008 Subject: [Haskell-cafe] gcc as a portable assembler: tail calls vs trampoline Message-ID: <6f9f8f4a0807010757x590058e7kc7892b716ccea359@mail.gmail.com> Hello, everyone, I'm not sure this is the good list for this posting: I plan to write yet another lazy graph reduction machine, using gcc, mainly for fun. My concern right now is about one particular aspect of gcc: the tail calls vs trampoline deathmatch. First some clarifications: -> By tail call, I mean a properly optimized one, which doesn't grow the stack. Basically a jump. -> By trampoline, I mean the infinite loop referred to as a "tiny interpreter" in the STG paper [1]. Instead of (tail) calling a function, we return its pointer, which will then be used for the actual call. I've read that trampoline calls are about 3 times as expensive as tail calls. Instead of a (direct) jump, you have a return, followed by an indirect call. However, testing this with gcc, I didn't manage to show any measurable difference. What am I missing? I used -O2 on both benchmarks, and turned off inlining (using the __noinline__ attribute). I'm running the program on a core2Duo in 32 bits mode, using GNU/Linux Ubuntu. Should I also make separate modules to prevent whole program analysis from gcc? Anyway, I send you the code below, so you can test and review it. Enjoy! [1]: http://research.microsoft.com/Users/simonpj/Papers/spineless-tagless-gmachine.ps.gz /* This program tests the performance difference between trampoline * calls and tail calls. (In the STG and related papers, trampoline * is referred to as "tiny interpreter") * * depending on the mode (tail call or trampoline), some code changes: * the return type of the code blocks, and the calls to other blocks * (direct tail calls or return to trampoline). Hence the macros ENTER * and RETURN. * * To compile it,type one of the two following commands: * gcc -O2 sibcall.c -D SIBCALL * gcc -O2 sibcall.c * * The first one will make the program use sibling calls (enabled at * O2), and the second one will fall back to trampoline calls */ #ifdef SIBCALL // tail call mode #define ENTER(f) (f()) #define RETURN void #define MAIN(start) start() #else // trampoline call mode #define ENTER(f) return f #define RETURN void* #define MAIN(start) do{ void * (*f)(void) = start; \ while (1) \ f = (*f)(); \ } while (0) #endif // Now, we can begin the generic code #include #define LIMIT 1000000000 // one billion int counter = 0; RETURN closure0(void); RETURN closure1(void); int main(int argc, char ** argv) { MAIN(closure0); return 0; } __attribute__ ((__noinline__)) RETURN closure0(void) { if (counter >= LIMIT) exit(0); counter++; ENTER(closure1); } __attribute__ ((__noinline__)) RETURN closure1(void) { if (counter >= LIMIT) exit(0); counter++; ENTER(closure0); } From loup.vaillant at gmail.com Tue Jul 1 11:43:52 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Tue Jul 1 11:35:03 2008 Subject: [Haskell-cafe] gcc as a portable assembler: tail calls vs trampoline In-Reply-To: <20080701162735.43fc009d@greenrd.org> References: <6f9f8f4a0807010757x590058e7kc7892b716ccea359@mail.gmail.com> <20080701162735.43fc009d@greenrd.org> Message-ID: <6f9f8f4a0807010843p3895f97by68429e35c17b204c@mail.gmail.com> 2008/7/1 Robin Green : > I think you should use the -march flag to gcc. Otherwise you are tying > the compiler to an ancient version of the x86 instruction set (386). OK, let's try... Done. I used -march=nocona. I couldn't do core2 (not available on my gcc 4.1.2 yet). Did not notice any difference... > On Tue, 1 Jul 2008 16:57:38 +0200 > "Loup Vaillant" wrote: > >> Hello, everyone, >> I'm not sure this is the good list for this posting: I plan to write >> yet another lazy graph reduction machine, using gcc, mainly for fun. >> My concern right now is about one particular aspect of gcc: the tail >> calls vs trampoline deathmatch. >> >> First some clarifications: >> -> By tail call, I mean a properly optimized one, which doesn't grow >> the stack. Basically a jump. >> -> By trampoline, I mean the infinite loop referred to as a "tiny >> interpreter" in the STG paper [1]. Instead of (tail) calling a >> function, we return its pointer, which will then be used for the >> actual call. >> >> I've read that trampoline calls are about 3 times as expensive as tail >> calls. Instead of a (direct) jump, you have a return, followed by an >> indirect call. However, testing this with gcc, I didn't manage to show >> any measurable difference. What am I missing? I used -O2 on both >> benchmarks, and turned off inlining (using the __noinline__ >> attribute). I'm running the program on a core2Duo in 32 bits mode, >> using GNU/Linux Ubuntu. Should I also make separate modules to prevent >> whole program analysis from gcc? >> >> Anyway, I send you the code below, so you can test and review it. >> Enjoy! >> >> [1]: >> http://research.microsoft.com/Users/simonpj/Papers/spineless-tagless-gmachine.ps.gz >> >> >> >> /* This program tests the performance difference between trampoline >> * calls and tail calls. (In the STG and related papers, trampoline >> * is referred to as "tiny interpreter") >> * >> * depending on the mode (tail call or trampoline), some code changes: >> * the return type of the code blocks, and the calls to other blocks >> * (direct tail calls or return to trampoline). Hence the macros ENTER >> * and RETURN. >> * >> * To compile it,type one of the two following commands: >> * gcc -O2 sibcall.c -D SIBCALL >> * gcc -O2 sibcall.c >> * >> * The first one will make the program use sibling calls (enabled at >> * O2), and the second one will fall back to trampoline calls >> */ >> >> #ifdef SIBCALL // tail call mode >> >> #define ENTER(f) (f()) >> #define RETURN void >> #define MAIN(start) start() >> >> #else // trampoline call mode >> >> #define ENTER(f) return f >> #define RETURN void* >> #define MAIN(start) do{ void * (*f)(void) = start; \ >> while (1) \ >> f = (*f)(); \ >> } while (0) >> #endif >> >> // Now, we can begin the generic code >> #include >> #define LIMIT 1000000000 // one billion >> >> int counter = 0; >> >> RETURN closure0(void); >> RETURN closure1(void); >> >> >> int main(int argc, char ** argv) >> { >> MAIN(closure0); >> return 0; >> } >> >> __attribute__ ((__noinline__)) >> RETURN closure0(void) >> { >> if (counter >= LIMIT) exit(0); >> counter++; >> ENTER(closure1); >> } >> __attribute__ ((__noinline__)) >> RETURN closure1(void) >> { >> if (counter >= LIMIT) exit(0); >> counter++; >> ENTER(closure0); >> } >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From bf3 at telenet.be Tue Jul 1 15:10:47 2008 From: bf3 at telenet.be (Peter Verswyvelen) Date: Tue Jul 1 15:02:01 2008 Subject: [Haskell-cafe] gcc as a portable assembler: tail calls vs trampoline In-Reply-To: <6f9f8f4a0807010843p3895f97by68429e35c17b204c@mail.gmail.com> References: <6f9f8f4a0807010757x590058e7kc7892b716ccea359@mail.gmail.com> <20080701162735.43fc009d@greenrd.org> <6f9f8f4a0807010843p3895f97by68429e35c17b204c@mail.gmail.com> Message-ID: <486A8136.2080500@telenet.be> Did you look at the generated assembly code? Although I don't know anything about GCC, I believe it's easy to let it generate an assembly listing file. Loup Vaillant wrote: > 2008/7/1 Robin Green : > >> I think you should use the -march flag to gcc. Otherwise you are tying >> the compiler to an ancient version of the x86 instruction set (386). >> > > OK, let's try... Done. I used -march=nocona. I couldn't do core2 (not > available on my gcc 4.1.2 yet). Did not notice any difference... > > > >> On Tue, 1 Jul 2008 16:57:38 +0200 >> "Loup Vaillant" wrote: >> >> >>> Hello, everyone, >>> I'm not sure this is the good list for this posting: I plan to write >>> yet another lazy graph reduction machine, using gcc, mainly for fun. >>> My concern right now is about one particular aspect of gcc: the tail >>> calls vs trampoline deathmatch. >>> >>> First some clarifications: >>> -> By tail call, I mean a properly optimized one, which doesn't grow >>> the stack. Basically a jump. >>> -> By trampoline, I mean the infinite loop referred to as a "tiny >>> interpreter" in the STG paper [1]. Instead of (tail) calling a >>> function, we return its pointer, which will then be used for the >>> actual call. >>> >>> I've read that trampoline calls are about 3 times as expensive as tail >>> calls. Instead of a (direct) jump, you have a return, followed by an >>> indirect call. However, testing this with gcc, I didn't manage to show >>> any measurable difference. What am I missing? I used -O2 on both >>> benchmarks, and turned off inlining (using the __noinline__ >>> attribute). I'm running the program on a core2Duo in 32 bits mode, >>> using GNU/Linux Ubuntu. Should I also make separate modules to prevent >>> whole program analysis from gcc? >>> >>> Anyway, I send you the code below, so you can test and review it. >>> Enjoy! >>> >>> [1]: >>> http://research.microsoft.com/Users/simonpj/Papers/spineless-tagless-gmachine.ps.gz >>> >>> >>> >>> /* This program tests the performance difference between trampoline >>> * calls and tail calls. (In the STG and related papers, trampoline >>> * is referred to as "tiny interpreter") >>> * >>> * depending on the mode (tail call or trampoline), some code changes: >>> * the return type of the code blocks, and the calls to other blocks >>> * (direct tail calls or return to trampoline). Hence the macros ENTER >>> * and RETURN. >>> * >>> * To compile it,type one of the two following commands: >>> * gcc -O2 sibcall.c -D SIBCALL >>> * gcc -O2 sibcall.c >>> * >>> * The first one will make the program use sibling calls (enabled at >>> * O2), and the second one will fall back to trampoline calls >>> */ >>> >>> #ifdef SIBCALL // tail call mode >>> >>> #define ENTER(f) (f()) >>> #define RETURN void >>> #define MAIN(start) start() >>> >>> #else // trampoline call mode >>> >>> #define ENTER(f) return f >>> #define RETURN void* >>> #define MAIN(start) do{ void * (*f)(void) = start; \ >>> while (1) \ >>> f = (*f)(); \ >>> } while (0) >>> #endif >>> >>> // Now, we can begin the generic code >>> #include >>> #define LIMIT 1000000000 // one billion >>> >>> int counter = 0; >>> >>> RETURN closure0(void); >>> RETURN closure1(void); >>> >>> >>> int main(int argc, char ** argv) >>> { >>> MAIN(closure0); >>> return 0; >>> } >>> >>> __attribute__ ((__noinline__)) >>> RETURN closure0(void) >>> { >>> if (counter >= LIMIT) exit(0); >>> counter++; >>> ENTER(closure1); >>> } >>> __attribute__ ((__noinline__)) >>> RETURN closure1(void) >>> { >>> if (counter >= LIMIT) exit(0); >>> counter++; >>> ENTER(closure0); >>> } >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/2c257f61/attachment.htm From ryani.spam at gmail.com Tue Jul 1 17:52:02 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 1 17:43:11 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <1214902297.3261.12.camel@otto.ehbuehl.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> Message-ID: <2f9b2d30807011452k1bb91a6btd7fc8a8d2b56b339@mail.gmail.com> On 7/1/08, Joachim Breitner wrote: > Hi, > > thanks for your comments. > > Am Montag, den 30.06.2008, 16:54 -0700 schrieb Ryan Ingram: > > 1) unsafeInterleaveIO seems like a big hammer to use for this problem, > > and there are a lot of gotchas involved that you may not have fully > > thought out. But you do meet the main criteria (file being read is > > assumed to be constant for a single run of the program). > > Any other gotcha? Anyways, is this really worse than the similary lazy > readFile? Using that would not safe the call to open, but at least the > reading and processing, in the same situations. Well, you're also (from your description) probably writing some tracking information to an IORef of some sort. That can happen in the middle of an otherwise pure computation, and it's difficult to know exactly when it'll get triggered, due to laziness. You can probably make it work :) > > If you have the ability to store metadata about the computation along > > with the computation results, maybe that would be a better solution? > > Not sure what you mean here, sorry. Can you elaborate? Well, while doing the computation the first time, you can track what depends on what. Then you save *that* information out. Here's an example: main = runODIO $ do do bar <- readFileOD "bar.txt" baz <- readFileOD "baz.txt" let result = expensiveComputation bar baz writeFileOD "foo.bin" result do hat <- readFileOD "hat.txt" let result = otherComputation hat writeFileOD "foo2.bin" result Now, as you mentioned before, you know that the RHS of >> doesn't depend on the files read on the LHS. So the two "do" blocks here are independent. Now, if you run with no information, you run the whole computation, and you write out in your metadata "First we are going to build foo.bin from bar.txt and baz.txt, and then we build foo2.bin from hat.txt". Now when you get to the first "do" block, you know what computation is about to happen (since you've recorded it before), and can check the timestamps of foo.bin, bar.txt, and baz.txt, and potentially skip the whole thing. Of course now the metadata depends on the script itself, but you already had to deal with that problem :) > > 2) I agree with Luke that this "smells" more like an applicative > > functor. But getting to monad syntax is quite nice if you can do so. > > As an applicative functor you would have "writeFileOD :: Filename -> > > ODIO ByteString -> ODIO ()"; then writeFile can handle all the > > necessary figuring out of timestamps itself, and you get the bonus > > guarantee that the contents of the files read by the "ODIO ByteString" > > argument won't affect the filename you are going to output to. > > I thought about this (without having the applicative abstraction in > mind). This would then look like: > > main = do > f1 <- readFileOD "infile1" > ? f2 <- readFileOD "infile2" > writeFileOD "outfile1" $ someFunc <$> f1 <*> f2 > writeFileOD "outfile2" $ someOtherFunc <$> f1 > > right? Not exactly. Try this: writeFileOD "outfile1" (someFunc <$> readFileOD "infile1" <*> readFileOD "infile2") writeFileOD "outfile2" (someOtherFunc <$> readFIleOD "infile1") (or, equivalently, replace the "<-" with "let .. in" in your data). > Will it still work so that if both outfiles need to be generated, > f1 is read only once? That depends how you write it! Remember that you can write your applicative functor to just build up a graph of what computation might need to be done. You can then analyze that graph and look for sharing if necessary. If you want the sharing to be explicit, you need something a bit more monad-ish. If the type of "readFileOD" is "Filename -> ODIO (ODIO ByteString)" then your original syntax works and gives you a chance to pick up on the explicit sharing by labelling the result of "f1 <- ...". -- ryan From mail at joachim-breitner.de Tue Jul 1 17:57:47 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue Jul 1 17:49:11 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <2f9b2d30807011452k1bb91a6btd7fc8a8d2b56b339@mail.gmail.com> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> <2f9b2d30807011452k1bb91a6btd7fc8a8d2b56b339@mail.gmail.com> Message-ID: <1214949467.4744.11.camel@otto.ehbuehl.net> Hi, thanks again for you input. Just one small remark: Am Dienstag, den 01.07.2008, 14:52 -0700 schrieb Ryan Ingram: > On 7/1/08, Joachim Breitner wrote: > > Am Montag, den 30.06.2008, 16:54 -0700 schrieb Ryan Ingram: > > > 1) unsafeInterleaveIO seems like a big hammer to use for this problem, > > > and there are a lot of gotchas involved that you may not have fully > > > thought out. But you do meet the main criteria (file being read is > > > assumed to be constant for a single run of the program). > > > > Any other gotcha? Anyways, is this really worse than the similary lazy > > readFile? Using that would not safe the call to open, but at least the > > reading and processing, in the same situations. > > Well, you're also (from your description) probably writing some > tracking information to an IORef of some sort. That can happen in the > middle of an otherwise pure computation, and it's difficult to know > exactly when it'll get triggered, due to laziness. You can probably > make it work :) Well, for the tracking information, I can do it purely, by copying code from StateT (or WriterT or ReaderT, I?m not sure :-)), and adapting slightly (e.g. the (>>) optimization). So besides unsafeInterleaveIO, no ?bad, unpure stuff? should be necessary. I think I?ll put my ideas to code soon and post it here. Greetings, Joachim -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189 Jabber-ID: nomeata@joachim-breitner.de -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/0e2c5e95/attachment.bin From allbery at ece.cmu.edu Tue Jul 1 17:59:55 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Jul 1 17:51:05 2008 Subject: [Haskell-cafe] A Monad for on-demand file generation? In-Reply-To: <2f9b2d30807011452k1bb91a6btd7fc8a8d2b56b339@mail.gmail.com> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <2f9b2d30806301654y47cef755pc13758dd4ea638c9@mail.gmail.com> <1214902297.3261.12.camel@otto.ehbuehl.net> <2f9b2d30807011452k1bb91a6btd7fc8a8d2b56b339@mail.gmail.com> Message-ID: On 2008 Jul 1, at 17:52, Ryan Ingram wrote: > Well, you're also (from your description) probably writing some > tracking information to an IORef of some sort. That can happen in the > middle of an otherwise pure computation, and it's difficult to know > exactly when it'll get triggered, due to laziness. You can probably > make it work :) > >>> If you have the ability to store metadata about the computation >>> along >>> with the computation results, maybe that would be a better solution? >> >> Not sure what you mean here, sorry. Can you elaborate? > > Well, while doing the computation the first time, you can track what > depends on what. Then you save *that* information out. Here's an This sounds suspiciously like Writer to me. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From vigalchin at gmail.com Wed Jul 2 01:42:20 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jul 2 01:33:28 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> Message-ID: <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> Hello, Haskell 101 question! I discovered that aio_error returns "errno" rather -1. Of course, my aio_error binding is called before my aio_return binding (aio calling sequence "protocol"). I have worked on Posix OS's for quite a while but am unhappy with non-consistent errno handling ;^(. In any case, I modified my aio_error binding implementation to have a "AIOCB -> IO Errno" signature: aioError :: AIOCB -> IO Errno aioError aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) return (errno) foreign import ccall safe "aio.h aio_error" c_aio_error :: Ptr AIOCB -> IO Errno "ghc" thinks that "Errno" should be an instance of "Num": System/Posix/Aio.hsc:117:15: No instance for (Num Errno) Why? Vasili On Tue, Jul 1, 2008 at 2:42 AM, Galchin, Vasili wrote: > Hello, > > I am also testing my aio support. The aio_write binding seems to > work ok .. as well as aio_error, Aio_return is a problem child. I think I > wrote a really simple binding. I always receive nbytes as 0. I have been > staring at the code hoping to catch a stupid mistake. I put putStrLn's in > the code. .....Here is the code ... > > aioReturn :: AIOCB -> IO (AIOCB, ByteCount) > aioReturn aiocb = do > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb > count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return p_aiocb) > aiocb <- peek p_aiocb > return (aiocb, fromIntegral count) > > foreign import ccall safe "aio.h aio_return" > c_aio_return :: Ptr AIOCB -> IO CInt > > Maybe someone can spot something that I haven't. > > Thanks, Vasili > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/f4ed9768/attachment.htm From allbery at ece.cmu.edu Wed Jul 2 02:07:25 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Jul 2 01:58:35 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> Message-ID: <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> On 2008 Jul 2, at 1:42, Galchin, Vasili wrote: > errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) > > "ghc" thinks that "Errno" should be an instance of "Num": > > System/Posix/Aio.hsc:117:15: > No instance for (Num Errno) I expect so it can compare it to -1(throwErrnoIfMinusOne). But if the return value is actually an errno and not -1 to indicate error (which it is if I read the manpage correctly), you don't want throwErrnoIfMinus1 anyway; I suspect you want to wrap the return value of c_aio_return (which should be IO CInt) in an Errno constructor, then use errnoToIOError if you really want to raise an IOError. (What were you expecting for "count"? I see none, just an errno.) Note that it *never* returns -1; it returns 0 for successful completion for the aiocb, EINPROGRESS if it's still working, and the appropriate errno if it failed. You might want to decide if you want to use the aio_return style interface or something more Haskell-ish before designing this part of the API. If you want to stick close to the C interface: aioReturn :: AIOCB -> IO (AIOCB, Errno) aioReturn aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb err <- c_aio_return p_aiocb aiocb <- peek p_aiocb return (aiocb, Errno err) I'd actually consider something more Haskellish, e.g. a variant of StateT IO where the state is the aiocb and errno, the errno initialized to eINPROGRESS and set by aioReturn and aioError (and once aioReturn is called, it can't be called again so return the cached value if needed). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/81a51ecc/attachment.htm From jonathanccast at fastmail.fm Wed Jul 2 02:15:34 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Jul 2 02:06:42 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> Message-ID: <1214979335.8058.21.camel@jonathans-macbook> On Wed, 2008-07-02 at 02:07 -0400, Brandon S. Allbery KF8NH wrote: > > On 2008 Jul 2, at 1:42, Galchin, Vasili wrote: > > > errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) > > > > "ghc" thinks that "Errno" should be an instance of "Num": > > > > System/Posix/Aio.hsc:117:15: > > No instance for (Num Errno) > > > I expect so it can compare it to -1(throwErrnoIfMinusOne). But if the > return value is actually an errno and not -1 to indicate error (which > it is if I read the manpage correctly), you don't want > throwErrnoIfMinus1 anyway; I suspect you want to wrap the return value > of c_aio_return (which should be IO CInt) in an Errno constructor, > then use errnoToIOError if you really want to raise an IOError. > > > (What were you expecting for "count"? I see none, just an errno.) > > > Note that it *never* returns -1; it returns 0 for successful > completion for the aiocb, EINPROGRESS if it's still working, and the > appropriate errno if it failed. It seems as though it can return -1 if given non-sensical input. But in that case, the nicely type-correct thing to do would still be to have the C binding return a CInt, and wrap that after the call to throwErrnoIfMinus1 (in this case, `errno' still refers to the global errno, set to EINVAL). jcc From allbery at ece.cmu.edu Wed Jul 2 02:17:23 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Jul 2 02:08:32 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <1214979335.8058.21.camel@jonathans-macbook> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> <1214979335.8058.21.camel@jonathans-macbook> Message-ID: <1BD0B579-BE0A-4B82-B98A-9C1C7CE2DC12@ece.cmu.edu> On 2008 Jul 2, at 2:15, Jonathan Cast wrote: > It seems as though it can return -1 if given non-sensical input. > But in The POSIX spec says it returns EINVAL in that case. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From jonathanccast at fastmail.fm Wed Jul 2 02:32:32 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Jul 2 02:23:40 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <1BD0B579-BE0A-4B82-B98A-9C1C7CE2DC12@ece.cmu.edu> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> <1214979335.8058.21.camel@jonathans-macbook> <1BD0B579-BE0A-4B82-B98A-9C1C7CE2DC12@ece.cmu.edu> Message-ID: <1214980352.8058.29.camel@jonathans-macbook> On Wed, 2008-07-02 at 02:17 -0400, Brandon S. Allbery KF8NH wrote: > On 2008 Jul 2, at 2:15, Jonathan Cast wrote: > > > It seems as though it can return -1 if given non-sensical input. > > But in > > The POSIX spec says it returns EINVAL in that case. Are you sure? A little googling picks up e.g. HP docs [1] that state RETURN VALUE If the aiocb is invalid or if no asynchronous I/O operation is enqueued for the aiocb, aio_error() returns -1 and errno is set to indicate the error It may be non-POSIX, but I'd like to see some verbiage for which HP/UX's behavior isn't the most natural interpretation. jcc [1] http://docs.hp.com/en/B9106-90009/aio_error.2.html From vigalchin at gmail.com Wed Jul 2 02:47:46 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jul 2 02:38:55 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> Message-ID: <5ae4f2ba0807012347k683fbd5bx516ffbe26e08cd50@mail.gmail.com> Thanks, Brandon!! I understand most of what you say but let me ponder! Kind regards, Vasili On Wed, Jul 2, 2008 at 1:07 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On 2008 Jul 2, at 1:42, Galchin, Vasili wrote: > > errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) > > "ghc" thinks that "Errno" should be an instance of "Num": > > System/Posix/Aio.hsc:117:15: > No instance for (Num Errno) > > > I expect so it can compare it to -1(throwErrnoIfMinusOne). But if the > return value is actually an errno and not -1 to indicate error (which it is > if I read the manpage correctly), you don't want throwErrnoIfMinus1 anyway; > I suspect you want to wrap the return value of c_aio_return (which should be > IO CInt) in an Errno constructor, then use errnoToIOError if you really want > to raise an IOError. > > (What were you expecting for "count"? I see none, just an errno.) > > Note that it *never* returns -1; it returns 0 for successful completion for > the aiocb, EINPROGRESS if it's still working, and the appropriate errno if > it failed. > > You might want to decide if you want to use the aio_return style interface > or something more Haskell-ish before designing this part of the API. If you > want to stick close to the C interface: > > aioReturn :: AIOCB -> IO (AIOCB, Errno) > aioReturn aiocb = do > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb > err <- c_aio_return p_aiocb > aiocb <- peek p_aiocb > return (aiocb, Errno err) > I'd actually consider something more Haskellish, e.g. a variant of StateT > IO where the state is the aiocb and errno, the errno initialized to > eINPROGRESS and set by aioReturn and aioError (and once aioReturn is called, > it can't be called again so return the cached value if needed). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/3de1571c/attachment.htm From leaveye.guo at gmail.com Wed Jul 2 04:26:03 2008 From: leaveye.guo at gmail.com (L.Guo) Date: Wed Jul 2 04:17:19 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) References: <87zlpoguqh.fsf@elefant.olsbruecken.local>, <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com>, <200806170851.22718.valgarv@gmx.net>, <87ej6ww9dy.fsf_-_@columbia.edu>, <20080617201233.GD19304@scytale.galois.com>, <871w2mit8o.wl%jeremy@n-heptane.com>, , <14d615330806241903s30734fe4q5c7af4569e9b421@mail.gmail.com>, <14d615330806261657h3ce55bebx74f8e89205a9854@mail.gmail.com>, <87tzfehfgy.wl%jeremy@n-heptane.com> Message-ID: <200807021626009536167@gmail.com> Thanks for sharing your experences. I just tried to port GHC 6.8.3 to my TI Davincci (c6446) board by following the GHC Wiki Building/Porting page [1]. Both arm-compile and cross-compile version have failed unfortunately. So, I turn to try compile an local GHC on linux. It takes me so many time. I can not finish building it before off work. [1] http://hackage.haskell.org/trac/ghc/wiki/Building/Porting#PortingGHCtoanewplatform ------------------ L.Guo 2008-07-02 ------------------------------------------------------------- From: Jeremy Shaw At: 2008-06-28 02:57:38 Subject: Re: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) Cool! By cross-compilation, I assume you mean, a version of GHC which runs on x86, but generates ARM assembly? Another option might be to use a nintendo DS emulator which has been configured to support more RAM and CPU power ? A true cross-compiler would be nice though, because it will run much faster. GHC does have some support for cross-compilation, but in the current implementation, it is mostly (entirely?) there for bootstrapping. I have no idea how the ghc backend rewrite for 6.10 will affect this. Hope this helps, j. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From v.dijk.bas at gmail.com Wed Jul 2 06:53:14 2008 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Jul 2 06:44:23 2008 Subject: [Haskell-cafe] Question about abstraction Message-ID: Dear list, I have I question about the following code I was playing with: (you can past the following right into your editor) ---------------------------------------------------------------------- import Data.Foldable (Foldable, foldMap) import Data.Monoid (mempty, mappend) import Data.Traversable (Traversable, traverse) import Control.Applicative (pure, (<$>), (<*>)) -- I was playing with the following tree-like datastructure (my plan -- is to make some kind of kd-tree but that's not important now): data T a = L | N C2 a (T a) (T a) (T a) (T a) type C2 = (Float, Float) -- A fold always comes in handy: foldT :: b -> (C2 -> a -> b -> b -> b -> b -> b) -> T a -> b foldT e _ L = e foldT e n (N c x tl tr bl br) = n c x (foldT e n tl) (foldT e n tr) (foldT e n bl) (foldT e n br) instance Functor T where fmap f = foldT L (\p -> N p . f) -- Now I defined the following instances: instance Foldable T where foldMap f = foldT mempty $ \_ x tl tr bl br -> f x `mappend` tl `mappend` tr `mappend` bl `mappend` br instance Traversable T where traverse f = foldT (pure L) $ \p x tl tr bl br -> N p <$> f x <*> tl <*> tr <*> bl <*> br ---------------------------------------------------------------------- -- If you look at the previous two functions you see a similar pattern: -- they both combine an initial value: 'f x' and 'N p <$> f x' respectively -- with the childs using a combining function: 'mappend' and '<*>' respectively. -- My question is: can I abstract from that? -- It looks like I can using a function like: combineWith :: b -> (b -> a -> b) -> a -> a -> a -> a -> b n `combineWith` f = \tl tr bl br -> n `f` tl `f` tr `f` bl `f` br -- Now 'foldMap' becomes: instance Foldable T where foldMap f = foldT mempty $ \_ x -> f x `combineWith` mappend -- But 'traverse' won't typecheck: instance Traversable T where traverse f = foldT (pure L) $ \p x -> (N p <$> f x) `combineWith` (<*>) -- Is it possible to make 'combineWith' more general so that the -- previous typechecks (maybe using arbitrary-rank polymorphism but I -- don't see how)? ---------------------------------------------------------------------- Thanks, Bas van Dijk From allbery at ece.cmu.edu Wed Jul 2 10:06:08 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Jul 2 09:57:17 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <1214980352.8058.29.camel@jonathans-macbook> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> <1214979335.8058.21.camel@jonathans-macbook> <1BD0B579-BE0A-4B82-B98A-9C1C7CE2DC12@ece.cmu.edu> <1214980352.8058.29.camel@jonathans-macbook> Message-ID: <0BED8C27-EC0E-428F-992E-A945C46B3D3F@ece.cmu.edu> On 2008 Jul 2, at 2:32, Jonathan Cast wrote: > On Wed, 2008-07-02 at 02:17 -0400, Brandon S. Allbery KF8NH wrote: >> On 2008 Jul 2, at 2:15, Jonathan Cast wrote: >> >>> It seems as though it can return -1 if given non-sensical input. >>> But in >> >> The POSIX spec says it returns EINVAL in that case. > > Are you sure? A little googling picks up e.g. HP docs [1] that state Hm. I think the manuals I was looking at are ambiguous on the point, and I can't get at the actual standard right now. Probably best to assume -1/EINVAL is a possible return value, then. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From haskell at list.mightyreason.com Wed Jul 2 11:43:20 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Jul 2 11:34:46 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? In-Reply-To: <1214820294.3204.24.camel@otto.ehbuehl.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> Message-ID: <486BA218.6020806@list.mightyreason.com> > hen, the readFileOD could put the timestamp > of the read file in a Monad-local state and the writeFileOD could, if > the output is newer then all inputs listed in the state, skip the > writing and thus the unsafeInterleaveIO?ed file reads are skipped as > well, if they were not required for deciding the flow of the program. How is your system similar to make/Makefile or different to make/Makefile ? Are your actions more restricted? Are the semantics more imperative? Are the dependencies still explicit or are them implicit and inferred? -- Chris From sedillard at gmail.com Wed Jul 2 12:48:24 2008 From: sedillard at gmail.com (Scott Dillard) Date: Wed Jul 2 12:39:31 2008 Subject: [Haskell-cafe] Unboxed array of product type -> product type of unboxed arrays Message-ID: Hi, I'm trying to extended the standard unboxed array types and array classes to my own product types, for now let's just say (,). So if the proper MArray and IArray instances exist for e and f, then I can make an instance for (e,f). The actual type of that array, something like (UArray i e, UArray i f), would be given by an associated type. This is how the uvector library does it, but that library defines its own array primitives and classes. I'd like to reuse the standard ones if possible. The problem I keep running into is the kind of the array, * -> * -> *, or 'a i e'. The crucial type there is e, which is used to dispatch the instance to the proper associated type, so if e = (a,b) then the array type would be (UArray i a, UArray I b), and if e is (a,b,c) then (UArray i a, UArray i b, UArray i c). If IArray was instead expecting the array type to be 'a e i' I could maybe do something like this: class UArrClass e where data UArr e :: * -> * instance (IArray UArray e, IArray UArray f) => UArrClass (e,f) where data UArr (e,f) i = UArrPair (UArray i e) (UArray i f) But as it stands, I can't do that. The 'i' type parameter has to be bound as a parameter of UArrClass. So instead I tried this. class UArrClass i e where data UArr i e unsafeAt_ :: UArr i e -> Int -> e --mirror all IArray methods instance ( IArray UArray e , IArray UArray f , Ix i --needed for unsafeAt ) => UArrClass i (e,f) where newtype UArr i (e,f) = UArrPair (UArray i e) (UArray i f) unsafeAt_ (UArrPair ea fa) i = (unsafeAt ea i , unsafeAt fa i) and then the instance for IArray could be defined as follows, just a mapping from the methods of that class onto my own: instance ( IArray UArray e , IArray UArray f , UArrClass i (e,f) ) => IArray UArr (e,f) where unsafeAt = unsafeAt_ The problem I get now is from the 'Ix i' context of the IArray methods. The 'i' there is only mentioned in the context of the methods, not the class, so I have no 'handle' onto that 'i' that I can use to explicitly unify it with the 'i' mentioned in UArrClass. The compiler keeps complaining about rigid type variables. It would be great if I could leave that type variable unbound in my class, and only bind it in the methods, as IArray does, but as far as I can tell, I can't. I need to bind 'i' in my class because it's the first type-argument to the array type constructor, rather than the second. I don't care about the 'i', its the 'e' I'm after, but all applications of the associated type constructor need to be saturated. Can anyone see a way to do this? I understand there's about a million other ways to accomplish what I'm trying to do without IArray and MArray, but I'm just wondering if I should abandon those classes altogether, and use my own array classes, using something like uvector or unsafeIO/ForeignPtr. That seems to be trend. Thanks, Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/0d1d576c/attachment.htm From dons at galois.com Wed Jul 2 13:14:40 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 2 13:05:48 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <200807021626009536167@gmail.com> References: <87tzfehfgy.wl%jeremy@n-heptane.com> <200807021626009536167@gmail.com> Message-ID: <20080702171440.GC26461@liouville.galois.com> Could we start documenting this on the wiki ? It will be interesting to keep track of what we have tried, what attempts failed and why. -- Don leaveye.guo: > Thanks for sharing your experences. > > I just tried to port GHC 6.8.3 to my TI Davincci (c6446) board by > following the GHC Wiki Building/Porting page [1]. Both arm-compile > and cross-compile version have failed unfortunately. > > So, I turn to try compile an local GHC on linux. > It takes me so many time. > I can not finish building it before off work. > > [1] http://hackage.haskell.org/trac/ghc/wiki/Building/Porting#PortingGHCtoanewplatform > > ------------------ > L.Guo > 2008-07-02 > > ------------------------------------------------------------- > From: Jeremy Shaw > At: 2008-06-28 02:57:38 > Subject: Re: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) > > Cool! > > By cross-compilation, I assume you mean, a version of GHC which runs > on x86, but generates ARM assembly? Another option might be to use a > nintendo DS emulator which has been configured to support more RAM and > CPU power ? > > A true cross-compiler would be nice though, because it will run much > faster. GHC does have some support for cross-compilation, but in the > current implementation, it is mostly (entirely?) there for > bootstrapping. I have no idea how the ghc backend rewrite for 6.10 > will affect this. > > Hope this helps, > j. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Wed Jul 2 13:52:43 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Jul 2 13:41:53 2008 Subject: [Haskell-cafe] Unboxed array of product type -> product type of unboxed arrays In-Reply-To: References: Message-ID: <200807021952.43732.daniel.is.fischer@web.de> Am Mittwoch, 2. Juli 2008 18:48 schrieb Scott Dillard: > Hi, > > I'm trying to extended the standard unboxed array types and array classes > to my own product types, for now let's just say (,). So if the proper > MArray and IArray instances exist for e and f, then I can make an instance > for (e,f). The actual type of that array, something like (UArray i e, > UArray i f), would be given by an associated type. This is how the uvector > library does it, but that library defines its own array primitives and > classes. I'd like to reuse the standard ones if possible. > > The problem I keep running into is the kind of the array, * -> * -> *, or > 'a i e'. The crucial type there is e, which is used to dispatch the > instance to the proper associated type, so if e = (a,b) then the array type > would be (UArray i a, UArray I b), and if e is (a,b,c) then (UArray i a, > UArray i b, UArray i c). If IArray was instead expecting the array type to > be 'a e i' I could maybe do something like this: > > class UArrClass e where > data UArr e :: * -> * > instance (IArray UArray e, IArray UArray f) => UArrClass (e,f) where > data UArr (e,f) i = UArrPair (UArray i e) (UArray i f) > > But as it stands, I can't do that. The 'i' type parameter has to be bound > as a parameter of UArrClass. So instead I tried this. > > class UArrClass i e where > data UArr i e > unsafeAt_ :: UArr i e -> Int -> e > --mirror all IArray methods Perhaps class (Ix i) => UArrClass i e where ... would work? > > instance > ( IArray UArray e > , IArray UArray f > , Ix i --needed for unsafeAt > ) => UArrClass i (e,f) > where > newtype UArr i (e,f) = UArrPair (UArray i e) (UArray i f) > unsafeAt_ (UArrPair ea fa) i = (unsafeAt ea i , unsafeAt fa i) > > and then the instance for IArray could be defined as follows, just a > mapping from the methods of that class onto my own: > > instance > ( IArray UArray e > , IArray UArray f > , UArrClass i (e,f) > ) => IArray UArr (e,f) > where > unsafeAt = unsafeAt_ > > The problem I get now is from the 'Ix i' context of the IArray methods. The > 'i' there is only mentioned in the context of the methods, not the class, > so I have no 'handle' onto that 'i' that I can use to explicitly unify it > with the 'i' mentioned in UArrClass. The compiler keeps complaining about > rigid type variables. It would be great if I could leave that type variable > unbound in my class, and only bind it in the methods, as IArray does, but > as far as I can tell, I can't. I need to bind 'i' in my class because it's > the first type-argument to the array type constructor, rather than the > second. I don't care about the 'i', its the 'e' I'm after, but all > applications of the associated type constructor need to be saturated. > > Can anyone see a way to do this? I understand there's about a million other > ways to accomplish what I'm trying to do without IArray and MArray, but I'm > just wondering if I should abandon those classes altogether, and use my own > array classes, using something like uvector or unsafeIO/ForeignPtr. That > seems to be trend. > > Thanks, > Scott From sedillard at ucdavis.edu Wed Jul 2 13:56:44 2008 From: sedillard at ucdavis.edu (Scott Dillard) Date: Wed Jul 2 13:47:51 2008 Subject: [Haskell-cafe] Unboxed array of product type -> product type of unboxed arrays In-Reply-To: <200807021952.43732.daniel.is.fischer@web.de> References: <200807021952.43732.daniel.is.fischer@web.de> Message-ID: On Wed, Jul 2, 2008 at 11:52 AM, Daniel Fischer wrote: > > Perhaps > > class (Ix i) => UArrClass i e where ... > > would work? > > class Ix i => UArrClass i e where data UArr i e unsafeAt_ :: UArr i e -> Int -> e instance ( IArray UArray e , IArray UArray f , Ix i ) => UArrClass i (e,f) where newtype UArr i (e,f) = UArrPair (UArray i e) (UArray i f) unsafeAt_ (UArrPair ea fa) i = (unsafeAt ea i , unsafeAt fa i) instance ( IArray UArray e , IArray UArray f , UArrClass i (e,f) , Ix i ) => IArray UArr (e,f) where unsafeAt = unsafeAt_ test1 :: UArr Int (Int,Int) -> (Int,Int) test1 a = unsafeAt a 5 --this is line 77 -------------------- Array.hs:77:10: Ambiguous type variable `i' in the constraint: `Ix i' arising from a use of `unsafeAt' at Array.hs:77:10-21 Probable fix: add a type signature that fixes these type variable(s) I think the 'i' there is the one from the method context of IArray, class IArray a e where unsafeAt :: Ix i => a i e -> Int -> e But that 'i' does not escape to the class context, so I have no way to address it. I think I need to leave it free, but I can't do that with my associated type. Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/1bcf698a/attachment.htm From garious at gmail.com Wed Jul 2 14:16:18 2008 From: garious at gmail.com (Greg Fitzgerald) Date: Wed Jul 2 14:07:26 2008 Subject: [Haskell-cafe] GHC ARM Hackathon (Re: Haskell on ARM ) Message-ID: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> It may not be long before most of the computing world has gone mobile. CNET suggests the major players will be Qualcomm and Intel, where QC is more power-efficient, but Intel conveniently targets x86. June 29, 2008 7:30 PM PDT Qualcomm vs Intel: You decide<%20http://news.cnet.com/8301-13924_3-9979989-64.html> I'm a software engineer at Qualcomm with a desire to code more Haskell at work. This desire will only get stronger in coming years as multithreaded apps on mobile devices get more popular, and ways to write them reliably in traditional languages continue not to exist. Jeremy Shaw said: > Perhaps we should have some sort of GHC on the ARM hackathon > when 6.10 comes out Would anybody be interested in a "GHC on ARM Hackathon" in San Diego this year? When is 6.10 estimated to come out? Do we really need to wait for it? Jeremy Apthorp said: > it'll also require that I significantly strip down the runtime system, as > the current RTS won't fit in 4M Do you have a plan for how to do this? Maybe we can invite a Simon to teach us the innards of the RTS and help guide us? Thanks, Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/99c0cbf4/attachment-0001.htm From garious at gmail.com Wed Jul 2 14:17:56 2008 From: garious at gmail.com (Greg Fitzgerald) Date: Wed Jul 2 14:09:03 2008 Subject: [Haskell-cafe] Re: GHC ARM Hackathon (Re: Haskell on ARM ) In-Reply-To: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> References: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> Message-ID: <1f3dc80d0807021117l39f29640v7f1425cde0dcf4f6@mail.gmail.com> ...try that hyperlink again... Qualcomm vs Intel: You decide http://news.cnet.com/8301-13924_3-9979989-64.html On Wed, Jul 2, 2008 at 11:16 AM, Greg Fitzgerald wrote: > It may not be long before most of the computing world has gone mobile. > CNET suggests the major players will be Qualcomm and Intel, where QC is more > power-efficient, but Intel conveniently targets x86. > > June 29, 2008 7:30 PM PDT > Qualcomm vs Intel: You decide > > I'm a software engineer at Qualcomm with a desire to code more Haskell at > work. This desire will only get stronger in coming years as multithreaded > apps on mobile devices get more popular, and ways to write them reliably in > traditional languages continue not to exist. > > > Jeremy Shaw said: > > Perhaps we should have some sort of GHC on the ARM hackathon > > when 6.10 comes out > > Would anybody be interested in a "GHC on ARM Hackathon" in San Diego this > year? > > When is 6.10 estimated to come out? Do we really need to wait for it? > > > Jeremy Apthorp said: > > it'll also require that I significantly strip down the runtime system, as > > the current RTS won't fit in 4M > > Do you have a plan for how to do this? Maybe we can invite a Simon to > teach us the innards of the RTS and help guide us? > > > Thanks, > Greg > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/940de235/attachment.htm From jeremy at n-heptane.com Wed Jul 2 15:03:22 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Jul 2 14:52:04 2008 Subject: [Haskell-cafe] Re: GHC ARM Hackathon (Re: Haskell on ARM ) In-Reply-To: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> References: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> Message-ID: <87k5g4glc5.wl%jeremy@n-heptane.com> At Wed, 2 Jul 2008 11:16:18 -0700, Greg Fitzgerald wrote: > Would anybody be interested in a "GHC on ARM Hackathon" in San Diego this > year? Definitely. (Conveniently, I live in La Jolla). > When is 6.10 estimated to come out? Do we really need to wait for it? According to this Release plan, the plan to release 6.10 around ICFP2008. http://hackage.haskell.org/trac/ghc/wiki/Status/Releases We wouldn't need a final release to get started, just something where the back-end changes are in place and working. One important item from the release plan is: * GHC now uses libffi to implement parts of the FFI, replacing some of the home-grown and very architecture-specific code we had to do this. Amongst other benefits, this will ease the task of porting GHC in the future. And possibly: * Substantial changes to the back end are likely, now that John Dias is here as an intern. John Dias, Simon PJ, Norman Ramsey It sounds like the changes to libffi might already be in 6.9. So, maybe we can start now ? j. From Braden.Shepherdson at gmail.com Wed Jul 2 15:24:28 2008 From: Braden.Shepherdson at gmail.com (Braden Shepherdson) Date: Wed Jul 2 15:16:46 2008 Subject: [Haskell-cafe] Re: GHC ARM Hackathon (Re: Haskell on ARM ) In-Reply-To: <87k5g4glc5.wl%jeremy@n-heptane.com> References: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> <87k5g4glc5.wl%jeremy@n-heptane.com> Message-ID: Jeremy Shaw wrote: > At Wed, 2 Jul 2008 11:16:18 -0700, > Greg Fitzgerald wrote: > >> Would anybody be interested in a "GHC on ARM Hackathon" in San Diego this >> year? > > Definitely. (Conveniently, I live in La Jolla). > >> When is 6.10 estimated to come out? Do we really need to wait for it? > > According to this Release plan, the plan to release 6.10 around ICFP2008. > > http://hackage.haskell.org/trac/ghc/wiki/Status/Releases > > We wouldn't need a final release to get started, just something where > the back-end changes are in place and working. One important item from > the release plan is: > > * GHC now uses libffi to implement parts of the FFI, replacing some > of the home-grown and very architecture-specific code we had to do > this. Amongst other benefits, this will ease the task of porting > GHC in the future. > > And possibly: > > * Substantial changes to the back end are likely, now that John Dias > is here as an intern. John Dias, Simon PJ, Norman Ramsey > > It sounds like the changes to libffi might already be in 6.9. So, > maybe we can start now ? > > j. Unfortunately that's a bit of a reach for me; I live in southern Ontario and will be in New York City from September to December. So, I will likely be unable to attend, though I'll certainly see if I can pull it off. I'd be paying out of pocket for the travel, unfortunately. I definitely want to contribute what I can to this project, both because I want its result and because I want to learn more about GHC and the RTS. As to waiting for 6.10, I won't be able to contribute much work here before late August anyway, by which point much of 6.10 will likely be solidified in the HEAD 6.9. Certainly there are experiments and other parts of the project that can be worked on while waiting for the 6.10 release in late September. I'll post the results of any experiments and any thoughts in the GHC-on-ARM wiki. Notably, a page on what devices the developers have comes to mind. Braden Shepherdson shepheb From byorgey at seas.upenn.edu Wed Jul 2 15:42:31 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jul 2 15:33:39 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 75 - July 2, 2008 Message-ID: <20080702194231.GA9221@minus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080702 Issue 75 - July 02, 2008 --------------------------------------------------------------------------- Welcome to issue 75 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements Anglo Haskell 2008. Matthew Sackman [2]announced [3]AngloHaskell 2008, a gathering of all people Haskell-related from beginners, to seasoned hackers to academic giants. All and more are welcomed by large fuzzy green lambdas. The proposed dates and location are Friday the 8th and Saturday the 9th of August, at Imperial College, London. CFP - Special Issue of Fundamenta Informaticae on Dependently Typed Programming. Wouter Swierstra [4]announced a call for papers for a special issue of [5]Fundamenta Informaticae on [6]Dependently Typed Programming. The deadline for submissions is October 1. Gtk2Hs 0.9.13. Peter Gavin [7]announced the release of Gtk2Hs 0.9.13, including bindings for Gnome VFS and GStreamer, a new Gtk+ tutorial adapted by Hans van Thiel, cairo image stride support, and more. Hasim. Jochem Berndsen [8]announced Hasim, a [9]small project to create a library to do discrete event simulation in Haskell, using monads to define a domain-specific language for "actions" of a process. Galois move. Don Stewart [10]announced that Galois has completed the move of its data center. Expect speedier response times for hackage.haskell.org and darcs.haskell.org. Google Summer of Code Progress updates from participants in the 2008 [11]Google Summer of Code. Hoogle 4. Neil Mitchell (ndm) is working on [12]Hoogle 4. [13]This week, Neil worked on better Haddock database generation, lazy name searching, and a snazzy --info flag for Hoogle. Next up: type search! DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a [14]physics engine using [15]Data Parallel Haskell. [16]This week, he worked on implementing Mirtich's V-Clip algorithm for collision detection (and [17]got it to work), cabalized his project and added documentation. He also ran into an interesting QuickCheck puzzle. Generic tries. Jamie Brandon is working on a library for efficient maps using generalized tries. [18]This week, he created a generic framework for automatically running QuickCheck tests at a number of different types. This week he plans to synthesize the many suggestions from the [19]discussion on the libraries list into a stable API design. Language.C. Benedikt Huber (visq) is [20]working on Language.C, a standalone parser/pretty printer library for C99. [21]This week he worked on a better representation for declarators, and abstracted the notion of an InputStream over both String and ByteString, among other accomplishments. GHC plugins. Max Bolingbroke is working on dynamically loaded plugins for GHC. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a [22]make-like dependency analysis framework for Cabal. GHC API. Thomas Schilling (nominolo) is working on [23]improvements to the GHC API. Officials at HWN headquarters have released a statement reversing their previous position regarding the existence of Thomas, citing regrettably faulty information to explain their previous misapprehensions. Expect to hear more from Thomas soon, now that he has finished graduating and moving. Libraries Proposals and extensions to the [24]standard libraries. GetOpt formatting improvements. Duncan Coutts [25]proposed some modifications to make the output of the System.Console.GetOpt library more readable, resulting in quite a bit of discussion. HughesPJ improvements. Benedikt Huber [26]proposed a patch with some bug fixes, performance improvements, and QuickCheck test suite for the Text.PrettyPrint.HughesPJ pretty-printing library. Discussion A Monad for on-demand file generation?. Joachim Breitner [27]asked about a monad for transparently tracking files which may need to be regenerated due to dependencies, leading to an interesting discussion of incremental computation, strict vs. lazy I/O, and other issues. New mailing list proposal: Haskell-Edu. Benjamin L. Russell sent out a message [28]proposing a new mailing list hosted at haskell.org, "Haskell-Edu: The Haskell Educational Mailing List." The new mailing list would be guided by the principle that Haskell is useful not just in research, but also in teaching programming as part of a liberal arts education. Comments and discussion welcomed. Learning GADT types to simulate dependent types. Paul Johnson is trying to use GADTs to simulate aspects of a dependently typed system, and [29]asks for help improving his Oleg rating. Call graph tool?. C.M.Brown [30]asked whether there is a tool for visualizing the call graph for a collection of source files, leading to a discussion of various tools. Jobs Formal methods and automated reasoning at Rockwell Collins. Janis Voigtlaender [31]passed on an opening for a Senior Systems Engineer at [32]Rockwell Collins. The opening is for a computer scientist or engineer to develop and apply automated analysis to computer systems and to pursue research in formal methods and automated reasoning. Contact: rmgatto at rockwellcollins.com. Blog noise [33]Haskell news from the [34]blogosphere. * Roman Cheplyaka: [35]V-Clip seems to work!. * Benedikt Huber: [36]Last week on Language.C (1). An update on Benedikt's Google Summer of Code project. * Jamie Brandon: [37]Week 3 progress. An update on Jamie's Google Summer of Code project. * Philip Wadler: [38]Welcome to Scotland, Neil, Patricia, and Conor!. * >>> codders: [39]Coding style, Haskell. codders likes how Real World Haskell gives some hints about Haskell coding style and culture in addition to teaching the language itself. * >>> zoo: [40]Haskell plug-in for Eclipse. zoo explains how to install the [41]Haskell Eclipse plugin. * Dan Piponi (sigfpe): [42]A blessed man's formula for holey containers. Dan descries an enlightening derivation of the [43]combinatorial form of Faa di Bruno's formula from the perspective of derivatives of types. * Roman Cheplyaka: [44]Status report: week 5. An update on Roman's Google Summer of Code project. * >>> codders: [45]More Haskell fun. * >>> Marco Tulio Gontijo e Silva: [46]Rank 2 Types. Marco describes a practical use for GHC's rank-2 types. * Edward Kmett: [47]Memoizing Context. * >>> JP Moresmau: [48]Deserializing JSON to Haskell Data objects. * >>> codders: [49]Getting started with Haskell... still. codders is learning Haskell by reading the beta version of [50]Real World Haskell. * Neil Mitchell: [51]GSoC Hoogle: Week 5. * Arnar: [52]Parsing JSON with Haskell. A nice example of using [53]Parsec to parse JSON. * Thomas Hartman: [54]HAppS Tutorial. Quotes of the Week * quicksilver: [on what OS sjanssen uses] sjanssen runs haskell programs in his head; much more efficient. * EvilTerran: "We were somewhere around Barstow, on the edge of the desert, when the phantom types began to take hold." * audreyt: o/~ the phantom of the typesystem is here / inside my mind! o/~ * dmwit: No, no, no, ($) isn't right-assoc, it's wrong-assoc. * solrize: this would never happen in haskell: i sent in a search query to a certain python program, but left the query field empty, expecting to get back an error message. instead it found a bunch of books written by the diet doctor Gary Null. * heatsink: We're all inside do-blocks in the IO monad if you think about it. * djsiegel: [upon having a question answered by dons] oh my, I'm talking to the man * mar77a: the first computers were big because they were actually cupboards with fast humans inside About the Haskell Weekly News New editions are posted to [55]the Haskell mailing list as well as to [56]the Haskell Sequence and [57]Planet Haskell. [58]RSS is also available, and headlines appear on [59]haskell.org. Headlines are available as [60]PDF. To help create new editions of this newsletter, please see the information on [61]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [62]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.general/16272 3. http://www.haskell.org/haskellwiki/AngloHaskell/2008 4. http://article.gmane.org/gmane.comp.lang.haskell.general/16269 5. http://fi.mimuw.edu.pl/ 6. http://sneezy.cs.nott.ac.uk/darcs/DTP08/journal.html 7. http://www.haskell.org//pipermail/haskell-cafe/2008-June/044805.html 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41881 9. http://huygens.functor.nl/hasim 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41847 11. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 12. http://code.haskell.org/hoogle/ 13. http://neilmitchell.blogspot.com/2008/06/gsoc-hoogle-week-5.html 14. http://haskell.org/haskellwiki/Hpysics 15. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 16. http://physics-dph.blogspot.com/2008/06/status-report-week-5.html 17. http://physics-dph.blogspot.com/2008/07/v-clip-seems-to-work.html 18. http://jamiiecb.blogspot.com/2008/06/week-3-progress.html 19. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9259 20. http://www.sivity.net/projects/language.c/wiki/ 21. http://hsbene.blogspot.com/2008/07/last-week-on-languagec-1.html 22. http://code.haskell.org/~Saizan/cabal 23. http://hackage.haskell.org/trac/ghc/wiki/GhcApiStatus 24. http://haskell.org/haskellwiki/Library_submissions 25. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9415 26. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9377 27. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41868 28. http://thread.gmane.org/gmane.comp.lang.haskell.general/16271 29. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41848 30. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41786 31. http://article.gmane.org/gmane.comp.lang.haskell.general/16266 32. http://www.rockwellcollins.com/ 33. http://planet.haskell.org/ 34. http://haskell.org/haskellwiki/Blog_articles 35. http://physics-dph.blogspot.com/2008/07/v-clip-seems-to-work.html 36. http://hsbene.blogspot.com/2008/07/last-week-on-languagec-1.html 37. http://jamiiecb.blogspot.com/2008/06/week-3-progress.html 38. http://wadler.blogspot.com/2008/06/welcome-to-scotland-neil-patricia-and.html 39. http://talkingcode.co.uk/2008/06/30/coding-style-haskell/ 40. http://imonad.com/blog/2008/06/haskell-plug-in-for-eclipse/ 41. http://sourceforge.net/projects/eclipsefp/ 42. http://sigfpe.blogspot.com/2008/06/blessed-mans-formula-for-holey.html 43. http://en.wikipedia.org/wiki/Fa%C3%A0_di_Bruno's_formula#Combinatorial_form 44. http://physics-dph.blogspot.com/2008/06/status-report-week-5.html 45. http://talkingcode.co.uk/2008/06/28/more-haskell-fun/ 46. http://marcotmarcot.blogspot.com/2008/06/rank-2-types.html 47. http://comonad.com/reader/2008/memoizing-context/ 48. http://jpmoresmau.blogspot.com/2008/06/deserializing-json-to-haskell-data.html 49. http://talkingcode.co.uk/2008/06/27/getting-started-with-haskell-still/ 50. http://www.realworldhaskell.org/ 51. http://neilmitchell.blogspot.com/2008/06/gsoc-hoogle-week-5.html 52. http://www.hvergi.net/2008/06/parsing-json-with-haskell/ 53. http://legacy.cs.uu.nl/daan/parsec.html 54. http://ramblings.tumblr.com/post/39794244/happs-tutorial 55. http://www.haskell.org/mailman/listinfo/haskell 56. http://sequence.complete.org/ 57. http://planet.haskell.org/ 58. http://sequence.complete.org/node/feed 59. http://haskell.org/ 60. http://code.haskell.org/~byorgey/code/hwn/archives/20080702.pdf 61. http://haskell.org/haskellwiki/HWN 62. http://code.haskell.org/~byorgey/code/hwn/ From vigalchin at gmail.com Wed Jul 2 17:10:09 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jul 2 17:01:18 2008 Subject: [Haskell-cafe] database 101 question Message-ID: <5ae4f2ba0807021410u6749a33fl4cef7204c71108a1@mail.gmail.com> Hello, I have installed the mysql server (mysqld) on my Ubuntu machine. What are the Haskell libraries/components that I will need to write a mysql client?? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/dc5019ba/attachment.htm From martindemello at gmail.com Wed Jul 2 17:12:54 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Jul 2 17:04:00 2008 Subject: [Haskell-cafe] calling setWMHints (expects a CInt, I have an Int) Message-ID: Could someone give me an example of calling setWMHints from Graphics.X11.Xlib.Extras? The signature is setWMHints :: Display -> Window -> WMHints -> IO Status and WMHints is defined as data WMHints = WMHints { wmh_flags :: CLong wmh_input :: Bool wmh_initial_state :: CInt wmh_icon_pixmap :: Pixmap wmh_icon_window :: Window wmh_icon_x :: CInt wmh_icon_y :: CInt wmh_icon_mask :: Pixmap wmh_window_group :: XID } I can't figure out how to convert an Int to a CInt to construct the WMHints martin From ndmitchell at gmail.com Wed Jul 2 17:16:09 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jul 2 17:07:15 2008 Subject: [Haskell-cafe] calling setWMHints (expects a CInt, I have an Int) In-Reply-To: References: Message-ID: <404396ef0807021416v6c7d5613t8a4da4347a1234b@mail.gmail.com> Hi Martin, > I can't figure out how to convert an Int to a CInt to construct the WMHints Ask Hoogle: http://haskell.org/hoogle/?q=Int+-%3E+CInt And Hoogle says: toEnum, fromIntegral Thanks Neil From martindemello at gmail.com Wed Jul 2 17:17:28 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Jul 2 17:08:38 2008 Subject: [Haskell-cafe] calling setWMHints (expects a CInt, I have an Int) In-Reply-To: <404396ef0807021416v6c7d5613t8a4da4347a1234b@mail.gmail.com> References: <404396ef0807021416v6c7d5613t8a4da4347a1234b@mail.gmail.com> Message-ID: On Wed, Jul 2, 2008 at 2:16 PM, Neil Mitchell wrote: > Hi Martin, > >> I can't figure out how to convert an Int to a CInt to construct the WMHints > > Ask Hoogle: > > http://haskell.org/hoogle/?q=Int+-%3E+CInt Nice!!!! > And Hoogle says: > > toEnum, fromIntegral thanks a lot :) martin From dons at galois.com Wed Jul 2 18:03:08 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 2 17:54:14 2008 Subject: [Haskell-cafe] database 101 question In-Reply-To: <5ae4f2ba0807021410u6749a33fl4cef7204c71108a1@mail.gmail.com> References: <5ae4f2ba0807021410u6749a33fl4cef7204c71108a1@mail.gmail.com> Message-ID: <20080702220308.GB7303@liouville.galois.com> vigalchin: > Hello, > > I have installed the mysql server (mysqld) on my Ubuntu machine. What > are the Haskell libraries/components that I will need to write a mysql > client?? Check on hackage.haskell.org under the 'database' category. -- Don From vigalchin at gmail.com Wed Jul 2 18:10:27 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jul 2 18:01:32 2008 Subject: [Haskell-cafe] database 101 question In-Reply-To: <20080702220308.GB7303@liouville.galois.com> References: <5ae4f2ba0807021410u6749a33fl4cef7204c71108a1@mail.gmail.com> <20080702220308.GB7303@liouville.galois.com> Message-ID: <5ae4f2ba0807021510q7141c936qf5870029fdc3203f@mail.gmail.com> Hi Don, I know where to look but I am knew to database architecture. I know there is a driver (whatever that is ... I write device drivers but this is obviously different), backend ??? My question is more generic about what pieces I would need for evenr sqlite3 for example. Vasil On Wed, Jul 2, 2008 at 5:03 PM, Don Stewart wrote: > vigalchin: > > Hello, > > > > I have installed the mysql server (mysqld) on my Ubuntu machine. > What > > are the Haskell libraries/components that I will need to write a mysql > > client?? > > Check on hackage.haskell.org under the 'database' category. > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/2e74d4c7/attachment.htm From nornagon at gmail.com Wed Jul 2 19:07:17 2008 From: nornagon at gmail.com (Jeremy Apthorp) Date: Wed Jul 2 18:58:23 2008 Subject: [Haskell-cafe] GHC ARM Hackathon (Re: Haskell on ARM ) In-Reply-To: <14d615330807021606k87cf1er32711b3581f4528f@mail.gmail.com> References: <1f3dc80d0807021116p72c266bak883857924b91c0ba@mail.gmail.com> <14d615330807021606k87cf1er32711b3581f4528f@mail.gmail.com> Message-ID: <14d615330807021607m241b6796pd97b40dc61edde73@mail.gmail.com> 2008/7/3 Greg Fitzgerald : >> Perhaps we should have some sort of GHC on the ARM hackathon >> when 6.10 comes out > > Would anybody be interested in a "GHC on ARM Hackathon" in San Diego this > year? I'd be interested, but I live in Sydney, Australia. San Diego's a bit of a stretch :) > Jeremy Apthorp said: >> it'll also require that I significantly strip down the runtime system, as >> the current RTS won't fit in 4M > > Do you have a plan for how to do this? Maybe we can invite a Simon to teach > us the innards of the RTS and help guide us? I've discussed it briefly with chak (who'll be supervising the project), but as I said, I haven't looked too deeply into the code yet. Jeremy -- - Jem From cotton at alum.mit.edu Wed Jul 2 21:42:58 2008 From: cotton at alum.mit.edu (Cotton Seed) Date: Wed Jul 2 21:34:04 2008 Subject: [Haskell-cafe] type classes Message-ID: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> Hi everyone, I'm working on a computational algebra program and I've run into a problem. In my program, I have types for instances of algebraic objects, e.g. ZModN for modular integers, and types for the objects themselves, e.g. ZModNTy for the ring of modular integers. Now, I want to subclass ZModNTy from something like class RingTy a b where order :: a -> Integer units :: a -> [b] where `a' represents algebraic object, and `b' the type of instances of that object. I want an instance instance RingTy ZModNTy ZModN where ... but then code that only uses order fails with errors like No instance for (RingTy ZModNTy b) arising from a use of `order' at Test2.hs:16:8-15 since there is no constraint on the second type variable. I think what I really want is class RingTy a where order :: a b -> Integer units :: a b -> [b] but this doesn't work either since ZModNTy is not parametric in its type like, say, `Polynomial a' is. Is this a common problem? Is there a standard way to handle it? Thank you for your attention, Cotton -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/cb7a03e3/attachment.htm From dan.doel at gmail.com Wed Jul 2 21:57:22 2008 From: dan.doel at gmail.com (Dan Doel) Date: Wed Jul 2 21:48:33 2008 Subject: [Haskell-cafe] type classes In-Reply-To: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> Message-ID: <200807022157.23318.dan.doel@gmail.com> On Wednesday 02 July 2008, Cotton Seed wrote: > Hi everyone, > > I'm working on a computational algebra program and I've run into a problem. > In my program, I have types for instances of algebraic objects, e.g. ZModN > for modular integers, and types for the objects themselves, e.g. ZModNTy > for the ring of modular integers. > > Now, I want to subclass ZModNTy from something like > > class RingTy a b where > order :: a -> Integer > units :: a -> [b] > > where `a' represents algebraic object, and `b' the type of instances of > that object. I want an instance > > instance RingTy ZModNTy ZModN where ... > > but then code that only uses order fails with errors like > > No instance for (RingTy ZModNTy b) > arising from a use of `order' at Test2.hs:16:8-15 > > since there is no constraint on the second type variable. > > I think what I really want is > > class RingTy a where > order :: a b -> Integer > units :: a b -> [b] > > but this doesn't work either since ZModNTy is not parametric in its type > like, say, `Polynomial a' is. > > Is this a common problem? Is there a standard way to handle it? Correct me if I'm wrong, but wouldn't the a uniquely determine the b? In that case, you'd probably want a functional dependency: class RingTy a b | a -> b where order :: a -> Integer units :: a -> [b] This solves the problem with order, because with multi-parameter type classes, all the variables should be determined for a use of a method. Since b is not involved with order, it could be anything, so it's rather ambiguous. The functional dependency solves this by uniquely determined b from a, so order is no longer ambiguous. Alternately, with the new type families, this can become: class RingTy a where type RingElem a :: * order :: a -> Integer units :: a -> [RingElem a] Or something along those lines. Hope that helps. -- Dan From cotton at alum.mit.edu Wed Jul 2 22:13:32 2008 From: cotton at alum.mit.edu (Cotton Seed) Date: Wed Jul 2 22:04:39 2008 Subject: [Haskell-cafe] type classes In-Reply-To: <200807022157.23318.dan.doel@gmail.com> References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> <200807022157.23318.dan.doel@gmail.com> Message-ID: <195938a50807021913l222114f3r3e4fc255806448fa@mail.gmail.com> Hi Dan, Thanks! This is exactly what I was looking for. Cotton On Wed, Jul 2, 2008 at 9:57 PM, Dan Doel wrote: > > On Wednesday 02 July 2008, Cotton Seed wrote: > > Hi everyone, > > > > I'm working on a computational algebra program and I've run into a problem. > > In my program, I have types for instances of algebraic objects, e.g. ZModN > > for modular integers, and types for the objects themselves, e.g. ZModNTy > > for the ring of modular integers. > > > > Now, I want to subclass ZModNTy from something like > > > > class RingTy a b where > > order :: a -> Integer > > units :: a -> [b] > > > > where `a' represents algebraic object, and `b' the type of instances of > > that object. I want an instance > > > > instance RingTy ZModNTy ZModN where ... > > > > but then code that only uses order fails with errors like > > > > No instance for (RingTy ZModNTy b) > > arising from a use of `order' at Test2.hs:16:8-15 > > > > since there is no constraint on the second type variable. > > > > I think what I really want is > > > > class RingTy a where > > order :: a b -> Integer > > units :: a b -> [b] > > > > but this doesn't work either since ZModNTy is not parametric in its type > > like, say, `Polynomial a' is. > > > > Is this a common problem? Is there a standard way to handle it? > > Correct me if I'm wrong, but wouldn't the a uniquely determine the b? In that > case, you'd probably want a functional dependency: > > class RingTy a b | a -> b where > order :: a -> Integer > units :: a -> [b] > > This solves the problem with order, because with multi-parameter type classes, > all the variables should be determined for a use of a method. Since b is not > involved with order, it could be anything, so it's rather ambiguous. The > functional dependency solves this by uniquely determined b from a, so order > is no longer ambiguous. > > Alternately, with the new type families, this can become: > > class RingTy a where > type RingElem a :: * > order :: a -> Integer > units :: a -> [RingElem a] > > Or something along those lines. > > Hope that helps. > -- Dan From vigalchin at gmail.com Thu Jul 3 00:49:39 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jul 3 00:40:45 2008 Subject: [Haskell-cafe] Re: POSIX AIO (asych I/O) ... In-Reply-To: <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> References: <5ae4f2ba0807010042wc292067h7f3ee000e37dc532@mail.gmail.com> <5ae4f2ba0807012242j5c835f10w3ecae9861c302015@mail.gmail.com> <4C055B99-DF06-4E55-944D-48B56122D60F@ece.cmu.edu> Message-ID: <5ae4f2ba0807022149x77c9eeb4r668402033326afaf@mail.gmail.com> Hi Brandon, Most of what you say makes sense. However, at some places in your narrative aren't you mixing up my aioError and aioReturn?(or aio_error and aio_return, respectively). E.g. aioReturn should return the byte count and not errno? If you want to stick close to the C interface: aioReturn :: AIOCB -> IO (AIOCB, Errno) aioReturn aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb err <- c_aio_return p_aiocb aiocb <- peek p_aiocb return (aiocb, Errno err) Vasili On Wed, Jul 2, 2008 at 1:07 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On 2008 Jul 2, at 1:42, Galchin, Vasili wrote: > > errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) > > "ghc" thinks that "Errno" should be an instance of "Num": > > System/Posix/Aio.hsc:117:15: > No instance for (Num Errno) > > > I expect so it can compare it to -1(throwErrnoIfMinusOne). But if the > return value is actually an errno and not -1 to indicate error (which it is > if I read the manpage correctly), you don't want throwErrnoIfMinus1 anyway; > I suspect you want to wrap the return value of c_aio_return (which should be > IO CInt) in an Errno constructor, then use errnoToIOError if you really want > to raise an IOError. > > (What were you expecting for "count"? I see none, just an errno.) > > Note that it *never* returns -1; it returns 0 for successful completion for > the aiocb, EINPROGRESS if it's still working, and the appropriate errno if > it failed. > > You might want to decide if you want to use the aio_return style interface > or something more Haskell-ish before designing this part of the API. If you > want to stick close to the C interface: > > aioReturn :: AIOCB -> IO (AIOCB, Errno) > aioReturn aiocb = do > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb > err <- c_aio_return p_aiocb > aiocb <- peek p_aiocb > return (aiocb, Errno err) > I'd actually consider something more Haskellish, e.g. a variant of StateT > IO where the state is the aiocb and errno, the errno initialized to > eINPROGRESS and set by aioReturn and aioError (and once aioReturn is called, > it can't be called again so return the cached value if needed). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080702/d18dc3a1/attachment.htm From lemming at henning-thielemann.de Thu Jul 3 01:19:25 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 3 01:10:31 2008 Subject: [Haskell-cafe] database 101 question In-Reply-To: <5ae4f2ba0807021510q7141c936qf5870029fdc3203f@mail.gmail.com> References: <5ae4f2ba0807021410u6749a33fl4cef7204c71108a1@mail.gmail.com> <20080702220308.GB7303@liouville.galois.com> <5ae4f2ba0807021510q7141c936qf5870029fdc3203f@mail.gmail.com> Message-ID: On Wed, 2 Jul 2008, Galchin, Vasili wrote: > Hi Don, > > I know where to look but I am knew to database architecture. I know > there is a driver (whatever that is ... I write device drivers but this is > obviously different), backend ??? My question is more generic about what > pieces I would need for evenr sqlite3 for example. As far as I understand you need either Takusen, HSQL or HDBC for database access. Additionally you need some of the driver packages for the corresponding main package. Due to package dependencies it should be enough to cabal install hsql-sqlite3 or cabal install HDBC-sqlite3 With these packages you have to write your queries in SQL. If you want a nice monadic interface you may cabal install haskelldb-hdbc-sqlite3 or cabal install haskelldb-hsql-sqlite3 From lemming at henning-thielemann.de Thu Jul 3 01:22:36 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 3 01:13:42 2008 Subject: [Haskell-cafe] type classes In-Reply-To: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> Message-ID: On Wed, 2 Jul 2008, Cotton Seed wrote: > Hi everyone, > > I'm working on a computational algebra program and I've run into a problem. > In my program, I have types for instances of algebraic objects, e.g. ZModN > for modular integers, and types for the objects themselves, e.g. ZModNTy for > the ring of modular integers. Maybe you are also interested in: http://darcs.haskell.org/numericprelude/src/Number/ResidueClass.hs http://darcs.haskell.org/numericprelude/src/Number/ResidueClass/ From dougal at dougalstanton.net Thu Jul 3 06:00:43 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Thu Jul 3 05:51:50 2008 Subject: [Haskell-cafe] Alternatives to convoluted record syntax Message-ID: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> Hi Haskellers, This is a style question, as my program works fine but looks really ugly and can be confusing to maintain. I take options from the command line using GetOpt and hand back this structure for later use. > data Opts = Opts > { query :: Query > , queryLimit :: Maybe Limit > , disabledOnly :: Bool > } deriving Show Here's a snippet from the parser for one option (others omitted for clarity): > options :: [OptDescr (Opts -> Opts)] > options = > [ Option "b" ["bus"] (ReqArg busNum "NUM") "Bus number" > , ... > ] > where busNum n os = let b = (query os) { queryBusNumber = Just n } > in if isBusId n then os { query = b } else os Variations on that ugliness are repeated four times for other fields. Is there an alternative way to change the value of nested fields? Thanks, Dougal. -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From lemming at henning-thielemann.de Thu Jul 3 06:13:26 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 3 06:04:33 2008 Subject: [Haskell-cafe] Alternatives to convoluted record syntax In-Reply-To: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> References: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> Message-ID: On Thu, 3 Jul 2008, Dougal Stanton wrote: > Here's a snippet from the parser for one option (others omitted for clarity): > >> options :: [OptDescr (Opts -> Opts)] >> options = >> [ Option "b" ["bus"] (ReqArg busNum "NUM") "Bus number" >> , ... >> ] >> where busNum n os = let b = (query os) { queryBusNumber = Just n } >> in if isBusId n then os { query = b } else os > > Variations on that ugliness are repeated four times for other fields. > Is there an alternative way to change the value of nested fields? For access to nested record fields I implemented the record-access package. Unfortunately the field accessors must still be written manually. http://darcs.haskell.org/record-access/src/Data/Accessor/Example.hs E.g.: infix2 :: ((Char, Int), String) infix2 = (('b',7),"hallo")$%first^:second^=10 (second^=10) replaces the second member of pair with a value. (^:) applies that change to the outer record (again a pair). ($%) applies the modifier (first^:second^=10) to a concrete pair. From davida at f2s.com Thu Jul 3 07:01:45 2008 From: davida at f2s.com (DavidA) Date: Thu Jul 3 06:56:07 2008 Subject: [Haskell-cafe] Re: type classes References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> Message-ID: Slightly off-topic - but I'm curious to know why you want objects representing the structures as well as the elements - what will they be used for? From dougal at dougalstanton.net Thu Jul 3 07:16:23 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Thu Jul 3 07:07:26 2008 Subject: [Haskell-cafe] Alternatives to convoluted record syntax In-Reply-To: References: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> Message-ID: <2d3641330807030416y2f981051i8ae69d105aef52b@mail.gmail.com> On Thu, Jul 3, 2008 at 11:13 AM, Henning Thielemann wrote: > > infix2 :: ((Char, Int), String) > infix2 = > (('b',7),"hallo")$%first^:second^=10 > > (second^=10) replaces the second member of pair with a value. > (^:) applies that change to the outer record (again a pair). > ($%) applies the modifier (first^:second^=10) to a concrete pair. > Hmm! Thanks for the pointer, but I'm not sure that would really clear things up much. It seems this may just be a wart I'll have to put up with. Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From scook0 at gmail.com Thu Jul 3 07:48:57 2008 From: scook0 at gmail.com (Stuart Cook) Date: Thu Jul 3 07:40:01 2008 Subject: [Haskell-cafe] Alternatives to convoluted record syntax In-Reply-To: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> References: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> Message-ID: <49b351060807030448x11b787fayc2e24e21ae456723@mail.gmail.com> On Thu, Jul 3, 2008 at 8:00 PM, Dougal Stanton wrote: > Here's a snippet from the parser for one option (others omitted for clarity): > >> options :: [OptDescr (Opts -> Opts)] >> options = >> [ Option "b" ["bus"] (ReqArg busNum "NUM") "Bus number" >> , ... >> ] >> where busNum n os = let b = (query os) { queryBusNumber = Just n } >> in if isBusId n then os { query = b } else os > > Variations on that ugliness are repeated four times for other fields. > Is there an alternative way to change the value of nested fields? Here's one suggestion, though whether it's less ugly is questionable. Start with these two handy TH functions: -- \f x -> x { field = f (field x) } alter :: Name -> Q Exp alter field = do f <- newName "f" x <- newName "x" lamE [varP f, varP x] $ recUpdE (varE x) [return (field, AppE (VarE f) (AppE (VarE field) (VarE x)))] -- \a x -> x { field = a } set :: Name -> Q Exp set field = do a <- newName "a" x <- newName "x" lamE [varP a, varP x] $ recUpdE (varE x) [return (field, VarE a)] Now define busNum as follows: busNum n | (isBusId n) = $(modify 'query) ($(set 'queryBusNumber) (Just n)) | otherwise = id The TH brackets and quotes make it look rather cumbersome, but I think the intent at least becomes clearer. Stuart From Ben.Lippmeier at anu.edu.au Thu Jul 3 08:12:30 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Thu Jul 3 08:03:45 2008 Subject: [Haskell-cafe] ANN: The Disciplined Disciple Compiler - alpha 1.1 Message-ID: Hi All, I'm pleased to announce version 1.1 of the Disciplined Disciple Compiler (DDC) Disciple is an explicitly lazy dialect of Haskell which supports: - first class destructive update of arbitrary data. - computational effects without the need for state monads. - type directed field projections. - allied functional goodness. All this and more through the magic of effect typing. New in this version: - support for x86_64 under linux and darwin, thanks to Jared Putnam. - the -make flag now does a full dependency driven build/rebuild. - constructor classes. - irrefutable patterns. - partial support for monadic do notation. - an unboxed Bool# type with true# and false# literals. - field projection punning. - lots more example code. Project page with full release notes and download at: http://www.haskell.org/haskellwiki/DDC DDC: more than lambdas. Ben. From cotton at alum.mit.edu Thu Jul 3 08:15:31 2008 From: cotton at alum.mit.edu (Cotton Seed) Date: Thu Jul 3 08:06:36 2008 Subject: [Haskell-cafe] Re: type classes In-Reply-To: References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> Message-ID: <195938a50807030515s1909bc14o5ea9423c353a7f45@mail.gmail.com> A number of operations -- like order above -- are conceptually connected not to the elements but to the structures themselves. Here is the outline of a more complicated example. I also have a vector space class class VectorSpaceTy a b | a - > b where dimension :: a -> Integer basis :: (Field c) => a -> [b c] where `b' is a vector space over the field `c'. Suppose I have a haskell function `f :: a c -> b c' representing a linear transformation between (elements) of two vector spaces. I can write transformationMatrix :: VectorSpaceTy ta a -> VectorSpaceTy tb b -> (a c -> b c) -> Matrix c to compute the matrix of the linear transformation. Another alternative is something like ModuleBasis from the numeric prelude: class (Module.C a v) => C a v where {- | basis of the module with respect to the scalar type, the result must be independent of argument, 'Prelude.undefined' should suffice. -} basis :: a -> [v] To compute the basis (for type reasons?) basis needs an (ignored) element of the vector space, but this seems ugly to me. In my case, the vector space is the space of modular forms. Computing a basis requires a tremendous amount of work. I only want to do it once. The ...Ty object gives me a place to stash the result. How would you do this? Cotton On Thu, Jul 3, 2008 at 7:01 AM, DavidA wrote: > Slightly off-topic - but I'm curious to know why you want objects representing > the structures as well as the elements - what will they be used for? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From cotton at alum.mit.edu Thu Jul 3 08:32:50 2008 From: cotton at alum.mit.edu (Cotton Seed) Date: Thu Jul 3 08:24:00 2008 Subject: [Haskell-cafe] type classes In-Reply-To: References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> Message-ID: <195938a50807030532h31d12acaid1728928a9e45605@mail.gmail.com> Hi Henning, The numeric prelude was inspiration for a lot of my design. Part of the reason I didn't use it was because one of my goals is to learn Haskell better, and I wanted to grapple with these design decisions myself. I decided, like IsZeroTestable in the numeric prelude, to make zero/one separate type classes. Thus, I have class AbelianGroup a where (+) :: a -> a -> a negate :: a -> a class HasZero a where zero :: a so ZModN is an instance of AbelianGroup but not HasZero. Most functions that "want" a zero have two forms, for example, sum :: (HasZero a, AbelianGroup a) => [a] -> a sumWithZero :: (AbelianGroup a) => a -> [a] -> a although I may eventually require all types to have a corresponding Ty class and change this to sumWithTy :: (AbelianGroup a) => AblieanGroupTy a -> [a] -> a Matrices are another example that fits this model. Numeric prelude defines zero/one to be 1x1 matrices, but asserts dimensions match in various operations, so they don't actually seem usable. Cotton On Thu, Jul 3, 2008 at 1:22 AM, Henning Thielemann wrote: > > On Wed, 2 Jul 2008, Cotton Seed wrote: > >> Hi everyone, >> >> I'm working on a computational algebra program and I've run into a >> problem. >> In my program, I have types for instances of algebraic objects, e.g. ZModN >> for modular integers, and types for the objects themselves, e.g. ZModNTy >> for >> the ring of modular integers. > > Maybe you are also interested in: > http://darcs.haskell.org/numericprelude/src/Number/ResidueClass.hs > http://darcs.haskell.org/numericprelude/src/Number/ResidueClass/ > > From nfjinjing at gmail.com Thu Jul 3 09:02:28 2008 From: nfjinjing at gmail.com (jinjing) Date: Thu Jul 3 08:53:33 2008 Subject: [Haskell-cafe] parallel_map_reduce, in easy one liner mod Message-ID: <81ea7d400807030602la9633bve738a4115f93bd62@mail.gmail.com> Hi haskellers, So.. the type says it all p_map_reduce :: ([a] -> b) -> (b -> b -> b) -> [a] -> b so the idea is to write your computation extensive funciton as a map_reduce function, simplest example: sum ( can be seen as map id then reduce (+) ) then instead of calling: sum xs just call: p_map_reduce sum (+) xs the function in the background will split the xs into 16 parts, and use all your cores to process the computation. Enless the computation from the map_reduce function is too trivial or the list is too small, it should bump all your cores to 100% usage, and linearly increase overall performance. You can customize the number of parts by calling the helper function p_map_reduce_to I hope this can be useful to someone besides me :) here is the code warning: i'm using a very annoying coding style, by redefining the (.) operater to be reverse application. Please forgive me and metally transform the order, or just pretend you are reading Java / Python / Ruby or whatever :) module Main where import Data.List import Control.Parallel import Prelude hiding ((.)) -- for my poor oo mind (.) :: a -> (a -> b) -> b a . f = f a infixl 9 . (...) :: (b -> c) -> (a -> b) -> a -> c (...) f g x = f (g x) -- helpers reduce = foldl1 in_group_of n [] = [] in_group_of n xs = xs.take(n) : xs.drop(n).in_group_of(n) split_to n xs = xs.in_group_of(size) where size = if xs.length < n then n else xs.length `div` n -- parallel processing p_eval' xs = xs.pseq(xs.reduce(par)) p_reduce' op xs = xs.p_eval'.reduce(op) p_map_reduce_to n m r xs = xs.split_to(n).map(m).p_reduce'(r) p_map_reduce m r xs = p_map_reduce_to 16 m r xs -- test fib 0 = 0 fib 1 = 1 fib n = fib (n-1) + fib (n-2) fibs xs = xs.map(fib).sum test_list = replicate 50 30 s_fibs = test_list.fibs p_fibs = test_list.p_map_reduce fibs (+) main = p_fibs.show.putStrLn From greenrd at greenrd.org Thu Jul 3 09:09:04 2008 From: greenrd at greenrd.org (Robin Green) Date: Thu Jul 3 09:01:30 2008 Subject: [Haskell-cafe] ANN: The Disciplined Disciple Compiler - alpha 1.1 In-Reply-To: References: Message-ID: <20080703140904.5ca5c4c9@greenrd.org> Is there any work on combining effect typing with extended static checking or full-blown formal verification (e.g. proof-carrying code)? My hunch would be that an impure functional language like this (OCaml is another example) makes optimisation easier, compared to Haskell - but at the expense of making formal reasoning about the code potentially as complicated and hard as formal reasoning about, say, Java code. Of course, the way in which programmers choose to use the language would impact how easy their code is to reason about. But from the standpoint of ease of reasoning, I'm leaning towards sticking with pure languages for the time being, in my research. -- Robin On Thu, 3 Jul 2008 22:12:30 +1000 Ben Lippmeier wrote: > > Hi All, > I'm pleased to announce version 1.1 > of the Disciplined Disciple Compiler (DDC) > > Disciple is an explicitly lazy dialect of Haskell which supports: > - first class destructive update of arbitrary data. > - computational effects without the need for state monads. > - type directed field projections. > - allied functional goodness. > > All this and more through the magic of effect typing. > > New in this version: > - support for x86_64 under linux and darwin, thanks to Jared Putnam. > - the -make flag now does a full dependency driven build/rebuild. > - constructor classes. > - irrefutable patterns. > - partial support for monadic do notation. > - an unboxed Bool# type with true# and false# literals. > - field projection punning. > - lots more example code. > > Project page with full release notes and download at: > http://www.haskell.org/haskellwiki/DDC > > DDC: more than lambdas. > > Ben. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mrchebas at gmail.com Thu Jul 3 09:20:07 2008 From: mrchebas at gmail.com (Alexey Rodriguez) Date: Thu Jul 3 09:11:12 2008 Subject: [Haskell-cafe] Type families versus functional dependencies question Message-ID: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> Hi guys, We are having trouble with the following program that uses type families: > class Blah f a where > blah :: a -> T f f a > class A f where > type T f :: (* -> *) -> * -> * the following function does not type: > wrapper :: forall a f . Blah f a => a -> T f f a > wrapper x = blah x GHC gives the error: Couldn't match expected type `T f1 f1 a' against inferred type `T f f a' In the expression: blah x In the definition of `wrapper': wrapper x = blah x Maybe it is a problem with ambiguous types, namely "f" appears only in applications of "T". But that is not the case, there is a "naked" f appearing as the argument of "T f". But perhaps the type checker does not want to unify those two f's precisely because they are the arguments of "T f". I have tried to encode the above program using FunDeps, because this procedure helps me understand type errors. But in this case I get no type error! > class A' (f :: * -> *) (g :: (* -> *) -> * -> *) | f -> g where > class Blah' f a where > blah' :: A' f g => a -> g f a > wrapper' :: forall a f g . (Blah' f a,A' f g) => a -> g f a > wrapper' x = blah' x So my question is whether my encoding is correct. And if it is, why isn't the type families version working? Thanks! Alexey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080703/772bcad6/attachment.htm From mail at joachim-breitner.de Thu Jul 3 09:55:52 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Thu Jul 3 09:46:56 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? In-Reply-To: <486BA218.6020806@list.mightyreason.com> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <486BA218.6020806@list.mightyreason.com> Message-ID: <1215093352.21636.2.camel@otto.ehbuehl.net> Hi, Am Mittwoch, den 02.07.2008, 16:43 +0100 schrieb ChrisK: > > hen, the readFileOD could put the timestamp > > of the read file in a Monad-local state and the writeFileOD could, if > > the output is newer then all inputs listed in the state, skip the > > writing and thus the unsafeInterleaveIO?ed file reads are skipped as > > well, if they were not required for deciding the flow of the program. > > How is your system similar to make/Makefile or different to > make/Makefile ? > > Are your actions more restricted? Are the semantics more imperative? Are the > dependencies still explicit or are them implicit and inferred? I think the biggest difference is that with Make, you have to explicitly list all dependencies, which is what I want to avoid by having the Monad keep record of the used files. So it?s mostly a convenience thingy, altough a monad would be generally more flexible, e.g. deciding the output file name based on some content of the some of the input files. I have some code that I?ll put somewhere soon. Greetings, Joachim -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189 Jabber-ID: nomeata@joachim-breitner.de -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080703/2c05a27e/attachment.bin From mail at joachim-breitner.de Thu Jul 3 11:00:04 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Thu Jul 3 10:51:10 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? In-Reply-To: <1215093352.21636.2.camel@otto.ehbuehl.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <486BA218.6020806@list.mightyreason.com> <1215093352.21636.2.camel@otto.ehbuehl.net> Message-ID: <1215097204.21636.16.camel@otto.ehbuehl.net> Hi, Am Donnerstag, den 03.07.2008, 15:55 +0200 schrieb Joachim Breitner: > I have some code that I?ll put somewhere soon. http://darcs.nomeata.de/odio/ODIO.hs now contains a simple implementation of the idea, together with more explanation. To show what the effect is, I wrote a very small program: 1> main = runODIO $ do 2> c1 <- readFileOD' "inFile1" 3> c2 <- readFileOD' "inFile2" 4> c3 <- readFileOD' "inFile3" 5> liftIO $ putStrLn "Some output" 6> writeFileOD' "outFile1" (show (length c1 + length c2)) 7> c4 <- readFileOD' "inFile4" 8> writeFileOD' "outFile2" (show (length c1 + length c3 + length c4)) 9> time <- liftIO $ getClockTime A> writeFileOD' "outFile3" (show time ++ c1) and a script that runs this under various conditions http://darcs.nomeata.de/odio/demo.sh with the output available at http://darcs.nomeata.de/odio/demo.out. Note that the primes after the function calls are just for the verbose variant for demonstration. Some points to emphasize (you can verify them in the demo output). * The 9th line runs an arbitary IO action, so from then on, ODIO can?t do anything else but to actually write out every file it should. * The 5th line does not have this effect. Because this gets desugared to (>>), the special implementation of (>>) means that the next line still sees the same dependency state as the before the call to liftIO. * A change to inFile3 causes outFile1 to be re-written, although from looking at the code, _we_ know that this is not necessary, but the ODIO monad can not tell. The programmer should have swapped the lines. * A change only to inFile4 means that outFile1 will not have to generated, and thanks to lazyness and unsafeInterleaveIO, inFile2 will not even opened. Some additions that might be necessary for real world use: * ByteString interface * a variant of readFileOD with type ?FilePath -> IO a -> ODIO a? if, instead of reading the file directly, you want to call some external parsing helper (e.g. to read exif data). * A even more verbose mode that tells you why exactly a write action has to be done. This is why I keep a list of Files and Timestamps around. I hope this is a basis for even more discussion, and of course http://darcs.nomeata.de/odio/ is a darcs repository, so feel free to send patches. Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080703/38233501/attachment.bin From claus.reinke at talk21.com Thu Jul 3 13:31:02 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Jul 3 13:22:11 2008 Subject: [Haskell-cafe] Type families versus functional dependencies question References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> Message-ID: <012d01c8dd32$922ff960$851f7ad5@cr3lt> > GHC gives the error: > > Couldn't match expected type `T f1 f1 a' > against inferred type `T f f a' > In the expression: blah x > In the definition of `wrapper': wrapper x = blah x actually, GHC gives me "could not deduce Blah f a from Blah f1 a" first. It seems that desugaring type function notation into an additional constraint helps, so there's something odd going on: class Blah f a where blah :: a -> T f f a class A f where type T f :: (* -> *) -> * -> * wrapper :: forall a f tf . (Blah f a,T f~tf) => a -> tf f a wrapper x = blah x You're relying on that second f to determine the first, which then allows T f to determine tf f a. Looks a bit like cyclic programming at the type level?-) Whereas the desugared view is that we may not know the type constructor tf yet, but whatever it is, its first parameter fixes f. Yet another take on it: tf, the result of T f f a, needs to be determined by the context, rather than the type function, and type functions are traditionally bad at reasoning backwards. The extra indirection separates determining f from applying T f. I think I'd prefer if that naive desugaring of type function always worked, without such differences. Worth a ticket? Claus From haskell at list.mightyreason.com Thu Jul 3 14:09:58 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Thu Jul 3 14:01:18 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? In-Reply-To: <1215097204.21636.16.camel@otto.ehbuehl.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <486BA218.6020806@list.mightyreason.com> <1215093352.21636.2.camel@otto.ehbuehl.net> <1215097204.21636.16.camel@otto.ehbuehl.net> Message-ID: <486D15F6.6070305@list.mightyreason.com> Joachim Breitner wrote: > * The 5th line does not have this effect. Because this gets desugared > to (>>), the special implementation of (>>) means that the next line > still sees the same dependency state as the before the call to liftIO. You are violating the monad laws. (f >> k) and (f >>= \_ -> k) should do the same thing. You might write a version of liftIO that has the effect you want, however. > > * A change to inFile3 causes outFile1 to be re-written, although from > looking at the code, _we_ know that this is not necessary, but the ODIO > monad can not tell. The programmer should have swapped the lines. Let me reverse engineer your algorithm (aside from the screwy >>): Every readFile that is encountered in processing ODIO is added to a list of source files. The reading deferred to be lazy with unsafePerformIO. When a writeFile is encountered it is assumed to depend on all previously read files. If this output file already exists and is newer than all the source files, then writing it is skipped (and perhaps also the lazy reads are skipped). Otherwise, the writing is strict. ---- I would say this is an unusual module. I rather prefer Makefile semantics, which could be improved in some ways by using a DSL in Haskell instead. The syntactic form of a file-oriented Makefile declaration is output : input1 input2 shell script more shell script And the "shell script" has access to the output file name, and also has access to the input names. In Haskell you could have a monadic DSL where the output name (and perhaps some explicit input names) are accessible like MonadReader. The result of running the DSL would do no IO at all but, much like a compiler, would return an IO action (the program to create the output file) and a list of inferred dependencies (an improvement over the Makefile syntax). Even if the DSL does not allow liftIO, it can still compile to various IO actions. Then you have a map from (outputname) to (dependencies,ioAction). And when outputname is demanded you can walk the dependencies to see if the timestamps are newer or older, using the ioActions to create the desired files. So perhaps to run the DSL monad you have a function like: makeRule :: DSL () -> FilePath -> [FilePath] -> ( [FilePath], IO () ) type Depends = Map FilePath ([FilePath], IO ()) demand :: Depends -> FilePath -> Maybe ByteString From droundy at darcs.net Thu Jul 3 14:35:05 2008 From: droundy at darcs.net (David Roundy) Date: Thu Jul 3 14:26:08 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? In-Reply-To: <486D15F6.6070305@list.mightyreason.com> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <486BA218.6020806@list.mightyreason.com> <1215093352.21636.2.camel@otto.ehbuehl.net> <1215097204.21636.16.camel@otto.ehbuehl.net> <486D15F6.6070305@list.mightyreason.com> Message-ID: <20080703183504.GN10093@darcs.net> On Thu, Jul 03, 2008 at 07:09:58PM +0100, ChrisK wrote: > Joachim Breitner wrote: > > * The 5th line does not have this effect. Because this gets desugared > >to (>>), the special implementation of (>>) means that the next line > >still sees the same dependency state as the before the call to liftIO. > > You are violating the monad laws. (f >> k) and (f >>= \_ -> k) > should do the same thing. You might write a version of liftIO that > has the effect you want, however. I don't mind a little anarchy in the monad laws... :) > > * A change to inFile3 causes outFile1 to be re-written, although from > >looking at the code, _we_ know that this is not necessary, but the ODIO > >monad can not tell. The programmer should have swapped the lines. > > Let me reverse engineer your algorithm (aside from the screwy >>): > > Every readFile that is encountered in processing ODIO is added to a > list of source files. The reading deferred to be lazy with > unsafePerformIO. > > When a writeFile is encountered it is assumed to depend on all > previously read files. If this output file already exists and is > newer than all the source files, then writing it is skipped (and > perhaps also the lazy reads are skipped). Otherwise, the writing is > strict. > > ---- > > I would say this is an unusual module. I rather prefer Makefile semantics, > which could be improved in some ways by using a DSL in Haskell instead. > > The syntactic form of a file-oriented Makefile declaration is > > output : input1 input2 > shell script > more shell script I must say that I prefer the automatic computation of dependencies as outlined by Joachim. A bit more is needed, of course, to enable true Makefile-like dependency handling, since you'd want to ensure that the dependencies themselves are up-to-date, but the automatic computation of dependencies would be a real boon. Makefiles are extremely prone to errors in which dependencies are left out, and those bugs are only caught on rare occasions when the build is performed in an unusual order, or when a rarely-touched source file is edited. Of course, to create a "make" replacement, you'd also have to be able to call external programs and track which files they use, which is a hard problem, particularly as which files they use may depend on the contents of the files that they use. One could, however, lift calls to well-behaved external programs (e.g. those like ghc or gcc that can output their dependencies) into this sort of monad. David From mrchebas at gmail.com Thu Jul 3 14:56:16 2008 From: mrchebas at gmail.com (Alexey Rodriguez) Date: Thu Jul 3 14:47:21 2008 Subject: [Haskell-cafe] Type families versus functional dependencies question In-Reply-To: <012d01c8dd32$922ff960$851f7ad5@cr3lt> References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> <012d01c8dd32$922ff960$851f7ad5@cr3lt> Message-ID: <4b39c80a0807031156h7aa86697k5a0012020d677f49@mail.gmail.com> On Thu, Jul 3, 2008 at 7:31 PM, Claus Reinke wrote: > GHC gives the error: >> >> Couldn't match expected type `T f1 f1 a' >> against inferred type `T f f a' >> In the expression: blah x >> In the definition of `wrapper': wrapper x = blah x >> > > actually, GHC gives me "could not deduce Blah f a from Blah f1 a" > first. It seems that desugaring type function notation into an additional > constraint helps, so there's something odd going on: Silly me, I didn't paste the whole type error. Yes, GHC gives both. I should add that I tested this under GHC 6.8.2. But this is known not to work with a (one/two months old) GHC head. Cheers, Alexey > > > class Blah f a where blah :: a -> T f f a > class A f where type T f :: (* -> *) -> * -> * > > wrapper :: forall a f tf . (Blah f a,T f~tf) => a -> tf f a > wrapper x = blah x > > You're relying on that second f to determine the first, which > then allows T f to determine tf f a. Looks a bit like cyclic > programming at the type level?-) Whereas the desugared > view is that we may not know the type constructor tf yet, > but whatever it is, its first parameter fixes f. > > Yet another take on it: tf, the result of T f f a, needs to be > determined by the context, rather than the type function, > and type functions are traditionally bad at reasoning backwards. The extra > indirection separates determining > f from applying T f. > > I think I'd prefer if that naive desugaring of type function > always worked, without such differences. > > Worth a ticket? > Claus > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080703/537f7b4c/attachment.htm From lemming at henning-thielemann.de Thu Jul 3 15:08:41 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 3 14:59:48 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806300449r304afd11g46d3b94fe52119dd@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> <79d7c4980806260554w3698f3d3p624dde7f16b6b06d@mail.gmail.com> <79d7c4980806270658u78530f51qc2d32f372976f1a0@mail.gmail.com> <79d7c4980806300449r304afd11g46d3b94fe52119dd@mail.gmail.com> Message-ID: On Mon, 30 Jun 2008, Alistair Bayley wrote: > I haven't found a way to detect where headers are installed, so I > propose that the Setup.hs assumes $ORACLE_HOME/rdbms/public (for > Unix), and you can add more with --extra-include-dirs=... . What do > you think? Many thanks for including the necessary changes for Oracle on Linux! From claus.reinke at talk21.com Thu Jul 3 16:14:22 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Jul 3 16:05:32 2008 Subject: [Haskell-cafe] Type families versus functional dependenciesquestion References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com><012d01c8dd32$922ff960$851f7ad5@cr3lt> <4b39c80a0807031156h7aa86697k5a0012020d677f49@mail.gmail.com> Message-ID: <019b01c8dd49$6491b180$851f7ad5@cr3lt> >> actually, GHC gives me "could not deduce Blah f a from Blah f1 a" >> first. It seems that desugaring type function notation into an additional >> constraint helps, so there's something odd going on: > > Silly me, I didn't paste the whole type error. Yes, GHC gives both. I should > add that I tested this under GHC 6.8.2. But this is known not to work with a > (one/two months old) GHC head. yes, I tested with 6.9.20080514. And just in case my phrasing was unclear: desugaring the type function application makes the error go away, so you have a workaround. It is just confusing that this example shows that the "desugaring" is not a desugaring, in the current implementation.. Claus From mail at joachim-breitner.de Thu Jul 3 17:37:08 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Thu Jul 3 17:28:44 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? In-Reply-To: <20080703183504.GN10093@darcs.net> References: <1214820294.3204.24.camel@otto.ehbuehl.net> <486BA218.6020806@list.mightyreason.com> <1215093352.21636.2.camel@otto.ehbuehl.net> <1215097204.21636.16.camel@otto.ehbuehl.net> <486D15F6.6070305@list.mightyreason.com> <20080703183504.GN10093@darcs.net> Message-ID: <1215121028.3338.3.camel@otto.ehbuehl.net> Hi, Am Donnerstag, den 03.07.2008, 11:35 -0700 schrieb David Roundy: > On Thu, Jul 03, 2008 at 07:09:58PM +0100, ChrisK wrote: > > Joachim Breitner wrote: > > You are violating the monad laws. (f >> k) and (f >>= \_ -> k) > > should do the same thing. You might write a version of liftIO that > > has the effect you want, however. > > I don't mind a little anarchy in the monad laws... :) It depends on what level you want them to be true. Assuming the rest of the code is correct, the only difference that (f >> k) from (f >>= \_ -> k) is that a file write in k, which would make no difference, would be omitted. In this sense, the monad laws are followed. > I must say that I prefer the automatic computation of dependencies as > outlined by Joachim. Thanks! > Of course, to create a "make" replacement, you'd also have to be able > to call external programs and track which files they use, which is a > hard problem, particularly as which files they use may depend on the > contents of the files that they use. One could, however, lift calls > to well-behaved external programs (e.g. those like ghc or gcc that can > output their dependencies) into this sort of monad. That?s easily possible with a custom sourceAction, which allows you to set the action, and the time stamp detection independently. Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080703/6607d84e/attachment.bin From twd2 at dockerz.net Thu Jul 3 20:24:07 2008 From: twd2 at dockerz.net (Tim Docker) Date: Thu Jul 3 20:18:23 2008 Subject: [Haskell-cafe] Alternatives to convoluted record syntax In-Reply-To: References: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> Message-ID: <37300.203.185.215.144.1215131047.squirrel@dockerz.net> > For access to nested record fields I implemented the record-access > package. Unfortunately the field accessors must still be written manually. > http://darcs.haskell.org/record-access/src/Data/Accessor/Example.hs I looked for this on hackage, but found instead this: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor which, unless I am mistaken, is actually a different package by Luke Palmer, with similar intent. Should we be trying to avoid name overlaps like this? Tim From chak at cse.unsw.edu.au Thu Jul 3 23:03:00 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Thu Jul 3 22:54:06 2008 Subject: [Haskell-cafe] Type families versus functional dependencies question In-Reply-To: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> Message-ID: <5826455B-5E82-4512-8482-C9845CB7DFB5@cse.unsw.edu.au> Alexey Rodriguez: > We are having trouble with the following program that uses type > families: > > > class Blah f a where > > blah :: a -> T f f a > > > class A f where > > type T f :: (* -> *) -> * -> * > > the following function does not type: > > > wrapper :: forall a f . Blah f a => a -> T f f a > > wrapper x = blah x > > GHC gives the error: > > Couldn't match expected type `T f1 f1 a' > against inferred type `T f f a' > In the expression: blah x > In the definition of `wrapper': wrapper x = blah x > > Maybe it is a problem with ambiguous types, namely "f" appears only > in applications of "T". But that is not the case, there is a "naked" > f appearing as the argument of "T f". But perhaps the type checker > does not want to unify those two f's precisely because they are the > arguments of "T f". The problem is that blah's type is ambiguous, as f does only occur as an argument to the type family. If you'd define class Blah f a where blah :: a -> f -> T f f a (and change the rest of the program accordingly) then all will be fine. See this thread for a more in-depth discussion of the problem: http://www.haskell.org/pipermail/haskell-cafe/2008-April/041385.html Manuel From ronwalf at volus.net Thu Jul 3 23:42:56 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 3 23:33:59 2008 Subject: [Haskell-cafe] Wouter Swierstra style extensible records! Message-ID: Having made over-use of Wouter's expression idioms, I decided to hack it into extensible records. It's not documented, it's probably got holes in its usability, but I thought I'd post it so people can play with it (and give suggestions before I rewrite my code to use it!). I know there are other extensible record systems, but I wondered how this stacks up. Notably, it looks like in HList the records are only extensible in one direction (tacking fields onto the end), although they have a much more developed syntax (if you're into that sort of thing). Current problems: * Defining a new field is rather bulky - currently it takes lines. Definitions are bulky in Wouter's extensible expressions, too, but I could probably shorten the get/set convenience functions to something more readable. * Construction of new records is only convenient by using the defaulting system. Maybe that makes sense, maybe it doesn't. A side benefit: Record access functions are reusable between record types (as long as they have the same type). Anyway, thanks again, Wouter! -Ron -------------- next part -------------- A non-text attachment was scrubbed... Name: WouterRecords.hs Type: application/octet-stream Size: 2591 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080703/0d46ad57/WouterRecords.obj From richardg at richardg.name Fri Jul 4 02:29:23 2008 From: richardg at richardg.name (Richard G.) Date: Fri Jul 4 02:20:25 2008 Subject: [Haskell-cafe] Existential Data Types Message-ID: <486DC343.6030209@richardg.name> Hello I've been doing some stuff with existential data types and came across a curious pattern. If anyone has thoughts, comments, or feedback, it would be appreciated. --- I'm trying to port and extend the Be messaging scheme to Haskell for use in distributed, heterogenous environments. BeOS was object oriented and pervasively threaded. That, and my background as an OOP programmer, has resulted in a very OOP approach. Because OOP allows for subclassing and the Be API was designed for it, I've used a wrapper approach. class HandlerC h where . . . data Handler = forall h . HandlerC h => Handler h instance HandlerC Handler where . . . data DefaultHandler = DefaultHandler ... instance HandlerC DefaultHandler where . . . newDefaultHandler = Handler (DefaultHandler ...) newHandler h = Handler h The HandlerC defines the interface. When Handler implements the interface, it mostly passes the functions to the inner Handler that actually has the data and the real functions. The advantage is that I can wrap anything that implements the HandlerC interface and have it behave in a known and simple way from the outside. ---- One area where this might have some application is in unit testing to make mock objects easier to use. If I had a Looper ADT that depended on the Handler, I would want test the Looper without having to worry about the complexity of the Handler interfering with the tests. I could do this with the following: data MockHandler = MockHandler ... instance HandlerC MockHandler where . . . h = newHandler (MockHandler ...) where h is passed to the Looper some how. ---- Overall, this seems very similar to data D = D1 | D2 | D3 | ... The big difference is that all the Dn constructors don't need to be known at compile time, which is very useful when writing libraries. Also, the wrapped data can include functions and state data, making it very easy to create applets. This is handy when doing message passing or request handling, such as in a web server, especially when using STM. Richard From leledumbo_cool at yahoo.co.id Fri Jul 4 02:49:44 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Fri Jul 4 02:40:45 2008 Subject: [Haskell-cafe] Integer = infinite precision integer? How? Message-ID: <18273875.post@talk.nabble.com> Does anyone have an explanation how Haskell implement this? Or a pointer to a article describing this? -- View this message in context: http://www.nabble.com/Integer-%3D-infinite-precision-integer--How--tp18273875p18273875.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From k.pierre.k at gmail.com Fri Jul 4 02:53:05 2008 From: k.pierre.k at gmail.com (pierre) Date: Fri Jul 4 02:44:53 2008 Subject: [Haskell-cafe] Integer = infinite precision integer? How? In-Reply-To: <18273875.post@talk.nabble.com> References: <18273875.post@talk.nabble.com> Message-ID: <20080704065305.GA6758@localdomain> On Thu, Jul 03, 2008 at 11:49:44PM -0700, leledumbo wrote: > > Does anyone have an explanation how Haskell implement this? Or a pointer to a > article describing this? > -- AFAIK it's implemented via GMP library: http://gmplib.org/ > View this message in context: http://www.nabble.com/Integer-%3D-infinite-precision-integer--How--tp18273875p18273875.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- pierre From brad.larsen at gmail.com Fri Jul 4 02:56:40 2008 From: brad.larsen at gmail.com (Brad Larsen) Date: Fri Jul 4 02:48:12 2008 Subject: [Haskell-cafe] Integer = infinite precision integer? How? In-Reply-To: <18273875.post@talk.nabble.com> References: <18273875.post@talk.nabble.com> Message-ID: On Fri, 04 Jul 2008 02:49:44 -0400, leledumbo wrote: > Does anyone have an explanation how Haskell implement this? Or a pointer to a > article describing this? GMP is presently used in GHC (at least according to ). Regards, Brad Larsen From lemming at henning-thielemann.de Fri Jul 4 03:18:23 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 4 03:09:28 2008 Subject: [Haskell-cafe] Integer = infinite precision integer? How? In-Reply-To: <18273875.post@talk.nabble.com> References: <18273875.post@talk.nabble.com> Message-ID: On Thu, 3 Jul 2008, leledumbo wrote: > Does anyone have an explanation how Haskell implement this? Or a pointer to a > article describing this? Just a nitpick: Integers can have an arbitrary but only a finite number of digits. In contrast to that reals have infinitely many digits after the decimal point. There are Cantor's proofs that the set of natural numbers and the set of rational numbers have the same cardinality, whereas the set of reals has larger cardinality. Students often fail to understand that, if they are not aware that integers can only have finitely many digits. From ashley at semantic.org Fri Jul 4 04:20:04 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Fri Jul 4 04:11:19 2008 Subject: [Haskell-cafe] Re: ANN: Gtk2Hs 0.9.13 released In-Reply-To: <4865ADA5.3070103@gmail.com> References: <4865ADA5.3070103@gmail.com> Message-ID: Peter Gavin wrote: > Gtk2Hs version 0.9.13 is now available. [1] > > New features: > > * bindings for Gnome VFS and GStreamer Is this bindings for the new GIO/GVFS stuff? Is Gtk2Hs cabal-ised? -- Ashley From mrchebas at gmail.com Fri Jul 4 04:39:08 2008 From: mrchebas at gmail.com (Alexey Rodriguez) Date: Fri Jul 4 04:30:36 2008 Subject: [Haskell-cafe] Type families versus functional dependenciesquestion In-Reply-To: <019b01c8dd49$6491b180$851f7ad5@cr3lt> References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> <012d01c8dd32$922ff960$851f7ad5@cr3lt> <4b39c80a0807031156h7aa86697k5a0012020d677f49@mail.gmail.com> <019b01c8dd49$6491b180$851f7ad5@cr3lt> Message-ID: <4b39c80a0807040139y6e7c8c24id8c659f2061a0dca@mail.gmail.com> On Thu, Jul 3, 2008 at 10:14 PM, Claus Reinke wrote: > actually, GHC gives me "could not deduce Blah f a from Blah f1 a" >>> first. It seems that desugaring type function notation into an additional >>> constraint helps, so there's something odd going on: >>> >> >> Silly me, I didn't paste the whole type error. Yes, GHC gives both. I >> should >> add that I tested this under GHC 6.8.2. But this is known not to work >> with a >> (one/two months old) GHC head. >> > > yes, I tested with 6.9.20080514. And just in case my phrasing > was unclear: desugaring the type function application makes the > error go away, so you have a workaround. Thanks for highlighting this. Indeed I missed it, and it makes my example work. Cheers, Alexey > > > It is just confusing that this example shows that the "desugaring" > is not a desugaring, in the current implementation.. > > Claus > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080704/b921617b/attachment.htm From mrchebas at gmail.com Fri Jul 4 04:42:24 2008 From: mrchebas at gmail.com (Alexey Rodriguez) Date: Fri Jul 4 04:33:25 2008 Subject: [Haskell-cafe] Type families versus functional dependencies question In-Reply-To: <5826455B-5E82-4512-8482-C9845CB7DFB5@cse.unsw.edu.au> References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> <5826455B-5E82-4512-8482-C9845CB7DFB5@cse.unsw.edu.au> Message-ID: <4b39c80a0807040142l1b23093bo5f14d2e40e8da751@mail.gmail.com> On Fri, Jul 4, 2008 at 5:03 AM, Manuel M T Chakravarty wrote: > The problem is that blah's type is ambiguous, as f does only occur as an > argument to the type family. If you'd define > > class Blah f a where > blah :: a -> f -> T f f a > > (and change the rest of the program accordingly) then all will be fine. > See this thread for a more in-depth discussion of the problem: > > http://www.haskell.org/pipermail/haskell-cafe/2008-April/041385.html > Yes, I was afraid that this was the case. However, the question remains on whether my functional dependencies encoding is correct. A correct encoding would help me understand this typing problem a bit more. Especially, now that Claus showed that adding an equality constraint makes this program work! Cheers, Alexey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080704/787915a4/attachment.htm From phy51km4n at yahoo.de Fri Jul 4 04:57:49 2008 From: phy51km4n at yahoo.de (phy51km4n) Date: Fri Jul 4 04:48:50 2008 Subject: [Haskell-cafe] Question concerning datatype "Either" Message-ID: <18264739.post@talk.nabble.com> There is a exercise using datatype "Either" I'm a bit confused about... The following datatypes are given: data Either a b = Left a | Right b data Tuple a b c d = One a | Two a b | Three a b c | Four a b c d Now the exercise: "Based on our definition of Tuple, write a function which takes a Tuple and returns either the value (if it?s a one-tuple), a Haskell-pair (i.e., (?a?,5)) if it?s a two-tuple, a Haskell-triple if it?s a three-tuple or a Haskell-quadruple if it?s a four-tuple. You will need to use the Either type to represent this." Why does that not work? : fromTuple (One a) = a fromTuple (Two a b) = (a, b) fromTuple (Three a b c) = (a, b, c) fromTuple (Four a b c d) = (a, b, c, d) Why is this correct? : fromTuple (One a ) = Left (Left a) fromTuple (Two a b ) = Left (Right (a,b)) fromTuple (Three a b c ) = Right (Left (a,b,c)) fromTuple (Four a b c d) = Right (Right (a,b,c,d)) Why does this combination of Rights and Lefts work and how does it work?? -- View this message in context: http://www.nabble.com/Question-concerning-datatype-%22Either%22-tp18264739p18264739.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From Alistair.Bayley at invesco.com Fri Jul 4 05:22:14 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Jul 4 05:13:18 2008 Subject: [Haskell-cafe] Question concerning datatype "Either" In-Reply-To: <18264739.post@talk.nabble.com> References: <18264739.post@talk.nabble.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E946D@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of phy51km4n > > Why does that not work? : > > fromTuple (One a) = a > fromTuple (Two a b) = (a, b) > fromTuple (Three a b c) = (a, b, c) > fromTuple (Four a b c d) = (a, b, c, d) Have you tried it? What are the types of the various cases in fromTuple (you can rename them to get ghci to accept them as separate functions): fromTuple1 :: Tuple a b c d -> a fromTuple1 (One a) = a fromTuple2 :: Tuple a b c d -> ??? fromTuple2 (Two a b) = (a, b) > Why is this correct? : > > fromTuple (One a ) = Left (Left a) > fromTuple (Two a b ) = Left (Right (a,b)) > fromTuple (Three a b c ) = Right (Left (a,b,c)) > fromTuple (Four a b c d) = Right (Right (a,b,c,d)) Again, what is the type of just this line? fromTuple (One a ) = Left (Left a) and this line? fromTuple (Two a b ) = Left (Right (a,b)) And if you combine them? fromTuple :: Tuple a b c d -> ??? fromTuple (One a ) = Left (Left a) fromTuple (Two a b ) = Left (Right (a,b)) (You should see that Either's type parameters are progressively filled-in as you add more cases.) Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From avatar at hot.ee Fri Jul 4 05:29:09 2008 From: avatar at hot.ee (Misha Aizatulin) Date: Fri Jul 4 05:20:19 2008 Subject: [Haskell-cafe] Alternatives to convoluted record syntax In-Reply-To: <49b351060807030448x11b787fayc2e24e21ae456723@mail.gmail.com> References: <2d3641330807030300p597374f3i48f7e8b2e90859d@mail.gmail.com> <49b351060807030448x11b787fayc2e24e21ae456723@mail.gmail.com> Message-ID: <486DED65.8070109@hot.ee> Hi, > busNum n > | (isBusId n) = $(modify 'query) ($(set 'queryBusNumber) (Just n)) > | otherwise = id > The solution I am using is creating for each record type @Rec@, and each of its fields @fieldName :: T@ an updater updateFieldName :: (T -> T) -> Rec -> Rec This way you can write busNum n | (isBusId n) = updateQuery $ updateQueryBusNumber $ const (Just n) | otherwise = id The task of creating updaters can be automated using TH, this is what the attached library does: all you need is to say $(genUpdaters ''Opts) $(genUpdaters ''Query) Cheers, Misha -------------- next part -------------- A non-text attachment was scrubbed... Name: RecordUpdate.tar.gz Type: application/x-gzip Size: 4158 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080704/49590c54/RecordUpdate.tar.bin From loup.vaillant at gmail.com Fri Jul 4 05:29:24 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Fri Jul 4 05:20:27 2008 Subject: [Haskell-cafe] Question concerning datatype "Either" In-Reply-To: <18264739.post@talk.nabble.com> References: <18264739.post@talk.nabble.com> Message-ID: <6f9f8f4a0807040229o26258f16u45ef4cdfa1bb2f61@mail.gmail.com> 2008/7/4 phy51km4n : > > There is a exercise using datatype "Either" I'm a bit confused about... > > The following datatypes are given: > > data Either a b = Left a > | Right b > > data Tuple a b c d = One a > | Two a b > | Three a b c > | Four a b c d > > Now the exercise: > > "Based on our definition of Tuple, write a function which takes a Tuple and > returns either the value > (if it's a one-tuple), a Haskell-pair (i.e., ('a',5)) if it's a two-tuple, a > Haskell-triple > if it's a three-tuple or a Haskell-quadruple if it's a four-tuple. You will > need to > use the Either type to represent this." > > Why does that not work? : > > fromTuple (One a) = a > fromTuple (Two a b) = (a, b) > fromTuple (Three a b c) = (a, b, c) > fromTuple (Four a b c d) = (a, b, c, d) The first line tells: fromTuple :: Tuple a b c d -> a The second line tells: fromTuple :: Tuple a b c d -> (a, b) The third line tells: fromTuple :: Tuple a b c d -> (a, b, c) The fourth line tells: fromTuple :: Tuple a b c d -> (a, b, c, d) There is no way you can unify the return types of these four lines (Well, the compiler must have told you something similar). That was the obvious part. > Why is this correct? : > > fromTuple (One a ) = Left (Left a) > fromTuple (Two a b ) = Left (Right (a,b)) > fromTuple (Three a b c ) = Right (Left (a,b,c)) > fromTuple (Four a b c d) = Right (Right (a,b,c,d)) > > Why does this combination of Rights and Lefts work and how does it work?? OK, first, let's simplify things a bit: data Stuple a b = Sone a | Stwo (a, b) fromStuple :: Stuple a b -> Either a (a, b) fromStuple (Sone a) = Left a fromStuple (Stwo (a, b)) = Right (a, b) According to the definition of Either, I can perfectly retrun different types for left and right. (That was the whole point of the Either type.) In your more complicated case, you can see you are using four combination of Left and Rights. The type of your function is (tell me if your compiler says otherwise): Tuple a b c d -> Either (Either a (a, b)) (Either (a, b, c) (a, b, c, d)) Ouch. Either is parametrized by two types: the one used in Left, and the one used in Right. If your are using Either types as left an right, it is possible to parametrize each of them by two types totalazing four types. Let me rewrite the return type above so you can read its tree structure more easily: Either (Either a (a, b)) (Either (a, b, c) (a, b, c, d)) Here, this should be obvious: while an Either type can hold two types, this nested one can hold four types. Hope this helps. Loup From claus.reinke at talk21.com Fri Jul 4 05:57:16 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jul 4 05:51:44 2008 Subject: [Haskell-cafe] Question about abstraction References: Message-ID: <00de01c8ddbc$d04e1f30$32028351@cr3lt> > combineWith :: b -> (b -> a -> b) -> a -> a -> a -> a -> b > n `combineWith` f = \tl tr bl br -> n `f` tl `f` tr `f` bl `f` br > > instance Foldable T where > foldMap f = foldT mempty $ \_ x -> f x `combineWith` mappend > > -- But 'traverse' won't typecheck: > > instance Traversable T where > traverse f = foldT (pure L) $ \p x -> (N p <$> f x) `combineWith` (<*>) > > -- Is it possible to make 'combineWith' more general so that the > -- previous typechecks (maybe using arbitrary-rank polymorphism but I > -- don't see how)? Looks tempting, doesn't it?-) But while the code is the same, the types needed for the two uses are rather different (and the inferred type not the most general one): combineWith :: b -> (b -> a -> b) -> (a -> a-> a-> a-> b) combineWith :: f (a->a->a->a->b) -> (forall a b . f (a->b) -> f a -> f b) -> (f a->f a->f a->f a->f b) We can shorten them a bit: type Four a b = a -> a -> a -> a -> b combineWith :: b -> (b -> a -> b) -> Four a b combineWith :: f (Four a b) -> (forall a b . f (a->b) -> f a -> f b) -> Four (f a) (f b) and we can add a dummy constructor to make them more similar: newtype Id a = Id{unId::a} combineWith :: f b -> ( f b -> f a -> f b) -> Four (f a) (f b) -- f ~ Id combineWith :: f (Four a b) -> (forall a b . f (a->b) -> f a -> f b) -> Four (f a) (f b) which leaves us with the crux of the matter: the function parameters and their uses are completely different: four independent applications of mappend vs four accumulating applications of (<*>). We still can make the simple case look like the complex case, by moving the mappend to the first parameter, but whether that is helpful is another question: combineWith :: f (Four a b) -> (forall a b . f (a->b) -> f a -> f b) -> Four (f a) (f b) n `combineWith` f = \tl tr bl br -> n `f` tl `f` tr `f` bl `f` br four f a b c d e = f (f (f (f a b) c) d) e instance Foldable T where foldMap f = unId . foldT (Id mempty) (\_ x -> Id (four mappend $ f x) `combineWith` (\(Id a) (Id b)->Id (a b))) instance Traversable T where traverse f = foldT (pure L) $ \p x -> (N p <$> f x) `combineWith` (<*>) Slightly more interesting is that foldMap should be an application of traverse (see Traversable documentation, and its source, for foldMapDefault). Hth, Claus From chris at eidhof.nl Fri Jul 4 10:54:55 2008 From: chris at eidhof.nl (Chris Eidhof) Date: Fri Jul 4 10:46:18 2008 Subject: [Haskell-cafe] The state of database libraries Message-ID: Hey everyone, I'm figuring out how to do databases in Haskell (on OS X). So far, I've tried the following approaches: 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I couldn't get this to work under OS X, while I installed myodbc, which seems to be broken. 2. hsql. The packages on hackage don't compile, so I grabbed the darcs version. hqsl itself installed perfectly, but when I try to compile hsql-mysql, it does not recognize that hsql is already installed and tries to recompile. Compiling fails, so I generated a .tar.gz of hsql using cabal sdist, put it in the .cabal/packages directory in the right place, and finally, it does compile. Now hsql-mysql starts compiling, but it finally fails with: MySQL.hsc:270:0: error: ?MYSQL_NO_DATA? undeclared (first use in this function) MySQL.hsc:270:0: error: (Each undeclared identifier is reported only once MySQL.hsc:270:0: error: for each function it appears in.) So what is the state of hsql? And haskelldb? Are they actively maintained? Thanks, -chris From alistair at abayley.org Fri Jul 4 11:16:37 2008 From: alistair at abayley.org (Alistair Bayley) Date: Fri Jul 4 11:07:36 2008 Subject: [Haskell-cafe] The state of database libraries In-Reply-To: References: Message-ID: <79d7c4980807040816r4904d90bs9a012a48ddadf79e@mail.gmail.com> 2008/7/4 Chris Eidhof : > > I'm figuring out how to do databases in Haskell (on OS X). So far, I've tried the following approaches: > > 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I couldn't get this to work under OS X, while I installed myodbc, which seems to be broken. > > 2. hsql. The packages on hackage don't compile, so I grabbed the darcs version. Bummer, dude. The only database library that directly supports MySQL is HSQL. If you want to use another library, you'll have to get the ODBC MySQL backend working. Alistair From Braden.Shepherdson at gmail.com Fri Jul 4 11:34:13 2008 From: Braden.Shepherdson at gmail.com (Braden Shepherdson) Date: Fri Jul 4 11:26:34 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <20080702171440.GC26461@liouville.galois.com> References: <87tzfehfgy.wl%jeremy@n-heptane.com> <200807021626009536167@gmail.com> <20080702171440.GC26461@liouville.galois.com> Message-ID: Don Stewart wrote: > Could we start documenting this on the wiki ? > > It will be interesting to keep track of what we have tried, > what attempts failed and why. > > -- Don > I've added some new sections to the top of the wiki page, above the original attempts. It's now quite long, since it contains details of the problems I encountered trying to build an unregisterised 6.9.20080614 as a first experiment. It ultimately failed because hc-file bootstrapping to a new platform has been broken since 6.8. Only platforms with an existing GHC prior to 6.8 have 6.8 or later now, because of this. A bug[1] has been up since mid-2007 detailing the problem. There's a self-proclaimed "quick hack" diff[2], posted with the following comment: > The diff I uploaded contains some comments inline. It's for ghc-6.8.2 > but also applies to the latest stable snapshot (ghc-6.8.2.20080401). > > As written earlier, it's possible to create a HC file bundle (with > some additional created files) and to build a stage1 compiler with > this. I'm a little bit uncertain how to proceed -- either go ahead > using libcompat (which is a little bit ugly), or try to rebuild all > the libraries immediately with that stage1 compiler (but without using > utils/ghc-pkg, since it's not yet buildable), then build the remaining > tools. The bug is milestoned for 6.10.1, and the owner, Ian Lynagh (Igloo), said on #haskell that 6.10.1 merely meant "soon". So, assuming some GHC dev doesn't swoop down and fix this, what options are left to the project in the short term? An unregisterised build of an old 6.6 should work, that would get us a working, though aging, GHC. Unfortunately a lot of the porting work to move from that first unregisterised build to a registerised one (even without native code-gen) wouldn't be transferable to a later 6.9 or 6.10, since 6.9 has moved from using the Evil Mangler to libffi. As to running GHC on a real ARM device, several steps beyond the first unregisterised build would have to be taken, regardless of GHC version: 1. Registerise it. Pre-6.9, this means porting parts of the Evil Mangler, for which there is a guide. Post-6.9, this is much easier. 2. Native code-gen. Registerised or not, a GHC without native code generation relies on a working gcc. That means a GHC for ARM without NCG would only allow compilation of apps in the development environment, though the binaries should work on the device. 3. Finally, even GHC with native code-gen seems to rely on ld and maybe a few other binutils, but this is much, much lighter than installing all of gcc. So, moving forward I intend to run an unregisterised 6.6 build, just to prove that it can be done. Where we go from there is up in the air. I'd be inclined at that point to wait for 6.10 if #1346 really gets fixed. Fully porting an old version seems like extra work that will hopefully be obsoleted. Comments here or on the wiki page are most welcome, I'll be documenting the quirks and changes for the second attempt with 6.6 there too. And if someone in the GHC know wants to work #1346, they would be my hero. Braden Shepherdson shepheb [1] http://hackage.haskell.org/trac/ghc/ticket/1346 [2] http://hackage.haskell.org/trac/ghc/attachment/ticket/1346/ghc.diff From ramsdell0 at gmail.com Fri Jul 4 15:43:38 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Fri Jul 4 15:34:41 2008 Subject: [Haskell-cafe] Santana on my evil ways Message-ID: <7687290b0807041243s59b4d607s3cffcb123a7b2bc0@mail.gmail.com> My son's nickname is Rama, so let me adopt it. I am a functional programmer, even when I use languages such as C. Scheme facilitated my development into a functional programmer, however, I appreciate the benefits of pure function programming at times. Yet when I use Haskell, I hear reminders of my Scheme past cast in the music of Santana. The words I hear are set to "Eval Ways": You've got to change your evil ways... Rama Before I stop respecting you. You've got to change... Rama And every word that I say, it's true. You use strange syntax and typing And offset rules You don't mutate locations You use strange do's This can't go on... Lord knows you got to change. John From badeadaniel at yahoo.com Fri Jul 4 16:31:07 2008 From: badeadaniel at yahoo.com (Badea Daniel) Date: Fri Jul 4 16:22:07 2008 Subject: [Haskell-cafe] parsec manyTill stack overflow Message-ID: <106476.22823.qm@web34601.mail.mud.yahoo.com> I'm trying to parse a large file looking for instructions on each line and for a section end marker but Parsec's manyTill function causes stack overflow, as you can see in the following example (I'm using ghci 6.8.3): > parse (many anyChar) "" ['a'|x<-[1..1024*64]] It almost immediately starts printing "aaaaaaaaaaa...." and runs to completion. > parse (manyTill anyChar eof) "" ['a'|x<-[1..1024*1024]] *** Exception: stack overflow I guess this happens because manyTill recursively accumulates output from the first parser and returns only when it hits the 'end' parser. Is it possible to write a version of 'manyTill' that works like 'many' returning output from 'anyChar' as soon as it advances through the list of tokens? Thanks, Daniel From felipe.lessa at gmail.com Fri Jul 4 17:11:35 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Jul 4 17:02:35 2008 Subject: [Haskell-cafe] parsec manyTill stack overflow In-Reply-To: <106476.22823.qm@web34601.mail.mud.yahoo.com> References: <106476.22823.qm@web34601.mail.mud.yahoo.com> Message-ID: On Fri, Jul 4, 2008 at 5:31 PM, Badea Daniel wrote: >> parse (manyTill anyChar eof) "" ['a'|x<-[1..1024*1024]] > *** Exception: stack overflow The usual solution applies: move the data from the stack to the heap. Try using manyTill' act end = go [] where go acc = choice [end >> return (reverse acc) ,act >>= \x -> go (x:acc)] -- Felipe. From derek.a.elkins at gmail.com Fri Jul 4 17:22:06 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Jul 4 17:13:09 2008 Subject: [Haskell-cafe] parsec manyTill stack overflow In-Reply-To: <106476.22823.qm@web34601.mail.mud.yahoo.com> References: <106476.22823.qm@web34601.mail.mud.yahoo.com> Message-ID: <1215206526.5892.18.camel@derek-laptop> On Fri, 2008-07-04 at 13:31 -0700, Badea Daniel wrote: > I'm trying to parse a large file looking for instructions on each line and for a section end marker but Parsec's manyTill function causes stack overflow, as you can see in the following example (I'm using ghci 6.8.3): > > > parse (many anyChar) "" ['a'|x<-[1..1024*64]] > > It almost immediately starts printing "aaaaaaaaaaa...." and runs to completion. > > > parse (manyTill anyChar eof) "" ['a'|x<-[1..1024*1024]] > *** Exception: stack overflow > > I guess this happens because manyTill recursively accumulates output > from the first parser and returns only when it hits the 'end' parser. > Is it possible to write a version of 'manyTill' that works like 'many' > returning output from 'anyChar' as soon as it advances through the > list of tokens? No, manyTill doesn't know whether it is going to return anything at all until its second argument succeeds. I can make manyTill not stack overflow, but it will never immediately start returning results. For the particular case above you can use getInput and setInput to get a result that does what you want. parseRest = do rest <- getInput setInput [] return rest That should probably update the position as well though it's not so crucial in the likely use-cases of such a function. From badeadaniel at yahoo.com Fri Jul 4 18:15:34 2008 From: badeadaniel at yahoo.com (Badea Daniel) Date: Fri Jul 4 18:06:33 2008 Subject: [Haskell-cafe] parsec manyTill stack overflow In-Reply-To: <1215206526.5892.18.camel@derek-laptop> Message-ID: <109957.32026.qm@web34602.mail.mud.yahoo.com> The file I'm trying to parse contains mixed sections like: ... ... so I defined two parsers: one for the 'outer' language and the other one for the 'inner' language. I used (manyTill inner_parser end_section_parser) but I got a stack overflow because there's just too much text between section begin and end. With getInput I can switch from the outer parser to the inner parser but this one tries to parse until eof and when it hits the '/end_section>' it fails. --- On Fri, 7/4/08, Derek Elkins wrote: > From: Derek Elkins > Subject: Re: [Haskell-cafe] parsec manyTill stack overflow > To: "Badea Daniel" > Cc: haskell-cafe@haskell.org > Date: Friday, July 4, 2008, 2:22 PM > On Fri, 2008-07-04 at 13:31 -0700, Badea Daniel wrote: > > I'm trying to parse a large file looking for > instructions on each line and for a section end marker but > Parsec's manyTill function causes stack overflow, as > you can see in the following example (I'm using ghci > 6.8.3): > > > > > parse (many anyChar) "" > ['a'|x<-[1..1024*64]] > > > > It almost immediately starts printing > "aaaaaaaaaaa...." and runs to completion. > > > > > parse (manyTill anyChar eof) "" > ['a'|x<-[1..1024*1024]] > > *** Exception: stack overflow > > > > I guess this happens because manyTill recursively > accumulates output > > from the first parser and returns only when it hits > the 'end' parser. > > Is it possible to write a version of > 'manyTill' that works like 'many' > > returning output from 'anyChar' as soon as it > advances through the > > list of tokens? > > No, manyTill doesn't know whether it is going to return > anything at all > until its second argument succeeds. I can make manyTill > not stack > overflow, but it will never immediately start returning > results. For > the particular case above you can use getInput and setInput > to get a > result that does what you want. > > parseRest = do > rest <- getInput > setInput [] > return rest > > That should probably update the position as well though > it's not so > crucial in the likely use-cases of such a function. From jonathanccast at fastmail.fm Fri Jul 4 18:29:33 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Jul 4 18:20:33 2008 Subject: [Haskell-cafe] parsec manyTill stack overflow In-Reply-To: <109957.32026.qm@web34602.mail.mud.yahoo.com> References: <109957.32026.qm@web34602.mail.mud.yahoo.com> Message-ID: <1215210573.6257.7.camel@jonathans-macbook> On Fri, 2008-07-04 at 15:15 -0700, Badea Daniel wrote: > The file I'm trying to parse contains mixed sections like: > > ... > > > ... script including arithmetic expressions ... > > /end_section> > > ... > > so I defined two parsers: one for the 'outer' language and > the other one for the 'inner' language. I used (manyTill > inner_parser end_section_parser) Does inner_parser (or a parser it calls) recognize `/end_section'? If not, I don't think you actually need manyTill. If so, that's more difficult. Two thoughts: * This design looks vaguely XML-ish; is it possible to use a two-stage parser, recognizing but not parsing the arithmetic expressions and then looping back over the parse tree later? * If the part of inner_parser that would recognize /end_section (presumably as a division operator followed by an identifier?) is well isolated, you could locally exclude it there; e.g., instead of divison_operator = operator "/" say division_operatory = try $ do satisfy (=='/') notFollowedBy (string "end_section") whitespace (Or reverse the order or notFollowedBy and whitespace). jcc From badeadaniel at yahoo.com Fri Jul 4 18:44:53 2008 From: badeadaniel at yahoo.com (Badea Daniel) Date: Fri Jul 4 18:35:52 2008 Subject: [Haskell-cafe] parsec manyTill stack overflow In-Reply-To: <1215210573.6257.7.camel@jonathans-macbook> Message-ID: <500056.11562.qm@web34608.mail.mud.yahoo.com> I'm using makeTokenParser and buildExpressionParser for the inner_parser. Thanks for your thoughts, I'll use a two-stage parser that looks for /end_section> and stores tokens in heap and then getInput/setInput to feed the inner_parser. --- On Fri, 7/4/08, Jonathan Cast wrote: > From: Jonathan Cast > Subject: Re: [Haskell-cafe] parsec manyTill stack overflow > To: badeadaniel@yahoo.com > Cc: "Derek Elkins" , haskell-cafe@haskell.org > Date: Friday, July 4, 2008, 3:29 PM > On Fri, 2008-07-04 at 15:15 -0700, Badea Daniel wrote: > > The file I'm trying to parse contains mixed > sections like: > > > > ... > > > > > > > ... script including arithmetic expressions ... > > > > /end_section> > > > > ... > > > > so I defined two parsers: one for the 'outer' > language and > > the other one for the 'inner' language. I > used (manyTill > > inner_parser end_section_parser) > > Does inner_parser (or a parser it calls) recognize > `/end_section'? If > not, I don't think you actually need manyTill. If so, > that's more > difficult. Two thoughts: > > * This design looks vaguely XML-ish; is it possible to use > a two-stage > parser, recognizing but not parsing the arithmetic > expressions and then > looping back over the parse tree later? > > * If the part of inner_parser that would recognize > /end_section > (presumably as a division operator followed by an > identifier?) is well > isolated, you could locally exclude it there; e.g., instead > of > > divison_operator = operator "/" > > say > > division_operatory = try $ do > satisfy (=='/') > notFollowedBy (string "end_section") > whitespace > > (Or reverse the order or notFollowedBy and whitespace). > > jcc From qdunkan at gmail.com Fri Jul 4 21:02:18 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Jul 4 20:53:17 2008 Subject: [Haskell-cafe] nested parsing? Message-ID: <2518b95d0807041802w5d38f99n22de2bae0a6c9002@mail.gmail.com> Here's something I occasionally want to do with parsec: msg = do header body <- manyTill anyToken footer vals <- sub_parse parse_body (preprocess body) ... By coincidence I notice that perhaps the "manyTill stack overflow" thread could use something like this too. So I wrote: sub_parse :: Parsec.GenParser subtok st a -> [subtok] -> Parsec.GenParser tok st a sub_parse parser toks = do st <- Parsec.getState pos <- Parsec.getPosition case Parsec.runParser (Parsec.setPosition pos >> parser) st "" toks of Left err -> fail (show err) Right val -> return val -- oh yes, and I'd set the state to the final sub parse state too In this particular case, I found another solution that didn't need sub-parsing, so I haven't actually tested this much. In particular parsec doesn't let me throw a "raw" exception so I have to use "fail" and the error msgs look ugly. In addition, if 'preprocess' adds or removes tokens from 'body', I have to do something awkward like pass tokens around as (pos, tok). But come to think of it, I've done this pattern before, where I invoke a sub-monad and (mostly) splice it in with the current one, in one case to allow the submonad to be monomorphic on the monad type while calling monad remains polymorphic, in another case so I can run the submonad from dynamically loaded code which must be monomorphic but splice its results into the polymorphic calling monad... this is similar to the first one I guess. It seems somewhat similar to what catchError is doing. From vigalchin at gmail.com Sat Jul 5 00:06:12 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Jul 4 23:57:11 2008 Subject: [Haskell-cafe] eyes again please .... on my POSIX aio code Message-ID: <5ae4f2ba0807042106j4c3d1426x1b98b5df9eeeea6f@mail.gmail.com> Hello, I have modified my aioError and aioReturn to hopefully be more in line with the actual aio_error and aio_return signatures, respectively. In the first implementation I had suffered a serious brain f**t ... oh well ..... The implementations below are still somewhat preliminary. Not seemingly rocket science .... I am still not getting a correct count from aioReturn .. should be 20 but I get 0! I have a C program which behaves properly giving 20 for aio_return! grrrrrr! aioReturn :: AIOCB -> IO (AIOCB, ByteCount) aioReturn aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb -- DO A PEEK HERE!!!!! -- count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return p_aiocb) count <- (c_aio_return p_aiocb) putStrLn ("count -> " ++ (show count)) aiocb <- peek p_aiocb putStrLn "aioReturn" aiocb1 <- peek p_aiocb dumpAIOCB aiocb1 return (aiocb, fromIntegral count) foreign import ccall safe "aio.h aio_return" c_aio_return :: Ptr AIOCB -> IO CInt aioError :: AIOCB -> IO (Errno) aioError aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb --throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) errno <- (c_aio_error p_aiocb) putStrLn ("errno -> " ++ (show errno)) putStrLn "aioError" aiocb1 <- peek p_aiocb dumpAIOCB aiocb1 return (Errno errno) foreign import ccall safe "aio.h aio_error" c_aio_error :: Ptr AIOCB -> IO CInt I added an internal helper function dumpAIOCB to print out the aiocb at points for sanity checking!! dumpAIOCB :: AIOCB -> IO () dumpAIOCB (AIOCB aioFd aioLioOpcode aioReqPrio aioOffset aioBuf aioBytes aioSigevent) = do putStrLn "aiocb dump" putStrLn ("fd => " ++ (show aioFd)) putStrLn ("opcode => " ++ (show aioLioOpcode)) putStrLn ("prio => " ++ (show aioReqPrio)) putStrLn ("offset => " ++ (show aioOffset)) -- aioBuf putStrLn ("nbytes => " ++ (show aioBytes) ++ "\n") -- aioSigevent Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080704/7a816677/attachment.htm From p.a.visschers at student.tue.nl Sat Jul 5 05:12:53 2008 From: p.a.visschers at student.tue.nl (Paul Visschers) Date: Sat Jul 5 05:03:52 2008 Subject: [Haskell-cafe] The state of database libraries In-Reply-To: References: Message-ID: <486F3B15.1040508@student.tue.nl> Hey Chris, I've been fiddling around with the database stuff myself and I had the same problems (on Linux). I eventually got both HaskellDB and HSQL to work, and am now using HSQL because HaskellDB had very poor documentation. I don't exactly know how I eventually got HSQL-MySQL to work, but I think it might be the case that you need to install a MySQL dev package first, as the haskell package only contains bindings to it. Good Luck, Paul P.S. It's nice to see I'm not the only one going into a Haskell frenzy after the exams. Chris Eidhof wrote: > Hey everyone, > > I'm figuring out how to do databases in Haskell (on OS X). So far, I've > tried the following approaches: > > 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I > couldn't get this to work under OS X, while I installed myodbc, which > seems to be broken. > > 2. hsql. The packages on hackage don't compile, so I grabbed the darcs > version. hqsl itself installed perfectly, but when I try to compile > hsql-mysql, it does not recognize that hsql is already installed and > tries to recompile. Compiling fails, so I generated a .tar.gz of hsql > using cabal sdist, put it in the .cabal/packages directory in the right > place, and finally, it does compile. Now hsql-mysql starts compiling, > but it finally fails with: > > MySQL.hsc:270:0: > error: ?MYSQL_NO_DATA? undeclared (first use in this function) > > MySQL.hsc:270:0: > error: (Each undeclared identifier is reported only once > > MySQL.hsc:270:0: error: for each function it appears in.) > > So what is the state of hsql? And haskelldb? Are they actively maintained? > > Thanks, > -chris_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ndmitchell at gmail.com Sat Jul 5 19:00:07 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jul 5 18:51:04 2008 Subject: [Haskell-cafe] Definition of hidden instance members (bug in GHC or Hugs+Yhc) Message-ID: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> Hi, This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but the compilers disagree: import Prelude hiding ((==)) data Foo = Foo instance Eq Foo where (==) a b = True GHC says: Temp.hs:14:4: `==' is not a (visible) method of class `Eq' Yhc and Hugs both successfully compile the module. Does anyone know which compiler(s) are in the wrong, and need bugs filing? Thanks Neil From ndmitchell at gmail.com Sat Jul 5 19:02:52 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jul 5 18:53:48 2008 Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc) In-Reply-To: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> References: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> Message-ID: <404396ef0807051602g44b6ca81u39a2b3ee37492065@mail.gmail.com> > This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but > the compilers disagree: > > import Prelude hiding ((==)) > data Foo = Foo > instance Eq Foo where > (==) a b = True I was thinking that GHC's behaviour seems more sensible, but the following fails: import qualified Module as M instance MClass Foo where M.foo = undefined M. is not allowed as a prefix of a function, which makes resolving ambiguities hard unless the compiler solves the issue for you (as Hugs and Yhc do) Thanks Neil From ross at soi.city.ac.uk Sat Jul 5 19:10:44 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sat Jul 5 19:01:43 2008 Subject: [Haskell-cafe] Definition of hidden instance members (bug in GHC or Hugs+Yhc) In-Reply-To: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> References: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> Message-ID: <20080705231044.GA9350@soi.city.ac.uk> On Sun, Jul 06, 2008 at 12:00:07AM +0100, Neil Mitchell wrote: > This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but > the compilers disagree: > > import Prelude hiding ((==)) > data Foo = Foo > instance Eq Foo where > (==) a b = True > > GHC says: > Temp.hs:14:4: `==' is not a (visible) method of class `Eq' > > Yhc and Hugs both successfully compile the module. > > Does anyone know which compiler(s) are in the wrong, and need bugs filing? GHC is correct. Report 4.3.2: "It is illegal to give a binding for a class method that is not in scope, but the name under which it is in scope is immaterial; in particular, it may be a qualified name." In this case neither == nor Prelude.== is in scope. From allbery at ece.cmu.edu Sat Jul 5 19:14:56 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jul 5 19:05:52 2008 Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc) In-Reply-To: <404396ef0807051602g44b6ca81u39a2b3ee37492065@mail.gmail.com> References: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> <404396ef0807051602g44b6ca81u39a2b3ee37492065@mail.gmail.com> Message-ID: On 2008 Jul 5, at 19:02, Neil Mitchell wrote: >> This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but >> the compilers disagree: >> >> import Prelude hiding ((==)) >> data Foo = Foo >> instance Eq Foo where >> (==) a b = True > > I was thinking that GHC's behaviour seems more sensible, but the > following fails: > > import qualified Module as M > > instance MClass Foo where > M.foo = undefined > > M. is not allowed as a prefix of a function, which makes resolving > ambiguities hard unless the compiler solves the issue for you (as Hugs > and Yhc do) But this works for me in ghc: foo.hs: > import Mod as M > > data Bar a = Bar Int a > > instance M.MClass (Bar a) where > foo _ = M.foozero > foozero = Bar 0 (undefined :: a) > > main = putStrLn "foo" Mod.hs: > module Mod where > > class MClass a where > foo :: a -> a > foozero :: a -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From claus.reinke at talk21.com Sat Jul 5 19:15:02 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Jul 5 19:06:05 2008 Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug inGHC or Hugs+Yhc) References: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> <404396ef0807051602g44b6ca81u39a2b3ee37492065@mail.gmail.com> Message-ID: <067401c8def4$f591f8f0$72137ad5@cr3lt> > M. is not allowed as a prefix of a function, which makes resolving > ambiguities hard unless the compiler solves the issue for you (as Hugs > and Yhc do) See also: http://www.haskell.org/pipermail/haskell-prime/2008-April/002569.html http://hackage.haskell.org/trac/ghc/ticket/2237 Claus From matth at mindspring.com Sat Jul 5 22:35:52 2008 From: matth at mindspring.com (matth@mindspring.com) Date: Sat Jul 5 22:12:05 2008 Subject: [Haskell-cafe] I/O system brokenness with named pipes In-Reply-To: <1207910394.9923.3.camel@dell.linuxdev.us.dell.com> References: <1207910394.9923.3.camel@dell.linuxdev.us.dell.com> Message-ID: <20080706023552.GA4492@pythagoras.hardenhome> On Fri, Apr 11, 2008 at 12:39:54PM +0200, Duncan Coutts wrote: > > On Thu, 2008-04-10 at 20:34 -0500, John Goerzen wrote: > > > I have created the named pipe from Haskell no problem. > > > > But I can't use writeFile to write data to it. Worse, it returns: > > > > *** Exception: /tmp/bakroller.zD0xHj/fifo: openFile: does not exist > > (No such device or address) > > > What's going on here? Am I going to have to resort to the > > System.Posix interface just to be able to write to a named pipe? > > Named pipes have broken semantics for non-blocking IO, see google or the > man pages on named pipes. GHC's standard Handle IO always sets file > descriptor to non-blocking mode. That's the problem. That's why cat > works, because it uses blocking IO. > > You would indeed need to use System.Posix to get a FD in blocking mode. > Then you have to worry a bit about blocking other Haskell thread when > you block on writing to the pipe. You could also work around this, at least on Linux, by opening the file in ReadMode before opening it in WriteMode. Hold the reading file handle open until you close the writing handle. Never read from the reading handle. In my testing, this worked well, but bear in mind that when the other readers close the pipe, further writes will "block" rather than produce a SIGPIPE. Matt From mfeathers at mindspring.com Sun Jul 6 13:06:34 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Sun Jul 6 13:02:42 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <1213332464.3124.14.camel@localhost.localdomain> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> Message-ID: <4870FB9A.5090800@mindspring.com> I have some code that looks like this and I'm having trouble with it: zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) groundSpeeds headings (map windShift headings) (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] (nub . nub) arrivalSchedule The domain is air traffic control and I need to generate 12-tuples for aircraft that are within a particular radius of the tower. When I evaluate that expression with 'take 4' it works fine. When I evaluate it with 'take 6' it works as well. But, when I evaluate it with 'take 5' I get the following runtime error from H# in Visual Studio (it runs fine on the command line). This is particularly odd because I'm not using Sql. The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. Exception (TypeInitializationException): Source="System.Data"; Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; Message = "The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception." InnerException (TypeInitializationException): Source="System.Data"; Target=null; Tag=null; Message = "The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception." StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" InnerException (TypeInitializationException): Source="System.Data"; Target=null; Tag=null; Message = "The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." StackTrace = " at System.Data.SqlClient.SqlConnectionFactory..ctor() at System.Data.SqlClient.SqlConnectionFactory..cctor()" InnerException (ConfigurationErrorsException): Source="System.Configuration"; Target=null; Tag=null; Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" StackTrace = " at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean ch... (truncated) ...olean checkPermission) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName) at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() at System.Diagnostics.DiagnosticsConfiguration.Initialize() at System.Diagnostics.Switch.InitializeConfigSettings() at System.Diagnostics.Switch.InitializeWithStatus() at System.Diagnostics.Switch.get_SwitchSetting() at System.Diagnostics.TraceSwitch.get_Level() at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp) at System.Data.SqlClient.SqlPerformanceCounters..ctor() at System.Data.SqlClient.SqlPerformanceCounters..cctor()" BareMessage = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack." Filename = "C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); Line=21; Message = "The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21)" Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; #0 = {System.Configuration.ConfigurationErrorsException: The value of the property 'traceOutputOptions' cannot be parsed. The error is: The enumeration value must be one of the following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack. (C:\Documents and Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is EmsInnerException helper object) --- End of inner exception stack trace ---} Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] Values = System.Configuration.ConfigurationException[] TypeName = "System.Data.SqlClient.SqlPerformanceCounters" TypeName = "System.Data.SqlClient.SqlConnectionFactory" Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 Service Pack 3"] MachineName="1LPPley" UserName="Pley" Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - at System.Data.SqlClient.SqlConnection..ctor() at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack) at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack) at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, Boolean RegisterNotification) at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute) at MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String UserName) at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String Username, String Password, String Domain, SFSUsersBO& User) at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, EventArgs e) at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in C:\Documents and Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Comments: EMS warning: maximum number of iterations reached when processing objects. From dons at galois.com Sun Jul 6 14:13:08 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 6 14:04:03 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <4870FB9A.5090800@mindspring.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> Message-ID: <20080706181308.GA31871@liouville.galois.com> mfeathers: > > > I have some code that looks like this and I'm having trouble with it: > > > zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) > groundSpeeds headings (map windShift headings) (regulations !! 2) > (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] > (nub . nub) arrivalSchedule > > The domain is air traffic control and I need to generate 12-tuples for > aircraft that are within a particular radius of the tower. 12 tuples are really really unusual. It sounds like perhaps you should be using a custom data type here. data Aircraft = Aircraft { wayPoints = currentWayPoints , groundSpeeds = ... , headings = ... , .... etc ... } From p.a.visschers at student.tue.nl Sun Jul 6 16:36:01 2008 From: p.a.visschers at student.tue.nl (Paul Visschers) Date: Sun Jul 6 16:26:52 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <4870FB9A.5090800@mindspring.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> Message-ID: <48712CB1.2010105@student.tue.nl> You're zipping 12 lists here, so how about testing each list individually? This will narrow down the problem considerably. Michael Feathers wrote: > > > I have some code that looks like this and I'm having trouble with it: > > > zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) > groundSpeeds headings (map windShift headings) (regulations !! 2) > (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] > (nub . nub) arrivalSchedule > > > The domain is air traffic control and I need to generate 12-tuples for > aircraft that are within a particular radius of the tower. > > When I evaluate that expression with 'take 4' it works fine. When I > evaluate it with 'take 6' it works as well. But, when I evaluate it > with 'take 5' I get the following runtime error from H# in Visual Studio > (it runs fine on the command line). This is particularly odd because > I'm not using Sql. > > > > The type initializer for 'System.Data.SqlClient.SqlConnection' threw an > exception. > Exception (TypeInitializationException): Source="System.Data"; > Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; > Message = "The type initializer for > 'System.Data.SqlClient.SqlConnection' threw an exception." > InnerException (TypeInitializationException): Source="System.Data"; > Target=null; Tag=null; > Message = "The type initializer for > 'System.Data.SqlClient.SqlConnectionFactory' threw an exception." > StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" > InnerException (TypeInitializationException): Source="System.Data"; > Target=null; Tag=null; > Message = "The type initializer for > 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." > StackTrace = > " at System.Data.SqlClient.SqlConnectionFactory..ctor() > at System.Data.SqlClient.SqlConnectionFactory..cctor()" > InnerException (ConfigurationErrorsException): > Source="System.Configuration"; Target=null; Tag=null; Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > StackTrace = > " at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] > keys, SectionInput input, Boolean isTrusted, FactoryRecord > factoryRecord, SectionRecord sectionRecord, Object parentResult) > at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord > factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean > getLkg, Boolean getRuntimeObject, Object& result, Object& > resultRuntimeObject) > at > System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String > configKey, Boolean getLkg, Boolean checkPermission, Boolean > getRuntimeObject, Boolean requestIsHere, Object& result, Object& > resultRuntimeObject) > at > System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String > configKey, Boolean getLkg, Boolean checkPermission, Boolean > getRuntimeObject, Boolean requestIsHere, Object& result, Object& > resultRuntimeObject) > at > System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String > configKey, Boolean getLkg, Boolean ch... (truncated) ...olean > checkPermission) > at System.Configuration.BaseConfigurationRecord.GetSection(String > configKey) > at > System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String > sectionName) > at System.Configuration.ConfigurationManager.GetSection(String sectionName) > at System.Configuration.PrivilegedConfigurationManager.GetSection(String > sectionName) > at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() > at System.Diagnostics.DiagnosticsConfiguration.Initialize() > at System.Diagnostics.Switch.InitializeConfigSettings() > at System.Diagnostics.Switch.InitializeWithStatus() > at System.Diagnostics.Switch.get_SwitchSetting() > at System.Diagnostics.TraceSwitch.get_Level() > at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String > categoryName, String categoryHelp) > at System.Data.SqlClient.SqlPerformanceCounters..ctor() > at System.Data.SqlClient.SqlPerformanceCounters..cctor()" > BareMessage = "The value of the property 'traceOutputOptions' cannot be > parsed. The error is: The enumeration value must be one of the > following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, > ThreadId, Callstack." > Filename = "C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line > 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > Line=21; > Message = > "The value of the property 'traceOutputOptions' cannot be parsed. The > error is: The enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21)" > Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > #0 = > {System.Configuration.ConfigurationErrorsException: The value of the > property 'traceOutputOptions' cannot be parsed. The error is: The > enumeration value must be one of the following: None, > LogicalOperationStack, DateTime, Timestamp, ProcessId, > ThreadId, Callstack. (C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is > EmsInnerException helper object) > --- End of inner exception stack trace ---} > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > Values = System.Configuration.ConfigurationException[] > TypeName = "System.Data.SqlClient.SqlPerformanceCounters" > TypeName = "System.Data.SqlClient.SqlConnectionFactory" > Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] > ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" > DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 > Service Pack 3"] MachineName="1LPPley" > UserName="Pley" > Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - - - - - - - - - - - - > at System.Data.SqlClient.SqlConnection..ctor() > at System.Data.SqlClient.SqlConnection..ctor(String connectionString) > at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() > at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand > Command, OnChangeEventHandler CallBack) > at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand > Command, OnChangeEventHandler CallBack) > at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, > Boolean RegisterNotification) > at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand > CommandToExecute) > at > MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String > UserName) > at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String > Username, String Password, String Domain, SFSUsersBO& User) > at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, > EventArgs e) > at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 > at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in > C:\Documents and > Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 > at System.Windows.Forms.Control.OnClick(EventArgs e) > at System.Windows.Forms.Button.OnClick(EventArgs e) > at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons > button, Int32 clicks) > at System.Windows.Forms.Control.WndProc(Message& m) > at System.Windows.Forms.ButtonBase.WndProc(Message& m) > at System.Windows.Forms.Button.WndProc(Message& m) > at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) > at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) > at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, > IntPtr wparam, IntPtr lparam) > Comments: > EMS warning: maximum number of iterations reached when processing objects. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tmorris at tmorris.net Sun Jul 6 16:47:07 2008 From: tmorris at tmorris.net (Tony Morris) Date: Sun Jul 6 16:38:06 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <4870FB9A.5090800@mindspring.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> Message-ID: <48712F4B.9040304@tmorris.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael Feathers wrote: > > > I have some code that looks like this and I'm having trouble with > it: > > > zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd > geoCaches) groundSpeeds headings (map windShift headings) > (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x <- > [1..], full x] (nub . nub) arrivalSchedule Hi Michael, Sorry to distract from your issue, but I note that (nub . nub) can be replaced with just 'nub' since the function nub is idempotent (f . f == f). @check \x -> (nub . nub) x == nub x -- is nub idempotent? OK, passed 500 tests. - -- Tony Morris http://tmorris.net/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIcS9LmnpgrYe6r60RAiDOAKCJlDaqNd5ssgxrUrrHee75WGzhbgCfftdn 70+4isXh4zaoYly0da2Gdk8= =ryfF -----END PGP SIGNATURE----- From mfeathers at mindspring.com Sun Jul 6 16:58:55 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Sun Jul 6 16:55:00 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <48712CB1.2010105@student.tue.nl> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> <48712CB1.2010105@student.tue.nl> Message-ID: <4871320F.6070603@mindspring.com> Sorry guys. I was just bored on a Sunday afternoon so I thought I'd type up a little joke. I thought to myself "Gee, how outrageous can I make it?" 1) Using and debugging a zip12 function. 2) That fails only on 'take 5' (Brubeck fans take note) 3) Has some absurd arguments like (nub . nub) 4) Is embedded in an air traffic control system 5) Is written in a Microsoft variant of Haskell called H# 6) Silently makes SQL calls when evaluating a pure function 7) Yields an mile long stack trace Sorry all. Boredom made me do it, Michael Paul Visschers wrote: > You're zipping 12 lists here, so how about testing each list > individually? This will narrow down the problem considerably. > > Michael Feathers wrote: >> >> I have some code that looks like this and I'm having trouble with it: >> >> >> zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) >> groundSpeeds headings (map windShift headings) (regulations !! 2) >> (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] >> (nub . nub) arrivalSchedule >> >> >> The domain is air traffic control and I need to generate 12-tuples for >> aircraft that are within a particular radius of the tower. >> >> When I evaluate that expression with 'take 4' it works fine. When I >> evaluate it with 'take 6' it works as well. But, when I evaluate it >> with 'take 5' I get the following runtime error from H# in Visual Studio >> (it runs fine on the command line). This is particularly odd because >> I'm not using Sql. >> >> >> >> The type initializer for 'System.Data.SqlClient.SqlConnection' threw an >> exception. >> Exception (TypeInitializationException): Source="System.Data"; >> Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; >> Message = "The type initializer for >> 'System.Data.SqlClient.SqlConnection' threw an exception." >> InnerException (TypeInitializationException): Source="System.Data"; >> Target=null; Tag=null; >> Message = "The type initializer for >> 'System.Data.SqlClient.SqlConnectionFactory' threw an exception." >> StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" >> InnerException (TypeInitializationException): Source="System.Data"; >> Target=null; Tag=null; >> Message = "The type initializer for >> 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." >> StackTrace = >> " at System.Data.SqlClient.SqlConnectionFactory..ctor() >> at System.Data.SqlClient.SqlConnectionFactory..cctor()" >> InnerException (ConfigurationErrorsException): >> Source="System.Configuration"; Target=null; Tag=null; Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> StackTrace = >> " at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] >> keys, SectionInput input, Boolean isTrusted, FactoryRecord >> factoryRecord, SectionRecord sectionRecord, Object parentResult) >> at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord >> factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean >> getLkg, Boolean getRuntimeObject, Object& result, Object& >> resultRuntimeObject) >> at >> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >> configKey, Boolean getLkg, Boolean checkPermission, Boolean >> getRuntimeObject, Boolean requestIsHere, Object& result, Object& >> resultRuntimeObject) >> at >> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >> configKey, Boolean getLkg, Boolean checkPermission, Boolean >> getRuntimeObject, Boolean requestIsHere, Object& result, Object& >> resultRuntimeObject) >> at >> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >> configKey, Boolean getLkg, Boolean ch... (truncated) ...olean >> checkPermission) >> at System.Configuration.BaseConfigurationRecord.GetSection(String >> configKey) >> at >> System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String >> sectionName) >> at System.Configuration.ConfigurationManager.GetSection(String sectionName) >> at System.Configuration.PrivilegedConfigurationManager.GetSection(String >> sectionName) >> at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() >> at System.Diagnostics.DiagnosticsConfiguration.Initialize() >> at System.Diagnostics.Switch.InitializeConfigSettings() >> at System.Diagnostics.Switch.InitializeWithStatus() >> at System.Diagnostics.Switch.get_SwitchSetting() >> at System.Diagnostics.TraceSwitch.get_Level() >> at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String >> categoryName, String categoryHelp) >> at System.Data.SqlClient.SqlPerformanceCounters..ctor() >> at System.Data.SqlClient.SqlPerformanceCounters..cctor()" >> BareMessage = "The value of the property 'traceOutputOptions' cannot be >> parsed. The error is: The enumeration value must be one of the >> following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, >> ThreadId, Callstack." >> Filename = "C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line >> 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> Line=21; >> Message = >> "The value of the property 'traceOutputOptions' cannot be parsed. The >> error is: The enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21)" >> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> #0 = >> {System.Configuration.ConfigurationErrorsException: The value of the >> property 'traceOutputOptions' cannot be parsed. The error is: The >> enumeration value must be one of the following: None, >> LogicalOperationStack, DateTime, Timestamp, ProcessId, >> ThreadId, Callstack. (C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is >> EmsInnerException helper object) >> --- End of inner exception stack trace ---} >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> Values = System.Configuration.ConfigurationException[] >> TypeName = "System.Data.SqlClient.SqlPerformanceCounters" >> TypeName = "System.Data.SqlClient.SqlConnectionFactory" >> Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] >> ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" >> DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 >> Service Pack 3"] MachineName="1LPPley" >> UserName="Pley" >> Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - >> - - - - - - - - - - - - - - - - - - - - - - >> at System.Data.SqlClient.SqlConnection..ctor() >> at System.Data.SqlClient.SqlConnection..ctor(String connectionString) >> at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() >> at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand >> Command, OnChangeEventHandler CallBack) >> at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand >> Command, OnChangeEventHandler CallBack) >> at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, >> Boolean RegisterNotification) >> at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand >> CommandToExecute) >> at >> MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String >> UserName) >> at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String >> Username, String Password, String Domain, SFSUsersBO& User) >> at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, >> EventArgs e) >> at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 >> at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in >> C:\Documents and >> Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 >> at System.Windows.Forms.Control.OnClick(EventArgs e) >> at System.Windows.Forms.Button.OnClick(EventArgs e) >> at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) >> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons >> button, Int32 clicks) >> at System.Windows.Forms.Control.WndProc(Message& m) >> at System.Windows.Forms.ButtonBase.WndProc(Message& m) >> at System.Windows.Forms.Button.WndProc(Message& m) >> at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) >> at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) >> at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, >> IntPtr wparam, IntPtr lparam) >> Comments: >> EMS warning: maximum number of iterations reached when processing objects. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Now Playing: Clammbon - 246 http://youtube.com/watch?v=PO77bN8W1mA From dons at galois.com Sun Jul 6 17:07:37 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 6 16:58:34 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <4871320F.6070603@mindspring.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> <48712CB1.2010105@student.tue.nl> <4871320F.6070603@mindspring.com> Message-ID: <20080706210737.GC31871@liouville.galois.com> I win, almost ... 13:13:18 dolio: yeah, it was ... almost ... an April 1 style post :) And yes, this was truly shocking on a number of levels. However, we have people doing a lot of weird things with Haskell these days, so its not as absurd that someone would be hacking up a zip12 for an air traffic control system on some MS platform, with SQL in the backend, as it might have been a few years ago :) mfeathers: > > Sorry guys. I was just bored on a Sunday afternoon so I thought I'd > type up a little joke. I thought to myself "Gee, how outrageous can I > make it?" > > 1) Using and debugging a zip12 function. > 2) That fails only on 'take 5' (Brubeck fans take note) > 3) Has some absurd arguments like (nub . nub) > 4) Is embedded in an air traffic control system > 5) Is written in a Microsoft variant of Haskell called H# > 6) Silently makes SQL calls when evaluating a pure function > 7) Yields an mile long stack trace > > Sorry all. Boredom made me do it, > > Michael > > Paul Visschers wrote: > >You're zipping 12 lists here, so how about testing each list > >individually? This will narrow down the problem considerably. > > > >Michael Feathers wrote: > >> > >>I have some code that looks like this and I'm having trouble with it: > >> > >> > >>zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) > >> groundSpeeds headings (map windShift headings) (regulations !! 2) > >> (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] > >> (nub . nub) arrivalSchedule > >> > >> > >>The domain is air traffic control and I need to generate 12-tuples for > >>aircraft that are within a particular radius of the tower. > >> > >>When I evaluate that expression with 'take 4' it works fine. When I > >>evaluate it with 'take 6' it works as well. But, when I evaluate it > >>with 'take 5' I get the following runtime error from H# in Visual Studio > >>(it runs fine on the command line). This is particularly odd because > >>I'm not using Sql. > >> > >> > >> > >>The type initializer for 'System.Data.SqlClient.SqlConnection' threw an > >>exception. > >>Exception (TypeInitializationException): Source="System.Data"; > >>Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; > >>Message = "The type initializer for > >>'System.Data.SqlClient.SqlConnection' threw an exception." > >>InnerException (TypeInitializationException): Source="System.Data"; > >>Target=null; Tag=null; > >>Message = "The type initializer for > >>'System.Data.SqlClient.SqlConnectionFactory' threw an exception." > >>StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" > >>InnerException (TypeInitializationException): Source="System.Data"; > >>Target=null; Tag=null; > >>Message = "The type initializer for > >>'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." > >>StackTrace = > >>" at System.Data.SqlClient.SqlConnectionFactory..ctor() > >>at System.Data.SqlClient.SqlConnectionFactory..cctor()" > >>InnerException (ConfigurationErrorsException): > >>Source="System.Configuration"; Target=null; Tag=null; Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>StackTrace = > >>" at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] > >>keys, SectionInput input, Boolean isTrusted, FactoryRecord > >>factoryRecord, SectionRecord sectionRecord, Object parentResult) > >>at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord > >>factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean > >>getLkg, Boolean getRuntimeObject, Object& result, Object& > >>resultRuntimeObject) > >>at > >>System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String > >>configKey, Boolean getLkg, Boolean checkPermission, Boolean > >>getRuntimeObject, Boolean requestIsHere, Object& result, Object& > >>resultRuntimeObject) > >>at > >>System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String > >>configKey, Boolean getLkg, Boolean checkPermission, Boolean > >>getRuntimeObject, Boolean requestIsHere, Object& result, Object& > >>resultRuntimeObject) > >>at > >>System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String > >>configKey, Boolean getLkg, Boolean ch... (truncated) ...olean > >>checkPermission) > >>at System.Configuration.BaseConfigurationRecord.GetSection(String > >>configKey) > >>at > >>System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String > >>sectionName) > >>at System.Configuration.ConfigurationManager.GetSection(String > >>sectionName) > >>at System.Configuration.PrivilegedConfigurationManager.GetSection(String > >>sectionName) > >>at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() > >>at System.Diagnostics.DiagnosticsConfiguration.Initialize() > >>at System.Diagnostics.Switch.InitializeConfigSettings() > >>at System.Diagnostics.Switch.InitializeWithStatus() > >>at System.Diagnostics.Switch.get_SwitchSetting() > >>at System.Diagnostics.TraceSwitch.get_Level() > >>at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String > >>categoryName, String categoryHelp) > >>at System.Data.SqlClient.SqlPerformanceCounters..ctor() > >>at System.Data.SqlClient.SqlPerformanceCounters..cctor()" > >>BareMessage = "The value of the property 'traceOutputOptions' cannot be > >>parsed. The error is: The enumeration value must be one of the > >>following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, > >>ThreadId, Callstack." > >>Filename = "C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line > >>21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; > >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); > >>Line=21; > >>Message = > >>"The value of the property 'traceOutputOptions' cannot be parsed. The > >>error is: The enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, > >>Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21)" > >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; > >>#0 = > >>{System.Configuration.ConfigurationErrorsException: The value of the > >>property 'traceOutputOptions' cannot be parsed. The error is: The > >>enumeration value must be one of the following: None, > >>LogicalOperationStack, DateTime, Timestamp, ProcessId, > >>ThreadId, Callstack. (C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config > >>line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is > >>EmsInnerException helper object) > >>--- End of inner exception stack trace ---} > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>Values = System.Configuration.ConfigurationException[] > >>TypeName = "System.Data.SqlClient.SqlPerformanceCounters" > >>TypeName = "System.Data.SqlClient.SqlConnectionFactory" > >>Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] > >>ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" > >>DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 > >>Service Pack 3"] MachineName="1LPPley" > >>UserName="Pley" > >>Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - > >>- - - - - - - - - - - - - - - - - - - - - - > >>at System.Data.SqlClient.SqlConnection..ctor() > >>at System.Data.SqlClient.SqlConnection..ctor(String connectionString) > >>at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() > >>at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand > >>Command, OnChangeEventHandler CallBack) > >>at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand > >>Command, OnChangeEventHandler CallBack) > >>at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, > >>Boolean RegisterNotification) > >>at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand > >>CommandToExecute) > >>at > >>MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String > >>UserName) > >>at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String > >>Username, String Password, String Domain, SFSUsersBO& User) > >>at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, > >>EventArgs e) > >>at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 > >>at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in > >>C:\Documents and > >>Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 > >>at System.Windows.Forms.Control.OnClick(EventArgs e) > >>at System.Windows.Forms.Button.OnClick(EventArgs e) > >>at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) > >>at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons > >>button, Int32 clicks) > >>at System.Windows.Forms.Control.WndProc(Message& m) > >>at System.Windows.Forms.ButtonBase.WndProc(Message& m) > >>at System.Windows.Forms.Button.WndProc(Message& m) > >>at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) > >>at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) > >>at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, > >>IntPtr wparam, IntPtr lparam) > >>Comments: > >>EMS warning: maximum number of iterations reached when processing objects. > >>_______________________________________________ > >>Haskell-Cafe mailing list > >>Haskell-Cafe@haskell.org > >>http://www.haskell.org/mailman/listinfo/haskell-cafe > >> > >_______________________________________________ > >Haskell-Cafe mailing list > >Haskell-Cafe@haskell.org > >http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -- > Now Playing: Clammbon - 246 > http://youtube.com/watch?v=PO77bN8W1mA > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wagner.andrew at gmail.com Sun Jul 6 17:13:34 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sun Jul 6 17:04:27 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <20080706210737.GC31871@liouville.galois.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> <48712CB1.2010105@student.tue.nl> <4871320F.6070603@mindspring.com> <20080706210737.GC31871@liouville.galois.com> Message-ID: Wow. Where did you come up with the stack trace? That's...impressive. On Sun, Jul 6, 2008 at 5:07 PM, Don Stewart wrote: > I win, almost ... > > 13:13:18 dolio: yeah, it was ... almost ... an April 1 style post > > :) > > And yes, this was truly shocking on a number of levels. However, we have > people doing a lot of weird things with Haskell these days, so its not > as absurd that someone would be hacking up a zip12 for an air traffic > control system on some MS platform, with SQL in the backend, as it might > have been a few years ago :) > > mfeathers: >> >> Sorry guys. I was just bored on a Sunday afternoon so I thought I'd >> type up a little joke. I thought to myself "Gee, how outrageous can I >> make it?" >> >> 1) Using and debugging a zip12 function. >> 2) That fails only on 'take 5' (Brubeck fans take note) >> 3) Has some absurd arguments like (nub . nub) >> 4) Is embedded in an air traffic control system >> 5) Is written in a Microsoft variant of Haskell called H# >> 6) Silently makes SQL calls when evaluating a pure function >> 7) Yields an mile long stack trace >> >> Sorry all. Boredom made me do it, >> >> Michael >> >> Paul Visschers wrote: >> >You're zipping 12 lists here, so how about testing each list >> >individually? This will narrow down the problem considerably. >> > >> >Michael Feathers wrote: >> >> >> >>I have some code that looks like this and I'm having trouble with it: >> >> >> >> >> >>zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) >> >> groundSpeeds headings (map windShift headings) (regulations !! 2) >> >> (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] >> >> (nub . nub) arrivalSchedule >> >> >> >> >> >>The domain is air traffic control and I need to generate 12-tuples for >> >>aircraft that are within a particular radius of the tower. >> >> >> >>When I evaluate that expression with 'take 4' it works fine. When I >> >>evaluate it with 'take 6' it works as well. But, when I evaluate it >> >>with 'take 5' I get the following runtime error from H# in Visual Studio >> >>(it runs fine on the command line). This is particularly odd because >> >>I'm not using Sql. >> >> >> >> >> >> >> >>The type initializer for 'System.Data.SqlClient.SqlConnection' threw an >> >>exception. >> >>Exception (TypeInitializationException): Source="System.Data"; >> >>Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; >> >>Message = "The type initializer for >> >>'System.Data.SqlClient.SqlConnection' threw an exception." >> >>InnerException (TypeInitializationException): Source="System.Data"; >> >>Target=null; Tag=null; >> >>Message = "The type initializer for >> >>'System.Data.SqlClient.SqlConnectionFactory' threw an exception." >> >>StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" >> >>InnerException (TypeInitializationException): Source="System.Data"; >> >>Target=null; Tag=null; >> >>Message = "The type initializer for >> >>'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." >> >>StackTrace = >> >>" at System.Data.SqlClient.SqlConnectionFactory..ctor() >> >>at System.Data.SqlClient.SqlConnectionFactory..cctor()" >> >>InnerException (ConfigurationErrorsException): >> >>Source="System.Configuration"; Target=null; Tag=null; Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>StackTrace = >> >>" at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] >> >>keys, SectionInput input, Boolean isTrusted, FactoryRecord >> >>factoryRecord, SectionRecord sectionRecord, Object parentResult) >> >>at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord >> >>factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean >> >>getLkg, Boolean getRuntimeObject, Object& result, Object& >> >>resultRuntimeObject) >> >>at >> >>System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >> >>configKey, Boolean getLkg, Boolean checkPermission, Boolean >> >>getRuntimeObject, Boolean requestIsHere, Object& result, Object& >> >>resultRuntimeObject) >> >>at >> >>System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >> >>configKey, Boolean getLkg, Boolean checkPermission, Boolean >> >>getRuntimeObject, Boolean requestIsHere, Object& result, Object& >> >>resultRuntimeObject) >> >>at >> >>System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >> >>configKey, Boolean getLkg, Boolean ch... (truncated) ...olean >> >>checkPermission) >> >>at System.Configuration.BaseConfigurationRecord.GetSection(String >> >>configKey) >> >>at >> >>System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String >> >>sectionName) >> >>at System.Configuration.ConfigurationManager.GetSection(String >> >>sectionName) >> >>at System.Configuration.PrivilegedConfigurationManager.GetSection(String >> >>sectionName) >> >>at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() >> >>at System.Diagnostics.DiagnosticsConfiguration.Initialize() >> >>at System.Diagnostics.Switch.InitializeConfigSettings() >> >>at System.Diagnostics.Switch.InitializeWithStatus() >> >>at System.Diagnostics.Switch.get_SwitchSetting() >> >>at System.Diagnostics.TraceSwitch.get_Level() >> >>at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String >> >>categoryName, String categoryHelp) >> >>at System.Data.SqlClient.SqlPerformanceCounters..ctor() >> >>at System.Data.SqlClient.SqlPerformanceCounters..cctor()" >> >>BareMessage = "The value of the property 'traceOutputOptions' cannot be >> >>parsed. The error is: The enumeration value must be one of the >> >>following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, >> >>ThreadId, Callstack." >> >>Filename = "C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line >> >>21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >> >>StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >> >>Line=21; >> >>Message = >> >>"The value of the property 'traceOutputOptions' cannot be parsed. The >> >>error is: The enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >> >>Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21)" >> >>Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >> >>#0 = >> >>{System.Configuration.ConfigurationErrorsException: The value of the >> >>property 'traceOutputOptions' cannot be parsed. The error is: The >> >>enumeration value must be one of the following: None, >> >>LogicalOperationStack, DateTime, Timestamp, ProcessId, >> >>ThreadId, Callstack. (C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >> >>line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is >> >>EmsInnerException helper object) >> >>--- End of inner exception stack trace ---} >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>Values = System.Configuration.ConfigurationException[] >> >>TypeName = "System.Data.SqlClient.SqlPerformanceCounters" >> >>TypeName = "System.Data.SqlClient.SqlConnectionFactory" >> >>Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] >> >>ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" >> >>DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 >> >>Service Pack 3"] MachineName="1LPPley" >> >>UserName="Pley" >> >>Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - >> >>- - - - - - - - - - - - - - - - - - - - - - >> >>at System.Data.SqlClient.SqlConnection..ctor() >> >>at System.Data.SqlClient.SqlConnection..ctor(String connectionString) >> >>at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() >> >>at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand >> >>Command, OnChangeEventHandler CallBack) >> >>at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand >> >>Command, OnChangeEventHandler CallBack) >> >>at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, >> >>Boolean RegisterNotification) >> >>at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand >> >>CommandToExecute) >> >>at >> >>MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String >> >>UserName) >> >>at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String >> >>Username, String Password, String Domain, SFSUsersBO& User) >> >>at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, >> >>EventArgs e) >> >>at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 >> >>at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in >> >>C:\Documents and >> >>Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 >> >>at System.Windows.Forms.Control.OnClick(EventArgs e) >> >>at System.Windows.Forms.Button.OnClick(EventArgs e) >> >>at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) >> >>at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons >> >>button, Int32 clicks) >> >>at System.Windows.Forms.Control.WndProc(Message& m) >> >>at System.Windows.Forms.ButtonBase.WndProc(Message& m) >> >>at System.Windows.Forms.Button.WndProc(Message& m) >> >>at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) >> >>at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) >> >>at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, >> >>IntPtr wparam, IntPtr lparam) >> >>Comments: >> >>EMS warning: maximum number of iterations reached when processing objects. >> >>_______________________________________________ >> >>Haskell-Cafe mailing list >> >>Haskell-Cafe@haskell.org >> >>http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> >_______________________________________________ >> >Haskell-Cafe mailing list >> >Haskell-Cafe@haskell.org >> >http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> >> -- >> Now Playing: Clammbon - 246 >> http://youtube.com/watch?v=PO77bN8W1mA >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mfeathers at mindspring.com Sun Jul 6 17:19:34 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Sun Jul 6 17:15:45 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <20080706210737.GC31871@liouville.galois.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> <48712CB1.2010105@student.tue.nl> <4871320F.6070603@mindspring.com> <20080706210737.GC31871@liouville.galois.com> Message-ID: <487136E6.5050306@mindspring.com> Don Stewart wrote: > I win, almost ... > > 13:13:18 dolio: yeah, it was ... almost ... an April 1 style post > > :) > > And yes, this was truly shocking on a number of levels. However, we have > people doing a lot of weird things with Haskell these days, so its not > as absurd that someone would be hacking up a zip12 for an air traffic > control system on some MS platform, with SQL in the backend, as it might > have been a few years ago :) :-) Was that IRC? Oh boy, now I have a reputation. Michael > > mfeathers: >> Sorry guys. I was just bored on a Sunday afternoon so I thought I'd >> type up a little joke. I thought to myself "Gee, how outrageous can I >> make it?" >> >> 1) Using and debugging a zip12 function. >> 2) That fails only on 'take 5' (Brubeck fans take note) >> 3) Has some absurd arguments like (nub . nub) >> 4) Is embedded in an air traffic control system >> 5) Is written in a Microsoft variant of Haskell called H# >> 6) Silently makes SQL calls when evaluating a pure function >> 7) Yields an mile long stack trace >> >> Sorry all. Boredom made me do it, >> >> Michael >> >> Paul Visschers wrote: >>> You're zipping 12 lists here, so how about testing each list >>> individually? This will narrow down the problem considerably. >>> >>> Michael Feathers wrote: >>>> I have some code that looks like this and I'm having trouble with it: >>>> >>>> >>>> zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) >>>> groundSpeeds headings (map windShift headings) (regulations !! 2) >>>> (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] >>>> (nub . nub) arrivalSchedule >>>> >>>> >>>> The domain is air traffic control and I need to generate 12-tuples for >>>> aircraft that are within a particular radius of the tower. >>>> >>>> When I evaluate that expression with 'take 4' it works fine. When I >>>> evaluate it with 'take 6' it works as well. But, when I evaluate it >>>> with 'take 5' I get the following runtime error from H# in Visual Studio >>>> (it runs fine on the command line). This is particularly odd because >>>> I'm not using Sql. >>>> >>>> >>>> >>>> The type initializer for 'System.Data.SqlClient.SqlConnection' threw an >>>> exception. >>>> Exception (TypeInitializationException): Source="System.Data"; >>>> Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; >>>> Message = "The type initializer for >>>> 'System.Data.SqlClient.SqlConnection' threw an exception." >>>> InnerException (TypeInitializationException): Source="System.Data"; >>>> Target=null; Tag=null; >>>> Message = "The type initializer for >>>> 'System.Data.SqlClient.SqlConnectionFactory' threw an exception." >>>> StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" >>>> InnerException (TypeInitializationException): Source="System.Data"; >>>> Target=null; Tag=null; >>>> Message = "The type initializer for >>>> 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." >>>> StackTrace = >>>> " at System.Data.SqlClient.SqlConnectionFactory..ctor() >>>> at System.Data.SqlClient.SqlConnectionFactory..cctor()" >>>> InnerException (ConfigurationErrorsException): >>>> Source="System.Configuration"; Target=null; Tag=null; Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> StackTrace = >>>> " at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] >>>> keys, SectionInput input, Boolean isTrusted, FactoryRecord >>>> factoryRecord, SectionRecord sectionRecord, Object parentResult) >>>> at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord >>>> factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean >>>> getLkg, Boolean getRuntimeObject, Object& result, Object& >>>> resultRuntimeObject) >>>> at >>>> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >>>> configKey, Boolean getLkg, Boolean checkPermission, Boolean >>>> getRuntimeObject, Boolean requestIsHere, Object& result, Object& >>>> resultRuntimeObject) >>>> at >>>> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >>>> configKey, Boolean getLkg, Boolean checkPermission, Boolean >>>> getRuntimeObject, Boolean requestIsHere, Object& result, Object& >>>> resultRuntimeObject) >>>> at >>>> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >>>> configKey, Boolean getLkg, Boolean ch... (truncated) ...olean >>>> checkPermission) >>>> at System.Configuration.BaseConfigurationRecord.GetSection(String >>>> configKey) >>>> at >>>> System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String >>>> sectionName) >>>> at System.Configuration.ConfigurationManager.GetSection(String >>>> sectionName) >>>> at System.Configuration.PrivilegedConfigurationManager.GetSection(String >>>> sectionName) >>>> at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() >>>> at System.Diagnostics.DiagnosticsConfiguration.Initialize() >>>> at System.Diagnostics.Switch.InitializeConfigSettings() >>>> at System.Diagnostics.Switch.InitializeWithStatus() >>>> at System.Diagnostics.Switch.get_SwitchSetting() >>>> at System.Diagnostics.TraceSwitch.get_Level() >>>> at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String >>>> categoryName, String categoryHelp) >>>> at System.Data.SqlClient.SqlPerformanceCounters..ctor() >>>> at System.Data.SqlClient.SqlPerformanceCounters..cctor()" >>>> BareMessage = "The value of the property 'traceOutputOptions' cannot be >>>> parsed. The error is: The enumeration value must be one of the >>>> following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, >>>> ThreadId, Callstack." >>>> Filename = "C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line >>>> 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>> Line=21; >>>> Message = >>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>> error is: The enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>> Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21)" >>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>> #0 = >>>> {System.Configuration.ConfigurationErrorsException: The value of the >>>> property 'traceOutputOptions' cannot be parsed. The error is: The >>>> enumeration value must be one of the following: None, >>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, >>>> ThreadId, Callstack. (C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>> line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is >>>> EmsInnerException helper object) >>>> --- End of inner exception stack trace ---} >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> Values = System.Configuration.ConfigurationException[] >>>> TypeName = "System.Data.SqlClient.SqlPerformanceCounters" >>>> TypeName = "System.Data.SqlClient.SqlConnectionFactory" >>>> Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] >>>> ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" >>>> DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 >>>> Service Pack 3"] MachineName="1LPPley" >>>> UserName="Pley" >>>> Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - >>>> - - - - - - - - - - - - - - - - - - - - - - >>>> at System.Data.SqlClient.SqlConnection..ctor() >>>> at System.Data.SqlClient.SqlConnection..ctor(String connectionString) >>>> at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() >>>> at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand >>>> Command, OnChangeEventHandler CallBack) >>>> at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand >>>> Command, OnChangeEventHandler CallBack) >>>> at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, >>>> Boolean RegisterNotification) >>>> at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand >>>> CommandToExecute) >>>> at >>>> MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String >>>> UserName) >>>> at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String >>>> Username, String Password, String Domain, SFSUsersBO& User) >>>> at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, >>>> EventArgs e) >>>> at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 >>>> at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in >>>> C:\Documents and >>>> Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 >>>> at System.Windows.Forms.Control.OnClick(EventArgs e) >>>> at System.Windows.Forms.Button.OnClick(EventArgs e) >>>> at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) >>>> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons >>>> button, Int32 clicks) >>>> at System.Windows.Forms.Control.WndProc(Message& m) >>>> at System.Windows.Forms.ButtonBase.WndProc(Message& m) >>>> at System.Windows.Forms.Button.WndProc(Message& m) >>>> at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) >>>> at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) >>>> at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, >>>> IntPtr wparam, IntPtr lparam) >>>> Comments: >>>> EMS warning: maximum number of iterations reached when processing objects. >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> -- >> Now Playing: Clammbon - 246 >> http://youtube.com/watch?v=PO77bN8W1mA >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Now Playing: Clammbon - 246 http://youtube.com/watch?v=PO77bN8W1mA From mfeathers at mindspring.com Sun Jul 6 17:21:39 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Sun Jul 6 17:17:45 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> <48712CB1.2010105@student.tue.nl> <4871320F.6070603@mindspring.com> <20080706210737.GC31871@liouville.galois.com> Message-ID: <48713763.6040105@mindspring.com> Andrew Wagner wrote: > Wow. Where did you come up with the stack trace? That's...impressive. Pulled it from a blog. I was actually looking for a creepy VB4 or VB5 stack trace I saw years ago that ripped through their dynamic type resolution layer. Now that would've been funny. :-) Michael > > On Sun, Jul 6, 2008 at 5:07 PM, Don Stewart wrote: >> I win, almost ... >> >> 13:13:18 dolio: yeah, it was ... almost ... an April 1 style post >> >> :) >> >> And yes, this was truly shocking on a number of levels. However, we have >> people doing a lot of weird things with Haskell these days, so its not >> as absurd that someone would be hacking up a zip12 for an air traffic >> control system on some MS platform, with SQL in the backend, as it might >> have been a few years ago :) >> >> mfeathers: >>> Sorry guys. I was just bored on a Sunday afternoon so I thought I'd >>> type up a little joke. I thought to myself "Gee, how outrageous can I >>> make it?" >>> >>> 1) Using and debugging a zip12 function. >>> 2) That fails only on 'take 5' (Brubeck fans take note) >>> 3) Has some absurd arguments like (nub . nub) >>> 4) Is embedded in an air traffic control system >>> 5) Is written in a Microsoft variant of Haskell called H# >>> 6) Silently makes SQL calls when evaluating a pure function >>> 7) Yields an mile long stack trace >>> >>> Sorry all. Boredom made me do it, >>> >>> Michael >>> >>> Paul Visschers wrote: >>>> You're zipping 12 lists here, so how about testing each list >>>> individually? This will narrow down the problem considerably. >>>> >>>> Michael Feathers wrote: >>>>> I have some code that looks like this and I'm having trouble with it: >>>>> >>>>> >>>>> zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd geoCaches) >>>>> groundSpeeds headings (map windShift headings) (regulations !! 2) >>>>> (foldr (\|/) (tail pathDistances)) [ghy x | x <- [1..], full x] >>>>> (nub . nub) arrivalSchedule >>>>> >>>>> >>>>> The domain is air traffic control and I need to generate 12-tuples for >>>>> aircraft that are within a particular radius of the tower. >>>>> >>>>> When I evaluate that expression with 'take 4' it works fine. When I >>>>> evaluate it with 'take 6' it works as well. But, when I evaluate it >>>>> with 'take 5' I get the following runtime error from H# in Visual Studio >>>>> (it runs fine on the command line). This is particularly odd because >>>>> I'm not using Sql. >>>>> >>>>> >>>>> >>>>> The type initializer for 'System.Data.SqlClient.SqlConnection' threw an >>>>> exception. >>>>> Exception (TypeInitializationException): Source="System.Data"; >>>>> Target=null; Tag=null; TypeName="System.Data.SqlClient.SqlConnection"; >>>>> Message = "The type initializer for >>>>> 'System.Data.SqlClient.SqlConnection' threw an exception." >>>>> InnerException (TypeInitializationException): Source="System.Data"; >>>>> Target=null; Tag=null; >>>>> Message = "The type initializer for >>>>> 'System.Data.SqlClient.SqlConnectionFactory' threw an exception." >>>>> StackTrace = " at System.Data.SqlClient.SqlConnection..cctor()" >>>>> InnerException (TypeInitializationException): Source="System.Data"; >>>>> Target=null; Tag=null; >>>>> Message = "The type initializer for >>>>> 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception." >>>>> StackTrace = >>>>> " at System.Data.SqlClient.SqlConnectionFactory..ctor() >>>>> at System.Data.SqlClient.SqlConnectionFactory..cctor()" >>>>> InnerException (ConfigurationErrorsException): >>>>> Source="System.Configuration"; Target=null; Tag=null; Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Paey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> StackTrace = >>>>> " at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] >>>>> keys, SectionInput input, Boolean isTrusted, FactoryRecord >>>>> factoryRecord, SectionRecord sectionRecord, Object parentResult) >>>>> at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord >>>>> factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean >>>>> getLkg, Boolean getRuntimeObject, Object& result, Object& >>>>> resultRuntimeObject) >>>>> at >>>>> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >>>>> configKey, Boolean getLkg, Boolean checkPermission, Boolean >>>>> getRuntimeObject, Boolean requestIsHere, Object& result, Object& >>>>> resultRuntimeObject) >>>>> at >>>>> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >>>>> configKey, Boolean getLkg, Boolean checkPermission, Boolean >>>>> getRuntimeObject, Boolean requestIsHere, Object& result, Object& >>>>> resultRuntimeObject) >>>>> at >>>>> System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String >>>>> configKey, Boolean getLkg, Boolean ch... (truncated) ...olean >>>>> checkPermission) >>>>> at System.Configuration.BaseConfigurationRecord.GetSection(String >>>>> configKey) >>>>> at >>>>> System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String >>>>> sectionName) >>>>> at System.Configuration.ConfigurationManager.GetSection(String >>>>> sectionName) >>>>> at System.Configuration.PrivilegedConfigurationManager.GetSection(String >>>>> sectionName) >>>>> at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection() >>>>> at System.Diagnostics.DiagnosticsConfiguration.Initialize() >>>>> at System.Diagnostics.Switch.InitializeConfigSettings() >>>>> at System.Diagnostics.Switch.InitializeWithStatus() >>>>> at System.Diagnostics.Switch.get_SwitchSetting() >>>>> at System.Diagnostics.TraceSwitch.get_Level() >>>>> at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String >>>>> categoryName, String categoryHelp) >>>>> at System.Data.SqlClient.SqlPerformanceCounters..ctor() >>>>> at System.Data.SqlClient.SqlPerformanceCounters..cctor()" >>>>> BareMessage = "The value of the property 'traceOutputOptions' cannot be >>>>> parsed. The error is: The enumeration value must be one of the >>>>> following: None, LogicalOperationStack, DateTime, Timestamp, ProcessId, >>>>> ThreadId, Callstack." >>>>> Filename = "C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pey\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config line >>>>> 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 (ConfigurationErrorsException): Source=null; Target=null; Tag=null; >>>>> StackTrace=null; BareMessage=(->BareMessage); Filename=(->Filename); >>>>> Line=21; >>>>> Message = >>>>> "The value of the property 'traceOutputOptions' cannot be parsed. The >>>>> error is: The enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, >>>>> Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21)" >>>>> Errors (ConfigurationException[]): Length=1; Rank=1; Count=1; >>>>> #0 = >>>>> {System.Configuration.ConfigurationErrorsException: The value of the >>>>> property 'traceOutputOptions' cannot be parsed. The error is: The >>>>> enumeration value must be one of the following: None, >>>>> LogicalOperationStack, DateTime, Timestamp, ProcessId, >>>>> ThreadId, Callstack. (C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\bin\Debug\RPMC.vshost.exe.config >>>>> line 21) ---> UJ.ExceptionManagement.Classes.EmsInnerException: (This is >>>>> EmsInnerException helper object) >>>>> --- End of inner exception stack trace ---} >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> Values = System.Configuration.ConfigurationException[] >>>>> TypeName = "System.Data.SqlClient.SqlPerformanceCounters" >>>>> TypeName = "System.Data.SqlClient.SqlConnectionFactory" >>>>> Environment: ThreadIdentity="" DateTime=["2008-06-27 13:02:08.709"] >>>>> ThreadName=null WindowsIdentity="STRUSS\Pley" ThreadId="10" >>>>> DomainName="RPMC.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 >>>>> Service Pack 3"] MachineName="1LPPley" >>>>> UserName="Pley" >>>>> Remaining Stack Trace - - - - - - - - - - - - - - - - - - - - - - - - - >>>>> - - - - - - - - - - - - - - - - - - - - - - >>>>> at System.Data.SqlClient.SqlConnection..ctor() >>>>> at System.Data.SqlClient.SqlConnection..ctor(String connectionString) >>>>> at MicroFour.StrataFrame.Data.SqlDataSourceItem.CreateBlankDbConnection() >>>>> at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand >>>>> Command, OnChangeEventHandler CallBack) >>>>> at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand >>>>> Command, OnChangeEventHandler CallBack) >>>>> at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, >>>>> Boolean RegisterNotification) >>>>> at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand >>>>> CommandToExecute) >>>>> at >>>>> MicroFour.StrataFrame.Security.BusinessObjects.SFSUsersBO.FillByUserName(String >>>>> UserName) >>>>> at MicroFour.StrataFrame.Security.Login.AuthenticateUser(String >>>>> Username, String Password, String Domain, SFSUsersBO& User) >>>>> at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, >>>>> EventArgs e) >>>>> at RPMC.LoginForm.OnAttemptLogin() in C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 30 >>>>> at RPMC.LoginForm.cmdOk_Click(Object sender, EventArgs e) in >>>>> C:\Documents and >>>>> Settings\Pley\Desktop\Projects\RPMC\Forms\LoginForm.vb:line 285 >>>>> at System.Windows.Forms.Control.OnClick(EventArgs e) >>>>> at System.Windows.Forms.Button.OnClick(EventArgs e) >>>>> at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) >>>>> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons >>>>> button, Int32 clicks) >>>>> at System.Windows.Forms.Control.WndProc(Message& m) >>>>> at System.Windows.Forms.ButtonBase.WndProc(Message& m) >>>>> at System.Windows.Forms.Button.WndProc(Message& m) >>>>> at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) >>>>> at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) >>>>> at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, >>>>> IntPtr wparam, IntPtr lparam) >>>>> Comments: >>>>> EMS warning: maximum number of iterations reached when processing objects. >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> -- >>> Now Playing: Clammbon - 246 >>> http://youtube.com/watch?v=PO77bN8W1mA >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > -- Now Playing: Clammbon - 246 http://youtube.com/watch?v=PO77bN8W1mA From allbery at ece.cmu.edu Sun Jul 6 18:43:31 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 6 18:34:24 2008 Subject: [Haskell-cafe] Having trouble with zip12.. In-Reply-To: <48712F4B.9040304@tmorris.net> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> <4870FB9A.5090800@mindspring.com> <48712F4B.9040304@tmorris.net> Message-ID: <72B00D8D-22E7-419E-8ECE-1F4CB378B27F@ece.cmu.edu> On 2008 Jul 6, at 16:47, Tony Morris wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Michael Feathers wrote: >> zip12 ((tails . nub) flightPaths) wayPoints etopsPackets (hd >> geoCaches) groundSpeeds headings (map windShift headings) >> (regulations !! 2) (foldr (\|/) (tail pathDistances)) [ghy x | x <- >> [1..], full x] (nub . nub) arrivalSchedule > > Hi Michael, > Sorry to distract from your issue, but I note that (nub . nub) can be > replaced with just 'nub' since the function nub is idempotent (f . f > == f). Or even better, with a custom nub: in order to handle some special cases the Prelude nub is rather inefficient. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From mfeathers at mindspring.com Sun Jul 6 19:45:53 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Sun Jul 6 19:41:57 2008 Subject: [Haskell-cafe] Is there a nicer way to do this? Message-ID: <48715931.6050101@mindspring.com> segment :: Int -> [a] -> [[a]] segment 0 _ = [] segment _ [] = [] segment n x = (take n x) : segment n (drop n x) I did a version of this which used splitAt but I wasn't sure whether it was going to buy me anything re performance that would justify its ugliness. Michael From dons at galois.com Sun Jul 6 19:55:27 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 6 19:46:32 2008 Subject: [Haskell-cafe] Is there a nicer way to do this? In-Reply-To: <48715931.6050101@mindspring.com> References: <48715931.6050101@mindspring.com> Message-ID: <20080706235527.GE31871@liouville.galois.com> mfeathers: > > > segment :: Int -> [a] -> [[a]] > segment 0 _ = [] > segment _ [] = [] > segment n x = (take n x) : segment n (drop n x) The first set of parens can go, segment n x = take n x : segment n (drop n x) > > I did a version of this which used splitAt but I wasn't sure whether it > was going to buy me anything re performance that would justify its ugliness. Besides, splitAt n xs = (take n xs, drop n xs) -- Don From jlhamilton at gmail.com Sun Jul 6 20:25:19 2008 From: jlhamilton at gmail.com (John Hamilton) Date: Sun Jul 6 20:16:12 2008 Subject: [Haskell-cafe] Is there a nicer way to do this? In-Reply-To: <48715931.6050101@mindspring.com> References: <48715931.6050101@mindspring.com> Message-ID: <65113aef0807061725o5548bd77j5bc20f63f16f670e@mail.gmail.com> On Sun, Jul 6, 2008 at 16:45, Michael Feathers wrote: > > > segment :: Int -> [a] -> [[a]] > segment 0 _ = [] > segment _ [] = [] > segment n x = (take n x) : segment n (drop n x) > > > I did a version of this which used splitAt but I wasn't sure whether it was > going to buy me anything re performance that would justify its ugliness. You can use segment n = takeWhile (not . null) . unfoldr (Just . splitAt n) I don't know how it compares in performance. It's from http://www.haskell.org/haskellwiki/Blow_your_mind - John From princedpw at gmail.com Sun Jul 6 20:33:58 2008 From: princedpw at gmail.com (David Walker) Date: Sun Jul 6 20:24:51 2008 Subject: [Haskell-cafe] extensible data types in Haskell? Message-ID: Hi all, SML conveniently contains the type "exn" which is an instance of an "extensible data type". In other words, unlike normal data types that are "closed" (can't admit new constructors once defined), SML's exn type is "open," allowing programmers to keep adding new alternatives as often as they choose. Like normal datatypes, the elimination form for an extensible data type is a case statement (or match function). Friends have told me that Haskell doesn't have extensible data types. However, it seems fairly straightforward to code them up using type classes....though the solution I'm thinking of has a little bit of boilerplate I'd like to scrap (you have to define a new type declaration *and* an instance of a type class with a "match" method) and matching occurs through a string comparison (which can lead to silly programmer errors if there is accidentally a typo in the string). Anyway, it's possible with some thought I could come up with a better solution, but before worrying about it, I figured I'd ask if anybody else already has a package that does this. It seems like a pretty natural feature to want to have. Thanks in advance, Dave From qdunkan at gmail.com Sun Jul 6 20:36:58 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Sun Jul 6 20:27:53 2008 Subject: [Haskell-cafe] Is there a nicer way to do this? In-Reply-To: <65113aef0807061725o5548bd77j5bc20f63f16f670e@mail.gmail.com> References: <48715931.6050101@mindspring.com> <65113aef0807061725o5548bd77j5bc20f63f16f670e@mail.gmail.com> Message-ID: <2518b95d0807061736i1defcf81sf09d3de19965c663@mail.gmail.com> On Sun, Jul 6, 2008 at 5:25 PM, John Hamilton wrote: > On Sun, Jul 6, 2008 at 16:45, Michael Feathers wrote: >> >> >> segment :: Int -> [a] -> [[a]] >> segment 0 _ = [] >> segment _ [] = [] >> segment n x = (take n x) : segment n (drop n x) >> >> >> I did a version of this which used splitAt but I wasn't sure whether it was >> going to buy me anything re performance that would justify its ugliness. > > You can use > > segment n = takeWhile (not . null) . unfoldr (Just . splitAt n) > > I don't know how it compares in performance. It's from > http://www.haskell.org/haskellwiki/Blow_your_mind Watch out for negative numbers, though. From dons at galois.com Sun Jul 6 20:42:04 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 6 20:32:58 2008 Subject: [Haskell-cafe] Is there a nicer way to do this? In-Reply-To: <4871636B.8000304@mindspring.com> References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> Message-ID: <20080707004204.GF31871@liouville.galois.com> mfeathers: > Don Stewart wrote: > >mfeathers: > >> > >>segment :: Int -> [a] -> [[a]] > >>segment 0 _ = [] > >>segment _ [] = [] > >>segment n x = (take n x) : segment n (drop n x) > > > >The first set of parens can go, > > > > segment n x = take n x : segment n (drop n x) > > > >>I did a version of this which used splitAt but I wasn't sure whether it > >>was going to buy me anything re performance that would justify its > >>ugliness. > > > >Besides, > > > > splitAt n xs = (take n xs, drop n xs) > > Thanks. That is odd, though. It makes me wonder what to expect re > optimization. Would the compiler/runtime know that splitAt could be > done in a single pass? Not with that definition. It would require some moderately unusual fusion combining the take and drop into a single fold with the (,) on the inside, rather than on the outside. However, GHC actually implements splitAt as: splitAt (I n) ls | n < 0 = ([], ls) | otherwise = splitAt' n ls where splitAt' :: Int -> [a] -> ([a], [a]) splitAt' 0 xs = ([], xs) splitAt' _ xs@[] = (xs, xs) splitAt' m (x:xs) = (x:xs', xs'') where (xs', xs'') = splitAt' (m - 1) xs So there may be some benefit. -- Don From mfeathers at mindspring.com Sun Jul 6 21:02:14 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Sun Jul 6 20:58:21 2008 Subject: [Haskell-cafe] Is there anything manifestly stupid about this code? In-Reply-To: <20080707004204.GF31871@liouville.galois.com> References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> Message-ID: <48716B16.5040901@mindspring.com> Decided a while ago to write some code to calculate the Mandelbrot set using the escape iterations algorithm. Discovered after mulling it about that I could just built it as an infinite list of infinite lists and then extract any rectangle of values that I wanted: type Point = (Double, Double) sq :: Double -> Double sq x = x ^ 2 translate :: Point -> Point -> Point translate (r0, i0) (r1, i1) = (r0 + r1, i0 + i1) mandel :: Point -> Point mandel (r, i) = (sq r + sq i, 2 * r * i) notEscaped :: Point -> Bool notEscaped (r, i) = (sq r + sq i) <= 4.0 trajectory :: (Point -> Point) -> [Point] trajectory pointFunction = takeWhile notEscaped $ iterate pointFunction seed where seed = (0.0, 0.0) escapeIterations :: (Point -> Point) -> Int escapeIterations = length . tail . take 1024 . trajectory mandelbrot :: Double -> [[Int]] mandelbrot incrementSize = [[ escapeIterations $ translate (x, y) . mandel | x <- increments] | y <- increments] where increments = [0.0, incrementSize .. ] window :: (Int, Int) -> (Int, Int) -> [[a]] -> [[a]] window (x0, y0) (x1, y1) = range x0 x1 . map (range y0 y1) where range m n = take (n - m) . drop m From derek.a.elkins at gmail.com Sun Jul 6 21:18:22 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Jul 6 21:09:22 2008 Subject: [Haskell-cafe] Is there anything manifestly stupid about this code? In-Reply-To: <48716B16.5040901@mindspring.com> References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> <48716B16.5040901@mindspring.com> Message-ID: <1215393502.5818.4.camel@derek-laptop> To answer the question in your subject, yes! We have a complex type. Not only does that make the code simpler and more obvious and idiomatic, but it's also more efficient because for this use you'd really prefer a strict pair type for "Point", and complex is strict in it's components. On Sun, 2008-07-06 at 21:02 -0400, Michael Feathers wrote: > Decided a while ago to write some code to calculate the Mandelbrot set > using the escape iterations algorithm. Discovered after mulling it > about that I could just built it as an infinite list of infinite lists > and then extract any rectangle of values that I wanted: > > type Point = (Double, Double) > sq :: Double -> Double > sq x = x ^ 2 > > translate :: Point -> Point -> Point > translate (r0, i0) (r1, i1) = > (r0 + r1, i0 + i1) > > mandel :: Point -> Point > mandel (r, i) = > (sq r + sq i, 2 * r * i) > > notEscaped :: Point -> Bool > notEscaped (r, i) = > (sq r + sq i) <= 4.0 > > trajectory :: (Point -> Point) -> [Point] > trajectory pointFunction = > takeWhile notEscaped $ iterate pointFunction seed > where seed = (0.0, 0.0) > > escapeIterations :: (Point -> Point) -> Int > escapeIterations = > length . tail . take 1024 . trajectory > > mandelbrot :: Double -> [[Int]] > mandelbrot incrementSize = > [[ escapeIterations $ translate (x, y) . mandel > | x <- increments] > | y <- increments] where > increments = [0.0, incrementSize .. ] > > window :: (Int, Int) -> (Int, Int) -> [[a]] -> [[a]] > window (x0, y0) (x1, y1) = range x0 x1 . map (range y0 y1) where > range m n = take (n - m) . drop m > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Sun Jul 6 21:18:55 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 6 21:12:02 2008 Subject: [Haskell-cafe] extensible data types in Haskell? In-Reply-To: References: Message-ID: <20080707011855.GA10461@liouville.galois.com> princedpw: > Hi all, > > SML conveniently contains the type "exn" which is an instance of an > "extensible data type". In other words, unlike normal data types that > are "closed" (can't admit new constructors once defined), SML's exn > type is "open," allowing programmers to keep adding new alternatives > as often as they choose. Like normal datatypes, the elimination form > for an extensible data type is a case statement (or match function). > > Friends have told me that Haskell doesn't have extensible data types. > However, it seems fairly straightforward to code them up using type > classes....though the solution I'm thinking of has a little bit of > boilerplate I'd like to scrap (you have to define a new type > declaration *and* an instance of a type class with a "match" method) > and matching occurs through a string comparison (which can lead to > silly programmer errors if there is accidentally a typo in the > string). You should probably use Typeable here, for the type matching, rather than a custom matcher. class Typeable a => Extensible a, this leads to a fairly straighforward extensible data type, where the open instance definition lets you add variants on the fly. > Anyway, it's possible with some thought I could come up with a better > solution, but before worrying about it, I figured I'd ask if anybody > else already has a package that does this. It seems like a pretty > natural feature to want to have. There's a number of ways to do this, including fully statically via type classes and existential types, or via the Dynamic type. Googling for "expression problem Haskell" will turn up some things. Some implementions of open data types in use can be found in xmonad, and the extensible exceptions proposal here, http://209.85.173.104/search?q=cache:xeXhle5KAqkJ:www.haskell.org/~simonmar/papers/ext-exceptions.pdf -- Don From ramsdell0 at gmail.com Sun Jul 6 22:33:06 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Sun Jul 6 22:23:59 2008 Subject: [Haskell-cafe] Associative Commutative Unification Message-ID: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> I'd like to write an obviously correct implementation of a unifier, a program that when given two terms, finds a substitution that makes the two terms equal. The phrase "obviously correct" is meant to imply that the clarity of the code trumps efficiency. As near as I can tell, high performance unifiers are full of side-effects, and achieving the same performance without side-effects in Haskell is difficult or impossible. In contrast, it is easy to write obviously correct Hasklell implementations of unifiers for freely generated term algebras. One can use Lawrence Paulson's code in ML for the Working Programmer as a template or follow Martelli and Montanari's simple set of rules. My problem is one of my operators is multiplication, which is associative and commutative. These two properties make unification much more difficult. Mark Stickel described a complete unification algorithm for this problem, but the task of translating his description into an obviously correct Haskell program appears to be difficult. For example, the algorithm requires the generation of the basis of solutions to linear homogeneous diophantine equations. I haven't located an algorithm for this part yet. If you have experience implemented equational unification in Haskell, please share it. John From dons at galois.com Sun Jul 6 22:38:56 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 6 22:29:50 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> Message-ID: <20080707023856.GB10461@liouville.galois.com> ramsdell0: > I'd like to write an obviously correct implementation of a unifier, a > program that when given two terms, finds a substitution that makes the > two terms equal. The phrase "obviously correct" is meant to imply > that the clarity of the code trumps efficiency. As near as I can > tell, high performance unifiers are full of side-effects, and > achieving the same performance without side-effects in Haskell is > difficult or impossible. > > In contrast, it is easy to write obviously correct Hasklell > implementations of unifiers for freely generated term algebras. One > can use Lawrence Paulson's code in ML for the Working Programmer as a > template or follow Martelli and Montanari's simple set of rules. > > My problem is one of my operators is multiplication, which is > associative and commutative. These two properties make unification > much more difficult. Mark Stickel described a complete unification > algorithm for this problem, but the task of translating his > description into an obviously correct Haskell program appears to be > difficult. For example, the algorithm requires the generation of the > basis of solutions to linear homogeneous diophantine equations. I > haven't located an algorithm for this part yet. > > If you have experience implemented equational unification in Haskell, > please share it. "Typing Haskell in Haskell" lives here, http://hackage.haskell.org/cgi-bin/hackage-scripts/package/thih "a Haskell program that implements a Haskell typechecker, thus providing a mathematically rigorous specification in a notation that is familiar to Haskell users. We expect this program to fill a serious gap in current descriptions of Haskell, both as a starting point for discussions about existing features of the type system, and as a platform from which to explore new proposals" Might be useful as a starting point. -- Don From prb at mult.ifario.us Mon Jul 7 00:43:50 2008 From: prb at mult.ifario.us (Paul Brown) Date: Mon Jul 7 00:34:47 2008 Subject: [Haskell-cafe] The state of database libraries In-Reply-To: References: Message-ID: <5DCBE90A-CA79-4EA9-9A94-84DBFD20901A@mult.ifario.us> On Jul 4, 2008, at 7:54 AM, Chris Eidhof wrote: > 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I > couldn't get this to work under OS X, while I installed myodbc, > which seems to be broken. FWIW, I've had good luck with the SQLite3 bindings for HDBC on MacOS X. I had a bit of a hiccup with Linux, but that was only because the version of SQLite on the Linux box was a bit too old. (3.2.x versus 3.4.x on the MacOS box.) With 3.5.9 on the Linux box, everything worked swimmingly. I haven't tried the MySQL support, but I don't need it. The timestamps on the other packages were old enough (~2007 IIRC) that I didn't even try 'em. Depending on what your application is, you might get more mileage out of a binding to CouchDB or some other post-relational storage system. -- Paul From ken.takusagawa.2 at gmail.com Mon Jul 7 01:12:46 2008 From: ken.takusagawa.2 at gmail.com (Ken Takusagawa) Date: Mon Jul 7 01:03:38 2008 Subject: [Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2 Message-ID: <4dcea1d80807062212y33b73b9fr792a3ebb92c588e3@mail.gmail.com> I'm using hopenssl 1.0 from hackage. What am I doing wrong here? $ cat test-hopenssl.hs import OpenSSL.Digest main=undefined $ ghc --make test-hopenssl.hs -lcrypto [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o ) Linking test-hopenssl ... /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In function `s2O8_info': (.text+0xf3a): undefined reference to `EVP_mdc2' /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In function `s2TQ_info': (.text+0x1435): undefined reference to `EVP_mdc2' collect2: ld returned 1 exit status $ dpkg-query -S /usr/lib/libcrypto.a libssl-dev: /usr/lib/libcrypto.a $ dpkg-query -l libssl-dev Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-======================-======================-============================================================ ii libssl-dev 0.9.8g-10.1 SSL development libraries, header files and documentation $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 $ uname -a Linux localhost 2.6.24-1-686 #1 SMP Thu May 8 02:16:39 UTC 2008 i686 GNU/Linux From dons at galois.com Mon Jul 7 01:21:03 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 7 01:12:10 2008 Subject: [Haskell-cafe] The state of database libraries In-Reply-To: <5DCBE90A-CA79-4EA9-9A94-84DBFD20901A@mult.ifario.us> References: <5DCBE90A-CA79-4EA9-9A94-84DBFD20901A@mult.ifario.us> Message-ID: <20080707052103.GE10461@liouville.galois.com> prb: > > On Jul 4, 2008, at 7:54 AM, Chris Eidhof wrote: > > >1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I > >couldn't get this to work under OS X, while I installed myodbc, > >which seems to be broken. > > FWIW, I've had good luck with the SQLite3 bindings for HDBC on MacOS > X. I had a bit of a hiccup with Linux, but that was only because the > version of SQLite on the Linux box was a bit too old. (3.2.x versus > 3.4.x on the MacOS box.) With 3.5.9 on the Linux box, everything > worked swimmingly. > > I haven't tried the MySQL support, but I don't need it. > > The timestamps on the other packages were old enough (~2007 IIRC) that > I didn't even try 'em. > > Depending on what your application is, you might get more mileage out > of a binding to CouchDB or some other post-relational storage system. The YHC guys have a simple CouchDB binding too. I was thinking this might be a nice project to actually polish up into a comprehensive system. -- Don From qdunkan at gmail.com Mon Jul 7 01:42:23 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Jul 7 01:33:16 2008 Subject: [Haskell-cafe] not for me, guv! Message-ID: <2518b95d0807062242r35134b89m790a5ab4794e1131@mail.gmail.com> So I wrote a big email about this mysterious message I was getting, but then after some research and poking and debugging tracked it down to a dangling pointer in C that was causing a callback to point to an invalid address, which somehow worked anyway 99% of the time. That all said, I'm not totally convinced that "freeHaskellFunctionPtr: not for me, guv! 0x23143f0" is the clearest error message ever. Now, if it were in a more contemporary American idiom such as "wtf this ptr ain't from MY house lol!!!" I probably would have found the bug in half the time. Anyway, I fixed my bug and I'm happy about that, but I didn't want to waste a chance to send an email with this title... From donn at avvanta.com Mon Jul 7 01:51:00 2008 From: donn at avvanta.com (Donn Cave) Date: Mon Jul 7 01:42:33 2008 Subject: [Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2 Message-ID: <20080707055100.881A0276C4F@mail.avvanta.com> Quoth "Ken Takusagawa" : | $ ghc --make test-hopenssl.hs -lcrypto | [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o ) | Linking test-hopenssl ... | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In | function `s2O8_info': | (.text+0xf3a): undefined reference to `EVP_mdc2' | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In | function `s2TQ_info': | (.text+0x1435): undefined reference to `EVP_mdc2' | collect2: ld returned 1 exit status I see the following in the Configure file for openssl-0.9.8h: my $default_depflags = "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SEED -DOPENSSL_NO_TLSEXT ";my $default_depflags = "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP I don't know why this would be, but I infer that the function hopenssl was looking for is commonly missing in SSL builds. Donn Cave, donn@avvanta.com From chak at cse.unsw.edu.au Mon Jul 7 02:21:16 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Mon Jul 7 02:12:09 2008 Subject: [Haskell-cafe] Type families versus functional dependencies question In-Reply-To: <4b39c80a0807040142l1b23093bo5f14d2e40e8da751@mail.gmail.com> References: <4b39c80a0807030620k7f12c91aw238933f751523a27@mail.gmail.com> <5826455B-5E82-4512-8482-C9845CB7DFB5@cse.unsw.edu.au> <4b39c80a0807040142l1b23093bo5f14d2e40e8da751@mail.gmail.com> Message-ID: <6115FD03-927E-4737-AFE7-9D2BD831DD74@cse.unsw.edu.au> Alexey Rodriguez: > > > On Fri, Jul 4, 2008 at 5:03 AM, Manuel M T Chakravarty > wrote: > The problem is that blah's type is ambiguous, as f does only occur > as an argument to the type family. If you'd define > > > class Blah f a where > blah :: a -> f -> T f f a > > (and change the rest of the program accordingly) then all will be > fine. See this thread for a more in-depth discussion of the problem: > > http://www.haskell.org/pipermail/haskell-cafe/2008-April/041385.html > > Yes, I was afraid that this was the case. However, the question > remains on whether my functional dependencies encoding is correct. A > correct encoding would help me understand this typing problem a bit > more. Especially, now that Claus showed that adding an equality > constraint makes this program work! For this particular program, you could argue that the signature is not ambiguous as T is unary; hence, in (T f f a) only the (T f) is really a type family application and so the second occurrence of 'f' should make the signature unambiguous. This is the reason why Claus' encoding works and why your FD translation works. I will have a look at whether I can improve the implementation in GHC to be smarter about handling such higher kinded TFs. Thanks for the example program! Manuel From DekuDekuplex at Yahoo.com Mon Jul 7 02:26:37 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Jul 7 02:25:56 2008 Subject: [Haskell-cafe] Ode from a Haskeller to a Schemer [Was: Re: Santana on my evil ways] References: <7687290b0807041243s59b4d607s3cffcb123a7b2bc0@mail.gmail.com> Message-ID: On Fri, 4 Jul 2008 15:43:38 -0400, "John D. Ramsdell" wrote: >My son's nickname is Rama, so let me adopt it. I am a functional >programmer, even when I use languages such as C. Scheme facilitated >my development into a functional programmer, however, I appreciate the >benefits of pure function programming at times. Yet when I use >Haskell, I hear reminders of my Scheme past cast in the music of >Santana. The words I hear are set to "Eval Ways": > >You've got to change your evil ways... Rama >Before I stop respecting you. >You've got to change... Rama >And every word that I say, it's true. >You use strange syntax and typing >And offset rules >You don't mutate locations >You use strange do's >This can't go on... >Lord knows you got to change. > >John Haskell poetry? Here is my Scheme -> Haskell story; since you have written your story as a poem, I have written mine, in the style of Japanese court poetry, as a poem in reply: Ode from a Haskeller to a Schemer Recursion was my curse, 'Till mapping came to fame, Parens to tail-recurse, Fade, monads are to blame. Let, let*, or letrec? They were my bar and foo. Now, monads have my neck: What shall there be to do? Recurse or iterate? The processes, too late! To map, fold, or filter: That is the question, sir. In Scheme, I threw a fit: Eval: how to write it? In Haskell, no more wait: Reactive-animate! -- by Benjamin L. Russell, July 7, 2008 (Tokyo time) From ketil at malde.org Mon Jul 7 02:38:17 2008 From: ketil at malde.org (Ketil Malde) Date: Mon Jul 7 02:28:48 2008 Subject: [Haskell-cafe] Is there a nicer way to do this? In-Reply-To: <20080707004204.GF31871@liouville.galois.com> (Don Stewart's message of "Sun\, 6 Jul 2008 17\:42\:04 -0700") References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> Message-ID: <87od5a9p2e.fsf@malde.org> Don Stewart writes: >>> splitAt n xs = (take n xs, drop n xs) >> Thanks. That is odd, though. It makes me wonder what to expect re >> optimization. Would the compiler/runtime know that splitAt could be >> done in a single pass? > Not with that definition. It would require some moderately unusual fusion > combining the take and drop into a single fold with the (,) on the inside, > rather than on the outside. Uhm, but I'm quite sure I saw a paper about how the garbage collector could discover this, and update both thunks simultaneously. (Unfortunately, I can't seem to find it now.) -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Mon Jul 7 04:21:33 2008 From: ketil at malde.org (Ketil Malde) Date: Mon Jul 7 04:11:59 2008 Subject: Reading A Monad Tutorial (Re: [Haskell-cafe] Ode from a Haskeller to a Schemer) In-Reply-To: (Benjamin L. Russell's message of "Mon\, 07 Jul 2008 15\:26\:37 +0900") References: <7687290b0807041243s59b4d607s3cffcb123a7b2bc0@mail.gmail.com> Message-ID: <87iqvi9kaa.fsf_-_@malde.org> (With apologies to Queen.) Is this the RealWorld#? Is this I/O I see? Caught in a monad - No escape back to purity Open a file, it wipes out my smile to see I'm just a programmer, don't need a Ph.D I'm easy come, easy go Don't need this high brow weird monadic action, no real reaction for me, from G-HC Hey man, I just found out that it is easy to achieve using unsafeInterleave and unsafe...PerformIO but people tell me I should let those go Oh man, no-o-o I'm about to start to cry If I can't make this stuff compile tomorrow I will just carry on Nothing really matters. Too late - 'cause I got it now there are monads all around IO, State and lists abound It's easy, like those people say but my program got abstracted all away! Maybe - o o o, It's a monad too, I know Why should I use another language at all? -k -- If I haven't seen further, it is by standing in the footprints of giants From frantisek.kocun at gmail.com Mon Jul 7 05:57:25 2008 From: frantisek.kocun at gmail.com (fero) Date: Mon Jul 7 05:48:16 2008 Subject: [Haskell-cafe] Interesting feature Message-ID: <18311432.post@talk.nabble.com> Hi I have read in one tutorial (I can't find it again, but it was probably either one on ibm, gentle introduction or yaht), that it is possible to define relationships between free variables and the same program can be used to calculate either first variable when second is set or second when first is set. I have understood this as if I set first free variable, run program and write name of second variable and I get result, and vice versa. I don't know if I understood it well. It looks really interesting but I can't figure out how to do it. Is this really possible? (I doubt.) If yes show example please. Thanks Fero -- View this message in context: http://www.nabble.com/Interesting-feature-tp18311432p18311432.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lemming at henning-thielemann.de Mon Jul 7 06:30:34 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jul 7 06:21:40 2008 Subject: [Haskell-cafe] Interesting feature In-Reply-To: <18311432.post@talk.nabble.com> References: <18311432.post@talk.nabble.com> Message-ID: On Mon, 7 Jul 2008, fero wrote: > Hi I have read in one tutorial (I can't find it again, but it was probably > either one on ibm, gentle introduction or yaht), that it is possible to > define relationships between free variables and the same program can be used > to calculate either first variable when second is set or second when first > is set. I have understood this as if I set first free variable, run program > and write name of second variable and I get result, and vice versa. I don't > know if I understood it well. It looks really interesting but I can't figure > out how to do it. Is this really possible? (I doubt.) If yes show example > please. Are you talking about logic programming and PROLOG? $ pl # swi-prolog ?- plus(X,2,3). X = 1 ; No ?- plus(1,X,3). X = 2 ; No ?- plus(1,2,X). X = 3 ; No Actually the type system of Haskell is also logic programming. I have implemented a simple kind of logic programming using lazy peano numbers: http://darcs.haskell.org/unique-logic/ From greenrd at greenrd.org Mon Jul 7 06:34:57 2008 From: greenrd at greenrd.org (Robin Green) Date: Mon Jul 7 06:27:00 2008 Subject: [Haskell-cafe] Interesting feature In-Reply-To: References: <18311432.post@talk.nabble.com> Message-ID: <20080707113457.1f145e85@greenrd.org> On Mon, 07 Jul 2008 12:30:34 +0200 (CEST) Henning Thielemann wrote: > Actually the type system of Haskell is also logic programming. I > have implemented a simple kind of logic programming using lazy peano > numbers: http://darcs.haskell.org/unique-logic/ There is also Curry which is basically Haskell extended with features from logic programming. There you get to use ordinary values instead of having to use types. However, it seems that Curry's solution finding mechanism is built-in to the language and cannot be modified (e.g. for performance reasons) without modifying the language implementation. (I think the same would be true for logic programming with Haskell types.) -- Robin From simonpj at microsoft.com Mon Jul 7 06:43:00 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Mon Jul 7 06:33:53 2008 Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc) In-Reply-To: <404396ef0807051602g44b6ca81u39a2b3ee37492065@mail.gmail.com> References: <404396ef0807051600k100e5e19p2f6a931ce5f22d4@mail.gmail.com> <404396ef0807051602g44b6ca81u39a2b3ee37492065@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE741BBEA@EA-EXMSG-C334.europe.corp.microsoft.com> I think GHC is right here. See http://haskell.org/onlinereport/decls.html#instance-decls esp the bit starting "It is illegal to give a binding..." Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Neil | Mitchell | Sent: 06 July 2008 00:03 | To: Haskell Cafe | Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc) | | > This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but | > the compilers disagree: | > | > import Prelude hiding ((==)) | > data Foo = Foo | > instance Eq Foo where | > (==) a b = True | | I was thinking that GHC's behaviour seems more sensible, but the | following fails: | | import qualified Module as M | | instance MClass Foo where | M.foo = undefined | | M. is not allowed as a prefix of a function, which makes resolving | ambiguities hard unless the compiler solves the issue for you (as Hugs | and Yhc do) | | Thanks | | Neil | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From voigt at tcs.inf.tu-dresden.de Mon Jul 7 06:53:43 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Mon Jul 7 06:38:06 2008 Subject: [Haskell-cafe] Interesting feature In-Reply-To: <20080707113457.1f145e85@greenrd.org> References: <18311432.post@talk.nabble.com> <20080707113457.1f145e85@greenrd.org> Message-ID: <4871F5B7.2030907@tcs.inf.tu-dresden.de> Robin Green wrote: > On Mon, 07 Jul 2008 12:30:34 +0200 (CEST) > Henning Thielemann wrote: > > >> Actually the type system of Haskell is also logic programming. I >>have implemented a simple kind of logic programming using lazy peano >>numbers: http://darcs.haskell.org/unique-logic/ > > > There is also Curry which is basically Haskell extended with features > from logic programming. There you get to use ordinary values instead of > having to use types. However, it seems that Curry's solution finding > mechanism is built-in to the language and cannot be modified (e.g. for > performance reasons) without modifying the language implementation. (I Actually, I think it can: http://dblp.uni-trier.de/rec/bibtex/conf/iclp/HanusS98 Also more recently, I heard of a way to abstract a nondeterministic Curry value into its explicit search tree, which one can then traverse to one's own liking. Obviously, people on the Curry list will know more about the details... Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From jules at jellybean.co.uk Mon Jul 7 06:52:51 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jul 7 06:43:44 2008 Subject: [Haskell-cafe] Interesting feature In-Reply-To: <18311432.post@talk.nabble.com> References: <18311432.post@talk.nabble.com> Message-ID: <4871F583.5030500@jellybean.co.uk> fero wrote: > Hi I have read in one tutorial (I can't find it again, but it was probably > either one on ibm, gentle introduction or yaht), that it is possible to > define relationships between free variables and the same program can be used > to calculate either first variable when second is set or second when first > is set. I have understood this as if I set first free variable, run program > and write name of second variable and I get result, and vice versa. I don't > know if I understood it well. It looks really interesting but I can't figure > out how to do it. Is this really possible? (I doubt.) If yes show example > please. See also metafont, which defines equational relationships between variables and solves. Jules From ndmitchell at gmail.com Mon Jul 7 07:01:39 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jul 7 06:52:30 2008 Subject: [Haskell-cafe] Interesting feature In-Reply-To: <18311432.post@talk.nabble.com> References: <18311432.post@talk.nabble.com> Message-ID: <404396ef0807070401pb6427do8bef0735659b856@mail.gmail.com> Hi > Hi I have read in one tutorial (I can't find it again, but it was probably > either one on ibm, gentle introduction or yaht), that it is possible to > define relationships between free variables and the same program can be used > to calculate either first variable when second is set or second when first > is set. Here is how to do it in Haskell: http://portal.acm.org/citation.cfm?id=1291201.1291207 Thanks Neil From frantisek.kocun at gmail.com Mon Jul 7 07:22:35 2008 From: frantisek.kocun at gmail.com (fero) Date: Mon Jul 7 07:13:26 2008 Subject: [Haskell-cafe] Interesting feature In-Reply-To: <404396ef0807070401pb6427do8bef0735659b856@mail.gmail.com> References: <18311432.post@talk.nabble.com> <404396ef0807070401pb6427do8bef0735659b856@mail.gmail.com> Message-ID: <18314566.post@talk.nabble.com> Thanks a lot Neil, I will definitely read it. I searched google and found the same article here for free http://www.cs.chalmers.se/~emax/wired/documents/LP_HFL07.pdf I didn't know that Haskell commuity is so alive. Much more answers in much less time than when I wrote something to jav:) Fero Neil Mitchell wrote: > > Hi > >> Hi I have read in one tutorial (I can't find it again, but it was >> probably >> either one on ibm, gentle introduction or yaht), that it is possible to >> define relationships between free variables and the same program can be >> used >> to calculate either first variable when second is set or second when >> first >> is set. > > Here is how to do it in Haskell: > > http://portal.acm.org/citation.cfm?id=1291201.1291207 > > Thanks > > Neil > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Interesting-feature-tp18311432p18314566.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From chris at eidhof.nl Mon Jul 7 08:17:49 2008 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Jul 7 08:08:44 2008 Subject: [Haskell-cafe] Compiling GHC 6.8.3 on OS X with readline support Message-ID: Hey all, When compiling GHC 6.8.3 on OS X, I ended up with a GHCi without readline support. That makes interacting quite hard, especially because the Backspace-key didn't even work. With some help on irc from Baughn and by reading a blog post from Paul Brown, I managed to get readline working after all. After installing readline from fink, I had to pass the following options to configure: ./configure --with-readline-includes=/sw/include/readline --with- readline-libraries=/sw/lib After that make and sudo make install worked just fine, and I had readline again! I wrote this down in case anybody else has had the same problems. -chris From mfeathers at mindspring.com Mon Jul 7 08:21:15 2008 From: mfeathers at mindspring.com (Michael Feathers) Date: Mon Jul 7 08:17:19 2008 Subject: [Haskell-cafe] Is there anything manifestly stupid about this code? In-Reply-To: <1215393502.5818.4.camel@derek-laptop> References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> <48716B16.5040901@mindspring.com> <1215393502.5818.4.camel@derek-laptop> Message-ID: <48720A3B.8080503@mindspring.com> Thanks. Here's a newb question: what does strictness really get me in this code? BTW, I only noticed the Complex type late. I looked at it and noticed that all I'd be using is the constructor and add. Didn't seem worth the change. Michael Derek Elkins wrote: > To answer the question in your subject, yes! We have a complex type. > Not only does that make the code simpler and more obvious and idiomatic, > but it's also more efficient because for this use you'd really prefer a > strict pair type for "Point", and complex is strict in it's components. > > On Sun, 2008-07-06 at 21:02 -0400, Michael Feathers wrote: >> Decided a while ago to write some code to calculate the Mandelbrot set >> using the escape iterations algorithm. Discovered after mulling it >> about that I could just built it as an infinite list of infinite lists >> and then extract any rectangle of values that I wanted: >> >> type Point = (Double, Double) > >> sq :: Double -> Double >> sq x = x ^ 2 >> >> translate :: Point -> Point -> Point >> translate (r0, i0) (r1, i1) = >> (r0 + r1, i0 + i1) >> >> mandel :: Point -> Point >> mandel (r, i) = >> (sq r + sq i, 2 * r * i) >> >> notEscaped :: Point -> Bool >> notEscaped (r, i) = >> (sq r + sq i) <= 4.0 >> >> trajectory :: (Point -> Point) -> [Point] >> trajectory pointFunction = >> takeWhile notEscaped $ iterate pointFunction seed >> where seed = (0.0, 0.0) >> >> escapeIterations :: (Point -> Point) -> Int >> escapeIterations = >> length . tail . take 1024 . trajectory >> >> mandelbrot :: Double -> [[Int]] >> mandelbrot incrementSize = >> [[ escapeIterations $ translate (x, y) . mandel >> | x <- increments] >> | y <- increments] where >> increments = [0.0, incrementSize .. ] >> >> window :: (Int, Int) -> (Int, Int) -> [[a]] -> [[a]] >> window (x0, y0) (x1, y1) = range x0 x1 . map (range y0 y1) where >> range m n = take (n - m) . drop m >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Now Playing: Clammbon - 246 http://youtube.com/watch?v=PO77bN8W1mA From miguelimo38 at yandex.ru Mon Jul 7 08:31:55 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Jul 7 08:24:07 2008 Subject: [Haskell-cafe] Compiling GHC 6.8.3 on OS X with readline support In-Reply-To: References: Message-ID: "rlwrap" adds readline support to everything. On 7 Jul 2008, at 16:17, Chris Eidhof wrote: > Hey all, > > When compiling GHC 6.8.3 on OS X, I ended up with a GHCi without > readline support. That makes interacting quite hard, especially > because the Backspace-key didn't even work. With some help on irc > from Baughn and by reading a blog post from Paul Brown, I managed to > get readline working after all. > > After installing readline from fink, I had to pass the following > options to configure: > > ./configure --with-readline-includes=/sw/include/readline --with- > readline-libraries=/sw/lib > > After that make and sudo make install worked just fine, and I had > readline again! I wrote this down in case anybody else has had the > same problems. > > -chris > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lrpalmer at gmail.com Mon Jul 7 08:37:52 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 7 08:28:43 2008 Subject: [Haskell-cafe] Is there anything manifestly stupid about this code? In-Reply-To: <48720A3B.8080503@mindspring.com> References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> <48716B16.5040901@mindspring.com> <1215393502.5818.4.camel@derek-laptop> <48720A3B.8080503@mindspring.com> Message-ID: <7ca3f0160807070537m24668943o2439a932523b65e5@mail.gmail.com> On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers wrote: > Thanks. Here's a newb question: what does strictness really get me in this > code? A bit of speed and memory improvements, I suspect. The type (Double,Double) has three boxes, one for the tuple and one for each double. The type Complex, which is defined as data Complex a = !a :+ !a has one box (after -funbox-strict-fields has done its work), the one for the type as a whole. So it will end up using less memory, and there will be fewer jumps to evaluate one (a jump is made for each box). > BTW, I only noticed the Complex type late. I looked at it and noticed that > all I'd be using is the constructor and add. Didn't seem worth the change. You would also be using the multiply and magnitude functions! And you would gain code readability, since you could define: mandel c z = z^2 + c trajectory c = iterate (mandel c) 0 Which is basically the mathematical definition right there in front of you, instead of splayed out all over the place. Luke From pablo at babel.ls.fi.upm.es Mon Jul 7 11:07:17 2008 From: pablo at babel.ls.fi.upm.es (Pablo Nogueira) Date: Mon Jul 7 10:58:08 2008 Subject: [Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly Message-ID: I find this interesting, GHCi accepts a function |dmap| which I show below and infers its type, but if I annotate the function with the inferred type, GHCi's type-checker rejects it. I'm trying to generalise the datatype-generic dmap: < dmap :: Bifunctor s => (a -> b) -> Fix s a -> Fix s b < dmap f = In . bimap (dmap f) f . out where > data Fix s a = In { out :: s (Fix s a) a } > > class Bifunctor s where > bimap :: (a -> c) -> (b -> d) -> s a b -> s c d The idea is that recursive types are represented by their (lamba-lifted) functors, eg: > data ListF b a = NilF | ConsF a b > instance Bifunctor ListF where > bimap f g NilF = NilF > bimap f g (ConsF a b) = ConsF (g a) (f b) I now define two classes: > class From a c x where > from :: a x -> c x > > class To a c y where > to :: c y -> a y And a generic |gmap| which given the map for |c| and a mapping for |x| delivers the map for |a|: > type GMap t x y = (x -> y) -> t x -> t y > > gmap :: (From a c x, To a c y) => GMap c x y -> GMap a x y > gmap gmc gmx = to . gmc gmx . from I want to write |dmap| as a special case of |gmap|, but I can't even get there. If I write > dmap f = to . bimap (dmap f) f . from GHCi infers it has type (up to renaming): (From a1 (s (a1 x)) x, Bifunctor s, To a2 (s (a2 y)) y) => (x -> y) -> a1 x -> a2 y But if I cut and paste the type into the code I get type errors: Could not deduce (From a1 (s1 (a11 x)) x) ... Could not deduce (From a11 (s1 (a11 x)) x, To a21 (s1 (a21 y)) y) ... Could not deduce (From a1 (s1 (a11 x)) x) ... Interesting, From bauertim at eecs.orst.edu Mon Jul 7 11:14:37 2008 From: bauertim at eecs.orst.edu (Tim Bauer) Date: Mon Jul 7 11:06:25 2008 Subject: [Haskell-cafe] Avoiding lazy evaluation in an ErrorT computation Message-ID: <487232DD.7000407@eecs.orst.edu> The file below models a problem I have been trying to figure out. This file simplifies my original code, while still illustrating the problem. > import Prelude hiding (catch) > import Control.Monad.Reader > import Control.Monad.Error > import Control.Exception > import System.IO(readFile) > import Data.Either(either) Our monad transformer is an ErrorT which wraps the IO monad. ErrorT allows us to use throwError, but we won't use it in this example. > type T a = ErrorT String IO a The following runs a (T a) in the context of the IO monad. We wrap runErrorT in try so as to catch things like division by zero and what not. > doTinIO :: T a -> IO (Either String a) > doTinIO ta = do > exesa <- try (runErrorT ta) -- IO (Either Exception (Either String a)) > return $ case exesa of > Left x -> Left ("EX: "++(show x)) > Right esa -> esa > > boom = 1 `div` 0 > b1 = return boom :: T Int > bad = doTinIO b1 The above, bad, results in: Right *** Exception: divide by zero My hope was to get Left "EX: divide by zero" I cannot understand why the `try' does not get a chance at the erroneous calculation. That is, I want the try to catch the runtime exception. Indeed, if the IO computation is strictly computed, I get the proper result. > g1 = boom `seq` (return boom :: T Int) > good = doTinIO g1 Stuff that raises exceptions in IO actions does not work either. > g2 = doTinIO (return boom) Results in: ``Right *** Exception: divide by zero'' However, other actions that do raise errors work correctly. It appears the value of the computation must be used as the next two examples show. > g3 = doTinIO (liftIO (readFile "nonexistent")) > g4 = doTinIO (liftIO (print boom)) My problem is that I control `doTinIO', but someone else provides the computation (T a). I cannot force callers to strictly evaluate their computations. I've tried three other variants (given below) that are all nearly equivalent. > handler :: Exception -> IO (Either String a) > handler = return . Left . ("EX: "++) . show > > doTinIO2 :: T a -> IO (Either String a) > doTinIO2 ta = catch (runErrorT ta >>= evaluate) handler > > doTinIO3 :: T a -> IO (Either String a) > doTinIO3 ta = do > esa <- catch (runErrorT ta) handler > case esa of > Right a -> catch (evaluate (return a)) handler > l -> return l > > doTinIO4 :: T a -> IO (Either String a) > doTinIO4 ta = catch (runErrorT ta) handler *Main> doTinIO2 b1 Right *** Exception: divide by zero *Main> doTinIO3 b1 Right *** Exception: divide by zero *Main> doTinIO4 b1 Right *** Exception: divide by zero Any suggestions? Thanks all. From allbery at ece.cmu.edu Mon Jul 7 11:23:11 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jul 7 11:14:02 2008 Subject: [Haskell-cafe] Avoiding lazy evaluation in an ErrorT computation In-Reply-To: <487232DD.7000407@eecs.orst.edu> References: <487232DD.7000407@eecs.orst.edu> Message-ID: <4D22C902-B51C-4FFC-B6DD-437A192691F4@ece.cmu.edu> On 2008 Jul 7, at 11:14, Tim Bauer wrote: > My problem is that I control `doTinIO', but someone else provides > the computation (T a). I cannot force callers to strictly evaluate > their computations. try (Control.Exception.evaluate ...) -- ? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From ken.takusagawa.2 at gmail.com Mon Jul 7 11:26:53 2008 From: ken.takusagawa.2 at gmail.com (Ken Takusagawa) Date: Mon Jul 7 11:17:43 2008 Subject: [Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2 In-Reply-To: <20080707055100.881A0276C4F@mail.avvanta.com> References: <20080707055100.881A0276C4F@mail.avvanta.com> Message-ID: <4dcea1d80807070826j5eb95624kbc36ac905095b5f3@mail.gmail.com> Thanks. Here's the quick-and-dirty patch I applied to make things work. --- /tmp/hopenssl-1.0/OpenSSL/Digest.hs 2008-02-20 18:43:43.000000000 -0500 +++ hopenssl-1.0/OpenSSL/Digest.hs 2008-07-07 02:06:55.000000000 -0400 @@ -197,7 +197,7 @@ foreign import ccall unsafe "EVP_sha1" mdSHA1 :: IO MDEngine foreign import ccall unsafe "EVP_dss" mdDSS :: IO MDEngine foreign import ccall unsafe "EVP_dss1" mdDSS1 :: IO MDEngine -foreign import ccall unsafe "EVP_mdc2" mdMDC2 :: IO MDEngine +--foreign import ccall unsafe "EVP_mdc2" mdMDC2 :: IO MDEngine foreign import ccall unsafe "EVP_ripemd160" mdRIPEMD160 :: IO MDEngine -- |Map a 'MessageDigest' type into the the corresponding @@ -211,7 +211,7 @@ toMDEngine SHA1 = mdSHA1 toMDEngine DSS = mdDSS toMDEngine DSS1 = mdDSS1 -toMDEngine MDC2 = mdMDC2 +toMDEngine MDC2 = undefined toMDEngine RIPEMD160 = mdRIPEMD160 -- * Helper Functions On Mon, Jul 7, 2008 at 1:51 AM, Donn Cave wrote: > Quoth "Ken Takusagawa" : > > | $ ghc --make test-hopenssl.hs -lcrypto > | [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o ) > | Linking test-hopenssl ... > | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In > | function `s2O8_info': > | (.text+0xf3a): undefined reference to `EVP_mdc2' > | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In > | function `s2TQ_info': > | (.text+0x1435): undefined reference to `EVP_mdc2' > | collect2: ld returned 1 exit status > > I see the following in the Configure file for openssl-0.9.8h: > > my $default_depflags = "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SEED -DOPENSSL_NO_TLSEXT ";my $default_depflags = "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP > > I don't know why this would be, but I infer that the function hopenssl > was looking for is commonly missing in SSL builds. > > Donn Cave, donn@avvanta.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From alfonso.acosta at gmail.com Mon Jul 7 11:30:21 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Mon Jul 7 11:21:12 2008 Subject: [Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly In-Reply-To: References: Message-ID: <6a7c66fc0807070830g2ed50625s1038b8f33e319609@mail.gmail.com> Hi Pablo, On Mon, Jul 7, 2008 at 10:07 AM, Pablo Nogueira wrote: > GHCi infers it has type (up to renaming): > > (From a1 (s (a1 x)) x, Bifunctor s, To a2 (s (a2 y)) y) => (x -> y) > -> a1 x -> a2 y > > But if I cut and paste the type into the code I get type errors: > > Could not deduce (From a1 (s1 (a11 x)) x) ... > Could not deduce (From a11 (s1 (a11 x)) x, To a21 (s1 (a21 y)) y) ... > Could not deduce (From a1 (s1 (a11 x)) x) ... I myselft don't understand why GHCi doesn't accept the type it infered as an explicit signature ... but your problem seems to be caused by a lack of functional dependencies. Redefining To and From as .. class From a c x | a -> c where from :: a x -> c x class To a c y | c -> a where to :: c y -> a y ... hushes GHCi. The question now is, of course, if the new dependencies are too restrictive for your problem. From matthew at wellquite.org Mon Jul 7 11:38:53 2008 From: matthew at wellquite.org (Matthew Sackman) Date: Mon Jul 7 11:29:45 2008 Subject: [Haskell-cafe] Re: Anglo Haskell 2008 In-Reply-To: <20080701121546.GC1808@arkansas.doc.ic.ac.uk> References: <20080701121531.GB1808@arkansas.doc.ic.ac.uk> Message-ID: <20080707153853.GB6240@wellquite.org> On Tue, Jul 01, 2008 at 01:15:31PM +0100, Matthew Sackman wrote: > Anglo Haskell is a gathering of all people Haskell-related from > beginners, to seasoned hackers to academic giants. All and more are > welcomed by large fuzzy green lambdas. > > In contrast to the last two years which have been held at MSR Cambridge > (UK), we're this year proposing to hold the event at Imperial College, > London. London is probably easier to get to and from (though more > tedious to get across) than Cambridge and we hope this will attract > people who previously have not been able to get out to Cambridge. > > The proposed dates are Friday the 8th and Saturday the 9th of August. > > More details are available on the wikipage: > http://www.haskell.org/haskellwiki/AngloHaskell/2008 > Please feel free to add to this page. There have been no objections to holding Anglo Haskell at Imperial this year and no objections about dates either. Thus we're now able to confirm this will happen at Imperial on the 8th and 9th of August as advertised. Some people have signed up on the wiki page, please add your name if you are able to come or are considering coming along. Also please make use of the wiki page and #anglohaskell irc channel to arrange where to stay overnight if necessary. Finally, once again, if you'd like to give a talk then please add your name to the list on the wiki page. We really do need both attendees and speakers to make this event a success. Matthew -- Matthew Sackman http://www.wellquite.org/ From claus.reinke at talk21.com Mon Jul 7 12:16:55 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Jul 7 12:07:50 2008 Subject: [Haskell-cafe] Compiling GHC 6.8.3 on OS X with readline support References: Message-ID: <00e901c8e04c$e0ff6770$04308351@cr3lt> > "rlwrap" adds readline support to everything. Well, yes, see the GHCi wiki for how to augment 'rlwrap ghci' with some basic completion support (filenames, flags, module names): http://www.haskell.org/haskellwiki/GHC/GHCi#rlwrap_-_what_to_try_when_your_GHCi_was_compiled_without_readline.2Feditline but is there a way to make rlwrap's completion context-sensitive? As with bash's complete command, for instance, I'd like to be able to tell rlwrap that :load wants filenames, while :module wants module names, and :set wants settable things. If your ghci is readline/editline enabled, you get quite specific support (or so I gather from the source code..), while rlwrap seems to throw everything in one pot. That said, rlwrap is still a good workaround, Claus From wnoise at ofb.net Mon Jul 7 13:23:45 2008 From: wnoise at ofb.net (Aaron Denney) Date: Mon Jul 7 13:14:44 2008 Subject: [Haskell-cafe] Re: Is there anything manifestly stupid about this code? References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> <48716B16.5040901@mindspring.com> <1215393502.5818.4.camel@derek-laptop> <48720A3B.8080503@mindspring.com> <7ca3f0160807070537m24668943o2439a932523b65e5@mail.gmail.com> Message-ID: On 2008-07-07, Luke Palmer wrote: > On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers > wrote: >> BTW, I only noticed the Complex type late. I looked at it and noticed that >> all I'd be using is the constructor and add. Didn't seem worth the change. > > You would also be using the multiply and magnitude functions! Well, he should continue to use a custom "magnitude squared" function, to save the square-rooting. -- Aaron Denney -><- From dons at galois.com Mon Jul 7 13:24:55 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 7 13:15:47 2008 Subject: [Haskell-cafe] Is there anything manifestly stupid about this code? In-Reply-To: <7ca3f0160807070537m24668943o2439a932523b65e5@mail.gmail.com> References: <48715931.6050101@mindspring.com> <20080706235527.GE31871@liouville.galois.com> <4871636B.8000304@mindspring.com> <20080707004204.GF31871@liouville.galois.com> <48716B16.5040901@mindspring.com> <1215393502.5818.4.camel@derek-laptop> <48720A3B.8080503@mindspring.com> <7ca3f0160807070537m24668943o2439a932523b65e5@mail.gmail.com> Message-ID: <20080707172455.GC2396@liouville.galois.com> lrpalmer: > On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers > wrote: > > Thanks. Here's a newb question: what does strictness really get me in this > > code? > > A bit of speed and memory improvements, I suspect. The type > (Double,Double) has three boxes, one for the tuple and one for each > double. The type Complex, which is defined as > > data Complex a = !a :+ !a > > has one box (after -funbox-strict-fields has done its work), the one > for the type as a whole. So it will end up using less memory, and > there will be fewer jumps to evaluate one (a jump is made for each > box). On a good day the two Double components will be unpacked into registers entirely. As here, a loop on Complex: {-# OPTIONS -funbox-strict-fields #-} module M where data Complex = !Double :+ !Double conjugate :: Complex -> Complex conjugate (x:+y) = x :+ (-y) realPart :: Complex -> Double realPart (x :+ _) = x go :: Complex -> Double go n | realPart n > pi = realPart n | otherwise = go (conjugate n) Note that notionally Complex has 3 indirections, the Complex constructor, and two for the Doubles. After optimisation however, there's only unboxed doubles in registers left: M.$wgo :: Double# -> Double# -> Double# M.$wgo = \ (ww_sjT :: Double#) (ww1_sjU :: Double#) -> case >## ww_sjT 3.141592653589793 of wild_Xs { False -> M.$wgo ww_sjT (negateDouble# ww1_sjU); True -> ww_sjT -- Don From pgavin at gmail.com Mon Jul 7 14:27:02 2008 From: pgavin at gmail.com (Peter Gavin) Date: Mon Jul 7 14:18:02 2008 Subject: [Haskell-cafe] Re: ANN: Gtk2Hs 0.9.13 released In-Reply-To: References: <4865ADA5.3070103@gmail.com> Message-ID: <48725FF6.3060208@gmail.com> Ashley Yakeley wrote: > Peter Gavin wrote: >> Gtk2Hs version 0.9.13 is now available. [1] >> >> New features: >> >> * bindings for Gnome VFS and GStreamer > > Is this bindings for the new GIO/GVFS stuff? No, its for the old GnomeVFS binding. I may get around to the binding the new one, unless someone else wants to do it :) > > Is Gtk2Hs cabal-ised? Not yet, but it's planned. The things we need from cabal to do it aren't finished yet, and every .chs file needs to be rewritten to work with the real c2hs, rather than our hacked up version :) Pete > > -- Ashley > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From narutocanada at gmail.com Mon Jul 7 14:30:56 2008 From: narutocanada at gmail.com (naruto canada) Date: Mon Jul 7 14:21:54 2008 Subject: [Haskell-cafe] parsec linking problem Message-ID: <9dde3d700807071130h62b78a1ckfbb29dfebaee317f@mail.gmail.com> hi I've just managed to get ghc-6.8.3 installed and tried to run an example from "http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing" I run into linking error with parsec: Here is the code: module Main where import System.Environment import Text.ParserCombinators.Parsec hiding (spaces) symbol :: Parser Char symbol = oneOf "!#$%&|*+-/:<=>?@^_~" main :: IO () main = do -- args <- getArgs -- putStrLn ("Hello, " ++ (args!!0) ++ " " ++ (args!!1) ) -- putStrLn ( show( read(args!!0) + read(args!!1) ) ) putStrLn ( "give me a name:" ) name <- getLine putStrLn ( name ) ghc -o /tmp/a.out accu.hs accu.o: In function `so8_info': : undefined reference to `parseczm2zi1zi0zi1_TextziParserCombinatorsziParsecziChar_oneOf_closure' accu.o: In function `spP_info': : undefined reference to `__stginit_parseczm2zi1zi0zi1_TextziParserCombinatorsziParsec_' accu.o: In function `so8_closure': : undefined reference to `parseczm2zi1zi0zi1_TextziParserCombinatorsziParsecziChar_oneOf_closure' collect2: ld returned 1 exit status Thanks my installation steps (just in case you need to know): WGET_UNPACK http://ftp.gnu.org/gnu/readline/readline-4.3.tar.gz ./configure --prefix=/usr make clean ; make || INTERVENTION find . -name libhistory.so* find . -name libreadline.so* cp shlib/libhistory.so.4.3 /lib cp shlib/libreadline.so.4.3 /lib ln -sfvn libhistory.so.4.3 /lib/libhistory.so.4 ln -sfvn libreadline.so.4.3 /lib/libreadline.so.4 WGET_UNPACK http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-i386-unknown-linux.tar.bz2 cd ghc-6.8.2 autoreconf ./configure --prefix=/usr make install echo 'main = putStrLn "hello"' > t.hs ghc t.hs ./a.out | grep hello || INTERVENTION rm -rf /build/ghc-6.8.2 WGET_UNPACK http://haskell.org/ghc/dist/6.8.3/ghc-6.8.3-src-extralibs.tar.bz2 WGET_UNPACK http://haskell.org/ghc/dist/6.8.3/ghc-6.8.3-src.tar.bz2 cd ghc-6.8.3 autoreconf ./configure --prefix=/usr make clean ; make || INTERVENTION make || INTERVENTION make install echo 'main = putStrLn "hello"' > t.hs ghc t.hs ./a.out | grep hello || INTERVENTION ghc --version | grep 6.8.3 || INTERVENTION From claudiusmaximus at goto10.org Mon Jul 7 14:37:50 2008 From: claudiusmaximus at goto10.org (Claude Heiland-Allen) Date: Mon Jul 7 14:28:42 2008 Subject: [Haskell-cafe] parsec linking problem In-Reply-To: <9dde3d700807071130h62b78a1ckfbb29dfebaee317f@mail.gmail.com> References: <9dde3d700807071130h62b78a1ckfbb29dfebaee317f@mail.gmail.com> Message-ID: <4872627E.7010602@goto10.org> naruto canada wrote: > I run into linking error with parsec: > ghc -o /tmp/a.out accu.hs Try ghc --make, or pass appropriate package flags on the command line so that it gets linked with Parsec. Claude -- http://claudiusmaximus.goto10.org From pgavin at gmail.com Mon Jul 7 14:41:26 2008 From: pgavin at gmail.com (Peter Gavin) Date: Mon Jul 7 14:32:26 2008 Subject: [Haskell-cafe] Re: [Gtk2hs-users] ANN: Gtk2Hs 0.9.13 released In-Reply-To: References: <4865ADA5.3070103@gmail.com> Message-ID: <48726356.7020306@gmail.com> Peter Hercek wrote: > Thanks for the package. > I experienced some bugs with it on windows. When showing a dynamically > built context menu, I'm getting errors like these: > > _cairo_win32_surface_show_glyphs(ExtTextOutW failed): The operation completed successfully. > _flush_glyphs: The operation completed successfully. > > ... and the text of some menu items is not shown (otherwise the menu > items do work - actions are called when they are clicked). > > When I try to run the app under ghci I get error like this: > > Loading package glib-0.9.13 ... : Unknown PEi386 section name `.reloc' (while processing: > C:/tools/Gtk2Hs/HSglib.o) > ghc.exe: panic! (the 'impossible' happened) > (GHC version 6.8.3 for i386-unknown-mingw32): > loadObj: failed > Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug > > Using older Gtk (2.10.13) helps for the first one. > Using my own compile of Gtk2Hs (I compiled older version 0.9.12.1 > myself) helps for the second one. > > Peter. Hi Peter, The first problem looks like a problem in cairo. I'm pretty sure the functions named are cairo internal API, you may want to report a bug to their list. I suppose it's possible those functions always print the error message (even on success), but behave correctly otherwise. It looks like the second problem is a GHC bug, since there isn't anything special about our library (that I can think of) that might cause that to happen. Pete > > Peter Gavin wrote: >> Hello everyone, >> >> Gtk2Hs version 0.9.13 is now available. [1] >> >> New features: >> >> * bindings for Gnome VFS and GStreamer >> * a new Gtk+ tutorial has been adapted by Hans van Thiel >> * cairo image stride support >> * many new demos >> * compiles with GHC 6.8.3 >> * lots of bug fixes >> >> This release has been tested on a variety of platforms with different >> versions of Gtk+ and GHC, so you should have no trouble compiling it if >> you're using an older version of Gtk+. >> >> Note that the binaries for Win32 for this release are only provided for >> GHC 6.8.3 and Gtk+ 2.12. As with older releases, all the C libraries >> needed are included in the installer, so you don't need to download >> anything else to get up an running. I've also created zip files >> containing only the C libraries that can be used for redistribution. >> The sources for these binaries are available at [2] >> >> Links: >> [1] >> http://sourceforge.net/project/showfiles.php?group_id=49207&package_id=42440 >> [2] http://ftp.gnome.org/pub/GNOME/sources/ >> >> >> -- >> Pete >> >> ------------------------------------------------------------------------- >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://sourceforge.net/services/buy/index.php > > > > ------------------------------------------------------------------------- > Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! > Studies have shown that voting for your favorite open source project, > along with a healthy diet, reduces your potential for chronic lameness > and boredom. Vote Now at http://www.sourceforge.net/community/cca08 > _______________________________________________ > Gtk2hs-users mailing list > Gtk2hs-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users From narutocanada at gmail.com Mon Jul 7 14:50:47 2008 From: narutocanada at gmail.com (naruto canada) Date: Mon Jul 7 14:41:37 2008 Subject: [Haskell-cafe] parsec linking problem In-Reply-To: <4872627E.7010602@goto10.org> References: <9dde3d700807071130h62b78a1ckfbb29dfebaee317f@mail.gmail.com> <4872627E.7010602@goto10.org> Message-ID: <9dde3d700807071150y3be15aa6r71aaebc57ade8b7@mail.gmail.com> On 7/7/08, Claude Heiland-Allen wrote: > naruto canada wrote: >> I run into linking error with parsec: > >> ghc -o /tmp/a.out accu.hs > > Try ghc --make, or pass appropriate package flags on the command line so > that it gets linked with Parsec. Thanks, it works. > > > Claude > -- > http://claudiusmaximus.goto10.org > From jgoerzen at complete.org Mon Jul 7 15:18:18 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Jul 7 15:09:08 2008 Subject: [Haskell-cafe] Portland & OSCon Message-ID: <48726BFA.3060007@complete.org> Hi, OSCon is happening in Portland, OR starting 2 weeks from today, with probably the largest number of people there on July 23 and 24. I know there are a number of Haskellers that live in the Portland area, and I suspect a few more may be going to OSCon. Anyone interested in a Haskell gathering someplace? -- John From trevor at galois.com Mon Jul 7 16:25:16 2008 From: trevor at galois.com (Trevor Elliott) Date: Mon Jul 7 16:17:47 2008 Subject: [Haskell-cafe] Portland & OSCon In-Reply-To: <48726BFA.3060007@complete.org> References: <48726BFA.3060007@complete.org> Message-ID: <1215462316.5091.6.camel@trogdor> Hi John, I'd certainly be interested in some sort of meeting. What did you have in mind? --trevor On Mon, 2008-07-07 at 14:18 -0500, John Goerzen wrote: > Hi, > > OSCon is happening in Portland, OR starting 2 weeks from today, with > probably the largest number of people there on July 23 and 24. I know > there are a number of Haskellers that live in the Portland area, and I > suspect a few more may be going to OSCon. > > Anyone interested in a Haskell gathering someplace? > > -- John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080707/ca06589c/attachment.bin From jgoerzen at complete.org Mon Jul 7 16:57:26 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Jul 7 16:48:16 2008 Subject: [Haskell-cafe] Portland & OSCon In-Reply-To: <1215462316.5091.6.camel@trogdor> References: <48726BFA.3060007@complete.org> <1215462316.5091.6.camel@trogdor> Message-ID: <48728336.5010805@complete.org> Trevor Elliott wrote: > Hi John, > > I'd certainly be interested in some sort of meeting. What did you have > in mind? I don't really know. I'm not from Portland, so I'm sort of hoping that one of you local folks could take the lead on that. It could be a bar, restaurant, park (insert obligatory xkcd references here), BoF at OSCon (I think those are open to the public), or whatever everyone seems to like. -- John From ryani.spam at gmail.com Mon Jul 7 18:13:31 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jul 7 18:04:21 2008 Subject: [Haskell-cafe] extensible data types in Haskell? In-Reply-To: References: Message-ID: <2f9b2d30807071513k223be861p881a0ca9b7109bdf@mail.gmail.com> I like the approach the "Data Types a la Carte" paper takes to solve this problem. There's a small discussion here: http://wadler.blogspot.com/2008/02/data-types-la-carte.html Summary: if you model your data types as functors, typeclass machinery lets you combine them into an extensible whole, while maintaining type safety. You then create an "interpretation" class which allows data to choose how it interacts with a particular computation. The biggest weakness is that you need a type annotation at the point of calling the "interpretation" function. An example (leaving out the "library" bits): class Functor a => EvalSimple a where evalSimple :: a Int -> Int instance (EvalSimple a, EvalSimple b) => EvalSimple (a :+: b) where evalSimple (Inl a) = evalSimple a evalSimple (Inr b) = evalSimple b -- foldExpr :: Functor e => (e a -> a) -> Expr e -> a -- eval :: EvalSimple e => Expr e -> Int eval e = foldExpr evalSimple e newtype Val a = Val Int -- "trivial" functor instance Functor Val where fmap _ (Val x) = (Val x) instance EvalSimple Val where evalSimple (Val x) = x val x = inject (Val x) -- inject :: a :<: e => a (Expr e) -> Expr e -- val :: Val :<: e => Int -> Expr e data Add a = Add a a -- "pair" functor instance Functor Add where fmap f (Add a b) = Add (f a) (f b) add a b = inject (Add a b) instance EvalSimple Add where evalSimple (Add a b) = a + b -- here is where we need the type annotation sample :: Expr (Val :+: Add) sample = add (add (val 1) (val 2)) (val 3) sampleResult = eval sample -- is 6 On 7/6/08, David Walker wrote: > Hi all, > > SML conveniently contains the type "exn" which is an instance of an > "extensible data type". In other words, unlike normal data types that > are "closed" (can't admit new constructors once defined), SML's exn > type is "open," allowing programmers to keep adding new alternatives > as often as they choose. Like normal datatypes, the elimination form > for an extensible data type is a case statement (or match function). > > Friends have told me that Haskell doesn't have extensible data types. > However, it seems fairly straightforward to code them up using type > classes....though the solution I'm thinking of has a little bit of > boilerplate I'd like to scrap (you have to define a new type > declaration *and* an instance of a type class with a "match" method) > and matching occurs through a string comparison (which can lead to > silly programmer errors if there is accidentally a typo in the > string). > > Anyway, it's possible with some thought I could come up with a better > solution, but before worrying about it, I figured I'd ask if anybody > else already has a package that does this. It seems like a pretty > natural feature to want to have. > > Thanks in advance, > Dave > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Mon Jul 7 18:49:30 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jul 7 18:40:19 2008 Subject: [Haskell-cafe] Avoiding lazy evaluation in an ErrorT computation In-Reply-To: <487232DD.7000407@eecs.orst.edu> References: <487232DD.7000407@eecs.orst.edu> Message-ID: <2f9b2d30807071549n612429a6r82b51eaeb555fa15@mail.gmail.com> This is the classic "exception embedded in pure value" problem with lazy languages. There's no need for the "a" returned by "return" to be evaluated. Even using "seq" isn't quite good enough: > boom2 = [1 `div` 0] ghci> doTinIO (boom2 `seq` return boom2) Right [*** Exception: divide by zero If you want to guarantee that all embedded exceptions have been excised from a pure value, you need something like deepSeq; see http://hackage.haskell.org/packages/archive/hxt/7.4/doc/html/Control-Strategies-DeepSeq.html -- ryan On 7/7/08, Tim Bauer wrote: > The file below models a problem I have been trying to figure out. > This file simplifies my original code, while still illustrating > the problem. > > > import Prelude hiding (catch) > > import Control.Monad.Reader > > import Control.Monad.Error > > import Control.Exception > > import System.IO(readFile) > > import Data.Either(either) > > > Our monad transformer is an ErrorT which wraps the IO monad. > ErrorT allows us to use throwError, but we won't use it in this example. > > > type T a = ErrorT String IO a > > The following runs a (T a) in the context of the IO monad. > We wrap runErrorT in try so as to catch things like division > by zero and what not. > > > doTinIO :: T a -> IO (Either String a) > > doTinIO ta = do > > exesa <- try (runErrorT ta) -- IO (Either Exception (Either String a)) > > return $ case exesa of > > Left x -> Left ("EX: "++(show x)) > > Right esa -> esa > > > > boom = 1 `div` 0 > > b1 = return boom :: T Int > > bad = doTinIO b1 > > The above, bad, results in: > Right *** Exception: divide by zero > My hope was to get > Left "EX: divide by zero" > > I cannot understand why the `try' does not get a chance at the > erroneous calculation. That is, I want the try to catch > the runtime exception. > > Indeed, if the IO computation is strictly computed, I get > the proper result. > > > g1 = boom `seq` (return boom :: T Int) > > good = doTinIO g1 > > Stuff that raises exceptions in IO actions does not work either. > > > g2 = doTinIO (return boom) > > Results in: ``Right *** Exception: divide by zero'' > However, other actions that do raise errors work correctly. > > It appears the value of the computation must be used > as the next two examples show. > > > g3 = doTinIO (liftIO (readFile "nonexistent")) > > g4 = doTinIO (liftIO (print boom)) > > My problem is that I control `doTinIO', but someone else provides > the computation (T a). I cannot force callers to strictly evaluate > their computations. > > I've tried three other variants (given below) that are all > nearly equivalent. > > > handler :: Exception -> IO (Either String a) > > handler = return . Left . ("EX: "++) . show > > > > doTinIO2 :: T a -> IO (Either String a) > > doTinIO2 ta = catch (runErrorT ta >>= evaluate) handler > > > > doTinIO3 :: T a -> IO (Either String a) > > doTinIO3 ta = do > > esa <- catch (runErrorT ta) handler > > case esa of > > Right a -> catch (evaluate (return a)) handler > > l -> return l > > > > doTinIO4 :: T a -> IO (Either String a) > > doTinIO4 ta = catch (runErrorT ta) handler > > *Main> doTinIO2 b1 > Right *** Exception: divide by zero > *Main> doTinIO3 b1 > Right *** Exception: divide by zero > *Main> doTinIO4 b1 > Right *** Exception: divide by zero > > Any suggestions? Thanks all. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Mon Jul 7 18:50:35 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 7 18:43:32 2008 Subject: [Haskell-cafe] Avoiding lazy evaluation in an ErrorT computation In-Reply-To: <2f9b2d30807071549n612429a6r82b51eaeb555fa15@mail.gmail.com> References: <487232DD.7000407@eecs.orst.edu> <2f9b2d30807071549n612429a6r82b51eaeb555fa15@mail.gmail.com> Message-ID: <20080707225035.GG6942@liouville.galois.com> Just use 'rnf', from the Control.Parallel namespace. ryani.spam: > This is the classic "exception embedded in pure value" problem with > lazy languages. There's no need for the "a" returned by "return" to > be evaluated. > > Even using "seq" isn't quite good enough: > > > boom2 = [1 `div` 0] > > ghci> doTinIO (boom2 `seq` return boom2) > Right [*** Exception: divide by zero > > If you want to guarantee that all embedded exceptions have been > excised from a pure value, you need something like deepSeq; see > http://hackage.haskell.org/packages/archive/hxt/7.4/doc/html/Control-Strategies-DeepSeq.html > > -- ryan > > On 7/7/08, Tim Bauer wrote: > > The file below models a problem I have been trying to figure out. > > This file simplifies my original code, while still illustrating > > the problem. > > > > > import Prelude hiding (catch) > > > import Control.Monad.Reader > > > import Control.Monad.Error > > > import Control.Exception > > > import System.IO(readFile) > > > import Data.Either(either) > > > > > > Our monad transformer is an ErrorT which wraps the IO monad. > > ErrorT allows us to use throwError, but we won't use it in this example. > > > > > type T a = ErrorT String IO a > > > > The following runs a (T a) in the context of the IO monad. > > We wrap runErrorT in try so as to catch things like division > > by zero and what not. > > > > > doTinIO :: T a -> IO (Either String a) > > > doTinIO ta = do > > > exesa <- try (runErrorT ta) -- IO (Either Exception (Either String a)) > > > return $ case exesa of > > > Left x -> Left ("EX: "++(show x)) > > > Right esa -> esa > > > > > > boom = 1 `div` 0 > > > b1 = return boom :: T Int > > > bad = doTinIO b1 > > > > The above, bad, results in: > > Right *** Exception: divide by zero > > My hope was to get > > Left "EX: divide by zero" > > > > I cannot understand why the `try' does not get a chance at the > > erroneous calculation. That is, I want the try to catch > > the runtime exception. > > > > Indeed, if the IO computation is strictly computed, I get > > the proper result. > > > > > g1 = boom `seq` (return boom :: T Int) > > > good = doTinIO g1 > > > > Stuff that raises exceptions in IO actions does not work either. > > > > > g2 = doTinIO (return boom) > > > > Results in: ``Right *** Exception: divide by zero'' > > However, other actions that do raise errors work correctly. > > > > It appears the value of the computation must be used > > as the next two examples show. > > > > > g3 = doTinIO (liftIO (readFile "nonexistent")) > > > g4 = doTinIO (liftIO (print boom)) > > > > My problem is that I control `doTinIO', but someone else provides > > the computation (T a). I cannot force callers to strictly evaluate > > their computations. > > > > I've tried three other variants (given below) that are all > > nearly equivalent. > > > > > handler :: Exception -> IO (Either String a) > > > handler = return . Left . ("EX: "++) . show > > > > > > doTinIO2 :: T a -> IO (Either String a) > > > doTinIO2 ta = catch (runErrorT ta >>= evaluate) handler > > > > > > doTinIO3 :: T a -> IO (Either String a) > > > doTinIO3 ta = do > > > esa <- catch (runErrorT ta) handler > > > case esa of > > > Right a -> catch (evaluate (return a)) handler > > > l -> return l > > > > > > doTinIO4 :: T a -> IO (Either String a) > > > doTinIO4 ta = catch (runErrorT ta) handler > > > > *Main> doTinIO2 b1 > > Right *** Exception: divide by zero > > *Main> doTinIO3 b1 > > Right *** Exception: divide by zero > > *Main> doTinIO4 b1 > > Right *** Exception: divide by zero > > > > Any suggestions? Thanks all. > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From leaveye.guo at gmail.com Mon Jul 7 21:20:44 2008 From: leaveye.guo at gmail.com (L.Guo) Date: Mon Jul 7 21:11:38 2008 Subject: [Haskell-cafe] Hoogle often updates ? Message-ID: <200807080920431099315@gmail.com> Hi Haskellers: I have just been asked for usage of timer in haskell. Which I did not remember clearly. So I ask the search engine. In Hoogle: timer In Google: haskell timer After I tried these, I wonder, when and how often the hoogle update its database? And, could hoogle search range cover the hackages? I like hoogle engine. Bcuz it is a very usful tool which helps me learn haskell. Wish it better. Regards -------------- L.Guo 2008-07-08 From DekuDekuplex at Yahoo.com Mon Jul 7 22:25:29 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Jul 7 22:16:36 2008 Subject: [Haskell-cafe] Re: Interesting feature References: <18311432.post@talk.nabble.com> Message-ID: On Mon, 7 Jul 2008 02:57:25 -0700 (PDT), fero wrote: If you are interested in logic programming in a language with some similarity to Haskell, you might also wish to investigate the strongly typed logic programming language Godel (see http://www.cs.bris.ac.uk/~bowers/goedel.html). When I first saw an example of the code, I was surprised that, unlike Prolog, the language was strongly typed, and supported modules, and (albeit very loosely) resembled Haskell, except that it was a logic programming language. Here is an example of a program in Godel to compute a greatest common divisor (note the strong typing and usage of a module system) (see http://www.cs.bris.ac.uk/~bowers/goedel-example.html): MODULE GCD. IMPORT Integers. PREDICATE Gcd : Integer * Integer * Integer. Gcd(i,j,d) <- CommonDivisor(i,j,d) & ~ SOME [e] (CommonDivisor(i,j,e) & e > d). PREDICATE CommonDivisor : Integer * Integer * Integer. CommonDivisor(i,j,d) <- IF (i = 0 \/ j = 0) THEN d = Max(Abs(i),Abs(j)) ELSE 1 =< d =< Min(Abs(i),Abs(j)) & i Mod d = 0 & j Mod d = 0. According to the home page for the language, > Go"del is a declarative, general-purpose programming language in the family of > logic programming languages. It is a strongly typed language, the type system > being based on many-sorted logic with parametric polymorphism. It has a > module system. Go"del supports infinite precision integers, infinite precision > rationals, and also floating-point numbers. It can solve constraints over finite > domains of integers and also linear rational constraints. It supports processing > of finite sets. It also has a flexible computation rule and a pruning operator > which generalises the commit of the concurrent logic programming languages. > Considerable emphasis is placed on Go"del's meta- logical facilities which provide > significant support for meta-programs that do analysis, transformation, > compilation, verification, debugging, and so on. -- Benjamin L. Russell >Hi I have read in one tutorial (I can't find it again, but it was probably >either one on ibm, gentle introduction or yaht), that it is possible to >define relationships between free variables and the same program can be used >to calculate either first variable when second is set or second when first >is set. I have understood this as if I set first free variable, run program >and write name of second variable and I get result, and vice versa. I don't >know if I understood it well. It looks really interesting but I can't figure >out how to do it. Is this really possible? (I doubt.) If yes show example >please. > >Thanks >Fero From ccshan at post.harvard.edu Mon Jul 7 14:56:36 2008 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Mon Jul 7 22:40:12 2008 Subject: [Haskell-cafe] Re: type classes References: <195938a50807021842r609a9d86jcde549228dfc7e67@mail.gmail.com> <195938a50807030515s1909bc14o5ea9423c353a7f45@mail.gmail.com> Message-ID: <4g5ak5-qtp.ln1@mantle.rutgers.edu> > class RingTy a b where > order :: a -> Integer > units :: a -> [b] > class VectorSpaceTy a b | a - > b where > dimension :: a -> Integer > basis :: (Field c) => a -> [b c] > > where `b' is a vector space over the field `c'. It looks like you are using the first (of two) type arguments to the RingTy and VectorSpaceTy type classes as abstract types; in other words, operations on rings and vector spaces don't really care what the type "a" is in "RingTy a b" and "VectorSpaceTy a b". Is that true? Assuming so, if I may strip away the (extremely sweet) syntactic sugar afforded by type classes for a moment, what you seem to be doing is to pass dictionaries of types data RingTy a b = RingTy { order :: a -> Integer, units :: a -> [b] } data VectorSpaceTy a b = VectorSpaceTy { dimension :: a -> Integer, basis :: forall c. (Field c) => a -> [b c] } to operations on rings and vector spaces. Because the type "a" is abstract, you may as well pass dictionaries of types data RingTy b = RingTy { order :: Integer, units :: [b] } data VectorSpaceTy b = VectorSpaceTy { dimension :: Integer, basis :: forall c. (Field c) => [b c] } to these operations. The information that you want computed just once per ring or per vector space can be defined as lexically scoped variables where you create these dictionaries in the first place. To add back the syntactic sugar (i.e., to make the dictionary arguments implicit) and to make the type system check that elements of different vector spaces are not confused, you may find Dylan Thurston's technique useful: http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 2008-07-04 Independence from America! http://caab.org.uk/ 2008-07-05 International Co-operative Day http://ica.coop/ http://www.guardian.co.uk/politics/2008/jul/02/labour.tradeunions From ccshan at post.harvard.edu Mon Jul 7 15:08:22 2008 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Mon Jul 7 22:40:52 2008 Subject: [Haskell-cafe] Re: A Monad for on-demand file generation? References: <1214820294.3204.24.camel@otto.ehbuehl.net> <1214827711.5892.0.camel@derek-laptop> <1214860549.3232.8.camel@otto.ehbuehl.net> Message-ID: <666ak5-qtp.ln1@mantle.rutgers.edu> Joachim Breitner wrote in article <1214860549.3232.8.camel@otto.ehbuehl.net> in gmane.comp.lang.haskell.cafe: > Am Montag, den 30.06.2008, 07:08 -0500 schrieb Derek Elkins: > > You may want to look at Magnus Carlsson's "Monads for Incremental > > Computing" http://citeseer.comp.nus.edu.sg/619122.html > not exactly what I need, but very interesting read. Maybe I can use some > of the ideas. You might also find relevant the work on "adaptive computation" by Umut Acar and collaborators. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 2008-07-04 Independence from America! http://caab.org.uk/ 2008-07-05 International Co-operative Day http://ica.coop/ http://www.guardian.co.uk/politics/2008/jul/02/labour.tradeunions From wren at freegeek.org Mon Jul 7 23:42:36 2008 From: wren at freegeek.org (wren ng thornton) Date: Mon Jul 7 23:33:27 2008 Subject: [Haskell-cafe] Portland & OSCon In-Reply-To: <48726BFA.3060007@complete.org> References: <48726BFA.3060007@complete.org> Message-ID: <4872E22C.9000203@freegeek.org> John Goerzen wrote: > Hi, > > OSCon is happening in Portland, OR starting 2 weeks from today, with > probably the largest number of people there on July 23 and 24. I know > there are a number of Haskellers that live in the Portland area, and I > suspect a few more may be going to OSCon. > > Anyone interested in a Haskell gathering someplace? > > -- John I'm no longer a local, alas, but you may also want to send a mail/post to the pdxfunc group: . I'm not sure how many of them on on here. -- Live well, ~wren From vigalchin at gmail.com Tue Jul 8 01:31:38 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jul 8 01:22:27 2008 Subject: [Haskell-cafe] more database issues Message-ID: <5ae4f2ba0807072231o3e110694s5802fe8ed0f3bf7@mail.gmail.com> vigalchin@ubuntu:~/Desktop/hsql-1.7$ runhaskell Setup.lhs clean cleaning... vigalchin@ubuntu:~/Desktop/hsql-1.7$ runhaskell Setup.lhs configure --user --prefix=$HOME Configuring hsql-1.7... Warning: No license-file field. vigalchin@ubuntu:~/Desktop/hsql-1.7$ runhaskell Setup.lhs build Preprocessing library hsql-1.7... Building hsql-1.7... Database/HSQL.hsc:66:7: Could not find module `System.Time': it is a member of package old-time-1.0.0.0, which is hidden vigalchin@ubuntu:~/Desktop/hsql-1.7$ I have a global ghc installation plus a local one off my user directory. In any case, when I do "ghc-pkg list" .... old-time-1.0.0.0 is not hidden. ???? Bottom line is how do I install DB libraries with least pain?? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080708/c2952eda/attachment-0001.htm From dominic.steinitz at blueyonder.co.uk Tue Jul 8 01:39:13 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Tue Jul 8 01:28:55 2008 Subject: [Haskell-cafe] Swapping Monads Message-ID: <4872FD81.9040409@blueyonder.co.uk> I have a solution so this is for interest only. It is not normally the case that two monads compose to give another monad. Monad transformers capture when this is possible. However, when there is a "swap" function satisfying some commutative diagrams then it can be proved that the monads compose to produce a monad. Is there such a swap function in a library? I had a look in the comprehensive category-extra package but couldn't find anything. Here's two possible implementations. Big caveat: I haven't proved that these satisfy the commutative diagrams but I am confident that they will. Option 1 define swap :: (Functor m, Monad m) => Either String (m a) -> m (Either String a) swap (Left s) = return (Left s) swap (Right x) = fmap Right x Option 2 use Traversable (EvilTerran's suggestion) instance F.Foldable (Either String) where foldMap f (Left s) = mempty foldMap f (Right x) = f x instance T.Traversable (Either String) where traverse f (Left s) = pure (Left s) traverse f (Right x) = Right <$> f x and now you can use T.sequence to swap the monads around. For further information see Composing Monads by Mark Jones and Luc Duponcheel and Toposes, Triples and Theories by Barr & Wells (Section 9.2). Dominic. From david at overtons.id.au Tue Jul 8 02:59:00 2008 From: david at overtons.id.au (David Overton) Date: Tue Jul 8 02:49:50 2008 Subject: [Haskell-cafe] Re: Interesting feature In-Reply-To: References: <18311432.post@talk.nabble.com> Message-ID: On 08/07/2008, Benjamin L. Russell wrote: > If you are interested in logic programming in a language with some > similarity to Haskell, you might also wish to investigate the strongly > typed logic programming language Godel (see > http://www.cs.bris.ac.uk/~bowers/goedel.html). When I first saw an > example of the code, I was surprised that, unlike Prolog, the language > was strongly typed, and supported modules, and (albeit very loosely) > resembled Haskell, except that it was a logic programming language. While we're plugging logic programming languages, you might also be interested in Mercury (http://www.cs.mu.oz.au/research/mercury/). This is a logic/functional language with Prolog-like syntax, but with a Haskell-like type system, including Hindley-Milner types and type classes. IMHO Mercury is even closer to Haskell than Goedel. Also, see my recent attempts at (constraint) logic programming in Haskell: http://overtond.blogspot.com/2008/07/pre.html http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html David From ndmitchell at gmail.com Tue Jul 8 03:50:09 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jul 8 03:40:57 2008 Subject: [Haskell-cafe] Hoogle often updates ? In-Reply-To: <200807080920431099315@gmail.com> References: <200807080920431099315@gmail.com> Message-ID: <404396ef0807080050u5200938cy30db60d2f8556220@mail.gmail.com> Hi, > I have just been asked for usage of timer in haskell. Which I did not > remember clearly. So I ask the search engine. > > In Hoogle: timer > In Google: haskell timer Hoogle does not search the general web, just the libraries supplied with GHC. A quick scan of the first few Google results shows nothing particularly obvious - what were you hoping Hoogle found? > After I tried these, I wonder, when and how often the hoogle update its > database? Now and then. I think it should be up to date with respect to GHC 6.8.2 at the moment. > And, could hoogle search range cover the hackages? Yes, I'm currently working on this as a Summer of Code project. http://neilmitchell.blogspot.com/2008/04/summer-of-code-2008.html Hopefully, by the end of the Summer, Hoogle will search all of hackage. Thanks Neil From pablo at babel.ls.fi.upm.es Tue Jul 8 04:03:21 2008 From: pablo at babel.ls.fi.upm.es (Pablo Nogueira) Date: Tue Jul 8 03:54:10 2008 Subject: [Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly In-Reply-To: <6a7c66fc0807070830g2ed50625s1038b8f33e319609@mail.gmail.com> References: <6a7c66fc0807070830g2ed50625s1038b8f33e319609@mail.gmail.com> Message-ID: > I myselft don't understand why GHCi doesn't accept the type it > infered as an explicit signature ... I think it has to do with the following: Looking at the type errors, they seem to indicate that the type checker is being general and does not assume the |From| and |To| "relations" are between a type |t| and (s (t x) x)| but, in general, between |t| and |s (t' x) x|. Given that from :: (From a1 c1 x) => a1 x -> c1 x to :: (To a2 c2 y) => c2 y -> a2 y bimap :: Bifunctor s => (t1 -> t3) -> (t2 -> t4) -> s t1 t2 -> s t3 t4 During type checking the following equations spring up: c2 y = s t3 t4 c1 x = s t1 t2 t2 = x t4 = y t1 = a1 x t3 = a2 y That'd give the same type as that inferred, but somehow new variables |a11| and |a12| appear. > caused by a lack of functional dependencies. > class From a c x | a -> c where > class To a c y | c -> a where > ... hushes GHCi. The question now is, of course, if the new > dependencies are too restrictive for your problem. They are of little avail given the instances I define: instance Bifunctor s => From (Fix s) (s (Fix s x)) x where from = out instance Bifunctor s => To (Fix s) (s (Fix s y)) y where to = In From pablo at babel.ls.fi.upm.es Tue Jul 8 04:19:01 2008 From: pablo at babel.ls.fi.upm.es (Pablo Nogueira) Date: Tue Jul 8 04:09:50 2008 Subject: [Haskell-cafe] extensible data types in Haskell? In-Reply-To: <2f9b2d30807071513k223be861p881a0ca9b7109bdf@mail.gmail.com> References: <2f9b2d30807071513k223be861p881a0ca9b7109bdf@mail.gmail.com> Message-ID: I prefer Bruno's approach, though. It allows meta-level type-checking of expressions and there's the possibility of closing the extension with a wrapper: (References: "Generics as a Library" and his PhD thesis) - GADT as a type class (or encode the type as it's fold): class Exp e where lit :: TyRange a => a -> e a plus :: e Int -> e Int -> e Int and :: e Bool -> e Bool -> e Bool - Notice we cannot construct an ill-typed expression, the Haskell type-checker complains. - |TyRange| is the class of indices: class TyRange a instance TyRange Int instance TyRange Bool - The behaviour is given by instances: newtype Eval a = Eval {eval :: a} instance Exp Eval where lit = Eval plus x y = Eval (eval x + eval y) and x y = Eval (eval x && eval y) Extension is easy: class Exp e => ExpIf e where ifOp :: TyRange a => e Bool -> e a -> e a -> e a instance ExpIf Eval where ifOp c t e = Eval (if (eval c) then (eval t) else (eval e)) class Exp e => ExpMult e where mult :: e Int -> e Int -> e Int instance ExpMult Eval where mult x y = Eval (eval x * eval y) - Adding new meta-level types is easy: instance TyRange a => TyRange [a] instance TyRange Char class Exp e => ExpConcat e where conc :: e [Char] -> e [Char] -> e [Char] instance ExpConcat Eval where conc x y = Eval (eval x ++ eval y) - Closing expressions is also easy: wrap around a type and provide new functions: data TyRange a => Wrap a = Wrap (forall e. (Exp e, ExpIf e, ExpMult e, ExpConcat e) => e a) > evalExp :: TyRange a => Wrap a -> a > evalExp (Wrap x) = eval x - Some expresions: Compare: exp1 :: Exp e => e Int exp1 = plus (lit 3) (lit 3) val1 = eval exp1 With: exp1' :: Eval Int exp1' = plus (lit 3) (lit 3) va1' = eval exp1 From lemming at henning-thielemann.de Tue Jul 8 05:25:52 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jul 8 05:17:06 2008 Subject: [Haskell-cafe] more database issues In-Reply-To: <5ae4f2ba0807072231o3e110694s5802fe8ed0f3bf7@mail.gmail.com> References: <5ae4f2ba0807072231o3e110694s5802fe8ed0f3bf7@mail.gmail.com> Message-ID: On Tue, 8 Jul 2008, Galchin, Vasili wrote: > vigalchin@ubuntu:~/Desktop/hsql-1.7$ runhaskell Setup.lhs clean > cleaning... > vigalchin@ubuntu:~/Desktop/hsql-1.7$ runhaskell Setup.lhs configure --user > --prefix=$HOME > Configuring hsql-1.7... > Warning: No license-file field. > vigalchin@ubuntu:~/Desktop/hsql-1.7$ runhaskell Setup.lhs build > Preprocessing library hsql-1.7... > Building hsql-1.7... > > Database/HSQL.hsc:66:7: > Could not find module `System.Time': > it is a member of package old-time-1.0.0.0, which is hidden > vigalchin@ubuntu:~/Desktop/hsql-1.7$ > > I have a global ghc installation plus a local one off my user directory. In > any case, when I do "ghc-pkg list" .... old-time-1.0.0.0 is not hidden. > ???? > Bottom line is how do I install DB libraries with least pain?? Is old-time listed in the dependencies of the HSQL package? Problem is probably that many functions moved from 'base' to smaller packages like 'old-time' but package maintainers did not move to new compilers and thus new package structure. It's very inconvenient, but a known issue. From DekuDekuplex at Yahoo.com Tue Jul 8 06:25:27 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Jul 8 06:16:35 2008 Subject: [Haskell-cafe] Re: Interesting feature References: <18311432.post@talk.nabble.com> Message-ID: <32f674170dmldk5mjfrml8ite5ikkv0egk@4ax.com> On Tue, 8 Jul 2008 16:59:00 +1000, "David Overton" wrote: >On 08/07/2008, Benjamin L. Russell wrote: >> If you are interested in logic programming in a language with some >> similarity to Haskell, you might also wish to investigate the strongly >> typed logic programming language Godel (see >> http://www.cs.bris.ac.uk/~bowers/goedel.html). When I first saw an >> example of the code, I was surprised that, unlike Prolog, the language >> was strongly typed, and supported modules, and (albeit very loosely) >> resembled Haskell, except that it was a logic programming language. > >While we're plugging logic programming languages, you might also be interested >in Mercury (http://www.cs.mu.oz.au/research/mercury/). This is a >logic/functional language with Prolog-like syntax, but with a Haskell-like >type system, including Hindley-Milner types and type classes. >IMHO Mercury is even closer to Haskell than Goedel. Yes, Mercury appears interesting, but I was also wondering whether there were any logic programming languages with strong typing and modules that have GUI-based REPL's, similar to WinHugs, available. For example, both SWI-Prolog and GNU Prolog have GUI-based REPL's of that type, but Mercury, at least from what I read in the on-line documentation, does not appear to have one. Go"del has SAGE (Self Applicable Go"del Evaluator) (download goedel-sage.tar.Z (200KB) at ftp://ftp.cs.bris.ac.uk/pub/goedel/latest/goedel-sage.tar.Z), but Go"del is not available for Windows, and according to the home page, there are no plans for this to change in the future. The advantage of a GUI-based REPL is that it facilitates learning the language for beginners and non-*NIX/Linux users, and, in some cases, using the language in a non-*NIX/Linux environment. For example, although I can use Mac OS X at home, my work computer, on which I study programming during lunch and after work, uses Windows XP Professional. It is clumsy switching to Cygwin and Emacs in a Windows environment, because I cannot use UNIX-style tools in the same way outside of Cygwin in Windows as in UNIX. In addition, many directories have spaces in their paths, and many UNIX tools do not support spaces in paths to files. In this environment, a GUI-based REPL would be convenient. Do you know of any logic programming languages with strong typing and modules that have GUI-based REPL's, similar to WinHugs, available? -- Benjamin L. Russell >Also, see my recent attempts at (constraint) logic programming in Haskell: >http://overtond.blogspot.com/2008/07/pre.html >http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html > >David From DekuDekuplex at Yahoo.com Tue Jul 8 07:00:04 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Jul 8 06:51:08 2008 Subject: [Haskell-cafe] Re: Interesting feature References: <18311432.post@talk.nabble.com> Message-ID: On Tue, 8 Jul 2008 16:59:00 +1000, "David Overton" wrote: >Also, see my recent attempts at (constraint) logic programming in Haskell: >http://overtond.blogspot.com/2008/07/pre.html >http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html Whoops! Sorry, I rushed to reply with my earlier message, and forgot to respond to this part of your post. Your blog posts about a Haskell Sudoku solver remind me of similar blog posts about Sudoku solvers in Python (see "Solving Every Sudoku Puzzle": http://norvig.com/sudoku.html) and Scheme (see "Schemely: Sudoku Solver1": http://www.bobmc.net/cgi-bin/Schemely.pl/Sudoku_Solver1, and "Schemely Blog: Scheme Sudoku Solver": http://schemely.blogspot.com/2006/02/scheme-sudoku-solver.html). Some programmers learn new languages by translating code for Sudoku solvers from one language that they already know well to another language that they are trying to learn. Because solving a Sudoku puzzle can be accomplished more easily by using constraint propagation, in which placing a constraint on one square can cause further constraints to be placed on other squares, this definition lends itself to constraint programming. Since constraint programming is a form of declarative programming, this form of programming lends itself to constraint logic programming. As an example, GNU Prolog has a constraint logic programming interpreter; however, GNU Prolog lacks strong typing. If you are interested in constraint programming, you may wish to investigate the multi-paradigm programming language Oz (see http://www.mozart-oz.org/), which can implement constraints in a functional programming language. The language lacks multiprocessor support, but supports declarative programming, object-oriented programming, constraint programming, and concurrency as part of a coherent whole. -- Benjamin L. Russell From dmehrtash at gmail.com Tue Jul 8 07:22:46 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Tue Jul 8 07:13:34 2008 Subject: [Haskell-cafe] data Color3 a = Color3 !a !a !a Message-ID: Can some one explain what the !a does in this: data Color3a = Color3!a !a !a http://cvs.haskell.org/Hugs/pages/libraries/OpenGL/Graphics-Rendering-OpenGL-GL-VertexSpec.html#t%3AColor3 Thanks, Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080708/9aa3ac0d/attachment.htm From voigt at tcs.inf.tu-dresden.de Tue Jul 8 07:32:53 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Tue Jul 8 07:17:08 2008 Subject: [Haskell-cafe] data Color3 a = Color3 !a !a !a In-Reply-To: References: Message-ID: <48735065.5080409@tcs.inf.tu-dresden.de> Daryoush Mehrtash wrote: > Can some one explain what the !a does in this: > > data Color3 > > a = Color3 > > !a !a !a > > http://cvs.haskell.org/Hugs/pages/libraries/OpenGL/Graphics-Rendering-OpenGL-GL-VertexSpec.html#t%3AColor3 In short, http://haskell.org/onlinereport/decls.html#strictness-flags -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From ramsdell0 at gmail.com Tue Jul 8 08:24:45 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Tue Jul 8 08:15:37 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <20080707023856.GB10461@liouville.galois.com> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> Message-ID: <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> The Haskell typechecker contains a nice example of a unifier for freely generated terms. My focus is on equational unification, but thanks anyway. John On Sun, Jul 6, 2008 at 10:38 PM, Don Stewart wrote: > ramsdell0: >> I'd like to write an obviously correct implementation of a unifier, a >> program that when given two terms, finds a substitution that makes the >> two terms equal. The phrase "obviously correct" is meant to imply >> that the clarity of the code trumps efficiency. As near as I can >> tell, high performance unifiers are full of side-effects, and >> achieving the same performance without side-effects in Haskell is >> difficult or impossible. >> >> In contrast, it is easy to write obviously correct Hasklell >> implementations of unifiers for freely generated term algebras. One >> can use Lawrence Paulson's code in ML for the Working Programmer as a >> template or follow Martelli and Montanari's simple set of rules. >> >> My problem is one of my operators is multiplication, which is >> associative and commutative. These two properties make unification >> much more difficult. Mark Stickel described a complete unification >> algorithm for this problem, but the task of translating his >> description into an obviously correct Haskell program appears to be >> difficult. For example, the algorithm requires the generation of the >> basis of solutions to linear homogeneous diophantine equations. I >> haven't located an algorithm for this part yet. >> >> If you have experience implemented equational unification in Haskell, >> please share it. > > "Typing Haskell in Haskell" lives here, > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/thih > > "a Haskell program that implements a Haskell typechecker, thus providing > a mathematically rigorous specification in a notation that is familiar > to Haskell users. We expect this program to fill a serious gap in > current descriptions of Haskell, both as a starting point for > discussions about existing features of the type system, and as a > platform from which to explore new proposals" > > Might be useful as a starting point. > > -- Don > From princedpw at gmail.com Tue Jul 8 08:25:11 2008 From: princedpw at gmail.com (David Walker) Date: Tue Jul 8 08:16:00 2008 Subject: [Haskell-cafe] extensible data types in Haskell? In-Reply-To: <20080707011855.GA10461@liouville.galois.com> References: <20080707011855.GA10461@liouville.galois.com> Message-ID: thanks for everyone's help -- it seems the simplest solution is to use the Typeable class, existential types and type-safe cast. Cheers, Dave On Sun, Jul 6, 2008 at 9:18 PM, Don Stewart wrote: > princedpw: >> Hi all, >> >> SML conveniently contains the type "exn" which is an instance of an >> "extensible data type". In other words, unlike normal data types that >> are "closed" (can't admit new constructors once defined), SML's exn >> type is "open," allowing programmers to keep adding new alternatives >> as often as they choose. Like normal datatypes, the elimination form >> for an extensible data type is a case statement (or match function). >> >> Friends have told me that Haskell doesn't have extensible data types. >> However, it seems fairly straightforward to code them up using type >> classes....though the solution I'm thinking of has a little bit of >> boilerplate I'd like to scrap (you have to define a new type >> declaration *and* an instance of a type class with a "match" method) >> and matching occurs through a string comparison (which can lead to >> silly programmer errors if there is accidentally a typo in the >> string). > > You should probably use Typeable here, for the type matching, rather > than a custom matcher. class Typeable a => Extensible a, this leads to a > fairly straighforward extensible data type, where the open instance > definition lets you add variants on the fly. > >> Anyway, it's possible with some thought I could come up with a better >> solution, but before worrying about it, I figured I'd ask if anybody >> else already has a package that does this. It seems like a pretty >> natural feature to want to have. > > There's a number of ways to do this, including fully statically via type > classes and existential types, or via the Dynamic type. > > Googling for "expression problem Haskell" will turn up some things. Some > implementions of open data types in use can be found in xmonad, and the > extensible exceptions proposal here, > > http://209.85.173.104/search?q=cache:xeXhle5KAqkJ:www.haskell.org/~simonmar/papers/ext-exceptions.pdf > > -- Don > From devriese at cs.tcd.ie Tue Jul 8 08:31:56 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Tue Jul 8 08:22:45 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> Message-ID: <20080708123155.GA634@netsoc.tcd.ie> On Tue, Jul 08, 2008 at 08:24:45AM -0400, John D. Ramsdell wrote: > The Haskell typechecker contains a nice example of a unifier for > freely generated terms. My focus is on equational unification, but > thanks anyway. Are you aware of "Term Rewriting and all That"? It describes how to do associative commutative unification; whether it satisfies your 'obviously correct' criterion I don't know. Edsko From dbueno at gmail.com Tue Jul 8 08:40:01 2008 From: dbueno at gmail.com (Denis Bueno) Date: Tue Jul 8 08:30:50 2008 Subject: [Haskell-cafe] more database issues In-Reply-To: <5ae4f2ba0807072231o3e110694s5802fe8ed0f3bf7@mail.gmail.com> References: <5ae4f2ba0807072231o3e110694s5802fe8ed0f3bf7@mail.gmail.com> Message-ID: <6dbd4d000807080540n15a92bd0hf6899e9ec95f7ce3@mail.gmail.com> 2008/7/8 Galchin, Vasili : > Database/HSQL.hsc:66:7: > Could not find module `System.Time': > it is a member of package old-time-1.0.0.0, which is hidden > vigalchin@ubuntu:~/Desktop/hsql-1.7$ > > I have a global ghc installation plus a local one off my user directory. In > any case, when I do "ghc-pkg list" .... old-time-1.0.0.0 is not hidden. > ???? I believe "hidden" here means that the .cabal file isn't specifically told it's okay to use "old-time", thus it's "hidden" to cabal, not to GHC. If you add "old-time" to the Build-depends field of the package, you should be able to get rid of this message. -- Denis From derek.a.elkins at gmail.com Tue Jul 8 09:59:01 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Jul 8 09:49:54 2008 Subject: [Haskell-cafe] Swapping Monads In-Reply-To: <4872FD81.9040409@blueyonder.co.uk> References: <4872FD81.9040409@blueyonder.co.uk> Message-ID: <1215525541.5818.9.camel@derek-laptop> On Tue, 2008-07-08 at 06:39 +0100, Dominic Steinitz wrote: > I have a solution so this is for interest only. > > It is not normally the case that two monads compose to give another > monad. Monad transformers capture when this is possible. However, when > there is a "swap" function satisfying some commutative diagrams then it > can be proved that the monads compose to produce a monad. > > Is there such a swap function in a library? I had a look in the > comprehensive category-extra package but couldn't find anything. You didn't look hard enough. What you want is called a distributive law in category theory. A class for exactly what you want is in Control.Functor.Extras. http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Functor-Extras.html#t%3ADistributes From ryani.spam at gmail.com Tue Jul 8 13:20:31 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 8 13:11:20 2008 Subject: [Haskell-cafe] data Color3 a = Color3 !a !a !a In-Reply-To: References: Message-ID: <2f9b2d30807081020t12ec4530gb1ba5e8cdb35262e@mail.gmail.com> A simple example to help understand the difference > data NoStrict a = NoStrict a deriving Show > data Strict a = Strict !a deriving Show > ns1 = NoStrict () > ns2 = NoStrict undefined > ns3 = undefined > nf1 (NoStrict ()) = "ok" > nf2 (NoStrict _) = "ok" > s1 = Strict () > s2 = Strict undefined > s3 = undefined > f1 (Strict ()) = "ok" > f2 (Strict _) = "ok" The difference between these: *Strict> nf2 ns2 "ok" *Strict> f2 s2 "*** Exception: Prelude.undefined s2 and s3 are both the same (undefined), while ns2 and ns3 are different. As to why you'd want that behavior? Here are a couple of reasons: 1) You can avoid hiding exceptions in strict data structures; if the top level evaluates, you know the entire structure is valid. 2) With -funbox-strict-fields, the compiler can remove a level of indirection; the performance difference between a structure that contains three machine words and a structure that contains three pointers to boxed integers is pretty significant. On the other hand, you lose the benefits of laziness; I find most "structure-like" data structures work better strict, but that "list-like" data structures definitely gain an advantage from laziness. -- ryan 2008/7/8 Daryoush Mehrtash : > Can some one explain what the !a does in this: > > data Color3 a = Color3 !a !a !a > > http://cvs.haskell.org/Hugs/pages/libraries/OpenGL/Graphics-Rendering-OpenGL-GL-VertexSpec.html#t%3AColor3 > > Thanks, > > Daryoush > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From trebla at vex.net Tue Jul 8 15:05:42 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Tue Jul 8 14:56:30 2008 Subject: [Haskell-cafe] data Color3 a = Color3 !a !a !a In-Reply-To: References: Message-ID: <4873BA86.9040402@vex.net> Daryoush Mehrtash wrote: > Can some one explain what the !a does in this: > > data Color3 a = Color3 !a !a !a Shameless plug: http://www.vex.net/~trebla/haskell/strict-field.xhtml From vigalchin at gmail.com Tue Jul 8 15:14:25 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jul 8 15:05:12 2008 Subject: [Haskell-cafe] more database issues In-Reply-To: <6dbd4d000807080540n15a92bd0hf6899e9ec95f7ce3@mail.gmail.com> References: <5ae4f2ba0807072231o3e110694s5802fe8ed0f3bf7@mail.gmail.com> <6dbd4d000807080540n15a92bd0hf6899e9ec95f7ce3@mail.gmail.com> Message-ID: <5ae4f2ba0807081214x2fad261eq7ad3feebe1ac97bd@mail.gmail.com> Thanks to everybody who responded! Vasili On Tue, Jul 8, 2008 at 7:40 AM, Denis Bueno wrote: > 2008/7/8 Galchin, Vasili : > > Database/HSQL.hsc:66:7: > > Could not find module `System.Time': > > it is a member of package old-time-1.0.0.0, which is hidden > > vigalchin@ubuntu:~/Desktop/hsql-1.7$ > > > > I have a global ghc installation plus a local one off my user directory. > In > > any case, when I do "ghc-pkg list" .... old-time-1.0.0.0 is not hidden. > > ???? > > I believe "hidden" here means that the .cabal file isn't specifically > told it's okay to use "old-time", thus it's "hidden" to cabal, not to > GHC. > > If you add "old-time" to the Build-depends field of the package, you > should be able to get rid of this message. > > -- > Denis > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080708/4d3c53b1/attachment.htm From ben.franksen at online.de Tue Jul 8 15:55:03 2008 From: ben.franksen at online.de (Ben Franksen) Date: Tue Jul 8 15:46:00 2008 Subject: [Haskell-cafe] Re: What is a rigid type variable? References: <87r6aokf0d.fsf@columbia.edu> <2f9b2d30806222337r7f462c9el89a3e8c58986ec8d@mail.gmail.com> Message-ID: Ryan Ingram wrote: > To answer the question in the subject: > >>From "Simple unification-based type inference for GADTs", > Peyton-Jones, et al. ICFP 2006. > http://research.microsoft.com/users/simonpj/papers/gadt/ > > "Instead of "user-specified type", we use the briefer term rigid > type to describe a type that is completely specified, in some > direct fashion, by a programmer-supplied type annotation." > > So a rigid type is any type specified by a programmer type signature. > All other types are "wobbly". Wow. Such a short and clear explanation. I have been wondering for some time what exactly this 'rigid' means... Please somebody who understands stuff like that better than me put it on some wiki page. It's obviously a FAQ. BTW, do we have a FAQ page? I think we should have one. Cheers Ben (a little behind on cafe, catching up...) From lemming at henning-thielemann.de Tue Jul 8 16:17:55 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jul 8 16:08:43 2008 Subject: [Haskell-cafe] Re: What is a rigid type variable? In-Reply-To: References: <87r6aokf0d.fsf@columbia.edu> <2f9b2d30806222337r7f462c9el89a3e8c58986ec8d@mail.gmail.com> Message-ID: On Tue, 8 Jul 2008, Ben Franksen wrote: > Wow. Such a short and clear explanation. I have been wondering for some time > what exactly this 'rigid' means... Please somebody who understands stuff > like that better than me put it on some wiki page. It's obviously a FAQ. > > BTW, do we have a FAQ page? I think we should have one. http://www.haskell.org/haskellwiki/Category:FAQ From david at overtons.id.au Tue Jul 8 19:22:20 2008 From: david at overtons.id.au (David Overton) Date: Tue Jul 8 19:13:07 2008 Subject: [Haskell-cafe] Re: Interesting feature In-Reply-To: <32f674170dmldk5mjfrml8ite5ikkv0egk@4ax.com> References: <18311432.post@talk.nabble.com> <32f674170dmldk5mjfrml8ite5ikkv0egk@4ax.com> Message-ID: On 08/07/2008, Benjamin L. Russell wrote: > Do you know of any logic programming languages with strong typing and > modules that have GUI-based REPL's, similar to WinHugs, available? You might want to look at Visual Prolog (http://www.visual-prolog.com/). It is strongly typed and has a Windows IDE. I'm not sure if it has a REPL though. David From ndmitchell at gmail.com Tue Jul 8 20:01:46 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jul 8 19:52:33 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) Message-ID: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> Hi, It seems that the qualified import syntax is a bit awkward. At the moment, its common to see: import qualified Data.Map as M import Data.Map(Map) i.e. import a module, give it an alias (M), and put some things in the current namespace (Map). Another way some people sometimes do it is: import qualified Data.Map as M import Data.Map hiding (lookup) i.e. import a module, give it an alias (M), and exclude some things from the current namespace. Both of these require two imports, yet feel like they should require only one. It seems as though the import syntax more naturally promotes security (preventing access to some functions), rather than namespacing. I think a better design for namespacing might be: import Data.Map as M implicit (Map) import Data.Map as M explicit (lookup) If this was the design, I'm not sure either qualified or hiding would be necessary for namespacing. You'd get module names aligning up in the same column after the import rather than being broken up with qualified. You'd only need one import of a module for most purposes. The hiding keyword might still be nice for lambdabot style applications, but that is probably a secondary concern, and better handled in other ways. Thoughts? Is this design flawed in some way? Does the existing design have some compelling benefit I've overlooked? Thanks Neil From marco-oweber at gmx.de Tue Jul 8 20:43:38 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Tue Jul 8 20:34:26 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell Message-ID: <20080709004338.GA16229@gmx.de> Is Haskell still used (in industry as well ?) to write (V)HDL code to program FPGAs and create circuits on chips? The Chalmers Lava homepage tells abouta Xilinx version which should be merged in soon. But on the xilinx homepage there was no reference to neither Lava nor haskell.. I'm thinking about designing a similar tool to www.combimouse.com. Sincerly Marc From skynare at gmail.com Tue Jul 8 21:19:03 2008 From: skynare at gmail.com (skynare@gmail.com) Date: Tue Jul 8 21:09:49 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> Message-ID: <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> How about using + and - prefixes instead of implicit and explicit clause? \begin{code} module T where import Data.Map (Map, (\\)) import qualified Data.Map as M hiding (lookup) f :: (Ord k) => Map k v -> k -> Map k v f m k = m \\ M.singleton k (m M.! k) \end{code} the following import command would mean the same: import qualified Data.Map as M (+Map, -lookup, +singleton, +(\\)) On 7/8/08, Neil Mitchell wrote: > Hi, > > It seems that the qualified import syntax is a bit awkward. At the > moment, its common to see: > > import qualified Data.Map as M > import Data.Map(Map) > > i.e. import a module, give it an alias (M), and put some things in the > current namespace (Map). > > Another way some people sometimes do it is: > > import qualified Data.Map as M > import Data.Map hiding (lookup) > > i.e. import a module, give it an alias (M), and exclude some things > from the current namespace. > > Both of these require two imports, yet feel like they should require > only one. It seems as though the import syntax more naturally promotes > security (preventing access to some functions), rather than > namespacing. > > I think a better design for namespacing might be: > > import Data.Map as M implicit (Map) > import Data.Map as M explicit (lookup) > > If this was the design, I'm not sure either qualified or hiding would > be necessary for namespacing. You'd get module names aligning up in > the same column after the import rather than being broken up with > qualified. You'd only need one import of a module for most purposes. > The hiding keyword might still be nice for lambdabot style > applications, but that is probably a secondary concern, and better > handled in other ways. > > Thoughts? Is this design flawed in some way? Does the existing design > have some compelling benefit I've overlooked? > > Thanks > > Neil > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From philip.weaver at gmail.com Tue Jul 8 22:05:42 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Tue Jul 8 21:56:31 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: <20080709004338.GA16229@gmx.de> References: <20080709004338.GA16229@gmx.de> Message-ID: On Tue, Jul 8, 2008 at 5:43 PM, Marc Weber wrote: > Is Haskell still used (in industry as well ?) to write (V)HDL code to > program FPGAs and create circuits on chips? Indeed! Galois maintains a language called Cryptol. Almost all tools for this language, including an FPGA compiler that produces HDL, are written in Haskell. It is not open source, nor is it free as in beer, but there is a free academic version without FPGA support. The Chalmers Lava homepage tells abouta Xilinx version which should be > merged in soon. But on the xilinx homepage there was no reference to > neither Lava nor haskell.. As for Lava and the Xilinx version, I am not really sure how actively it is being developed. Perhaps someone else here knows? > I'm thinking about designing a similar tool to www.combimouse.com. You're going to design something like that with an FPGA in it? :) For a simple enough design, it can be useful to write specs in Haskell and then translate them to HDL by hand. I believe someone on this list had a particularly successful experience doing that :). - Philip > Sincerly > Marc > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080708/93d2bd74/attachment.htm From alfonso.acosta at gmail.com Tue Jul 8 22:26:44 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Tue Jul 8 22:17:35 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: <20080709004338.GA16229@gmx.de> References: <20080709004338.GA16229@gmx.de> Message-ID: <6a7c66fc0807081926u4efaa13bha5080686e40a63e2@mail.gmail.com> We'll soon (before september, hopefully) relase a deep-embedded version of ForSyDe[1] which, among other things, has a VHDL backend (with specific support for Altera's Modelsim and Quartus). ForSyDe's new implementation is internally based upon the same concept as Lava (Observable Sharing). However, it has quite a few differences: * ForSyDe is behavioural (computations are expressed in plain haskell) * It has support for components * Is not barely targeted at synchrounous hardware systems (although the VHDL backend is obviously aimed at them). It has suport for other MoCs (Models of Computation). [1] http://www.imit.kth.se/info/FOFU/ForSyDe/ On Tue, Jul 8, 2008 at 7:43 PM, Marc Weber wrote: > Is Haskell still used (in industry as well ?) to write (V)HDL code to > program FPGAs and create circuits on chips? > The Chalmers Lava homepage tells abouta Xilinx version which should be > merged in soon. But on the xilinx homepage there was no reference to > neither Lava nor haskell.. > I'm thinking about designing a similar tool to www.combimouse.com. > > Sincerly > Marc > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From vigalchin at gmail.com Wed Jul 9 00:55:35 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jul 9 00:46:22 2008 Subject: [Haskell-cafe] use of the GHC universal quantifier Message-ID: <5ae4f2ba0807082155t6718d9f3jfb09174c905ec2af@mail.gmail.com> Hello, It seems to me by its name that "forall" denotes a logical universal quantifier. In any case, hsql-1.7/Database/HSQL/Types.hs uses "forall" at line #134. I got a nasty build so I added {-# LANGUAGE ExistentialQuantification #-} at the top of the module. Now I get the following a coupleof lines up: Database/HSQL/Types.hs:131:5: Illegal polymorphic or qualified type: forall a. Int -> FieldDef -> FieldDef -> CString -> Int -> IO a -> IO a In the definition of data constructor `Statement' In the data type declaration for `Statement' If seems that GHC doesn't like "a". Why? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080708/6b0705ef/attachment-0001.htm From wren at freegeek.org Wed Jul 9 01:03:52 2008 From: wren at freegeek.org (wren ng thornton) Date: Wed Jul 9 00:54:42 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> Message-ID: <487446B8.6010202@freegeek.org> Quoth skynare@gmail.com: > Quoth Neil Mitchell : > > [...] > > > > Both of these require two imports, yet feel like they should require > > only one. It seems as though the import syntax more naturally promotes > > security (preventing access to some functions), rather than > > namespacing. > > > > I think a better design for namespacing might be: > > > > import Data.Map as M implicit (Map) > > import Data.Map as M explicit (lookup) > > > > If this was the design, I'm not sure either qualified or hiding would > > be necessary for namespacing. You'd get module names aligning up in > > the same column after the import rather than being broken up with > > qualified. You'd only need one import of a module for most purposes. > > The hiding keyword might still be nice for lambdabot style > > applications, but that is probably a secondary concern, and better > > handled in other ways. > > > > Thoughts? Is this design flawed in some way? Does the existing design > > have some compelling benefit I've overlooked? > > How about using + and - prefixes instead of implicit and explicit clause? > > \begin{code} > module T where > > import Data.Map (Map, (\\)) > import qualified Data.Map as M hiding (lookup) > > f :: (Ord k) => Map k v -> k -> Map k v > f m k = m \\ M.singleton k (m M.! k) > \end{code} > > the following import command would mean the same: > import qualified Data.Map as M (+Map, -lookup, +singleton, +(\\)) What I would like to see is the ability to do (1) module renaming, (2) qualified import, (3) unqualified import, and (4) hiding all in a single declaration with a regular syntax. For example: import Data.Map as Map unqualified (Map, (\\)) qualified (lookup, map, null) hiding (filter) To simplify this full generality for the common cases: * At most one of the lists can be dropped, keeping the keyword, to mean "everything else". * Naturally if both the qualified and unqualified clauses have lists, then everything else is assumed to be hidden and so the 'hiding' keyword can be dropped too. * Similarly, if any clause has an empty list, both the keyword and the () can be dropped. * A special case can be made when all three clauses are dropped so that, if there's no 'as'-clause then everything is imported unqualified, otherwise everything is imported qualified. * Another special case to better mimic the current syntax is that if neither 'qualified'- nor 'hiding'-clauses are present, then the 'unqualified' keyword can be dropped (retaining the list of imports). As Neil mentioned, the most common idioms are to combine unqualified/hiding or unqualified/qualified, but allowing all three makes the syntax more consistent. And there are times when we would want all three, such as when being very specific about expressing dependencies: unqualified types and operators (for sanity), qualified functions (for explicitness), hidden "dangerous"/known-unused functions (for safety). With the abbreviations above, this syntax is almost a proper superset of the current syntax. The main incompatible difference is moving the 'qualified' keyword to make the syntax more consistent. -- Live well, ~wren From lemming at henning-thielemann.de Wed Jul 9 01:06:05 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jul 9 00:57:43 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> Message-ID: On Wed, 9 Jul 2008, Neil Mitchell wrote: > It seems that the qualified import syntax is a bit awkward. At the > moment, its common to see: > > import qualified Data.Map as M > import Data.Map(Map) > > i.e. import a module, give it an alias (M), and put some things in the > current namespace (Map). > > Another way some people sometimes do it is: > > import qualified Data.Map as M > import Data.Map hiding (lookup) > > i.e. import a module, give it an alias (M), and exclude some things > from the current namespace. > > Both of these require two imports, yet feel like they should require > only one. It seems as though the import syntax more naturally promotes > security (preventing access to some functions), rather than > namespacing. > > I think a better design for namespacing might be: > > import Data.Map as M implicit (Map) > import Data.Map as M explicit (lookup) Why 'implicit' and 'explicit'? Do you mean something like 'include' and 'exclude'? From lemming at henning-thielemann.de Wed Jul 9 01:09:26 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jul 9 01:00:12 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> Message-ID: On Tue, 8 Jul 2008, skynare@gmail.com wrote: > How about using + and - prefixes instead of implicit and explicit clause? Hiding of identifiers is the wrong way round. It fails if new identifiers are added to a module interface: http://www.haskell.org/haskellwiki/Import_modules_properly For one-line imports, see: http://www.haskell.org/haskellwiki/Qualified_names From tom.davie at gmail.com Wed Jul 9 03:04:23 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Jul 9 02:55:12 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> Message-ID: >> >> I think a better design for namespacing might be: >> >> import Data.Map as M implicit (Map) >> import Data.Map as M explicit (lookup) > > Why 'implicit' and 'explicit'? Do you mean something like 'include' > and 'exclude'? To me at least, implicit and explicit make more sense. I don't want to exclude importing lookup, I want to make it so I have to explicitly tag lookup as being M.lookup. Similarly, I don't want to include Map (as opposed to all the other things I'm getting from Data.Map), I just want to make it so that when I say Map, I implicitly mean M.Map. Personally I'd extend this syntax (something Neil may have had in mind), so that import Data.Map as M (lookup, union) implicit (Map) gives me M.lookup, M.union and Map while import Data.Map as M hiding (union) explicit (lookup) gives me everything in Data.Map with no qualification except for union and lookup, plus it gives me M.lookup. Bob From ryani.spam at gmail.com Wed Jul 9 05:03:08 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jul 9 04:53:53 2008 Subject: [Haskell-cafe] use of the GHC universal quantifier In-Reply-To: <5ae4f2ba0807082155t6718d9f3jfb09174c905ec2af@mail.gmail.com> References: <5ae4f2ba0807082155t6718d9f3jfb09174c905ec2af@mail.gmail.com> Message-ID: <2f9b2d30807090203u771260ffja8abe70814e426fc@mail.gmail.com> Try {-# LANGUAGE RankNTypes #-}? "forall" does denote a universal quantifier, but because the 'implies' of the function arrow, in logic, includes negation, you can use it to emulate existential quantifiers. > data Existential = forall a. Ex a The type of the constructor Ex: Ex :: forall a. a -> Existential Pattern matching on Ex brings "a" back into scope (with no information about it, so this type isn't that useful on its own): > use (Ex x) = 0 -- can't recover any useful information about x > sample = Ex "sample" However, you can use existential types to encode additional information about the included data; for example: > -- Ex2 :: forall a. Show a => a -> Exist2 > data Exist2 = forall a. Show a => Ex2 a Now, pattern matching on Ex2 brings the Show instance into scope as well: > sample2 = Ex2 "sample2" > use2 (Ex2 x) = show x You can also use higher rank polymorphism to encode existential types: > -- Ex3 :: (forall a. (forall b. Show b => b -> a) -> a) -> Exist3 > -- note the rank-3 type on Ex3! > newtype Exist3 = Ex3 (forall a. (forall b. Show b => b -> a) -> a) > sample3 = Ex3 (\k -> k "sample3") > use3 (Ex3 f) = f (\x -> show x) -- ryan 2008/7/8 Galchin, Vasili : > Hello, > > It seems to me by its name that "forall" denotes a logical universal > quantifier. In any case, hsql-1.7/Database/HSQL/Types.hs uses "forall" at > line #134. I got a nasty build so I added {-# LANGUAGE > ExistentialQuantification #-} at the top of the module. Now I get the > following a coupleof lines up: > > Database/HSQL/Types.hs:131:5: > Illegal polymorphic or qualified type: forall a. > Int > -> FieldDef > -> FieldDef > -> CString > -> Int > -> IO a > -> IO a > In the definition of data constructor `Statement' > In the data type declaration for `Statement' > > If seems that GHC doesn't like "a". Why? > > Kind regards, Vasili > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From marco-oweber at gmx.de Wed Jul 9 05:22:54 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Wed Jul 9 05:13:42 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: References: <20080709004338.GA16229@gmx.de> Message-ID: <20080709092254.GA18779@gmx.de> > You're going to design something like that with an FPGA in it? :) The FPGA is only used for developement. If everything works fine I'd like to put it on the market. My hope is to get one low cost chip doing everything this way. Would you suggest using other tools? I'm still a total noob in this area > For a simple enough design, it can be useful to write specs in Haskell and > then translate them to HDL by hand. I believe someone on this list had a > particularly successful experience doing that :). Thanks for this note. Marc Weber From gale at sefer.org Wed Jul 9 05:23:59 2008 From: gale at sefer.org (Yitzchak Gale) Date: Wed Jul 9 05:14:45 2008 Subject: [Haskell-cafe] Re: Interesting feature In-Reply-To: References: <18311432.post@talk.nabble.com> Message-ID: <2608b8a80807090223u79936248w1746a00d558e8d2@mail.gmail.com> David Overton wrote: > Also, see my recent attempts at (constraint) logic programming in Haskell: > http://overtond.blogspot.com/2008/07/pre.html > http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html See the Sudoku page on the wiki: http://www.haskell.org/haskellwiki/Sudoku Please add your solver there. Regards, Yitz From ndmitchell at gmail.com Wed Jul 9 05:49:51 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jul 9 05:40:36 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <487446B8.6010202@freegeek.org> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> Message-ID: <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> Hi > declaration with a regular syntax. For example: > > import Data.Map as Map > unqualified (Map, (\\)) > qualified (lookup, map, null) > hiding (filter) I think I prefer this to my proposal, plus its closer to the current syntax. I think its also nearly equal to what Tom Davie came up with, given some keyword renaming. If we dropped the unqualified keyword, and just required unqualified things to come directly after, we get the full benefits of not introducing any keywords. > * A special case can be made when all three clauses are dropped so that, if > there's no 'as'-clause then everything is imported unqualified, otherwise > everything is imported qualified. That's not the current semantics. Currently 'as' means everything is imported unqualified and also qualified. > Why 'implicit' and 'explicit'? Do you mean something like 'include' and 'exclude'? I want to refer to these things explicitly (with a module name), I want to refer to these things implicitly (without a module name). I have no particular attachment to the keywords - think of it as a discussion starter rather than a suggestion. Thanks Neil From a.d.clark at ed.ac.uk Wed Jul 9 06:05:20 2008 From: a.d.clark at ed.ac.uk (allan) Date: Wed Jul 9 05:54:16 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> Message-ID: <48748D60.7030005@ed.ac.uk> Neil Mitchell wrote: > Hi > >> declaration with a regular syntax. For example: >> >> import Data.Map as Map >> unqualified (Map, (\\)) >> qualified (lookup, map, null) >> hiding (filter) > > I think I prefer this to my proposal, plus its closer to the current > syntax. I think its also nearly equal to what Tom Davie came up with, > given some keyword renaming. If we dropped the unqualified keyword, > and just required unqualified things to come directly after, we get > the full benefits of not introducing any keywords. > Just to say that I also like this design. A minor point would be; do we really need the parentheses and commas? or could we not just use indentation (I think this about module imports in general). Also I wouldn't mind 'as' for the names which are imported which would be a bit of a work around for the debate as to whether I should design my modules for qualified import or not. Suppose I make a 'NewList' module and use the default names then someone could do: import Data.NewList unqualified map as nlMap find as nlFind lookup as nlLookup or vice-versa. regards allan -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From ndmitchell at gmail.com Wed Jul 9 06:14:07 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jul 9 06:04:52 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <48748D60.7030005@ed.ac.uk> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> <48748D60.7030005@ed.ac.uk> Message-ID: <404396ef0807090314x7e175c75v3efff7737b483c8f@mail.gmail.com> Hi > Just to say that I also like this design. A minor point would be; do we > really need the parentheses and commas? or could we not just use > indentation (I think this about module imports in general). Yes, then you could just uses {a;b} to get the list which is actually a newline list. I think this would be even better for module declarations. For example, in the module I'm currently working on: module Hoogle.DataBase.TypeSearch.Graph( Graph, newGraph, GraphResult(..), ArgPos, Binding, graphSearch ) where I dislike the fact that ,'s come after every line but the last - it lacks consistency, and often requires 1 more line of diff when adding somethign (add comma to previous line, and add the line). I would rather write: module Hoogle.DataBase.TypeSearch.Graph{ Graph; newGraph GraphResult(..); ArgPos; Binding graphSearch } where However, I think the new syntax for modules, and the new type of declarations for modules, are separate issues. > Also I wouldn't mind 'as' for the names which are imported which would > be a bit of a work around for the debate as to whether I should design > my modules for qualified import or not. Suppose I make a 'NewList' > module and use the default names then someone could do: > import Data.NewList > unqualified map as nlMap > find as nlFind > lookup as nlLookup I believe old versions of Haskell had this, and it was considered too confusing. Consider: import Prelude unqualified (+) as (-) Also people reading the code will find it easier to know N = Data.NewList (one mapping), than three mappings as you have. Thanks Neil From a.d.clark at ed.ac.uk Wed Jul 9 06:33:08 2008 From: a.d.clark at ed.ac.uk (allan) Date: Wed Jul 9 06:23:56 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807090314x7e175c75v3efff7737b483c8f@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> <48748D60.7030005@ed.ac.uk> <404396ef0807090314x7e175c75v3efff7737b483c8f@mail.gmail.com> Message-ID: <487493E4.70403@ed.ac.uk> Neil Mitchell wrote: > Hi > >> Just to say that I also like this design. A minor point would be; do we >> really need the parentheses and commas? or could we not just use >> indentation (I think this about module imports in general). > [snip general agreement] > > However, I think the new syntax for modules, and the new type of > declarations for modules, are separate issues. Sure! > >> Also I wouldn't mind 'as' for the names which are imported which would >> be a bit of a work around for the debate as to whether I should design >> my modules for qualified import or not. Suppose I make a 'NewList' >> module and use the default names then someone could do: >> import Data.NewList >> unqualified map as nlMap >> find as nlFind >> lookup as nlLookup > > I believe old versions of Haskell had this, and it was considered too > confusing. Consider: > > import Prelude unqualified (+) as (-) > > Also people reading the code will find it easier to know N = > Data.NewList (one mapping), than three mappings as you have. > Yes I generally agree there, I don't think 'as' for imported names is particularly important and if it's been tried before and found to be confusing well then that pretty much settles it for me. If I were particularly for it then I'd point out that: import Prelude unqualified (+) as (-) would only be written by someone with limited common sense or someone trying to break things (but I'm sure you could come up with a more realistic example). More importantly for me is the consistency you mentioned, for me it seems inconsistent that you can remap a module name but not an imported identifier. That said, your point about knowing one or three mappings is somewhat compelling and I'm now somewhat less in favour of 'as' for imported names. regards allan -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From lemming at henning-thielemann.de Wed Jul 9 06:36:40 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jul 9 06:27:31 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807090314x7e175c75v3efff7737b483c8f@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> <48748D60.7030005@ed.ac.uk> <404396ef0807090314x7e175c75v3efff7737b483c8f@mail.gmail.com> Message-ID: On Wed, 9 Jul 2008, Neil Mitchell wrote: > For example, in the module I'm currently working on: > > module Hoogle.DataBase.TypeSearch.Graph( > Graph, newGraph, > GraphResult(..), ArgPos, Binding, > graphSearch > ) where > > I dislike the fact that ,'s come after every line but the last - it > lacks consistency, and often requires 1 more line of diff when adding > somethign (add comma to previous line, and add the line). I would > rather write: Also in the current syntax it is allowed to add a comma in the last line. From isaacdupree at charter.net Wed Jul 9 07:23:08 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Wed Jul 9 07:13:53 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> Message-ID: <48749F9C.4010807@charter.net> Neil Mitchell wrote: > Hi > >> declaration with a regular syntax. For example: >> >> import Data.Map as Map >> unqualified (Map, (\\)) >> qualified (lookup, map, null) >> hiding (filter) > > I think I prefer this to my proposal, plus its closer to the current > syntax. I think its also nearly equal to what Tom Davie came up with, > given some keyword renaming. If we dropped the unqualified keyword, > and just required unqualified things to come directly after, we get > the full benefits of not introducing any keywords. We're still not introducing any keywords either way, fortunately :-). 'qualified', 'as' and 'hiding' are not keywords: the syntax after 'import' has no place for lowercase identifiers, so we can use as many new words as we want, here, as long as module names stay capitalized and import lists remain parenthesized (or, import lists could equally well be in layout after 'where', 'of', 'let' or 'do' if we adopt the layout syntax) -Isaac From scook0 at gmail.com Wed Jul 9 08:43:09 2008 From: scook0 at gmail.com (Stuart Cook) Date: Wed Jul 9 08:33:58 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> Message-ID: <49b351060807090543w290d7b94u15d55b7eb50515a1@mail.gmail.com> On Wed, Jul 9, 2008 at 10:01 AM, Neil Mitchell wrote: > It seems that the qualified import syntax is a bit awkward. At the > moment, its common to see: > > import qualified Data.Map as M > import Data.Map(Map) > > i.e. import a module, give it an alias (M), and put some things in the > current namespace (Map). Incidentally, I sometimes find myself writing this: import Data.Map (Map) ; import qualified Data.Map as M It's not perfect, but at least it lines up with my other imports a little better. Stuart From roma at ro-che.info Wed Jul 9 08:45:24 2008 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed Jul 9 08:36:12 2008 Subject: [Haskell-cafe] QuickCheck: outdated manual Message-ID: <20080709124524.GA4415@flit> Online QC manual[1] says[2] that 'vector' takes number of elements and generator, while in QuickCheck-1.1.0.0 it takes only number and generates vector of arbitrary's. Please fix that. By the way, I find the old version as useful as the new one. Although both are trivially implemented, I don't see any reason of why one is included and the other is not. Does anyone? 1. http://www.cs.chalmers.se/~rjmh/QuickCheck/manual.html 2. http://www.cs.chalmers.se/~rjmh/QuickCheck/manual_body.html#17 -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... From david at overtons.id.au Wed Jul 9 09:02:07 2008 From: david at overtons.id.au (David Overton) Date: Wed Jul 9 08:52:55 2008 Subject: [Haskell-cafe] Re: Interesting feature In-Reply-To: <2608b8a80807090223u79936248w1746a00d558e8d2@mail.gmail.com> References: <18311432.post@talk.nabble.com> <2608b8a80807090223u79936248w1746a00d558e8d2@mail.gmail.com> Message-ID: 2008/7/9 Yitzchak Gale : > David Overton wrote: >> Also, see my recent attempts at (constraint) logic programming in Haskell: >> http://overtond.blogspot.com/2008/07/pre.html >> http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html > > See the Sudoku page on the wiki: > > http://www.haskell.org/haskellwiki/Sudoku > > Please add your solver there. I've done that. Thanks. David From newhoggy at gmail.com Wed Jul 9 09:31:21 2008 From: newhoggy at gmail.com (John Ky) Date: Wed Jul 9 09:22:08 2008 Subject: [Haskell-cafe] How to do a special kind of comment with the TokenParser Message-ID: Hi, TokenParser supports two kinds of comments, the multi-line comments (ie. {- -}) and the single line comments (ie. -- \n). The language I am trying to parse, however, has comments which are neither. The -- acts like a single line comment which extends to the end of the line usually, but can also be truncated to before the end of the line by another --. For example: noncomment -- comment comment noncomment -- comment comment -- noncomment noncomment -- comment -- noncomment noncomment I haven't been able to get the TokenParser to work with this style of comment. The best I could do was copy the whole Token module and modify the code: data LanguageDef st = LanguageDef { {- snip -} *, commentLine :: String* {- snip -} } {- snip -} makeTokenParser languageDef = TokenParser{ {- snip -} } where {- snip -} whiteSpace | noLine && noMulti = skipMany (simpleSpace *<|> customComment* "") | noLine = skipMany (simpleSpace *<|> customComment* <|> multiLineComment "") | noMulti = skipMany (simpleSpace *<|> customComment* <|> oneLineComment "") | otherwise = skipMany (simpleSpace *<|> customComment* <|> oneLineComment <|> multiLineComment "") where noLine = null (commentLine languageDef) noMulti = null (commentStart languageDef) *customComment = do{commentCustom languageDef ;return() }* Then I put my specialised comment parser in the customComment field: languageDef = TOKEN.LanguageDef { {- snip -} , TOKEN.commentCustom = customComment {- snip -} } where customComment = do string "--" untilLineCommentEnd return () untilLineCommentEnd = do c <- manyTill anyChar (string "\n" <|> try (string "--")) return () Anyone know of a way I could reuse the TokenParser code rather than copy and tweaking it? Thanks -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080709/b1ccdc17/attachment.htm From philip.weaver at gmail.com Wed Jul 9 09:58:29 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Wed Jul 9 09:49:14 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: <20080709092254.GA18779@gmx.de> References: <20080709004338.GA16229@gmx.de> <20080709092254.GA18779@gmx.de> Message-ID: On Wed, Jul 9, 2008 at 2:22 AM, Marc Weber wrote: > > You're going to design something like that with an FPGA in it? :) > The FPGA is only used for developement. If everything works fine I'd > like to put it on the market. My hope is to get one low cost chip doing > everything this way. Would you suggest using other tools? > Ah, yes, it is common to develop on an FPGA before fabricating to, say, on ASIC . > I'm still a total noob in this area So you plan on developing a chip or board without any previous hardware experience? Sounds.... challenging :). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080709/6edb5ec8/attachment.htm From Christian.Maeder at dfki.de Wed Jul 9 10:32:58 2008 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Jul 9 10:23:44 2008 Subject: [Haskell-cafe] Re: How to do a special kind of comment with the TokenParser In-Reply-To: References: Message-ID: <4874CC1A.3010102@dfki.de> TokenParser seems to pose more problems than it solves. I think it is usually easier to define your own scanner and avoid the necessary Haskell language extensions used there. (Surely parts of the code from TokenParser can be copied.) Cheers Christian John Ky wrote: > Hi, > > TokenParser supports two kinds of comments, the multi-line comments (ie. > {- -}) and the single line comments (ie. -- \n). > > The language I am trying to parse, however, has comments which are > neither. The -- acts like a single line comment which extends to the > end of the line usually, but can also be truncated to before the end of > the line by another --. For example: > > noncomment -- comment comment > noncomment -- comment comment -- noncomment noncomment -- comment -- > noncomment > noncomment > > I haven't been able to get the TokenParser to work with this style of > comment. The best I could do was copy the whole Token module and modify > the code: > > data LanguageDef st > = LanguageDef > { {- snip -} > *, commentLine :: String* > {- snip -} > } > > {- snip -} > > makeTokenParser languageDef > = TokenParser{ {- snip -} } > where > {- snip -} > whiteSpace > | noLine && noMulti = skipMany (simpleSpace *<|> customComment* > "") > | noLine = skipMany (simpleSpace *<|> customComment* > <|> multiLineComment "") > | noMulti = skipMany (simpleSpace *<|> customComment* > <|> oneLineComment "") > | otherwise = skipMany (simpleSpace *<|> customComment* > <|> oneLineComment <|> multiLineComment "") > where > noLine = null (commentLine languageDef) > noMulti = null (commentStart languageDef) > *customComment = > do{commentCustom languageDef > ;return() > }* > > Then I put my specialised comment parser in the customComment field: > > languageDef = TOKEN.LanguageDef > { {- snip -} > , TOKEN.commentCustom = customComment > {- snip -} > } > where > customComment = do > string "--" > untilLineCommentEnd > return () > > untilLineCommentEnd = do > c <- manyTill anyChar (string "\n" <|> try (string "--")) > return () > > Anyone know of a way I could reuse the TokenParser code rather than copy > and tweaking it? > > Thanks > > -John > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From frantisek.kocun at gmail.com Wed Jul 9 13:06:44 2008 From: frantisek.kocun at gmail.com (fero) Date: Wed Jul 9 12:57:27 2008 Subject: [Haskell-cafe] CAL (OpenQuark) and enterprise Message-ID: <18366397.post@talk.nabble.com> Hi Haskellers and CALers, I have the feeling that a lot of code in my jee application can be done better by using functional programming. There is a lot of searching in object trees, transforming objects to another objects, aggregation functions... All written in java. Sequential logic can by done declarative with statemachines and workflows (not handcoded, dut drawed) all other with functions. Has somebody experience with this? Or is that a bad idea? Should I use pure functions, or imperative-functional language such as Scala? Is somebody here using CAL (OpenQuark) in jee application? What is your experience -- View this message in context: http://www.nabble.com/CAL-%28OpenQuark%29-and-enterprise-tp18366397p18366397.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jonathanccast at fastmail.fm Wed Jul 9 13:07:40 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Jul 9 12:59:32 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <404396ef0807090249x4fb91c82x73e453ce0cbda8db@mail.gmail.com> <48748D60.7030005@ed.ac.uk> <404396ef0807090314x7e175c75v3efff7737b483c8f@mail.gmail.com> Message-ID: <1215623260.6255.183.camel@jcchost> On Wed, 2008-07-09 at 12:36 +0200, Henning Thielemann wrote: > On Wed, 9 Jul 2008, Neil Mitchell wrote: > > > For example, in the module I'm currently working on: > > > > module Hoogle.DataBase.TypeSearch.Graph( > > Graph, newGraph, > > GraphResult(..), ArgPos, Binding, > > graphSearch > > ) where > > > > I dislike the fact that ,'s come after every line but the last - it > > lacks consistency, and often requires 1 more line of diff when adding > > somethign (add comma to previous line, and add the line). I would > > rather write: > > Also in the current syntax it is allowed to add a comma in the last line. GHC rejects this. (Or is that just for import lists?) jcc From ndmitchell at gmail.com Wed Jul 9 13:28:46 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jul 9 13:19:30 2008 Subject: [Haskell-cafe] CAL (OpenQuark) and enterprise In-Reply-To: <18366397.post@talk.nabble.com> References: <18366397.post@talk.nabble.com> Message-ID: <404396ef0807091028r1101a388wee196276f795aadd@mail.gmail.com> Hi > There is a lot of searching in > object trees, transforming objects to another objects, aggregation > functions... Sounds like you want: Either Uniplate: http://www-users.cs.york.ac.uk/~ndm/uniplate/ Or SYB: http://www.cs.vu.nl/boilerplate/ Read through both papers for various examples of what you might want to do, > Should > I use pure functions, or imperative-functional language such as Scala? On the Haskell list I think its fair to say everyone recommends you should use Haskell. Thanks Neil From dons at galois.com Wed Jul 9 13:41:44 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 9 13:32:32 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: <20080709004338.GA16229@gmx.de> References: <20080709004338.GA16229@gmx.de> Message-ID: <20080709174144.GB16241@liouville.galois.com> marco-oweber: > Is Haskell still used (in industry as well ?) to write (V)HDL code to > program FPGAs and create circuits on chips? > The Chalmers Lava homepage tells abouta Xilinx version which should be > merged in soon. But on the xilinx homepage there was no reference to > neither Lava nor haskell.. > I'm thinking about designing a similar tool to www.combimouse.com. See also BlueSpec and Atom et al, http://funhdl.org/wiki/doku.php http://funhdl.org/wiki/doku.php?id=funhdl&DokuWiki=fa52189d5ac4c0098c15ee324e0056ec From dave at zednenem.com Wed Jul 9 13:42:52 2008 From: dave at zednenem.com (David Menendez) Date: Wed Jul 9 13:33:36 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <487446B8.6010202@freegeek.org> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> Message-ID: <49a77b7a0807091042x7f7d0ffjd047eff5e97f759e@mail.gmail.com> On Wed, Jul 9, 2008 at 1:03 AM, wren ng thornton wrote: > What I would like to see is the ability to do (1) module renaming, (2) > qualified import, (3) unqualified import, and (4) hiding all in a single > declaration with a regular syntax. For example: > > import Data.Map as Map > unqualified (Map, (\\)) > qualified (lookup, map, null) > hiding (filter) I've often thought it would be for Haskell to steal Agda's module syntax. It does pretty much everything you want (plus some other stuff we maybe don't need) and the various things it does fit together logically. -- Dave Menendez From byorgey at seas.upenn.edu Wed Jul 9 14:41:54 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jul 9 14:32:43 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 76 - July 9, 2008 Message-ID: <20080709184154.GA2745@minus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080709 Issue 76 - July 09, 2008 --------------------------------------------------------------------------- Welcome to issue 76 of HWN, a newsletter covering developments in the [1]Haskell community. The [2]ICFP Programming Contest is this weekend! Go forth and kick some butt, Haskell-style. A big thank you in advance to all those at PSU and U Chicago who are working hard to write and run the contest. Community News Luke Palmer (luqui) is [3]having a great time in Antwerp. John Goerzen's son is [4]so cute, it should be illegal. Announcements Haskell-cafe on lively.com. Edward Kmett has created a [5]Haskell Cafe room on Google's new virtual-world platform [6]Lively (which is unfortunately windows-only at the moment). Uniplate 1.2. Neil Mitchell [7]announced the release of [8]Uniplate 1.2, a library for reducing boilerplate code by performing generic traversals. Version 1.2 features some bug fixes, a compatibility layer with Compos and SYB, and a 25-50% performance increase over Uniplate 1.0. GHC 6.8.2 stable in Gentoo. Luis Araujo [9]announced that GHC 6.8.2, and its accompanying libraries, have now been marked as stable in the official Gentoo portage tree. The Monad.Reader (11) - Call for Copy. Wouter Swierstra [10]announced a call for copy for Issue 11 of [11]the Monad.Reader. The submission deadline is August 1, although you should let Wouter know as soon as possible if you plan to submit something. hCsound. John Lato [12]announced the initial public release of [13]hCsound, a Haskell binding to the Csound audio processing language API. Portland and OSCon. John Goerzen [14]inquired whether any Haskellers in Portland would be interested in getting together during OSCon July 23 or 24. Faster graph SCCs. Iavor Diatchki [15]announced that he has implemented Tarjan's algorithm for computing the strongly connected components of a graph, which is considerably faster than the containers package for larger graphs. Iavor's implementation is available in the [16]GraphSCC package. parallel map/reduce. jinjing [17]exhibited some code for doing parallel map/reduce computations. Disciplined Disciple Compiler. Ben Lippmeier [18]announced version 1.1 of the [19]Disciplined Disciple Compiler (DDC), an explicitly lazy dialect of Haskell, with support for first class destructive update of arbitrary data, computational effects without the need for state monads, and type directed field projections. Version 1.1 includes a number of new features and more example code. darcs 2.0.2. David Roundy [20]announced the release of [21]darcs 2.0.1 and 2.0.2. These releases fix quite a few bugs, and users of darcs 2 are strongly recommended to upgrade. Google Summer of Code Progress updates from participants in the 2008 [22]Google Summer of Code. GHC plugins. Max Bolingbroke is working on dynamically loaded plugins for GHC. Over the [23]past two weeks, he has implemented type safe dynamic loading, an annotations system, and some sample plugins. Hoogle 4. Neil Mitchell (ndm) is working on [24]Hoogle 4. [25]This week, he has been working on type searching, using a much more efficient algorithm than type search in previous versions of Hoogle. Next week, he plans to finish off type search and work on the build system. DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a [26]physics engine using [27]Data Parallel Haskell. He spent most of [28]this week fixing bugs and improving existing simulation code. And he now has something to [29]show for it! Language.C. Benedikt Huber (visq) is [30]working on Language.C, a standalone parser/pretty printer library for C99. [31]This week, he created a semantic representation for declarations and types, and a way to convert between an AST representation and a semantic representation. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a [32]make-like dependency analysis framework for Cabal. Generic tries. Jamie Brandon is working on a library for efficient maps using generalized tries. GHC API. Thomas Schilling (nominolo) is working on [33]improvements to the GHC API. Libraries Proposals and extensions to the [34]standard libraries. Extensible exceptions. Ian Lynagh sent out a [35]proposal to replace the current exception mechanism in the base library with extensible exceptions, a la Simon Marlow's [36]extensible extensions paper. Deadline for discussion is 25th July. Discussion Qualified import syntax badly designed (?). Neil Mitchell began a [37]discussion about Haskell syntax for qualified module imports (and module imports in general). Trouble with zip12. Michael Feathers is [38]having trouble with the zip12 function and some weird SQL-related errors... Santana on my evil ways. John D. Ramsdell [39]set off a spate of Haskell song and poetry. Alternatives to convoluted record syntax. Dougal Stanton [40]asked about alternatives to convoluted record update syntax, eliciting a number of interesting responses. Jobs Lectureship in Functional Programming, Nottingham. Graham Hutton [41]announced an opening for a Lecturer in the Functional Programming Lab in Nottingham, a recently formed research group that comprises Thorsten Altenkirch, Graham Hutton, Henrik Nilsson, four research fellows, and eleven PhD students. Applications from the Haskell community are encouraged! The closing date for applications is Friday 15th August 2008. Blog noise [42]Haskell news from the [43]blogosphere. * Edward Kmett: [44]A Lively Haskell Cafe. A Haskell Cafe room on lively.com! * Sterling Clover: [45]Comonads in everyday life. A neat post on using a zipper comonad to render a website menu hierarchy without lots of duplicated effort. * Chung-chieh Shan: [46]Differentiating regions. * Real-World Haskell: [47]Real World Haskell, The Book, Available for Pre-Order. * Benedikt Huber: [48]An analysis-friendly representation. An update on Benedikt's Google Summer of Code project, Language.C. * Chris Okasaki: [49]Breadth-First Numbering: An Algorithm in Pictures. Algorithms without words! * >>> Jeremy Frens: [50]PE Problem #2 in All Languages (Part I). Jeremy explores solutions to Project Euler problem #2 in a variety of languages. * Roman Cheplyaka: [51]Double buffering & demo. A demo of Roman's Google Summer of Code physics simulator! * Roman Cheplyaka: [52]QuickCheck puzzle: the answer. Why Roman's QuickCheck test involving nonzero vectors didn't terminate. Sneaky. * Roman Cheplyaka: [53]Status report: week 6. A status report on Roman's Google Summer of Code project. * >>> JP Moresmau: [54]Handling errors in JSON to Haskell deserialization. JP adds error handling with an Either monad to his JSON deserialization code. * Braden Shepherdson: [55]Fixed Point Datatypes. Braden explains the concept of recursive data types as fixed points of functors. * Luis Araujo: [56]GHC 6.8.2 stable! (Himerge 0.21.9 too!). * Matthew Sackman: [57]Anglo Haskell 2008. * Neil Mitchell: [58]GSoC Hoogle: Week 6. * >>> James Hague: [59]Functional Programming Went Mainstream Years Ago. * Max Bolingbroke: [60]Compiler Plugins For GHC: Weeks Three and Four. An update on Max's Google Summer of Code project. * >>> David Overton: [61]A Haskell Sudoku Solver using Finite Domain Constraints. David shows how to use his Haskell constraint solver to solve Sudoku puzzles. Pretty neat! * >>> Lorenz Pretterhofer: [62]Haskell Does Concurrency. * Edward Kmett: [63]Anamorphism. The newest installment in Edward's [64]field guide to recursion schemes. * John Goerzen (Real World Haskell): [65]Last Call for Comments on Most Chapters. Real World Haskell is going to press soon! Get your final comments in ASAP! * Edward Kmett: [66]MSFP 2008. * Lennart Augustsson: [67]Lost and Found. A very slick Haskell library for tracing how expressions are actually evaluated, including the ability to explicitly see the sharing involved! * Tom Nielsen (FP Lunch): [68]braincurry. A domain specific language to define and execute experiments and simulations related to cellular neuroscience. * Alex McLean: [69]Visualisation of a triangular mesh. * Paul R Brown: [70]Beust Sequence Ruminations. Thoughts on solving an interesting puzzle in Haskell. * >>> David Overton: [71]Constraint Programming in Haskell. David is working on a constraint logic programming system in Haskell. * >>> chaource: [72]Why functional programming is almost dead (and has always been). Interesting argument? Flawed premises? Both? None of the above? You decide! Quotes of the Week * jfredett: I'd code but I'm so drugged up I could only write effective code in perl. * SamB: [SamB] @let forkbomb n = forkbomb (2*n) `par` forkbomb (2*n+1) [lambdabot] Defined. [SamB] > forkbomb 1 -!- lambdabot [n=lambdabo@72.249.126.23] has quit [Remote closed the connection] * vinicius: haskell is macgyver with bananas, barbed wired and envelopes * dons: huh, amazon recommends Neal Stephenson + RWH * Pseudonym: trapped in the IO monad: The lesser known R. Kelly opera * byorgey: Extreme Anger Programming: you are paired with a really dumb partner and after twenty minutes of agony you rip the keyboard from their hands, delete everything they typed, and do it yourself About the Haskell Weekly News New editions are posted to [73]the Haskell mailing list as well as to [74]the Haskell Sequence and [75]Planet Haskell. [76]RSS is also available, and headlines appear on [77]haskell.org. Headlines are available as [78]PDF. To help create new editions of this newsletter, please see the information on [79]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [80]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://www.icfpcontest.org/ 3. http://luqui.org/blog/archives/2008/07/05/fun-with-flemish/ 4. http://changelog.complete.org/posts/728-guid.html 5. http://www.lively.com/dr?rid=-4485567674160322075 6. http://www.lively.com/ 7. http://article.gmane.org/gmane.comp.lang.haskell.general/16292 8. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uniplate 9. http://araujoluis.blogspot.com/2008/07/ghc-682-stable-himerge-0219-too.html 10. http://article.gmane.org/gmane.comp.lang.haskell.general/16290 11. http://www.haskell.org/haskellwiki/The_Monad.Reader 12. http://article.gmane.org/gmane.comp.lang.haskell.general/16288 13. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hCsound 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42047 15. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9470 16. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GraphSCC 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41944 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41941 19. http://www.haskell.org/haskellwiki/DDC 20. http://lists.osuosl.org/pipermail/darcs-users/2008-June/012480.html 21. http://darcs.net/ 22. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 23. http://blog.omega-prime.co.uk/2008/07/05/compiler-plugins-for-ghc-weeks-three-and-four/ 24. http://code.haskell.org/hoogle/ 25. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-6.html 26. http://haskell.org/haskellwiki/Hpysics 27. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 28. http://physics-dph.blogspot.com/2008/07/status-report-week-6.html 29. http://physics-dph.blogspot.com/2008/07/double-buffering-demo.html 30. http://www.sivity.net/projects/language.c/wiki/ 31. http://hsbene.blogspot.com/2008/07/analysis-friendly-representation.html 32. http://code.haskell.org/~Saizan/cabal 33. http://hackage.haskell.org/trac/ghc/wiki/GhcApiStatus 34. http://haskell.org/haskellwiki/Library_submissions 35. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9481 36. http://www.haskell.org/~simonmar/papers/ext-exceptions.pdf 37. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42080 38. http://www.haskell.org//pipermail/haskell-cafe/2008-July/044956.html 39. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41975 40. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41936 41. http://article.gmane.org/gmane.comp.lang.haskell.general/16285 42. http://planet.haskell.org/ 43. http://haskell.org/haskellwiki/Blog_articles 44. http://comonad.com/reader/2008/haskell-cafe/ 45. http://fmapfixreturn.wordpress.com/2008/07/09/comonads-in-everyday-life/ 46. http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Differentiation/ 47. http://www.realworldhaskell.org/blog/2008/07/08/real-world-haskell-the-book-available-for-pre-order/ 48. http://hsbene.blogspot.com/2008/07/analysis-friendly-representation.html 49. http://okasaki.blogspot.com/2008/07/breadth-first-numbering-algorithm-in.html 50. http://jdfrens.blogspot.com/2008/07/pe-problem-2-in-all-languages-part-i.html 51. http://physics-dph.blogspot.com/2008/07/double-buffering-demo.html 52. http://physics-dph.blogspot.com/2008/07/quickcheck-puzzle-answer.html 53. http://physics-dph.blogspot.com/2008/07/status-report-week-6.html 54. http://jpmoresmau.blogspot.com/2008/07/handling-errors-in-json-to-haskell.html 55. http://braincrater.wordpress.com/2008/07/07/fixed-point-datatypes/ 56. http://araujoluis.blogspot.com/2008/07/ghc-682-stable-himerge-0219-too.html 57. http://www.wellquite.org/anglo_haskell_2008.html 58. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-6.html 59. http://prog21.dadgum.com/31.html 60. http://blog.omega-prime.co.uk/2008/07/05/compiler-plugins-for-ghc-weeks-three-and-four/ 61. http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html 62. http://krysole.net/2008/07/04/haskell-does-concurrency/ 63. http://comonad.com/reader/2008/anamorphism/ 64. http://comonad.com/reader/2008/recursion-schemes/ 65. http://www.realworldhaskell.org/blog/2008/07/03/last-call-for-comments-on-most-chapters/ 66. http://comonad.com/reader/2008/msfp/ 67. http://augustss.blogspot.com/2008/07/lost-and-found-if-i-write-108-in.html 68. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=105 69. http://doc.gold.ac.uk/~ma503am/alex/visualisation-of-a-mesh/ 70. http://mult.ifario.us/p/beust-sequence-ruminations 71. http://overtond.blogspot.com/2008/07/pre.html 72. http://chaource.livejournal.com/34530.html 73. http://www.haskell.org/mailman/listinfo/haskell 74. http://sequence.complete.org/ 75. http://planet.haskell.org/ 76. http://sequence.complete.org/node/feed 77. http://haskell.org/ 78. http://code.haskell.org/~byorgey/code/hwn/archives/20080709.pdf 79. http://haskell.org/haskellwiki/HWN 80. http://code.haskell.org/~byorgey/code/hwn/ From jason.dusek at gmail.com Wed Jul 9 14:51:53 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Jul 9 14:42:48 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <49a77b7a0807091042x7f7d0ffjd047eff5e97f759e@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <49a77b7a0807091042x7f7d0ffjd047eff5e97f759e@mail.gmail.com> Message-ID: <42784f260807091151o27700e20s902a720d65b9ae53@mail.gmail.com> David Menendez wrote: > I've often thought it would be for Haskell to steal Agda's > module syntax. It does pretty much everything you want (plus > some other stuff we maybe don't need) and the various things > it does fit together logically. What does that look like? I've been looking for some kind of documentation for ~20 minutes and I still can't find an example of an import. -- _jsn From miles at milessabin.com Wed Jul 9 18:20:55 2008 From: miles at milessabin.com (Miles Sabin) Date: Wed Jul 9 18:11:38 2008 Subject: [Haskell-cafe] CAL (OpenQuark) and enterprise In-Reply-To: <404396ef0807091028r1101a388wee196276f795aadd@mail.gmail.com> References: <18366397.post@talk.nabble.com> <404396ef0807091028r1101a388wee196276f795aadd@mail.gmail.com> Message-ID: <30961e500807091520nddba83l470255344fefcc61@mail.gmail.com> On Wed, Jul 9, 2008 at 6:28 PM, Neil Mitchell wrote: > On the Haskell list I think its fair to say everyone recommends you > should use Haskell. Not necessarily. If the OP has a significant body of existing Java code (s)he has to work with (which is what the question suggests) then Scala would most likely be a very good place to look. Cheers, Miles From dave at zednenem.com Wed Jul 9 18:22:40 2008 From: dave at zednenem.com (David Menendez) Date: Wed Jul 9 18:13:25 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <42784f260807091151o27700e20s902a720d65b9ae53@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <49a77b7a0807091042x7f7d0ffjd047eff5e97f759e@mail.gmail.com> <42784f260807091151o27700e20s902a720d65b9ae53@mail.gmail.com> Message-ID: <49a77b7a0807091522m4fc47341v3fe129b7b90ad4f1@mail.gmail.com> On Wed, Jul 9, 2008 at 2:51 PM, Jason Dusek wrote: > David Menendez wrote: >> I've often thought it would be for Haskell to steal Agda's >> module syntax. It does pretty much everything you want (plus >> some other stuff we maybe don't need) and the various things >> it does fit together logically. > > What does that look like? I've been looking for some kind of > documentation for ~20 minutes and I still can't find an > example of an import. There's a description on their wiki at . There's a longer description in chapter 4 of Ulf Norell's thesis, , which may be slightly out of date. Essentially, the import statement in Agda brings a module from another file into scope as if it were a sub-module in the current file. It also lets you rename the module, in case it conflicts with another name. It does not bring any values or types into scope; they are accessed by qualified names. import Some.Module import Some.Other.Module as SOM A separate statement lets you bring names from any module into the current scope. You can provide a list of names to include or exclude, and a list of names to rename. open SOM using (x,y) open SOM renaming (x as alsoX, y as alsoY) open SOM hiding (x,y) You can combine renaming with using or hiding, but you can't use using or hiding together. Note that hidden names are still accessible as qualified names. That is, if you open SOM hiding x, you can still say "SOM.x". There's also a short-hand form that lets you import a module and open it on the same line. Aside from the syntax differences, Agda's module system features nested modules and parameterized modules, both of which could be pretty handy in Haskell. Nested modules allow libraries which have many modules with similar names to use qualified names. open import Gtk using (module Button, module Window) f = ... Button.name ... Window.name ... Parameterized modules work sort of like implicit arguments. I suspect that having them in Haskell could eliminate most of the call for things like top-level IORefs. -- Dave Menendez From lgreg.meredith at biosimilarity.com Wed Jul 9 19:17:29 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Wed Jul 9 19:08:13 2008 Subject: [Haskell-cafe] Swapping Monads Message-ID: <5de3f5ca0807091617l304d6ddegbf42784b9472c96c@mail.gmail.com> Dominic, You can also reference Eugenia Cheng's paper on arXiv . Best wishes, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080709/e2727794/attachment.htm From jason.dusek at gmail.com Wed Jul 9 19:25:28 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Jul 9 19:16:11 2008 Subject: [Haskell-cafe] Qualified import syntax badly designed (?) In-Reply-To: <49a77b7a0807091522m4fc47341v3fe129b7b90ad4f1@mail.gmail.com> References: <404396ef0807081701t29949996v4ff297fda8caee8f@mail.gmail.com> <4e7aa0f80807081819x2a3d9e91uc08d46d7156b1c5b@mail.gmail.com> <487446B8.6010202@freegeek.org> <49a77b7a0807091042x7f7d0ffjd047eff5e97f759e@mail.gmail.com> <42784f260807091151o27700e20s902a720d65b9ae53@mail.gmail.com> <49a77b7a0807091522m4fc47341v3fe129b7b90ad4f1@mail.gmail.com> Message-ID: <42784f260807091625y38813132jeb9c84834f5aafbb@mail.gmail.com> David Menendez wrote: > Jason Dusek wrote: > > David Menendez wrote: > > > I've often thought it would be for Haskell to steal Agda's > > > module syntax. > > > > What does that look like? I've been looking for some kind of > > documentation for ~20 minutes and I still can't find an > > example of an import. > > There's a description on their wiki at > . Thanks. That system is pretty neat -- I wish we had it. Without parameterized modules, we are reduced to a kind of warty singleton pattern -- or IORefs, as you mention. -- _jsn From ronwalf at volus.net Wed Jul 9 22:40:57 2008 From: ronwalf at volus.net (Ron Alford) Date: Wed Jul 9 22:31:41 2008 Subject: [Haskell-cafe] Combining Wouter's expressions with extensible records Message-ID: Well, my extension of Wouter's datatypes proved to be unweildy.... So, I'm trying to use http://fmapfixreturn.wordpress.com/2008/05/03/simple-extensible-records-now-quick-generic-tricks-pt-1/ for extensible records. I ran across my first problem rather quickly! data Expr f = In (f (Expr f)) Ok, but to make it part of a record, it needs to implement Data: data Expr f = In (f (Expr f)) deriving Data but this gives No instances for (Data (f (Expr f)), Typeable (Expr f)) arising from the 'deriving' clause of a data type declaration at Planning/Wouter.hs:77:0-42 Any hints? Thanks, -Ron From aslatter at gmail.com Wed Jul 9 23:01:49 2008 From: aslatter at gmail.com (Antoine Latter) Date: Wed Jul 9 22:52:33 2008 Subject: [Haskell-cafe] Combining Wouter's expressions with extensible records In-Reply-To: References: Message-ID: <694519c50807092001m59c4543fhba7a6200ae3e5072@mail.gmail.com> On Wed, Jul 9, 2008 at 9:40 PM, Ron Alford wrote: > Ok, but to make it part of a record, it needs to implement Data: > data Expr f = In (f (Expr f)) deriving Data > > but this gives > No instances for (Data (f (Expr f)), Typeable (Expr f)) > arising from the 'deriving' clause of a data type declaration > at Planning/Wouter.hs:77:0-42 The Data class has a requirement that any instances are also instances of Typeable, so you'd really want > data ... = ... deriving (Data, Typeable) Except that I couldn't derive Typeable for your particular data type. It isn't immediately obvious to me that the "Typeable" family of classes deal at all with higher-kinded type constructors, but I didn't look that hard. -Antoine From oddron at gmail.com Wed Jul 9 23:05:47 2008 From: oddron at gmail.com (Ronald Guida) Date: Wed Jul 9 22:56:30 2008 Subject: [Haskell-cafe] Lazy IO Message-ID: <62728db30807092005v470b170bvaf9b9b8f3e485fe9@mail.gmail.com> Suppose I have a lazy function f :: [Int] -> [Int], and I happen to know that for all n, the n-th element of the output may only depend on the first (n-1) elements of the input. I want to print a number from f's output list, and then ask the user for the next number in f's input list, and then loop until the user stops providing valid numbers. I also need to be able to do IO after my loop exits. Consider the following code: ---------------------------------------------- module Main where import Control.Monad.Fix import System.IO.Unsafe promptInt :: String -> IO (Maybe Int) promptInt p = do putStr p s <- getLine let rs = reads s if not $ null rs then return $ Just $ fst $ head rs else return $ Nothing promptInts :: [String] -> IO [Int] promptInts [] = return [] promptInts (p:ps) = do m <- promptInt p case m of Just n -> do ns <- unsafeInterleaveIO $ promptInts ps return $ n:ns Nothing -> return [] -- assume accumulator is an opaque function accumulator :: [Int] -> [Int] accumulator = scanl (+) 0 makeAccPrompt :: Int -> String makeAccPrompt n = "[Acc = " ++ show n ++ "] ? " main :: IO () main = do xs <- mfix $ promptInts . map makeAccPrompt . accumulator seq (length xs) $ print xs ---------------------------------------------- Question: If I can't change my function f (in this case, accumulator), then is it possible to get the effect I want without having to resort to "unsafeInterleaveIO"? From mmitar at gmail.com Wed Jul 9 23:08:06 2008 From: mmitar at gmail.com (Mitar) Date: Wed Jul 9 22:58:54 2008 Subject: [Haskell-cafe] Profiling nested case Message-ID: Hi! I am making a simple raycasting engine and have a function which take a point in space and return a color of an object (if there is any) at this point in space. And because the whole thing is really slow (or was really slow) on simple examples I decided to profile it. It takes around 60 seconds for a 640x480 px image with 400 depth of field. This is at worst 122,880,000 calculations (if the scene is rather empty) of a coordinate of a point in space and then checking for a color. And 60 seconds look really a lot to me for that. So I went profiling and found out that the strange part of code is the main color checking function which has a list of objects (at this time the list is hardcoded). It looks like this: world :: SpacePoint -> VoxelColor world point = case msum . sequence elements $ point of Just v -> v Nothing -> noColor where elements = [redSphere (0,50,0) 50, greenSphere (25,-50,0) 50, blueSphere (-150,0,150) 50] So three spheres in a world and I check if the point is in any of them. Like that: sphere :: SpacePoint -> BasicReal -> VoxelColor -> WorldElement -- center of sphere, it's radius, it's color sphere (x0,y0,z0) r color (x,y,z) | x' * x' + y' * y' + z' * z' <= r * r = Just color | otherwise = Nothing where x' = x - x0 y' = y - y0 z' = z - z0 redSphere :: SpacePoint -> BasicReal -> WorldElement redSphere c r = sphere c r redColor So profiling told me that world function takes 38.4 % of all running time. So I decided to play with it. Maybe a more direct approach would be better: world :: SpacePoint -> VoxelColor world point = findColor [redSphere (0,50,0) 50, greenSphere (25,-50,0) 50, blueSphere (-150,0,150) 50] where findColor [] = noColor findColor (f:fs) = case f point of Just v -> v Nothing -> findColor fs Great, it improved. To 40 s. But still it was too much. I tried this: world :: SpacePoint -> VoxelColor world point = case redSphere (0,50,0) 50 point of Just v -> v Nothing -> case greenSphere (25,-50,0) 50 point of Just v -> v Nothing -> case blueSphere (-150,0,150) 50 point of Just v -> v Nothing -> noColor And it took 15 s. And also the profiling was like I would anticipate. Calculating points coordinates and checking spheres takes almost all time. So any suggestions how could I build a list of objects to check at runtime and still have this third performance? Why this big difference? (I am using GHC 6.8.3 with -O2 compile switch.) (The <* operator is casting a ray, that is multiplying a ray direction vector with a scalar factor.) Mitar -------------- next part -------------- A non-text attachment was scrubbed... Name: Main-case.prof Type: application/octet-stream Size: 6535 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/7a21c7c1/Main-case.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: Main-rec.prof Type: application/octet-stream Size: 6536 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/7a21c7c1/Main-rec.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: Main-seq.prof Type: application/octet-stream Size: 6414 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/7a21c7c1/Main-seq.obj From ryani.spam at gmail.com Wed Jul 9 23:48:45 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jul 9 23:39:28 2008 Subject: [Haskell-cafe] Lazy IO In-Reply-To: <62728db30807092005v470b170bvaf9b9b8f3e485fe9@mail.gmail.com> References: <62728db30807092005v470b170bvaf9b9b8f3e485fe9@mail.gmail.com> Message-ID: <2f9b2d30807092048r702bd324n4cf9afabb40390e5@mail.gmail.com> On 7/9/08, Ronald Guida wrote: > Question: If I can't change my function f (in this case, accumulator), > then is it possible to get the effect I want without having to resort > to "unsafeInterleaveIO"? Yes, but you won't like it. Since you know that (f xs !! n) only depends on the first (n-1) elements of xs, you have this identity: f xs !! n == f (take (n-1) xs) !! n You can then call f with a new list each time, extracting the desired elements as you build up the source list. This is, of course, terribly inefficient. In order to see why you need an unsafe primitive to solve this function, you may find it enlightening to try to write this function: > data Stream a b = NilStream | Stream b (a -> Stream a b) > liftStream :: ([a] -> [b]) -> Stream a b > liftStream = ? (the inverse of this function is trivial to write) The problem is that there is no way to extract the continuation from f (x:??); if you had some way, you'd be able to call the same continuation multiple times with different arguments, effectively "pausing" f partway through and giving it new input. By using unsafeInterleaveIO, you are adding a side-effect to the "pure" argument to f, which allows it to interact with the user. Once that side-effect executes, the value is 'fixed' into place and can't be modified. Another way to look at it is to suppose that f didn't meet your invariant, and tried to access an element out of order. How is the thunk to be evaluated for that element built? If it can't do IO, it must be a pure computation. But it needs to do IO because the element hasn't been determined yet. -- ryan From lists at qseep.net Thu Jul 10 03:39:21 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Thu Jul 10 03:30:31 2008 Subject: [Haskell-cafe] Poor Parsec error message Message-ID: <4875BCA9.4060507@qseep.net> Hi folks, I'm using Parsec to parse a stream of tokens. The token primitive takes, among other arguments, a function to print tokens. However, this function is not always applied. Try the code below: --------- import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Pos(newPos) mytoken :: (Eq t, Show t) => t -> GenParser (SourcePos,t) () t mytoken x = token showTok posFromTok testTok where showTok (pos,t) = "<" ++ show t ++ ">" posFromTok (pos,t) = pos testTok (pos,t) = if (x == t) then Just t else Nothing main = do putStrLn "" case parse the123Parser "" [(newPos "" 1 n, n) | n <- [1,2,3,4]] of (Left err) -> putStrLn (show err) (Right _) -> putStrLn "parsed correctly" putStrLn "" case parse the123Parser "" [(newPos "" 1 n, n) | n <- [1,3,4]] of (Left err) -> putStrLn (show err) (Right _) -> putStrLn "parsed correctly" the123Parser = do mytoken 1 mytoken 2 mytoken 3 eof return 123 ------- The output I get looks like this: (line 1, column 4): unexpected [((line 1, column 4),4)] expecting end of input (line 1, column 3): unexpected <3> In the second parse case, it correctly uses my showTok function to show the token. But in the first case, it just uses the regular show method. I guess that's because the eof parser doesn't know anything about how to show the token it sees. Any ideas on how I can get the error message in the first case to look more like the second case? Thanks, Lyle From vigalchin at gmail.com Thu Jul 10 04:23:08 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jul 10 04:13:51 2008 Subject: [Haskell-cafe] use of the GHC universal quantifier In-Reply-To: <2f9b2d30807090203u771260ffja8abe70814e426fc@mail.gmail.com> References: <5ae4f2ba0807082155t6718d9f3jfb09174c905ec2af@mail.gmail.com> <2f9b2d30807090203u771260ffja8abe70814e426fc@mail.gmail.com> Message-ID: <5ae4f2ba0807100123m396d07e6o565a2fc354777bc2@mail.gmail.com> Hi Ryan, Please see below. Vasili On Wed, Jul 9, 2008 at 4:03 AM, Ryan Ingram wrote: > Try {-# LANGUAGE RankNTypes #-}? vigalchin@ubuntu:~/FTP/Haskell/hsql-1.7$ runhaskell Setup.lhs build Preprocessing library hsql-1.7... Building hsql-1.7... [1 of 2] Compiling Database.HSQL.Types ( Database/HSQL/Types.hs, dist/build/Database/HSQL/Types.o ) Database/HSQL/Types.hs:67:0: Can't make a derived instance of `Typeable SqlError' (You need -XDeriveDataTypeable to derive an instance for this class) In the data type declaration for `SqlError' > > > "forall" does denote a universal quantifier, but because the 'implies' > of the function arrow, in logic, includes negation, you can use it to > emulate existential quantifiers. > > > data Existential = forall a. Ex a > > The type of the constructor Ex: > Ex :: forall a. a -> Existential Classical logic opposed to intuitionistic logic? <<<<<<<<<<<<<<<<<<<<<<<<<< > > > Pattern matching on Ex brings "a" back into scope (with no information > about it, so this type isn't that useful on its own): > > > use (Ex x) = 0 -- can't recover any useful information about x > > sample = Ex "sample" > > However, you can use existential types to encode additional > information about the included data; for example: > > > -- Ex2 :: forall a. Show a => a -> Exist2 > > data Exist2 = forall a. Show a => Ex2 a > > Now, pattern matching on Ex2 brings the Show instance into scope as well: > > > sample2 = Ex2 "sample2" > > use2 (Ex2 x) = show x > > You can also use higher rank polymorphism to encode existential types: > > > -- Ex3 :: (forall a. (forall b. Show b => b -> a) -> a) -> Exist3 > > -- note the rank-3 type on Ex3! > > newtype Exist3 = Ex3 (forall a. (forall b. Show b => b -> a) -> a) > > > sample3 = Ex3 (\k -> k "sample3") > > use3 (Ex3 f) = f (\x -> show x) > > -- ryan > > 2008/7/8 Galchin, Vasili : > > Hello, > > > > It seems to me by its name that "forall" denotes a logical universal > > quantifier. In any case, hsql-1.7/Database/HSQL/Types.hs uses "forall" at > > line #134. I got a nasty build so I added {-# LANGUAGE > > ExistentialQuantification #-} at the top of the module. Now I get the > > following a coupleof lines up: > > > > Database/HSQL/Types.hs:131:5: > > Illegal polymorphic or qualified type: forall a. > > Int > > -> FieldDef > > -> FieldDef > > -> CString > > -> Int > > -> IO a > > -> IO a > > In the definition of data constructor `Statement' > > In the data type declaration for `Statement' > > > > If seems that GHC doesn't like "a". Why? > > > > Kind regards, Vasili > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/957e5aba/attachment.htm From grzegorz.chrupala at computing.dcu.ie Thu Jul 10 06:16:25 2008 From: grzegorz.chrupala at computing.dcu.ie (Grzegorz Chrupala) Date: Thu Jul 10 06:07:08 2008 Subject: [Haskell-cafe] More idiomatic use of strictness Message-ID: <18379800.post@talk.nabble.com> Hi all, Is there a less ugly way of avoiding laziness in the code pasted below then the use of seq in the last line? The program is supposed to split a large input file into chunks and check in how many of those chunks each of a list of words appear, as well as the total number of chunks. Without the seq it consumes huge amounts of memory. Thanks! Grzegorz {-# LANGUAGE BangPatterns, PatternGuards #-} import Data.List (foldl') split delim s | [] <- rest = [token] | otherwise = token : split delim (tail rest) where (token,rest) = span (/=delim) s main = do putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words) getContents stats ws docs = foldl' f ((map (const 0) ws),0) docs where f (dfs,n) d = let dfs' = zipWith (\w df -> (df + fromEnum (w `elem` d))) ws dfs in sum dfs' `seq` (dfs',n+1) -- View this message in context: http://www.nabble.com/More-idiomatic-use-of-strictness-tp18379800p18379800.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From tux_rocker at reinier.de Thu Jul 10 06:48:27 2008 From: tux_rocker at reinier.de (Reinier Lamers) Date: Thu Jul 10 06:39:24 2008 Subject: [Haskell-cafe] More idiomatic use of strictness Message-ID: <200807101248.39798.tux_rocker@reinier.de> Hi all, Op Thursday 10 July 2008 12:16:25 schreef Grzegorz Chrupala: > Is there a less ugly way of avoiding laziness in the code pasted below then > the use of seq in the last line? You could replace the list dfs' with a strict list type, like: data StrictList a = Cons !a !(StrictList a) | Nil Then you wouldn't have to make useless calls to sum and seq to force strictness. It would be more work though because you'd have to define your own higher order functions to work with the strict list. Reinier -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part. Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/a9f33a4d/attachment.bin From mfn-haskell-cafe at cs.york.ac.uk Thu Jul 10 08:44:22 2008 From: mfn-haskell-cafe at cs.york.ac.uk (Matthew Naylor) Date: Thu Jul 10 08:36:14 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: <20080709004338.GA16229@gmx.de> References: <20080709004338.GA16229@gmx.de> Message-ID: <20080710124422.GA17542@pc149.staff.cs.york.ac.uk> Hi Marc, > The Chalmers Lava homepage tells abouta Xilinx version which should > be merged in soon. But on the xilinx homepage there was no reference > to neither Lava nor haskell.. > I'm thinking about designing a similar tool to www.combimouse.com. you also might consider using a PIC or some such microcontroller for this kind of project. I don't think there is a Haskell library for PIC programming, but it would be fun to make one! For somewhat related work, see issues 6 and 7 of The Monad.Reader (http://www.haskell.org/haskellwiki/The_Monad.Reader), especially Russell O'Conner's article. As mentioned in issue 7, I did use Lava to program an RCX microcontroller, but in general the techniques I used are much better suited to hardware. Also, there is "PICBIT: A Scheme System for the PIC Microcontroller" by Marc Feeley (http://www.iro.umontreal.ca/~feeley/papers/sw03.pdf) which might be of interest. Regarding Lava, there is a version on Satnam Singh's website (http://raintown.org/lava/). I use Emil Axelsson's version of Chalmers Lava (http://www.cs.chalmers.se/~emax/darcs/Lava2000/) that works with the latest GHC. I made some mods to target the Xilinx toolset and to provide very basic support for block RAMs (http://www.cs.york.ac.uk/fp/darcs/reduceron2/Lava2000/). I wish I had time to work more on this, and make it more accessible to others! Nevertheless, Chalmers Lava as it stands is already very usable. It is also very hacker-friendly, so I can recommend diving in! As an aside: I'm currently finishing off a document about my uses of Lava and its capabilities/weaknesses. Hopefully this will be publicly available soon. Matt. From rwbarton at math.harvard.edu Thu Jul 10 09:47:15 2008 From: rwbarton at math.harvard.edu (Reid Barton) Date: Thu Jul 10 09:38:05 2008 Subject: [Haskell-cafe] Lazy IO In-Reply-To: <62728db30807092005v470b170bvaf9b9b8f3e485fe9@mail.gmail.com> References: <62728db30807092005v470b170bvaf9b9b8f3e485fe9@mail.gmail.com> Message-ID: <20080710134715.GC26005@rwbarton.mit.edu> On Wed, Jul 09, 2008 at 11:05:47PM -0400, Ronald Guida wrote: > Question: If I can't change my function f (in this case, accumulator), > then is it possible to get the effect I want without having to resort > to "unsafeInterleaveIO"? Here's a possibility; you may or may not like it. module Main where import Control.Concurrent import Control.Concurrent.Chan import Control.Concurrent.MVar import Control.Monad {- promptInt, accumulator, makeAccPrompt as before -} main :: IO () main = do inChan <- newChan outMVar <- newEmptyMVar forkIO $ (getChanContents inChan) >>= (mapM_ (putMVar outMVar) . accumulator) let go = do p <- takeMVar outMVar m <- promptInt (makeAccPrompt p) case m of Just n -> do writeChan inChan n ns <- go return $ n:ns Nothing -> return [] xs <- go print xs The unsafeInterleaveIO is now hidden inside getChanContents. (I have an outMVar rather than an outChan just in case accumulator could produce lots of output before consuming much of its input.) Regards, Reid Barton From ronwalf at volus.net Thu Jul 10 10:29:39 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 10:20:21 2008 Subject: [Haskell-cafe] Combining Wouter's expressions with extensible records In-Reply-To: <694519c50807092001m59c4543fhba7a6200ae3e5072@mail.gmail.com> References: <694519c50807092001m59c4543fhba7a6200ae3e5072@mail.gmail.com> Message-ID: On Wed, Jul 9, 2008 at 11:01 PM, Antoine Latter wrote: > > It isn't immediately obvious to me that the "Typeable" family of > classes deal at all with higher-kinded type constructors, but I didn't > look that hard. > Yes, that's what I'm worried about. For people's fun and amusement, I've attached the file. The trailing comments show what I'm trying to accomplish (getName, setName, and so forth). -Ron -------------- next part -------------- A non-text attachment was scrubbed... Name: WouterTest.hs Type: application/octet-stream Size: 4001 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/f215e405/WouterTest.obj From ronwalf at volus.net Thu Jul 10 10:45:33 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 10:36:15 2008 Subject: [Haskell-cafe] Combining Wouter's expressions with extensible records In-Reply-To: References: <694519c50807092001m59c4543fhba7a6200ae3e5072@mail.gmail.com> Message-ID: Or, if people have easy-enough extensible records that /will/ work with funky types, I'd be happy to use those! -Ron On Thu, Jul 10, 2008 at 10:29 AM, Ron Alford wrote: > On Wed, Jul 9, 2008 at 11:01 PM, Antoine Latter wrote: >> >> It isn't immediately obvious to me that the "Typeable" family of >> classes deal at all with higher-kinded type constructors, but I didn't >> look that hard. >> > > Yes, that's what I'm worried about. For people's fun and amusement, > I've attached the file. The trailing comments show what I'm trying to > accomplish (getName, setName, and so forth). > > -Ron > From lists at qseep.net Thu Jul 10 11:15:14 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Thu Jul 10 11:06:25 2008 Subject: [Haskell-cafe] Poor Parsec error message In-Reply-To: <4875BCA9.4060507@qseep.net> References: <4875BCA9.4060507@qseep.net> Message-ID: <48762782.7080603@qseep.net> I figured it out, but it's not pretty. The problem is that the eof parser had no awareness of the showTok function. To fix the problem, I had to replace eof with its definition in terms of notFollowedBy, then replace notFollowedBy with its definition in terms of try and unexpected. Then, I changed the "show [c]" into "showToken c". Passing a token shower to the token function isn't a very robust way of guaranteeing your tokens display properly in error messages, because the other combinators don't take the same option. Of course, you can implement a Show instance for your tokens as you like. But, if you make the Show instance show the pretty version for the user, you lose the ability to see the real structure you get from a derived Show instance. In my real code, I want debugging to show tokens using a derived Show instance, so I can see all the structure. But when I show them to the user, I don't want them to see the embedded SourcePos, or the constructor names - I just want them to see a representation of what was lexed in order to produce that token. I think there should be a class called Token, with a method called showToken, or unlex, or display, or displayInError, something like that. This class should be a precondition of all the GenParser combinators. It should use the provided method to show the token in error messages. Here's the working version: import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Pos(newPos) showToken (pos,t) = "<" ++ show t ++ ">" myToken :: (Eq t, Show t) => (t -> Bool) -> GenParser (SourcePos,t) () (SourcePos,t) myToken q = token showToken posFromTok testTok where posFromTok (pos,t) = pos testTok (pos,t) = if (q t) then Just (pos,t) else Nothing main = do putStrLn "" case parse the123Parser "" [(newPos "" 1 n, n) | n <- [1,2,3,4]] of (Left err) -> putStrLn (show err) (Right _) -> putStrLn "parsed correctly" putStrLn "" case parse the123Parser "" [(newPos "" 1 n, n) | n <- [1,3,4]] of (Left err) -> putStrLn (show err) (Right _) -> putStrLn "parsed correctly" the123Parser = do myToken (==1) myToken (==2) myToken (==3) try (do{ c <- myToken (const True); unexpected (showToken c) } <|> return ()) notFollowedBy (myToken (==4)) return 123 - Lyle From dokondr at gmail.com Thu Jul 10 12:05:54 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Thu Jul 10 11:56:35 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? Message-ID: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> What is the best way to extend array? I would use a list instead of array as it is easy to append, but need to have random access to its elements later. So in fact I need to start with an integer array of size 1. Next I may need to add new elements to this array or modify values of the existing ones. Function: array :: (Ix a) => (a,a) -> [(a,b)] -> Array a b allows construct an array of a fixed size. How to add more elements to the array later? Thanks! -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/c669f8f7/attachment.htm From felipe.lessa at gmail.com Thu Jul 10 12:12:19 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Jul 10 12:03:01 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> Message-ID: 2008/7/10 Dmitri O.Kondratiev : > allows construct an array of a fixed size. How to add more elements to the > array later? I can't really answer your question, however I bet that it would require allocating another, bigger array and copying the old elements over, at least from time to time. So you may want to take a look at Data.Sequence[1], supporting O(1) append on both sides and (sort of) O(log i) for accessing the i-th element. [1] http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html HTH, -- Felipe. From jgbailey at gmail.com Thu Jul 10 12:37:19 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Thu Jul 10 12:28:01 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: Message-ID: 2008/7/9 Mitar : > > And it took 15 s. And also the profiling was like I would anticipate. > Calculating points coordinates and checking spheres takes almost all > time. > > So any suggestions how could I build a list of objects to check at > runtime and still have this third performance? Why this big > difference? I think the speed difference really comes from using a list to hold the spheres in your first two examples, to referring to them directly in case statements in your last example. Lists are going to introduce indirections and therefore are slower than referring directly to the values themselves. Maybe you would have better luck using arrays? Template Haskell is also an option - if you want to "hard code" your scene in another module, TH can turn it into that kind of case statement. Of course, as the scenes get more complex a series of nested cases isn't going to be too effecient. Justin From jonathanccast at fastmail.fm Thu Jul 10 13:06:56 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Jul 10 12:58:49 2008 Subject: [Haskell-cafe] More idiomatic use of strictness In-Reply-To: <18379800.post@talk.nabble.com> References: <18379800.post@talk.nabble.com> Message-ID: <1215709617.6571.7.camel@jcchost> On Thu, 2008-07-10 at 03:16 -0700, Grzegorz Chrupala wrote: > Hi all, > > Is there a less ugly way of avoiding laziness in the code pasted below then > the use of seq in the last line? > The program is supposed to split a large input file into chunks and check in > how many of those chunks each of a list of words appear, as well as the > total number of chunks. Without the seq it consumes huge amounts of memory. Strategies! Try ((,) $| rnf) dfs' (n + 1) Or (id $| seqPair rnf r0) (dfs', n + 1) But I don't know if that falls within the intended meaning of `less ugly'. jcc > {-# LANGUAGE BangPatterns, PatternGuards #-} > import Data.List (foldl') > > split delim s > | [] <- rest = [token] > | otherwise = token : split delim (tail rest) > where (token,rest) = span (/=delim) s > > main = do > putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words) > getContents > > stats ws docs = foldl' f ((map (const 0) ws),0) docs > where f (dfs,n) d = let dfs' = zipWith (\w df -> (df + fromEnum (w > `elem` d))) ws dfs > in sum dfs' `seq` (dfs',n+1) From marcot at riseup.net Thu Jul 10 13:53:20 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Thu Jul 10 13:43:54 2008 Subject: [Haskell-cafe] Existential quantification problem Message-ID: <1215712400.8094.7.camel@quindinho.domain.invalid> Hello, how do I unbox a existential quantificated data type? > {-# LANGUAGE ExistentialQuantification #-} > data L a = forall l. L (l a) > unboxL (L l) = l is giving me, in GHC: Inferred type is less polymorphic than expected Quantified type variable `l' escapes When checking an existential match that binds l :: l t The pattern(s) have type(s): L t The body has type: l t In the definition of `unboxL': unboxL (L l) = l Thanks. -- ?Marco T?lio Gontijo e Silva P?gina: http://marcotmarcot.googlepages.com/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From eeoam at ukfsn.org Thu Jul 10 14:00:52 2008 From: eeoam at ukfsn.org (Eric) Date: Thu Jul 10 13:51:41 2008 Subject: [Haskell-cafe] Trying to install cabal Message-ID: <48764E54.2090303@ukfsn.org> Dear all, I have downloaded cabal and am trying to install it but have gotten the following error message: C:\cabal\cabal-install-0.5.1>runghc Setup configure Configuring cabal-install-0.5.1... Setup: At least the following dependencies are missing Cabal >=1.4&&<1.5, HTTP >=3000&&<3002, zlib >=0.4 I'm not sure from this message what packages I need to install to get cabal up and running. Can anyone help? Eric M. From jonathanccast at fastmail.fm Thu Jul 10 13:59:56 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Jul 10 13:51:52 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <1215712400.8094.7.camel@quindinho.domain.invalid> References: <1215712400.8094.7.camel@quindinho.domain.invalid> Message-ID: <1215712796.6571.10.camel@jcchost> On Thu, 2008-07-10 at 14:53 -0300, Marco T?lio Gontijo e Silva wrote: > Hello, > > how do I unbox a existential quantificated data type? You can't. You have to use case analysis: case foo of L l -> where none of the information your case analysis discovers about the actual type of l can be made available outside of the scope of the case expression. (It can't `escape'). This is required for decidable static typing, IIRC. jcc > > > {-# LANGUAGE ExistentialQuantification #-} > > data L a = forall l. L (l a) > > unboxL (L l) = l > > is giving me, in GHC: > > Inferred type is less polymorphic than expected > Quantified type variable `l' escapes > When checking an existential match that binds > l :: l t > The pattern(s) have type(s): L t > The body has type: l t > In the definition of `unboxL': unboxL (L l) = l > > Thanks. > From dons at galois.com Thu Jul 10 14:03:51 2008 From: dons at galois.com (Don Stewart) Date: Thu Jul 10 13:54:47 2008 Subject: [Haskell-cafe] More idiomatic use of strictness In-Reply-To: <1215709617.6571.7.camel@jcchost> References: <18379800.post@talk.nabble.com> <1215709617.6571.7.camel@jcchost> Message-ID: <20080710180351.GB26811@liouville.galois.com> jonathanccast: > On Thu, 2008-07-10 at 03:16 -0700, Grzegorz Chrupala wrote: > > Hi all, > > > > Is there a less ugly way of avoiding laziness in the code pasted below then > > the use of seq in the last line? > > The program is supposed to split a large input file into chunks and check in > > how many of those chunks each of a list of words appear, as well as the > > total number of chunks. Without the seq it consumes huge amounts of memory. > > Strategies! Try > > ((,) $| rnf) dfs' (n + 1) > > Or > > (id $| seqPair rnf r0) (dfs', n + 1) > > But I don't know if that falls within the intended meaning of `less > ugly'. I'd use a strict pair and the rnf strategy. data P = P [Something] !Int rnf dfs' (P dfs' (n+1) From dons at galois.com Thu Jul 10 14:05:57 2008 From: dons at galois.com (Don Stewart) Date: Thu Jul 10 13:56:44 2008 Subject: [Haskell-cafe] Trying to install cabal In-Reply-To: <48764E54.2090303@ukfsn.org> References: <48764E54.2090303@ukfsn.org> Message-ID: <20080710180557.GC26811@liouville.galois.com> eeoam: > Dear all, > > I have downloaded cabal and am trying to install it but have gotten the > following error message: > > C:\cabal\cabal-install-0.5.1>runghc Setup configure > Configuring cabal-install-0.5.1... > Setup: At least the following dependencies are missing > Cabal >=1.4&&<1.5, HTTP >=3000&&<3002, zlib >=0.4 > > I'm not sure from this message what packages I need to install to get > cabal up and running. Can anyone help? All Haskell packages of good repute live on hackage.haskell.org. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Cabal http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTTP http://hackage.haskell.org/cgi-bin/hackage-scripts/package/zlib From marcot at riseup.net Thu Jul 10 14:16:38 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Thu Jul 10 14:07:12 2008 Subject: [Haskell-cafe] Trying to install cabal In-Reply-To: <48764E54.2090303@ukfsn.org> References: <48764E54.2090303@ukfsn.org> Message-ID: <1215713798.8094.8.camel@quindinho.domain.invalid> Hello Eric. Em Qui, 2008-07-10 ?s 19:00 +0100, Eric escreveu: > C:\cabal\cabal-install-0.5.1>runghc Setup configure > Configuring cabal-install-0.5.1... > Setup: At least the following dependencies are missing > Cabal >=1.4&&<1.5, HTTP >=3000&&<3002, zlib >=0.4 > > I'm not sure from this message what packages I need to install to get > cabal up and running. Can anyone help? You can get these listed packages (Cabal, HTTP and zlib) in Hackage ( http://hackage.haskell.org/ ). Greetings. -- ?Marco T?lio Gontijo e Silva P?gina: http://marcotmarcot.googlepages.com/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From dan.doel at gmail.com Thu Jul 10 14:19:28 2008 From: dan.doel at gmail.com (Dan Doel) Date: Thu Jul 10 14:10:42 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <1215712400.8094.7.camel@quindinho.domain.invalid> References: <1215712400.8094.7.camel@quindinho.domain.invalid> Message-ID: <200807101419.29255.dan.doel@gmail.com> On Thursday 10 July 2008, Marco T?lio Gontijo e Silva wrote: > Hello, > > how do I unbox a existential quantificated data type? > > > {-# LANGUAGE ExistentialQuantification #-} > > data L a = forall l. L (l a) > > unboxL (L l) = l > > is giving me, in GHC: > > Inferred type is less polymorphic than expected > Quantified type variable `l' escapes > When checking an existential match that binds > l :: l t > The pattern(s) have type(s): L t > The body has type: l t > In the definition of `unboxL': unboxL (L l) = l You don't. Or, at least, you don't do it that way. The point of an existential is that the quantified type is 'forgotten', and there's no way to get it back. That's good for abstraction, in that it restricts you to using some provided interface that's guaranteed to work with the forgotten type, but it means that you can't just take things out of the existential box. Instead, you have to use them in ways that make the forgotten type irrelevant (that is, ways that are parametric in the corresponding type). The type of the unboxL function in a type system with first-class existentials is something like: unboxL :: L a -> (exists l. l a) Of course, GHC doesn't do first-class existentials, otherwise you'd probably not be bothering with the datatype in the first place. :) The proper way to eliminate an existential is (as mentioned above) with a universal: elim :: (exists l. l a) -> (forall l. l a -> r) -> r elim e f = f e Or, since existentials in GHC are restricted to data types: elim :: L a -> (forall l. l a -> r) -> r elim (L e) f = f e Of course, as has already been noted, elim foo (\l -> stuff) is equivalent to: case foo of L l -> stuff and doesn't need rank-2 polymorphism enabled, to boot. :) -- Dan From andrewcoppin at btinternet.com Thu Jul 10 14:35:21 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Jul 10 14:27:24 2008 Subject: [Haskell-cafe] Architecturally flawed Message-ID: <48765669.8090708@btinternet.com> OK, so I just spent an entire day trying to write some code, and after hours of struggling I have something that's semi-working but very ugly and rather unreliable. My usual guideline for Haskell programming is "if it seems hard, you're doing it wrong"... After many hours of effort, I came up with these: data Writer x instance Monad Writer run_writer :: Writer () -> ByteString write1 :: Bool -> Writer () write8 :: Word8 -> Writer () write16 :: Word16 -> Writer () write32 :: Word32 -> Writer () write64 :: Word64 -> Writer () writeN :: Word8 -> Word32 -> Writer () data Reader x instance Monad Reader run_reader :: Reader x -> ByteString -> x is_EOF :: Reader Bool read1 :: Reader Bool read8 :: Reader Word8 read16 :: Reader Word16 read32 :: Reader Word32 read64 :: Reader Word64 readN :: Word8 -> Reader Word32 Notice that, unlike the Binary package, all of these are bit-aligned rather than byte-aligned. This is what took so much effort. I strived to make each operation as efficient as possible - by performing as few steps as possible. It would have been *far* easier to, say, implement read8 by calling read1 eight times and then packing the bits back into a byte. But that wouldn't be very fast. So actually read8 reads a pair of bytes, bit-shifts them as required, and then ANDs them together. And so on. (Note that the Writer monad uses Data.Binary.Builder (only) from the Binary package. I assume this is more efficient...) I even sat down and wrote a battery of QuickCheck properties because - as you can imagine - there's a hell of a lot to go wrong here! After many hours, I managed to get it to pass all tests... Next I decided to write an LZW compressor. Here's what I came up with: data EncodeLZW symbol eLZW_start :: (Ord symbol) => EncodeLZW symbol eLZW_encode :: (Ord symbol) => EncodeLZW symbol -> symbol -> Writer (EncodeLZW symbol) eLZW_end :: (Ord symbol) => EncodeLZW symbol -> Writer () data DecodeLZW symbol dLZW_start :: DecodeLZW symbol dLZW_decode :: DecodeLZW symbol -> Reader (DecodeLZW symbol, symbol) So each step of the encoder (possibly) writes some bits, and also returns a new encoder state. The decoder is similar. (At least one program bug was caused by the wrong version of the state being used somewhere!) Then I tried to run the code, and oh look, there's a bug somewhere. Emphasis "somewhere". At this point I have several KB of code and no idea how in hell to test it. What I *want* to do is single-step through the encoder algorithm, watch it write bits out and update state, and then single-step through the decoder watching it read bits in and update its state, etc. But I can't. All the encoder does is return a giant Writer object which you can't look inside, only run. And likewise for the decoder. I could try GHC's new debugger. But my experiences with it so far have shown that for all but the most trivial programs possible, it becomes intractably difficult to figure out what the debugger is actually showing you. I actually tried to debug a "normal" LZW implementation once - one that didn't involve two highly convoluted custom monads and a stateful execution model with manually threaded state. This is *not* my idea of a fun time... In a "normal" programming language, at this point you would sprinkle a few print statements around so you can see the intermediate steps the program is taking. But I can't. I'm in the wrong monad. Curses! In the end, the only solution I could come up with was to design a second, "hacked" version of the two monads. Instead of importing one module, you import another that provides the same interface. However, now Reader and Writer are aliases to IO. All write requests cause pretty-printed binary to be sent to stdout, and all read requests pop up a prompt for input from stdin. It worked reasonably well in that I could now add the vitally necessary print statements, and see intermediate values and so forth... It wasn't very pretty though. At this point I decided that lugging 5 individual functions around was silly, and I should write a class: class Encoder e where encoder_start :: e x encode :: e x -> x -> Writer (e x) encoder_end :: e x -> Writer () class Decoder d where decoder_start :: d x decode :: d x -> Reader (d x, x) 10 points to the first person to spot the fatal flaw in this plan... Yep, that's right. The type system won't accept this. The reason? x needs an Ord context. If you turn on multi-parameter type classes *and* flexible instances, apparently this works: class Encoder e x where... instance (Ord x) => Encoder EncodeLZW x where... (I haven't tried but I *presume* it means what I think it does...) Alternatively, you can avoid using dangerous type system extensions and just write class Encoder e where encode :: (Symbol x) => e x -> x -> Writer (e x) ... and make Symbol encompass everything any possible encoder could want. (In reality, x is almost always Word8 or something. But I dislike loss of generality just for the hell of it...) So at least I got that part fixed. Heh. But now I find myself worrying about yet *another* problem: is Writer lazy enough? I mean, the idea is that you can write a program that lazily reads from a file, pushes it through a Writer, and lazily writes the result back to another file. The thing should chug along reasonably fast and use a constant amount of RAM. But all this is only true of Writer is actually lazy enough. I have a horrible feeling that all the complicated Origami inside makes it too strict. And I have no way to check! Actually, thinking about it, is Reader lazy enough? You call run_reader and it hands over your data, but if that data is, say, a list, will run_reader build the entire damn list before it'll hand it over? Or will the monadic code by called as-needed to generate the list elements? Obviously I desire the latter, but I'm really not sure what the actual behaviour is... In summary, I've spent several days coding, and I still don't have a single algorithm working. I've spent all my time wrestling with the mundane details of infrastructure rather than the interesting algorithms I actually set out to implement. This makes me very sad. :-( If anybody can think of a better set of abstractions or another way to do debugging, I'd be interested to hear about it. (This would all be so trivial in an OO language. Just make an Encoder object that updates its own state internally and talks to a Source object and a Destination object for its data...) From oddron at gmail.com Thu Jul 10 14:39:55 2008 From: oddron at gmail.com (Ronald Guida) Date: Thu Jul 10 14:30:36 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <200807101419.29255.dan.doel@gmail.com> References: <1215712400.8094.7.camel@quindinho.domain.invalid> <200807101419.29255.dan.doel@gmail.com> Message-ID: <62728db30807101139x3b79c36cn5cd1648b43f52165@mail.gmail.com> On Thu, 10 July 2008, Marco T?lio Gontijo e Silva wrote: > how do I unbox a existential quantificated data type? Dan Doel wrote: > elim :: L a -> (forall l. l a -> r) -> r > elim (L e) f = f e Just one catch: You can't actually write a function 'f' of type (forall l. l a -> r) without knowing something about the forgotten type of l. One way to deal with this is by restricting the type of l in the data declaration. For example, you could restrict it to the typeclass Foldable, and then you have access to the methods of that typeclass. \begin{code} {-# LANGUAGE ExistentialQuantification #-} module Main where import qualified Data.Foldable as F data L a = forall l. (F.Foldable l) => L (l a) toList :: L a -> [a] toList (L x) = F.foldr (:) [] x main :: IO () main = do let x = L [1..10] print $ toList x \end{code} See also http://www.haskell.org/haskellwiki/Existential_type From dons at galois.com Thu Jul 10 14:41:45 2008 From: dons at galois.com (Don Stewart) Date: Thu Jul 10 14:32:29 2008 Subject: [Haskell-cafe] Architecturally flawed In-Reply-To: <48765669.8090708@btinternet.com> References: <48765669.8090708@btinternet.com> Message-ID: <20080710184145.GD26811@liouville.galois.com> andrewcoppin: > I could try GHC's new debugger. But my experiences with it so far have > shown that for all but the most trivial programs possible, it becomes > intractably difficult to figure out what the debugger is actually > showing you. I actually tried to debug a "normal" LZW implementation > once - one that didn't involve two highly convoluted custom monads and a > stateful execution model with manually threaded state. This is *not* my > idea of a fun time... For what its worth, people are using this at work on large projects happily. > In a "normal" programming language, at this point you would sprinkle a > few print statements around so you can see the intermediate steps the > program is taking. But I can't. I'm in the wrong monad. Curses! Use Debug.Trace.trace. > In the end, the only solution I could come up with was to design a > second, "hacked" version of the two monads. Instead of importing one > module, you import another that provides the same interface. However, > now Reader and Writer are aliases to IO. All write requests cause > pretty-printed binary to be sent to stdout, and all read requests pop up > a prompt for input from stdin. It worked reasonably well in that I could > now add the vitally necessary print statements, and see intermediate > values and so forth... It wasn't very pretty though. You should have used Debug.Trace. > So at least I got that part fixed. Heh. But now I find myself worrying > about yet *another* problem: is Writer lazy enough? > > I mean, the idea is that you can write a program that lazily reads from > a file, pushes it through a Writer, and lazily writes the result back to > another file. The thing should chug along reasonably fast and use a > constant amount of RAM. But all this is only true of Writer is actually > lazy enough. I have a horrible feeling that all the complicated Origami > inside makes it too strict. And I have no way to check! Actually, you can use 'chasingBottoms' to write QuickCheck properties that state your expected laziness or strictness behaviour. > Actually, thinking about it, is Reader lazy enough? You call run_reader > and it hands over your data, but if that data is, say, a list, will > run_reader build the entire damn list before it'll hand it over? Or will > the monadic code by called as-needed to generate the list elements? > Obviously I desire the latter, but I'm really not sure what the actual > behaviour is... The mtl Reader class is lazy. > In summary, I've spent several days coding, and I still don't have a > single algorithm working. I've spent all my time wrestling with the > mundane details of infrastructure rather than the interesting algorithms > I actually set out to implement. This makes me very sad. :-( You should have stopped by #haskell a few days ago. > If anybody can think of a better set of abstractions or another way to > do debugging, I'd be interested to hear about it. There's already a bit layer for Data.Binary on hackage, for what its worth. And an LZW encoder/decoder. > (This would all be so trivial in an OO language. Just make an Encoder > object that updates its own state internally and talks to a Source > object and a Destination object for its data...) Make an Encoder class that updates its own state internally and lazy streams input and output. As Data.Binary does, as zlib does, et al. -- Don From jefferson.r.heard at gmail.com Thu Jul 10 14:59:04 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Thu Jul 10 14:49:45 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> Message-ID: <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> Two questions. How often does the array change, and how big does it get? It may well be that you just copy it and take the hit, as that'll be cheaper (even in C, incidentally) than any other solution, if it's a short array or if the updates happen rarely. If not, try using Data.Array.Diff and replaceDiffArray. This is usually fairly efficient for most applications. By the way, depending on the type of the data you're putting into these arrays, Data.ByteString might be a good choice as well. On Thu, Jul 10, 2008 at 12:12 PM, Felipe Lessa wrote: > 2008/7/10 Dmitri O.Kondratiev : >> allows construct an array of a fixed size. How to add more elements to the >> array later? > > I can't really answer your question, however I bet that it would > require allocating another, bigger array and copying the old elements > over, at least from time to time. So you may want to take a look at > Data.Sequence[1], supporting O(1) append on both sides and (sort of) > O(log i) for accessing the i-th element. > > [1] http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html > > HTH, > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From ronwalf at volus.net Thu Jul 10 15:04:49 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 14:55:30 2008 Subject: [Haskell-cafe] Data.Derive problems Message-ID: I'm using GHC 6.8.3 with $ cabal --version cabal-install version 0.5.1 using version 1.4.0.1 of the Cabal library I installed Data.Derive from hackage, only to be unable to find the 'derive' binary! Trying it directly from darcs, I get: $ ghc --make Setup.hs [1 of 1] Compiling Main ( Setup.hs, Setup.o ) Linking Setup ... silverback-wired:derive ronwalf$ ./Setup configure Warning: defaultUserHooks in Setup script is deprecated. Configuring derive-0.1.1... Warning: No 'build-type' specified. If you do not need a custom Setup.hs or ./configure script then use 'build-type: Simple'. -Ron From ronwalf at volus.net Thu Jul 10 15:15:18 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 15:05:59 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: References: Message-ID: I'm making progress, but how would I make the following a Typeable instance: data (f :+: g) e = Inl (f e) | Inr (g e) deriving Eq Here is what I'm using for Expr: data Expr f = In (f (Expr f)) instance Typeable1 f => Typeable (Expr f) where typeOf (In x) = mkTyConApp (mkTyCon "Data.Trie.General.ListGT") [typeOf1 x] I don't think I can use this for ':+:', because the typeOf instance only has access to a member of one type at a time. This may be similar to a definition of Typeable2 for Either, but I can't find an example to follow for that. Thanks, -Ron On Wed, Jul 9, 2008 at 10:40 PM, Ron Alford wrote: > Well, my extension of Wouter's datatypes proved to be unweildy.... > So, I'm trying to use > http://fmapfixreturn.wordpress.com/2008/05/03/simple-extensible-records-now-quick-generic-tricks-pt-1/ > for extensible records. > > I ran across my first problem rather quickly! > data Expr f = In (f (Expr f)) > > Ok, but to make it part of a record, it needs to implement Data: > data Expr f = In (f (Expr f)) deriving Data > > but this gives > No instances for (Data (f (Expr f)), Typeable (Expr f)) > arising from the 'deriving' clause of a data type declaration > at Planning/Wouter.hs:77:0-42 > > Any hints? > > Thanks, > -Ron > From ndmitchell at gmail.com Thu Jul 10 15:18:49 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Jul 10 15:09:30 2008 Subject: [Haskell-cafe] Data.Derive problems In-Reply-To: References: Message-ID: <404396ef0807101218l57bad652m28a08a383d1e7ae5@mail.gmail.com> Hi Ron, > I'm using GHC 6.8.3 with $ cabal --version > cabal-install version 0.5.1 > using version 1.4.0.1 of the Cabal library > > I installed Data.Derive from hackage, only to be unable to find the > 'derive' binary! Did you do the runhaskell Setup configure && runhaskell Setup build && runhaskell Setup install? You may also need to add the install path to your $PATH variable - do -v when running Setup install to see where it goes. Thanks Neil From jamiiecb at googlemail.com Thu Jul 10 15:19:58 2008 From: jamiiecb at googlemail.com (Jamie Brandon) Date: Thu Jul 10 15:10:39 2008 Subject: [Haskell-cafe] Architecturally flawed In-Reply-To: <20080710184145.GD26811@liouville.galois.com> References: <48765669.8090708@btinternet.com> <20080710184145.GD26811@liouville.galois.com> Message-ID: <10ed1a750807101219j2fd40264k8b5fc45050b1f697@mail.gmail.com> I have a similar piece of code at http://code.haskell.org/gmap/serial/ which is fairly well tested. It currently only outputs lists of words but its based on Data.Binary so it should be fairly easy to get bytestrings out it (bytestrings worked up till 2-3 weeks ago, I just havent bothered to keep the byestring part up to date).I dont yet know how fast it is but I will be tweaking it over the next month or so. Jamie From ronwalf at volus.net Thu Jul 10 15:25:22 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 15:16:02 2008 Subject: [Haskell-cafe] Data.Derive problems In-Reply-To: <404396ef0807101218l57bad652m28a08a383d1e7ae5@mail.gmail.com> References: <404396ef0807101218l57bad652m28a08a383d1e7ae5@mail.gmail.com> Message-ID: On Thu, Jul 10, 2008 at 3:18 PM, Neil Mitchell wrote: > Hi Ron, > >> I'm using GHC 6.8.3 with $ cabal --version >> cabal-install version 0.5.1 >> using version 1.4.0.1 of the Cabal library >> >> I installed Data.Derive from hackage, only to be unable to find the >> 'derive' binary! > > Did you do the runhaskell Setup configure && runhaskell Setup build && > runhaskell Setup install? I used 'sudo cabal install derive'. I did find the binary - in my user's .cabal/bin directory! Odd that it should default to that when run as root. I don't have the darcs version working yet, though. -Ron From tom.davie at gmail.com Thu Jul 10 15:32:31 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Jul 10 15:23:16 2008 Subject: [Haskell-cafe] Data.Derive problems In-Reply-To: References: <404396ef0807101218l57bad652m28a08a383d1e7ae5@mail.gmail.com> Message-ID: <04808646-6F24-4AED-AE87-D9DF88963EB9@gmail.com> On 10 Jul 2008, at 21:25, Ron Alford wrote: > On Thu, Jul 10, 2008 at 3:18 PM, Neil Mitchell > wrote: >> Hi Ron, >> >>> I'm using GHC 6.8.3 with $ cabal --version >>> cabal-install version 0.5.1 >>> using version 1.4.0.1 of the Cabal library >>> >>> I installed Data.Derive from hackage, only to be unable to find the >>> 'derive' binary! >> >> Did you do the runhaskell Setup configure && runhaskell Setup build >> && >> runhaskell Setup install? > > I used 'sudo cabal install derive'. I did find the binary - in my > user's .cabal/bin directory! Odd that it should default to that when > run as root. > > I don't have the darcs version working yet, though. I've found that cabal install doesn't actually install anything on my system either, despite going through all the motions. I just download the tarballs of hackage and config/build/install them myself, and I then end up with all the relevant bits installed. Bob From ndmitchell at gmail.com Thu Jul 10 15:34:40 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Jul 10 15:25:32 2008 Subject: [Haskell-cafe] Data.Derive problems In-Reply-To: References: <404396ef0807101218l57bad652m28a08a383d1e7ae5@mail.gmail.com> Message-ID: <404396ef0807101234k7dbf9f50k97fea324b1beb119@mail.gmail.com> Hi > > Did you do the runhaskell Setup configure && runhaskell Setup build && > > runhaskell Setup install? > > I used 'sudo cabal install derive'. I did find the binary - in my > user's .cabal/bin directory! Odd that it should default to that when > run as root. I think if you pass --global as a flag it will appear somewhere more sensible. > I don't have the darcs version working yet, though. What is the problem? The message you gave from runhaskell Setup configure was merely a warning, and it should continue to work fine if you build/install it. Thanks Neil From haskell at list.mightyreason.com Thu Jul 10 15:47:34 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Thu Jul 10 15:38:31 2008 Subject: [Haskell-cafe] Template Haskell and haskell-src-exts Message-ID: Hi, Can one represent the ''Type template Haskell syntax of $( makeMergeable ''FileDescriptorProto ) in haskell-src.exts Language.Haskell.Exts.Syntax ? And what are the HsReify data (e.g. HsReifyType and HsReifyDecl and HsReifyFixity )? I don't see any pretty print capability to produce the ''Type so I am wondering what else I might use... From aslatter at gmail.com Thu Jul 10 16:16:33 2008 From: aslatter at gmail.com (Antoine Latter) Date: Thu Jul 10 16:07:20 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: References: Message-ID: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> On Thu, Jul 10, 2008 at 2:15 PM, Ron Alford wrote: > I'm making progress, but how would I make the following a Typeable instance: > data (f :+: g) e = Inl (f e) | Inr (g e) deriving Eq > > Here is what I'm using for Expr: > data Expr f = In (f (Expr f)) > instance Typeable1 f => Typeable (Expr f) where > typeOf (In x) = mkTyConApp (mkTyCon "Data.Trie.General.ListGT") [typeOf1 x] > > I don't think I can use this for ':+:', because the typeOf instance > only has access to a member of one type at a time. > This may be similar to a definition of Typeable2 for Either, but I > can't find an example to follow for that. > Maybe something like: instance (Typeable1 f, Typeable1 g) => Typeable (f :+: g) where typeOf in@(InL f) = (some function of 'f' and 'g') where InR g = undefined `asTypeOf` in typeOf in@(InR g) = (some function of 'f' and 'g') where InL f = undefined `asTypeOf` in would work? -Antoine From jeremy at n-heptane.com Thu Jul 10 16:22:01 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Jul 10 16:09:57 2008 Subject: [Haskell-cafe] Template Haskell and haskell-src-exts In-Reply-To: References: Message-ID: <87zlopv6ae.wl%jeremy@n-heptane.com> Hello, I am not sure about the full answer to your qusetion, but I do know that template haskell support in haskell-src-exts is currently broken, but supposedly easy to fix. Not sure if that will give you the features you need or not though. From this thread: http://groups.google.com/group/haskell-server-pages/browse_thread/thread/c2a44d1445b66d35 --> > It would be really nice if trhsx could parse files that have template > haskell in them. It would simplify using happs-hsp-template a bit. Right, there's an open bug in haskell-src-exts for that. There used to be working support for TH, but the syntax was changed for 6.4 iirc and haskell-src-exts was never updated to fix that. It should be rather easy though, I'll have a look when I get some time over. <-- j. At Thu, 10 Jul 2008 20:47:34 +0100, ChrisK wrote: > > Hi, > > Can one represent the ''Type template Haskell syntax of > > $( makeMergeable ''FileDescriptorProto ) > > in haskell-src.exts Language.Haskell.Exts.Syntax ? > > And what are the HsReify data (e.g. HsReifyType and HsReifyDecl and HsReifyFixity )? > > I don't see any pretty print capability to produce the ''Type so I am wondering > what else I might use... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andre at digirati.com.br Thu Jul 10 16:57:22 2008 From: andre at digirati.com.br (Andre Nathan) Date: Thu Jul 10 16:44:58 2008 Subject: [Haskell-cafe] Inductive graphs memory usage Message-ID: <1215723442.5468.18.camel@homesick> Hello I'm trying to create a directed graph using the Data.Graph.Inductive. The graph is a random graph using the G(n, p) model, that is, each of the n nodes is linked to every other node with probability p. I'm seeing a large increase of memory usage when n grows (this is using p = 0.1): n = 1000 -> 96MB n = 2000 -> 283MB n = 3000 -> 760MB So, I'm probably doing something very stupid :) The code is below. Is there anything I could do to optimize memory usage here? module Main where import Control.Monad import Data.Graph.Inductive import System.Random createEdges :: Int -> Double -> IO [LEdge Int] createEdges n prob = foldM create [] [1..n] where create es i = foldM (flip $ link i) es [i, i-1 .. 1] link i j es | i == j = return es -- no self-loops | otherwise = do es' <- maybeCreateEdge i j prob es es'' <- maybeCreateEdge j i prob es' return es'' maybeCreateEdge :: Node -> Node -> Double -> [LEdge Int] -> IO [LEdge Int] maybeCreateEdge i j prob es = do r <- randomDouble return $ if r < prob then (i, j, 0):es else es randomDouble :: IO Double randomDouble = getStdRandom $ random main :: IO () main = do let (n, p) = (3000, 0.1) es <- createEdges n p let g = mkGraph [(i, 0) | i <- [1..n]] es :: Gr Int Int return () Thanks, Andre From oddron at gmail.com Thu Jul 10 18:32:38 2008 From: oddron at gmail.com (Ronald Guida) Date: Thu Jul 10 18:23:19 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <1215723442.5468.18.camel@homesick> References: <1215723442.5468.18.camel@homesick> Message-ID: <62728db30807101532k6c5adb20hd1e8344f8a2cdd98@mail.gmail.com> On Thu, Jul 10, 2008 at 4:57 PM, Andre Nathan wrote: > Hello > > I'm trying to create a directed graph using the Data.Graph.Inductive. > The graph is a random graph using the G(n, p) model, that is, each of > the n nodes is linked to every other node with probability p. So the average degree of a single node is p * n, and the expected number of edges in the entire graph will grow as O(n ^2). > I'm seeing a large increase of memory usage when n grows (this is using > p = 0.1): > > n = 1000 -> 96MB > n = 2000 -> 283MB > n = 3000 -> 760MB > > So, I'm probably doing something very stupid :) Your ratios are about 1 : 3 : 8. That pretty close to quadratic growth, 1 : 4 : 9, so I think all is well. From ronwalf at volus.net Thu Jul 10 18:38:47 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 18:29:30 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> Message-ID: Close - it compiles now! I made a minor change, going to Typeable1 instead of Typeable: instance (Typeable1 f, Typeable1 g) => Typeable1 (f :+: g) where typeOf1 l@(Inl x) = mkTyConApp (mkTyCon "Planning.Wouter.:+:") [typeOf1 x, typeOf1 y] where (Inr y) = undefined `asTypeOf` l typeOf1 r@(Inr y) = mkTyConApp (mkTyCon "Planning.Wouter.:+:") [typeOf1 x, typeOf1 y] where (Inl x) = undefined `asTypeOf` r Except this gives me a runtime error: *WouterTest> getName testNamed "*** Exception: Prelude.undefined The only thing I can think of is to have a class that gives default values to type - ick! -Ron Alford On Thu, Jul 10, 2008 at 4:16 PM, Antoine Latter wrote: > On Thu, Jul 10, 2008 at 2:15 PM, Ron Alford wrote: >> I'm making progress, but how would I make the following a Typeable instance: >> data (f :+: g) e = Inl (f e) | Inr (g e) deriving Eq >> >> Here is what I'm using for Expr: >> data Expr f = In (f (Expr f)) >> instance Typeable1 f => Typeable (Expr f) where >> typeOf (In x) = mkTyConApp (mkTyCon "Data.Trie.General.ListGT") [typeOf1 x] >> >> I don't think I can use this for ':+:', because the typeOf instance >> only has access to a member of one type at a time. >> This may be similar to a definition of Typeable2 for Either, but I >> can't find an example to follow for that. >> > > Maybe something like: > > instance (Typeable1 f, Typeable1 g) => Typeable (f :+: g) where > typeOf in@(InL f) = (some function of 'f' and 'g') > where InR g = undefined `asTypeOf` in > > typeOf in@(InR g) = (some function of 'f' and 'g') > where InL f = undefined `asTypeOf` in > > would work? > > -Antoine > -------------- next part -------------- A non-text attachment was scrubbed... Name: WouterTest.hs Type: application/octet-stream Size: 5429 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/85cc3618/WouterTest-0001.obj From ronwalf at volus.net Thu Jul 10 18:43:58 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 18:34:39 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> Message-ID: This is a bit similar to Either. Is there a way to see the generated instance code for deriving instance Data Either ? On Thu, Jul 10, 2008 at 6:38 PM, Ron Alford wrote: > Close - it compiles now! I made a minor change, going to Typeable1 > instead of Typeable: > > instance (Typeable1 f, Typeable1 g) => Typeable1 (f :+: g) where > typeOf1 l@(Inl x) = mkTyConApp (mkTyCon "Planning.Wouter.:+:") > [typeOf1 x, typeOf1 y] > where (Inr y) = undefined `asTypeOf` l > typeOf1 r@(Inr y) = mkTyConApp (mkTyCon "Planning.Wouter.:+:") > [typeOf1 x, typeOf1 y] > where (Inl x) = undefined `asTypeOf` r > > Except this gives me a runtime error: > *WouterTest> getName testNamed > "*** Exception: Prelude.undefined > > The only thing I can think of is to have a class that gives default > values to type - ick! > > -Ron Alford > > On Thu, Jul 10, 2008 at 4:16 PM, Antoine Latter wrote: >> On Thu, Jul 10, 2008 at 2:15 PM, Ron Alford wrote: >>> I'm making progress, but how would I make the following a Typeable instance: >>> data (f :+: g) e = Inl (f e) | Inr (g e) deriving Eq >>> >>> Here is what I'm using for Expr: >>> data Expr f = In (f (Expr f)) >>> instance Typeable1 f => Typeable (Expr f) where >>> typeOf (In x) = mkTyConApp (mkTyCon "Data.Trie.General.ListGT") [typeOf1 x] >>> >>> I don't think I can use this for ':+:', because the typeOf instance >>> only has access to a member of one type at a time. >>> This may be similar to a definition of Typeable2 for Either, but I >>> can't find an example to follow for that. >>> >> >> Maybe something like: >> >> instance (Typeable1 f, Typeable1 g) => Typeable (f :+: g) where >> typeOf in@(InL f) = (some function of 'f' and 'g') >> where InR g = undefined `asTypeOf` in >> >> typeOf in@(InR g) = (some function of 'f' and 'g') >> where InL f = undefined `asTypeOf` in >> >> would work? >> >> -Antoine >> > From allbery at ece.cmu.edu Thu Jul 10 18:53:31 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jul 10 18:44:11 2008 Subject: [Haskell-cafe] Trying to install cabal In-Reply-To: <48764E54.2090303@ukfsn.org> References: <48764E54.2090303@ukfsn.org> Message-ID: On 2008 Jul 10, at 14:00, Eric wrote: > I have downloaded cabal and am trying to install it but have gotten > the > following error message: > > C:\cabal\cabal-install-0.5.1>runghc Setup configure Cabal itself is a special case; you need the same version of Cabal already installed to install it via Cabal... Just run "make" to bootstrap it, IIRC. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From andre at digirati.com.br Thu Jul 10 19:07:56 2008 From: andre at digirati.com.br (Andre Nathan) Date: Thu Jul 10 18:55:33 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <62728db30807101532k6c5adb20hd1e8344f8a2cdd98@mail.gmail.com> References: <1215723442.5468.18.camel@homesick> <62728db30807101532k6c5adb20hd1e8344f8a2cdd98@mail.gmail.com> Message-ID: <1215731276.5468.26.camel@homesick> On Thu, 2008-07-10 at 18:32 -0400, Ronald Guida wrote: > Your ratios are about 1 : 3 : 8. > That pretty close to quadratic growth, 1 : 4 : 9, so I think all is well. Maybe, but 96MB of resident memory for a 1000-node graph looks bad, especially considering p is low. Is the internal representation of inductive graphs perhaps not very memory-efficient? I still haven't read Erwig's paper... I know this is probably not fair, but I'm comparing these numbers with a C implementation which uses Ruby's C API for its complex data structures, and a 10,000 nodes graph uses around 6MB of memory. Thanks, Andre From dons at galois.com Thu Jul 10 19:52:44 2008 From: dons at galois.com (Don Stewart) Date: Thu Jul 10 19:43:59 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <1215731276.5468.26.camel@homesick> References: <1215723442.5468.18.camel@homesick> <62728db30807101532k6c5adb20hd1e8344f8a2cdd98@mail.gmail.com> <1215731276.5468.26.camel@homesick> Message-ID: <20080710235244.GB11600@liouville.galois.com> andre: > On Thu, 2008-07-10 at 18:32 -0400, Ronald Guida wrote: > > Your ratios are about 1 : 3 : 8. > > That pretty close to quadratic growth, 1 : 4 : 9, so I think all is well. > > Maybe, but 96MB of resident memory for a 1000-node graph looks bad, > especially considering p is low. Is the internal representation of > inductive graphs perhaps not very memory-efficient? I still haven't read > Erwig's paper... > > I know this is probably not fair, but I'm comparing these numbers with a > C implementation which uses Ruby's C API for its complex data > structures, and a 10,000 nodes graph uses around 6MB of memory. Well, they're radically different graph representations, and fgl hasn't been designed for large graphs. What C library is Ruby's binding to? It might be quite cheap to bind to that. I've been on the look out for a good C graph lib to use for Haskell bindings for a while.. -- Don From andre at digirati.com.br Thu Jul 10 20:15:39 2008 From: andre at digirati.com.br (Andre Nathan) Date: Thu Jul 10 20:03:16 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <20080710235244.GB11600@liouville.galois.com> References: <1215723442.5468.18.camel@homesick> <62728db30807101532k6c5adb20hd1e8344f8a2cdd98@mail.gmail.com> <1215731276.5468.26.camel@homesick> <20080710235244.GB11600@liouville.galois.com> Message-ID: <1215735339.5468.39.camel@homesick> On Thu, 2008-07-10 at 16:52 -0700, Don Stewart wrote: > Well, they're radically different graph representations, and fgl > hasn't been designed for large graphs. Do you know if King and Launchbury's implementation (Data.Graph) scales better? > What C library is Ruby's binding to? It might be quite cheap to bind > to that. I've been on the look out for a good C graph lib to use for > Haskell bindings for a while.. None. I've built my own representing the graph as a hash table with nodes as keys and arrays of nodes as values, and I'm using ruby's hash and array classes (which are written in C) for that. Did you have a look at igraph [http://cneurocvs.rmki.kfki.hu/igraph/]? It would probably be a lot of work to bind to it (it has many public functions), but it looks nice and has bindings for a few languages. Andre From thomas.dubuisson at gmail.com Thu Jul 10 23:16:39 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Thu Jul 10 23:07:20 2008 Subject: GHCi Debugger (was Re: [Haskell-cafe] Architecturally flawed) In-Reply-To: <48765669.8090708@btinternet.com> References: <48765669.8090708@btinternet.com> Message-ID: <1215746199.6249.25.camel@tom-laptop> > I could try GHC's new debugger. But my experiences with it so far have > shown that for all but the most trivial programs possible, it becomes > intractably difficult to figure out what the debugger is actually > showing you. GDB is to C as (a) GHCi debugger :: Haskell (b) Pigs :: Farmers (c) Food :: TomMD (d) None of the above Hint: Its not (a). The GHCi debugger seems to catch extra flack because people want to pour through their Haskell code as they do imperative code. I can sympathize - I would like to do that too - but it would be an inaccurate picture of the programs execution. so long as you regard the GHCi as a new/useful tool and not try to pretend its like other debuggers you'll probably be happier. I've found ghcid to be useful when quickcheck + HPC + ChasingBottoms fails to narrow down the problem any further. Its gotten to the point where I often know exactly which LOC/module will be the next step (based on knowledge of the data dependencies). A fair share of bugs have fallen to the sword named vim as a result :-). It really is useful, but like all other haskellisms, one must learn to ride a bike all over again. At times I think of ghcid as the anti-gdb. If there's a series of let bindings, each mutating the predecessor, its enjoyable to see the debugger start at the bottom and crawl its way back up. Tom From ronwalf at volus.net Thu Jul 10 23:20:56 2008 From: ronwalf at volus.net (Ron Alford) Date: Thu Jul 10 23:11:44 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> Message-ID: Ok, I'm closer, but I'm running into a problem with typeOf and lists, of all things: *WouterTest> typeOf (eVar "v" :: TermExpr) Planning.Wouter.Expr (Planning.Wouter.:+: WouterTest.Const WouterTest.Var) *WouterTest> typeOf ([eVar "v"] :: [TermExpr]) *** Exception: Prelude.undefined I'm pretty sure this is the culprit for getName: *WouterTest> getName testNamed "*** Exception: Prelude.undefined Any hints? Also, anyone have hints for how to get automatic derivation of Data (Expr f) ? I don't want to proliferate the last lines: deriving instance Data (Expr (And :+: Atomic (Expr (Const :+: Var)))) deriving instance Data (Expr (Const :+: Var)) -Ron Alford -------------- next part -------------- A non-text attachment was scrubbed... Name: WouterTest.hs Type: application/octet-stream Size: 5358 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080710/68ff7974/WouterTest.obj From dons at galois.com Fri Jul 11 00:38:15 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 11 00:28:56 2008 Subject: [Haskell-cafe] Re: HPC for debugging (Was Re: GHCi Debugger In-Reply-To: <1215746199.6249.25.camel@tom-laptop> References: <48765669.8090708@btinternet.com> <1215746199.6249.25.camel@tom-laptop> Message-ID: <20080711043815.GA18421@liouville.galois.com> thomas.dubuisson: > > I could try GHC's new debugger. But my experiences with it so far have > > shown that for all but the most trivial programs possible, it becomes > > intractably difficult to figure out what the debugger is actually > > showing you. > > At times I think of ghcid as the anti-gdb. If there's a series of let > bindings, each mutating the predecessor, its enjoyable to see the > debugger start at the bottom and crawl its way back up. I'd like to relate a debugging effort this week. A colleague had an exception thrown from deep within a large body of code, we knew not where. A few trace statements didn't yield much information. The debugger was fired up on this >50 module program, and we got a few interesting hints and pieces, but it seemed as if the exception was floating away from its call site, to the point it was being demanded. Hmm. A puzzle. So instead we compiled the application with -fhpc, ran it till the exception occured, and then ran hpc markup on the result. (This marks up the program source in colours showing what code was actually executed during a given program run). Loading the colourised trace into firefox, we saw at a glance all the code that had been executed up to the point of the exception, and then there was the exception itself, staring at us amongst a chunk of bright yellow code, a lone streak of uncoloured code where it shouldn't have been. It took all of 5 seconds to find the bug with HPC. -- Don From lemming at henning-thielemann.de Fri Jul 11 01:44:09 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 11 01:34:49 2008 Subject: [Haskell-cafe] Re: HPC for debugging (Was Re: GHCi Debugger In-Reply-To: <20080711043815.GA18421@liouville.galois.com> References: <48765669.8090708@btinternet.com> <1215746199.6249.25.camel@tom-laptop> <20080711043815.GA18421@liouville.galois.com> Message-ID: On Thu, 10 Jul 2008, Don Stewart wrote: > thomas.dubuisson: >>> I could try GHC's new debugger. But my experiences with it so far have >>> shown that for all but the most trivial programs possible, it becomes >>> intractably difficult to figure out what the debugger is actually >>> showing you. >> >> At times I think of ghcid as the anti-gdb. If there's a series of let >> bindings, each mutating the predecessor, its enjoyable to see the >> debugger start at the bottom and crawl its way back up. > > I'd like to relate a debugging effort this week. A colleague had an > exception thrown from deep within a large body of code, we knew not where. Let me relate this to the Extensible Exception thread of the Haskell-Library list. Your exception - was it an 'error' or an IO exception? If it would be an exception (like "file not found") and we would use ErrorT monad for exceptions with specific types for the exceptions, then it would be clearer where the exception can come from. However if it was an error, then we cannot handle it terminally by some exception-catching like mechanism. From aslatter at gmail.com Fri Jul 11 01:56:06 2008 From: aslatter at gmail.com (Antoine Latter) Date: Fri Jul 11 01:46:45 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> Message-ID: <694519c50807102256j9fa19b7n85cb15376b5eba3a@mail.gmail.com> 2008/7/10 Ron Alford : > Ok, I'm closer, but I'm running into a problem with typeOf and lists, > of all things: > *WouterTest> typeOf (eVar "v" :: TermExpr) > Planning.Wouter.Expr (Planning.Wouter.:+: WouterTest.Const WouterTest.Var) > *WouterTest> typeOf ([eVar "v"] :: [TermExpr]) > *** Exception: Prelude.undefined > > I'm pretty sure this is the culprit for getName: > *WouterTest> getName testNamed > "*** Exception: Prelude.undefined > > Any hints? > > Also, anyone have hints for how to get automatic derivation of Data (Expr f) ? > I don't want to proliferate the last lines: > deriving instance Data (Expr (And :+: Atomic (Expr (Const :+: Var)))) > deriving instance Data (Expr (Const :+: Var)) > > I screwed up the example code - it typechecks, but it'll fail at runtime. If you say: > Inr x = undefined and then try to pass 'x' off to another function, you're trying to evaluate the "undeifned", which is a runtime error. You'll want something more like: typeOf1 in@(InR f) = [...] where InL f = (InL undefined) `asTypeOf` in This is approaching silliness, but I've tested the code this time around - so it should even work. -Antoine From satnams at microsoft.com Fri Jul 11 03:14:57 2008 From: satnams at microsoft.com (Satnam Singh) Date: Fri Jul 11 03:05:42 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell Message-ID: Hello Marc. I've been distracted with the Kiwi project (parallel C# programs to hardware) and right now a Bluespec project so I've not made any progress on a merge of the Lava I produced for designing circuits (with layout) for Xilinx's FPGAs and the Chalmers version (which I recommend for situations where you don't care about circuit layout or when you don't want to use FPGA architecture specific features). The version of Lava on my website at http://raintown.org/lava/ still builds under the current version of ghc and it provides support for generating Xilinx EDIF netlists that supports the basic FPGA circuit building blocks. If you need things like ODDRs etc. which appear in the new FPGAs then you have to either add them yourself (not too difficult) or wait for me to do it :) Cheers, Satnam ________________________________ Satnam Singh Microsoft 7 JJ Thomson Avenue Cambridge CB3 0FB United Kingdom Email: satnams@microsoft.com UK tel: +44 1223 479905 Fax: +44 1223 479 999 UK mobile: +44 7979 648412 USA cell: 206 330 1580 USA tel: 206 219 9024 URL: http://research.microsoft.com/~satnams Live Messenger: satnam@raintown.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080711/6567a7d2/attachment.htm From alistair at abayley.org Fri Jul 11 06:12:56 2008 From: alistair at abayley.org (Alistair Bayley) Date: Fri Jul 11 06:03:38 2008 Subject: [Haskell-cafe] ANN: Takusen 0.8.3 Message-ID: <79d7c4980807110312h5e159834he6f9b7dd9890189@mail.gmail.com> Changes since 0.8.1 (I put 0.8.2 up on hackage with an error in Setup.hs, so it's been skipped): - ODBC support: datetime marshalling is improved. For bind parameters this uses the timestamp struct for most back-ends, but String for MS SQL Server because populating the timestamp struct always failed. - more Cabal improvements: now uses configurations, so the Setup.hs script should be both simpler and more robust. Requires Cabal >= 1.4. Oracle backend on Linux should build nicely. - bug fix for a resource leak if an exception was thrown when initiating a query (the Statement handle was not closed). - some basic result-set validation against the iteratee: if you try to fetch a column that is not in the result-set, an error is thrown (rather than garbage returned). The release bundle: http://hackage.haskell.org/packages/archive/Takusen/0.8.3/Takusen-0.8.3.tar.gz The latest code: darcs get http://darcs.haskell.org/takusen Docs: http://darcs.haskell.org/takusen/doc/html/index.html A comprehensive description of API usage can be found in the documentation for module Database.Enumerator (look for the Usage section): http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html Future plans: - Output bind-parameters and multiple-result sets for ODBC - FreeTDS backend (Sybase and MS Sql Server) - support for Blobs and Clobs For those of you unfamiliar with Takusen, here is our HCAR blurb: Takusen is a DBMS access library. Like HSQL and HDBC, we support arbitrary SQL statements (currently strings, extensible to anything that can be converted to a string). Takusen's 'unique-selling-point' is safety and efficiency. We statically ensure all acquired database resources - such as cursors, connection and statement handles - are released, exactly once, at predictable times. Takusen can avoid loading the whole result set in memory, and so can handle queries returning millions of rows in constant space. Takusen also supports automatic marshalling and unmarshalling of results and query parameters. These benefits come from the design of query result processing around a left-fold enumerator. Currently we fully support ODBC, Oracle, Sqlite, and PostgreSQL. From ronwalf at volus.net Fri Jul 11 08:07:32 2008 From: ronwalf at volus.net (Ron Alford) Date: Fri Jul 11 07:58:10 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: <694519c50807102256j9fa19b7n85cb15376b5eba3a@mail.gmail.com> References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> <694519c50807102256j9fa19b7n85cb15376b5eba3a@mail.gmail.com> Message-ID: What's odd is that it works directly (typeOf ... (Expr (f :+: g)) returns a type), but if you enclose the expression in a list, it fails with Prelude.undefined. Do I also need a custom instance for Typeable [Expr ...] ? (See previous message for code) -Ron On Fri, Jul 11, 2008 at 1:56 AM, Antoine Latter wrote: > 2008/7/10 Ron Alford : >> Ok, I'm closer, but I'm running into a problem with typeOf and lists, >> of all things: >> *WouterTest> typeOf (eVar "v" :: TermExpr) >> Planning.Wouter.Expr (Planning.Wouter.:+: WouterTest.Const WouterTest.Var) >> *WouterTest> typeOf ([eVar "v"] :: [TermExpr]) >> *** Exception: Prelude.undefined >> >> I'm pretty sure this is the culprit for getName: >> *WouterTest> getName testNamed >> "*** Exception: Prelude.undefined >> >> Any hints? >> >> Also, anyone have hints for how to get automatic derivation of Data (Expr f) ? >> I don't want to proliferate the last lines: >> deriving instance Data (Expr (And :+: Atomic (Expr (Const :+: Var)))) >> deriving instance Data (Expr (Const :+: Var)) >> >> > > > I screwed up the example code - it typechecks, but it'll fail at runtime. > > If you say: > >> Inr x = undefined > > and then try to pass 'x' off to another function, you're trying to > evaluate the "undeifned", which is a runtime error. > > You'll want something more like: > > typeOf1 in@(InR f) = [...] > where InL f = (InL undefined) `asTypeOf` in > > This is approaching silliness, but I've tested the code this time > around - so it should even work. > > -Antoine > From gsan at stillpsycho.net Fri Jul 11 08:26:45 2008 From: gsan at stillpsycho.net (=?utf-8?q?G=C3=B6khan_San?=) Date: Fri Jul 11 08:17:28 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <1215735339.5468.39.camel@homesick> References: <1215723442.5468.18.camel@homesick> <20080710235244.GB11600@liouville.galois.com> <1215735339.5468.39.camel@homesick> Message-ID: <200807111426.45735.gsan@stillpsycho.net> On Friday July 11 2008, Andre Nathan wrote: > On Thu, 2008-07-10 at 16:52 -0700, Don Stewart wrote: > > Well, they're radically different graph representations, and fgl > > hasn't been designed for large graphs. > > Do you know if King and Launchbury's implementation (Data.Graph) scales > better? Looks like it. I now did a rough benchmark on fully connected graphs with 25 and 50 nodes. Data.Graph.Inductive used 28MB and 365MB respectively (x13 increase) compared to Data.Graph's 486KB and 2MB (x4). And Data.Graph seems to be much faster (basic operations up to 200 times), although it might be related to GC. -- Gokhan From dokondr at gmail.com Fri Jul 11 08:39:05 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Fri Jul 11 08:29:44 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> Message-ID: <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> I don't quite understand how Data.Array.Diff work. I tried this: > let arr = listArray (1,3) [1..3] :: DiffArray Int Int then: > replaceDiffArray arr [(1, 777)] array (1,3) [(1,1),(2,777),(3,3)] Why when replacing first element the second one changes? and also trying to add 4-th element results in: Prelude Data.Array.Diff> replaceDiffArray arr [(4, 444)] array (1,3) [(1,1),(2,2),(3,3)] It looks like replaceDiffArray can not be used to add new element to the end of array? Thanks, Dima On Thu, Jul 10, 2008 at 10:59 PM, Jefferson Heard < jefferson.r.heard@gmail.com> wrote: > Two questions. How often does the array change, and how big does it > get? It may well be that you just copy it and take the hit, as > that'll be cheaper (even in C, incidentally) than any other solution, > if it's a short array or if the updates happen rarely. > > If not, try using Data.Array.Diff and replaceDiffArray. This is > usually fairly efficient for most applications. > > By the way, depending on the type of the data you're putting into > these arrays, Data.ByteString might be a good choice as well. > > On Thu, Jul 10, 2008 at 12:12 PM, Felipe Lessa > wrote: > > 2008/7/10 Dmitri O.Kondratiev : > >> allows construct an array of a fixed size. How to add more elements to > the > >> array later? > > > > I can't really answer your question, however I bet that it would > > require allocating another, bigger array and copying the old elements > > over, at least from time to time. So you may want to take a look at > > Data.Sequence[1], supporting O(1) append on both sides and (sort of) > > O(log i) for accessing the i-th element. > > > > [1] > http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html > > > > HTH, > > > > -- > > Felipe. > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > I try to take things like a crow; war and chaos don't always ruin a > picnic, they just mean you have to be careful what you swallow. > > -- Jessica Edwards > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080711/02ad47c7/attachment.htm From ramsdell0 at gmail.com Fri Jul 11 08:39:28 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Fri Jul 11 08:30:06 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <20080708123155.GA634@netsoc.tcd.ie> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> <20080708123155.GA634@netsoc.tcd.ie> Message-ID: <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> > Are you aware of "Term Rewriting and all That"? It describes how to do > associative commutative unification; whether it satisfies your > 'obviously correct' criterion I don't know. Oh yes, I know about term rewriting. If your equations can be expressed as a set of confluent rewrite rules, one can use the Martelli and Montanari's formalization of unification to come up with an obviously correct equational unifier. Alas, that simple trick doesn't work for AC unification. Have you heard of Maude? I hear the next version will have support for AC unification. If I stay with Haskell, I'd have to use their support via interprocess communication. Yuck. http://maude.cs.uiuc.edu/ John From voigt at tcs.inf.tu-dresden.de Fri Jul 11 08:51:05 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Fri Jul 11 08:34:55 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> <20080708123155.GA634@netsoc.tcd.ie> <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> Message-ID: <48775739.7060601@tcs.inf.tu-dresden.de> John D. Ramsdell wrote: >>Are you aware of "Term Rewriting and all That"? It describes how to do >>associative commutative unification; whether it satisfies your >>'obviously correct' criterion I don't know. > > > Oh yes, I know about term rewriting. I think Edsko was more specifically referring to the book "Term Rewriting and all That" by Baader and Nipkow. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From chaddai.fouche at gmail.com Fri Jul 11 08:58:00 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Fri Jul 11 08:48:38 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> Message-ID: 2008/7/11 Dmitri O.Kondratiev : > I don't quite understand how Data.Array.Diff work. > I tried this: > >> let arr = listArray (1,3) [1..3] :: DiffArray Int Int > > then: >> replaceDiffArray arr [(1, 777)] > array (1,3) [(1,1),(2,777),(3,3)] > Why when replacing first element the second one changes? replaceDiffArray is low-level, nobody should use it, use the normal IArray interface instead. (To answer your question, replaceDiffArray works with low level index, not the Ix class, all array are indexed by 0, 1, .. for it, so 1 is the index of the second element of the array) > and also trying to add 4-th element results in: > Prelude Data.Array.Diff> replaceDiffArray arr [(4, 444)] > array (1,3) [(1,1),(2,2),(3,3)] > > It looks like replaceDiffArray can not be used to add new element to the end > of array? No, the size of a DiffArray can't be changed : DiffArray are just an IArray instance with better performances for update than the classic IArray instance (which copy the entire content on every update...). There are some libraries that allows you to change the size of your array, be aware though that this operation is very costly (in every language). http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ArrayRef -- Jeda? From grzegorz.chrupala at computing.dcu.ie Fri Jul 11 09:19:45 2008 From: grzegorz.chrupala at computing.dcu.ie (Grzegorz Chrupala) Date: Fri Jul 11 09:10:23 2008 Subject: [Haskell-cafe] More idiomatic use of strictness In-Reply-To: <20080710180351.GB26811@liouville.galois.com> References: <18379800.post@talk.nabble.com> <1215709617.6571.7.camel@jcchost> <20080710180351.GB26811@liouville.galois.com> Message-ID: <18403657.post@talk.nabble.com> Don Stewart-2 wrote: > > I'd use a strict pair and the rnf strategy. > > data P = P [Something] !Int > > rnf dfs' (P dfs' (n+1) > Thanks all, it definitely seems like an improvement. -- Grzegorz -- View this message in context: http://www.nabble.com/More-idiomatic-use-of-strictness-tp18379800p18403657.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Fri Jul 11 09:27:31 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jul 11 09:15:57 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> Message-ID: <36080391.20080711172731@gmail.com> Hello Chaddai, Friday, July 11, 2008, 4:58:00 PM, you wrote: > There are some libraries that allows you to change the size of your > array, be aware though that this operation is very costly (in every > language). > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ArrayRef or http://haskell.org/haskellwiki/Library/ArrayRef for reference -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dokondr at gmail.com Fri Jul 11 10:18:35 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Fri Jul 11 10:09:14 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> Message-ID: <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> How does Data.Sequence http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html compares with ArrayRef for appending and accessing arrays efficiently ? On Fri, Jul 11, 2008 at 4:58 PM, Chadda? Fouch? wrote: > 2008/7/11 Dmitri O.Kondratiev : > > I don't quite understand how Data.Array.Diff work. > > I tried this: > > > >> let arr = listArray (1,3) [1..3] :: DiffArray Int Int > > > > then: > >> replaceDiffArray arr [(1, 777)] > > array (1,3) [(1,1),(2,777),(3,3)] > > Why when replacing first element the second one changes? > > replaceDiffArray is low-level, nobody should use it, use the normal > IArray interface instead. > (To answer your question, replaceDiffArray works with low level index, > not the Ix class, all array are indexed by 0, 1, .. for it, so 1 is > the index of the second element of the array) > > > and also trying to add 4-th element results in: > > Prelude Data.Array.Diff> replaceDiffArray arr [(4, 444)] > > array (1,3) [(1,1),(2,2),(3,3)] > > > > It looks like replaceDiffArray can not be used to add new element to the > end > > of array? > > No, the size of a DiffArray can't be changed : DiffArray are just an > IArray instance with better performances for update than the classic > IArray instance (which copy the entire content on every update...). > > There are some libraries that allows you to change the size of your > array, be aware though that this operation is very costly (in every > language). > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ArrayRef > > -- > Jeda? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080711/71645bce/attachment.htm From mnislaih at gmail.com Fri Jul 11 10:18:40 2008 From: mnislaih at gmail.com (Pepe Iborra) Date: Fri Jul 11 10:09:21 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> <20080708123155.GA634@netsoc.tcd.ie> <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> Message-ID: <44b20d900807110718j7558a59eu242d3cdab670dd9a@mail.gmail.com> On Fri, Jul 11, 2008 at 2:39 PM, John D. Ramsdell wrote: >> Are you aware of "Term Rewriting and all That"? It describes how to do >> associative commutative unification; whether it satisfies your >> 'obviously correct' criterion I don't know. > > Oh yes, I know about term rewriting. If your equations can be > expressed as a set of confluent rewrite rules, one can use the > Martelli and Montanari's formalization of unification to come up with > an obviously correct equational unifier. Alas, that simple trick > doesn't work for AC unification. > > Have you heard of Maude? I hear the next version will have support > for AC unification. If I stay with Haskell, I'd have to use their > support via interprocess communication. Yuck. > > http://maude.cs.uiuc.edu/ > > John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > You are surely aware that AC unification is much more difficult than syntactical unification. CIMe[1] might be useful to solve the generated diophantine equations. But I don't think you will be able to obtain obvious correctness, and probably performance neither. I don't know what you are planning to do, but perhaps you'd be better served by Maude than by Haskell. The Maude language is a joy to use and version 2.4 with AC unification is (expectedly) being released next week in RTA. Cheers pepe [1] - http://cime.lri.fr/ From chaddai.fouche at gmail.com Fri Jul 11 11:23:53 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Fri Jul 11 11:14:33 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> Message-ID: 2008/7/11 Dmitri O.Kondratiev : > How does Data.Sequence > http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html > compares with ArrayRef for appending and accessing arrays efficiently ? It doesn't since Data.Sequence doesn't use arrays, it uses a custom data structure that allows to do plenty of operations with pretty good asymptotic complexity. Be aware though that the constants aren't that good and that depending on your usage, lists, array or another specialized data structure could be much more efficient. By comparisons, extending an array is very likely to be much more expensive from time to time than adding some elements to your Data.Sequence. On the other hand the random access would be much faster in an array and even the amortized cost of extending the array may not be much worse than the amortized cost on the Data.Sequence in some cases. What exactly are you trying to do ? -- Jeda? From dokondr at gmail.com Fri Jul 11 12:07:50 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Fri Jul 11 11:58:28 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> Message-ID: <53396d9e0807110907p2e6169e3g6d451cba86ec73eb@mail.gmail.com> I need extendable array to store and count unique vectors. I have a file containing vectors presented as strings like: 10, 6, 80, 25, 6, 7 1, 2, 15, 17, 33, 22 21, 34, 56, 78, 91, 2 ... (BTW, what is the best library function to use to convert string of digits into a list or array?) There are two arrays: 1) Array of unique vectors. The first vector red from file starts this array. Next vectors are added to this array if they are sufficiently dissimilar from the already existing in the array. Similarity is computed as euclidean distance between two vectors. 2) Array of counts. Length of this array is equal to the length of array with unique vectors. Thus every vector has a corresponding count. If new vector is similar to some vector already existing in the first array then corresponding count is incremented. For example, array of unique vectors: [[10, 6, 80, 25, 6, 7], [1, 2, 15, 17, 33, 22], [21, 34, 56, 78, 91, 2]] may have a corresponding counts array: [5,1,3] where: 5 tells that my file has 5 vectors similar to vector [10, 6, 80, 25, 6, 7], Only 1 vector [1, 2, 15, 17, 33, 22], and 3 vectors similar to [21, 34, 56, 78, 91, 2] As long as I don't know a priory how many unique vectors my file has, as well as how many similar to these unique others exists - I need to start both arrays with size 0. Next when I find a similar vector I need to increment count at corresponding index in 'counts' array. I will also need to access vectors at different index in unique array later. That's why I need a collection both indexed and able to extend also. I think that Data.Sequence will do for the task, don't you think? On Fri, Jul 11, 2008 at 7:23 PM, Chadda? Fouch? wrote: > 2008/7/11 Dmitri O.Kondratiev : > > How does Data.Sequence > > > http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html > > compares with ArrayRef for appending and accessing arrays efficiently ? > > It doesn't since Data.Sequence doesn't use arrays, it uses a custom > data structure that allows to do plenty of operations with pretty good > asymptotic complexity. Be aware though that the constants aren't that > good and that depending on your usage, lists, array or another > specialized data structure could be much more efficient. > > By comparisons, extending an array is very likely to be much more > expensive from time to time than adding some elements to your > Data.Sequence. On the other hand the random access would be much > faster in an array and even the amortized cost of extending the array > may not be much worse than the amortized cost on the Data.Sequence in > some cases. > > What exactly are you trying to do ? > > -- > Jeda? > -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080711/918986db/attachment.htm From ronwalf at volus.net Fri Jul 11 12:41:57 2008 From: ronwalf at volus.net (Ron Alford) Date: Fri Jul 11 12:32:37 2008 Subject: [Haskell-cafe] Typeable and fancy types Message-ID: Hey all, I've reduced my previous problem to a small example. Anyone know why typeOf (...) would work, but typeOf [...] would not? Is the derivation for lists funky? data Expr f = In (f (Expr f)) instance Typeable1 f => Typeable (Expr f) where typeOf (In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x] data Foo e = Foo deriving instance Typeable1 Foo *TypeTest> typeOf (In Foo) TypeTest.Expr TypeTest.Foo *TypeTest> typeOf [In Foo] *** Exception: Prelude.undefined -------------- next part -------------- A non-text attachment was scrubbed... Name: TypeTest.hs Type: application/octet-stream Size: 398 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080711/bc60e228/TypeTest.obj From aslatter at gmail.com Fri Jul 11 12:50:51 2008 From: aslatter at gmail.com (Antoine Latter) Date: Fri Jul 11 12:41:38 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> <694519c50807102256j9fa19b7n85cb15376b5eba3a@mail.gmail.com> Message-ID: <694519c50807110950n6eec6466k11e5cfd151015139@mail.gmail.com> On Fri, Jul 11, 2008 at 7:07 AM, Ron Alford wrote: > What's odd is that it works directly (typeOf ... (Expr (f :+: g)) > returns a type), but if you enclose the expression in a list, it fails > with Prelude.undefined. Do I also need a custom instance for > Typeable [Expr ...] ? (See previous message for code) > The problem is that the List instance is playing the same dirty tricks with it's 'typeOf' implementation as we are: it's asking us the type of one of the list elements by passing in "undefined" to our "typeOf1" implementation. And then your "typeOf1" implementation tries to do pattern matching on undefined. Here is what will work: instance (Typeable1 f, Typeable1 g) => Typeable1 (f :+: g) where typeOf1 x = mkTyConApp (mkTyCon "Planning.Wouter.:+:") [typeOf1 left, typeOf1 right] where (Inr right) = Inr undefined `asTypeOf` x (Inl left) = Inl undefined `asTypeOf` x Now we never do pattern matching on our input. This has been pretty educational. -Antoine From ronwalf at volus.net Fri Jul 11 12:55:44 2008 From: ronwalf at volus.net (Ron Alford) Date: Fri Jul 11 12:46:22 2008 Subject: [Haskell-cafe] Re: Combining Wouter's expressions with extensible records In-Reply-To: <694519c50807110950n6eec6466k11e5cfd151015139@mail.gmail.com> References: <694519c50807101316x4cb4d84s78c59834e0ea5080@mail.gmail.com> <694519c50807102256j9fa19b7n85cb15376b5eba3a@mail.gmail.com> <694519c50807110950n6eec6466k11e5cfd151015139@mail.gmail.com> Message-ID: On Fri, Jul 11, 2008 at 12:50 PM, Antoine Latter wrote: > > Now we never do pattern matching on our input. > > This has been pretty educational. > Mightily! I'll have to do the same trick for Expr. Thank you very much! -Ron From zunino at di.unipi.it Fri Jul 11 13:13:35 2008 From: zunino at di.unipi.it (Roberto Zunino) Date: Fri Jul 11 13:02:13 2008 Subject: [Haskell-cafe] Typeable and fancy types In-Reply-To: References: Message-ID: <487794BF.6070903@di.unipi.it> Ron Alford wrote: > instance Typeable1 f => Typeable (Expr f) where > typeOf (In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x] typeOf ~(In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x] Lazy patterns are jolly useful here. Remember that typeOf will be usually called on _|_, so it must not inspect its argument. Also, dummy functions such as getC :: Foo a b c d -> c getC _ = undefined can be exploited in typeOf x = ... typeOf (getC x) ... Zun. From dons at galois.com Fri Jul 11 13:38:05 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 11 13:28:57 2008 Subject: [Haskell-cafe] Re: ANN: Takusen 0.8.3 In-Reply-To: <79d7c4980807110312h5e159834he6f9b7dd9890189@mail.gmail.com> References: <79d7c4980807110312h5e159834he6f9b7dd9890189@mail.gmail.com> Message-ID: <20080711173805.GA10341@scytale.galois.com> Wonderful. Builds out of the box for me. Available in Arch Linux: http://aur.archlinux.org/packages.php?ID=18349 alistair: > Changes since 0.8.1 (I put 0.8.2 up on hackage with an error in Setup.hs, > so it's been skipped): From dons at galois.com Fri Jul 11 13:39:54 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 11 13:30:35 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <200807111426.45735.gsan@stillpsycho.net> References: <1215723442.5468.18.camel@homesick> <20080710235244.GB11600@liouville.galois.com> <1215735339.5468.39.camel@homesick> <200807111426.45735.gsan@stillpsycho.net> Message-ID: <20080711173954.GB10341@scytale.galois.com> gsan: > On Friday July 11 2008, Andre Nathan wrote: > > On Thu, 2008-07-10 at 16:52 -0700, Don Stewart wrote: > > > Well, they're radically different graph representations, and fgl > > > hasn't been designed for large graphs. > > > > Do you know if King and Launchbury's implementation (Data.Graph) scales > > better? > > Looks like it. > > I now did a rough benchmark on fully connected graphs with 25 and 50 nodes. > Data.Graph.Inductive used 28MB and 365MB respectively (x13 increase) compared > to Data.Graph's 486KB and 2MB (x4). And Data.Graph seems to be much faster > (basic operations up to 200 times), although it might be related to GC. > Do you have the bencmark code? I'd like to try a couple of variants on the underlying structures. From rwbarton at math.harvard.edu Fri Jul 11 13:44:34 2008 From: rwbarton at math.harvard.edu (Reid Barton) Date: Fri Jul 11 13:35:14 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <53396d9e0807110907p2e6169e3g6d451cba86ec73eb@mail.gmail.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> <53396d9e0807110907p2e6169e3g6d451cba86ec73eb@mail.gmail.com> Message-ID: <20080711174434.GB756@rwbarton.mit.edu> This doesn't require any fancy data structures. On Fri, Jul 11, 2008 at 08:07:50PM +0400, Dmitri O.Kondratiev wrote: > For example, array of unique vectors: > [[10, 6, 80, 25, 6, 7], > [1, 2, 15, 17, 33, 22], > [21, 34, 56, 78, 91, 2]] > > may have a corresponding counts array: > [5,1,3] Instead store this as a list of pairs [([10,6,80,25,6,7], 5), ...] and it'll be easy to write a recursive function that accepts a new vector and either increments the appropriate count or adds the new vector at the end with count 1. > I will also need to access vectors at different index in unique > array later. Then once you've finished constructing the list, turn it into an array with listArray and use random access into that. Regards, Reid Barton From andrewcoppin at btinternet.com Fri Jul 11 14:10:54 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jul 11 14:13:58 2008 Subject: [Haskell-cafe] Re: QuickCheck [Architecturally flawed] In-Reply-To: <48765669.8090708@btinternet.com> References: <48765669.8090708@btinternet.com> Message-ID: <4877A22E.8080309@btinternet.com> Andrew Coppin wrote: > After many hours of effort, I came up with these: > > data Writer x > instance Monad Writer > run_writer :: Writer () -> ByteString > write1 :: Bool -> Writer () > write8 :: Word8 -> Writer () > write16 :: Word16 -> Writer () > write32 :: Word32 -> Writer () > write64 :: Word64 -> Writer () > writeN :: Word8 -> Word32 -> Writer () > > data Reader x > instance Monad Reader > run_reader :: Reader x -> ByteString -> x > is_EOF :: Reader Bool > read1 :: Reader Bool > read8 :: Reader Word8 > read16 :: Reader Word16 > read32 :: Reader Word32 > read64 :: Reader Word64 > readN :: Word8 -> Reader Word32 How would you write QuickCheck properties for these? For starters, what would be a good set of properties to confirm that any monad is actually working correctly? More particularly, how about a state monad? It's easy to screw up the implementation and pass the wrong state around. How would you catch that? Secondly, the monads themselves. I started writing things like "if X has the lowest bit set then the lowest bit of the final byte of the output should be set"... but then all I'm really doing is reimplementing the algorithm as a property rather than a monad! If a property fails, is the program wrong or is the property wrong? In the end, what I opted to do was define various properties where I take some arbitrary data, write it with the Writer monad, then read it back with the Reader monad and confirm that the data stays identical. (This actually fails for writeN, which writes the N least-significant bits of the supplied data, so you need to apply some masking before doing equity. Or, equivilently, reject some test values...) Looking at the QuickCheck paper, it seems I should probably have done some checking that the size of the output is correct. I didn't actually bother because it's really easy to get right, whereas strickiness with bit-shifts and indexing is all too easy to screw up. What I finally did was try writing/reading with each primitive (to check that actually works properly), and then again with a random number of individual bits packed on each side to give random alignment (to check that the index adjustments actually work right). It's easy to make the code work correctly with a certain alignment, but fail spectacularly otherwise. It's packed at *both* ends because it's also quite easy to make it write out the correct bit pattern, but leave the bit pointer with the wrong value, causing subsequent writes to screw up. How would you approach this one? All hints welcomed. From andrewcoppin at btinternet.com Fri Jul 11 14:23:05 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jul 11 14:14:01 2008 Subject: [Haskell-cafe] Re: Improvements [Architecturally flawed] In-Reply-To: <48765669.8090708@btinternet.com> References: <48765669.8090708@btinternet.com> Message-ID: <4877A509.4050207@btinternet.com> Andrew Coppin wrote: > data Writer x > instance Monad Writer > run_writer :: Writer () -> ByteString > write1 :: Bool -> Writer () > write8 :: Word8 -> Writer () > write16 :: Word16 -> Writer () > write32 :: Word32 -> Writer () > write64 :: Word64 -> Writer () > writeN :: Word8 -> Word32 -> Writer () > > data Reader x > instance Monad Reader > run_reader :: Reader x -> ByteString -> x > is_EOF :: Reader Bool > read1 :: Reader Bool > read8 :: Reader Word8 > read16 :: Reader Word16 > read32 :: Reader Word32 > read64 :: Reader Word64 > readN :: Word8 -> Reader Word32 > > Next I decided to write an LZW compressor. Here's what I came up with: > > data EncodeLZW symbol > eLZW_start :: (Ord symbol) => EncodeLZW symbol > eLZW_encode :: (Ord symbol) => EncodeLZW symbol -> symbol -> Writer > (EncodeLZW symbol) > eLZW_end :: (Ord symbol) => EncodeLZW symbol -> Writer () > > data DecodeLZW symbol > dLZW_start :: DecodeLZW symbol > dLZW_decode :: DecodeLZW symbol -> Reader (DecodeLZW symbol, symbol) Suddenly it seems very obvious to me... I built a monad to allow writing bits to a ByteString, so why not make another monad for writing symbols to an LZW-compressed ByteString? So... run a monad on top of another monad. Can that be done? Notionally it should be possible. I mean, thinking about it, what's the difference between a Writer and an EncodeLZW? One writes bits using some internal state, the other writes symbols using a more complex algorithm and internal state. Heck, if I augment Writer slightly so that the user can carry along some arbitrary state of their own, then I can just do something like newtype EncodeLZW symbol x = Wrap (Writer (StateLZW symbol) x) deriving Monad Now I automatically have Wrap :: Writer (StateLZW symbol) x -> EncodeLZW symbol x as my magical lifting operator. Now the caller can't use any Writer functions (because they all have the wrong type) and can only use the LZW writing functions I provide. I can even write a class - something like class Encoder e s where encode :: symbol -> e symbol () run_encoder :: e symbol () -> Writer s () where the "run_encoder" thing is actually just a typecast. (I'm doing is this way so you could possibly run another, different, encoder feeding to the same sink. If I returned an actual ByteString you'd be prevented from doing that.) So far, this only appears to require GeneralizedNewtypeDeriving and MultiParamTypeClasses, so we should be golden... ...unless somebody else has a better idea? From westondan at imageworks.com Fri Jul 11 15:32:29 2008 From: westondan at imageworks.com (Dan Weston) Date: Fri Jul 11 15:23:13 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <53396d9e0807110907p2e6169e3g6d451cba86ec73eb@mail.gmail.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> <53396d9e0807110907p2e6169e3g6d451cba86ec73eb@mail.gmail.com> Message-ID: <4877B54D.2080200@imageworks.com> Dmitri O.Kondratiev wrote: > I need extendable array to store and count unique vectors. I have a file > containing vectors presented as strings like: > 10, 6, 80, 25, 6, 7 > 1, 2, 15, 17, 33, 22 > 21, 34, 56, 78, 91, 2 > ... > (BTW, what is the best library function to use to convert string of > digits into a list or array?) If you don't need to do error checking on the input syntax, the easiest (and arguably fastest) method is just read: Prelude> let x = "10, 6, 80, 25, 6, 7" Prelude> read ("[" ++ x ++ "]") :: [Int] [10,6,80,25,6,7] For error checking, you can use reads. From gsan at stillpsycho.net Fri Jul 11 16:30:45 2008 From: gsan at stillpsycho.net (=?utf-8?q?G=C3=B6khan_San?=) Date: Fri Jul 11 16:21:27 2008 Subject: [Haskell-cafe] Inductive graphs memory usage In-Reply-To: <20080711173954.GB10341@scytale.galois.com> References: <1215723442.5468.18.camel@homesick> <200807111426.45735.gsan@stillpsycho.net> <20080711173954.GB10341@scytale.galois.com> Message-ID: <200807112230.45785.gsan@stillpsycho.net> On Friday July 11 2008, Don Stewart wrote: > Do you have the bencmark code? I'd like to try a couple of variants on > the underlying structures. It's not a thorough test but I suppose it gives an impression about performance. -- Gokhan -------------- next part -------------- $ ghc -O -prof --make TestGraph $ ./TestGraph +RTS -s -P -RTS TestGraph.stat with (testIG 50): 20,881,408 bytes maximum residency (62 sample(s)) %GC time 55.2% (56.0% elapsed) TestGraph.stat with (testG 50): 90,112 bytes maximum residency (1 sample(s)) %GC time 14.3% (21.2% elapsed) > module Main (main) where > import qualified Data.Graph as G > import qualified Data.Graph.Inductive as IG > import Data.Tree > import Data.Maybe > main :: IO () > main = do testIG 50 > -- testG 50 > testIG nn = do let gi = createIG nn > print $ length $ IG.edges gi > print $ igTestDFS gi > print $ igTestDFS' gi 1 > print $ igTestAdd gi > createIG :: Int -> IG.Gr String () > createIG nn = IG.mkGraph lnodes ledges > where nodes = [1 .. nn] > lnodes = zip nodes $ map show nodes > ledges = [(n1, n2, ()) | n1 <- nodes, n2 <- nodes] > igTestDFS g = length $ IG.dfs [1] g > igTestDFS' g sn = length sstr > where ns = IG.dfs [sn] g > sstr = concatMap (fromJust . (IG.lab g)) ns > igTestAdd g = igTestDFS' g'' (nn + 1) > where nn = IG.noNodes g > newNodes = [nn + 1 .. nn + nn] > lnodes = zip newNodes $ map show newNodes > ledges = [(n1, n2, ()) | n1 <- newNodes, n2 <- newNodes] > g' = IG.insNodes lnodes g > g'' = IG.insEdges ledges g' > type GG = (G.Graph, G.Vertex -> (String, Int, [Int]), Int -> Maybe G.Vertex) > testG nn = do let g = createG nn > print $ length $ G.edges $ fst3 g > print $ gTestDFS g > print $ gTestDFS' g 1 > print $ gTestAdd g > createG :: Int -> GG > createG nn = G.graphFromEdges edges > where edges = [(show k, k, [1 .. nn]) | k <- [1 .. nn]] > gTestDFS (g, fromVertex, toVertex) = length vs > where vs = flatten $ head $ G.dfs g [(fromJust $ toVertex 1)] > gTestDFS' (g, fromVertex, toVertex) sk = length sstr > where vs = flatten $ head $ G.dfs g [(fromJust $ toVertex sk)] > sstr = concatMap (fst3 . fromVertex) vs A little bit unfair but still performs well: > gTestAdd (g, fromVertex, _) = gTestDFS' gg (nn + 1) > where vertices = G.vertices g > nn = length vertices > edges = map fromVertex vertices > newks = [nn + 1 .. nn + nn] > edges' = [(show k, k, newks) | k <- newks] > -- edges' = map (\ (n, k, ks) -> (n, k + ki, map (ki +) ks)) edges > gg = G.graphFromEdges (edges ++ edges') > fst3 (x, _, _) = x > snd3 (_, y, _) = y From rodrigo.bonifacio at uol.com.br Fri Jul 11 17:23:07 2008 From: rodrigo.bonifacio at uol.com.br (rodrigo.bonifacio) Date: Fri Jul 11 17:13:46 2008 Subject: [Haskell-cafe] Getting module functions Message-ID: Hi all, Is there any function that can be used for retrieving the exposed functions of a given module? Thanks, Rodrigo. From dokondr at gmail.com Fri Jul 11 17:26:42 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Fri Jul 11 17:17:20 2008 Subject: [Haskell-cafe] Newbie: Appending arrays? In-Reply-To: <4877B54D.2080200@imageworks.com> References: <53396d9e0807100905p69b75ba9tf978444ca3808adf@mail.gmail.com> <4165d3a70807101159l44d9602cr1e4ae67e40ddd4b0@mail.gmail.com> <53396d9e0807110539m28edb705r2fb4920ab28455aa@mail.gmail.com> <53396d9e0807110718w61a3dfb8tc73e9757b83db3c7@mail.gmail.com> <53396d9e0807110907p2e6169e3g6d451cba86ec73eb@mail.gmail.com> <4877B54D.2080200@imageworks.com> Message-ID: <53396d9e0807111426q2dc825e9k7352711acd6ec279@mail.gmail.com> Thanks for your help, guys! I like simple solutions most of all :) On Fri, Jul 11, 2008 at 9:44 PM, Reid Barton wrote: This doesn't require any fancy data structures. Instead store this as a list of pairs [([10,6,80,25,6,7], 5), ...] and it'll be easy to write a recursive function that accepts a new vector and either increments the appropriate count or adds the new vector at the end with count 1. On Fri, Jul 11, 2008 at 11:32 PM, Dan Weston wrote: > If you don't need to do error checking on the input syntax, the easiest > (and arguably fastest) method is just read: > > Prelude> let x = "10, 6, 80, 25, 6, 7" > Prelude> read ("[" ++ x ++ "]") :: [Int] > [10,6,80,25,6,7] > > For error checking, you can use reads. > > -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080712/dd7cc4d9/attachment.htm From ndmitchell at gmail.com Fri Jul 11 17:51:59 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Jul 11 17:42:36 2008 Subject: [Haskell-cafe] Getting module functions In-Reply-To: References: Message-ID: <404396ef0807111451p1a5721b7uc2ca25ae9ca61d91@mail.gmail.com> Hi Rodrigo, > Is there any function that can be used for retrieving the exposed functions of a given module? Not at runtime, but if you are just looking for documentation, there is online documentation here: http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html Thanks Neil From dons at galois.com Fri Jul 11 18:13:33 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 11 18:04:11 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays Message-ID: <20080711221333.GB14364@scytale.galois.com> Just a quick note about next week's Galois Tech Talk. Now that Galois has completed its move into downtown Portland, and a shiny new, centrally located, office space, we're opening up our tech talk series a bit more widely. If you're in Portland, and interested in functional programming and formal methods, drop by! ------------------------------------------------------------------------ Title: Stream Fusion for Haskell Arrays Speaker: Don Stewart Date: Tuesday, July 15th, 10.30am sharp. Location: Galois, Inc. 421 SW 6th Ave. Suite 300 (3rd floor of the Commonwealth Building) Portland, Oregon Abstract: Arrays have traditionally been an awkward data structure for Haskell programmers. Despite the large number of array libraries available, they have remained relatively awkward to use in comparison to the rich suite of purely functional data structures, such as fingertrees or finite maps. Arrays have simply not been first class citizens in the language. In this talk we'll begin with a survey of the more than a dozen array types available, including some new matrix libraries developed in the past year. I'll then describe a new efficient, pure, and flexible array library for Haskell with a list like interface, based on work in the Data Parallel Haskell project, that employs stream fusion to dramatically reduce the cost of pure arrays. The implementation will be presented from the ground up, along with a discussion of the entire compilation process of the library, from source to assembly. About the Galois Tech Talks. Galois (http://galois.com) has been holding weekly technical seminars for several years on topics from functional programming, formal methods, compiler and language design, to cryptography, and operating system construction, with talks by many figures from the programming language and formal methods communities. The talks are open and free. If you?re planning to attend, dropping a note to is appreciated, but not required. If you're interested in giving a talk, Don's always looking for new speakers. ------------------------------------------------------------------------ From johan.tibell at gmail.com Fri Jul 11 18:26:04 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Fri Jul 11 18:16:41 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays In-Reply-To: <20080711221333.GB14364@scytale.galois.com> References: <20080711221333.GB14364@scytale.galois.com> Message-ID: <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> On Sat, Jul 12, 2008 at 12:13 AM, Don Stewart wrote: > > Just a quick note about next week's Galois Tech Talk. Now that Galois > has completed its move into downtown Portland, and a shiny new, centrally > located, office space, we're opening up our tech talk series a bit more > widely. If you're in Portland, and interested in functional programming > and formal methods, drop by! Any possibility of you guys taping the talk? Cheers, Johan From lemming at henning-thielemann.de Fri Jul 11 18:59:08 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 11 18:49:47 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays In-Reply-To: <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> References: <20080711221333.GB14364@scytale.galois.com> <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> Message-ID: On Sat, 12 Jul 2008, Johan Tibell wrote: > On Sat, Jul 12, 2008 at 12:13 AM, Don Stewart wrote: >> >> Just a quick note about next week's Galois Tech Talk. Now that Galois >> has completed its move into downtown Portland, and a shiny new, centrally >> located, office space, we're opening up our tech talk series a bit more >> widely. If you're in Portland, and interested in functional programming >> and formal methods, drop by! > > Any possibility of you guys taping the talk? me too From mmitar at gmail.com Fri Jul 11 19:46:58 2008 From: mmitar at gmail.com (Mitar) Date: Fri Jul 11 19:37:35 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: Message-ID: Hi! This is not all. If I compare performance of those two semantically same functions: castRayScene1 :: Ray -> ViewportDotColor castRayScene1 (Ray vd o d) = ViewportDotColor vd (castRay' noColor 0) where castRay' color@(VoxelColor _ _ _ alpha) depth | depth > depthOfField = color | alpha < 0.001 = castRay' pointColor (depth + distance') | alpha > 0.999 = color | otherwise = castRay' newColor (depth + distance') where (# pointColor, distance #) = worldScene (o <+> (d <* depth)) distance' = max 1 distance newColor = addColor color pointColor and: castRay :: World -> Ray -> ViewportDotColor castRay world (Ray vd o d) = ViewportDotColor vd (castRay' noColor 0) where castRay' color@(VoxelColor _ _ _ alpha) depth | depth > depthOfField = color | alpha < 0.001 = castRay' pointColor (depth + distance') | alpha > 0.999 = color | otherwise = castRay' newColor (depth + distance') where (# pointColor, distance #) = world (o <+> (d <* depth)) distance' = max 1 distance newColor = addColor color pointColor castRayScene2 :: Ray -> ViewportDotColor castRayScene2 = castRay worldScene is the program which uses castRayScene1 1.35 faster then the program which uses castRayScene2 (37 seconds versus 50 seconds). (Compiler with GHC 6.8.3 and -O2 switch. Program is executing almost just this function over and over again.) It is somehow award that passing function as an argument slow down the program so much. Is not Haskell a functional language and this such (functional) code reuse is one of its main points? Of course. I could use some preprocessor/template engine to change/find/replace castRay-like function into a castRayScene1 before compiling. But this somehow kills the idea of a compiler? Smart compiler. Which should do things for you? The same as my previous example. Where a hard-coded list was not optimized. (Like it would change during the execution.) It looks like my program would be interpreted and not compiled. Mitar From lrpalmer at gmail.com Fri Jul 11 19:59:41 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Jul 11 19:50:17 2008 Subject: [Haskell-cafe] Typeable and fancy types In-Reply-To: <487794BF.6070903@di.unipi.it> References: <487794BF.6070903@di.unipi.it> Message-ID: <7ca3f0160807111659pb1bac20x8c395d74e6a3770b@mail.gmail.com> On Fri, Jul 11, 2008 at 5:13 PM, Roberto Zunino wrote: > Ron Alford wrote: >> >> instance Typeable1 f => Typeable (Expr f) where >> typeOf (In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x] > > typeOf ~(In x) = mkTyConApp (mkTyCon "TypeTest.Expr") [typeOf1 x] Yes, that works, but what would also work is this: newtype Expr f = In (f (Expr f)) Keeping the typeOf code the same as the original. I would consider this more correct, since this is a type trick, not a value trick. The data definition makes your model have an extra bottom, which can't be very attractive! Luke From allbery at ece.cmu.edu Fri Jul 11 20:24:00 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jul 11 20:14:39 2008 Subject: [Haskell-cafe] Getting module functions In-Reply-To: References: Message-ID: On 2008 Jul 11, at 17:23, rodrigo.bonifacio wrote: > Is there any function that can be used for retrieving the exposed > functions of a given module? Not in the usual introspection/RTTI sense; but you could probably use the GHC API to read a .hi file. (At which point I direct you to people clueful about GHC innards, which I'm not.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From allbery at ece.cmu.edu Fri Jul 11 20:39:41 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jul 11 20:30:20 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: Message-ID: On 2008 Jul 11, at 19:46, Mitar wrote: > It is somehow award that passing function as an argument slow down the > program so much. Is not Haskell a functional language and this such > (functional) code reuse is one of its main points? That is in fact the case; GHC's version of various Prelude functions refactors them to avoid passing functional arguments. IIRC the problem is that, while Haskell is indeed functional, passing a polymorphic function as an argument causes the runtime to have to look up which type is needed for every call, whereas if it's factored out it can be computed only once and (implicitly) let-bound. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From batterseapower at hotmail.com Fri Jul 11 21:33:00 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Fri Jul 11 21:23:36 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: Message-ID: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> > It is somehow award that passing function as an argument slow down the > program so much. Is not Haskell a functional language and this such > (functional) code reuse is one of its main points? I can think of a few reasons why function passing is slow: * There is an overhead to closure creation (I don't know how big this is in practice, but it can be significant) * GHC has little information about what function-typed variables mean, because the function they are bound to is not known until runtime. This precludes the use of inlining, rewrite rules etc, which are absolutely key factors in making Haskell fast Regarding your first example: currently GHC does not do loop unrolling. It probably should though because loop unrolling reduces braches and increases the amount of information about the execution path that is available statically (as in e.g. the case liberation transformation), which probably explains the increased performance you saw by doing it manually in your first email. Earlier this year I implemented something somewhat similar though: fusable list literals. In this example from your first email: world :: SpacePoint -> VoxelColor world point = findColor [redSphere (0,50,0) 50, greenSphere (25,-50,0) 50, blueSphere (-150,0,150) 50] where findColor [] = noColor findColor (f:fs) = case f point of Just v -> v Nothing -> findColor fs If findColor had been a function defined in terms of foldr rather than using explicit recursion, then theres a good chance GHC 6.9 would have fused it with the list to yield your optimized, loop unrolled, version: world :: SpacePoint -> VoxelColor world point = case redSphere (0,50,0) 50 point of Just v -> v Nothing -> case greenSphere (25,-50,0) 50 point of Just v -> v Nothing -> case blueSphere (-150,0,150) 50 point of Just v -> v Nothing -> noColor Incidentally, if in your most recent email castRayScene2 was your only used of castRay, GHC would have inlined the whole definition into that use site and you would have got castRayScene1 back again. So, GHC does try its best to make higher order functions fast :-). But it's quite tricky! All the best, Max From ramsdell0 at gmail.com Fri Jul 11 21:48:03 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Fri Jul 11 21:38:40 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <48775739.7060601@tcs.inf.tu-dresden.de> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> <20080708123155.GA634@netsoc.tcd.ie> <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> <48775739.7060601@tcs.inf.tu-dresden.de> Message-ID: <7687290b0807111848o7179d287sdd82543ada2bc08d@mail.gmail.com> > I think Edsko was more specifically referring to the book "Term > Rewriting and all That" by Baader and Nipkow. Thanks for pointing this out--I was confused. I notice the book has a chapter on equational unification that includes a section on AC unification. This book looks like a winner. Thank you. John From ramsdell0 at gmail.com Fri Jul 11 22:02:26 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Fri Jul 11 21:53:08 2008 Subject: [Haskell-cafe] Associative Commutative Unification In-Reply-To: <44b20d900807110718j7558a59eu242d3cdab670dd9a@mail.gmail.com> References: <7687290b0807061933w6196b9a2hd1f393ecaa8e461e@mail.gmail.com> <20080707023856.GB10461@liouville.galois.com> <7687290b0807080524p11e35860h833463b93be648c8@mail.gmail.com> <20080708123155.GA634@netsoc.tcd.ie> <7687290b0807110539j59234e8br8252d53af8f8749f@mail.gmail.com> <44b20d900807110718j7558a59eu242d3cdab670dd9a@mail.gmail.com> Message-ID: <7687290b0807111902x362c48fehfce32376dc606dd3@mail.gmail.com> > CIMe[1] might be useful to solve the generated diophantine equations. It also has AC unification, and it probably wouldn't be all that hard to translate our code into OCaml. I think CiME isn't supported anymore. Still it's worth considering. It's quite large. The source distribution compiled effortlessly on Ubuntu. That's about all I know now. > I don't know what you are planning to do, but perhaps you'd be better > served by Maude than by Haskell. Switching to Maude is an option we're considering. John From jtod at dcs.gla.ac.uk Sat Jul 12 10:53:14 2008 From: jtod at dcs.gla.ac.uk (John O'Donnell) Date: Sat Jul 12 10:43:52 2008 Subject: [Haskell-cafe] FPGA / Lava and haskell In-Reply-To: <6a7c66fc0807081926u4efaa13bha5080686e40a63e2@mail.gmail.com> References: <20080709004338.GA16229@gmx.de> <6a7c66fc0807081926u4efaa13bha5080686e40a63e2@mail.gmail.com> Message-ID: Hello, Here are some more references relevant to ForSyDe, which looks very interesting! The following paper describes the first version of Hydra, a functional hardware description language which has gone through many versions, using several different functional languages. Hydra uses streams for modelling synchronous circuits, and the paper contains references to the first work on streams for hardware description, by Steve Johnson. Note that the syntax in this paper isn't Haskell; after all, Hydra was initially implemented in 1982, and Haskell didn't exist then! www.dcs.gla.ac.uk/~jtod/publications/1987-HDRE/ The mid 80s version of Hydra had multiple semantics, including both behaviour and netlist generation, and it used observable sharing to implement the netlists. That's described in the following paper, which also shows how Hydra can (optionally) use combinators to express layout and wiring. The geometric combinators are based on Mary Sheeran's Ruby language, although the actual combinators in Hydra are a bit different. The main difference between Hydra and Ruby is that Hydra is functional, it's based on streams, and the geometric combinators are optional: you can just use connect the streams together if all you want is a simulation and netlist but not a layout. www.dcs.gla.ac.uk/~jtod/publications/1988-HydraCombinators The netlists are represented as a data structure, and can be converted to a particular netlist notation with a suitable "show" function. The paper doesn't use the term "observable sharing" -- that name for the technique was introduced in Lava -- but the technique was already implemented and published in 1988. Lava is essentially a clone of Hydra the way it was from around 1985 to about 1992. However, there are a number of drawbacks to using observable sharing for generating netlists, and some of these are discussed in the following paper, which also proposes an alternative approach based on program transformation. www.dcs.gla.ac.uk/~jtod/publications/1992-Netlist The program transformation approach to netlist generation has been implemented using Template Haskell to perform the transformations automatically, as described in the next paper. Currently, Hydra uses this, and it avoids observable sharing. www.dcs.gla.ac.uk/~jtod/publications/2004-EmbedHDLinTH/ Here are a few more papers that give an overview of Hydra with some examples,: www.dcs.gla.ac.uk/~jtod/publications/1995-Hydra-FPLE/ www.dcs.gla.ac.uk/~jtod/publications/2002-Hydra-PDSECA/ www.dcs.gla.ac.uk/~jtod/publications/2004-DeriveFastAdder/ John O'Donnell -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Alfonso Acosta Sent: 09 July 2008 03:27 To: Marc Weber; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] FPGA / Lava and haskell We'll soon (before september, hopefully) relase a deep-embedded version of ForSyDe[1] which, among other things, has a VHDL backend (with specific support for Altera's Modelsim and Quartus). ForSyDe's new implementation is internally based upon the same concept as Lava (Observable Sharing). However, it has quite a few differences: * ForSyDe is behavioural (computations are expressed in plain haskell) * It has support for components * Is not barely targeted at synchrounous hardware systems (although the VHDL backend is obviously aimed at them). It has suport for other MoCs (Models of Computation). [1] http://www.imit.kth.se/info/FOFU/ForSyDe/ On Tue, Jul 8, 2008 at 7:43 PM, Marc Weber wrote: > Is Haskell still used (in industry as well ?) to write (V)HDL code to > program FPGAs and create circuits on chips? > The Chalmers Lava homepage tells abouta Xilinx version which should be > merged in soon. But on the xilinx homepage there was no reference to > neither Lava nor haskell.. > I'm thinking about designing a similar tool to www.combimouse.com. > > Sincerly > Marc > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From rl at cse.unsw.edu.au Sat Jul 12 11:01:05 2008 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Sat Jul 12 10:51:44 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) Message-ID: <4878C731.9020004@cse.unsw.edu.au> Hi all, the vector library will eventually provide fast, Int-indexed arrays with a powerful fusion framework. It's very immature at the moment (I haven't tested most of the code) and implements just a few combinators but I thought releasing early wouldn't hurt. Use at your own risk and expect things to break horribly! What it provides: * Boxed and unboxed arrays with a generic interface and a very basic set of combinators. * A powerful loop fusion framework. It is based on stream fusion but already goes beyond that (in particular, it can do some things in-place) and will be significantly extended in the future. * Extensibility. * Rudimentary documentation. * Bugs. The code is based on the DPH libraries but is much more generic and a *lot* simpler. This has only been made possible by the tremendous progress in GHC's simplifier in the recent months/years (thanks Simon!). Consequently, you'll need a recent development version of GHC to build this, 6.8 won't work. It might be able to compile the library but you'll get terrible code, much worse than with lists. If you want to try it out, compile with -O2 -fno-spec-constr-count and please don't forget to let me know about things that didn't work (or, miraculously, did). Grab it from http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector or darcs get http://darcs.haskell.org/vector Again, special thanks to Simon for doing such a wonderful job with the optimiser. Enjoy, Roman From bulat.ziganshin at gmail.com Sat Jul 12 11:16:27 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 12 11:07:11 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <4878C731.9020004@cse.unsw.edu.au> References: <4878C731.9020004@cse.unsw.edu.au> Message-ID: <708474936.20080712191627@gmail.com> Hello Roman, Saturday, July 12, 2008, 7:01:05 PM, you wrote: > the vector library will eventually provide fast, Int-indexed arrays with > a powerful fusion framework. GREAT! doom4 would be written in Haskell! -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From sebastian.sylvan at gmail.com Sat Jul 12 12:20:15 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sat Jul 12 12:10:49 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <4878C731.9020004@cse.unsw.edu.au> References: <4878C731.9020004@cse.unsw.edu.au> Message-ID: <3d96ac180807120920h78001df8rf50e7ca2f2cc3b33@mail.gmail.com> On 7/12/08, Roman Leshchinskiy wrote: > > Hi all, > > the vector library will eventually provide fast, Int-indexed arrays with a > powerful fusion framework. It's very immature at the moment (I haven't > tested most of the code) and implements just a few combinators but I > thought releasing early wouldn't hurt. Use at your own risk and expect > things to break horribly! > > What it provides: > > * Boxed and unboxed arrays with a generic interface and a very basic > set of combinators. > > * A powerful loop fusion framework. It is based on stream fusion but > already goes beyond that (in particular, it can do some things > in-place) and will be significantly extended in the future. > (moving to cafe) Is there any more (easily-digested, like a paper) information available about this? Specifically what things can happen in-place, and future extensions... -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080712/d3d10008/attachment.htm From batterseapower at hotmail.com Sat Jul 12 12:44:52 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sat Jul 12 12:35:28 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC Message-ID: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> I had some free time this afternoon so I put together an (experimental) patch for GHC that implements helpful errors messages. Have a look at this GHCi session to see what I mean: "" $ stage2/ghc-inplace --interactive -fhelpful-errors GHCi, version 6.9.20080711: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> let foo = 10 Prelude> foa :1:0: Not in scope: `foa' Maybe you meant one of: `foo' `fst' `not' -- Maybe the matching threshold could stand to be tweaked a bit, e.g. scaled with identifier string length.. Prelude> let myIdentifier = 10 Prelude> myIdentfiier :1:0: Not in scope: `myIdentfiier' Maybe you meant `myIdentifier' Prelude> "" The feature was inspired by the equivalent feature in the Boo programming language (http://boo.codehaus.org/). I use the restricted Damerau?Levenshtein distance to do the fuzzy match (http://en.wikipedia.org/wiki/Damerau-Levenshtein_distance). What do you think about this feature? Would it be genuinely helpful or annoying? Max From batterseapower at hotmail.com Sat Jul 12 13:05:36 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sat Jul 12 12:56:15 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <20080712165055.GA6646@craft> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <20080712165055.GA6646@craft> Message-ID: <9d4d38820807121005w1a3e2d7cg325cd52ae354b312@mail.gmail.com> > Personally, I would suggest make it take up less space. A newline for each match may be alright if there are only 3 suggestions, but past that it begins to take up too much of the screen. Columns are nice, or perhaps a limit on how many matches will be displayed (with more available if the user asks?). I've actually limited it to 3 matches displayed in the current implementation, but indeed it would probably be good to display the matches in columns instead. Max From qdunkan at gmail.com Sat Jul 12 13:11:56 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Sat Jul 12 13:02:30 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> Message-ID: <2518b95d0807121011n2870ad4co93e3d564bcfba68d@mail.gmail.com> > What do you think about this feature? Would it be genuinely helpful or annoying? It could be handy if it understands qualified names. Occasionally typos e.g. just now Confg.default_x are surprisingly hard to see and I go around making sure Config is imported, making sure it exports default_x, etc. before finally figuring it out. From rl at cse.unsw.edu.au Sat Jul 12 13:17:22 2008 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Sat Jul 12 13:08:03 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <3d96ac180807120920h78001df8rf50e7ca2f2cc3b33@mail.gmail.com> References: <4878C731.9020004@cse.unsw.edu.au> <3d96ac180807120920h78001df8rf50e7ca2f2cc3b33@mail.gmail.com> Message-ID: <4878E722.1020701@cse.unsw.edu.au> Sebastian Sylvan wrote: > > Is there any more (easily-digested, like a paper) information available > about this? Specifically what things can happen in-place, and future > extensions... Apart from the stream fusion papers, unfortunately no, it's all very much work in progress. Basically, at the moment it will avoid allocating some unnecessary arrays even if no loop fusion happens. So for instance, in something like map f (xs // us) the two loops can't be fused ((//) is the same update operation as in Data.Array). Usually, you'd allocate one array for (xs // us) and then another one for the map. This library will do the map in-place if f doesn't change the type of the elements. This is pretty important at least for data-parallel code. I'll have to see how far this scales. In the future, the fusion system will also be able to handle multiple directions of traversals and permutations (it can only do left-to-right traversals at the moment). The "Rewriting Haskell Strings" paper talks a bit about that but DPH has much more complex requirements so I'll have to use a different approach which I haven't implemented so far. Roman From batterseapower at hotmail.com Sat Jul 12 14:15:26 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sat Jul 12 14:06:06 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <2518b95d0807121011n2870ad4co93e3d564bcfba68d@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <2518b95d0807121011n2870ad4co93e3d564bcfba68d@mail.gmail.com> Message-ID: <9d4d38820807121115k48df94ecycb87b98f1442a1c3@mail.gmail.com> 2008/7/12 Evan Laforge : >> What do you think about this feature? Would it be genuinely helpful or annoying? > > It could be handy if it understands qualified names. Occasionally > typos e.g. just now Confg.default_x are surprisingly hard to see and I > go around making sure Config is imported, making sure it exports > default_x, etc. before finally figuring it out. Good point. It turns out that actually since my implementation doesn't include module names in the match at all, this works without writing more code on my part. But perhaps I should make it module-aware as I think that will allow more accurate matching. I've also changed the output format and tweaked the match threshold algorithm, with this result: "" mbolingbroke@Equinox ~/Programming/Checkouts/ghc.working/compiler $ stage2/ghc-inplace --interactive -fhelpful-errors GHCi, version 6.9.20080711: http://www.haskell.org/ghc/ :? for help Prelude> let foo = 10 Prelude> foa :1:0: Not in scope: `foa' Maybe you meant `foo' Prelude> fts :1:0: Not in scope: `fts' Maybe you meant `fst' Prelude> let foa = 20 Prelude> fof :1:0: Not in scope: `fof' Maybe you meant `foo' or `foa' Prelude> import Data.Lost Could not find module `Data.Lost': -- Maybe it should do something better here.. Use -v to see a list of the files searched for. Prelude> :q $ stage2/ghc-inplace --make Test.hs [1 of 1] Compiling Main ( Test.hs, Test.o ) Test.hs:5:14: Not in scope: `Chbr.isSpoce' Maybe you meant `Char.isSpace' """ Max From niklas.broberg at gmail.com Sat Jul 12 14:37:03 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Jul 12 14:27:36 2008 Subject: [Haskell-cafe] Template Haskell and haskell-src-exts In-Reply-To: References: Message-ID: > Can one represent the ''Type template Haskell syntax of > > $( makeMergeable ''FileDescriptorProto ) > > in haskell-src.exts Language.Haskell.Exts.Syntax ? > > And what are the HsReify data (e.g. HsReifyType and HsReifyDecl and > HsReifyFixity )? > > I don't see any pretty print capability to produce the ''Type so I am > wondering what else I might use... Hi Chris, like Jeremy said the support for TH in haskell-src-exts is legacy from GHC pre-6.4 (iirc) and needs updating. So don't look too closely at the things that are in there right now. It shouldn't be hard to fix to work with 6.8, I just need to find the time to sit down and do it. I'll try to get it fixed this week. Cheers, /Niklas From lrpalmer at gmail.com Sat Jul 12 14:40:07 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Jul 12 14:30:42 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> Message-ID: <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> On Sat, Jul 12, 2008 at 10:44 AM, Max Bolingbroke wrote: > I had some free time this afternoon so I put together an > (experimental) patch for GHC that implements helpful errors messages. > Have a look at this GHCi session to see what I mean: > > "" > $ stage2/ghc-inplace --interactive -fhelpful-errors > GHCi, version 6.9.20080711: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> let foo = 10 > Prelude> foa > > :1:0: > Not in scope: `foa' > Maybe you meant one of: > `foo' > `fst' > `not' -- Maybe the matching threshold could stand to be tweaked That's pretty cool. Unfortunately in my early Haskell days the 'not in scope' errors were the only ones I _did_ understand. It would be nice to human-friendlify the other types of errors. I'm not judging your work though, this is helpful, and the other types of errors are of course much harder to friendlify. On the topic of things that aren't stupid complaints by me, a typo is the most likely cause for not in scope errors. As Evan points out, I think it would be more helpful to search for matching names in imported modules to see if the name was accidentally not qualified or exported. I don't know about this fuzzy matching business, since when I go to the line of the error message, I'm going to see my typo and what I meant. I don't think I'd ever use the suggestions... Luke From mmitar at gmail.com Sat Jul 12 14:57:09 2008 From: mmitar at gmail.com (Mitar) Date: Sat Jul 12 14:47:43 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> Message-ID: Hi! (I will reply propely later, I have a project to finish and GHC is playing me around and does not want to cooperate.) This project of mine is getting really interesting. Is like playing table tennis with GHC. Some time it gives a nice ball, sometimes I have to run around after it. But I just wanted to make a simple raycasting engine. Not debug GHC. But it is interesting - just I do not have time just know for playing the change code - compile - run on known input - check if time elapsed increased (I have to do this even when I am thinking that I am optimizing things or even when I am thinking that I am just refactoring code - moving constants to definitions...). And this is a slow process because every iteration runs for a few minutes. The next beautiful example in this series is this function for computing 4D Julia set fractal: julia4DFractal :: BasicReal -> World julia4DFractal param (x,y,z) = julia4D (Q (x / scale) (y / scale) (z / scale) param) iterations where c = (Q (-0.08) 0.0 (-0.8) (-0.03)) alphaBlue = VoxelColor 0 0 (2 / scale) (2 / scale) scale = fromIntegral sceneHeight / 1.8 threshold = 16 iterations = 100 :: Int julia4D _ 0 = (# alphaBlue, 1 #) -- point is (probably) not in the set julia4D q it | qMagnitudeSquared q > threshold = (# noColor, 1 #) -- point is in the set | otherwise = julia4D (qSquared q + c) (it - 1) where distance = scale * (qMagnitude qN) / (2 * (qMagnitude qN')) * log (qMagnitude qN) (# qN, qN' #) = disIter q (Q 1 0 0 0) iterations where disIter qn qn' 0 = (# qn, qn' #) disIter qn qn' i | qMagnitudeSquared qn > threshold = (# qn, qn' #) | otherwise = disIter (qSquared qn + c) (2 * qn * qn') (i - 1) Please observe that distance is never used. And this is also what GHC warns. But the trick is that with having this part of a code in there, the program virtually never finishes (I killed it after 15 minutes). If I remove everything on and after the "where distance" line it finishes in 30 seconds. OK, the problem is with (# qN, qN' #), if this is changed to normal (qN, qN'), then it works. But to notice this ... This is something you have to spend a day for. Mitar From lrpalmer at gmail.com Sat Jul 12 15:39:49 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Jul 12 15:30:24 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> Message-ID: <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> On Sat, Jul 12, 2008 at 8:57 PM, Mitar wrote: > julia4DFractal :: BasicReal -> World > julia4DFractal param (x,y,z) = julia4D (Q (x / scale) (y / scale) (z / > scale) param) iterations > where c = (Q (-0.08) 0.0 (-0.8) (-0.03)) > alphaBlue = VoxelColor 0 0 (2 / scale) (2 / scale) > scale = fromIntegral sceneHeight / 1.8 > threshold = 16 > iterations = 100 :: Int > julia4D _ 0 = (# alphaBlue, > 1 #) -- point is (probably) not in the set > julia4D q it | qMagnitudeSquared q > threshold = (# noColor, 1 > #) -- point is in the set > | otherwise = julia4D > (qSquared q + c) (it - 1) > where distance = scale * (qMagnitude qN) / (2 * > (qMagnitude qN')) * log (qMagnitude qN) > (# qN, qN' #) = disIter q (Q 1 0 0 0) iterations > where disIter qn qn' 0 > = (# qn, qn' #) > disIter qn qn' i | qMagnitudeSquared qn > > threshold = (# qn, qn' #) > | otherwise > = disIter (qSquared qn + c) (2 * qn * qn') (i - 1) > > Please observe that distance is never used. And this is also what GHC > warns. But the trick is that with having this part of a code in there, > the program virtually never finishes (I killed it after 15 minutes). > If I remove everything on and after the "where distance" line it > finishes in 30 seconds. OK, the problem is with (# qN, qN' #), if this > is changed to normal (qN, qN'), then it works. But to notice this ... > This is something you have to spend a day for. My guess is that it was premature optimization that created this bug. Unboxed tuples are not the best answer for every situation. They are evaluated strictly! Which means: unboxedBottom x | False = (# 0, 0 #) | otherwise = unboxedBottom x let (# x, y #) = unboxedBottom 0 in 42 Is an infinite loop, not 42 as you would expect. So when you write: where (# ... #) = something You are requiring your program to evaluate 'something' regardless of whether it is needed. Unboxed tuples should be taken in the same vain as explicit strictness annotations: almost never use them, and let GHC do the work for you. If you are in that phase where you are doing performance tweaks and you think GHC's strictness analysis might not be picking up on some strict behavior in your program, add the annotation. If it makes it faster, great; if it doesn't change things, take it out! Best to underconstrain your program. But these days I try to make my programs fast by making the structure of my program apparent to the compiler, not by forcing it to do things in a certain way. Admittedly making the structure of a program apparent to the compiler is a rather subtle and brittle process. I'm sure people have at least brainstormed ways to help the compiler more. Luke From mmitar at gmail.com Sat Jul 12 16:49:20 2008 From: mmitar at gmail.com (Mitar) Date: Sat Jul 12 16:40:00 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> Message-ID: Hi! > My guess is that it was premature optimization that created this bug. It is the root of all evil. ;-) > Unboxed tuples are not the best answer for every situation. They are > evaluated strictly! Then I have not understood the last paragraph correctly: http://www.haskell.org/ghc/docs/latest/html/users_guide/primitives.html Oh, no. It is like you say. I also use -funbox-strict-fields and Q is defined with strict fields. But I tried also without the switch and is it the same (it takes forever). But then qN and qN' does not have unboxed types. So it should be lazy? > If you are in that phase where you are doing performance tweaks and > you think GHC's strictness analysis might not be picking up on some > strict behavior in your program, add the annotation. If it makes it > faster, great; if it doesn't change things, take it out! Best to > underconstrain your program. I completely agree. I am also a firm believer in the clean and pure code where I would leave all optimization to compiler and just write semantics into a program. But this project just showed me that there is still a long way of compiler development before that would be possible (and usable). That some simple refactoring of code which is not really changing semantics have a big influence on a performance because compiler uses it differently (polymorphic types instead of hardcoded types, passing function as an parameter instead of hardcode it). For example I have now defined my types as: type BasicReal = Double data Quaternion = Q !BasicReal !BasicReal !BasicReal !BasicReal deriving (Eq,Show) So that I can easily change the type everywhere. But it would be much nicer to write: data Quaternion a = Q !a !a !a !a deriving (Eq,Show) Only the performance of Num instance functions of Quaternion is then quite worse. Mitar From dons at galois.com Sat Jul 12 17:25:22 2008 From: dons at galois.com (Don Stewart) Date: Sat Jul 12 17:16:03 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <708474936.20080712191627@gmail.com> References: <4878C731.9020004@cse.unsw.edu.au> <708474936.20080712191627@gmail.com> Message-ID: <20080712212522.GA17008@scytale.galois.com> bulat.ziganshin: > Hello Roman, > > Saturday, July 12, 2008, 7:01:05 PM, you wrote: > > > the vector library will eventually provide fast, Int-indexed arrays with > > a powerful fusion framework. > > GREAT! doom4 would be written in Haskell! Did you know about Cheplyaka's Summer of Code project to build a physics engine using fusible arrays? http://physics-dph.blogspot.com/ :) -- Don From dons at galois.com Sat Jul 12 18:16:50 2008 From: dons at galois.com (Don Stewart) Date: Sat Jul 12 18:07:26 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays In-Reply-To: <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> References: <20080711221333.GB14364@scytale.galois.com> <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> Message-ID: <20080712221650.GC17008@scytale.galois.com> johan.tibell: > On Sat, Jul 12, 2008 at 12:13 AM, Don Stewart wrote: > > > > Just a quick note about next week's Galois Tech Talk. Now that Galois > > has completed its move into downtown Portland, and a shiny new, centrally > > located, office space, we're opening up our tech talk series a bit more > > widely. If you're in Portland, and interested in functional programming > > and formal methods, drop by! > > Any possibility of you guys taping the talk? Unlikely next week, but soon, yes! -- Don From batterseapower at hotmail.com Sat Jul 12 19:11:11 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sat Jul 12 19:01:44 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> Message-ID: <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> > That's pretty cool. Unfortunately in my early Haskell days the 'not > in scope' errors were the only ones I _did_ understand. Heh :-) > It would be > nice to human-friendlify the other types of errors. I'm not judging > your work though, this is helpful, and the other types of errors are > of course much harder to friendlify. Yep, this would only be one small step forward in error message quality. > On the topic of things that aren't stupid complaints by me, a typo is > the most likely cause for not in scope errors. As Evan points out, I > think it would be more helpful to search for matching names in > imported modules to see if the name was accidentally not qualified or > exported. Agreed: I've implemented this too. I've also added fuzzy matching to package search: """ $ stage2/ghc-inplace --make ../Test1.hs ../Test1.hs:3:7: Could not find module `Data.Lost': Use -v to see a list of the files searched for. Maybe you meant `Data.List' $ stage2/ghc-inplace --make ../Test2.hs [1 of 1] Compiling Main ( ../Test2.hs, ../Test2.o ) ../Test2.hs:7:14: Not in scope: `isSpace' Maybe you meant `Char.isSpace' """ > I don't know about this fuzzy matching business, since when > I go to the line of the error message, I'm going to see my typo and > what I meant. I don't think I'd ever use the suggestions... I can think of a few times it would have helped me out, with identifiers that may or may not be pluralized or have suprising capitalisation. I don't know though, I guess you'd have to work with the feature turned on for a while to work out if it really was useful. I think this feature has shaped up pretty nicely after the helpful suggestions I recieved. I don't know if I'll be able to get the patch into GHC proper, though.. Max From ryani.spam at gmail.com Sat Jul 12 20:29:54 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Jul 12 20:20:29 2008 Subject: [Haskell-cafe] Re: QuickCheck [Architecturally flawed] In-Reply-To: <4877A22E.8080309@btinternet.com> References: <48765669.8090708@btinternet.com> <4877A22E.8080309@btinternet.com> Message-ID: <2f9b2d30807121729t3f2531dfh668c210ca31f1866@mail.gmail.com> I think you can use the duality of Writer/Reader to help you here; you have the law that, for suitable "dual" computations r and w, run_reader r (run_writer (w x)) == x Then you can build up a list of rules specifying which computations are dual; read64 is dual to write64, for example. You can then have some laws like: if r1 is dual to w1, and r2 is dual to w2, then r1 >>= \x -> r2 >>= \y -> (x,y) is dual to \(x,y) -> w1 x >> w2 y if r1 is dual to w1, and r2 is dual to w2, then read1 >>= \b -> case b of True -> liftM Left r1 ; False -> liftM Right r2 is dual to \x -> case x of Left l -> w1 l; Right r -> w2 r You can then use these to build up more complicated reader/writer duals and verify that the main "identity" law holds. It's a little bit tricky; QuickCheck is not good at dealing with polymorphic data, but you could generalize this to a simple term ADT: data SimpleTerm = Leaf Word8 Word32 | Pair SimpleTerm SimpleTerm | Switch (Either SimpleTerm SimpleTerm) deriving Eq and make a suitable "arbitrary" instance for SimpleTerm to test your reader/writer. Leaf would test readN/writeN, or you can make custom leaves to test the other operations. -- ryan On Fri, Jul 11, 2008 at 11:10 AM, Andrew Coppin wrote: > Andrew Coppin wrote: >> >> After many hours of effort, I came up with these: >> >> data Writer x >> instance Monad Writer >> run_writer :: Writer () -> ByteString >> write1 :: Bool -> Writer () >> write8 :: Word8 -> Writer () >> write16 :: Word16 -> Writer () >> write32 :: Word32 -> Writer () >> write64 :: Word64 -> Writer () >> writeN :: Word8 -> Word32 -> Writer () >> >> data Reader x >> instance Monad Reader >> run_reader :: Reader x -> ByteString -> x >> is_EOF :: Reader Bool >> read1 :: Reader Bool >> read8 :: Reader Word8 >> read16 :: Reader Word16 >> read32 :: Reader Word32 >> read64 :: Reader Word64 >> readN :: Word8 -> Reader Word32 > > How would you write QuickCheck properties for these? > > For starters, what would be a good set of properties to confirm that any > monad is actually working correctly? More particularly, how about a state > monad? It's easy to screw up the implementation and pass the wrong state > around. How would you catch that? > > Secondly, the monads themselves. I started writing things like "if X has the > lowest bit set then the lowest bit of the final byte of the output should be > set"... but then all I'm really doing is reimplementing the algorithm as a > property rather than a monad! If a property fails, is the program wrong or > is the property wrong? > > In the end, what I opted to do was define various properties where I take > some arbitrary data, write it with the Writer monad, then read it back with > the Reader monad and confirm that the data stays identical. (This actually > fails for writeN, which writes the N least-significant bits of the supplied > data, so you need to apply some masking before doing equity. Or, > equivilently, reject some test values...) > > Looking at the QuickCheck paper, it seems I should probably have done some > checking that the size of the output is correct. I didn't actually bother > because it's really easy to get right, whereas strickiness with bit-shifts > and indexing is all too easy to screw up. > > What I finally did was try writing/reading with each primitive (to check > that actually works properly), and then again with a random number of > individual bits packed on each side to give random alignment (to check that > the index adjustments actually work right). It's easy to make the code work > correctly with a certain alignment, but fail spectacularly otherwise. It's > packed at *both* ends because it's also quite easy to make it write out the > correct bit pattern, but leave the bit pointer with the wrong value, causing > subsequent writes to screw up. > > How would you approach this one? All hints welcomed. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wren at freegeek.org Sat Jul 12 23:45:47 2008 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 12 23:36:24 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> Message-ID: <48797A6B.7080803@freegeek.org> Max Bolingbroke wrote: > Agreed: I've implemented this too. I've also added fuzzy matching to > package search: > > """ > $ stage2/ghc-inplace --make ../Test1.hs > > ../Test1.hs:3:7: > Could not find module `Data.Lost': > Use -v to see a list of the files searched for. > Maybe you meant `Data.List' > > $ stage2/ghc-inplace --make ../Test2.hs > [1 of 1] Compiling Main ( ../Test2.hs, ../Test2.o ) > > ../Test2.hs:7:14: > Not in scope: `isSpace' > Maybe you meant `Char.isSpace' > """ In terms of making error messages more helpful, I don't find general typos are much of an issue, but this part would be really nice! I've always been annoyed that GHC just says "no" rather than offering suggestions (-v is rarely helpful), especially since it knows about what modules are installed et al. Granted it's still an easy class of bugs to fix, but this is a much friendlier way of fixing them. -- Live well, ~wren From johan.tibell at gmail.com Sun Jul 13 04:41:40 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Jul 13 04:32:14 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays In-Reply-To: <20080712221650.GC17008@scytale.galois.com> References: <20080711221333.GB14364@scytale.galois.com> <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> <20080712221650.GC17008@scytale.galois.com> Message-ID: <90889fe70807130141y466e422fie1525b4e13500b5e@mail.gmail.com> On Sun, Jul 13, 2008 at 12:16 AM, Don Stewart wrote: > johan.tibell: >> On Sat, Jul 12, 2008 at 12:13 AM, Don Stewart wrote: >> Any possibility of you guys taping the talk? > > Unlikely next week, but soon, yes! How about the slides? From paul at cogito.org.uk Sun Jul 13 04:48:48 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Sun Jul 13 04:39:29 2008 Subject: [Haskell-cafe] Re: QuickCheck [Architecturally flawed] In-Reply-To: <2f9b2d30807121729t3f2531dfh668c210ca31f1866@mail.gmail.com> References: <48765669.8090708@btinternet.com> <4877A22E.8080309@btinternet.com> <2f9b2d30807121729t3f2531dfh668c210ca31f1866@mail.gmail.com> Message-ID: <4879C170.3080900@cogito.org.uk> Ryan Ingram wrote: > I think you can use the duality of Writer/Reader to help you here; you > have the law that, for suitable "dual" computations r and w, > > run_reader r (run_writer (w x)) == x > > Then you can build up a list of rules specifying which computations > are dual; read64 is dual to write64, for example. You can then have > some laws like: > > if r1 is dual to w1, and r2 is dual to w2, > then > r1 >>= \x -> r2 >>= \y -> (x,y) > is dual to > \(x,y) -> w1 x >> w2 y > > if r1 is dual to w1, and r2 is dual to w2, > then > read1 >>= \b -> case b of True -> liftM Left r1 ; False -> liftM Right r2 > is dual to > \x -> case x of Left l -> w1 l; Right r -> w2 r > > You can then use these to build up more complicated reader/writer > duals and verify that the main "identity" law holds. > > It's a little bit tricky; QuickCheck is not good at dealing with > polymorphic data, but you could generalize this to a simple term ADT: > data SimpleTerm = Leaf Word8 Word32 | Pair SimpleTerm SimpleTerm | > Switch (Either SimpleTerm SimpleTerm) deriving Eq > > and make a suitable "arbitrary" instance for SimpleTerm to test your > reader/writer. Leaf would test readN/writeN, or you can make custom > leaves to test the other operations. > > -- ryan > > On Fri, Jul 11, 2008 at 11:10 AM, Andrew Coppin > wrote: > >> For starters, what would be a good set of properties to confirm that any >> monad is actually working correctly? More particularly, how about a state >> monad? It's easy to screw up the implementation and pass the wrong state >> around. How would you catch that? >> See http://www.cs.chalmers.se/~rjmh/Papers/QuickCheckST.ps on QuickCheck tests for monadic properties. The basic idea is to write a Gen action to generate a list of actions in your target monad. >> Secondly, the monads themselves. I started writing things like "if X has the >> lowest bit set then the lowest bit of the final byte of the output should be >> set"... but then all I'm really doing is reimplementing the algorithm as a >> property rather than a monad! If a property fails, is the program wrong or >> is the property wrong This is a fundamental issue with the way that QuickCheck, or any other automatic test generator, works. QuickCheck tests are a formal specification of the properties of your program, so they have the same fundamental complexity as your program. See http://en.wikipedia.org/wiki/Kolmogorov_complexity for more on this. The only exception is when a complicated algorithm produces a simple result, such as sorting or square roots. There are two ways of dealing with this: 1: Write abbreviated properties that only specify part of your program's behaviour, and trust to single-case tests and code inspection for the rest. For instance a test for "reverse" done this way might test that reverse "abcd" = "dcba" and otherwise just check that the input and output strings were the same length. 2: Accept that your tests are going to be as long as the program itself. When a test fails, just figure out which is at fault (you have to do this for any testing method anyway). You still gain reliability because you have implemented the algorithm in two different ways, so hopefully a defect in one will not have a matching defect in the other. I say "hopefully" because the history of N-version programming suggests that such errors are not independent, even when the versions are developed by different teams. From voigt at tcs.inf.tu-dresden.de Sun Jul 13 05:00:49 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Sun Jul 13 04:44:26 2008 Subject: [Haskell-cafe] Prime time for Haskell Message-ID: <4879C441.7000701@tcs.inf.tu-dresden.de> It is really just a short discussion, but Haskell STM is featured in an article of this month's Communications of the ACM: http://doi.acm.org/10.1145/1364782.1364800 -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From jon at ffconsultancy.com Sun Jul 13 05:52:39 2008 From: jon at ffconsultancy.com (Jon Harrop) Date: Sun Jul 13 05:44:22 2008 Subject: [Haskell-cafe] Prime time for Haskell In-Reply-To: <4879C441.7000701@tcs.inf.tu-dresden.de> References: <4879C441.7000701@tcs.inf.tu-dresden.de> Message-ID: <200807131052.39668.jon@ffconsultancy.com> On Sunday 13 July 2008 10:00:49 Janis Voigtlaender wrote: > It is really just a short discussion, but Haskell STM is featured in an > article of this month's Communications of the ACM: > > http://doi.acm.org/10.1145/1364782.1364800 Is the article freely available anywhere? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e From voigt at tcs.inf.tu-dresden.de Sun Jul 13 06:07:04 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Sun Jul 13 05:50:41 2008 Subject: [Haskell-cafe] Prime time for Haskell In-Reply-To: <200807131052.39668.jon@ffconsultancy.com> References: <4879C441.7000701@tcs.inf.tu-dresden.de> <200807131052.39668.jon@ffconsultancy.com> Message-ID: <4879D3C8.1090809@tcs.inf.tu-dresden.de> Jon Harrop wrote: > On Sunday 13 July 2008 10:00:49 Janis Voigtlaender wrote: > >>It is really just a short discussion, but Haskell STM is featured in an >>article of this month's Communications of the ACM: >> >> http://doi.acm.org/10.1145/1364782.1364800 > > > Is the article freely available anywhere? Unfortunately, I cannot tell. I have free access from office, where I currently am. But that could be because the server recognizes my university's IP. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From isaacdupree at charter.net Sun Jul 13 06:11:22 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Sun Jul 13 06:01:48 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <48797A6B.7080803@freegeek.org> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> Message-ID: <4879D4CA.70407@charter.net> wren ng thornton wrote: > Max Bolingbroke wrote: >> Agreed: I've implemented this too. I've also added fuzzy matching to >> package search: >> >> """ >> $ stage2/ghc-inplace --make ../Test1.hs >> >> ../Test1.hs:3:7: >> Could not find module `Data.Lost': >> Use -v to see a list of the files searched for. >> Maybe you meant `Data.List' >> >> $ stage2/ghc-inplace --make ../Test2.hs >> [1 of 1] Compiling Main ( ../Test2.hs, ../Test2.o ) >> >> ../Test2.hs:7:14: >> Not in scope: `isSpace' >> Maybe you meant `Char.isSpace' >> """ > > In terms of making error messages more helpful, I don't find general > typos are much of an issue, but this part would be really nice! I've > always been annoyed that GHC just says "no" rather than offering > suggestions (-v is rarely helpful), especially since it knows about what > modules are installed et al. It sounds like it only searches for modules you've imported (after all they might've been brought into scope with an as-clause, and ghc has no business poking in un-imported modules), but perhaps since in GHCi all modules are in scope (under their original names -- in addition to any imports in an interpreted file), it (ghci) searches all modules then? If I want a "perhaps you meant to import" message, I want it to be a *complete* listing of modules available that export that symbol, both local ones and library ones, ideally :-) (certainly don't want a recommendation to import e.g. List without at least an equal recommendation of Data.List...) -Isaac From batterseapower at hotmail.com Sun Jul 13 07:23:19 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sun Jul 13 07:13:52 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <4879D4CA.70407@charter.net> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> Message-ID: <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> 2008/7/13 Isaac Dupree : > wren ng thornton wrote: >> In terms of making error messages more helpful, I don't find general typos >> are much of an issue, but this part would be really nice! I've always been >> annoyed that GHC just says "no" rather than offering suggestions (-v is >> rarely helpful), especially since it knows about what modules are installed >> et al. > > It sounds like it only searches for modules you've imported (after all they > might've been brought into scope with an as-clause, and ghc has no business > poking in un-imported modules), but perhaps since in GHCi all modules are in > scope (under their original names -- in addition to any imports in an > interpreted file), it (ghci) searches all modules then? You're right: if there is no qualified import of Char then it won't suggest Char.isSpace. The reason for this is that doing so would require GHC to load all the interface files for all exposed modules on disk in order to search exported names, which doesn't sound like a great idea performance-wise. The same thing applies to GHCi. > If I want a "perhaps you meant to import" message, I want it to be a > *complete* listing of modules available that export that symbol, both local > ones and library ones, ideally :-) (certainly don't want a recommendation > to import e.g. List without at least an equal recommendation of > Data.List...) I agree this feature would be cool, I'm just not sure the possible memory/performance problems associated with loading all interfaces of all exposed modules in all packages (it would be most helpful but even more of a performance problem to even scan non-exposed packages) would be worth it. Probably it could be made practical by building a sort of index, which is cached on disk.. Max From claus.reinke at talk21.com Sun Jul 13 08:00:36 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun Jul 13 07:51:20 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com><7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com><9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com><48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> Message-ID: <004701c8e4e0$12a35380$520f7ad5@cr3lt> > I agree this feature would be cool, I'm just not sure the possible > memory/performance problems associated with loading all interfaces of > all exposed modules in all packages (it would be most helpful but even > more of a performance problem to even scan non-exposed packages) would > be worth it. Probably it could be made practical by building a sort of > index, which is cached on disk.. That is the approach the haskellmode plugins for Vim take: build an index of Haddocumented identifiers once per installation, build an index of import-available identifiers once per :make. The latter turns out to be a performance issue for large libraries, such as Gtk2hs, so some users had to switch it off, updating less frequently, the former doesn't seem to cause any problems. Then again, we don't do fuzzy matching, only completion of partial identifiers and suggesting possible qualified names and imports for unqualified ones. Completion alone can result in many matches, I'd expect fuzzy matching to be worse, and while edit distance is a useful criterion for well-chosen examples, I'd have to agree with those who have their doubts about its use in this context (but then, those who don't need a feature shouldn't stand in the way of those who do;-). A general comment: once there was a time when GHC error messages were inferior to Hugs ones, then Simon PJ spent a lot of time improving GHC's messages, until there came a time when some of GHC's messages were too helpful - you couldn't find the error in all the help provided. It used to be a good idea to have several Haskell installations, just to be able to compare error messages for tricky code. Things have levelled off since then, but there are still cases were longish fuzzy messages are provided by GHC when brief harsh messages would be more to the point - which wouldn't be a problem if the longer friendlier messages at least provided all the details of the short unfriendly ones, which isn't always the case. See, eg, #1928, #2360, #956, #589, #451, .. By all means, record unhelpful error messages as tickets, especially, but not only, when you have an idea of the information that is missing/misleading in them. It is an ongoing process, and balance is as important as perceived friendlyness, and lots of "friendly" suggestions without concrete, specific and useful help may result in a very unfriendly effect (think telephone/email support..). Claus From niklas.broberg at gmail.com Sun Jul 13 08:38:56 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Jul 13 08:29:27 2008 Subject: [Haskell-cafe] ANN: haskell-src-exts 0.3.5 Message-ID: Hi all, I'm pleased to report that haskell-src-exts is now updated to understand Template Haskell syntax (it used to understand pre-6.4 TH, but now it works with the current version). At least I hope so, I didn't have much TH code to try it on so if you find some bugs just let me know. It wasn't all that hard to fix though, so I'm pretty confident it actually works. Get the code: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts-0.3.5 darcs get http://code.haskell.org/HSP/haskell-src-exts Cheers, /Niklas From batterseapower at hotmail.com Sun Jul 13 09:36:03 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sun Jul 13 09:26:34 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <004701c8e4e0$12a35380$520f7ad5@cr3lt> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> Message-ID: <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> 2008/7/13 Claus Reinke : > That is the approach the haskellmode plugins for Vim take: > build an index of Haddocumented identifiers once per installation, > build an index of import-available identifiers once per :make. > > The latter turns out to be a performance issue for large > libraries, such as Gtk2hs, so some users had to switch it > off, updating less frequently, the former doesn't seem to cause any > problems. Interesting. GHC would probably want to do something a bit smarter than an index at /installation/ time as the package environment is dynamic: 1. Create the index upon the first error message that needs it 2. On all subsequent error messages, update the index by rescanning packages whose versions have changed or have been newly installed 3. Cache this index on disk in some quick-to-read binary format This wouldn't actually be too hard, but is probably more effort than I'm willing to put in for an experimental weekend project! > Then again, we don't do fuzzy matching, only completion > of partial identifiers and suggesting possible qualified > names and imports for unqualified ones. Agreed: doing fuzzy matching on >every< available identifier from all packages would truly suck. I would propose just looking for exact matches in non-imported modules for identifiers that are not in scope. > Completion alone can result in many > matches, I'd expect fuzzy matching > to be worse, and while edit distance is a useful criterion > for well-chosen examples, I'd have to agree with those > who have their doubts about its use in this context (but then, > those who don't need a feature shouldn't stand in the way > of those who do;-). Well, noone has actually said they think fuzzy matching would be useful yet, so I suspect this patch is dead on the vine :). I've filed a ticket with the code anyway (http://hackage.haskell.org/trac/ghc/ticket/2442) so at least it's available for others to look at. > Things have levelled off since then, but there are still cases were longish > fuzzy messages are provided by GHC when brief harsh messages would be more > to the point - which wouldn't be a problem if the longer friendlier messages > at least provided all the details of the short unfriendly ones, which isn't > always the > case. See, eg, #1928, #2360, #956, #589, #451, .. > > ... > > It is an ongoing process, and balance is as important as > perceived friendlyness, and lots of "friendly" suggestions > without concrete, specific and useful help may result in a very unfriendly > effect (think telephone/email support..). These are interesting comments and tickets: thanks! I don't know where this kind of unbound-name suggestion we've talked about here fits in the spectrum of useful<->overwhelming, but I would like to think it's more towards the left end. It's easy to see why opinions would differ though. Cheers, Max From gwern0 at gmail.com Sun Jul 13 10:39:47 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Jul 13 10:30:52 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> Message-ID: <20080713143947.GA25980@craft> On 2008.07.13 14:36:03 +0100, Max Bolingbroke scribbled 2.8K characters: ... > Well, noone has actually said they think fuzzy matching would be > useful yet, so I suspect this patch is dead on the vine :). I've filed > a ticket with the code anyway > (http://hackage.haskell.org/trac/ghc/ticket/2442) so at least it's > available for others to look at. ,,, > Cheers, > Max Don't be discouraged; I think it would be useful. IMO, Haskellers tend to be pretty insensitive when it comes to usability. For example, before the GHC devs were asked for that feature, I wonder whether anyone ever thought: "Hey, when ghc -Wall complains about having no type signature - why doesn't it print out the inferred type signature? That would be helpful and convenient." I don't think it's because there's any sort of gung-ho elitism there, it's just not something anyone but the educators like the Helium folk really think about much. -- gwern virginia spies ISADC in rounds GRU Alex CQB Lander Elvis -------------- 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/20080713/f6e91a15/attachment.bin From allbery at ece.cmu.edu Sun Jul 13 11:21:44 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 13 11:12:22 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> Message-ID: <56D930B8-7691-4875-9C39-ABFD01B145E5@ece.cmu.edu> On 2008 Jul 13, at 9:36, Max Bolingbroke wrote: > 2008/7/13 Claus Reinke : >> Then again, we don't do fuzzy matching, only completion >> of partial identifiers and suggesting possible qualified >> names and imports for unqualified ones. > > Agreed: doing fuzzy matching on >every< available identifier from all > packages would truly suck. I would propose just looking for exact > matches in non-imported modules for identifiers that are not in scope. I would fuzzy match on unqualified names in the current module (or directory), qualified names in the module in question, and if that doesn't exist (== have a .hi) then try fuzzy-matching the module name. If the unqualified fuzzy match doesn't work, look for exact matches in non-imported modules. > Well, noone has actually said they think fuzzy matching would be > useful yet, so I suspect this patch is dead on the vine :). I've filed Huh? Edit distance is a good way to handle typoes --- and, while some people have asserted that "we don't need that because I can see it already", most people *don't* see it right away. (I do tend to spot typoes quickly --- in prose. It's nowhere near as accurate for code, and even when it does work it isn't exact: I'll have a "something's wrong" about some spot in the code and still take an hour to spot the typo.) I'm also *really* good at typoes, which you won't see in email but will see regularly in #haskell. :) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From allbery at ece.cmu.edu Sun Jul 13 11:25:37 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 13 11:16:09 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <56D930B8-7691-4875-9C39-ABFD01B145E5@ece.cmu.edu> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> <56D930B8-7691-4875-9C39-ABFD01B145E5@ece.cmu.edu> Message-ID: Following up on my own message... talking to yourself is a bad sign, right? :) On 2008 Jul 13, at 11:21, Brandon S. Allbery KF8NH wrote: > Huh? Edit distance is a good way to handle typoes --- and, while > some people have asserted that "we don't need that because I can see > it already", most people *don't* see it right away. It occurs to me to mention, in the vein of "over-friendly-ing is bad", the example of WATFOR/WATFIV: even a well thought out typo detection facility can badly obscure things. But as long the proposal is to conditionalize these on a compile flag, that isn't too much of an issue. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From bremner at unb.ca Sun Jul 13 14:07:31 2008 From: bremner at unb.ca (David Bremner) Date: Sun Jul 13 13:58:10 2008 Subject: [Haskell-cafe] confusion with fgl and ghc6 Message-ID: <0t1w1xk68s.wl%bremner@pivot.cs.unb.ca> I don't know whether this is a bug in fgl, in ghc, or I'm just confused. Any ideas? This is on debian/sid. GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> import Data.Graph.Inductive.Example Prelude Data.Graph.Inductive.Example> star 6 :1:0: Ambiguous type variable `gr' in the constraint: `Data.Graph.Inductive.Graph.Graph gr' arising from a use of `star' at :1:0-5 Probable fix: add a type signature that fixes these type variable(s) Prelude Data.Graph.Inductive.Example> From lrpalmer at gmail.com Sun Jul 13 14:20:48 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Jul 13 14:11:19 2008 Subject: [Haskell-cafe] confusion with fgl and ghc6 In-Reply-To: <0t1w1xk68s.wl%bremner@pivot.cs.unb.ca> References: <0t1w1xk68s.wl%bremner@pivot.cs.unb.ca> Message-ID: <7ca3f0160807131120q27b33bf9i41ef2c4351e40844@mail.gmail.com> On Sun, Jul 13, 2008 at 8:07 PM, David Bremner wrote: > > I don't know whether this is a bug in fgl, in ghc, or I'm just confused. > Any ideas? This is on debian/sid. > > > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> import Data.Graph.Inductive.Example > Prelude Data.Graph.Inductive.Example> star 6 The type of star is polymorphic: > :t star star :: (Graph gr) => Int -> gr () () Haskell does not know what type to pick for gr; there is no context from which it can infer this information. So you need to specify explicitly: > star 6 :: Gr () () -- works Luke From lpillay at webafrica.org.za Sun Jul 13 14:24:13 2008 From: lpillay at webafrica.org.za (Logesh Pillay) Date: Sun Jul 13 14:15:37 2008 Subject: [Haskell-cafe] memoization Message-ID: <487A484D.1080009@webafrica.org.za> I know we can perform memoization in Haskell. The well known recursive Fibonacci example works v. well. f(10000) returns a virtually instant answer which would not be possible otherwise. My (probably naive) function to give the number of partitions of a number :- p = ((map p' [0 .. ]) !!) where p' 0 = 1 p' 1 = 1 p' n = sum [(((-1) ^ (k+1)) * ( p' (n-((k*(3*k-1)) `div` 2)) + p' (n-((k*(3*k+1)) `div` 2)))) | k <- [1 .. n]] It is an attempt to apply the Euler recurrence formula (no 11 in http://mathworld.wolfram.com/PartitionFunctionP.html ) It works but it is shockingly slow. It is orders of magnitude slower than the Python memoized version which runs very fast. parts = {0:1, 1:1} def P(n): if not n in parts: parts[n] = sum ([( ((-1) ** (k+1)) * ( P(n-((k*(3*k-1))//2)) + P(n-((k*(3*k+1))//2)) ) ) for k in xrange (1, n+1)]) return parts[n] Why? Its as if memoization is being ignored in the haskell version. How to fix? From derek.a.elkins at gmail.com Sun Jul 13 14:29:48 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Jul 13 14:20:22 2008 Subject: [Haskell-cafe] memoization In-Reply-To: <487A484D.1080009@webafrica.org.za> References: <487A484D.1080009@webafrica.org.za> Message-ID: <1215973788.5818.16.camel@derek-laptop> On Sun, 2008-07-13 at 20:24 +0200, Logesh Pillay wrote: > I know we can perform memoization in Haskell. The well known recursive > Fibonacci example works v. well. f(10000) returns a virtually instant > answer which would not be possible otherwise. > > My (probably naive) function to give the number of partitions of a number :- > p = ((map p' [0 .. ]) !!) > where > p' 0 = 1 > p' 1 = 1 > p' n = sum [(((-1) ^ (k+1)) * ( p' (n-((k*(3*k-1)) `div` 2)) + p' > (n-((k*(3*k+1)) `div` 2)))) | k <- [1 .. n]] > > It is an attempt to apply the Euler recurrence formula (no 11 in > http://mathworld.wolfram.com/PartitionFunctionP.html ) > > It works but it is shockingly slow. It is orders of magnitude slower > than the Python memoized version which runs very fast. > parts = {0:1, 1:1} > def P(n): > if not n in parts: > parts[n] = sum ([( ((-1) ** (k+1)) * ( P(n-((k*(3*k-1))//2)) + > P(n-((k*(3*k+1))//2)) ) ) for k in xrange (1, n+1)]) > return parts[n] > > Why? Its as if memoization is being ignored in the haskell version. That's because you aren't using it. > How to fix? Use your memoized function. From ketil at malde.org Sun Jul 13 14:37:31 2008 From: ketil at malde.org (Ketil Malde) Date: Sun Jul 13 14:27:23 2008 Subject: [Haskell-cafe] memoization In-Reply-To: <487A484D.1080009@webafrica.org.za> (Logesh Pillay's message of "Sun\, 13 Jul 2008 20\:24\:13 +0200") References: <487A484D.1080009@webafrica.org.za> Message-ID: <87zlolljf8.fsf@malde.org> Logesh Pillay writes: > Why? Its as if memoization is being ignored in the haskell version. > How to fix? Shouldn't the definition of p' call (the memoized) p somewhere? In other words, I can't see any memoization, you seem to just map a normal, expensive, recursive function p' over a list. (Another difference is that Python's associative arrays are likely to be faster than Haskell's linear-time indexed lists.) -k -- If I haven't seen further, it is by standing in the footprints of giants From lemming at henning-thielemann.de Sun Jul 13 14:46:40 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jul 13 14:37:13 2008 Subject: [Haskell-cafe] memoization In-Reply-To: <487A484D.1080009@webafrica.org.za> References: <487A484D.1080009@webafrica.org.za> Message-ID: On Sun, 13 Jul 2008, Logesh Pillay wrote: > I know we can perform memoization in Haskell. The well known recursive > Fibonacci example works v. well. f(10000) returns a virtually instant answer > which would not be possible otherwise. > > My (probably naive) function to give the number of partitions of a number :- > p = ((map p' [0 .. ]) !!) > where > p' 0 = 1 > p' 1 = 1 > p' n = sum [(((-1) ^ (k+1)) * ( p' (n-((k*(3*k-1)) `div` 2)) + p' (n-((k*(3*k+1)) `div` 2)))) | k <- [1 .. n]] You don't use memoization here - so why do you expect it would take place? I have a fast implementation: http://darcs.haskell.org/htam/src/Combinatorics/Partitions.hs From andrewcoppin at btinternet.com Sun Jul 13 15:49:43 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Jul 13 16:24:22 2008 Subject: [Haskell-cafe] Re: QuickCheck [Architecturally flawed] In-Reply-To: <2f9b2d30807121729t3f2531dfh668c210ca31f1866@mail.gmail.com> References: <48765669.8090708@btinternet.com> <4877A22E.8080309@btinternet.com> <2f9b2d30807121729t3f2531dfh668c210ca31f1866@mail.gmail.com> Message-ID: <487A5C57.5050401@btinternet.com> Ryan Ingram wrote: > I think you can use the duality of Writer/Reader to help you here; you > have the law that, for suitable "dual" computations r and w, > > run_reader r (run_writer (w x)) == x > > Then you can build up a list of rules specifying which computations > are dual; read64 is dual to write64, for example. OK. This is more or less the approach I ended up taking. Otherwise the QuickCheck properties just reimplement the functions themselves - which doesn't tell you anything! ;-) From derek.a.elkins at gmail.com Sun Jul 13 19:28:10 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Jul 13 19:18:44 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <1215712796.6571.10.camel@jcchost> References: <1215712400.8094.7.camel@quindinho.domain.invalid> <1215712796.6571.10.camel@jcchost> Message-ID: <1215991690.5818.18.camel@derek-laptop> On Thu, 2008-07-10 at 10:59 -0700, Jonathan Cast wrote: > On Thu, 2008-07-10 at 14:53 -0300, Marco T?lio Gontijo e Silva wrote: > > Hello, > > > > how do I unbox a existential quantificated data type? > > You can't. You have to use case analysis: > > case foo of > L l -> > > where none of the information your case analysis discovers about the > actual type of l can be made available outside of the scope of the case > expression. (It can't `escape'). This is required for decidable static > typing, IIRC. It's not an extraneous requirement; it is part of the definition of existential types. From marco-oweber at gmx.de Sun Jul 13 19:42:04 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Sun Jul 13 19:32:37 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <20080713143947.GA25980@craft> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> <20080713143947.GA25980@craft> Message-ID: <20080713234204.GA838@gmx.de> > Don't be discouraged; I think it would be useful. IMO, Haskellers tend to be pretty insensitive when it comes to usability. > > For example, before the GHC devs were asked for that feature, I wonder whether anyone ever thought: "Hey, when ghc -Wall complains about having no type signature - why doesn't it print out the inferred type signature? That would be helpful and convenient." > > I don't think it's because there's any sort of gung-ho elitism there, it's just not something anyone but the educators like the Helium folk really think about much. I've been thinking about stuff like this as well. It happens to me as well that I spend minutes on finding an error till I notice that I've misspelled a word.. but this has been while programming PHP. In haskell this kind of error tends to take much less time IMHO. There is a "friendlier" shell (don't remember it's name) which takes another approach: Change color if the word is known.. In case of ghci the commandline could switch color to green before pressing enter to indicate there are no errors left.. Marc From jonathanccast at fastmail.fm Sun Jul 13 19:50:50 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Jul 13 19:41:21 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <1215991690.5818.18.camel@derek-laptop> References: <1215712400.8094.7.camel@quindinho.domain.invalid> <1215712796.6571.10.camel@jcchost> <1215991690.5818.18.camel@derek-laptop> Message-ID: <1215993050.6357.8.camel@jonathans-macbook> On Sun, 2008-07-13 at 18:28 -0500, Derek Elkins wrote: > On Thu, 2008-07-10 at 10:59 -0700, Jonathan Cast wrote: > > On Thu, 2008-07-10 at 14:53 -0300, Marco T?lio Gontijo e Silva wrote: > > > Hello, > > > > > > how do I unbox a existential quantificated data type? > > > > You can't. You have to use case analysis: > > > > case foo of > > L l -> > > > > where none of the information your case analysis discovers about the > > actual type of l can be made available outside of the scope of the case > > expression. (It can't `escape'). This is required for decidable static > > typing, IIRC. > > It's not an extraneous requirement; it is part of the definition of > existential types. I know that. I didn't know implementing existential types was an end in itself, though. jcc From isaacdupree at charter.net Sun Jul 13 21:00:07 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Sun Jul 13 20:50:51 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <20080713234204.GA838@gmx.de> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> <20080713143947.GA25980@craft> <20080713234204.GA838@gmx.de> Message-ID: <487AA517.80109@charter.net> Marc Weber wrote: > There is a "friendlier" shell (don't remember it's name) which takes > another approach: > Change color if the word is known.. In case of ghci the commandline > could switch color to green before pressing enter to indicate there are > no errors left.. "fish", the "friendly interactive shell", which I use, although it has lots of minor friendliness problems (compared to ideal, not to bash) that could be fixed by more hacking on its C code :-P -Isaac From allbery at ece.cmu.edu Sun Jul 13 21:03:04 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 13 20:53:35 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <1215993050.6357.8.camel@jonathans-macbook> References: <1215712400.8094.7.camel@quindinho.domain.invalid> <1215712796.6571.10.camel@jcchost> <1215991690.5818.18.camel@derek-laptop> <1215993050.6357.8.camel@jonathans-macbook> Message-ID: <4A8E494C-A20A-4618-8A0E-B1F52A2D102E@ece.cmu.edu> On 2008 Jul 13, at 19:50, Jonathan Cast wrote: > On Sun, 2008-07-13 at 18:28 -0500, Derek Elkins wrote: >> On Thu, 2008-07-10 at 10:59 -0700, Jonathan Cast wrote: >>> On Thu, 2008-07-10 at 14:53 -0300, Marco T?lio Gontijo e Silva >>> wrote: >>>> Hello, >>>> >>>> how do I unbox a existential quantificated data type? >>> >>> You can't. You have to use case analysis: >>> >>> case foo of >>> L l -> >>> >>> where none of the information your case analysis discovers about the >>> actual type of l can be made available outside of the scope of the >>> case >>> expression. (It can't `escape'). This is required for decidable >>> static >>> typing, IIRC. >> >> It's not an extraneous requirement; it is part of the definition of >> existential types. > > I know that. I didn't know implementing existential types was an > end in itself, though. No? Consider ST. Anytime you need to completely restrict access to the innards of a datum, existential types are your friend. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From jonathanccast at fastmail.fm Sun Jul 13 21:16:54 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Jul 13 21:07:25 2008 Subject: [Haskell-cafe] Existential quantification problem In-Reply-To: <4A8E494C-A20A-4618-8A0E-B1F52A2D102E@ece.cmu.edu> References: <1215712400.8094.7.camel@quindinho.domain.invalid> <1215712796.6571.10.camel@jcchost> <1215991690.5818.18.camel@derek-laptop> <1215993050.6357.8.camel@jonathans-macbook> <4A8E494C-A20A-4618-8A0E-B1F52A2D102E@ece.cmu.edu> Message-ID: <1215998214.6357.10.camel@jonathans-macbook> On Sun, 2008-07-13 at 21:03 -0400, Brandon S. Allbery KF8NH wrote: > On 2008 Jul 13, at 19:50, Jonathan Cast wrote: > > > On Sun, 2008-07-13 at 18:28 -0500, Derek Elkins wrote: > >> On Thu, 2008-07-10 at 10:59 -0700, Jonathan Cast wrote: > >>> On Thu, 2008-07-10 at 14:53 -0300, Marco T?lio Gontijo e Silva > >>> wrote: > >>>> Hello, > >>>> > >>>> how do I unbox a existential quantificated data type? > >>> > >>> You can't. You have to use case analysis: > >>> > >>> case foo of > >>> L l -> > >>> > >>> where none of the information your case analysis discovers about the > >>> actual type of l can be made available outside of the scope of the > >>> case > >>> expression. (It can't `escape'). This is required for decidable > >>> static > >>> typing, IIRC. > >> > >> It's not an extraneous requirement; it is part of the definition of > >> existential types. > > > > I know that. I didn't know implementing existential types was an > > end in itself, though. > > No? Consider ST. Anytime you need to completely restrict access to > the innards of a datum, existential types are your friend. Right. Mea culpa. jcc From levi.stephen at optusnet.com.au Sun Jul 13 22:08:00 2008 From: levi.stephen at optusnet.com.au (Levi Stephen) Date: Sun Jul 13 21:58:30 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <8341e4f40807131859n4763735ek78555b9516203dd2@mail.gmail.com> References: <4878C731.9020004@cse.unsw.edu.au> <8341e4f40807131859n4763735ek78555b9516203dd2@mail.gmail.com> Message-ID: <8341e4f40807131908q64c7d8dct3ea804f0b16d26a@mail.gmail.com> On Sun, Jul 13, 2008 at 12:31 AM, Roman Leshchinskiy wrote: > Hi all, > > the vector library will eventually provide fast, Int-indexed arrays with a > powerful fusion framework. It's very immature at the moment (I haven't > tested most of the code) and implements just a few combinators but I > thought releasing early wouldn't hurt. Use at your own risk and expect > things to break horribly! > Sounds interesting. How does this compare to the uvector library? Thanks, Levi From rl at cse.unsw.edu.au Mon Jul 14 00:30:31 2008 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Mon Jul 14 00:21:06 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <8341e4f40807131908q64c7d8dct3ea804f0b16d26a@mail.gmail.com> References: <4878C731.9020004@cse.unsw.edu.au> <8341e4f40807131859n4763735ek78555b9516203dd2@mail.gmail.com> <8341e4f40807131908q64c7d8dct3ea804f0b16d26a@mail.gmail.com> Message-ID: <487AD667.40506@cse.unsw.edu.au> Levi Stephen wrote: > On Sun, Jul 13, 2008 at 12:31 AM, Roman Leshchinskiy > wrote: >> Hi all, >> >> the vector library will eventually provide fast, Int-indexed arrays with a >> powerful fusion framework. It's very immature at the moment (I haven't >> tested most of the code) and implements just a few combinators but I >> thought releasing early wouldn't hurt. Use at your own risk and expect >> things to break horribly! >> > > Sounds interesting. How does this compare to the uvector library? IIUC, uvector is based on an older version of the DPH libraries and only provides unboxed arrays. On the other hand, it's much more stable and has more functionality. I expect that the two libraries will be merged eventually. Roman From david at overtons.id.au Mon Jul 14 01:27:24 2008 From: david at overtons.id.au (David Overton) Date: Mon Jul 14 01:17:55 2008 Subject: [Haskell-cafe] Prime time for Haskell In-Reply-To: <4879D3C8.1090809@tcs.inf.tu-dresden.de> References: <4879C441.7000701@tcs.inf.tu-dresden.de> <200807131052.39668.jon@ffconsultancy.com> <4879D3C8.1090809@tcs.inf.tu-dresden.de> Message-ID: 2008/7/13 Janis Voigtlaender : > Jon Harrop wrote: >> Is the article freely available anywhere? > > Unfortunately, I cannot tell. I have free access from office, where I > currently am. But that could be because the server recognizes my > university's IP. A quick google found a copy here: http://research.microsoft.com/~larus/Papers/p80-larus.pdf David From rendel at daimi.au.dk Mon Jul 14 02:47:47 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Mon Jul 14 02:38:22 2008 Subject: [Haskell-cafe] Architecturally flawed In-Reply-To: <48765669.8090708@btinternet.com> References: <48765669.8090708@btinternet.com> Message-ID: <487AF693.7040103@daimi.au.dk> Andrew Coppin wrote: > [design of a bitwise binary library] > > (This would all be so trivial in an OO language. Just make an Encoder > object that updates its own state internally and talks to a Source > object and a Destination object for its data...) I guess it's on the same level of trivialness in Haskell, too, but to be fair, I haven't tried it... I would proceed as follows: (1) Try to not shadow names from the mtl or other standard packages. I choose BitSink and BitSource instead of Reader and Writer. (2) Select a small number of primitive operations. I select the operations "read n bits" and "put n bits" as primitive operations. As interface format, I choose [Boolean], which is not exactly optimized, but easy to understand. It is easy to implement operations for single bits, bytes etc. on top of this operations. We will later include them into the typeclass, but we will first make the [Boolean]-based operations correct. (2) Make BitSink and BitSource composable, e.g., as monad transformers. The type classes could look like: class MonadBitSource m where getBits :: Int -> m [Boolean] class MonadBitSink m where putBits :: [Boolean] -> m () And we need a lot of trivial instances for the various mtl monad transformers in the style of: instance MonadBitSink m => MonadBitSink (ReaderT m) where putBits = lift . putBits (3) Write a very simple implementation to (a) check that the typeclasses makes sense and is implementable and (b) have a test-implementation for later correctness tests. The easiest implementation I can think of consists of a state monad which handles a list of booleans. It could look like this: newtype BitListT m a = BitListT (StateT [Boolean] m a) deriving (Functor, Monad, MonadReader r, MonadWriter w, ...) You should be able to derive all mtl classes except MonadTransformer, MonadIO and MonadState. Instantiate these yourself: instance MonadTransformer BitListT where lift (BitListT p) = BitListT (lift p) instance MonadIO m => MonadIO (BitListT m) where liftIO = lift . liftIO We want to hide BitListT's state and expose a state in the nested monad to the user, if there is any. instance MonadState s m => MonadState s (BitListT m) where get = lift get put = lift . put Finally, the real stuff: instance MonadBitSink (BitListT m) where putBits x = BitListT $ modify (++ x) instance MonadBitSource (BitListT m) where getBits n = BitListT $ do result <- gets (take n) guard (length result == n) modify (drop n) return result runSinkBitListT :: BitListT m a -> m (BitListT ([Boolean], a)) runSinkBitListT (BitListT p) = return $ runState p [] runSourceBitListT :: BitListT m a -> [Boolean] -> m a runSourceBitListT (BitListT p) bits = return $ evalState p bits (4) Check the simple implementation Now we can write quickcheck properties (if you believe in XP, you can write them before (3), of course) to check our simple implementation and document the specification. given simple function runSink = runIdentity . runSinkBitListT and runSource bits = runIdentity . runSourceBitListT bits, we have such properties as forall n . forall bits . length bits >= n ==> length (runSource (getBits n)) == n forall bits . runSource (getBits (length bits)) == bits forall a . forall b . (runSource (liftM2 (++) (getBits a) (getBits b))) == runSource (getBits (a + b)) forall p . forall q . runSink p ++ runSink q == runSink (p ++ q) usw. Use the tricks already mentioned in this thread for the last property. Don't forget to write properties for the high-level interface putWord8 etc. (5) Write a more realistic instance, e.g. by replacing [Boolean] through (Int, ByteString) and doing clever things in getBits / putBits. Test this instance both with the existing properties and against the simple instance, i.e., verify that getBits and setBits means the same in both monads. (6) move the high-level functions getWord8 & Co. into the typeclass, keep the definition as defaults. they are fine for BitListT, but implement your own versions for the other instance. Quickcheck them against the properties, against the simple implementation in BitListT and against the default definitions. (7) if you need tracing, use liftIO (print ...) and finally understand what's the point about monad transformer stacks and MonadIO and why you almost always want to define a monad transformer instead of a monad. (8) Write your LZW stuff with newtype EncoderT s m a = EncoderT (StateT (LZW s) (BitSink m) a) deriving (a lot of stuff) (9) Have fun! Tillmann From johan.tibell at gmail.com Mon Jul 14 02:48:50 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Jul 14 02:39:20 2008 Subject: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion) In-Reply-To: <487AD667.40506@cse.unsw.edu.au> References: <4878C731.9020004@cse.unsw.edu.au> <8341e4f40807131859n4763735ek78555b9516203dd2@mail.gmail.com> <8341e4f40807131908q64c7d8dct3ea804f0b16d26a@mail.gmail.com> <487AD667.40506@cse.unsw.edu.au> Message-ID: <90889fe70807132348qce9b561r38145c2cf1095f3c@mail.gmail.com> On Mon, Jul 14, 2008 at 6:30 AM, Roman Leshchinskiy wrote: > Levi Stephen wrote: >> Sounds interesting. How does this compare to the uvector library? > > IIUC, uvector is based on an older version of the DPH libraries and only > provides unboxed arrays. On the other hand, it's much more stable and has > more functionality. I expect that the two libraries will be merged > eventually. That would be great indeed. From rendel at daimi.au.dk Mon Jul 14 03:11:28 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Mon Jul 14 03:01:58 2008 Subject: [Haskell-cafe] Trying to install cabal In-Reply-To: References: <48764E54.2090303@ukfsn.org> Message-ID: <487AFC20.4020100@daimi.au.dk> Brandon S. Allbery KF8NH wrote: >> I have downloaded cabal and am trying to install it but have gotten the >> following error message: >> >> C:\cabal\cabal-install-0.5.1>runghc Setup configure > > Cabal itself is a special case; you need the same version of Cabal > already installed to install it via Cabal... > > Just run "make" to bootstrap it, IIRC. Cabal managed to bootstrap just fine when installed with runhaskell Setup.hs ... as usual on my windows machine. (and running make would have been a problem). But to install cabal-install (the command line interface), you have to install cabal (the library) first. I assume that in the future, ghc will include cabal-install? Until then, it would be nice to have some ad-hoc solution to add cabal-install to a fresh installation of ghc (e.g. a tarball containing cabal-install and it's dependencies and a build script, or a script which downloads said dependencies). Currently, people have to learn dependency chasing and manual hackage/cabal installation just to install cabal-install, which does a great job at making this skill useless. Apropos cabal-install: can i make it build documentation during the installation process and store them in some central location? Tillmann From lemming at henning-thielemann.de Mon Jul 14 03:51:22 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jul 14 03:41:53 2008 Subject: [Haskell-cafe] Trying to install cabal In-Reply-To: <487AFC20.4020100@daimi.au.dk> References: <48764E54.2090303@ukfsn.org> <487AFC20.4020100@daimi.au.dk> Message-ID: On Mon, 14 Jul 2008, Tillmann Rendel wrote: > Apropos cabal-install: can i make it build documentation during the > installation process and store them in some central location? I also wondered about that. Maybe a '--haddock' flag for 'cabal install' ? From grzegorz.chrupala at computing.dcu.ie Mon Jul 14 04:43:06 2008 From: grzegorz.chrupala at computing.dcu.ie (Grzegorz Chrupala) Date: Mon Jul 14 04:33:36 2008 Subject: [Haskell-cafe] Strange space leak Message-ID: <18439685.post@talk.nabble.com> Hi all, I just noticed that a tiny change to the program which I posted recently in the "More idiomatic use of strictness" thread causes a space leak. The code is: {-# LANGUAGE BangPatterns, PatternGuards #-} import Data.List (foldl') import Data.Char split delim s | [] <- rest = [token] | otherwise = token : split delim (tail rest) where (token,rest) = span (/=delim) s main = do putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words) getContents stats ws docs = foldl' f ((map (const 0) ws),0) docs where f (dfs,n) d = let dfs' = zipWith (\w df -> (df + fromEnum (w `elem` d))) ws dfs in sum dfs' `seq` (dfs',n+1) If I change this line: putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words) getContents to this: putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words . map toLower) getContents suddenly the programs starts using tons of memory instead of running in small constant space. What's going on? Best, -- Grzegorz -- View this message in context: http://www.nabble.com/Strange-space-leak-tp18439685p18439685.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From arthurvl at cs.uu.nl Mon Jul 14 04:52:17 2008 From: arthurvl at cs.uu.nl (Arthur van Leeuwen) Date: Mon Jul 14 04:42:47 2008 Subject: [Haskell-cafe] Human-friendly compiler errors for GHC In-Reply-To: <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> References: <9d4d38820807120944w7d286727t8c8c45bd2421c06d@mail.gmail.com> <7ca3f0160807121140hf250ac5o3286b275acd798f7@mail.gmail.com> <9d4d38820807121611p19c28b2q391269bae2704ab0@mail.gmail.com> <48797A6B.7080803@freegeek.org> <4879D4CA.70407@charter.net> <9d4d38820807130423x4544f7b5ua085bf781e1d375@mail.gmail.com> <004701c8e4e0$12a35380$520f7ad5@cr3lt> <9d4d38820807130636m7eb4abafhd9323410a0549416@mail.gmail.com> Message-ID: <8AEB2295-67F9-4DD3-AFC8-AD024B0B305E@cs.uu.nl> On 13 jul 2008, at 15:36, Max Bolingbroke wrote: [snip, patches towards friendlier error messages in GHC] >> Then again, we don't do fuzzy matching, only completion >> of partial identifiers and suggesting possible qualified >> names and imports for unqualified ones. > > Agreed: doing fuzzy matching on >every< available identifier from all > packages would truly suck. I would propose just looking for exact > matches in non-imported modules for identifiers that are not in scope. The approach taken by Helium (which doesn't quite do full Haskell''98 yet) is to not just do fuzzy matching, but to figure out if the identifiers that were fuzzily matched also have the right type. For more info, read Bastiaan Heeren's PhD Thesis: Top Quality Type Error Messages. available at http://people.cs.uu.nl/bastiaan/phdthesis/ > Well, noone has actually said they think fuzzy matching would be > useful yet, so I suspect this patch is dead on the vine :). I've filed > a ticket with the code anyway > (http://hackage.haskell.org/trac/ghc/ticket/2442) so at least it's > available for others to look at. More help is very much useful. However, there are different use cases that imply different types of help and diffent types of searching. With kind regards, Arthur van Leeuwen. -- /\ / | arthurvl@cs.uu.nl | Work like you don't need the money /__\ / | A friend is someone with whom | Love like you have never been hurt / \/__ | you can dare to be yourself | Dance like there's nobody watching From duncan.coutts at worc.ox.ac.uk Mon Jul 14 06:59:04 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jul 14 06:48:59 2008 Subject: [Haskell-cafe] Trying to install cabal In-Reply-To: References: <48764E54.2090303@ukfsn.org> Message-ID: <1216033144.6279.85.camel@localhost> On Thu, 2008-07-10 at 18:53 -0400, Brandon S. Allbery KF8NH wrote: > On 2008 Jul 10, at 14:00, Eric wrote: > > > I have downloaded cabal and am trying to install it but have gotten > > the > > following error message: > > > > C:\cabal\cabal-install-0.5.1>runghc Setup configure Note that Eric is talking about cabal-install, not the Cabal library package. > Cabal itself is a special case; you need the same version of Cabal > already installed to install it via Cabal... The Cabal library package always bootstraps using its own source code. It does not need any existing version. Despite the bootstrapping it is just an ordinary Cabal package. It can be configured and built in the standard way using runhaskell or cabal-install. > Just run "make" to bootstrap it, IIRC. Though that also works. Duncan From apfelmus at quantentunnel.de Mon Jul 14 08:08:43 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Mon Jul 14 07:59:24 2008 Subject: [Haskell-cafe] Re: Strange space leak In-Reply-To: <18439685.post@talk.nabble.com> References: <18439685.post@talk.nabble.com> Message-ID: Grzegorz Chrupala wrote: > Hi all, > I just noticed that a tiny change to the program which I posted recently in > the "More idiomatic use of strictness" thread causes a space leak. > > The code is: > {-# LANGUAGE BangPatterns, PatternGuards #-} > import Data.List (foldl') > import Data.Char > split delim s > | [] <- rest = [token] > | otherwise = token : split delim (tail rest) > where (token,rest) = span (/=delim) s > > main = do > putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words) > getContents > > stats ws docs = foldl' f ((map (const 0) ws),0) docs > where f (dfs,n) d = let dfs' = zipWith (\w df -> (df + fromEnum (w > `elem` d))) ws dfs > in sum dfs' `seq` (dfs',n+1) > > If I change this line: > putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words) > getContents > to this: > putStrLn =<< fmap (show . stats ["the","a","and"] . split "" . words > .. map toLower) getContents > > suddenly the programs starts using tons of memory instead of running in > small constant space. > What's going on? Answer: split "" . words . map toLower = (:[]) . words . map toLower Since you converted everything to lowercase, the string "" will never appear in the text, resulting in a single huge document. Furthermore, due to `elem` d , your stats function takes space proportional to the length of each document it processes. Beauty & makeup tips: putStrLn =<< fmap f getContents = putStrLn . f =<< getContents ~= interact f Here's a version with glittering nail polish that should run in constant space: split y xs = zs : case xs' of [] -> [] _:xs' -> split y xs' where (zs,xs') = break (==y) xs main = interact $ show . stats ["the","a","and"] . split "" . words zipWith' f xs ys = zipWith f xs ys `using` rnf stats ws = foldl' (zipWith' (+)) zero . map (foldl' (zipWith' max) zero . map bits) where zero = map (const 0) ws bits v = map (fromEnum . (== v)) ws Regards, apfelmus From grzegorz.chrupala at computing.dcu.ie Mon Jul 14 09:41:11 2008 From: grzegorz.chrupala at computing.dcu.ie (Grzegorz Chrupala) Date: Mon Jul 14 09:31:38 2008 Subject: [Haskell-cafe] Strange space leak In-Reply-To: References: <18439685.post@talk.nabble.com> Message-ID: <18444159.post@talk.nabble.com> apfelmus wrote: > > Answer: > > split "" . words . map toLower = (:[]) . words . map toLower > > Since you converted everything to lowercase, the string "" will > never appear in the text, resulting in a single huge document. > Oops, that should have been obvious, sorry for the dumb question. Thanks, -- Grzegorz -- View this message in context: http://www.nabble.com/Strange-space-leak-tp18439685p18444159.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From chris at eidhof.nl Mon Jul 14 10:37:16 2008 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Jul 14 10:27:46 2008 Subject: [Haskell-cafe] Sphinx full-text searching client on Hackage Message-ID: <5C5DB7A5-4554-4AA1-85E2-8A7226FEDE83@eidhof.nl> Hey everyone, We started working on a client [1] for the sphinx full-text search engine [2], which is a very fast full-text search engine that has either SQL or XML as a backend. While our version is far from done (it only supports the query command, and a limited number of parameters), we still think that it might be useful for other people as well. If you want to help us hacking on it, testing it or improving documentation, you're more than welcome. The communication with Sphinx is done using a quite low-level binary protocol, but Data.Binary saved the day: it made it very easy for us to parse all the binary things. Especially the use of the Get and Put monads are a big improvement over the manual reading and keeping track of positions, as is done in the PHP/Python clients. Thanks, -chris [1]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sphinx [2]: http://www.sphinxsearch.com/ From sk at k-hornz.de Mon Jul 14 11:56:42 2008 From: sk at k-hornz.de (stefan kersten) Date: Mon Jul 14 11:47:51 2008 Subject: [Haskell-cafe] vector vs uvector Message-ID: hi, what's the difference between the vector [1] and uvector [2] packages? should one of those preferred over the other? thanks, [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ vector-0.1 [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ uvector-0.1.0.1 From lemming at henning-thielemann.de Mon Jul 14 12:06:36 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jul 14 11:57:06 2008 Subject: [Haskell-cafe] vector vs uvector In-Reply-To: References: Message-ID: On Mon, 14 Jul 2008, stefan kersten wrote: > what's the difference between the vector [1] and uvector [2] packages? should > one of those preferred over the other? > > thanks, > > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector-0.1 > [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uvector-0.1.0.1 To make things even more confusing, there is also: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/storablevector http://code.haskell.org/storablevector/ This library was mentioned in Haskell-Cafe in December of 2007 on Haskell-Cafe and I started to use and extend it by a lazy chunky structure, an ST interface for in-place update, and an experimental element-wise lazy but efficient data structure. Now I become aware that there are parallel efforts. I'm also uncertain where to invest more time. From lists at qseep.net Mon Jul 14 12:10:07 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Mon Jul 14 12:01:56 2008 Subject: [Haskell-cafe] vector vs uvector In-Reply-To: References: Message-ID: <487B7A5F.7090109@qseep.net> stefan kersten wrote: > hi, > > what's the difference between the vector [1] and uvector [2] packages? > should one of those preferred over the other? > > thanks, > > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector-0.1 > [2] > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uvector-0.1.0.1 > You should use the most mature and stable package, which is of course, uvector, being a whole 0.0.0.1 versions past vector. ;) - Lyle From sk at k-hornz.de Mon Jul 14 12:17:04 2008 From: sk at k-hornz.de (stefan kersten) Date: Mon Jul 14 12:11:05 2008 Subject: [Haskell-cafe] uvector and the stream interface Message-ID: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> currently i'm working on stuff that looks something like this: 1 read soundfile from disk in blocks of N samples (IOCArray, hsndfile package) 2 convert to CArray with unsafeFreeze (simple O(1) cast, carray package) 3 perform FFT (CArray, fftw package) 4 convert to UArr (uvector package) 5 do some stuff with vectors i'd like to minimize copying, and since the FFT returns a new array anyway, the only copying conversion is the one between CArray and UArr in step 4. the approach i've been following is defining a `stream' conversion for CArray, hoping that subsequent carray accesses will be fused with uvector operations without the need for allocating a vector in between. does that make sense? could this be a general strategy for avoiding copying at the boundary between the various array libraries? thanks, From dons at galois.com Mon Jul 14 12:27:16 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 14 12:17:48 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> Message-ID: <20080714162716.GA23601@scytale.galois.com> sk: > currently i'm working on stuff that looks something like this: > > 1 read soundfile from disk in blocks of N samples (IOCArray, hsndfile > package) > 2 convert to CArray with unsafeFreeze (simple O(1) cast, carray package) > 3 perform FFT (CArray, fftw package) > 4 convert to UArr (uvector package) > 5 do some stuff with vectors > > i'd like to minimize copying, and since the FFT returns a new array > anyway, the only copying conversion is the one between CArray and > UArr in step 4. the approach i've been following is defining a > `stream' conversion for CArray, hoping that subsequent carray > accesses will be fused with uvector operations without the need for > allocating a vector in between. does that make sense? could this be a > general strategy for avoiding copying at the boundary between the > various array libraries? If you can write a function from CArray a -> Stream a, then yep, it'll fuse, and that's a good way to avoid copying. Another way is to dive into the internals and coerce the CArray type to a MUArr. It would be helpful to see the programs people are writing with uvector, so I can polish up the API some more :) -- Don From jules at jellybean.co.uk Mon Jul 14 12:42:40 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jul 14 12:33:11 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <20080714162716.GA23601@scytale.galois.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> Message-ID: <487B8200.1020901@jellybean.co.uk> Don Stewart wrote: > sk: >> currently i'm working on stuff that looks something like this: >> >> 1 read soundfile from disk in blocks of N samples (IOCArray, hsndfile >> package) >> 2 convert to CArray with unsafeFreeze (simple O(1) cast, carray package) >> 3 perform FFT (CArray, fftw package) >> 4 convert to UArr (uvector package) >> 5 do some stuff with vectors [snip] > It would be helpful to see the programs people are writing with uvector, > so I can polish up the API some more :) It would also be helpful to have someone explain why we have: Ptr a ByteString IOUArray IOCArray Data.Storable.StorableArray UArr Of course, I know the answers to some of those questions, ByteString is obviously less polymorphic than all the others there, and Ptr a doesn't contain size information. But it seems we have a rapidly bifurcating profusion of 'typed interfaces to chunks of memory' with no obvious consistency to their naming scheme and I think it's starting to get confusing... Jules From sk at k-hornz.de Mon Jul 14 13:14:50 2008 From: sk at k-hornz.de (stefan kersten) Date: Mon Jul 14 13:06:36 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <487B8200.1020901@jellybean.co.uk> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> Message-ID: On 14.07.2008, at 18:42, Jules Bean wrote: >> It would be helpful to see the programs people are writing with >> uvector, >> so I can polish up the API some more :) > > It would also be helpful to have someone explain why we have: > > Ptr a > ByteString > IOUArray > IOCArray > Data.Storable.StorableArray > UArr > > Of course, I know the answers to some of those questions, > ByteString is obviously less polymorphic than all the others there, > and Ptr a doesn't contain size information. But it seems we have a > rapidly bifurcating profusion of 'typed interfaces to chunks of > memory' with no obvious consistency to their naming scheme and I > think it's starting to get confusing... maybe it would be useful to look at (1) what's expected in terms of the underlying array implementation and (2) in terms of array access. (1) some things that come to mind: * ghc heap or system heap (can the garbage collector move memory during calls to C?) * access to a Ptr for interfacing to external libraries (possible with UArr?) * alignment (most SIMD instruction sets require 16 byte aligned data) * mutability * strict vs (partially) lazy (2) personally i much prefer the list-like interface provided by the stream-fusion powered libraries (ndp, uvector, vector). can't the stream-fusion framework and correspondingly the vector interface be separated from the memory representation, provided a particular concrete representation comes up with a stream/unstream pair? then it would be easy to swap out the underlying representation according to the required characteristics. From dons at galois.com Mon Jul 14 13:19:19 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 14 13:09:51 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <487B8200.1020901@jellybean.co.uk> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> Message-ID: <20080714171919.GB23666@scytale.galois.com> jules: > Don Stewart wrote: > >sk: > >>currently i'm working on stuff that looks something like this: > >> > >>1 read soundfile from disk in blocks of N samples (IOCArray, hsndfile > >>package) > >>2 convert to CArray with unsafeFreeze (simple O(1) cast, carray package) > >>3 perform FFT (CArray, fftw package) > >>4 convert to UArr (uvector package) > >>5 do some stuff with vectors > > [snip] > > >It would be helpful to see the programs people are writing with uvector, > >so I can polish up the API some more :) > > It would also be helpful to have someone explain why we have: > > Ptr a > ByteString > IOUArray > IOCArray > Data.Storable.StorableArray > UArr > > Of course, I know the answers to some of those questions, ByteString is > obviously less polymorphic than all the others there, and Ptr a doesn't > contain size information. But it seems we have a rapidly bifurcating > profusion of 'typed interfaces to chunks of memory' with no obvious > consistency to their naming scheme and I think it's starting to get > confusing... > > Jules An abstraction stack: Impure Pure ------------------------------- Further from the machine: UArr hmatrix/blas/fftw IOUArr CArray ByteString StorableArray STUArr MUArr ForeginPtr Ptr Addr# Closer to machine The key now is to ensure we have enough introduction and elimination forms, and perhaps a few mergers can also take place. -- Don From bulat.ziganshin at gmail.com Mon Jul 14 13:30:06 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jul 14 13:19:15 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <20080714171919.GB23666@scytale.galois.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714171919.GB23666@scytale.galois.com> Message-ID: <131554255.20080714213006@gmail.com> Hello Don, Monday, July 14, 2008, 9:19:19 PM, you wrote: > An abstraction stack: it would be great to document these things on wiki like we've documented old arrays -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From westondan at imageworks.com Mon Jul 14 13:40:02 2008 From: westondan at imageworks.com (Dan Weston) Date: Mon Jul 14 13:31:58 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays In-Reply-To: <90889fe70807130141y466e422fie1525b4e13500b5e@mail.gmail.com> References: <20080711221333.GB14364@scytale.galois.com> <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> <20080712221650.GC17008@scytale.galois.com> <90889fe70807130141y466e422fie1525b4e13500b5e@mail.gmail.com> Message-ID: <487B8F72.4030206@imageworks.com> Slides, plus an audio recording of the talk would be great. With that, we could follow along easily. Johan Tibell wrote: > On Sun, Jul 13, 2008 at 12:16 AM, Don Stewart wrote: >> johan.tibell: >>> On Sat, Jul 12, 2008 at 12:13 AM, Don Stewart wrote: >>> Any possibility of you guys taping the talk? >> Unlikely next week, but soon, yes! > > How about the slides? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dons at galois.com Mon Jul 14 13:42:25 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 14 13:32:56 2008 Subject: [Haskell-cafe] Galois Tech Talks: Stream Fusion for Haskell Arrays In-Reply-To: <487B8F72.4030206@imageworks.com> References: <20080711221333.GB14364@scytale.galois.com> <90889fe70807111526l42def894w12617ab13eee3c61@mail.gmail.com> <20080712221650.GC17008@scytale.galois.com> <90889fe70807130141y466e422fie1525b4e13500b5e@mail.gmail.com> <487B8F72.4030206@imageworks.com> Message-ID: <20080714174225.GC23666@scytale.galois.com> westondan: > Slides, plus an audio recording of the talk would be great. With that, > we could follow along easily. > > Johan Tibell wrote: > >On Sun, Jul 13, 2008 at 12:16 AM, Don Stewart wrote: > >>johan.tibell: > >>>On Sat, Jul 12, 2008 at 12:13 AM, Don Stewart wrote: > >>>Any possibility of you guys taping the talk? > >>Unlikely next week, but soon, yes! > > > >How about the slides? Slides will certainly be provided. We've not yet sorted out the audio/visual set up in the new office, but it will follow in good time. -- Don From nbloomf at gmail.com Mon Jul 14 14:00:22 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Mon Jul 14 13:50:55 2008 Subject: [Haskell-cafe] A question about algebra and dependent typing Message-ID: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> There's something I want to do with Haskell, and after tinkering for a while I think it's not possible. Before giving up entirely, I thought I'd try this mailing list. I'm working on an abstract algebra library, using the "types are sets" strategy. For the algebraists out there, I'm trying to implement as much as I can of "Abstract Algebra" by Dummit & Foote in Haskell. I've got a Ring class definition that looks approximately like > class Ring t where > (<+>) :: t -> t -> t > (<*>) :: t -> t -> t > neg :: t -> t > zero :: t So, for example, we can say >instance Ring Integer where > (<+>) = (+) > (<*>) = (*) > neg = negate > zero = 0 >From here I can subclass to domains, PIDs, EDs, UFDs, fields, et cetera, and write some useful algorithms in great generality. The ring R[x] can be modeled by the type [r], direct products are tuples, and fractions in the domain r have type Fraction r. I can even model the set (i.e. type) of nxn matrices over a ring using type-level integers as demonstrated in the paper "Number-Parameterized Types" by Oleg Kiselyov [1]. All good stuff. However, I'm running into problems modeling some other useful and computationally interesting things, in particular adjoining an algebraic element and taking a quotient by an ideal. For example, I've tried the following (using GHC extensions): >class (Ring r) => Ideal i r | i -> r > >data (Ring r) => FinGenIdeal r = Ideal [r] > >instance (Ring r) => Ideal (FinGenIdeal r) r > >data (Ring r, Ideal i r) => Coset r i = r :+: i But of course I can't say >instance (Ring r, Ideal i r) => Ring (Coset r i) where > (r :+: i) <+> (s :+: j) = (r <+> s) :+: i > zero = zero :+: ? > ... It shouldn't make sense to add 2 :+: Ideal [3] and 3 :+: Ideal [5], for example, and zero is ambiguous. This problem happems because Ideal [3] and Ideal [5] have the same type, namely FinGenIdeal Integer. I am pretty new to Haskell and type theory, but I think what I'm wanting is dependent types. So, for instance, the type of Coset r i is parameterized by an particular value in FinGenIdeal r. Is there another way around this? I'm sure there is some sophisticated type-fu one could perform (similar to the examples in [1]) to construct ideals of integers, tuples of integers, et cetera, but this would quickly get unwieldy and sacrifices some generality. I have heard lots of praise of GADT as an approximation to dependent types, but I don't yet see how they could apply in this situation. Has anyone else encountered a similar problem, and if so, how did you get around it? Would I be better off working in a dependently-typed language like Agda? [1] - http://okmij.org/ftp/papers/number-parameterized-types.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080714/206f449f/attachment.htm From sk at k-hornz.de Mon Jul 14 14:10:24 2008 From: sk at k-hornz.de (stefan kersten) Date: Mon Jul 14 14:02:25 2008 Subject: [Haskell-cafe] vector vs uvector In-Reply-To: <487B7A5F.7090109@qseep.net> References: <487B7A5F.7090109@qseep.net> Message-ID: <677C49A0-564C-4DC4-9333-ABF334077786@k-hornz.de> On 14.07.2008, at 18:10, Lyle Kopnicky wrote: > You should use the most mature and stable package, which is of > course, uvector, being a whole 0.0.0.1 versions past vector. oops, didn't notice the thread announcing vector. i'll stick with uvector then for the time being :) From dons at galois.com Mon Jul 14 14:39:35 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 14 14:30:07 2008 Subject: [Haskell-cafe] Sphinx full-text searching client on Hackage In-Reply-To: <5C5DB7A5-4554-4AA1-85E2-8A7226FEDE83@eidhof.nl> References: <5C5DB7A5-4554-4AA1-85E2-8A7226FEDE83@eidhof.nl> Message-ID: <20080714183935.GE23666@scytale.galois.com> chris: > The communication with Sphinx is done using a quite low-level binary > protocol, but Data.Binary saved the day: it made it very easy for us > to parse all the binary things. Especially the use of the Get and Put > monads are a big improvement over the manual reading and keeping track > of positions, as is done in the PHP/Python clients. That's great news! -- Don From dons at galois.com Mon Jul 14 14:48:51 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 14 14:39:19 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> Message-ID: <20080714184851.GH23666@scytale.galois.com> sk: > On 14.07.2008, at 18:42, Jules Bean wrote: > >>It would be helpful to see the programs people are writing with > >>uvector, > >>so I can polish up the API some more :) > > > >It would also be helpful to have someone explain why we have: > > > >Ptr a > >ByteString > >IOUArray > >IOCArray > >Data.Storable.StorableArray > >UArr > > > >Of course, I know the answers to some of those questions, > >ByteString is obviously less polymorphic than all the others there, > >and Ptr a doesn't contain size information. But it seems we have a > >rapidly bifurcating profusion of 'typed interfaces to chunks of > >memory' with no obvious consistency to their naming scheme and I > >think it's starting to get confusing... > > maybe it would be useful to look at (1) what's expected in terms of > the underlying array implementation and (2) in terms of array access. > > (1) some things that come to mind: > > * ghc heap or system heap (can the garbage collector move memory > during calls to C?) > * access to a Ptr for interfacing to external libraries (possible > with UArr?) > * alignment (most SIMD instruction sets require 16 byte aligned data) > * mutability > * strict vs (partially) lazy > > (2) personally i much prefer the list-like interface provided by the > stream-fusion powered libraries (ndp, uvector, vector). can't the > stream-fusion framework and correspondingly the vector interface be > separated from the memory representation, provided a particular > concrete representation comes up with a stream/unstream pair? then it > would be easy to swap out the underlying representation according to > the required characteristics. Yes, we have long been discussing a generic Stream library to which the various sequence structures can be translated to and from. Already it is useful to say, stream bytestrings into uvectors and out to lists. If people are using uvector or stream-fusion (the list version) and are interested in interop please let Roman, Duncan and I know, so we can think more about how best to make it all play together. -- Don From lemming at henning-thielemann.de Mon Jul 14 16:08:33 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jul 14 15:59:02 2008 Subject: [Haskell-cafe] A question about algebra and dependent typing In-Reply-To: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> References: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> Message-ID: On Mon, 14 Jul 2008, Nathan Bloomfield wrote: > There's something I want to do with Haskell, and after tinkering for a while > I think it's not possible. Before giving up entirely, I thought I'd try this > mailing list. > > I'm working on an abstract algebra library, using the "types are sets" > strategy. For the algebraists out there, I'm trying to implement as much as > I can of "Abstract Algebra" by Dummit & Foote in Haskell. I've got a Ring > class definition that looks approximately like It follows my usual pointer to NumericPrelude where some algebraic structures are implemented including residue classes. However a quotient by a general ideal is missing. http://darcs.haskell.org/numericprelude/src/Number/ResidueClass/Func.hs http://hackage.haskell.org/cgi-bin/hackage-scripts/package/numeric-prelude From lists at qseep.net Mon Jul 14 16:22:26 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Mon Jul 14 16:14:42 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <20080714184851.GH23666@scytale.galois.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714184851.GH23666@scytale.galois.com> Message-ID: <487BB582.4050209@qseep.net> Don Stewart wrote: > > Yes, we have long been discussing a generic Stream library to which > the various sequence structures can be translated to and from. Already > it is useful to say, stream bytestrings into uvectors and out to lists. > Isn't there already such a thing? http://www.haskell.org/haskellwiki/Library/Streams - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080714/2a571c08/attachment.htm From dons at galois.com Mon Jul 14 16:32:00 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 14 16:22:32 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <487BB582.4050209@qseep.net> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714184851.GH23666@scytale.galois.com> <487BB582.4050209@qseep.net> Message-ID: <20080714203200.GI23666@scytale.galois.com> lists: > Don Stewart wrote: > > Yes, we have long been discussing a generic Stream library to which > the various sequence structures can be translated to and from. Already > it is useful to say, stream bytestrings into uvectors and out to lists. > > > Isn't there already such a thing? > > [1]http://www.haskell.org/haskellwiki/Library/Streams Not those kind of streams (Wouter!! :) These kind, http://www.cse.unsw.edu.au/~dons/papers/CLS07.html -- Don From claus.reinke at talk21.com Mon Jul 14 16:34:40 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Jul 14 16:25:15 2008 Subject: [Haskell-cafe] A question about algebra and dependent typing References: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> Message-ID: <798f01c8e5f1$0da0f330$743b8351@cr3lt> > I'm working on an abstract algebra library, using the "types are sets" > strategy. For the algebraists out there, I'm trying to implement as much as > I can of "Abstract Algebra" by Dummit & Foote in Haskell. I've got a Ring > class definition that looks approximately like You might find this interesting: @inproceedings{ fokker95explaining, author = "Jeroen Fokker", title = "Explaining Algebraic Theory with Functional Programs", booktitle = "Functional Programming Languages in Education", pages = "139-158", year = "1995", url = "citeseer.ist.psu.edu/fokker95explaining.html" } Claus From derek.a.elkins at gmail.com Mon Jul 14 17:58:06 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Jul 14 17:48:37 2008 Subject: [Haskell-cafe] A question about algebra and dependent typing In-Reply-To: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> References: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> Message-ID: <1216072686.5818.24.camel@derek-laptop> On Mon, 2008-07-14 at 13:00 -0500, Nathan Bloomfield wrote: > There's something I want to do with Haskell, and after tinkering for a > while I think it's not possible. Before giving up entirely, I thought > I'd try this mailing list. > > I'm working on an abstract algebra library, using the "types are sets" strategy. For the algebraists out there, I'm trying to implement as much as I can of "Abstract Algebra" by Dummit & Foote in Haskell. I've got a Ring class definition that looks approximately like > ?I haven't read most of the rest of this email, but you might want to look at Serge Mechveliani's DoCon library if you haven't already: http://www.haskell.org/docon/ > From rl at cse.unsw.edu.au Mon Jul 14 23:22:35 2008 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Mon Jul 14 23:13:35 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <487B8200.1020901@jellybean.co.uk> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> Message-ID: <487C17FB.7090903@cse.unsw.edu.au> Jules Bean wrote: > > It would also be helpful to have someone explain why we have: > > Ptr a > ByteString > IOUArray > IOCArray > Data.Storable.StorableArray > UArr > > Of course, I know the answers to some of those questions, ByteString is > obviously less polymorphic than all the others there, and Ptr a doesn't > contain size information. But it seems we have a rapidly bifurcating > profusion of 'typed interfaces to chunks of memory' with no obvious > consistency to their naming scheme and I think it's starting to get > confusing... I think the main reason for this is the lack of a generic infrastructure for efficient arrays which means that everyone is rolling their own. My hope is that the Data Parallel Haskell project will eventually provide such an infrastructure (but I'm biased, of course). We need it anyway and we are perhaps in the best position to do it at the moment. Unfortunately, we don't have too much time to work on it so development is slow. Still, I think (obviously) that the vector library is a step in the right direction. Roman From rl at cse.unsw.edu.au Mon Jul 14 23:32:47 2008 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Mon Jul 14 23:23:22 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> Message-ID: <487C1A5F.7060705@cse.unsw.edu.au> stefan kersten wrote: > > (2) personally i much prefer the list-like interface provided by the > stream-fusion powered libraries (ndp, uvector, vector). can't the > stream-fusion framework and correspondingly the vector interface be > separated from the memory representation, provided a particular concrete > representation comes up with a stream/unstream pair? then it would be > easy to swap out the underlying representation according to the required > characteristics. The vector library does this. The problem is that just stream/unstream isn't sufficient to get good performance. In fact, stream fusion alone is suboptimal for many array algorithms since it can't handle array operations which require random access. In particular, it isn't enough for DPH. We need a more powerful framework which, hopefully, will also be useful for non-DPH arrays. Roman From carette at mcmaster.ca Mon Jul 14 21:03:10 2008 From: carette at mcmaster.ca (Jacques Carette) Date: Tue Jul 15 00:51:06 2008 Subject: [Haskell-cafe] A question about algebra and dependent typing In-Reply-To: <798f01c8e5f1$0da0f330$743b8351@cr3lt> References: <9858b5620807141100s5eabc07bu823dbc6abc45149c@mail.gmail.com> <798f01c8e5f1$0da0f330$743b8351@cr3lt> Message-ID: <487BF74E.2080407@mcmaster.ca> Claus Reinke wrote: > You might find this interesting: > > @inproceedings{ fokker95explaining, > author = "Jeroen Fokker", > title = "Explaining Algebraic Theory with Functional Programs", > booktitle = "Functional Programming Languages in Education", > pages = "139-158", > year = "1995", > url = "citeseer.ist.psu.edu/fokker95explaining.html" } Extremely interesting, thank you. It also contains a very interesting remark (on p. 2), noting that one should have class Eq a => Monoid a where (<+>) :: a -> a -> a zero ::a And states "Because in the laws? the notion of equality is used, we have made Monoid a subclass of Eq". In hindsight, this is obvious, but is naively tempting to define a monoid without this constraint. And, indeed, Data.Monoid defines a Monoid class without an Eq constraint! So, what are monoids without equality in Haskell? There are rather interesting beasts: they are monoids for which we have a computable 0 (mempty) and a computable addition (mappend), but for which we cannot *witness* equality of the underlying carrier 'set'. This, for example, is the only way one can legitimately get an instance such as instance Monoid b => Monoid (a->b) While Haskell is used quite a lot for doing computable (or 'extensional') mathematics, intensionality sneaks in here and there -- and this is just one such example. I must admit, I actually don't yet know whether I prefer classical monoids or these generalized monoids where the laws are _purely_ intensional. Opinions? Jacques From jstrait at moonloop.net Tue Jul 15 02:46:27 2008 From: jstrait at moonloop.net (Jon Strait) Date: Tue Jul 15 02:47:32 2008 Subject: [Haskell-cafe] ANN: Launching Haskell Group in Vancouver, Canada Message-ID: <487C47C3.20902@moonloop.net> For those in Vancouver, a short announcement about the recently created Haskell Programmers Group and a meeting scheduled for next Monday, July 21st. http://groups.google.com/group/hugvan Future group announcements will be posted on this Google Groups site, so feel free to join the group list to be notified of future events or just show up to a meeting to bounce ideas and questions off of other Haskell programmers. Thanks, Jon From haskell at list.mightyreason.com Tue Jul 15 07:21:16 2008 From: haskell at list.mightyreason.com (Chris Kuklewicz) Date: Tue Jul 15 07:11:42 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers Message-ID: <487C882C.2030505@list.mightyreason.com> I have reached an impasse in designing a Haskell API for the google's protocol-buffers data language / format. ( http://code.google.com/apis/protocolbuffers/docs/overview.html ) The messages in protobuf are defined in a namespace that nests in the usual hierarchical OO style that Java encourages. To avoid namespace conflicts, I made a hierarchy of modules. But...this is a legal pair protobuf message definitions: > // Test that mutual recursion works. > message TestMutualRecursionA { > optional TestMutualRecursionB b = 1; > optional int32 content = 2; > } > > message TestMutualRecursionB { > optional TestMutualRecursionA a = 1; > optional int32 content = 2; > } And there is no way ghc can compile these in separate modules. But the overlap of record accessors names "content" makes defining these messages in a single module with a common namespace quite verbose. Any opinions on the least worst way to design this? -- Chris From batterseapower at hotmail.com Tue Jul 15 09:20:27 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue Jul 15 09:10:53 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487C882C.2030505@list.mightyreason.com> References: <487C882C.2030505@list.mightyreason.com> Message-ID: <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> > And there is no way ghc can compile these in separate modules. I may be being redundant here, but you may not know that GHC actually can compile mutually recursive modules. See http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#mutual-recursion . Of course, this is not a great solution either, as creating hs-boot files is a bit tedious, but at least the option is there. Cheers, Max From J.Burton at brighton.ac.uk Tue Jul 15 09:25:14 2008 From: J.Burton at brighton.ac.uk (J.Burton@brighton.ac.uk) Date: Tue Jul 15 09:15:35 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc Message-ID: <874p6r8ekl.wl%j.burton@brighton.ac.uk> I have a problem with applying a type constraint in the constructor of a GADT...I wrote some type level code for sets using empty types and fundeps, along the lines of Conrad Parker's Instant Insanity and Oleg's Lightweight Static Resources. At this level things works OK so I have empty types A, B ... Nil with an infix cons (:::) and fundeps determining constraints like Member, Disjoint etc. (Links to code at the end of message.) Then I can evaluate: > :t insert (undefined::A) (undefined:: A ::: Nil) insert (undefined::A) (undefined:: A ::: Nil) :: A ::: Nil But what I really want to do is wrap this up so that it can be used at runtime, not just in the type-checker, so that (just a sketch) I could have insert 'A' empty :: Set (A ::: Nil) where the runtime value of the set is fully determined by its type. I got some help with this and existential boxing seems to be the answer. I got a version that uses this strategy working OK until it comes to applying constraints (e.g. Member, needed when inserting an element). My problem is below. Here's one with no constraints that will type-check: ---------------------- {-box for labels -} data LBox = forall a. LBox (L a) {-box for sets of labels-} data LSetBox = forall t. LSetBox (LSet t) {-sets of labels -} data LSet t where Nil :: LSet Nil -- 'dumb' insertion Ins :: L a -> LSet t -> LSet (a ::: t) insert = Ins empty :: LSetBox empty = LSetBox Nil {-take a Char into a boxed LSet-} insertChar :: Char -> LSetBox -> LSetBox insertChar c (LSetBox s) = case fromChar c of LBox t -> LSetBox (insert t s) {-populate a box-} fromChar :: Char -> LBox fromChar 'A' = LBox AL {- ... B, etc -- use Template Haskell to generate alphabet and the various instances needed? -} fromChar _ = error "fromChar: bad Char" ------------------------ With some Show instances then I can evaluate > insertChar 'A' empty LSet {A,} But what about constraints on the Ins constructor, e.g. on insertion, ignore elements that are already there: --------------------- data LSet t where Nil :: LSet Nil --either add the new element or do nothing Ins :: (Member a t b , If b (LSet t) (LSet (a ::: t)) r) => L a -> LSet t -> r insert = Ins [...] class Member x ys b | x ys -> b where member :: x -> ys -> b instance Member x Nil F instance (Eq x y b', Member x ys m, If b' T m b) => Member x (y:::ys) b class If p x y z | p x y -> z where if' :: p -> x -> y -> z instance If T x y x instance If F x y y --------------------- But this evidently isn't the way to use fundeps -- here's the error: Malformed constructor result type: r In the result type of a data constructor: r In the data type declaration for `LSet' Failed, modules loaded: none. (The other place I tried putting the constraints is in the type of `insert' rather than the Ins constructor...) How can I express this constraint? BTW, I would rather be using type families for this, for forward compatibility and their greater generality, so if I can also get round this with them I'd love to know how... Thanks, and sorry for the long post! Jim [1] Purely type level version: http://jim.sdf-eu.org/TypeLevelSets2.hs [2] Interactive version using GADTs/Existential boxing: http://jim.sdf-eu.org/Set-July08.hs From jeff.polakow at db.com Tue Jul 15 09:43:40 2008 From: jeff.polakow at db.com (Jeff Polakow) Date: Tue Jul 15 09:34:13 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: <874p6r8ekl.wl%j.burton@brighton.ac.uk> Message-ID: Hello, > data LSet t where > Nil :: LSet Nil > --either add the new element or do nothing > Ins :: (Member a t b > , If b (LSet t) (LSet (a ::: t)) r) > => L a -> LSet t -> r > The constructor Ins needs to return an LSet. Maybe try replacing occurrences of r with (LSet r). -Jeff --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080715/ebb48b10/attachment.htm From J.Burton at brighton.ac.uk Tue Jul 15 09:49:09 2008 From: J.Burton at brighton.ac.uk (J.Burton@brighton.ac.uk) Date: Tue Jul 15 09:39:30 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: References: <874p6r8ekl.wl%j.burton@brighton.ac.uk> Message-ID: <873amb8dgq.wl%j.burton@brighton.ac.uk> At Tue, 15 Jul 2008 09:43:40 -0400, Jeff Polakow wrote: > Hello, Hi Jeff, > > > data LSet t where > > Nil :: LSet Nil > > --either add the new element or do nothing > > Ins :: (Member a t b > > , If b (LSet t) (LSet (a ::: t)) r) > > => L a -> LSet t -> r > > > The constructor Ins needs to return an LSet. Maybe try replacing occurrences of r with (LSet r). > I expected that r would be an LSet, as its the output of If which returns its 2nd or 3rd argument: class If p x y z | p x y -> z where if' :: p -> x -> y -> z instance If T x y x instance If F x y y Jim > -Jeff > > --- > > This e-mail may contain confidential and/or privileged information. If you > are not the intended recipient (or have received this e-mail in error) > please notify the sender immediately and destroy this e-mail. Any > unauthorized copying, disclosure or distribution of the material in this > e-mail is strictly forbidden. > > From jeff.polakow at db.com Tue Jul 15 10:02:23 2008 From: jeff.polakow at db.com (Jeff Polakow) Date: Tue Jul 15 09:52:52 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: <873amb8dgq.wl%j.burton@brighton.ac.uk> Message-ID: Hello, > > > data LSet t where > > > Nil :: LSet Nil > > > --either add the new element or do nothing > > > Ins :: (Member a t b > > > , If b (LSet t) (LSet (a ::: t)) r) > > > => L a -> LSet t -> r > > > > > The constructor Ins needs to return an LSet. Maybe try replacing > occurrences of r with (LSet r). > > > > I expected that r would be an LSet, as its the output of If which > returns its 2nd or 3rd argument: > > class If p x y z | p x y -> z > where if' :: p -> x -> y -> z > instance If T x y x > instance If F x y y > Type classes are open so there is nothing to prevent you from adding another instance for If, perhaps in a different module, which returns some arbitrary type. -Jeff --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080715/3e2c239c/attachment-0001.htm From J.Burton at brighton.ac.uk Tue Jul 15 10:23:42 2008 From: J.Burton at brighton.ac.uk (J.Burton@brighton.ac.uk) Date: Tue Jul 15 10:14:03 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: References: <873amb8dgq.wl%j.burton@brighton.ac.uk> Message-ID: <87r69vmdjl.wl%j.burton@brighton.ac.uk> At Tue, 15 Jul 2008 10:02:23 -0400, Jeff Polakow wrote: [...] > > > Type classes are open so there is nothing to prevent you from adding another > instance for If, perhaps in a different module, which returns some arbitrary > type. I see what you mean...so I tried to make Ins return an LSet of "something", like this: data LSet t where Nil :: LSet Nil Ins :: (Member a t b , If b t (a ::: t) r) => L a -> LSet t -> LSet r /home/jim/sdf-bzr/dsel/TF/Set-July08.hs:44:9: No instance for (If b t (a ::: t) r) arising from a use of `Ins' at /home/jim/sdf-bzr/dsel/TF/Set-July08.hs:44:9-11 Possible fix: add an instance declaration for (If b t (a ::: t) r) In the expression: Ins In the definition of `insert': insert = Ins /home/jim/sdf-bzr/dsel/TF/Set-July08.hs:68:6: Inferred type is less polymorphic than expected Quantified type variable `a' is mentioned in the environment: insert :: L a -> LSet t -> LSet r (bound at /home/jim/sdf-bzr/dsel/TF/Set-July08.hs:44:0) When checking an existential match that binds t :: L a The pattern(s) have type(s): LBox The body has type: LSetBox In a case alternative: LBox t -> LSetBox (insert t s) In the expression: case fromChar c of LBox t -> LSetBox (insert t s) Failed, modules loaded: none. > > -Jeff > > > --- > > This e-mail may contain confidential and/or privileged information. If you > are not the intended recipient (or have received this e-mail in error) > please notify the sender immediately and destroy this e-mail. Any > unauthorized copying, disclosure or distribution of the material in this > e-mail is strictly forbidden. > [2 ] > From jeff.polakow at db.com Tue Jul 15 10:27:59 2008 From: jeff.polakow at db.com (Jeff Polakow) Date: Tue Jul 15 10:18:28 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: <87r69vmdjl.wl%j.burton@brighton.ac.uk> Message-ID: Hello, > data LSet t where > Nil :: LSet Nil > Ins :: (Member a t b > , If b t (a ::: t) r) > => L a -> LSet t -> LSet r > Try replacing both original occurrences of r, i.e. (untested) Ins :: (Member a t b, If b t (a ::: t) (LSet r)) => L a -> LSet t -> LSet r -Jeff --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080715/a2661e1f/attachment.htm From haskell at list.mightyreason.com Tue Jul 15 10:43:39 2008 From: haskell at list.mightyreason.com (Chris Kuklewicz) Date: Tue Jul 15 10:34:15 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> Message-ID: <487CB79B.6020403@list.mightyreason.com> Ah, a teachable moment. One of us is not entirely correct about what GHC can do with this example. Hopefully I am wrong, but my experiments... Max Bolingbroke wrote: >> And there is no way ghc can compile these in separate modules. > > I may be being redundant here, but you may not know that GHC actually > can compile mutually recursive modules. See > http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#mutual-recursion > . Of course, this is not a great solution either, as creating hs-boot > files is a bit tedious, but at least the option is there. > > Cheers, > Max Consider these 3 files: A.hs: > module A(A) where > import B(B) > data A = A B B.hs > module B(B) where > import A(A) > data B = B A Main.hs > module Main where > import A > import B > main = return () There is no way to create a "A.hs-boot" file that has all of (1) Allows A.hs-boot to be compiled without compiling B.hs first (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after A.hs-boot (3) Allows A.hs to compiled after A.hs-boot with a consistent interface But this "Main2.hs" file works fine: > module Main where > data A = A B > data B = B A > main = return () But in "Main2.hs" I cannot define two record field accessors such as > data A = A { getName :: B} > data B = B { getName :: A} because there cannot be two different "getName" created in the same namespace. There is no way GHC can put the two field accessors in different module namespaces because their "data" types include mutual recursion. So I can choose one of (*) Ignore mutual recursion and make all such .proto specifications break (*) Autogenerate very verbose data type names and put them all in the same module to allow mutual recursion. And then either (**) Autogenerate even more verbose field accessor names (**) Define no field accessors and create some poor replacement, such as > class Field'Name a b | a ->b where > getName :: a -> b > setName :: a -> b -> a Cheers, Chris From haskell at list.mightyreason.com Tue Jul 15 10:47:12 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Jul 15 10:37:52 2008 Subject: [Haskell-cafe] Re: ANN: haskell-src-exts 0.3.5 In-Reply-To: References: Message-ID: Thanks for the fix. I have gotten the darcs version and I am compiling... Niklas Broberg wrote: > Hi all, > > I'm pleased to report that haskell-src-exts is now updated to > understand Template Haskell syntax (it used to understand pre-6.4 TH, > but now it works with the current version). At least I hope so, I > didn't have much TH code to try it on so if you find some bugs just > let me know. It wasn't all that hard to fix though, so I'm pretty > confident it actually works. > > Get the code: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts-0.3.5 > darcs get http://code.haskell.org/HSP/haskell-src-exts > > Cheers, > > /Niklas From lemming at henning-thielemann.de Tue Jul 15 10:54:34 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jul 15 10:45:03 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487CB79B.6020403@list.mightyreason.com> References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> <487CB79B.6020403@list.mightyreason.com> Message-ID: On Tue, 15 Jul 2008, Chris Kuklewicz wrote: > Consider these 3 files: > > A.hs: >> module A(A) where >> import B(B) >> data A = A B > > B.hs >> module B(B) where >> import A(A) >> data B = B A > > Main.hs >> module Main where >> import A >> import B >> main = return () Sooner or later you want generalize your datatypes. Then you can define data A b = A b and you do not need to import B any longer. I do not know if this is a generally applicable approach, but it helped me in some cases. There is still a problem with mutually recursive classes. In the one case where I had this problem, I could solve it the opposite way, namely by turning one type variable into a concrete type, which could represent all values one could represent with the variable type. From zunino at di.unipi.it Tue Jul 15 11:10:45 2008 From: zunino at di.unipi.it (Roberto Zunino) Date: Tue Jul 15 10:59:00 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487CB79B.6020403@list.mightyreason.com> References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> <487CB79B.6020403@list.mightyreason.com> Message-ID: <487CBDF5.8060601@di.unipi.it> Chris Kuklewicz wrote: > There is no way to create a "A.hs-boot" file that has all of > (1) Allows A.hs-boot to be compiled without compiling B.hs first > (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after > A.hs-boot > (3) Allows A.hs to compiled after A.hs-boot with a consistent interface I thought the following A.hs-boot would suffice: module A(A) where data A There's no need to provide the data constructors for type A. Does this violate any of the goals above? Regards, Zun. From s.clover at gmail.com Tue Jul 15 11:12:51 2008 From: s.clover at gmail.com (Sterling Clover) Date: Tue Jul 15 11:03:28 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487CB79B.6020403@list.mightyreason.com> References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> <487CB79B.6020403@list.mightyreason.com> Message-ID: What about generating the verbose accessor/single module code, and then creating a hierarchical module space as well, all importing your Base module, and reexporting the data types you want as well as less verbosely named accessor functions? Of course, this will break record update syntax, but maybe you could move to functional references instead -- given that you're generating all the code to begin with, autogenerating fref/lens style getter-setter pairs shouldn't be any more work. --Sterl On Jul 15, 2008, at 10:43 AM, Chris Kuklewicz wrote: > Ah, a teachable moment. One of us is not entirely correct about > what GHC can do with this example. Hopefully I am wrong, but my > experiments... > > Max Bolingbroke wrote: >>> And there is no way ghc can compile these in separate modules. >> I may be being redundant here, but you may not know that GHC actually >> can compile mutually recursive modules. See >> http://www.haskell.org/ghc/docs/latest/html/users_guide/separate- >> compilation.html#mutual-recursion >> . Of course, this is not a great solution either, as creating hs-boot >> files is a bit tedious, but at least the option is there. >> Cheers, >> Max > > Consider these 3 files: > > A.hs: >> module A(A) where >> import B(B) >> data A = A B > > B.hs >> module B(B) where >> import A(A) >> data B = B A > > Main.hs > > module Main where > > import A > > import B > > main = return () > > There is no way to create a "A.hs-boot" file that has all of > (1) Allows A.hs-boot to be compiled without compiling B.hs first > (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled > after A.hs-boot > (3) Allows A.hs to compiled after A.hs-boot with a consistent > interface > > But this "Main2.hs" file works fine: >> module Main where >> data A = A B >> data B = B A >> main = return () > > But in "Main2.hs" I cannot define two record field accessors such as > > data A = A { getName :: B} > > data B = B { getName :: A} > because there cannot be two different "getName" created in the same > namespace. > > There is no way GHC can put the two field accessors in different > module namespaces because their "data" types include mutual recursion. > > So I can choose one of > (*) Ignore mutual recursion and make all such .proto > specifications break > (*) Autogenerate very verbose data type names and put them all in > the same module to allow mutual recursion. And then either > (**) Autogenerate even more verbose field accessor names > (**) Define no field accessors and create some poor > replacement, such as > >> class Field'Name a b | a ->b where >> getName :: a -> b >> setName :: a -> b -> a > > > > Cheers, > Chris > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From scook0 at gmail.com Tue Jul 15 11:36:03 2008 From: scook0 at gmail.com (Stuart Cook) Date: Tue Jul 15 11:26:42 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> <487CB79B.6020403@list.mightyreason.com> Message-ID: <49b351060807150836i195a9154t8d823c080dda74eb@mail.gmail.com> On Wed, Jul 16, 2008 at 12:54 AM, Henning Thielemann wrote: > Sooner or later you want generalize your datatypes. Then you can define > data A b = A b > and you do not need to import B any longer. I do not know if this is a > generally applicable approach, but it helped me in some cases. This only really works if it's "natural" for A to be polymorphic in b. Otherwise you end up with all sorts of irrelevant administrative type parameters polluting your signatures. (I recently had a similar problem with mutually recursive modules; I ended up deciding to write my program in not-Haskell instead, which made me a little sad.) Stuart From jefferson.r.heard at gmail.com Tue Jul 15 15:12:06 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Tue Jul 15 15:02:33 2008 Subject: [Haskell-cafe] Remote control of firefox through Haskell? Message-ID: <4165d3a70807151212k65c6b471lf2a72868322fd2bb@mail.gmail.com> Is there a library out there that will allow me to remote-control the firefox or mozilla browsers, e.g. change the current page, open a new tab? -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From rk at trie.org Tue Jul 15 15:24:06 2008 From: rk at trie.org (Rahul Kapoor) Date: Tue Jul 15 15:14:31 2008 Subject: [Haskell-cafe] Remote control of firefox through Haskell? In-Reply-To: <4165d3a70807151212k65c6b471lf2a72868322fd2bb@mail.gmail.com> References: <4165d3a70807151212k65c6b471lf2a72868322fd2bb@mail.gmail.com> Message-ID: Selenium (http://selenium.openqa.org/) might do what you want. The bindings were announced on this list a little while ago (http://tinyurl.com/se-bindings) On Tue, Jul 15, 2008 at 3:12 PM, Jefferson Heard wrote: > Is there a library out there that will allow me to remote-control the > firefox or mozilla browsers, e.g. change the current page, open a new > tab? > > -- > I try to take things like a crow; war and chaos don't always ruin a > picnic, they just mean you have to be careful what you swallow. > > -- Jessica Edwards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Tue Jul 15 16:03:52 2008 From: dons at galois.com (Don Stewart) Date: Tue Jul 15 15:54:21 2008 Subject: [Haskell-cafe] Remote control of firefox through Haskell? In-Reply-To: <4165d3a70807151212k65c6b471lf2a72868322fd2bb@mail.gmail.com> References: <4165d3a70807151212k65c6b471lf2a72868322fd2bb@mail.gmail.com> Message-ID: <20080715200352.GB27250@scytale.galois.com> jefferson.r.heard: > Is there a library out there that will allow me to remote-control the > firefox or mozilla browsers, e.g. change the current page, open a new > tab? Yeah, use the haskell selenium bindings, on hackage.haskell.org --- Don From jefferson.r.heard at gmail.com Tue Jul 15 16:04:39 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Tue Jul 15 15:55:04 2008 Subject: [Haskell-cafe] Remote control of firefox through Haskell? In-Reply-To: <20080715200352.GB27250@scytale.galois.com> References: <4165d3a70807151212k65c6b471lf2a72868322fd2bb@mail.gmail.com> <20080715200352.GB27250@scytale.galois.com> Message-ID: <4165d3a70807151304s2b20e434x5bfe38a3bdd15028@mail.gmail.com> Thanks, Rahul, Don. These work... From frantisek.kocun at gmail.com Tue Jul 15 16:29:33 2008 From: frantisek.kocun at gmail.com (fero) Date: Tue Jul 15 16:20:00 2008 Subject: [Haskell-cafe] CAL (OpenQuark) and enterprise In-Reply-To: <30961e500807091520nddba83l470255344fefcc61@mail.gmail.com> References: <18366397.post@talk.nabble.com> <404396ef0807091028r1101a388wee196276f795aadd@mail.gmail.com> <30961e500807091520nddba83l470255344fefcc61@mail.gmail.com> Message-ID: <18474222.post@talk.nabble.com> And what if writing new application? Has anybody experience with enterprise application in functional language? Is it really clearer? I can see a advantage in using Scala but it doesn't have some features from Haskell or CAL or requires more code to write. Or better has anybody experience with the same and functional language for JVM? And what about ORM (e.g. Hibernate)? And what about objects, they are stateful itself. And CRUD is a very common part of enterprise applications and I think it's easier in imperative style (client is declarative of course but it assigns values to fields). I am interested in ours opinions/experience in business logic (not any infrastructure or client stuff) for apps such as accounting/bank/insurance/document management... systems in functional languages. Sometimes the rules for these kind of apps is more complex that it seem to be and such systems are maintained for many years (some even decades) so it needs to be readable. Rule engines are very popularized among java community now but I think many logic can be expressed clearer in functions. It is maybe useful for some kind of logic (e.g. calculate price with discounts) but for what I do I can write the same clearer in java that in rule engine (and much clearer in Haskell and I am only beginner. What will come after few years coding;). Miles Sabin wrote: > > On Wed, Jul 9, 2008 at 6:28 PM, Neil Mitchell > wrote: >> On the Haskell list I think its fair to say everyone recommends you >> should use Haskell. > > Not necessarily. If the OP has a significant body of existing Java > code (s)he has to work with (which is what the question suggests) then > Scala would most likely be a very good place to look. > > Cheers, > > > Miles > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/CAL-%28OpenQuark%29-and-enterprise-tp18366397p18474222.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From daniil.elovkov at googlemail.com Tue Jul 15 16:37:17 2008 From: daniil.elovkov at googlemail.com (Daniil Elovkov) Date: Tue Jul 15 16:27:45 2008 Subject: [Haskell-cafe] CAL (OpenQuark) and enterprise In-Reply-To: <18474222.post@talk.nabble.com> References: <18366397.post@talk.nabble.com> <404396ef0807091028r1101a388wee196276f795aadd@mail.gmail.com> <30961e500807091520nddba83l470255344fefcc61@mail.gmail.com> <18474222.post@talk.nabble.com> Message-ID: <487D0A7D.8060408@gmail.com> fero wrote: > And what if writing new application? Has anybody experience with enterprise > application in functional language? Is it really clearer? I can see a > advantage in using Scala but it doesn't have some features from Haskell or > CAL or requires more code to write. Or better has anybody experience with > the same and functional language for JVM? And what about ORM (e.g. > Hibernate)? And what about objects, they are stateful itself. And CRUD is a > very common part of enterprise applications and I think it's easier in > imperative style (client is declarative of course but it assigns values to > fields). I am interested in ours opinions/experience in business logic (not > any infrastructure or client stuff) for apps such as > accounting/bank/insurance/document management... systems in functional > languages. Sometimes the rules for these kind of apps is more complex that > it seem to be and such systems are maintained for many years (some even > decades) so it needs to be readable. Rule engines are very popularized among > java community now but I think many logic can be expressed clearer in > functions. It is maybe useful for some kind of logic (e.g. calculate price > with discounts) but for what I do I can write the same clearer in java that > in rule engine (and much clearer in Haskell and I am only beginner. What > will come after few years coding;). > You may start writing more obscure code. Look at this: http://www.willamette.edu/~fruehr/haskell/evolution.html This is humour, of course. > > Miles Sabin wrote: >> On Wed, Jul 9, 2008 at 6:28 PM, Neil Mitchell >> wrote: >>> On the Haskell list I think its fair to say everyone recommends you >>> should use Haskell. >> Not necessarily. If the OP has a significant body of existing Java >> code (s)he has to work with (which is what the question suggests) then >> Scala would most likely be a very good place to look. >> From m at ryangunter.com Tue Jul 15 16:59:32 2008 From: m at ryangunter.com (Mike Gunter) Date: Tue Jul 15 16:50:43 2008 Subject: [Haskell-cafe] Can't get Haddock 2.0 anchor reference to work Message-ID: <87wsjmeudn.fsf@c966553-A.attbi.com> How are anchor references in Haddock supposed to work? When I use "Dir.Mod#foo", the resulting HTML contains: instead of the more desirable: User error or bug? thanks, -m From john at repetae.net Tue Jul 15 17:34:47 2008 From: john at repetae.net (John Meacham) Date: Tue Jul 15 17:25:12 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487C882C.2030505@list.mightyreason.com> References: <487C882C.2030505@list.mightyreason.com> Message-ID: <20080715213447.GG24588@sliver.repetae.net> On Tue, Jul 15, 2008 at 12:21:16PM +0100, Chris Kuklewicz wrote: > I have reached an impasse in designing a Haskell API for the google's > The messages in protobuf are defined in a namespace that nests in the usual > hierarchical OO style that Java encourages. > > To avoid namespace conflicts, I made a hierarchy of modules. I wonder if this is the root of your issue, OO concepts don't map directly to haskell concepts a lot of the time. You may end up with some very atypical haskell code if you try to copy OO designs directly. John -- John Meacham - ?repetae.net?john? From pjdtech2000 at gmail.com Tue Jul 15 17:51:09 2008 From: pjdtech2000 at gmail.com (PJ Durai) Date: Tue Jul 15 17:41:32 2008 Subject: [Haskell-cafe] Linker problems linking FFI import call in Windows Message-ID: <4f712c6f0807151451p4fc68efoe2e7c2ad238745fe@mail.gmail.com> Greetings I am trying to import some functions from a windows DLL. I am getting strange errors. (This used to work with previous versions of GHC. 6.6 I think.). This is my import statement: foreign import stdcall "ace.h AdsConnect" adsConnect' :: CString -> Ptr CInt -> IO CInt This is the build output. C:\moonar>\bin\make.exe ghc --make -ffi main.hs -ffi adsapi.hs -optc -DWIN32 native.cpp -lace32 -L/hom e/pjdurai/dev/moonar -L/tmp/Advantage -o moonar.exe [1 of 2] Compiling AdsApi ( adsapi.hs, adsapi.o ) [2 of 2] Compiling Main ( main.hs, main.o ) Linking moonar.exe ... adsapi.o(.text+0x124):fake: undefined reference to `AdsConnect@8' adsapi.o(.text+0x260):fake: undefined reference to `AdsDisconnect@4' collect2: ld returned 1 exit status make: *** [main.exe] Error 1 It actually links without errors if I use 'ccall' instead of 'stdcall'. But the executable segfaults when the function is called. I had the same code working with 'stdcall' declaration a while ago. (With GCH 6.6 I think) I am using ghc-6.8.3 on Windows XP SP2. appreciate your time. thanks pj From gwern0 at gmail.com Tue Jul 15 17:50:59 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Jul 15 17:42:22 2008 Subject: [Haskell-cafe] Can't get Haddock 2.0 anchor reference to work In-Reply-To: <87wsjmeudn.fsf@c966553-A.attbi.com> References: <87wsjmeudn.fsf@c966553-A.attbi.com> Message-ID: <20080715215059.GA15962@craft> On 2008.07.15 13:59:32 -0700, Mike Gunter scribbled 0.2K characters: > > How are anchor references in Haddock supposed to work? > > When I use "Dir.Mod#foo", the resulting HTML contains: > > instead of the more desirable: > > > User error or bug? > > thanks, > -m For what it's worth, I've run into this issue with XMonad docs before. For example: has a line "See XMonad.Doc.Extending#Editing_key_bindings for instructions on how to edit your key bindings."; the source is "See "XMonad.Doc.Extending#Editing_key_bindings" for instructions on how to edit your key bindings." This links to . The source At least in Firefox, clicking only reloads the current page, and doesn't go down the several sections to the key binding information. (When I tried with my offline docs, it didn't even reload, just errored.) -- gwern Bess fritz Team espionage Blowfish Kosovo SIG LF ISPE Saudi -------------- 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/20080715/cec16c40/attachment.bin From jason.dusek at gmail.com Tue Jul 15 20:29:04 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Jul 15 20:19:29 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <20080715213447.GG24588@sliver.repetae.net> References: <487C882C.2030505@list.mightyreason.com> <20080715213447.GG24588@sliver.repetae.net> Message-ID: <42784f260807151729m209b5d0l50dc83a3ebb01c7b@mail.gmail.com> John Meacham wrote: > Chris Kuklewicz wrote: > > I have reached an impasse in designing a Haskell API for the > > google's The messages in protobuf are defined in a namespace > > that nests in the usual hierarchical OO style that Java > > encourages. > > > To avoid namespace conflicts, I made a hierarchy of modules. > > I wonder if this is the root of your issue, OO concepts don't > map directly to haskell concepts a lot of the time. You may > end up with some very atypical haskell code if you try to copy > OO designs directly. What do you think is a good approach to a protocol buffer parser generator? -- _jsn From mad.one at gmail.com Tue Jul 15 20:45:18 2008 From: mad.one at gmail.com (Austin Seipp) Date: Tue Jul 15 20:35:47 2008 Subject: [Haskell-cafe] Getting latest GHC-head/libraries takes forever Message-ID: <1216167949-sup-6673@existential.local> For the purpose of experimenting with NDP I went through the process of getting the GHC head from darcs.haskell.org. As specified in the developer wiki[1], using darcs get is basically not possible because there're so many patches. So I downloaded http://darcs.haskell.org/ghc-HEAD-2008-06-06-ghc-corelibs-testsuite.tar.bz2 This alone took over *7 hours* using wget because it could never get a connection faster than 5kb/s. After downloading I changed to the directory and ran 'darcs pull -a'. Nothing bad happened here, darcs pulled most of the changes pretty quick so I had an up to date GHC. However, when trying to use the ./darcs-all script to pull in the latest library/testsuite changes, things go horribly, horribly wrong. I let darcs sit for over another hour and a half trying to pull patches from darcs.haskell.org for the libraries and the testsuite. It never got past packages/base. In fact, it never even got to *getting* the patches from the base repository, it sat there, stuck at the 'identifying repository' stage (darcs 2.0.2) for over an hour, making my processor go round and round at 99% CPU usage the entire way, never accomplishing anything. What makes it even stranger is that it got the latest patches for the testsuite and the array package pretty quick. It just got permanently stuck on base for some reason and never went further. Also, I tried pulling package-ndp a few days ago while using an older development snapshot of GHC (not the darcs repository, a nightly HEAD tarball of ghc.) Just pulling 500 patches from http://darcs.haskell.org/packages/ndp took over an hour, but at least it got done. It didn't build properly so I thought I'd get the latest darcs version of GHC instead, and here I am. Has anybody experienced anything like this recently? Off the top of my head the only things that possibly come to mind are: 1) darcs.haskell.org is just really slow or under -constant- heavy load. 2) the darcs repositories are in darcs-1 format, so darcs-2 is having issues when trying to pull the patches. 3) Diabolical connection-killing ninjas. None of these 3 possibilities are really 'great,' and none of them help me get the latest version of GHC, the libs, and NDP any faster then a narcoleptic snail. If instead this is a techincal issue with, say, darcs that someone is aware of, I'm using OS X Leopard, 10.5.4 with a statically linked darcs-2.0.2 binary from [2]. [1] http://hackage.haskell.org/trac/ghc/wiki/Building/GettingTheSources [2] http://wiki.darcs.net/DarcsWiki/CategoryBinaries#head-25c8108e9d719be30a8cc6bcc86ce243a78b8c25 From allbery at ece.cmu.edu Tue Jul 15 20:54:46 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Jul 15 20:45:13 2008 Subject: [Haskell-cafe] Getting latest GHC-head/libraries takes forever In-Reply-To: <1216167949-sup-6673@existential.local> References: <1216167949-sup-6673@existential.local> Message-ID: On 2008 Jul 15, at 20:45, Austin Seipp wrote: > For the purpose of experimenting with NDP I went through the > process of getting the GHC head from darcs.haskell.org. As > specified in the developer wiki[1], using darcs get is basically > not possible because there're so many patches. So I downloaded > > http://darcs.haskell.org/ghc-HEAD-2008-06-06-ghc-corelibs-testsuite.tar.bz2 > > This alone took over *7 hours* using wget because it could never get > a connection faster than 5kb/s. FWIW I did manage to get it using darcs (!) having not checked the wiki to see that it was supposedly impossible these days. (Well, I did get --partial. --all is a definite mistake.) > I let darcs sit for over another hour and a half trying to pull > patches > from darcs.haskell.org for the libraries and the testsuite. > > It never got past packages/base. In fact, it never even got to > *getting* the > patches from the base repository, it sat there, stuck at the > 'identifying repository' > stage (darcs 2.0.2) for over an hour, making my processor go round > and round at > 99% CPU usage the entire way, never accomplishing anything. What > makes it even stranger > is that it got the latest patches for the testsuite and the array > package pretty quick. > It just got permanently stuck on base for some reason and never went > further. Mine stopped at array. That said, it does seem really slow; given your comment about downloading, this sounds like a problem with darcs.haskell.org in general. But it might be worth grabbing darcs1 for Leopard and trying again. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From duncan.coutts at worc.ox.ac.uk Tue Jul 15 21:02:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jul 15 20:54:20 2008 Subject: [Haskell-cafe] Getting latest GHC-head/libraries takes forever In-Reply-To: <1216167949-sup-6673@existential.local> References: <1216167949-sup-6673@existential.local> Message-ID: <1216170140.6279.101.camel@localhost> On Tue, 2008-07-15 at 19:45 -0500, Austin Seipp wrote: > For the purpose of experimenting with NDP I went through the > process of getting the GHC head from darcs.haskell.org. As > specified in the developer wiki[1], using darcs get is basically > not possible because there're so many patches. So I downloaded > > http://darcs.haskell.org/ghc-HEAD-2008-06-06-ghc-corelibs-testsuite.tar.bz2 > > This alone took over *7 hours* using wget because it could never get > a connection faster than 5kb/s. darcs.haskell.org is still being throttled. The server move means the machine itself has more bandwidth but the apache http server is still configured to limit connection speed. I believe this is supposed to change at some point but I don't know when. I've no idea about what's going on with darcs though. I know there are some issues with case-insensitive file systems or as you speculate it might be a darcs 1 vs 2 issue. Ask a darcs expert. Duncan From nadine.and.henry at pobox.com Wed Jul 16 01:59:01 2008 From: nadine.and.henry at pobox.com (nadine.and.henry@pobox.com) Date: Wed Jul 16 01:49:29 2008 Subject: [Haskell-cafe] Euler 201 performance mystery Message-ID: <18557.36389.527565.10329@exxor.localdomain> Dear Group, I've spend the last few days figuring out the solution to Euler Problem 201 in haskell. I first tried a relatively elegant approach based on Data.Map but the performance was horrible. I never actually arrived at the answer. I then rewrote the same algorithm using STUArrays and it was lightning. I have posted both versions of the code at: http://www.maztravel.com/haskell/euler_problem_201.html and would appreciate any insights that you master haskellers can provide on why the speed difference is so huge. Thanks in advance. Henry Laxen From olivier.boudry at gmail.com Wed Jul 16 02:38:33 2008 From: olivier.boudry at gmail.com (Olivier Boudry) Date: Wed Jul 16 02:29:00 2008 Subject: [Haskell-cafe] Linker problems linking FFI import call in Windows In-Reply-To: <4f712c6f0807151451p4fc68efoe2e7c2ad238745fe@mail.gmail.com> References: <4f712c6f0807151451p4fc68efoe2e7c2ad238745fe@mail.gmail.com> Message-ID: On Tue, Jul 15, 2008 at 11:51 PM, PJ Durai wrote: > I am trying to import some functions from a windows DLL. I am getting > strange errors. (This used to work with previous versions of GHC. 6.6 > I think.). You may have to create an import library for the DLL. I had a similar problem and solved it that way. Look at http://www.emmestech.com/moron_guides/moron1.html for advices on how to create such a library. My problem was that the exports in the dll were prefixed with an underscore. I had to remove them from the .def file before creating the import library. Best regards, Olivier. From frantisek.kocun at gmail.com Wed Jul 16 05:19:27 2008 From: frantisek.kocun at gmail.com (fero) Date: Wed Jul 16 05:09:56 2008 Subject: [Haskell-cafe] CAL (OpenQuark) and enterprise In-Reply-To: <487D0A7D.8060408@gmail.com> References: <18366397.post@talk.nabble.com> <404396ef0807091028r1101a388wee196276f795aadd@mail.gmail.com> <30961e500807091520nddba83l470255344fefcc61@mail.gmail.com> <18474222.post@talk.nabble.com> <487D0A7D.8060408@gmail.com> Message-ID: <18483627.post@talk.nabble.com> Nice:) Daniil Elovkov wrote: > > fero wrote: >> And what if writing new application? Has anybody experience with >> enterprise >> application in functional language? Is it really clearer? I can see a >> advantage in using Scala but it doesn't have some features from Haskell >> or >> CAL or requires more code to write. Or better has anybody experience with >> the same and functional language for JVM? And what about ORM (e.g. >> Hibernate)? And what about objects, they are stateful itself. And CRUD is >> a >> very common part of enterprise applications and I think it's easier in >> imperative style (client is declarative of course but it assigns values >> to >> fields). I am interested in ours opinions/experience in business logic >> (not >> any infrastructure or client stuff) for apps such as >> accounting/bank/insurance/document management... systems in functional >> languages. Sometimes the rules for these kind of apps is more complex >> that >> it seem to be and such systems are maintained for many years (some even >> decades) so it needs to be readable. Rule engines are very popularized >> among >> java community now but I think many logic can be expressed clearer in >> functions. It is maybe useful for some kind of logic (e.g. calculate >> price >> with discounts) but for what I do I can write the same clearer in java >> that >> in rule engine (and much clearer in Haskell and I am only beginner. What >> will come after few years coding;). >> > > You may start writing more obscure code. > > Look at this: > http://www.willamette.edu/~fruehr/haskell/evolution.html > > This is humour, of course. > >> >> Miles Sabin wrote: >>> On Wed, Jul 9, 2008 at 6:28 PM, Neil Mitchell >>> wrote: >>>> On the Haskell list I think its fair to say everyone recommends you >>>> should use Haskell. >>> Not necessarily. If the OP has a significant body of existing Java >>> code (s)he has to work with (which is what the question suggests) then >>> Scala would most likely be a very good place to look. >>> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/CAL-%28OpenQuark%29-and-enterprise-tp18366397p18483627.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From haskell at list.mightyreason.com Wed Jul 16 06:01:59 2008 From: haskell at list.mightyreason.com (Chris Kuklewicz) Date: Wed Jul 16 05:52:40 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487CBDF5.8060601@di.unipi.it> References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> <487CB79B.6020403@list.mightyreason.com> <487CBDF5.8060601@di.unipi.it> Message-ID: <487DC717.2000301@list.mightyreason.com> Thanks Roberto! Roberto Zunino wrote: > Chris Kuklewicz wrote: >> There is no way to create a "A.hs-boot" file that has all of >> (1) Allows A.hs-boot to be compiled without compiling B.hs first >> (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after >> A.hs-boot >> (3) Allows A.hs to compiled after A.hs-boot with a consistent interface > > I thought the following A.hs-boot would suffice: > > module A(A) where > data A > > There's no need to provide the data constructors for type A. Does this > violate any of the goals above? > > Regards, > Zun. I tried that experiment. The failure is complicated, and triggers be a ghc bug. Hmmm... the bug for > module A(A) where > data A > deriving Show using "ghc -c -XGeneralizedNewtypeDeriving A.hs-boot" is > A.hs-boot:2:0:ghc-6.8.3: panic! (the 'impossible' happened) > (GHC version 6.8.3 for powerpc-apple-darwin): > newTyConEtadRhs main:A.A{tc r5z} > > Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Is this a known bug? But now I see that > module A(A(..)) where > import B(B) > data A = A B | End > deriving Show > does work. And avoids the bug! -- Chris From apfelmus at quantentunnel.de Wed Jul 16 06:34:38 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Jul 16 06:25:15 2008 Subject: [Haskell-cafe] Re: Euler 201 performance mystery In-Reply-To: <18557.36389.527565.10329@exxor.localdomain> References: <18557.36389.527565.10329@exxor.localdomain> Message-ID: nadine.and.henry@pobox.com wrote: > Dear Group, > > I've spend the last few days figuring out the solution to Euler Problem 201 in > haskell. I first tried a relatively elegant approach based on Data.Map but > the performance was horrible. I never actually arrived at the answer. I then > rewrote the same algorithm using STUArrays and it was lightning. I have > posted both versions of the code at: > http://www.maztravel.com/haskell/euler_problem_201.html > and would appreciate any insights that you master haskellers can provide on > why the speed difference is so huge. Thanks in advance. > Henry Laxen First, you may want to change the map type to type SumMap = Map (Int,Int) Int since you're working with pairs (length, sum), not lists. I mean, you're doing the same with STUArray (Int,Int) Int . Did you try to estimate the running time of both data structures? Calculating the number of big-O operations on the back of an envelope is a very good guideline. So, Data.Map.insert takes O(log (size of map)) operations and so on. A rule of thumb is that a computer can perform 10 million "operations" per second (maybe 100, that was five years ago :)). Granted, this rule works best for C programs whereas Haskell is quite sensitive to constant factors, in particular concerning memory and cache effects. So, the rule is pretty accurate for an STUArray but you may have to multiply with 10 to get the right order of magnitude for Data.Map. As you have noted, the choice of data structure (Map, STUArray, something else) is important (Map only touches existing sums, but STUArray has O(1) access and uses a tight representation in memory). But in the following, I want to discuss something what you did implicitly, namely how to *calculate* the general algorithm in a mechanical fashion. This follows the lines of Richard Bird's work, of which the book "Algebra of Programming" http://web.comlab.ox.ac.uk/oucl/research/pdt/ap/pubs.html#Bird-deMoor96:Algebra is one of the cornerstones. The systematic derivation of dynamic programming algorithms has been rediscovered in a more direct but less general fashion in http://bibiserv.techfak.uni-bielefeld.de/adp/ Euler problem 201 asks to calculate the possible sums you can form with 50 elements from the set of square numbers from 1^2 to 100^2. Hence, given a function subsets [] = [[]] subsets (x:xs) = map (x:) (subsets xs) ++ subsets xs that returns all subsets of a set, we can implement a solution as follows: squares = map (^2) [1..100] euler201 = map sum . filter ((==50) . length) . subsets $ squares While hopelessly inefficient, this solution is obviously correct! In fact, we did barely more than write down the task. Ok ok, the solution is *not correct* because map sum may generate *duplicates*. In other words, subsets generates a lot of sets that have the same sum. But that's the key point for creating a better algorithm: we could be a lot faster if merging subsets with the same sum and generating these subsets could be interleaved. To that end, we first have to move the length filter to after the summation: map sum . filter ((==50) . length) = map snd . filter ((==50) . fst) . map (length &&& sum) The function (&&&) is very useful and defined as (length &&& sum) xs = (length xs, sum xs) You can import (a generalization of) of it from Control.Arrow. In other words, our solution now reads euler201 = map snd . filter ((==50) . fst) . subsums $ squares where subsums = map (length &&& sum) . subsets and our task is to find a definition of subsums that fuses summation and subset generation. But this is a straightforward calculation! Let's assume that we have an implementation of Sets that we can use for merging duplicates. In other words, we assume operations singleton :: a -> Set a union :: Set a -> Set a -> Set a map :: (a -> b) -> Set a -> Set b so that subsets becomes subsets [] = singleton [] subsets (x:xs) = map (x:) (subsets xs) `union` subsets xs Now, let's calculate: subsums [] = { definition } map (length &&& sum) (subsets []) = { subsets } map (length &&& sum) (singleton []) = { map } singleton ((length &&& sum) []) = { length &&& sum } singleton (0,0) subsums (x:xs) = { definition } map (length &&& sum) (subsets (x:xs)) = { subsets } map (length &&& sum) (map (x:) (subsets xs) `union` subsets xs) = { map preserves unions } map (length &&& sum) (map (x:) subsets xs) `union` map (length &&& sum) (subsets xs) = { map fusion } map (length &&& sum . (x:)) (subsets xs) `union` map (length &&& sum) (subsets xs) = { move (length &&& sum) to the front, see footnote } map ((\(n,s) -> (n+1,s+x)) . (length &&& sum)) (subsets xs) `union` map (length &&& sum) (subsets xs) = { reverse map fusion } map (\(n,s) -> (n+1,s+x)) (map (length &&& sum) (subsets xs)) `union` map (length &&& sum) (subsets xs) = { reverse definition of subsums } map (\(n,s) -> (n+1,s+x)) (subsums xs) `union` subsums xs In other words, we have now calculated the more efficient program euler201 = map snd . filter ((==50) . fst) . subsums $ squares where subsums [] = singleton (0,0) subsums (x:xs) = map (\(n,s) -> (n+1,s+x)) (subsums xs) `union` subsums xs Of course, we still need an efficient implementation for sets of (length, sum) pairs. Henry has already explored the two possibilities Set (Int,Int) and STUArray (Int,Int) a bit, but there are others, like IntMap Int [Int] or sorted lists. (Strictly speaking, Henry has explored something different but similar, what is it?). Regards, apfelmus Footnote: We still have to prove the identity (length &&& sum) . (x:) = (\(n,s) -> (n+1,s+x)) . (length &&& sum) I mean, you can figure this out in your head, but a formal calculation best proceeds with the two identities length . (x:) = (1+) . length -- definition of length sum . (x:) = (x+) . sum -- definition of sum and the observation (f &&& g) . h = (f . h &&& g . h) = (hf . f &&& hg . g) -- assuming hf . f = f . h and hg . g = g . h = (hg *** hf) . (f &&& g) where (***) is yet another handy function from Control.Arrow with the definition (f *** g) (x,y) = (f x, g y) From ganesh.sittampalam at credit-suisse.com Wed Jul 16 07:03:07 2008 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Wed Jul 16 06:54:39 2008 Subject: [Haskell-cafe] Mutually recursive modules and google protocol-buffers In-Reply-To: <487DC717.2000301@list.mightyreason.com> References: <487C882C.2030505@list.mightyreason.com> <9d4d38820807150620j254bc4dax8a8a0e3e1cbd9c25@mail.gmail.com> <487CB79B.6020403@list.mightyreason.com> <487CBDF5.8060601@di.unipi.it> <487DC717.2000301@list.mightyreason.com> Message-ID: <78A3C5650E28124399107F21A1FA419401D3B71C@ELON17P32002A.csfb.cs-group.com> Hi, > module A(A) where > data A > deriving Show I think you should use "instance Show A" rather than "deriving Show". All the boot file needs to do is say that the instance exists, not explain how it is constructed. Cheers, Ganesh ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From apfelmus at quantentunnel.de Wed Jul 16 08:33:16 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Jul 16 08:23:53 2008 Subject: [Haskell-cafe] Re: Strange space leak In-Reply-To: <18444159.post@talk.nabble.com> References: <18439685.post@talk.nabble.com> <18444159.post@talk.nabble.com> Message-ID: Grzegorz Chrupala wrote: >> >> split "" . words . map toLower = (:[]) . words . map toLower >> >> Since you converted everything to lowercase, the string "" will >> never appear in the text, resulting in a single huge document. >> > > Oops, that should have been obvious, sorry for the dumb question. > Thanks, No problem, it was not obvious to me and I had fun trying to figure it out :) Regards, apfelmus From dokondr at gmail.com Wed Jul 16 08:41:16 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Wed Jul 16 08:31:40 2008 Subject: [Haskell-cafe] win32: haddock: internal Haddock or GHC error? Message-ID: <53396d9e0807160541q44a02f02m6ffd1c30edcb83f7@mail.gmail.com> Using GHC 6.8.2 and haddock 2.0.0.0. in WinXP (SP3) I am trying to follow instructions from "How to write a Haskell program ". Everything goes well, until I try to generate html documentation for the project. Then I get the following errors: C:\wks\haq>runhaskell Setup.lhs haddock --executables Preprocessing executables for haq-0.0... Running Haddock for haq-0.0... Preprocessing executables for haq-0.0... Warning: Cannot read C:/usr/ghc-6.8.2/doc/libraries/base\base.haddock: "Magic number mismatch: couldn't load interface file: C:/usr/ghc-6.8.2/doc/li braries/base\\base.haddock" Skipping this interface. Warning: main:Main: could not find link destinations for: GHC.IOBase.IO haddock: internal Haddock or GHC error: c:/builds/haddock-2/install\haddock-2.0. 0.0/html/haddock.css: openFile: does not exist (No such file or directory) Any ideas how to solve this? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080716/6e431122/attachment.htm From ndmitchell at gmail.com Wed Jul 16 08:45:43 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Jul 16 08:36:06 2008 Subject: [Haskell-cafe] win32: haddock: internal Haddock or GHC error? In-Reply-To: <53396d9e0807160541q44a02f02m6ffd1c30edcb83f7@mail.gmail.com> References: <53396d9e0807160541q44a02f02m6ffd1c30edcb83f7@mail.gmail.com> Message-ID: <404396ef0807160545ya91e668h97aebd292f3c8fed@mail.gmail.com> Hi Dmitri, How did you obtain Haddock 2.0? Did you download it off hackage and install it, using the standard cabal bits? Can you also do runhaskell Setup configure -v, so we can see which Haddock Cabal is attempting to use. Thanks Neil > C:\wks\haq>runhaskell Setup.lhs haddock --executables > Preprocessing executables for haq-0.0... > Running Haddock for haq-0.0... > Preprocessing executables for haq-0.0... > Warning: Cannot read > C:/usr/ghc-6.8.2/doc/libraries/base\base.haddock: > "Magic number mismatch: couldn't load interface file: > C:/usr/ghc-6.8.2/doc/li > braries/base\\base.haddock" > Skipping this interface. > Warning: main:Main: could not find link destinations for: > GHC.IOBase.IO > haddock: internal Haddock or GHC error: > c:/builds/haddock-2/install\haddock-2.0. > 0.0/html/haddock.css: openFile: does not exist (No such file or directory) > > Any ideas how to solve this? > Thanks! > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dokondr at gmail.com Wed Jul 16 08:56:48 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Wed Jul 16 08:47:12 2008 Subject: [Haskell-cafe] win32: haddock: internal Haddock or GHC error? In-Reply-To: <404396ef0807160545ya91e668h97aebd292f3c8fed@mail.gmail.com> References: <53396d9e0807160541q44a02f02m6ffd1c30edcb83f7@mail.gmail.com> <404396ef0807160545ya91e668h97aebd292f3c8fed@mail.gmail.com> Message-ID: <53396d9e0807160556t669402b7r496464cda9993428@mail.gmail.com> Neil, Thanks for the quick response! I got haddock from its site ( http://haskell.org/haddock/#Download )using the link that says: "Windows: a binary distribution is available, just unzip and go. " My configuration: C:\wks\haq>runhaskell Setup.lhs configure -v Configuring haq-0.0... Dependency base-any: using base-3.0.1.0 Using compiler: ghc-6.8.2 Using install prefix: C:\Program Files\Haskell Binaries installed in: C:\Program Files\Haskell\bin Libraries installed in: C:\Program Files\Haskell\haq-0.0\ghc-6.8.2 Private binaries installed in: C:\Program Files\Haskell\haq-0.0 Data files installed in: C:\Program Files\Haskell\haq-0.0 Documentation installed in: C:\Program Files\Haskell\doc\haq-0.0 No alex found Using ar found on system at: C:\usr\ghc-6.8.2\bin\ar.exe No c2hs found No cpphs found No ffihugs found Using ghc version 6.8.2 found on system at: C:\usr\ghc-6.8.2\bin\ghc.exe Using ghc-pkg version 6.8.2 found on system at: C:\usr\ghc-6.8.2\bin\ghc-pkg.exe No greencard found Using haddock version 2.0.0.0 found on system at: C:\usr\haddock\haddock.exe No happy found No hmake found Using hsc2hs version 0.66-ghc found on system at: C:\usr\ghc-6.8.2\bin\hsc2hs.ex e No hscolour found No hugs found No jhc found Using ld found on system at: C:\usr\ghc-6.8.2\gcc-lib\ld.exe No nhc98 found No pfesetup found No pkg-config found No ranlib found No tar found On Wed, Jul 16, 2008 at 4:45 PM, Neil Mitchell wrote: > Hi Dmitri, > > How did you obtain Haddock 2.0? Did you download it off hackage and > install it, using the standard cabal bits? > > Can you also do runhaskell Setup configure -v, so we can see which > Haddock Cabal is attempting to use. > > Thanks > > Neil > > > > C:\wks\haq>runhaskell Setup.lhs haddock --executables > > Preprocessing executables for haq-0.0... > > Running Haddock for haq-0.0... > > Preprocessing executables for haq-0.0... > > Warning: Cannot read > > C:/usr/ghc-6.8.2/doc/libraries/base\base.haddock: > > "Magic number mismatch: couldn't load interface file: > > C:/usr/ghc-6.8.2/doc/li > > braries/base\\base.haddock" > > Skipping this interface. > > Warning: main:Main: could not find link destinations for: > > GHC.IOBase.IO > > haddock: internal Haddock or GHC error: > > c:/builds/haddock-2/install\haddock-2.0. > > 0.0/html/haddock.css: openFile: does not exist (No such file or > directory) > > > > Any ideas how to solve this? > > Thanks! > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080716/330ced1b/attachment.htm From carette at mcmaster.ca Wed Jul 16 09:03:10 2008 From: carette at mcmaster.ca (Jacques Carette) Date: Wed Jul 16 08:54:06 2008 Subject: [Haskell-cafe] Re: Strange space leak In-Reply-To: References: <18439685.post@talk.nabble.com> <18444159.post@talk.nabble.com> Message-ID: <487DF18E.30703@mcmaster.ca> apfelmus wrote: > Grzegorz Chrupala wrote: >>> >>> split "" . words . map toLower = (:[]) . words . map toLower >>> >>> Since you converted everything to lowercase, the string "" will >>> never appear in the text, resulting in a single huge document. >> >> Oops, that should have been obvious, sorry for the dumb question. >> Thanks, > > No problem, it was not obvious to me and I had fun trying to figure it > out :) Speaking of not obvious: Haskell's type system catches a lot of bugs -- but still gives no help with this particular 'problem'. But one can easily imagine an extension to a type system which could have detected that "" can never occur in the result of words . map toLower, and then with a bit more work [type-level Nat], the type of the full expression could have encoded that the result is always going to be of length 1. That would surely have been a good hint that something non-trivial was going on. Whether a Haskell-friendly type system extension could be created/implemented which would cover this example, I don't know. However, I have had a lot of fun with the underlying idea: anytime someone encounters a bug in their code (and relates the debugging story on haskell-cafe), try to imagine how the type system could be extended to automate that. In most cases, I don't mean to have the type system reject the code, but rather to have an inferred type that would make it obvious that the code did not behave as expected. Jacques From apfelmus at quantentunnel.de Wed Jul 16 09:34:27 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Jul 16 09:25:07 2008 Subject: [Haskell-cafe] Re: Euler 201 performance mystery In-Reply-To: References: <18557.36389.527565.10329@exxor.localdomain> Message-ID: apfelmus wrote: > In other words, we have now calculated the more efficient program > > euler201 = map snd . filter ((==50) . fst) . subsums $ squares > where > subsums [] = singleton (0,0) > subsums (x:xs) = map (\(n,s) -> (n+1,s+x)) (subsums xs) `union` subsums xs I forgot something very important, namely that the common subexpression subsums xs has to be shared euler201 = map snd . filter ((==50) . fst) . subsums $ squares where subsums [] = singleton (0,0) subsums (x:xs) = let s = subsums xs in map (\(n,s) -> (n+1,s+x)) s `union`s Otherwise, this exercise would be pointless and the runtime exponential ... :O Regards, apfelmus From sk at k-hornz.de Wed Jul 16 11:07:20 2008 From: sk at k-hornz.de (stefan kersten) Date: Wed Jul 16 10:58:04 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <20080714184851.GH23666@scytale.galois.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714184851.GH23666@scytale.galois.com> Message-ID: On 14.07.2008, at 20:48, Don Stewart wrote: > Yes, we have long been discussing a generic Stream library to which > the various sequence structures can be translated to and from. Already > it is useful to say, stream bytestrings into uvectors and out to > lists. could the Stream interface be made public in uvector for writing custom adapters? > If people are using uvector or stream-fusion (the list version) and > are interested in interop please let Roman, Duncan and I know, so we > can think more about how best to make it all play together. i'd be interested, just have to gather a little more infrastructure before i start working on real algorithms. From pjdtech2000 at gmail.com Wed Jul 16 12:22:46 2008 From: pjdtech2000 at gmail.com (PJ Durai) Date: Wed Jul 16 12:13:11 2008 Subject: [Haskell-cafe] Linker problems linking FFI import call in Windows In-Reply-To: References: <4f712c6f0807151451p4fc68efoe2e7c2ad238745fe@mail.gmail.com> Message-ID: <4f712c6f0807160922j6caea8c3wfdf638b148de08d3@mail.gmail.com> On 7/16/08, Olivier Boudry wrote: > On Tue, Jul 15, 2008 at 11:51 PM, PJ Durai wrote: > > I am trying to import some functions from a windows DLL. I am getting > > strange errors. (This used to work with previous versions of GHC. 6.6 > > I think.). > > You may have to create an import library for the DLL. I had a similar > problem and solved it that way. > > Look at http://www.emmestech.com/moron_guides/moron1.html for advices > on how to create such a library. > > My problem was that the exports in the dll were prefixed with an > underscore. I had to remove them from the .def file before creating > the import library. > I do have the import library. It came with the DLL. It links properly when I use CCALL on the haskell import statements. Doesnt link when I use STDCALL. It looks for function name with something like '@4 or @8' tacked on at the end. Not sure what that is all about. From steve at fenestra.com Wed Jul 16 12:26:31 2008 From: steve at fenestra.com (Steve Schafer) Date: Wed Jul 16 12:16:52 2008 Subject: [Haskell-cafe] Linker problems linking FFI import call in Windo ws In-Reply-To: <4f712c6f0807160922j6caea8c3wfdf638b148de08d3@mail.gmail.com> References: <4f712c6f0807151451p4fc68efoe2e7c2ad238745fe@mail.gmail.com> <4f712c6f0807160922j6caea8c3wfdf638b148de08d3@mail.gmail.com> Message-ID: <288s741ge516o5mad882pnbr8lrh0513e8@4ax.com> On Wed, 16 Jul 2008 10:22:46 -0600, you wrote: >I do have the import library. It came with the DLL. It links properly >when I use CCALL on the haskell import statements. Doesnt link when I >use STDCALL. It looks for function name with something like '@4 or >@8' tacked on at the end. Not sure what that is all about. This is known as name mangling. See the Wikipedia article for more info: http://en.wikipedia.org/wiki/Name_mangling Steve Schafer Fenestra Technologies Corp. http://www.fenestra.com/ From aneumann at inf.fu-berlin.de Wed Jul 16 15:17:05 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Wed Jul 16 15:07:41 2008 Subject: [Haskell-cafe] Fixed-Point Combinators Message-ID: Hello, while studying for a exam I came across this little pearl: Y = (L L L L L L L L L L L L L L L L L L L L L L L L L L L L) where L = ?abcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d p o i n t c o m b i n a t o r)) posted by Cale Gibbard to this list. Now I'm wondering how exactly does one finde such awesome ? expressions? Is there some mathemagical background that lets one conjure such beasts? Adrian -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080716/7cf606c3/PGP.bin From bulat.ziganshin at gmail.com Wed Jul 16 15:35:39 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 16 15:25:19 2008 Subject: [Haskell-cafe] Fixed-Point Combinators In-Reply-To: References: Message-ID: <1393441809.20080716233539@gmail.com> Hello Adrian, Wednesday, July 16, 2008, 11:17:05 PM, you wrote: > L = ?abcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d p o i n > t c o m b i n a t o r)) > does one finde such awesome ? expressions? Is there some mathemagical > background that lets one conjure such beasts? full search? :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From simonpj at microsoft.com Wed Jul 16 15:51:59 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Jul 16 15:42:26 2008 Subject: [Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly In-Reply-To: References: <6a7c66fc0807070830g2ed50625s1038b8f33e319609@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE759893D@EA-EXMSG-C334.europe.corp.microsoft.com> | > I myselft don't understand why GHCi doesn't accept the type it | > infered as an explicit signature ... I've known about this confusing behavior for some time, and the design goal that the compiler should not infer a type that it can't check seems Clearly Right. Stupidly, though, I had not previously realized that it's all a consequence of GHC's rather relaxed approach to ambiguity. Here's a little section from a some notes I'm working on that may clarify. Bottom line: I intend to change GHC (I hope for 6.10) so that if a definition gets an inferred type that could not appear as a type signature, the definition will be rejected as ambiguous. Comments welcome. (Do cc me since I no longer guarantee to read all of the wisdom of Haskell Caf?.) Simon Consider this \begin{code} class C a b where op :: b -> a -> a instance C [a] b op _ x = x instance Ord b => C (Maybe a) b op _ x = x f x = op undefined x \end{code} GHC currently infers the type \begin{code} f :: C a b => a -> a \end{code} Despite the fact that @b@ is not mentioned after the @=>@, nor is there a functional dependency, @f@ can be called unambiguously, thus \begin{code} f [True] \end{code} This call gives rise to the constraint @(C [Bool] b)@, for some undetermined type @b@, and the instance declaration fires happily. However, the call @(f Nothing)@ will give the constraint @(Ord b)@, which cannot be discharged without knowing @b@. Some calls are ambiguous and some are not. GHC defers this choice to the caller, unless it can readily see that every call will be ambiguous. However, this relaxed approach has a big disadvantage: \emph{you cannot write a type signature for @f@!}: \begin{code} f :: C a c => a -> a f x = op undefined x \end{code} Now GHC has no way to prove that the given constraint @(C a c)@ proves the wanted constraint @(C a b)@, using plain syntactic matching. So we propose the following: \begin{itemize} \item Every inferred type (and every type written by the programmer) must be unambiguous. \item A type $\forall \overline{a}.C \Rightarrow \rho$ is unambiguous iff from $C$ we can deduce $C[\overline{b'/b}]$ where $\overline{b} = \overline{a} \setminus fv(\rho)$, and $\overline{b'}$ are fresh. That is, freshen the variables in $C$ that are not mentioned in the type $\rho$, and check that you can can deduce the freshened $C'$ from $C$. \end{itemize} This would reject the definition @f@, either with or without a type signature. | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe- | bounces@haskell.org] On Behalf Of Pablo Nogueira | Sent: 08 July 2008 09:03 | To: Alfonso Acosta | Cc: Haskell-Cafe | Subject: Re: [Haskell-cafe] A type signature inferred by GHCi that is | rejected when written explicitly | | > I myselft don't understand why GHCi doesn't accept the type it | > infered as an explicit signature ... | | I think it has to do with the following: | | Looking at the type errors, they seem to indicate that the type | checker is being general and does not assume the |From| and |To| | "relations" are between | a type |t| and (s (t x) x)| but, in general, between |t| and |s (t' x) x|. | | Given that | | from :: (From a1 c1 x) => a1 x -> c1 x | to :: (To a2 c2 y) => c2 y -> a2 y | bimap :: Bifunctor s => (t1 -> t3) -> (t2 -> t4) -> s t1 t2 -> s t3 t4 | | During type checking the following equations spring up: | | c2 y = s t3 t4 | c1 x = s t1 t2 | t2 = x | t4 = y | t1 = a1 x | t3 = a2 y | | That'd give the same type as that inferred, but somehow new variables | |a11| and |a12| appear. | | > caused by a lack of functional dependencies. | > class From a c x | a -> c where | > class To a c y | c -> a where | > ... hushes GHCi. The question now is, of course, if the new | > dependencies are too restrictive for your problem. | | They are of little avail given the instances I define: | | instance Bifunctor s => From (Fix s) (s (Fix s x)) x where | from = out | | instance Bifunctor s => To (Fix s) (s (Fix s y)) y where | to = In | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From simonpj at microsoft.com Wed Jul 16 15:52:00 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Jul 16 15:42:39 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE7598940@EA-EXMSG-C334.europe.corp.microsoft.com> | Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007 | armv6l unknown | | I would love a working GHC implementation on it, if for nothing else | than how awesome it would be. Whether that means using a C back-end or | native compilation doesn't matter to me so much. | | I might be one to attempt this, as I know C and ARM-ish asm decently | well and have a powerful desktop to compile on. I have no familiarity | with GHC internals, though. Lastly, I won't have anything like the time | to attempt this seriously until mid-September or so. That's good. John Dias is hard at work on GHC's back end, and we should be in reasonable shape by mid Sept. Better still a month later... Keep us posted with what you do. Simon From noahaon at gmx.at Wed Jul 16 15:50:59 2008 From: noahaon at gmx.at (Thomas Fuhrmann) Date: Wed Jul 16 15:50:25 2008 Subject: [Haskell-cafe] curl installation Message-ID: Hello, I'm trying to install the curl package 1.3.2.1 for haskell, I'm using Ubuntu and I've already installed curl-7.18.2. I can't get rid of the configuration error. According to the log entry the curl.h doesn't exist. Shell output: runghc Setup.hs configure Configuring curl-1.3.2.1... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -E configure: error: curl libraries not found, so curl package cannot be built See `config.log' for more details. Part of Log entry: configure:2439: gcc -E conftest.c conftest.c:9:23: error: curl/curl.h: No such file or directory configure:2445: $? = 1 configure: failed program was: | /* confdefs.h. */ | | #define PACKAGE_NAME "Haskell curl package" | #define PACKAGE_TARNAME "curl" | #define PACKAGE_VERSION "1.1" | #define PACKAGE_STRING "Haskell curl package 1.1" | #define PACKAGE_BUGREPORT "dons@galois.com" | /* end confdefs.h. */ | #include configure:2469: error: curl libraries not found, s o curl package cannot be built See `config.log' for more details. Any ideas? From byorgey at seas.upenn.edu Wed Jul 16 16:13:54 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jul 16 16:04:18 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 77 - July 16, 2008 Message-ID: <20080716201354.GA5713@plus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080716 Issue 77 - July 16, 2008 --------------------------------------------------------------------------- Welcome to issue 77 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements Takusen 0.8.3. Alistair Bayley [2]announced the release of [3]Takusen 0.8.3, with ODBC support, more Cabal improvements, bug fixes, and some basic result-set validation. Launching Haskell Group in Vancouver, Canada. Jon Strait [4]announced that a [5]Haskell Programmers Group has been created in Vancouver; the first meeting is scheduled for next Monday, July 21st. Feel free to join the Google Groups list to be notified of future events, or just show up to a meeting to bounce ideas and questions off of other Haskell programmers. Sphinx full-text searching client on Hackage. Chris Eidhof [6]announced work on a [7]client for the [8]sphinx full-text search engine. Help hacking on it, testing it or improving documentation is welcome. haskell-src-exts 0.3.5. Niklas Broberg [9]announced that the [10]haskell-src-exts package is now updated to understand the current version of Template Haskell syntax. Bug reports welcome. Prime time for Haskell. Janis Voigtlaender [11]announced that Haskell STM is featured in an [12]article in this month's Communications of the ACM. vector 0.1 (efficient arrays with lots of fusion). Roman Leshchinskiy [13]announced an initial release of the [14]vector library, which will eventually provide fast, Int-indexed arrays with a powerful fusion framework. Galois Tech Talks: Stream Fusion for Haskell Arrays. Don Stewart [15]announced that he was giving this week's Galois Tech Talk, on stream fusion for Haskell arrays. The talk was yesterday, July 15, but hopefully some sort of recording or slides will be made available. protocol-buffers. Chris Kuklewicz [16]announced a very early version of the [17]protocol-buffers package, a Haskell interface to Google's newly released [18]data interchange format. GHC IRC meeting. Simon Marlow [19]announced the (first weekly?) IRC meeting to discuss GHC, a scheduled time when the developers turn up on #ghc, discuss current topics around GHC, and users can chime in with questions, points for discussion, complaints and so on. The first meeting took place on July 16 at 1600 BST (UTC +1)/0800 PDT (UTC-7)/1100 EDT (UTC-4), in the #ghc channel on chat.freenode.net; hopefully this will become a weekly event. Google Summer of Code Progress updates from participants in the 2008 [20]Google Summer of Code. GHC API. Thomas Schilling (nominolo) is working on [21]improvements to the GHC API. He recently [22]asked for comments on a proposed refactoring to the GHC API, creating a new Ghc monad to capture error handling and single-threaded use of Sessions. GHC plugins. Max Bolingbroke is working on dynamically loaded plugins for GHC. [23]This week, he wrote a ton of Haddock documentation for GHC internals. He also added the ability for compiler plugins to generate their own source annotations, to allow plugins to use intermediate results from previous plugins. He's currently working on an exciting, secret feature: tune in next week to find out what it is! Generic tries. Jamie Brandon is working on a library for efficient maps using generalized tries. Jamie is [24]currently working on, tweaking the [25]api, writing tests and writing reference implementations on sorted and unsorted association lists. Hoogle 4. Neil Mitchell (ndm) is working on [26]Hoogle 4. [27]This week, he worked on type search and database generation. Next week he plans to finish up type search and release and command-line version. Language.C. Benedikt Huber (visq) is [28]working on Language.C, a standalone parser/pretty printer library for C99. DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a [29]physics engine using [30]Data Parallel Haskell. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a [31]make-like dependency analysis framework for Cabal. Libraries Proposals and extensions to the [32]standard libraries. adding split to Data.List. Gwern Branwen [33]proposed adding some split-like functions to Data.List. Will they actually get added this time? Will people be able to agree on one of the seventeen possible sets of semantics? Tune in next time... Discussion GHC API: monad and error handling. Thomas Schilling [34]asked for comments on a proposed refactoring to the GHC API, creating a new Ghc monad to capture error handling and single-threaded use of Sessions. Jobs Research positions on Modeling and Analyzing Software Adaptation, University of Koblenz. Ralf Lammel [35]announced two research positions for a postdoc and a PhD student, available initially for 2 years. The successful applicants will work on the research theme of "ADAPT: Modeling and Analyzing Software Adaptation". The objective of [36]ADAPT is to relate, advance, combine, and challenge adaptation methods and associated methods of modeling and analyzing that are used by the communities of software engineering, programming languages, logic-based modeling, multi-agent systems, formal methods, SOA, web systems, and mobile, autonomous systems. Blog noise [37]Haskell news from the [38]blogosphere. * Real-World Haskell: [39]Real World Haskellers at OSCON next week. John Goerzen and Bryan O'Sullivan will be in Portland, Oregon next week for OSCON (along with Don Stewart, who lives in Portland). * Russell O'Connor: [40]ICFP 2008 Post-Mortem. * Brent Yorgey: [41]Call for an ICFP Mars Server. Will someone make a Mars Server where we can all submit our rovers and new maps, watch them compete, improve them, and generally have fun getting some feedback without bugging the organizing committee? Pretty please? * Jamie Brandon: [42]Week 5 progress. An update on Jamie's Google Summer of Code project. * Brent Yorgey: [43]ICFP programming contest reflections. * >>> Chris Bogart: [44]Help with study of functional programmers. Chris is doing a study as part of a research internship at Microsoft, and is seeking people currently working on a real project in a functional language whom he can observe as part of his study. * >>> eigenclass: [45]Quicksort erratum. A time and space analysis of a classic quicksort implementation in Haskell. * Ralf Lammel: [46]Research positions on Modeling and Analyzing Software Adaptation, University of Koblenz. * Max Bolingbroke: [47]Compiler Plugins For GHC: Week Five. An update on Max's Google Summer of Code project. * Luke Plant: [48]Haskell Blog Rewrite - Session 7. Luke documents setting up CentOS in VirtualBox VM in order to compile Haskell code for a server to which he does not have ssh access. Not for the faint of heart. * Chris Eidhof: [49]Stemming with Haskell. A [50]stemming library and [51]Sphinx client for Haskell. * >>> Duane Johnson: [52]Haskell is Popular on IRC. The large amount of community participation and academic brainshare gives Duane a lot of confidence in Haskell. * >>> Mike Harris: [53]ICFP Programming Contest '08. Mike participated in the ICFP programming contest, and might try porting his solution to Haskell. * Luke Palmer: [54]The Curry-Howard isomorphism and the duality of x and ->. * Magnus Therning: [55]Playing with prefixes. Magnus explores different ways to encode units of storage (bytes, kilobytes, kibibytes...) in Haskell. * Dan Piponi (sigfpe): [56]MSFP 2008. * Shin-Cheng Mu: [57]Tail-Recursive, Linear-Time Fibonacci. * Neil Mitchell: [58]GSoC Hoogle: Week 7. * FP Lunch: [59]CCC-ness of the category of containers. * JP Moresmau: [60]instance Data Map where -- half done!. JP writes an Data.Generics.Data instance for Data.Map. * >>> Rick Carback: [61]AutoKey in Haskell. Rick is learning Haskell and has implemented a simple AutoKey cipher. * >>> Jeremy Frens: [62]PE Problem #2 in All Languages (Part II). * Luke Palmer: [63]Required Optimization. Annotations for specifying expected compiler optimizations? * London Haskell Users Group: [64]AngloHaskell 2008. * >>> Justus: [65]random programming. Solving a simple programming challenge in Haskell. Quotes of the Week * Japsu: segfault cat is watching you unsafeCoerce * z0MB13: who can say hello to me as a md5 or decipher what kind of technique can be used to remove the password * denq: [upon experiencing a moment of enlightenment] oh! something bing in my brain :) * Pseudonym: Pseudonym needs codependent types - useful when you're doing dysfunctional programming. About the Haskell Weekly News New editions are posted to [66]the Haskell mailing list as well as to [67]the Haskell Sequence and [68]Planet Haskell. [69]RSS is also available, and headlines appear on [70]haskell.org. Headlines are available as [71]PDF. To help create new editions of this newsletter, please see the information on [72]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [73]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9570 3. http://hackage.haskell.org/packages/archive/Takusen/0.8.3/Takusen-0.8.3.tar.gz 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42287 5. http://groups.google.com/group/hugvan 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42263 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sphinx 8. http://www.sphinxsearch.com/ 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42233 10. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42227 12. http://research.microsoft.com/~larus/Papers/p80-larus.pdf 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42207 14. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42196 16. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9575 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers 18. http://code.google.com/apis/protocolbuffers/docs/overview.html 19. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/14741 20. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 21. http://hackage.haskell.org/trac/ghc/wiki/GhcApiStatus 22. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9589 23. http://blog.omega-prime.co.uk/?p=69 24. http://jamiiecb.blogspot.com/2008/07/week-5-progress.html 25. http://code.haskell.org/gmap/api 26. http://code.haskell.org/hoogle/ 27. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-7.html 28. http://www.sivity.net/projects/language.c/wiki/ 29. http://haskell.org/haskellwiki/Hpysics 30. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 31. http://code.haskell.org/~Saizan/cabal 32. http://haskell.org/haskellwiki/Library_submissions 33. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9558 34. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9589 35. http://blogs.msdn.com/ralflammel/archive/2008/07/15/research-positions-on-modeling-and-analyzing-software-adaptation-university-of-koblenz.aspx 36. http://adapt.uni-koblenz.de/ 37. http://planet.haskell.org/ 38. http://haskell.org/haskellwiki/Blog_articles 39. http://www.realworldhaskell.org/blog/2008/07/16/real-world-haskellers-at-oscon-next-week/ 40. http://r6.ca/blog/20080716T131235Z.html 41. http://byorgey.wordpress.com/2008/07/16/call-for-an-icfp-mars-server/ 42. http://jamiiecb.blogspot.com/2008/07/week-5-progress.html 43. http://byorgey.wordpress.com/2008/07/15/icfp-programming-contest-reflections/ 44. http://sambangu.blogspot.com/2008/07/help-with-study-of-functional 45. http://eigenclass.org/hiki/quicksort-erratum 46. http://blogs.msdn.com/ralflammel/archive/2008/07/15/research-positions-on-modeling-and-analyzing-software-adaptation-university-of-koblenz.aspx 47. http://blog.omega-prime.co.uk/2008/07/14/compiler-plugins-for-ghc-week-five/ 48. http://lukeplant.me.uk/blog.php?id=1107301689 49. http://blog.tupil.com/stemming-with-haskell/ 50. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/stemmer 51. http://www.sphinxsearch.com/ 52. http://blog.inquirylabs.com/2008/07/14/haskell-is-popular-on-irc/ 53. http://thingsthatmikethinks.blogspot.com/2008/07/icfp-programming-contest-08.html 54. http://luqui.org/blog/archives/2008/07/13/ch-isomorphism-duality/ 55. http://therning.org/magnus/archives/354 56. http://sigfpe.blogspot.com/2008/07/msfp-2008.html 57. http://www.iis.sinica.edu.tw/~scm/2008/tail-recursive-linear-time-fibonacci/ 58. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-7.html 59. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=108 60. http://jpmoresmau.blogspot.com/2008/07/instance-data-map-where-half-done.html 61. http://carback.us/rick/blog/?p=24 62. http://jdfrens.blogspot.com/2008/07/pe-problem-2-in-all-languages-part-ii.html 63. http://luqui.org/blog/archives/2008/07/10/required-optimization/ 64. http://www.londonhug.net/2008/07/10/anglohaskell-2008/ 65. http://hoostus.blogspot.com/2008/07/random-programming.html 66. http://www.haskell.org/mailman/listinfo/haskell 67. http://sequence.complete.org/ 68. http://planet.haskell.org/ 69. http://sequence.complete.org/node/feed 70. http://haskell.org/ 71. http://code.haskell.org/~byorgey/code/hwn/archives/20080716.pdf 72. http://haskell.org/haskellwiki/HWN 73. http://code.haskell.org/~byorgey/code/hwn/ From marcot at riseup.net Wed Jul 16 16:18:12 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Wed Jul 16 16:08:12 2008 Subject: [Haskell-cafe] curl installation In-Reply-To: References: Message-ID: <1216239492.2965.3.camel@quindinho.domain.invalid> Em Qua, 2008-07-16 ?s 19:50 +0000, Thomas Fuhrmann escreveu: > Hello, Hello. > conftest.c:9:23: error: curl/curl.h: No such file or directory http://packages.ubuntu.com/search?searchon=contents&keywords=curl.h&mode=exactfilename&suite=hardy&arch=any Hope it helps. -- ?Marco T?lio Gontijo e Silva P?gina: http://marcotmarcot.googlepages.com/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From dons at galois.com Wed Jul 16 16:19:32 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 16 16:10:00 2008 Subject: [Haskell-cafe] curl installation In-Reply-To: References: Message-ID: <20080716201932.GB31218@scytale.galois.com> noahaon: > Hello, > > I'm trying to install the curl package 1.3.2.1 for haskell, I'm using Ubuntu and > I've already installed curl-7.18.2. I can't get rid of the configuration error. > According to the log entry the curl.h doesn't exist. > > Shell output: > > runghc Setup.hs configure > Configuring curl-1.3.2.1... > checking for gcc... gcc > checking for C compiler default output file name... a.out > checking whether the C compiler works... yes > checking whether we are cross compiling... no > checking for suffix of executables... > checking for suffix of object files... o > checking whether we are using the GNU C compiler... yes > checking whether gcc accepts -g... yes > checking for gcc option to accept ANSI C... none needed > checking how to run the C preprocessor... gcc -E > configure: error: curl libraries not found, so curl package cannot be built > See `config.log' for more details. > > Part of Log entry: > > configure:2439: gcc -E conftest.c > conftest.c:9:23: error: curl/curl.h: No such file or directory > configure:2445: $? = 1 > configure: failed program was: > | /* confdefs.h. */ > | > | #define PACKAGE_NAME "Haskell curl package" > | #define PACKAGE_TARNAME "curl" > | #define PACKAGE_VERSION "1.1" > | #define PACKAGE_STRING "Haskell curl package 1.1" > | #define PACKAGE_BUGREPORT "dons@galois.com" > | /* end confdefs.h. */ > | #include > configure:2469: error: curl libraries not found, s > o curl package cannot be built > See `config.log' for more details. Check where curl/curl.h is on your system. It is possible the development headers are missing? From noahaon at gmx.at Wed Jul 16 16:29:14 2008 From: noahaon at gmx.at (Thomas Fuhrmann) Date: Wed Jul 16 16:19:43 2008 Subject: [Haskell-cafe] Re: curl installation References: <1216239492.2965.3.camel@quindinho.domain.invalid> Message-ID: Marco T?lio Gontijo e Silva riseup.net> writes: > > Em Qua, 2008-07-16 ?s 19:50 +0000, Thomas Fuhrmann escreveu: > > Hello, > > Hello. > > > conftest.c:9:23: error: curl/curl.h: No such file or directory > > http://packages.ubuntu.com/search?searchon=contents&keywords=curl.h&mode=exactfilename&suite=hardy&arch=any > > Hope it helps. > Thanks a lot, the GnuTLS package wasn't yet installed. Bye From holgersiegel74 at yahoo.de Wed Jul 16 19:25:29 2008 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Wed Jul 16 19:15:50 2008 Subject: AW: [Haskell-cafe] Fixed-Point Combinators In-Reply-To: Message-ID: <599825.31339.qm@web25217.mail.ukl.yahoo.com> --- Adrian Neumann schrieb am Mi, 16.7.2008: > Von: Adrian Neumann > Betreff: [Haskell-cafe] Fixed-Point Combinators > An: "Haskell Cafe mailing list" > Datum: Mittwoch, 16. Juli 2008, 21:17 > Hello, > > while studying for a exam I came across this little pearl: > > Y = (L L L L L L L L L L L L L L L L L L L L L L L L L L L > L) > where > L = ?abcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e > d p o i n > t c o m b i n a t o r)) > > posted by Cale Gibbard to this list. Now I'm wondering > how exactly > does one finde such awesome ? expressions? Is there some > mathemagical > background that lets one conjure such beasts? Have a look at http://citeseer.ist.psu.edu/251224.html In this paper Jeroen Fokker describes how to derive a one-combinator basis from the SKI combinators in a systematic way. Maybe it can give you some hints how to treat this kind of problem. __________________________________________________________ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com From Braden.Shepherdson at gmail.com Wed Jul 16 20:32:50 2008 From: Braden.Shepherdson at gmail.com (Braden Shepherdson) Date: Wed Jul 16 20:24:50 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C32AE7598940@EA-EXMSG-C334.europe.corp.microsoft.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> <638ABD0A29C8884A91BC5FB5C349B1C32AE7598940@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: Simon Peyton-Jones wrote: > | Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007 > | armv6l unknown > | > | I would love a working GHC implementation on it, if for nothing else > | than how awesome it would be. Whether that means using a C back-end or > | native compilation doesn't matter to me so much. > | > | I might be one to attempt this, as I know C and ARM-ish asm decently > | well and have a powerful desktop to compile on. I have no familiarity > | with GHC internals, though. Lastly, I won't have anything like the time > | to attempt this seriously until mid-September or so. > > That's good. John Dias is hard at work on GHC's back end, and we should be in reasonable shape by mid Sept. Better still a month later... Keep us posted with what you do. > > Simon Well, I've documented three attempts in detail on the ArmLinuxGhc Trac page[1]. In short, it doesn't work. 6.8 and 6.9 fail, expectedly, since bootstrapping is known to be broken[2]. 6.6 might be made to work, but it didn't work with moderate effort and so it seems foolish to invest that sort of energy into an old version when the back end is being overhauled. As it appears that the task will be much easier after the back end changes, this project is effectively on hold until the 6.10 release. In particular, bootstrapping needs to work. There is a bug[2] about this with milestone set to 6.10.1. Hopefully a quick-and-dirty unregisterised port will be easy after that, with registerised and possibly even native code-gen on the horizon. One question that has come up is, what external tools does GHC need to build binaries on a given platform? When going via-c, is a complete C toolchain necessary? When doing native code-gen, are ld or ar required, or other binutils? If we magically had a 6.9 that would generate ARM binaries, what would it take to run binaries built in the dev environment on the device? Would it take more to run GHC itself on the device? Braden Shepherdson shepheb [1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc [2] http://hackage.haskell.org/trac/ghc/ticket/1346 From felipe.lessa at gmail.com Wed Jul 16 21:45:19 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Jul 16 21:35:41 2008 Subject: [Haskell-cafe] FFI and struct arguments Message-ID: Hi, I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send struct arguments to C functions via the FFI or do I need to create a C wrapper? I guess there isn't, and while I can live without it, I'd like to leave no doubt. Details: I have something like ==================== typedef struct vect { float x,y; } vect; void func(vect v); ===================== on the C side and ==================== -- Please disregard float /= Float, just an example :) data Vector = Vector Float Float instance Storable Vector where ... ==================== on the Haskell side, and I want to call func with Vector as argument. Now, Vector isn't a basic FFI type, although it implements Storable. So does that mean that I need to create something like ==================== void funcWrapper(vect *v) { func(*v); } ==================== and then allocate some temporary memory on the Haskell side to use func? Cheers! -- Felipe. From olivier.boudry at gmail.com Thu Jul 17 02:10:17 2008 From: olivier.boudry at gmail.com (Olivier Boudry) Date: Thu Jul 17 02:00:38 2008 Subject: [Haskell-cafe] Linker problems linking FFI import call in Windows In-Reply-To: <4f712c6f0807160922j6caea8c3wfdf638b148de08d3@mail.gmail.com> References: <4f712c6f0807151451p4fc68efoe2e7c2ad238745fe@mail.gmail.com> <4f712c6f0807160922j6caea8c3wfdf638b148de08d3@mail.gmail.com> Message-ID: On Wed, Jul 16, 2008 at 6:22 PM, PJ Durai wrote: > I do have the import library. It came with the DLL. It links properly > when I use CCALL on the haskell import statements. Doesnt link when I > use STDCALL. It looks for function name with something like '@4 or > @8' tacked on at the end. Not sure what that is all about. Is your import library a ".lib" or a ".a" file? If you have a ".lib" import library ghc will ignore it and link directly with the DLL. I think you can convert a ".lib" to a ".a" using the reimp tool which is part of the mingw utilities. From kyrab at mail.ru Thu Jul 17 02:57:03 2008 From: kyrab at mail.ru (kyra) Date: Thu Jul 17 02:47:22 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: References: Message-ID: <487EED3F.40506@mail.ru> Felipe Lessa wrote: > Hi, > > I tried googling and searching the haskellwiki about this but wasn't > lucky enough. My question is: is there a way to send struct arguments > to C functions via the FFI or do I need to create a C wrapper? I guess > there isn't, and while I can live without it, I'd like to leave no > doubt. > Sometimes there is such a way. See below. > Details: > > I have something like > > ==================== > typedef struct vect { > float x,y; > } vect; > > void func(vect v); > For most architectures stack layout of void func(vect v); and void func(float x, float y); is exactly the same, so for FFI purposes this 'func' can be declared as something like: foreign import ccall unsafe :: Float -> Float -> IO () Cheers, Kyra From jon.fairbairn at cl.cam.ac.uk Thu Jul 17 04:07:59 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu Jul 17 03:58:31 2008 Subject: [Haskell-cafe] Re: Fixed-Point Combinators References: Message-ID: Adrian Neumann writes: > Hello, > > while studying for a exam I came across this little pearl: > > Y = (L L L L L L L L L L L L L L L L L L L L L L L L L L L L) > where > L = ?abcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d > p o i n t c o m b i n a t o r)) > > posted by Cale Gibbard to this list. Now I'm wondering how > exactly does one finde such awesome ? expressions? In this particular case, once one has seen the Turing fixed point combinator, I think it's fairly obvious. The idea this is, we want a fixpoint combinator; let's assume we can make it by applying one thing to another. F G. We want (F G f) = f (F G f) so F has got to look something like \g f -> f (F g f). Oh, but where are we going to get another F without a fixpoint combinator? I know, how about passing it in as g? now F = (\g f -> f (g g f)), which works so long as the argument given for g is F. So Y = F F. Now, one can look at this as "F is half of a fixpoint combinator", so what about one third of a fixpoint combinator? ie T T T f = f (T T T f) Clearly T has to look like (\t2 t3 f -> f (T T T f)), and the same reasoning applies. Obviously it doesn't matter what you call the bound variables. > Is there some mathemagical background that lets one > conjure such beasts? If you play around with lambda expressions and combinators enough, they'll come to you in your dreams. To what extent this is a Good Thing is a matter of personal taste. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2008-04-26) From J.Burton at brighton.ac.uk Thu Jul 17 05:50:06 2008 From: J.Burton at brighton.ac.uk (J.Burton@brighton.ac.uk) Date: Thu Jul 17 05:40:21 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: References: <87r69vmdjl.wl%j.burton@brighton.ac.uk> Message-ID: <87ej5s3kmp.wl%j.burton@brighton.ac.uk> At Tue, 15 Jul 2008 10:27:59 -0400, Jeff Polakow wrote: > > [1 ] > > [2 ] > Hello, > > > data LSet t where > > Nil :: LSet Nil > > Ins :: (Member a t b > > , If b t (a ::: t) r) > > => L a -> LSet t -> LSet r > > > Try replacing both original occurrences of r, i.e. (untested) > > Ins :: (Member a t b, If b t (a ::: t) (LSet r)) => L a -> LSet t -> LSet r > Thanks. This sort of works, but shifts the problem to another context. Now it seems that I can't hide the extra type information in the existential types, which is what I want to do. In the function `insertChar' below I want the type LSetBox to be opaque (i.e. it will be called by users who don't need to know about the fancy types): data LSet t where Nil :: LSet Nil Ins :: (Member a t b , If b t (a ::: t) (LSet r)) => L a -> LSet t -> LSet r -- I have to supply a type for `insert' now and it must include the constraints insert :: (Member a t b , If b t (a ::: t) (LSet r)) => L a -> LSet t -> LSet r insert = Ins --insertChar (and the boxing) doesn't work insertChar :: Char -> LSetBox -> LSetBox insertChar c (LSetBox s) = case fromChar c of LBox t -> LSetBox (insert t s) The error: Could not deduce (If b t1 (a ::: t1) (LSet t), Member a t1 b) from the context () arising from a use of `insert' at /home/jim/sdf-bzr/dsel/TF/Set-July08.hs:54:25-34 Possible fix: add (If b t1 (a ::: t1) (LSet t), Member a t1 b) to the context of the constructor `LBox' or add an instance declaration for (If b t1 (a ::: t1) (LSet t)) In the first argument of `LSetBox', namely `(insert t s)' In the expression: LSetBox (insert t s) In a case alternative: LBox t -> LSetBox (insert t s) Failed, modules loaded: none. Jim > -Jeff > > --- > > This e-mail may contain confidential and/or privileged information. If you > are not the intended recipient (or have received this e-mail in error) > please notify the sender immediately and destroy this e-mail. Any > unauthorized copying, disclosure or distribution of the material in this > e-mail is strictly forbidden. > > From frantisek.kocun at gmail.com Thu Jul 17 06:38:58 2008 From: frantisek.kocun at gmail.com (fero) Date: Thu Jul 17 06:29:18 2008 Subject: [Haskell-cafe] Searchig for modules Message-ID: <18505770.post@talk.nabble.com> Hi I am learnig Haskell form SOE book, but I can't find out how to import SOE module. I use eclipsefp IDE and I get no error when I have SOE.hs in my project and in SimpleGraphics.hs I make "import SOE". But when trying to run it I get error: "Could not find module `SOE': Use -v to see a list of the files searched for." Where ghc/ghci search for modules? Is it possible put some modules somewhere that every Haskell project can find it (something as global classpath in java). And is it posible in eclipsefp to link some modules to project that this project will use them. As I wrote even when I have 2 modules in src in project I when trying to run one of then the others are not found. I can't find any site about searching for modules (in java there is a lot options, global/local classpath, directory in java runtime used only with this rt or directory in web server used in all apps run on this server...). Can you put a link? Thanks Fero -- View this message in context: http://www.nabble.com/Searchig-for-modules-tp18505770p18505770.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From frantisek.kocun at gmail.com Thu Jul 17 07:18:11 2008 From: frantisek.kocun at gmail.com (fero) Date: Thu Jul 17 07:08:30 2008 Subject: [Haskell-cafe] Searchig for modules In-Reply-To: <18505770.post@talk.nabble.com> References: <18505770.post@talk.nabble.com> Message-ID: <18506257.post@talk.nabble.com> Actually I have already found the way how to do it but not in eclipsefp. Either I run ghci and when both modules are in the same dir it works or I use "-idirs" but in eclipsefp it doesn't. Can somebody help me how to configure eclipsefp. I don't want to go to command prompt every time I want to run my program. Fero -- View this message in context: http://www.nabble.com/Searchig-for-modules-tp18505770p18506257.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From duncan.coutts at worc.ox.ac.uk Thu Jul 17 07:46:02 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jul 17 07:35:32 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: References: Message-ID: <1216295162.6279.208.camel@localhost> On Wed, 2008-07-16 at 22:45 -0300, Felipe Lessa wrote: > Hi, > > I tried googling and searching the haskellwiki about this but wasn't > lucky enough. My question is: is there a way to send struct arguments > to C functions via the FFI or do I need to create a C wrapper? I guess > there isn't, and while I can live without it, I'd like to leave no > doubt. Correct. The FFI spec does not support C structs as C function parameters or results. You'll need a wrapper. If the struct is passed by reference of course then you're fine, but if it's by value then you need a C wrapper. The reason is because it's beyond the scope of the FFI to know the structure layout and how to map that to haskell types. That's the domain of FFI pre-processors. However I don't know of any FFI pre-processors that help in this case. Passing C structs by value seems to be pretty rare in exported C APIs. Duncan From isaacdupree at charter.net Thu Jul 17 08:43:25 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jul 17 08:33:42 2008 Subject: [Haskell-cafe] Searchig for modules In-Reply-To: <18506257.post@talk.nabble.com> References: <18505770.post@talk.nabble.com> <18506257.post@talk.nabble.com> Message-ID: <487F3E6D.2080300@charter.net> fero wrote: > Actually I have already found the way how to do it but not in eclipsefp. > Either I run ghci and when both modules are in the same dir it works or I > use "-idirs" but in eclipsefp it doesn't. Can somebody help me how to > configure eclipsefp. I don't want to go to command prompt every time I want > to run my program. I don't know anything about IDEs, but... ghc --make, should work to find the module on the command-line, and so should `runghc` (like interpreter but runs 'main'). There is also a way to install it more globally but I'm not sure what is a simple way to do that (it could involve making a .cabal file, I think) -Isaac From frantisek.kocun at gmail.com Thu Jul 17 08:46:44 2008 From: frantisek.kocun at gmail.com (frantisek kocun) Date: Thu Jul 17 08:37:03 2008 Subject: [Haskell-cafe] Searchig for modules In-Reply-To: <18506257.post@talk.nabble.com> References: <18505770.post@talk.nabble.com> <18506257.post@talk.nabble.com> Message-ID: It works when I put "-idirs c:\eworkspace2\Soe\src\SOE" to extra compiler options and set GHCi to use GHC setting, but you need to restart ecpilse. And the module, wht is loaded is SOE so I always need to switch module.. Fero On Thu, Jul 17, 2008 at 1:18 PM, fero wrote: > > Actually I have already found the way how to do it but not in eclipsefp. > Either I run ghci and when both modules are in the same dir it works or I > use "-idirs" but in eclipsefp it doesn't. Can somebody help me how to > configure eclipsefp. I don't want to go to command prompt every time I want > to run my program. > > Fero > -- > View this message in context: > http://www.nabble.com/Searchig-for-modules-tp18505770p18506257.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080717/0be95e58/attachment.htm From sk at k-hornz.de Thu Jul 17 08:57:58 2008 From: sk at k-hornz.de (stefan kersten) Date: Thu Jul 17 10:50:02 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? Message-ID: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> hi, i've attached an example program which seems to indicate that the magnitude function from Data.Complex is very slow compared to a more naive implementation (for Complex Float). on my machine (intel core2 duo, osx 10.4) the CPU time using the library function is about 6-7 times as much as when using the other function. any ideas what might be going on? any flaws in my measurement code? thanks, -------------- next part -------------- A non-text attachment was scrubbed... Name: magnitude.hs Type: application/octet-stream Size: 1700 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080717/4fd69aed/magnitude.obj -------------- next part -------------- From kyrab at mail.ru Thu Jul 17 11:08:07 2008 From: kyrab at mail.ru (kyra) Date: Thu Jul 17 10:58:27 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: <1216295162.6279.208.camel@localhost> References: <1216295162.6279.208.camel@localhost> Message-ID: <487F6057.5010207@mail.ru> > If the struct is passed by reference of course then you're fine, but if > it's by value then you need a C wrapper. The reason is because it's > beyond the scope of the FFI to know the structure layout and how to map > that to haskell types. That's the domain of FFI pre-processors. However > I don't know of any FFI pre-processors that help in this case. Passing C > structs by value seems to be pretty rare in exported C APIs. Yes, but programmer *knows* the structure layout, so she usually can emulate it with a sequence of primary ffi type arguments. It's pretty trivial for the original example (see my previous post on this subj) and can be extended further. For example, in my homebrew COM library I pretty successfully marshall 16-byte Variants *by value* by means of two consecutive "legal" Word64 arguments. Cheers, Kyra From jeff.polakow at db.com Thu Jul 17 11:17:27 2008 From: jeff.polakow at db.com (Jeff Polakow) Date: Thu Jul 17 11:07:52 2008 Subject: [Haskell-cafe] Type level sets with GADTs, fundeps etc In-Reply-To: <87ej5s3kmp.wl%j.burton@brighton.ac.uk> Message-ID: Hello, > Thanks. This sort of works, but shifts the problem to another context. Now it > seems that I can't hide the extra type information in the existential > types, which is what I want to do. > I think that you can't abstract over a type context, i.e. you can't expect type inference to instantiate a type variable to a constrained polymorphic type. I get the impression that GADTs are a bit of a distraction for what you are aiming to do. I'm not sure exactly what you mean by > > > :t insert (undefined::A) (undefined:: A ::: Nil) > insert (undefined::A) (undefined:: A ::: Nil) :: A ::: Nil > > But what I really want to do is wrap this up so that it can be used > at runtime, not just in the type-checker, so that (just a sketch) > I could have > > insert 'A' empty :: Set (A ::: Nil) > > where the runtime value of the set is fully determined by its type. > but it looks like it should be a realtively easy bit of machinery to add to what you already had. Also, in case you haven't already seen these, other good sources of type level programming are the HList paper ( http://homepages.cwi.nl/~ralf/HList/) and the OOHaskell paper ( http://homepages.cwi.nl/~ralf/OOHaskell/) -Jeff --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080717/52faa450/attachment.htm From lemming at henning-thielemann.de Thu Jul 17 11:18:01 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 17 11:08:21 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> Message-ID: On Thu, 17 Jul 2008, stefan kersten wrote: > i've attached an example program which seems to indicate that the magnitude > function from Data.Complex is very slow compared to a more naive > implementation (for Complex Float). on my machine (intel core2 duo, osx 10.4) > the CPU time using the library function is about 6-7 times as much as when > using the other function. any ideas what might be going on? any flaws in my > measurement code? Complex.magnitude must prevent overflows, that is, if you just square 1e200::Double you get an overflow, although the end result may be also around 1e200. I guess, that to this end Complex.magnitude will separate mantissa and exponent, but this is done via Integers, I'm afraid. From Alistair.Bayley at invesco.com Thu Jul 17 11:37:18 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Thu Jul 17 11:27:40 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: <1216295162.6279.208.camel@localhost> References: <1216295162.6279.208.camel@localhost> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E94BD@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Duncan Coutts > Sent: 17 July 2008 12:46 > > On Wed, 2008-07-16 at 22:45 -0300, Felipe Lessa wrote: > > Hi, > > > > I tried googling and searching the haskellwiki about this but wasn't > > lucky enough. My question is: is there a way to send struct > arguments > > to C functions via the FFI or do I need to create a C > wrapper? I guess > > there isn't, and while I can live without it, I'd like to leave no > > doubt. > > If the struct is passed by reference of course then you're > fine, but if > it's by value then you need a C wrapper. The reason is because it's > beyond the scope of the FFI to know the structure layout and > how to map > that to haskell types. That's the domain of FFI > pre-processors. However > I don't know of any FFI pre-processors that help in this > case. Passing C > structs by value seems to be pretty rare in exported C APIs. hsc2hs can help a bit (I haven't used the other FFI tools, so don't take this as an endorsement of hsc2hs over them). You could create a wrapper that marshals your Vector to a vector struct like this: ---- .hsc file: #include -- whatever header contains your C vector struct data VectorC = Ptr () -- opaque data type, like void* -- your Haskell vector data Vector = Vector Float Float vector2cvect :: Vector -> IO VectorC vector2cvect (Vector x y) = do ptr <- mallocBytes #{size vect} pokeByteOff #{offset vect, x} x pokeByteOff #{offset vect, x} x return ptr cvect2Vector :: VectorC -> IO Vector cvect2Vector ptr = do x <- peekByteOff ptr #{offset vect, x} y <- peekByteOff ptr #{offset vect, y} return (Vector x y) -- inline your *vect->vect wrapper (ends up in generated .c file) #def void funcWrapper(vect *v) { func(*v); } foreign import stdcall funcWr unsafe "funcWrapper" :: VectorC -> IO () main = do vc <- vector2cvect (Vector 3 4) funcWr vc free vc ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From qdunkan at gmail.com Thu Jul 17 11:37:24 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Jul 17 11:27:48 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <20080714171919.GB23666@scytale.galois.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714171919.GB23666@scytale.galois.com> Message-ID: <2518b95d0807170837q7d784ff8t4e51a1be03fb437a@mail.gmail.com> > An abstraction stack: > > Impure Pure How about strict vs. lazy? I ask because I assumed there were lazy variants of uvector or storablevector, using the bytestring list of chunks approach, but apparently not? Making a lazy version seems pretty easy, but rewriting all the basic functions looks not so easy. Granted, I can probably do most of what I want with just foldr... Also, what's the distinction between storablevector and uvector? Also, it's even more off subject, but haddock crashes on uvector. You can see the errors on hackage. From lemming at henning-thielemann.de Thu Jul 17 11:41:01 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 17 11:31:52 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <2518b95d0807170837q7d784ff8t4e51a1be03fb437a@mail.gmail.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714171919.GB23666@scytale.galois.com> <2518b95d0807170837q7d784ff8t4e51a1be03fb437a@mail.gmail.com> Message-ID: On Thu, 17 Jul 2008, Evan Laforge wrote: >> An abstraction stack: >> >> Impure Pure > > How about strict vs. lazy? I ask because I assumed there were lazy > variants of uvector or storablevector, using the bytestring list of > chunks approach, but apparently not? For storablevector there exists code, but not complete and not tested: http://code.haskell.org/storablevector/Data/StorableVector/Lazy.hs > Also, what's the distinction between storablevector and uvector? I hoped that I answered this with my previous mail. From igloo at earth.li Thu Jul 17 11:42:41 2008 From: igloo at earth.li (Ian Lynagh) Date: Thu Jul 17 11:33:02 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> Message-ID: <20080717154241.GA12211@matrix.chaos.earth.li> On Thu, Jul 17, 2008 at 05:18:01PM +0200, Henning Thielemann wrote: > > On Thu, 17 Jul 2008, stefan kersten wrote: > > >i've attached an example program which seems to indicate that the > >magnitude function from Data.Complex is very slow compared to a more naive > >implementation (for Complex Float). on my machine (intel core2 duo, osx > >10.4) the CPU time using the library function is about 6-7 times as much > >as when using the other function. any ideas what might be going on? any > >flaws in my measurement code? > > Complex.magnitude must prevent overflows, that is, if you just square > 1e200::Double you get an overflow, although the end result may be also > around 1e200. I guess, that to this end Complex.magnitude will separate > mantissa and exponent, but this is done via Integers, I'm afraid. Here's the code: {-# SPECIALISE magnitude :: Complex Double -> Double #-} magnitude :: (RealFloat a) => Complex a -> a magnitude (x:+y) = scaleFloat k (sqrt ((scaleFloat mk x)^(2::Int) + (scaleFloat mk y)^(2::Int))) where k = max (exponent x) (exponent y) mk = - k So the slowdown may be due to the scaling, presumably to prevent overflow as you say. However, the e^(2 :: Int) may also be causing a slowdown, as (^) is lazy in its first argument; I'm not sure if there is a rule that will rewrite that to e*e. Stefan, perhaps you can try timing with the above code, and also with: {-# SPECIALISE magnitude :: Complex Double -> Double #-} magnitude :: (RealFloat a) => Complex a -> a magnitude (x:+y) = scaleFloat k (sqrt (sqr (scaleFloat mk x) + sqr (scaleFloat mk y))) where k = max (exponent x) (exponent y) mk = - k sqr x = x * x and let us know what the results are? Thanks Ian From felipe.lessa at gmail.com Thu Jul 17 12:32:54 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Jul 17 12:23:14 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: <487F6057.5010207@mail.ru> References: <1216295162.6279.208.camel@localhost> <487F6057.5010207@mail.ru> Message-ID: On Thu, Jul 17, 2008 at 12:08 PM, kyra wrote: > Yes, but programmer *knows* the structure layout, so she usually can emulate > it with a sequence of primary ffi type arguments. It's pretty trivial for > the original example (see my previous post on this subj) and can be extended > further. For example, in my homebrew COM library I pretty successfully > marshall 16-byte Variants *by value* by means of two consecutive "legal" > Word64 arguments. I am concerned, however, with the portability of the library. I mean, is the calling convention for both void func(vect v); void func(float x, float y); the same on x86? On x86-64? On Windows? On Linux? I guess it would be a lot faster to pass the arguments on the stack than alloca'ting, copying to the new area and then copying from the area to the stack, but I don't want to sacrifice the portability. Thanks, -- Felipe. From felipe.lessa at gmail.com Thu Jul 17 12:36:18 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Jul 17 12:26:37 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA9049E94BD@GBLONXMB02.corp.amvescap.net> References: <1216295162.6279.208.camel@localhost> <125EACD0CAE4D24ABDB4D148C4593DA9049E94BD@GBLONXMB02.corp.amvescap.net> Message-ID: On Thu, Jul 17, 2008 at 12:37 PM, Bayley, Alistair wrote: > -- inline your *vect->vect wrapper (ends up in generated .c file) > #def void funcWrapper(vect *v) { func(*v); } > > foreign import stdcall funcWr unsafe "funcWrapper" :: VectorC -> IO () I am using hsc2hs currently, but googling about #def with Cabal I found out that some people were having trouble to make Cabal discover that hsc2hs had created a new C file. Specifically, bug #245 [1] which says that the milestone is undefined. So for now I'm creating a wrapper.[ch] myself. [1] http://hackage.haskell.org/trac/hackage/ticket/245 -- Felipe. From sk at k-hornz.de Thu Jul 17 12:56:52 2008 From: sk at k-hornz.de (stefan kersten) Date: Thu Jul 17 12:47:31 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <20080717154241.GA12211@matrix.chaos.earth.li> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <20080717154241.GA12211@matrix.chaos.earth.li> Message-ID: <3F8A5875-4937-4F2C-8A9C-F720BCF68EDB@k-hornz.de> On 17.07.2008, at 17:42, Ian Lynagh wrote: > On Thu, Jul 17, 2008 at 05:18:01PM +0200, Henning Thielemann wrote: >> Complex.magnitude must prevent overflows, that is, if you just square >> 1e200::Double you get an overflow, although the end result may be >> also >> around 1e200. I guess, that to this end Complex.magnitude will >> separate >> mantissa and exponent, but this is done via Integers, I'm afraid. > > Here's the code: > > {-# SPECIALISE magnitude :: Complex Double -> Double #-} > magnitude :: (RealFloat a) => Complex a -> a > magnitude (x:+y) = scaleFloat k > (sqrt ((scaleFloat mk x)^(2::Int) + > (scaleFloat mk y)^(2::Int))) > where k = max (exponent x) (exponent y) > mk = - k > > So the slowdown may be due to the scaling, presumably to prevent > overflow as you say. However, the e^(2 :: Int) may also be causing a > slowdown, as (^) is lazy in its first argument; I'm not sure if > there is > a rule that will rewrite that to e*e. Stefan, perhaps you can try > timing > with the above code, and also with: > > {-# SPECIALISE magnitude :: Complex Double -> Double #-} > magnitude :: (RealFloat a) => Complex a -> a > magnitude (x:+y) = scaleFloat k > (sqrt (sqr (scaleFloat mk x) + sqr (scaleFloat > mk y))) > where k = max (exponent x) (exponent y) > mk = - k > sqr x = x * x > > and let us know what the results are? thanks ian, here are the absolute runtimes (non-instrumented code) and the corresponding entries in the profile: c_magnitude0 (Complex.Data.magnitude) 0m7.249s c_magnitude1 (non-scaling version) 0m1.176s c_magnitude2 (scaling version, strict square) 0m3.278s %time %alloc (inherited) c_magnitude0 91.6 90.2 c_magnitude1 41.7 49.6 c_magnitude2 81.5 71.1 interestingly, just pasting the original ghc library implementation seems to slow things down considerably (0m12.264s) when compiling with -O2 -funbox-strict-fields -fvia-C -optc-O2 -fdicts-cheap -fno-method-sharing -fglasgow-exts when leaving away -fdicts-cheap and -fno-method-sharing the execution time for the pasted library code reduces to 0m6.873s. seems like some options that are useful (or even necessary?) for stream fusion rule reduction, may produce non-optimal code in other cases? From isaacdupree at charter.net Thu Jul 17 13:53:23 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jul 17 13:43:38 2008 Subject: [Haskell-cafe] uvector and the stream interface In-Reply-To: <2518b95d0807170837q7d784ff8t4e51a1be03fb437a@mail.gmail.com> References: <223DAABF-7ED6-46F4-8C7C-5C43955E5381@k-hornz.de> <20080714162716.GA23601@scytale.galois.com> <487B8200.1020901@jellybean.co.uk> <20080714171919.GB23666@scytale.galois.com> <2518b95d0807170837q7d784ff8t4e51a1be03fb437a@mail.gmail.com> Message-ID: <487F8713.9010008@charter.net> Evan Laforge wrote: >> An abstraction stack: >> >> Impure Pure > > How about strict vs. lazy? I ask because I assumed there were lazy > variants of uvector or storablevector, using the bytestring list of > chunks approach, but apparently not? wait.... "list of chunks" makes something that behaves not like a random-access array, and yet is still rather strict in the elements. How about strict vs. lazy as in UArray vs. Array: whether the elements are evaluated lazily (although UArray has the complication that the elements must also be Storable: e.g. what if you want a strict random-access array of functions -- so there is not such an easy solution for a strict but boxed array). so do we have at least three different variables here? :-) -Isaac From pgavin at gmail.com Thu Jul 17 14:14:02 2008 From: pgavin at gmail.com (Peter Gavin) Date: Thu Jul 17 14:04:24 2008 Subject: [Haskell-cafe] Space leaks Message-ID: <487F8BEA.9050109@gmail.com> Hello everyone, I have this piece of code I've been working on, and I've been stuck on tracking down a space leak in it for some time now. The code is essentially a tight loop that updates a rather largish data structure with embedded functions that are called by the driver loop. The code doesn't accumulate any data as the loop runs (at least deliberately), so I would expect the memory profile to be flat. Unfortunately, the profile is a wedge :) I've added bangs and `seq` literally everywhere, and it looks (to me at least) like there's nothing left to be lazily evaluated anywhere. I've used retainer profiling, and the functions that are leaking space according to the profiler output are strict throughout. I'm really pulling my hair out over this, but I'm reluctant to publish the code just yet because I'm planning on using it (eventually) for my thesis. It seems like I've just about run out of options, though. Does anyone have any advice on tracking down space leaks? I don't want to accuse GHC of having a bug just yet, but has GHC had space leak bugs in the past? Thanks in advance, Peter Gavin From lrpalmer at gmail.com Thu Jul 17 14:58:52 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Jul 17 14:49:11 2008 Subject: [Haskell-cafe] Space leaks In-Reply-To: <487F8BEA.9050109@gmail.com> References: <487F8BEA.9050109@gmail.com> Message-ID: <7ca3f0160807171158q8422f6ai252e946780271f0a@mail.gmail.com> On Thu, Jul 17, 2008 at 12:14 PM, Peter Gavin wrote: > Hello everyone, > > I have this piece of code I've been working on, and I've been stuck on > tracking down a space leak in it for some time now. The code is essentially > a tight loop that updates a rather largish data structure with embedded > functions that are called by the driver loop. The code doesn't accumulate > any data as the loop runs (at least deliberately), so I would expect the > memory profile to be flat. Unfortunately, the profile is a wedge :) I've > added bangs and `seq` literally everywhere, and it looks (to me at least) > like there's nothing left to be lazily evaluated anywhere. I've used > retainer profiling, and the functions that are leaking space according to > the profiler output are strict throughout. I don't know what I can suggest as for general tactics. Without seeing the code it's hard to say what could be happening. Just remember that strictness is not always the answer! >From the very limited amount of information I got from this description, my first guess would be the data structure itself, or the functions inside it. If it's lazily generated, then you might not be seeing the full amount of space it's taking up at once. But that's just a guess. Luke From sk at k-hornz.de Thu Jul 17 15:21:32 2008 From: sk at k-hornz.de (stefan kersten) Date: Thu Jul 17 15:12:08 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> Message-ID: <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> On 17.07.2008, at 17:18, Henning Thielemann wrote: >> i've attached an example program which seems to indicate that the >> magnitude function from Data.Complex is very slow compared to a >> more naive implementation (for Complex Float). on my machine >> (intel core2 duo, osx 10.4) the CPU time using the library >> function is about 6-7 times as much as when using the other >> function. any ideas what might be going on? any flaws in my >> measurement code? > > Complex.magnitude must prevent overflows, that is, if you just > square 1e200::Double you get an overflow, although the end result > may be also around 1e200. I guess, that to this end > Complex.magnitude will separate mantissa and exponent, but this is > done via Integers, I'm afraid. very enlightening, thanks! it might be possible to (almost) get the best of two worlds (ported from dejagnu's libm): c_magnitude4 :: Complex Float -> Float c_magnitude4 (x:+y) = if x' < y' then mag y' x' else mag x' y' where x' = abs x y' = abs y sqr x = x * x mag a 0 = a mag a b = a * sqrt (1 + sqr (b/a)) is fast and doesn't overflow intermediate results but accuracy isn't so great ... From lennart at augustsson.net Thu Jul 17 15:46:12 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Jul 17 15:36:31 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: If scaleFloat and exponent are implemented with bit twiddling they can be quite fast. I have a feeling that they involve slow FFI calls in GHC (being the original author of a lot of the code involved). On Thu, Jul 17, 2008 at 8:21 PM, stefan kersten wrote: > On 17.07.2008, at 17:18, Henning Thielemann wrote: >>> >>> i've attached an example program which seems to indicate that the >>> magnitude function from Data.Complex is very slow compared to a more naive >>> implementation (for Complex Float). on my machine (intel core2 duo, osx >>> 10.4) the CPU time using the library function is about 6-7 times as much as >>> when using the other function. any ideas what might be going on? any flaws >>> in my measurement code? >> >> Complex.magnitude must prevent overflows, that is, if you just square >> 1e200::Double you get an overflow, although the end result may be also >> around 1e200. I guess, that to this end Complex.magnitude will separate >> mantissa and exponent, but this is done via Integers, I'm afraid. > > very enlightening, thanks! it might be possible to (almost) get the best of > two worlds (ported from dejagnu's libm): > > c_magnitude4 :: Complex Float -> Float > c_magnitude4 (x:+y) = if x' < y' > then mag y' x' > else mag x' y' > where > x' = abs x > y' = abs y > sqr x = x * x > mag a 0 = a > mag a b = a * sqrt (1 + sqr (b/a)) > > is fast and doesn't overflow intermediate results but accuracy isn't so > great ... > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lemming at henning-thielemann.de Thu Jul 17 16:15:39 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 17 16:05:59 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <20080717154241.GA12211@matrix.chaos.earth.li> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <20080717154241.GA12211@matrix.chaos.earth.li> Message-ID: On Thu, 17 Jul 2008, Ian Lynagh wrote: > On Thu, Jul 17, 2008 at 05:18:01PM +0200, Henning Thielemann wrote: >> >> Complex.magnitude must prevent overflows, that is, if you just square >> 1e200::Double you get an overflow, although the end result may be also >> around 1e200. I guess, that to this end Complex.magnitude will separate >> mantissa and exponent, but this is done via Integers, I'm afraid. > > Here's the code: > > {-# SPECIALISE magnitude :: Complex Double -> Double #-} > magnitude :: (RealFloat a) => Complex a -> a > magnitude (x:+y) = scaleFloat k > (sqrt ((scaleFloat mk x)^(2::Int) + (scaleFloat mk y)^(2::Int))) > where k = max (exponent x) (exponent y) > mk = - k > > So the slowdown may be due to the scaling, presumably to prevent > overflow as you say. However, the e^(2 :: Int) may also be causing a > slowdown, as (^) is lazy in its first argument; I'm not sure if there is > a rule that will rewrite that to e*e. I guess the rule should be INLINE. Indeed, here you can see http://darcs.haskell.org/packages/base/GHC/Float.lhs that scaleFloat calls decodeFloat and encodeFloat. Both of them use Integer. I expect that most FPUs are able to divide a floating point number into exponent and mantissa, but GHC seems not to have a primitive for it? As a quick work-around, Complex.magnitude could check whether the arguments are too big, then use scaleFloat and otherwise it should use the naive algorithm. In the math library of C there is the function 'frexp' http://www.codecogs.com/reference/c/math.h/frexp.php?alias= but calling an external functions will be slower than a comparison that can be performed by a single FPU instruction. From lemming at henning-thielemann.de Thu Jul 17 16:18:50 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 17 16:09:08 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: On Thu, 17 Jul 2008, stefan kersten wrote: > On 17.07.2008, at 17:18, Henning Thielemann wrote: >>> i've attached an example program which seems to indicate that the >>> magnitude function from Data.Complex is very slow compared to a more naive >>> implementation (for Complex Float). on my machine (intel core2 duo, osx >>> 10.4) the CPU time using the library function is about 6-7 times as much >>> as when using the other function. any ideas what might be going on? any >>> flaws in my measurement code? >> >> Complex.magnitude must prevent overflows, that is, if you just square >> 1e200::Double you get an overflow, although the end result may be also >> around 1e200. I guess, that to this end Complex.magnitude will separate >> mantissa and exponent, but this is done via Integers, I'm afraid. > > very enlightening, thanks! it might be possible to (almost) get the best of > two worlds (ported from dejagnu's libm): > > c_magnitude4 :: Complex Float -> Float > c_magnitude4 (x:+y) = if x' < y' > then mag y' x' > else mag x' y' > where > x' = abs x > y' = abs y > sqr x = x * x > mag a 0 = a > mag a b = a * sqrt (1 + sqr (b/a)) > > is fast and doesn't overflow intermediate results but accuracy isn't so great > ... Yes, that's also a possible work-around. But division is quite slow. From jefferson.r.heard at gmail.com Thu Jul 17 16:34:40 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Thu Jul 17 16:25:00 2008 Subject: [Haskell-cafe] Space leaks In-Reply-To: <7ca3f0160807171158q8422f6ai252e946780271f0a@mail.gmail.com> References: <487F8BEA.9050109@gmail.com> <7ca3f0160807171158q8422f6ai252e946780271f0a@mail.gmail.com> Message-ID: <4165d3a70807171334l1b475fa3p750a1027ab1a6446@mail.gmail.com> Peter, from 500 feet, we can't see much, but your strictness might actually be your problem depending on what "largish" looks like and whether you're reading your data from disc. It's entirely possible that your data structure updates or disc reads are head-strict and you're evaluating or loading the entirety of data in memory at a single update. -- Jeff On Thu, Jul 17, 2008 at 2:58 PM, Luke Palmer wrote: > On Thu, Jul 17, 2008 at 12:14 PM, Peter Gavin wrote: >> Hello everyone, >> >> I have this piece of code I've been working on, and I've been stuck on >> tracking down a space leak in it for some time now. The code is essentially >> a tight loop that updates a rather largish data structure with embedded >> functions that are called by the driver loop. The code doesn't accumulate >> any data as the loop runs (at least deliberately), so I would expect the >> memory profile to be flat. Unfortunately, the profile is a wedge :) I've >> added bangs and `seq` literally everywhere, and it looks (to me at least) >> like there's nothing left to be lazily evaluated anywhere. I've used >> retainer profiling, and the functions that are leaking space according to >> the profiler output are strict throughout. > > I don't know what I can suggest as for general tactics. Without > seeing the code it's hard to say what could be happening. Just > remember that strictness is not always the answer! > > >From the very limited amount of information I got from this > description, my first guess would be the data structure itself, or the > functions inside it. If it's lazily generated, then you might not be > seeing the full amount of space it's taking up at once. But that's > just a guess. > > Luke > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From jgbailey at gmail.com Thu Jul 17 16:58:03 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Thu Jul 17 16:48:23 2008 Subject: [Haskell-cafe] Space leaks In-Reply-To: <487F8BEA.9050109@gmail.com> References: <487F8BEA.9050109@gmail.com> Message-ID: On Thu, Jul 17, 2008 at 11:14 AM, Peter Gavin wrote: > evaluated anywhere. I've used retainer profiling, and the functions that > are leaking space according to the profiler output are strict throughout. > Have you looked at the Core code generated? That might show something that isn't strict which you think is. I believe "let" statements in Core represent allocations, while "case" statements are strict. In case you don't know, the best thing you can do to read core is to add comment annotations ({-# CORE "..." #-} I think), which will help you pinpoint which Haskell gets turned into core. To produce core with 6.8, use the -fext-core flag. Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080717/f68ea0f7/attachment.htm From magnus at therning.org Thu Jul 17 17:20:43 2008 From: magnus at therning.org (Magnus Therning) Date: Thu Jul 17 17:11:06 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: References: Message-ID: <487FB7AB.5010006@therning.org> Felipe Lessa wrote: > Hi, > > I tried googling and searching the haskellwiki about this but wasn't > lucky enough. My question is: is there a way to send struct arguments > to C functions via the FFI or do I need to create a C wrapper? I guess > there isn't, and while I can live without it, I'd like to leave no > doubt. You might find this old post of mine useful. http://therning.org/magnus/archives/315 > > > Details: > > I have something like > > ==================== > typedef struct vect { > float x,y; > } vect; > > void func(vect v); > ===================== > > on the C side and > > ==================== > -- Please disregard float /= Float, just an example :) > data Vector = Vector Float Float > > instance Storable Vector where > ... > ==================== > > on the Haskell side, and I want to call func with Vector as argument. > Now, Vector isn't a basic FFI type, although it implements Storable. > So does that mean that I need to create something like > > ==================== > void funcWrapper(vect *v) { > func(*v); > } > ==================== > > and then allocate some temporary memory on the Haskell side to use func? > > Cheers! > -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus Haskell is an even 'redder' pill than Lisp or Scheme. -- PaulPotts -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080717/1ab7bb3f/signature.bin From duncan.coutts at worc.ox.ac.uk Thu Jul 17 19:19:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jul 17 19:08:48 2008 Subject: [Haskell-cafe] FFI and struct arguments In-Reply-To: References: <1216295162.6279.208.camel@localhost> <125EACD0CAE4D24ABDB4D148C4593DA9049E94BD@GBLONXMB02.corp.amvescap.net> Message-ID: <1216336760.6279.224.camel@localhost> On Thu, 2008-07-17 at 13:36 -0300, Felipe Lessa wrote: > I am using hsc2hs currently, but googling about #def with Cabal I > found out that some people were having trouble to make Cabal discover > that hsc2hs had created a new C file. Specifically, bug #245 [1] which > says that the milestone is undefined. Note that a milestone of _|_ doesn't mean we don't want a fix, just that nobody has said they're going to do it. We would welcome a fix for this if someone wants to contribute. (Of course we'd like contributions to fix all our bugs!) Duncan From pgavin at gmail.com Thu Jul 17 23:00:26 2008 From: pgavin at gmail.com (Peter Gavin) Date: Thu Jul 17 22:50:48 2008 Subject: [Haskell-cafe] Space leaks In-Reply-To: <4165d3a70807171334l1b475fa3p750a1027ab1a6446@mail.gmail.com> References: <487F8BEA.9050109@gmail.com> <7ca3f0160807171158q8422f6ai252e946780271f0a@mail.gmail.com> <4165d3a70807171334l1b475fa3p750a1027ab1a6446@mail.gmail.com> Message-ID: <4880074A.40007@gmail.com> Thanks for the responses. This is basically what I've got looks like (grossly simplified): data Monad m => Foo m a b = Foo { action :: m (Foo m a b, b) , update :: a -> Foo m a b } The driver loop injects new values with update, and executes action whenever it's ready to, replacing the old Foo with the newly returned Foo. I finally fixed the space leak it by inserting SPECIALIZE pragmas for Foo IO a b on every function that creates a Foo. I'm not sure if I can remove all the strictness annotations I've accumulated yet, though. This is a bit disconcerting, though, because in the future I'd like to not use IO and use a strict State instead. I hope I won't have to specialize for every monad that ends up getting used. Thanks again, Pete Jefferson Heard wrote: > Peter, from 500 feet, we can't see much, but your strictness might > actually be your problem depending on what "largish" looks like and > whether you're reading your data from disc. It's entirely possible > that your data structure updates or disc reads are head-strict and > you're evaluating or loading the entirety of data in memory at a > single update. > > -- Jeff > > On Thu, Jul 17, 2008 at 2:58 PM, Luke Palmer wrote: >> On Thu, Jul 17, 2008 at 12:14 PM, Peter Gavin wrote: >>> Hello everyone, >>> >>> I have this piece of code I've been working on, and I've been stuck on >>> tracking down a space leak in it for some time now. The code is essentially >>> a tight loop that updates a rather largish data structure with embedded >>> functions that are called by the driver loop. The code doesn't accumulate >>> any data as the loop runs (at least deliberately), so I would expect the >>> memory profile to be flat. Unfortunately, the profile is a wedge :) I've >>> added bangs and `seq` literally everywhere, and it looks (to me at least) >>> like there's nothing left to be lazily evaluated anywhere. I've used >>> retainer profiling, and the functions that are leaking space according to >>> the profiler output are strict throughout. >> I don't know what I can suggest as for general tactics. Without >> seeing the code it's hard to say what could be happening. Just >> remember that strictness is not always the answer! >> >> >From the very limited amount of information I got from this >> description, my first guess would be the data structure itself, or the >> functions inside it. If it's lazily generated, then you might not be >> seeing the full amount of space it's taking up at once. But that's >> just a guess. >> >> Luke >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > From pgavin at gmail.com Fri Jul 18 00:21:03 2008 From: pgavin at gmail.com (Peter Gavin) Date: Fri Jul 18 00:11:24 2008 Subject: [Haskell-cafe] Space leaks In-Reply-To: <4880074A.40007@gmail.com> References: <487F8BEA.9050109@gmail.com> <7ca3f0160807171158q8422f6ai252e946780271f0a@mail.gmail.com> <4165d3a70807171334l1b475fa3p750a1027ab1a6446@mail.gmail.com> <4880074A.40007@gmail.com> Message-ID: <48801A2F.8080408@gmail.com> Replying to myself... Interesting. I removed all the bangs other than the obvious loop variables, and all the uses of seq that I had inserted, and there's still no leak. Does anyone know why the leak would disappear when GHC is using IO other than a generic (unspecified) monad? Is there something special about the >>= and return operators for IO that aren't true for other monads? Thanks, Pete Peter Gavin wrote: > Thanks for the responses. > > This is basically what I've got looks like (grossly simplified): > > > data Monad m => Foo m a b = > Foo > { action :: m (Foo m a b, b) > , update :: a -> Foo m a b > } > > The driver loop injects new values with update, and executes action > whenever it's ready to, replacing the old Foo with the newly returned Foo. > > I finally fixed the space leak it by inserting SPECIALIZE pragmas for > Foo IO a b on every function that creates a Foo. I'm not sure if I can > remove all the strictness annotations I've accumulated yet, though. This > is a bit disconcerting, though, because in the future I'd like to not > use IO and use a strict State instead. I hope I won't have to specialize > for every monad that ends up getting used. > > Thanks again, > Pete > > > Jefferson Heard wrote: >> Peter, from 500 feet, we can't see much, but your strictness might >> actually be your problem depending on what "largish" looks like and >> whether you're reading your data from disc. It's entirely possible >> that your data structure updates or disc reads are head-strict and >> you're evaluating or loading the entirety of data in memory at a >> single update. >> >> -- Jeff >> >> On Thu, Jul 17, 2008 at 2:58 PM, Luke Palmer wrote: >>> On Thu, Jul 17, 2008 at 12:14 PM, Peter Gavin wrote: >>>> Hello everyone, >>>> >>>> I have this piece of code I've been working on, and I've been stuck on >>>> tracking down a space leak in it for some time now. The code is >>>> essentially >>>> a tight loop that updates a rather largish data structure with embedded >>>> functions that are called by the driver loop. The code doesn't >>>> accumulate >>>> any data as the loop runs (at least deliberately), so I would expect >>>> the >>>> memory profile to be flat. Unfortunately, the profile is a wedge >>>> :) I've >>>> added bangs and `seq` literally everywhere, and it looks (to me at >>>> least) >>>> like there's nothing left to be lazily evaluated anywhere. I've used >>>> retainer profiling, and the functions that are leaking space >>>> according to >>>> the profiler output are strict throughout. >>> I don't know what I can suggest as for general tactics. Without >>> seeing the code it's hard to say what could be happening. Just >>> remember that strictness is not always the answer! >>> >>> >From the very limited amount of information I got from this >>> description, my first guess would be the data structure itself, or the >>> functions inside it. If it's lazily generated, then you might not be >>> seeing the full amount of space it's taking up at once. But that's >>> just a guess. >>> >>> Luke >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> > From martin.hofmann at uni-bamberg.de Fri Jul 18 03:49:43 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Fri Jul 18 03:40:01 2008 Subject: [Haskell-cafe] syntactic anti-unification of TH terms --- best practise? Message-ID: <1216367383.5957.37.camel@ios.cogsys.wiai.uni-bamberg.de> I am implementing syntactic anti-unification for TH terms (Exp, Pat, Clause, ...). For example anti-unifying the clauses tail (1:xs) = xs tail (1:2:xs) = (2:xs) would yield tail (1:x1) = x1 whereas the anti-instance of last (1:[]) = 1 last (1:xs) = last xs is last (1:x1) = x2 So different subterms are always replaced with the same variable if anti-unified twice. So far, so good, there is nothing complicated. I am using a State Monad to keep track of my variables and defined a type class for anti-unification and implemented instances for Exp, Pat, ... type AU a = State (Data.Map [a] a) a class Antiunifieable t where antiunify :: (Ord t) => [t] -> t antiunify = (\t -> evalState (aunify t) M.empty) aunify :: (Ord t) => [t] -> AU t Problems arise when I come to clauses, defined in TH as Clause [Pat] Body [Dec] where Body is for example NormalB Exp Since a term can occur both as a pattern on the left-hand side of the equation and also as expression on the right-hand side, I need to keep track of this, too. So in fact, I have to anti-unify the patterns, 'translate' the resulting state (Data.Map [Pat] Pat) to (Data.Map [Body] Body) and pass it to the state transformer for anti-unifying the bodies. Similarly, from Body to Exp. This seems a bit ugly to me, but I have no idea how to solve it more elegantly. I thought about introducing some kind of wrapper type like data Term = TC Clause | TB Body | TP Pat | TE Exp and implement an instance for Eq and Antiunifieable for it. But again, this is not better either and I run into a lot of bookkeeping when processing it. Is there some kind of best practise dealing with such a problem? I am not sure if MonadTransformers would help here, because it is always the same monad but with different parameter. Thanks a lot, Martin From claus.reinke at talk21.com Fri Jul 18 05:25:40 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jul 18 05:16:02 2008 Subject: [Haskell-cafe] syntactic anti-unification of TH terms --- bestpractise? References: <1216367383.5957.37.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <01cf01c8e8b8$40566750$ec2c7ad5@cr3lt> > Since a term can occur both as a pattern on the left-hand side of the > equation and also as expression on the right-hand side, I need to keep > track of this, too. > > So in fact, I have to anti-unify the patterns, 'translate' the resulting > state (Data.Map [Pat] Pat) to (Data.Map [Body] Body) and pass it to the > state transformer for anti-unifying the bodies. Similarly, from Body to > Exp. Don't you need to do this translation anyway, because Pat and Exp use different constructors? Perhaps you can reduce some of the lookup cases to looking up just Pat and Exp (eg, looking up in a Body or Clause or Pat or Exp could always give antiunifiers in terms of either Pat or Exp, so you need only one type of Map)? Claus From martin.hofmann at uni-bamberg.de Fri Jul 18 06:01:28 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Fri Jul 18 05:51:46 2008 Subject: [Haskell-cafe] syntactic anti-unification of TH terms --- best practice? In-Reply-To: <01cf01c8e8b8$40566750$ec2c7ad5@cr3lt> References: <1216367383.5957.37.camel@ios.cogsys.wiai.uni-bamberg.de> <01cf01c8e8b8$40566750$ec2c7ad5@cr3lt> Message-ID: <1216375288.5957.49.camel@ios.cogsys.wiai.uni-bamberg.de> > Don't you need to do this translation anyway, because Pat > and Exp use different constructors? Yes, somewhere I have to say how to convert Pat to Exp. > Perhaps you can reduce > some of the lookup cases to looking up just Pat and Exp > (eg, looking up in a Body or Clause or Pat or Exp could > always give antiunifiers in terms of either Pat or Exp, so > you need only one type of Map)? So you mean use a specific (M.Map [Exp] Exp) instead of a general (M.Map [a] a)? Yes, this would make sense. Then I only translate the value I want to lookup (if at all) and not the whole map, which I can pass to the accordant state transformer straight away. I'll try it out. Thanks, Martin From nicolas.pouillard at gmail.com Fri Jul 18 06:33:35 2008 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Fri Jul 18 06:24:36 2008 Subject: [Haskell-cafe] syntactic anti-unification of TH terms --- best practice? In-Reply-To: <1216375288.5957.49.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1216367383.5957.37.camel@ios.cogsys.wiai.uni-bamberg.de> <01cf01c8e8b8$40566750$ec2c7ad5@cr3lt> <1216375288.5957.49.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <1216377139-sup-7203@ausone.inria.fr> Excerpts from Martin Hofmann's message of Fri Jul 18 12:01:28 +0200 2008: > > > Don't you need to do this translation anyway, because Pat > > and Exp use different constructors? > > Yes, somewhere I have to say how to convert Pat to Exp. That's often doable, but you have to deal with patterns like `_', `v@pat', `!v'... -- Nicolas Pouillard -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 240 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080718/3fe65867/signature.bin From sk at k-hornz.de Fri Jul 18 06:54:23 2008 From: sk at k-hornz.de (stefan kersten) Date: Fri Jul 18 06:45:04 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: On 17.07.2008, at 21:46, Lennart Augustsson wrote: > If scaleFloat and exponent are implemented with bit twiddling they can > be quite fast. is there a way in ghc to 'cast' between float/int32 and double/int64 (without going through memory)? From sk at k-hornz.de Fri Jul 18 07:25:55 2008 From: sk at k-hornz.de (stefan kersten) Date: Fri Jul 18 07:20:52 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: On 18.07.2008, at 13:05, Henning Thielemann wrote: > On Fri, 18 Jul 2008, stefan kersten wrote: > >> On 17.07.2008, at 21:46, Lennart Augustsson wrote: >>> If scaleFloat and exponent are implemented with bit twiddling >>> they can >>> be quite fast. >> >> is there a way in ghc to 'cast' between float/int32 and double/ >> int64 (without going through memory)? > > What speaks against going through memory? If you want to write a > large chunk of Doubles to disk, you may write it to a > StorableVector and write that to disk. However shipping internal > bit patterns to disk may violate portability, because on different > machines there can be different floating point formats. What other > situations might be there, where you want to cast Float to Int32 > and so on? for implementing scaleFloat and exponent on the bitlevel as lennart suggested, it would be preferable if the cast would be compiled to a register move/reinterpretation, rather than a store/load through several layers of abstraction (such as Data.Binary). i'm just curious ;) From lemming at henning-thielemann.de Fri Jul 18 07:05:51 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 18 07:26:54 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: On Fri, 18 Jul 2008, stefan kersten wrote: > On 17.07.2008, at 21:46, Lennart Augustsson wrote: >> If scaleFloat and exponent are implemented with bit twiddling they can >> be quite fast. > > is there a way in ghc to 'cast' between float/int32 and double/int64 (without > going through memory)? What speaks against going through memory? If you want to write a large chunk of Doubles to disk, you may write it to a StorableVector and write that to disk. However shipping internal bit patterns to disk may violate portability, because on different machines there can be different floating point formats. What other situations might be there, where you want to cast Float to Int32 and so on? From mmitar at gmail.com Fri Jul 18 08:23:41 2008 From: mmitar at gmail.com (Mitar) Date: Fri Jul 18 08:13:56 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> Message-ID: Hi! On Sat, Jul 12, 2008 at 3:33 AM, Max Bolingbroke wrote: > If findColor had been a function defined in terms of foldr rather than > using explicit recursion, then theres a good chance GHC 6.9 would have > fused it with the list to yield your optimized, loop unrolled, > version: My first version was with msum. Is this also covered by this fusion? (And it is interesting that my own recursion version is faster than the version with msum. Why?) > Incidentally, if in your most recent email castRayScene2 was your only > used of castRay, GHC would have inlined the whole definition into that > use site and you would have got castRayScene1 back again. It is a little more tricky. I choose in an IO monad which scene it will render (selected by a program argument). So at compile time it does not yet know which one it will use. But there is a finite number of possibilities (in my case two) - why not inline both versions and at run time choose one? Mitar From lemming at henning-thielemann.de Fri Jul 18 08:56:27 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 18 08:46:43 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: On Fri, 18 Jul 2008, stefan kersten wrote: > for implementing scaleFloat and exponent on the bitlevel as lennart > suggested, it would be preferable if the cast would be compiled to a register > move/reinterpretation, rather than a store/load through several layers of > abstraction (such as Data.Binary). i'm just curious ;) Ok, but then you need a check, whether the numbers on your machine are in IEEE format. This check could be done when configuring 'base' package. The current implementation in GHC.Float could be used as fall-back. From igloo at earth.li Fri Jul 18 09:25:40 2008 From: igloo at earth.li (Ian Lynagh) Date: Fri Jul 18 09:15:59 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <3F8A5875-4937-4F2C-8A9C-F720BCF68EDB@k-hornz.de> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <20080717154241.GA12211@matrix.chaos.earth.li> <3F8A5875-4937-4F2C-8A9C-F720BCF68EDB@k-hornz.de> Message-ID: <20080718132540.GA22264@matrix.chaos.earth.li> On Thu, Jul 17, 2008 at 06:56:52PM +0200, stefan kersten wrote: > > c_magnitude0 (Complex.Data.magnitude) 0m7.249s > c_magnitude1 (non-scaling version) 0m1.176s > c_magnitude2 (scaling version, strict square) 0m3.278s Thanks! I've filed a bug here: http://hackage.haskell.org/trac/ghc/ticket/2450 Ian From chaddai.fouche at gmail.com Fri Jul 18 09:54:12 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Fri Jul 18 09:44:28 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> Message-ID: 2008/7/12 Mitar : > So that I can easily change the type everywhere. But it would be much > nicer to write: > > data Quaternion a = Q !a !a !a !a deriving (Eq,Show) > > Only the performance of Num instance functions of Quaternion is then > quite worse. You can probably use a specialization pragma to get around that. -- Jeda? From mmitar at gmail.com Fri Jul 18 11:28:10 2008 From: mmitar at gmail.com (Mitar) Date: Fri Jul 18 11:18:25 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> Message-ID: Hi! On Fri, Jul 18, 2008 at 3:54 PM, Chadda? Fouch? wrote: >> So that I can easily change the type everywhere. But it would be much >> nicer to write: >> >> data Quaternion a = Q !a !a !a !a deriving (Eq,Show) >> >> Only the performance of Num instance functions of Quaternion is then >> quite worse. > > You can probably use a specialization pragma to get around that. But why is this not automatic? If I use Quaternions of only one type in the whole program then why it does not make specialized version for it? At least with -O2 switch. Why exactly are polymorphic functions slower? Is not this just a question of type checking (and of writing portable/reusable code)? But later on in a compiler process we do know of which type exactly is the called function - so we could use a function as it would be written only for that type. Something what specialization is doing as I see. I thought this is always done. Mitar From dons at galois.com Fri Jul 18 13:47:31 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 18 13:37:51 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: <20080718174731.GD16953@scytale.galois.com> sk: > On 17.07.2008, at 21:46, Lennart Augustsson wrote: > >If scaleFloat and exponent are implemented with bit twiddling they can > >be quite fast. > > is there a way in ghc to 'cast' between float/int32 and double/int64 > (without going through memory)? Yeah, "fromIntegral/Int->Float" fromIntegral = int2Float "truncate/Float->Int" truncate = float2Int "truncate/Double->Int" truncate = double2Int with appropriate no-op fromIntegrals for the 32 and 64 variants. From sk at k-hornz.de Fri Jul 18 13:56:48 2008 From: sk at k-hornz.de (stefan kersten) Date: Fri Jul 18 13:49:03 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <20080718174731.GD16953@scytale.galois.com> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> <20080718174731.GD16953@scytale.galois.com> Message-ID: <6753C45A-AB0A-4C27-9BA9-5B1E5EACE57D@k-hornz.de> On 18.07.2008, at 19:47, Don Stewart wrote: > sk: >> On 17.07.2008, at 21:46, Lennart Augustsson wrote: >>> If scaleFloat and exponent are implemented with bit twiddling >>> they can >>> be quite fast. >> >> is there a way in ghc to 'cast' between float/int32 and double/int64 >> (without going through memory)? > > Yeah, > > "fromIntegral/Int->Float" fromIntegral = int2Float > "truncate/Float->Int" truncate = float2Int > > > "truncate/Double->Int" truncate = double2Int > > with appropriate no-op fromIntegrals for the 32 and 64 variants. i actually meant something like *(uint32_t*)fptr, but thanks anyway ;) From dons at galois.com Fri Jul 18 14:03:37 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 18 13:53:52 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: <6753C45A-AB0A-4C27-9BA9-5B1E5EACE57D@k-hornz.de> References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> <20080718174731.GD16953@scytale.galois.com> <6753C45A-AB0A-4C27-9BA9-5B1E5EACE57D@k-hornz.de> Message-ID: <20080718180337.GG16953@scytale.galois.com> sk: > On 18.07.2008, at 19:47, Don Stewart wrote: > >sk: > >>On 17.07.2008, at 21:46, Lennart Augustsson wrote: > >>>If scaleFloat and exponent are implemented with bit twiddling > >>>they can > >>>be quite fast. > >> > >>is there a way in ghc to 'cast' between float/int32 and double/int64 > >>(without going through memory)? > > > >Yeah, > > > > "fromIntegral/Int->Float" fromIntegral = int2Float > > "truncate/Float->Int" truncate = float2Int > > > > > > "truncate/Double->Int" truncate = double2Int > > > >with appropriate no-op fromIntegrals for the 32 and 64 variants. > > i actually meant something like *(uint32_t*)fptr, but thanks anyway ;) ah well, these should compile into as-close-to-noops as possible. From ales.bizjak0 at gmail.com Fri Jul 18 14:29:22 2008 From: ales.bizjak0 at gmail.com (=?iso-8859-2?B?QWxluSBCaXpqYWs=?=) Date: Fri Jul 18 14:18:26 2008 Subject: [Haskell-cafe] FFI C Structs Message-ID: Hello, Suppose I have a C struct like typedef { int a; int *b; } Foo; typedef Foo *fooptr; and all worker functions which are all basically int foofun (fooptr , fooptr, fooptr) where the first one is a out argument and the other two are in arguments and the return value is (almost) irrelevant. Now before I can pass arguments I have to initialize them and this is done with void init(fooptr ) function and all values have to be cleared which is done with void clear(fooptr ). I tried to import this to haskell like this. data Foo = Foo type FFptr = ForeignPtr Foo and because I would like to have a nice interface without manually worrying about allocation and freeing up I tried something like this: foreign import ccall "&clear" clear :: FunPtr (Ptr Foo -> IO ()) foreign import ccall "init" init :: Ptr Foo -> IO () foreign import ccall "foofun" foofun_ :: Ptr Foo -> Ptr Foo -> Ptr Foo -> IO Int foofun :: FFptr -> FFptr -> FFptr foofun f1 f2 = unsafePerformIO f where f = withForeignPtr f1 (p1 -> withForeignPtr f2 (p2 -> do p3 <- malloc init p3 r <- foofun_ p3 p1 p2 newForeignPtr clear p3 Now should that work or do I have to do some more reading on ffi and if so, would anyone recommend some material because this is all I could come up with. PS: An example of a haskell binding like this would be even more useful, if anyone knows of such. From batterseapower at hotmail.com Fri Jul 18 15:57:38 2008 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Fri Jul 18 15:47:54 2008 Subject: [Haskell-cafe] Profiling nested case In-Reply-To: References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> Message-ID: <9d4d38820807181257u3c67aec6i3c55eae6684e6f6a@mail.gmail.com> 2008/7/18 Mitar : > On Sat, Jul 12, 2008 at 3:33 AM, Max Bolingbroke > wrote: >> If findColor had been a function defined in terms of foldr rather than >> using explicit recursion, then theres a good chance GHC 6.9 would have >> fused it with the list to yield your optimized, loop unrolled, >> version: > > My first version was with msum. Is this also covered by this fusion? Note that as I said the fusion only applies to 6.9 onwards. However, assuming that you were using msum at the list monad then since msum = concat is defined in terms of foldr there is a chance it could happen. The best guide to this kind of thing is not asking me but rather looking at the Core output by GHC for your particular program. > (And it is interesting that my own recursion version is faster than > the version with msum. Why?) I don't know why you find this suprising :-). Your own version is specialized exactly for the situation you wish to use it for. msum is a generic combinator, which naturally makes it less amenable to optimization because there is less information available about it's usage pattern. Note that GHC will of course try to do its best to de-specialize the msum function for any particular scenario it's used in, through inlining etc, but there are no guarantees. > It is a little more tricky. I choose in an IO monad which scene it > will render (selected by a program argument). So at compile time it > does not yet know which one it will use. But there is a finite number > of possibilities (in my case two) - why not inline both versions and > at run time choose one? If there was only one static occurance of each identifier in your module then it would do that. This is because there is no code size implications for inlining a function into it's unitary use site. Inlining is not a cure-all for performance though: if you inline too much then you increase code size and hence increase the amount of main memory you're reading and reduce instruction cache hits, not to mention fill up your disk with multi-MB binaries. Max From ben.franksen at online.de Fri Jul 18 19:03:12 2008 From: ben.franksen at online.de (Ben Franksen) Date: Fri Jul 18 18:53:37 2008 Subject: [Haskell-cafe] Re: Profiling nested case References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> Message-ID: Mitar wrote: > On Fri, Jul 18, 2008 at 3:54 PM, Chadda? Fouch? > wrote: >>> So that I can easily change the type everywhere. But it would be much >>> nicer to write: >>> >>> data Quaternion a = Q !a !a !a !a deriving (Eq,Show) >>> >>> Only the performance of Num instance functions of Quaternion is then >>> quite worse. >> >> You can probably use a specialization pragma to get around that. > > But why is this not automatic? If I use Quaternions of only one type > in the whole program then why it does not make specialized version for > it? At least with -O2 switch. You could try jhc: it does whole program optimization. Ghc compiles each module separately. Cheers Ben From dons at galois.com Fri Jul 18 19:14:34 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 18 19:04:54 2008 Subject: [Haskell-cafe] Re: Profiling nested case In-Reply-To: References: <9d4d38820807111833s65cc095ej6eaa00449f1ea27b@mail.gmail.com> <7ca3f0160807121239h6f26da2au7c2b6aa5cdc8f2f5@mail.gmail.com> Message-ID: <20080718231434.GV16953@scytale.galois.com> ben.franksen: > Mitar wrote: > > On Fri, Jul 18, 2008 at 3:54 PM, Chadda? Fouch? > > wrote: > >>> So that I can easily change the type everywhere. But it would be much > >>> nicer to write: > >>> > >>> data Quaternion a = Q !a !a !a !a deriving (Eq,Show) > >>> > >>> Only the performance of Num instance functions of Quaternion is then > >>> quite worse. > >> > >> You can probably use a specialization pragma to get around that. > > > > But why is this not automatic? If I use Quaternions of only one type > > in the whole program then why it does not make specialized version for > > it? At least with -O2 switch. > > You could try jhc: it does whole program optimization. Ghc compiles each > module separately. No need to switch compilers. GHC is able to do a pretty good job. Consider, data Q a = Q !a !a !a !a deriving (Eq,Show) -- yeah, polymorphic go :: Num a => Q a -> Q a go (Q 0 0 0 0) = Q 1 2 3 4 go (Q a b c d) = go $! Q (a * a) (b * b) (c * c) (d * d) -- ah, but we fix it. type QI = Q Int -- and try that: main = print (go (Q 2 3 7 13 :: QI)) GHC specialises and gives us, $wgo :: Int# -> Int# -> Int# -> Int# -> Q Int So just use ghc-core to check what you're getting. -- Don From ben.franksen at online.de Fri Jul 18 19:26:37 2008 From: ben.franksen at online.de (Ben Franksen) Date: Fri Jul 18 19:17:04 2008 Subject: [Haskell-cafe] Re: Trying to install cabal References: <48764E54.2090303@ukfsn.org> <487AFC20.4020100@daimi.au.dk> Message-ID: Henning Thielemann wrote: > On Mon, 14 Jul 2008, Tillmann Rendel wrote: > >> Apropos cabal-install: can i make it build documentation during the >> installation process and store them in some central location? > > I also wondered about that. Maybe a '--haddock' flag for 'cabal install' ? Everyone seems to ask the same (me too). See Ticket #206 (http://hackage.haskell.org/trac/hackage/ticket/206). Additional comments count as priority bumper! Cheers Ben From jim at sdf-eu.org Fri Jul 18 20:16:46 2008 From: jim at sdf-eu.org (Jim Burton) Date: Fri Jul 18 20:07:17 2008 Subject: [Haskell-cafe] Help using Network.Curl Message-ID: <87ej5q3ez5.wl%jim@sdf-eu.org> I want to convert this code (a Hello World with the ebay API) to the curl binding in the hope that it will handle SSL and redirections etc better. Can someone give me some pointers please, or a link to an example? I haven't used libcurl or Network.Curl and can't find anything helpful...Thanks! ----------------- import Network.URI import Network.HTTP import Network.Browser import Data.Maybe (fromJust) mkRequest :: Request mkRequest = Request { rqURI = fromJust (parseURI "https://api.sandbox.ebay.com/ws/api.dll") , rqMethod = POST , rqBody = body , rqHeaders = headers } headers :: [Header] headers = [Header HdrContentType "text/xml" , Header (HdrCustom "X-EBAY-API-COMPATIBILITY-LEVEL") "391" , Header (HdrCustom "X-EBAY-API-DEV-NAME") "DevName" , Header (HdrCustom "X-EBAY-API-APP-NAME") "AppName" , Header (HdrCustom "X-EBAY-API-CERT-NAME") "CertName" , Header (HdrCustom "X-EBAY-API-CALL-NAME") "GeteBayOfficialTime" , Header (HdrCustom "X-EBAY-API-SITEID") "0" ] body = "" ++ "" ++ " " ++ " "++"MyToken"++"" ++ " " ++ "" main = do (_, resp) <- browse (request mkRequest) print resp From lgreg.meredith at biosimilarity.com Fri Jul 18 20:25:35 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Fri Jul 18 20:15:49 2008 Subject: [Haskell-cafe] Fwd: NW Functional Programming Interest Group In-Reply-To: <5de3f5ca0802011155l771cc649wa0e671bbe3abe364@mail.gmail.com> References: <5de3f5ca0802011155l771cc649wa0e671bbe3abe364@mail.gmail.com> Message-ID: <5de3f5ca0807181725x36139c55gbd64f479688066ee@mail.gmail.com> All, Apologies for multiple listings. This is just a friendly reminder to Northwest functionally minded folks that this month's meeting is to be held The Seattle Public Library 5009 Roosevelt Way N.E. Seattle, WA 98105 206-684-4063 from 18.30 - 19:45 on July 23rd. We'll be getting a demo of a scala-lift-based application that compiles a graphical rendition of functional expressions into expressions in a functional language. Hope to see you there. Monadically yours, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080718/612affd7/attachment.htm From vigalchin at gmail.com Sat Jul 19 02:40:18 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Jul 19 02:30:31 2008 Subject: [Haskell-cafe] carry "state" around .... Message-ID: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> hello, Following is more of a criticism of Linux implementation of the Posix real-time extension of asynchronous I/O.... if not interesting please skip. The central data structure for Posix AIO is an aiocb. In any case, the Linux implementors added to the aiocb: /* Asynchronous I/O control block. */ struct aiocb { int aio_fildes; /* File desriptor. */ int aio_lio_opcode; /* Operation to be performed. */ int aio_reqprio; /* Request priority offset. */ volatile void *aio_buf; /* Location of buffer. */ size_t aio_nbytes; /* Length of transfer. */ struct sigevent aio_sigevent; /* Signal number and value. */ /* Internal members. */ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< struct aiocb *__next_prio; int __abs_prio; int __policy; int __error_code; __ssize_t __return_value; #ifndef __USE_FILE_OFFSET64 __off_t aio_offset; /* File offset. */ char __pad[sizeof (__off64_t) - sizeof (__off_t)]; #else __off64_t aio_offset; /* File offset. */ #endif char __unused[32]; }; My viewpoint is that the above "Internal members" must be "carried" around in a Haskell program. Am I correct?? If I am correct, then the Linux implementation of Posix AIO is not portable to say Solaris? In hindsight, if I am correct, it seems that the Linux implementation of AIO should use the ordered pair (pid, fd) to reference the "internal" members and leave the "aiocb" "clean"? Very kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/b4b16e78/attachment.htm From catamorphism at gmail.com Sat Jul 19 06:35:09 2008 From: catamorphism at gmail.com (Tim Chevalier) Date: Sat Jul 19 06:25:23 2008 Subject: [Haskell-cafe] FFI C Structs In-Reply-To: References: Message-ID: <4683d9370807190335h6b41e57cjc0b2361a0fa9e3f4@mail.gmail.com> On 7/18/08, Ale? Bizjak wrote: > PS: An example of a haskell binding like this would be even more useful, if > anyone knows of such. I don't know that it's good for much else besides serving as an example of an FFI binding that uses structs (and possibly as an example of what not to do), but you could look at my half-finished GraphicsMagick binding: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsmagick Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "Good memories make me feel bad / Bad memories make me feel small" --Dom Leone From duncan.coutts at worc.ox.ac.uk Sat Jul 19 09:17:22 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jul 19 09:06:35 2008 Subject: [Haskell-cafe] Re: Trying to install cabal In-Reply-To: References: <48764E54.2090303@ukfsn.org> <487AFC20.4020100@daimi.au.dk> Message-ID: <1216473442.6279.284.camel@localhost> On Sat, 2008-07-19 at 01:26 +0200, Ben Franksen wrote: > Henning Thielemann wrote: > > On Mon, 14 Jul 2008, Tillmann Rendel wrote: > > > >> Apropos cabal-install: can i make it build documentation during the > >> installation process and store them in some central location? > > > > I also wondered about that. Maybe a '--haddock' flag for 'cabal install' ? > > Everyone seems to ask the same (me too). See Ticket #206 > (http://hackage.haskell.org/trac/hackage/ticket/206). Additional comments > count as priority bumper! So! Who wants to implement it? :-) Volunteers please line up over here. Duncan From mmitar at gmail.com Sat Jul 19 09:48:21 2008 From: mmitar at gmail.com (Mitar) Date: Sat Jul 19 09:38:34 2008 Subject: [Haskell-cafe] Re: Profiling nested case In-Reply-To: References: Message-ID: Hi! I had to change code somewhat. Now I have a function like: worldScene point = case redSphere (0,50,0) 50 point of v@(Right _) -> v Left d1 -> case greenSphere (25,-250,0) 50 point of v@(Right _) -> v Left d2 -> Left $ d1 `min` d2 (Of course there could be more objects.) Any suggestion how could I make this less hard-coded? Something which would take a list of objects (object functions) and then return a Right if any object function return Right or a minimum value of all Lefts. But that it would have similar performance? If not on my GHC version (6.8.3) on something newer (which uses fusion or something). Is there some standard function for this or should I write my own recursive function to run over a list of object functions? But I am afraid that this will be hard to optimize for compiler. (It is important to notice that the order of executing object functions is not important so it could be a good candidate for parallelism.) Mitar From allbery at ece.cmu.edu Sat Jul 19 10:45:56 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jul 19 10:36:13 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> Message-ID: On 2008 Jul 19, at 2:40, Galchin, Vasili wrote: > My viewpoint is that the above "Internal members" must be "carried" > around in a Haskell program. Am I correct?? If I am correct, then > the Linux implementation of Posix AIO is not portable to say > Solaris? In hindsight, if I am correct, it seems that You are correct --- but Solaris also has its own addenda, and its standard fields are not at the same offsets as in the Linux aiocb. The only safe way to do this is to use an opaque aiocb on the Haskell side and accessors in C via FFI. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/e1514b2d/attachment-0001.htm From duncan.coutts at worc.ox.ac.uk Sat Jul 19 09:28:38 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jul 19 10:54:36 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> Message-ID: <1216474118.6279.292.camel@localhost> On Sat, 2008-07-19 at 01:40 -0500, Galchin, Vasili wrote: > hello, > > > Following is more of a criticism of Linux implementation of the > Posix real-time extension of asynchronous I/O.... if not interesting > please skip. The central data structure for Posix AIO is an aiocb. In > any case, the Linux implementors added to the aiocb: [..] > My viewpoint is that the above "Internal members" must be "carried" > around in a Haskell program. Am I correct?? If I am correct, then the > Linux implementation of Posix AIO is not portable to say Solaris? In > hindsight, if I am correct, it seems that the Linux implementation of > AIO should use the ordered pair (pid, fd) to reference the "internal" > members and leave the "aiocb" "clean"? Although it is different between platforms it is still portable. When you allocate memory in C for the aiocb struct you would use sizeof(aiocb). That's portable even if the size is different on Linux vs Solaris. Then members are only accessed by name which is again portable. Your problem perhaps is that you're trying to convert an aiocb into a pure haskell version and convert it back and expect to retain all the information. I think that is a mistake. Don't pass the aiocb's by value, pass them by reference. Use a ForeignPtr and just access the members you need whenever you need them. Duncan From duncan.coutts at worc.ox.ac.uk Sat Jul 19 11:05:23 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jul 19 10:54:48 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> Message-ID: <1216479923.6279.302.camel@localhost> On Sat, 2008-07-19 at 10:45 -0400, Brandon S. Allbery KF8NH wrote: > > On 2008 Jul 19, at 2:40, Galchin, Vasili wrote: > > > My viewpoint is that the above "Internal members" must be "carried" > > around in a Haskell program. Am I correct?? If I am correct, then > > the Linux implementation of Posix AIO is not portable to say > > Solaris? In hindsight, if I am correct, it seems that > > > You are correct --- but Solaris also has its own addenda, and its > standard fields are not at the same offsets as in the Linux aiocb. > The only safe way to do this is to use an opaque aiocb on the Haskell > side and accessors in C via FFI. You can do field accessors using an FFI pre-processor like c2hs or hsc2hs which will calculate the correct field offsets for the current platform. No need for C wrappers. Duncan From gtener at gmail.com Sat Jul 19 12:39:20 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Sat Jul 19 12:29:35 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues Message-ID: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: ansi2html.hs Type: application/octet-stream Size: 8228 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/4e3593f9/ansi2html-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: samo_pk_merusa.log Type: application/octet-stream Size: 12227 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/4e3593f9/samo_pk_merusa-0001.obj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/4e3593f9/samo_pk_merusa.log-0001.html From chaddai.fouche at gmail.com Sat Jul 19 15:52:45 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Sat Jul 19 15:42:57 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> Message-ID: 2008/7/19 Krzysztof Skrz?tnicki : > Hi all > > 1) Profiling shows that very simple functions are source of great memory and > time consumption. However, if I turn them off and simply print their input > arguments instead, the overall time and memory consumption doesn't change. > But now another function is acting badly. My guess: somehow the cost of > Parsec code is shifted into whatever function is using it's output. Let's > see: Are you using Parsec to parse the whole file ? Then your problem is there : Parsec needs to read and process the whole file before it can give us any output since it thinks it could have to give us an error instead and it can't be sure of that before he has read the whole thing... In your case, your problem is such that you would prefer to treat the file as a stream, isn't it ? There are some parser library that can give output lazily (look at polyparse flavour), another option would be to only use Parsec where you need it and just read and print the ordinary text for example. -- Jeda? From jim at sdf-eu.org Sat Jul 19 16:22:55 2008 From: jim at sdf-eu.org (Jim Burton) Date: Sat Jul 19 16:13:12 2008 Subject: [Haskell-cafe] Re: Help using Network.Curl Message-ID: <87r69pd3og.wl%jim@sdf-eu.org> I tried to translate that using the Network.Curl docs and ended up with the following code, but it's not sending the post data correctly (an ebay api error re an "unsupported verb", which I am told means a malformed request). Any ideas? The code from a perl tutorial (which works for me, making me think that my problem is just about the right way to post xml to a web service) follows the haskell version, which is meant to be a straight translation of that. Thanks, Jim ---------------------- [..skipped definitions of tokens etc..] opts = [CurlEncoding "text/xml" , CurlHttpHeaders ["X-EBAY-API-COMPATIBILITY-LEVEL="++compatLevel , "X-EBAY-API-DEV-NAME="++devName , "X-EBAY-API-APP-NAME="++appName , "X-EBAY-API-CERT-NAME="++certName , "X-EBAY-API-CALL-NAME=GeteBayOfficialTime" , "X-EBAY-API-SITEID=0"]] body = "" ++ "" ++ " " ++ " "++token++"" ++ " " ++ "" url = "https://api.sandbox.ebay.com/ws/api.dll" postData = HttpPost {postName = "body" , contentType = Just "text/xml" , content = ContentString body , extraHeaders = [] , showName = Nothing} opts = [] --also tried using curlPost and setopts then perform... main = withCurlDo (do h <- initialize curlMultiPost url opts [postData] ) --------------------------- Original perl: use strict; use LWP::UserAgent; use HTTP::Request; use HTTP::Headers; # define the HTTP header my $objHeader = HTTP::Headers->new; $objHeader->push_header('X-EBAY-API-COMPATIBILITY-LEVEL' => '391'); $objHeader->push_header('X-EBAY-API-DEV-NAME' => 'yourdevname'); $objHeader->push_header('X-EBAY-API-APP-NAME' => 'yourappname'); $objHeader->push_header('X-EBAY-API-CERT-NAME' => 'yourcertname'); $objHeader->push_header('X-EBAY-API-CALL-NAME' => 'GeteBayOfficialTime'); $objHeader->push_header('X-EBAY-API-SITEID' => '0'); $objHeader->push_header('Content-Type' => 'text/xml'); # define the XML request my $request = "" . "" . " " . " TOKENGoesHERE" . " " . ""; # make the call my $objRequest = HTTP::Request->new( "POST", "https://api.sandbox.ebay.com/ws/api.dll", $objHeader, $request ); # deal with the response my $objUserAgent = LWP::UserAgent->new; my $objResponse = $objUserAgent->request($objRequest); if (!$objResponse->is_error) { print $objResponse->content; } else { print $objResponse->error_as_HTML; } ------------------------------ This is what I get when running my version: $ ./curlTest * About to connect() to api.sandbox.ebay.com port 443 (#0) * Trying 66.135.197.133... * connected * Connected to api.sandbox.ebay.com (66.135.197.133) port 443 (#0) * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none * SSL connection using AES256-SHA * Server certificate: * subject: /C=US/ST=California/L=San Jose/O=eBay Inc./OU=Site Operations/CN=api.sandbox.ebay.com * start date: 2008-01-25 00:00:00 GMT * expire date: 2010-03-15 23:59:59 GMT * common name: api.sandbox.ebay.com (matched) * issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)05/CN=VeriSign Class 3 Secure Server CA * SSL certificate verify ok. > POST /ws/api.dll HTTP/1.1 Host: api.sandbox.ebay.com Accept: */* Accept-Encoding: text/xml Content-Length: 1254 Expect: 100-continue Content-Type: multipart/form-data; boundary=----------------------------7c836e9408cd < HTTP/1.1 100 Continue < HTTP/1.1 200 OK < Date: Sat, 19 Jul 2008 20:04:12 GMT < Server: Microsoft-IIS/5.0 < X-EBAY-API-POOL-NAME: ___cDRidW90YmtiZWx9b2l3aQ== < X-EBAY-API-SERVER-NAME: ___dXUucnVlYnVvNzM3KTYzKzc3LTI0KTQxPD8zPTc= < Content-Type: text/xml < Content-Length: 330 < X-Cache: MISS from sjcsbagpigw02.sjc.ebay.com, MISS from sjcsbagpigw02.sjc.ebay.com < Connection: close < * Closing connection #0 2008-07-19 20:04:552RequestError1SeriousError00 From vigalchin at gmail.com Sat Jul 19 16:42:49 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Jul 19 16:33:02 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> Message-ID: <5ae4f2ba0807191342l68978d33o2b0a750626d22f7e@mail.gmail.com> Brandon, You lost me .... can you explain what an opaque aiocb would look like? Vasili On Sat, Jul 19, 2008 at 9:45 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On 2008 Jul 19, at 2:40, Galchin, Vasili wrote: > > My viewpoint is that the above "Internal members" must be "carried" around > in a Haskell program. Am I correct?? If I am correct, then the Linux > implementation of Posix AIO is not portable to say Solaris? In hindsight, if > I am correct, it seems that > > > You are correct --- but Solaris also has its own addenda, and its standard > fields are not at the same offsets as in the Linux aiocb. The only safe way > to do this is to use an opaque aiocb on the Haskell side and accessors in C > via FFI. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/fe9e17b8/attachment.htm From gtener at gmail.com Sat Jul 19 16:49:54 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Sat Jul 19 16:40:06 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> Message-ID: <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> I forgot to mention that the memory consumption is several times higher than file size. On 8,3 Mb file: > 532 MB total memory in use (4 MB lost due to fragmentation). Having that 8 Mb in memory is not the problem. 532 Mb is another story. In general, the program consumes roughly 64 times more memory than file size and it scales linearly. Best regards Christopher Skrz?tnicki On Sat, Jul 19, 2008 at 9:52 PM, Chadda? Fouch? wrote: > 2008/7/19 Krzysztof Skrz?tnicki : > > Hi all > > > > 1) Profiling shows that very simple functions are source of great memory > and > > time consumption. However, if I turn them off and simply print their > input > > arguments instead, the overall time and memory consumption doesn't > change. > > But now another function is acting badly. My guess: somehow the cost of > > Parsec code is shifted into whatever function is using it's output. Let's > > see: > > Are you using Parsec to parse the whole file ? Then your problem is > there : Parsec needs to read and process the whole file before it can > give us any output since it thinks it could have to give us an error > instead and it can't be sure of that before he has read the whole > thing... > In your case, your problem is such that you would prefer to treat the > file as a stream, isn't it ? > There are some parser library that can give output lazily (look at > polyparse flavour), another option would be to only use Parsec where > you need it and just read and print the ordinary text for example. > > -- > Jeda? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/42e26bff/attachment.htm From bulat.ziganshin at gmail.com Sat Jul 19 17:02:36 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 19 16:53:00 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> Message-ID: <378298756.20080720010236@gmail.com> Hello Krzysztof, Sunday, July 20, 2008, 12:49:54 AM, you wrote: on the 32-bit computers 36x memreqs for storing large strings in memory is a rule, on 64-bit ones - 72x > I forgot to mention that the memory consumption is several times > higher than file size. On 8,3 Mb file: >> 532 MB total memory in use (4 MB lost due to fragmentation). > Having that 8 Mb in memory is not the problem. 532 Mb is another > story. In general, the program consumes roughly 64 times more memory > than file size and it scales linearly. > > Best regards > Christopher Skrzetnicki > On Sat, Jul 19, 2008 at 9:52 PM, Chaddai Fouche wrote: > 2008/7/19 Krzysztof Skrzetnicki < gtener@gmail.com>: >> Hi all > >> >> 1) Profiling shows that very simple functions are source of great memory and >> time consumption. However, if I turn them off and simply print their input >> arguments instead, the overall time and memory consumption doesn't change. >> But now another function is acting badly. My guess: somehow the cost of >> Parsec code is shifted into whatever function is using it's output. Let's >> see: > > > Are you using Parsec to parse the whole file ? Then your problem is > there : Parsec needs to read and process the whole file before it can > give us any output since it thinks it could have to give us an error > instead and it can't be sure of that before he has read the whole > thing... > In your case, your problem is such that you would prefer to treat the > file as a stream, isn't it ? > There are some parser library that can give output lazily (look at > polyparse flavour), another option would be to only use Parsec where > you need it and just read and print the ordinary text for example. > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From allbery at ece.cmu.edu Sat Jul 19 17:23:01 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jul 19 17:13:14 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807191342l68978d33o2b0a750626d22f7e@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <5ae4f2ba0807191342l68978d33o2b0a750626d22f7e@mail.gmail.com> Message-ID: <2A2CF9CC-1AD3-4EDD-AC44-49982824A9A5@ece.cmu.edu> On 2008 Jul 19, at 16:42, Galchin, Vasili wrote: > You lost me .... can you explain what an opaque aiocb would > look like? In Haskell, it's a ForeignPtr --- you can't see "inside" it except by FFI calls. Although Duncan is correct and you can use an FFI preprocessor to access the portable fields, and simply not provide access to the rest from Haskell. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/19db63a8/attachment.htm From chaddai.fouche at gmail.com Sat Jul 19 17:35:04 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Sat Jul 19 17:25:16 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> Message-ID: 2008/7/19 Krzysztof Skrz?tnicki : > I forgot to mention that the memory consumption is several times higher than > file size. On 8,3 Mb file: >> 532 MB total memory in use (4 MB lost due to fragmentation). > > Having that 8 Mb in memory is not the problem. 532 Mb is another story. In > general, the program consumes roughly 64 times more memory than file size > and it scales linearly. You should be using ByteString, though this problem would be alleviated if you were consuming the file as a stream. -- Jeda? From gtener at gmail.com Sat Jul 19 17:55:45 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Sat Jul 19 17:45:57 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> Message-ID: <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> On Sat, Jul 19, 2008 at 11:35 PM, Chadda? Fouch? wrote: > 2008/7/19 Krzysztof Skrz?tnicki : > > I forgot to mention that the memory consumption is several times higher > than > > file size. On 8,3 Mb file: > >> 532 MB total memory in use (4 MB lost due to fragmentation). > > > > Having that 8 Mb in memory is not the problem. 532 Mb is another story. > In > > general, the program consumes roughly 64 times more memory than file size > > and it scales linearly. > > You should be using ByteString, though this problem would be > alleviated if you were consuming the file as a stream. > > Since ANSI color codes doesn't contain characters like newline or space, I have simply split input file into such lines. Now the whole program behaves much better: GC time is below 10% and memory consumption dropped to 74 Mb per thread. It's still a lot of memory though and it certainly holds much more than one line of text. Best regards Christopher Skrz?tnicki -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/52dbcdb4/attachment.htm From bulat.ziganshin at gmail.com Sat Jul 19 18:34:09 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 19 18:33:08 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> Message-ID: <782623184.20080720023409@gmail.com> Hello Krzysztof, Sunday, July 20, 2008, 1:55:45 AM, you wrote: >>> 532 MB total memory in use (4 MB lost due to fragmentation). i think that Parsec library should hold entire file in memory only when you use 'try' for whole file. otherwise it should omit data as proceeded -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gtener at gmail.com Sat Jul 19 19:11:33 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Sat Jul 19 19:01:45 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <782623184.20080720023409@gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> <782623184.20080720023409@gmail.com> Message-ID: <220e47b40807191611w4e23847bo46341bebaeced7ca@mail.gmail.com> On Sun, Jul 20, 2008 at 12:34 AM, Bulat Ziganshin wrote: > Hello Krzysztof, > > Sunday, July 20, 2008, 1:55:45 AM, you wrote: > >>> 532 MB total memory in use (4 MB lost due to fragmentation). > > i think that Parsec library should hold entire file in memory only when > you use 'try' for whole file. otherwise it should omit data as > proceeded > > That's exactly what I thought. But even if I remove the only 'try' I use the memory consumption remains unchanged: C:\cygwin\home\Metharius\killer\KillerPy\ansi2html\ansi2html_old.exe duzy.log +RTS -sstderr File duzy.log processed. It took 5.046875s. File size was 4166578 characters. 3,950,649,704 bytes allocated in the heap 535,544,056 bytes copied during GC 117,603,408 bytes maximum residency (9 sample(s)) 1,647,828 bytes maximum slop 265 MB total memory in use (2 MB lost due to fragmentation) Generation 0: 7527 collections, 0 parallel, 0.86s, 0.86s elapsed Generation 1: 9 collections, 0 parallel, 0.80s, 0.81s elapsed INIT time 0.02s ( 0.00s elapsed) MUT time 3.20s ( 3.63s elapsed) GC time 1.66s ( 1.67s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 4.88s ( 5.30s elapsed) %GC time 34.0% (31.6% elapsed) Alloc rate 1,227,386,315 bytes per MUT second Productivity 65.7% of total user, 60.5% of total elapsed One more thing to note: with partial parsing there is no longer a difference between mapM_ and mapMPar. Best regards Christopher Skrz?tnicki -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/0d3a3a2f/attachment.htm From diyu60607 at yahoo.com Sat Jul 19 19:29:42 2008 From: diyu60607 at yahoo.com (Yu Di) Date: Sat Jul 19 19:19:52 2008 Subject: [Haskell-cafe] ghc 6.8.3 build error with __DISCARD__ linking problem, please help! Message-ID: <371015.98825.qm@web32208.mail.mud.yahoo.com> Hi, I am trying to build ghc 6.8.3 from source release, my currently installed version is ghc 6.4.2 (x86 linux binary release version), and I got: /usr/local/ghc/bin/ghc -o ghc-pkg.bin -H16m -O -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches -DUSING_COMPAT -i../../compat -ignore-package Cabal -Rghc-timing -package unix -L../../compat -lghccompat Main.o Version.o CRT_noglob.o Main.o: In function `__stginit_ZCMain': ghc13533.hc:(.text+0x4): undefined reference to `__DISCARD__' ghc13533.hc:(.text+0x9): undefined reference to `__DISCARD__' Main.o: In function `__stginit_Main': ghc13533.hc:(.text+0x18): undefined reference to `__DISCARD__' ghc13533.hc:(.text+0x1d): undefined reference to `__DISCARD__' Main.o: In function `__stginit_Main_': ghc13533.hc:(.text+0x2c): undefined reference to `__DISCARD__' Main.o:ghc13533.hc:(.text+0x3d): more undefined references to `__DISCARD__' follow collect2: ld returned 1 exit status <> Do you know how I can fix this problem? My ghc and gcc versions are: The Glorious Glasgow Haskell Compilation System, version 6.4.2 gcc (GCC) 4.1.1 20060724 (prerelease) (4.1.1-4pclos2007) Thanks! Di, Yu 7.19 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/e10ee173/attachment.htm From vigalchin at gmail.com Sun Jul 20 00:55:44 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Jul 20 00:45:54 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <1216474118.6279.292.camel@localhost> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> Message-ID: <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> yes Duncan I am trying to pass-by-value. I am familiar with ForeignPtr; however, I don't comprehend what you and Brandon are suggesting to do. Could either of you provide a code illustration or point at existing code to illustrate your approach? Kind regards, Vasili On Sat, Jul 19, 2008 at 8:28 AM, Duncan Coutts wrote: > > On Sat, 2008-07-19 at 01:40 -0500, Galchin, Vasili wrote: > > hello, > > > > > > Following is more of a criticism of Linux implementation of the > > Posix real-time extension of asynchronous I/O.... if not interesting > > please skip. The central data structure for Posix AIO is an aiocb. In > > any case, the Linux implementors added to the aiocb: > > [..] > > > My viewpoint is that the above "Internal members" must be "carried" > > around in a Haskell program. Am I correct?? If I am correct, then the > > Linux implementation of Posix AIO is not portable to say Solaris? In > > hindsight, if I am correct, it seems that the Linux implementation of > > AIO should use the ordered pair (pid, fd) to reference the "internal" > > members and leave the "aiocb" "clean"? > > Although it is different between platforms it is still portable. When > you allocate memory in C for the aiocb struct you would use > sizeof(aiocb). That's portable even if the size is different on Linux vs > Solaris. Then members are only accessed by name which is again portable. > > Your problem perhaps is that you're trying to convert an aiocb into a > pure haskell version and convert it back and expect to retain all the > information. I think that is a mistake. Don't pass the aiocb's by value, > pass them by reference. Use a ForeignPtr and just access the members you > need whenever you need them. > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080719/fb929fe7/attachment.htm From chaddai.fouche at gmail.com Sun Jul 20 01:25:37 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Sun Jul 20 01:15:47 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <220e47b40807191611w4e23847bo46341bebaeced7ca@mail.gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> <782623184.20080720023409@gmail.com> <220e47b40807191611w4e23847bo46341bebaeced7ca@mail.gmail.com> Message-ID: 2008/7/20 Krzysztof Skrz?tnicki : > On Sun, Jul 20, 2008 at 12:34 AM, Bulat Ziganshin > wrote: >> >> Hello Krzysztof, >> >> Sunday, July 20, 2008, 1:55:45 AM, you wrote: >> >>> 532 MB total memory in use (4 MB lost due to fragmentation). >> >> i think that Parsec library should hold entire file in memory only when >> you use 'try' for whole file. otherwise it should omit data as >> proceeded >> > > That's exactly what I thought. But even if I remove the only 'try' I use the > memory consumption remains unchanged: It's true, but in your case your output is almost the raw input data, which means that even without a noxious "try", you still have the whole file in memory. Well hopefully not with your latest code, which I would really like to see. -- Jeda? From john at repetae.net Sun Jul 20 02:17:22 2008 From: john at repetae.net (John Meacham) Date: Sun Jul 20 02:07:35 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <782623184.20080720023409@gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> <782623184.20080720023409@gmail.com> Message-ID: <20080720061719.GB15843@sliver.repetae.net> On Sun, Jul 20, 2008 at 02:34:09AM +0400, Bulat Ziganshin wrote: > i think that Parsec library should hold entire file in memory only when > you use 'try' for whole file. otherwise it should omit data as > proceeded I do not believe that is the case, since the return type of runParser "Either ParseError a" means that before you can extract the result of the parse from the 'Right' branch, it must evaluate whether the result is 'Left' or 'Right' meaning it needs to parse the whole input in order to determine whether the parse was succesful. This was the reason I made frisby's main parsing routine just be (roughly) > runPeg :: P a -> String -> a so you have to do something explicit like > runPegMaybe :: P a -> String -> Maybe a > runPegMaybe p s = runPeg (fmap Just p // return Nothing) s to force strictness in the parsing. Though, perhaps parsec is doing something more clever. I do know it uses the one token lookahead trick to determine which branch to take on alternation, but I don't think that solves the issue with parsing the entire file.. John -- John Meacham - ?repetae.net?john? From john at repetae.net Sun Jul 20 02:26:28 2008 From: john at repetae.net (John Meacham) Date: Sun Jul 20 02:16:38 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> Message-ID: <20080720062623.GC15843@sliver.repetae.net> In order to write portable code that accesses C structures, you need to write a c shim, or better, use the 'hsc2hs' tool to produce portable code. For an example, you can see my OpenSSL binding code in http://repetae.net/repos/ginsu/RSA.hsc in particular the 'createPkey' function. the #ptr construct gets a pointer to a member of a C structure, and #peek and #poke let you read and set members. You should use (#const sizeof(struct foo)) to determine how much memory you need to allocate for a structure. (unless the API you are binding specifies some other allocation method) John -- John Meacham - ?repetae.net?john? From dan.doel at gmail.com Sun Jul 20 02:55:10 2008 From: dan.doel at gmail.com (Dan Doel) Date: Sun Jul 20 02:45:24 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <20080720061719.GB15843@sliver.repetae.net> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <782623184.20080720023409@gmail.com> <20080720061719.GB15843@sliver.repetae.net> Message-ID: <200807200255.11107.dan.doel@gmail.com> On Sunday 20 July 2008, John Meacham wrote: > I do not believe that is the case, since the return type of runParser > "Either ParseError a" means that before you can extract the result of > the parse from the 'Right' branch, it must evaluate whether the result > is 'Left' or 'Right' meaning it needs to parse the whole input in order > to determine whether the parse was succesful. > > This was the reason I made frisby's main parsing routine just be > (roughly) > > > runPeg :: P a -> String -> a > > so you have to do something explicit like > > > runPegMaybe :: P a -> String -> Maybe a > > runPegMaybe p s = runPeg (fmap Just p // return Nothing) s > > to force strictness in the parsing. > > Though, perhaps parsec is doing something more clever. I do know it uses > the one token lookahead trick to determine which branch to take on > alternation, but I don't think that solves the issue with parsing the > entire file.. It doesn't stop it from parsing the entire file strictly. However, what it does do is prevent the parser from backtracking out of arbitrary amounts of lookahead. So, unless you use try (which allows for lookahead), when any token is consumed by the parser, it can be garbage collected (assuming the parser is the only thing pointing to the token stream). So, it consumes its input strictly, but with limited overhead (ideally using try only for some small bounded lookahead where it's needed). By contrast, a naive parser combinator of the form: p = foo <|> bar -- or p = try foo <|> bar in parsec Might read the entire file into memory parsing foo, without any of it being garbage collected until completion, in case foo fails and a backtrack to bar is required. Of course, this all assumes that the input to the parser can both be lazily generated, and discarded in pieces (so, not the case if reading an entire file into a strict byte string, for instance). -- Dan From duncan.coutts at worc.ox.ac.uk Sun Jul 20 07:51:21 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jul 20 07:40:30 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> Message-ID: <1216554681.6279.345.camel@localhost> On Sat, 2008-07-19 at 23:55 -0500, Galchin, Vasili wrote: > yes Duncan I am trying to pass-by-value. I am familiar with > ForeignPtr; however, I don't comprehend what you and Brandon are > suggesting to do. Could either of you provide a code illustration or > point at existing code to illustrate your approach? Take a look at John Meacham's RSA example. So at the moment you're using using Storable and a Haskell record, say: data AIOCB = AIOCB { ... } and we're suggesting instead: newtype AIOCB = AIOCB (ForeignPtr AIOCB) then to access a member use hsc2hs: getBlah :: AIOCB -> IO Blah getBlah (AIOCB fptr) = withForeignPtr fptr $ \ptr -> {# peek aiocb,blah #} ptr So you only access the parts you need and keep the aiocb C struct allocated on the heap (use mallocForeignPtr). Duncan From mmitar at gmail.com Sun Jul 20 08:13:16 2008 From: mmitar at gmail.com (Mitar) Date: Sun Jul 20 08:03:25 2008 Subject: [Haskell-cafe] Help with optimization Message-ID: Hi! Profiling says that my program spends 18.4 % of time (that is around three seconds) and 18.3 % of allocations in this function which is saving the rendered image to a PPM file: saveImageList :: String -> Int -> Int -> [ViewportDotColor] -> IO () saveImageList filename width height image = do B.writeFile filename file where file = B.append header bytes header = C.pack $ "P6\n" ++ show width ++ " " ++ show height ++ "\n255\n" bytes = B.pack $ concatMap (color . dealpha . (\(ViewportDotColor _ c) -> c)) image where color (VoxelColor red green blue _) = [floor $ red * 255, floor $ green * 255, floor $ blue * 255] dealpha c = addColor c (VoxelColor 1.0 1.0 1.0 1.0) -- white background For a 921615 bytes large file to save this is too much in my opinion. And I think that it consumes to much allocations. Probably it should not store intermediate lists? Any suggestions? Best regards Mitar From gtener at gmail.com Sun Jul 20 09:18:46 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Sun Jul 20 09:08:57 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> <782623184.20080720023409@gmail.com> <220e47b40807191611w4e23847bo46341bebaeced7ca@mail.gmail.com> Message-ID: <220e47b40807200618o6e014086u14e121123b86525@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: ansi2html.hs Type: application/octet-stream Size: 9314 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/7e83f859/ansi2html-0001.obj From isaacdupree at charter.net Sun Jul 20 09:55:15 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Sun Jul 20 09:45:31 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <200807200255.11107.dan.doel@gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <782623184.20080720023409@gmail.com> <20080720061719.GB15843@sliver.repetae.net> <200807200255.11107.dan.doel@gmail.com> Message-ID: <488343C3.7060904@charter.net> Dan Doel wrote: > On Sunday 20 July 2008, John Meacham wrote: >> I do not believe that is the case, since the return type of runParser >> "Either ParseError a" means that before you can extract the result of >> the parse from the 'Right' branch, it must evaluate whether the result >> is 'Left' or 'Right' meaning it needs to parse the whole input in order >> to determine whether the parse was succesful. ... > It doesn't stop it from parsing the entire file strictly. However, what it > does do is prevent the parser from backtracking out of arbitrary amounts of > lookahead. So, unless you use try (which allows for lookahead), when any > token is consumed by the parser, it can be garbage collected (assuming the > parser is the only thing pointing to the token stream). So, it consumes its > input strictly, but with limited overhead (ideally using try only for some > small bounded lookahead where it's needed). So with Parsec, you can keep the *input* from filling up memory, but if you do, the *result* will still take up space (e.g. Right (value)). For a simple transformation where the output is a similar string to the input, it will be just as large, so not much space is actually saved (maybe a factor of 2 -- just keeping the output, not also the input), it seems. -Isaac From aneumann at inf.fu-berlin.de Sun Jul 20 14:17:41 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sun Jul 20 14:08:14 2008 Subject: [Haskell-cafe] Help with optimization In-Reply-To: References: Message-ID: Maybe your image isn't strict enough and the computations are forced when the image gets written to disc? Am 20.07.2008 um 14:13 schrieb Mitar: > Hi! > > Profiling says that my program spends 18.4 % of time (that is around > three seconds) and 18.3 % of allocations in this function which is > saving the rendered image to a PPM file: > > saveImageList :: String -> Int -> Int -> [ViewportDotColor] -> IO () > saveImageList filename width height image = do > B.writeFile filename file > where file = B.append header bytes > header = C.pack $ "P6\n" ++ show width ++ " " ++ show height > ++ "\n255\n" > bytes = B.pack $ concatMap (color . dealpha . > (\(ViewportDotColor _ c) -> c)) image > where color (VoxelColor red green blue _) = [floor $ red * > 255, floor $ green * 255, floor $ blue * 255] > dealpha c = addColor c (VoxelColor 1.0 1.0 1.0 1.0) > -- white background > > For a 921615 bytes large file to save this is too much in my opinion. > And I think that it consumes to much allocations. Probably it should > not store intermediate lists? > > Any suggestions? > > Best regards > > > Mitar > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/f3a20217/PGP.bin From gtener at gmail.com Sun Jul 20 17:51:22 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Sun Jul 20 17:41:31 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <220e47b40807200618o6e014086u14e121123b86525@mail.gmail.com> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <220e47b40807191349q465794b0jd231be2b48a4171a@mail.gmail.com> <220e47b40807191455x703971b0h28707127756cb6a2@mail.gmail.com> <782623184.20080720023409@gmail.com> <220e47b40807191611w4e23847bo46341bebaeced7ca@mail.gmail.com> <220e47b40807200618o6e014086u14e121123b86525@mail.gmail.com> Message-ID: <220e47b40807201451k69e6f448pc775dbf71e580611@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: ansi2html.hs Type: application/octet-stream Size: 6464 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/aa671c57/ansi2html.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: ansi2html.hs Type: application/octet-stream Size: 6464 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/aa671c57/ansi2html-0001.obj From mmitar at gmail.com Sun Jul 20 20:07:58 2008 From: mmitar at gmail.com (Mitar) Date: Sun Jul 20 19:58:05 2008 Subject: [Haskell-cafe] Help with optimization In-Reply-To: References: Message-ID: Hi! 2008/7/20 Adrian Neumann : > Maybe your image isn't strict enough and the computations are forced when > the image gets written to disc? But it still takes three seconds more than displaying to the screen. This is why I am also thinking that this code is to slow. This and that when saving to a file it takes almost 25 % more allocations. So probably it is slower because of all this allocations? Mitar From ok at cs.otago.ac.nz Sun Jul 20 20:11:28 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Sun Jul 20 20:01:41 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: >> On Fri, 18 Jul 2008, stefan kersten wrote: >> >>> On 17.07.2008, at 21:46, Lennart Augustsson wrote: >>>> If scaleFloat and exponent are implemented with bit twiddling >>>> they can >>>> be quite fast. >>> >>> is there a way in ghc to 'cast' between float/int32 and double/ >>> int64 (without going through memory)? I read this as "Is there any way to take a 32-bit float in a register and end up with a 32-bit int in a register, without going through memory, in GHC? How about the other way around? How about 64-bit floats and integers?" It is rather hard to do portably in GHC what some hardware does not do. A long time ago hardware architects decided that separating the integer and floating point register files was a Good Thing. The machine I know best is SPARC, where there are no instructions to move data directly between integer registers and floating point registers. On the other hand, there are other pressures, notably graphics. While integer and floating point registers may be kept separate, there are often "vector" instructions that let you operate on integers in the floating- point registers. (Such as the VIS instructions on SPARCs, which are technically optional.) Exploiting such instructions tends to be rather non- portable. All things considered, I wouldn't worry about it too much: the memory in question should be at the top of the stack, so should be in L1 cache, so should be pretty fast to access, and other things may be more significant. From dons at galois.com Sun Jul 20 20:28:47 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 20 20:18:57 2008 Subject: [Haskell-cafe] Help with optimization In-Reply-To: References: Message-ID: <20080721002847.GB11969@scytale.galois.com> mmitar: > Hi! > > Profiling says that my program spends 18.4 % of time (that is around > three seconds) and 18.3 % of allocations in this function which is > saving the rendered image to a PPM file: > > saveImageList :: String -> Int -> Int -> [ViewportDotColor] -> IO () > saveImageList filename width height image = do > B.writeFile filename file > where file = B.append header bytes > header = C.pack $ "P6\n" ++ show width ++ " " ++ show height > ++ "\n255\n" > bytes = B.pack $ concatMap (color . dealpha . > (\(ViewportDotColor _ c) -> c)) image > where color (VoxelColor red green blue _) = [floor $ red * > 255, floor $ green * 255, floor $ blue * 255] > dealpha c = addColor c (VoxelColor 1.0 1.0 1.0 1.0) > -- white background > > For a 921615 bytes large file to save this is too much in my opinion. > And I think that it consumes to much allocations. Probably it should > not store intermediate lists? Rather than generating the bytes as a list and packing them, could you instead fill a bytestring directly? -- Don From ok at cs.otago.ac.nz Sun Jul 20 21:05:48 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Sun Jul 20 20:55:59 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <20080720062623.GC15843@sliver.repetae.net> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <20080720062623.GC15843@sliver.repetae.net> Message-ID: <03F7B11D-BD5F-4BCF-8168-29D375080340@cs.otago.ac.nz> I think it may be time for a little clarity about aoicb's. From the Single Unix Specification: "The header shall define the aiocb structure which shall include AT LEAST the following members: int aio_fildes File descriptor. off_t aio_offset File offset. volatile void *aio_buf Location of buffer. size_t aio_nbytes Length of transfer. int aio_reqprio Request priority offset. struct sigevent aio_sigevent Signal number and value. int aio_lio_opcode Operation to be performed. " The "AT LEAST" here means that - a portable program may rely on these members being present - a portable program MUST assume that an unknown number of additional members are also present - a portable program may freely copy such a record, but may only pass it to a library function if that function is expecting to initialise it For asynchronous I/O, this means that - you can allocate an aiocb object - an aiocb passed to aio_suspend, aio_error, aio_return, or aio_cancel should have been filled in by aio_read or aio_write and should be EXACTLY THE SAME object, not a copy of it. From ronwalf at volus.net Sun Jul 20 21:24:41 2008 From: ronwalf at volus.net (Ron Alford) Date: Sun Jul 20 21:14:49 2008 Subject: [Haskell-cafe] GHC Error: "FATAL:Symbol _XJv_srt already defined." Message-ID: Anyone know what this is about? Removing parts makes problem go away, but it's not clear what parts to remove! (that, and I wrote those parts for a reason!). bash-3.2$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.3 bash-3.2$ uname -a Darwin silverback-wired.home 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun 9 19:30:53 PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386 $ rm -f DerivingError.o DerivingError.hi; ghc --make DerivingError.hs [1 of 1] Compiling DerivingError ( DerivingError.hs, DerivingError.o ) /var/folders/C0/C0SledGV2RaxbU+8ZLDnVU+++TI/-Tmp-//ghc27223_0/ghc27223_0.s:6080:0: FATAL:Symbol _XxG_srt already defined. -Ron Alford -------------- next part -------------- A non-text attachment was scrubbed... Name: DerivingError.hs Type: application/octet-stream Size: 2483 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/42db77cf/DerivingError.obj From allbery at ece.cmu.edu Sun Jul 20 21:55:00 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 20 21:45:09 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <03F7B11D-BD5F-4BCF-8168-29D375080340@cs.otago.ac.nz> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <20080720062623.GC15843@sliver.repetae.net> <03F7B11D-BD5F-4BCF-8168-29D375080340@cs.otago.ac.nz> Message-ID: <20F1503F-429E-4214-B271-0BB8E4AA5A74@ece.cmu.edu> On 2008 Jul 20, at 21:05, Richard A. O'Keefe wrote: > For asynchronous I/O, this means that > - you can allocate an aiocb object > - an aiocb passed to aio_suspend, aio_error, > aio_return, or aio_cancel should have been > filled in by aio_read or aio_write and should > be EXACTLY THE SAME object, not a copy of it. Right, hence a ForeignPtr which is mostly opaque. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From jmaessen at alum.mit.edu Sun Jul 20 23:06:03 2008 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Sun Jul 20 22:56:16 2008 Subject: [Haskell-cafe] Data.Complex.magnitude slow? In-Reply-To: References: <0147E730-2307-4817-BD05-0826ACB55302@k-hornz.de> <9CA5A4CB-A64C-45C4-90C3-F3E1ADB70E0A@k-hornz.de> Message-ID: <379B2BC6-8DB0-4A0C-941B-2535B37B54CD@alum.mit.edu> On Jul 20, 2008, at 8:11 PM, Richard A. O'Keefe wrote: > I read this as > > "Is there any way to take a 32-bit float in a register and end up > with a 32-bit int > in a register, without going through memory, in GHC? > How about the other way around? > How about 64-bit floats and integers?" > > It is rather hard to do portably in GHC what some hardware does not > do. The reason to provide this as a primitive is so that code like Complex magnitude doesn't have to go through a completely opaque-to-the- compiler interface in order to extract bits from the underlying IEEE float representation. Sure, code generation can't assign it to a register, but it could be kept on the stack. Once we're peeking and poking through a Ptr (the trick that was suggested the last time this came up, too, if I remember rightly) we're sunk---GHC doesn't reason well at all about this stuff, and we need to allocate a Ptr to peek and poke. If instead we use a foreign call, again, it's completely compiler-opaque. > A long time ago hardware architects decided that separating the > integer and > floating point register files was a Good Thing. > The machine I know best is SPARC, where there are no instructions to > move > data directly between integer registers and floating point registers. Ironically, this is no longer true on Niagara-class (T1 and T2) SPARC machines. So nowadays this may be the only architecture that *does* provide this ability. But again, the really important thing is that the compiler can see that bits is bits and that the conversion involves no magic and no extra storage beyond a spill location on the stack. > ... [stuff about SIMD snipped]... > All things considered, I wouldn't worry about it too much: the > memory in > question should be at the top of the stack, so should be in L1 > cache, so should > be pretty fast to access, and other things may be more significant. But only if GHC can treat them transparently---which at the moment it evidently can't! All it'd take is a primitive from Float# -> Int32# and another from Double# -> Int64#... -Jan-Willem Maessen > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vigalchin at gmail.com Mon Jul 21 00:59:21 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 21 00:49:29 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <1216554681.6279.345.camel@localhost> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> Message-ID: <5ae4f2ba0807202159j6494ca24hbdaad8440734624c@mail.gmail.com> Thank you Duncan for your example. I will also read the RSA code. Regards, Vasili On Sun, Jul 20, 2008 at 6:51 AM, Duncan Coutts wrote: > > On Sat, 2008-07-19 at 23:55 -0500, Galchin, Vasili wrote: > > yes Duncan I am trying to pass-by-value. I am familiar with > > ForeignPtr; however, I don't comprehend what you and Brandon are > > suggesting to do. Could either of you provide a code illustration or > > point at existing code to illustrate your approach? > > Take a look at John Meacham's RSA example. > > So at the moment you're using using Storable and a Haskell record, say: > > data AIOCB = AIOCB { > ... > } > > and we're suggesting instead: > > newtype AIOCB = AIOCB (ForeignPtr AIOCB) > > then to access a member use hsc2hs: > > getBlah :: AIOCB -> IO Blah > getBlah (AIOCB fptr) = > withForeignPtr fptr $ \ptr -> {# peek aiocb,blah #} ptr > > So you only access the parts you need and keep the aiocb C struct > allocated on the heap (use mallocForeignPtr). > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080720/c6b48d50/attachment.htm From vigalchin at gmail.com Mon Jul 21 01:01:49 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 21 00:51:57 2008 Subject: [Haskell-cafe] Haskell code contributions Message-ID: <5ae4f2ba0807202201i6f461651s23a320fff1eea82d@mail.gmail.com> Hello, I have a password to upload Haskell code contributions but I can't find the email with the password and I have forgotten who is the "gatekeeper". ?? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080721/d98ac053/attachment.htm From mad.one at gmail.com Mon Jul 21 03:04:01 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 21 02:54:11 2008 Subject: [Haskell-cafe] GHC Error: "FATAL:Symbol _XJv_srt already defined." In-Reply-To: References: Message-ID: <1216622333-sup-3336@existential.local> I can replicate this err with 6.8.3 on my macbook (os 10.5.4.) It also appears to fail with a copy of the GHC HEAD as well: $ uname -a Darwin existential.local 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun 9 19:30:53 PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386 $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.3 $ ~/ghc-head/bin/ghc --version The Glorious Glasgow Haskell Compilation System, version 6.9.20080615 $ ghc --make DerivingError.hs [1 of 1] Compiling DerivingError ( DerivingError.hs, DerivingError.o ) /var/folders/27/27CWjmd8HK8wG5FT3nu3pk+++TI/-Tmp-//ghc39082_0/ghc39082_0.s:6080:0: FATAL:Symbol _XxH_srt already defined. $ rm DerivingError.hi $ ~/ghc-head/bin/ghc --make DerivingError.hs [1 of 1] Compiling DerivingError ( DerivingError.hs, DerivingError.o ) /var/folders/27/27CWjmd8HK8wG5FT3nu3pk+++TI/-Tmp-/ghc39116_0/ghc39116_0.s:6207:0: FATAL:Symbol _XyQ_srt already defined. $ However, things get even wackier because I *can* get it to build on the HEAD, only through a very odd compilation step (I figured this out while trying to examine the ASM output from the -S flag): $ ~/ghc-head/bin/ghc --version The Glorious Glasgow Haskell Compilation System, version 6.9.20080615 $ ~/ghc-head/bin/ghc --make DerivingError.hs [1 of 1] Compiling DerivingError ( DerivingError.hs, DerivingError.o ) /var/folders/27/27CWjmd8HK8wG5FT3nu3pk+++TI/-Tmp-/ghc44257_0/ghc44257_0.s:6207:0: FATAL:Symbol _XyP_srt already defined. $ rm DerivingError.hi $ ~/ghc-head/bin/ghc -S DerivingError.hs $ ~/ghc-head/bin/ghc --make DerivingError.hs [1 of 1] Compiling DerivingError ( DerivingError.hs, DerivingError.o ) $ Although in 6.8.3 it doesn't work regardless; but if we make it build the object file through this odd step, we can then link it with a main stub: $ cat > main.hs main = putStrLn "hello world" $ ~/ghc-head/bin/ghc --make main.hs DerivingError.o [1 of 1] Compiling Main ( main.hs, main.o ) Linking main ... $ In particular the issue appears to be related to generics (duh,) since if we search through the .s file generated when using -S, we can see what it's referring to (6.8.3): .align 2 _Xxn_srt: ;; line 5757 .long _base_DataziGenericsziBasics_mkDataType_closure .long _s1Zg_closure .long _s1Zi_closure .const_data .align 2 _Xw9_srt: .long _Xxn_closure ... _Xxn_srt: ;; line 6080 .long _base_DataziGenericsziBasics_mkDataType_closure .long _s1Zs_closure .long _s1Zu_closure .data .align 2 ... So it seems like a bug in the native code generator for generics. The ghc-6.9 version was actually a snapshot of the head a few weeks back as you can see, I'm building the latest HEAD from darcs as we speak, but in the mean time I would file a bug report with the code attached: http://hackage.haskell.org/trac/ghc/newticket?type=bug If you do, I'll be sure to post what I've done here so the devs might be able to track it easier. If the latest HEAD turns out to work I'll get back to you as well. Austin From mad.one at gmail.com Mon Jul 21 03:06:07 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 21 02:56:17 2008 Subject: [Haskell-cafe] Haskell code contributions In-Reply-To: <5ae4f2ba0807202201i6f461651s23a320fff1eea82d@mail.gmail.com> References: <5ae4f2ba0807202201i6f461651s23a320fff1eea82d@mail.gmail.com> Message-ID: <1216623909-sup-9047@existential.local> >From the looks of the User Accounts page on hackage, Ross Patterson seems to be responsible, you can contact him here: ross@soi.city.ac.uk Austin From mad.one at gmail.com Mon Jul 21 03:29:34 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 21 03:19:45 2008 Subject: [Haskell-cafe] GHC Error: "FATAL:Symbol _XJv_srt already defined." In-Reply-To: <1216622333-sup-3336@existential.local> References: <1216622333-sup-3336@existential.local> Message-ID: <1216625156-sup-7796@existential.local> Status update: after checking out the latest HEAD and building it, the above error does not occur: $ ~/ghc-head/bin/ghc --version The Glorious Glasgow Haskell Compilation System, version 6.9.20080720 $ ~/ghc-head/bin/ghc --make DerivingError.hs : Warning: -fallow-overlapping-instances is deprecated: Use the OverlappingInstances language instead [1 of 1] Compiling DerivingError ( DerivingError.hs, DerivingError.o ) $ However, this doesn't exactly help your immediate problem, and it likely won't until 6.10.1 is released, as 6.8.3 is going to be the last release of the 6.8 branch. Truly sorry I couldn't have helped you more. Austin From ryani.spam at gmail.com Mon Jul 21 03:36:44 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jul 21 03:26:52 2008 Subject: [Haskell-cafe] Re: Profiling nested case In-Reply-To: References: Message-ID: <2f9b2d30807210036j45a7f79eie87c80e04c1b19ea@mail.gmail.com> I had similar experiences as you when attempting to write "high performance Haskell"; the language makes you want to use high-level abstracted functions but the optimizer (while amazing, to be honest) seems to miss a few cases that it seems like it should hit. The problem seems to be that the compiler is extremely good at optimizing systems-level code, but that any "control-structure" function needs to be extremely inlined to be successful. You might try re-writing "sequence" or "foldM" a few different ways using the same "test" function and see what you can get. One thing that I notice about this code is that if you switch Right and Left you will get the default behavior for the Either monad: worldSceneSwitch point = case redSphere (0,50,0) 50 point of v@(Left _) -> v Right d1 -> case greenSphere (25,-250,0) 50 point of v@(Left _) -> v Right d2 -> Right $ d1 `min` d2 is the same as worldSceneSwitch point = do d1 <- redSphere (0, 50, 0) 50 point d2 <- greenSphere (25, -250, 0) 50 point Right (d1 `min` d2) Here is the same concept using foldM: minimumM (x : xs) = do v0 <- x foldM (return . min) v0 xs worldSceneSwitch point = minimumM [ redSphere (0, 50, 0) 50 point, greenSphere (25, -250, 0) 50 point ] However, the performance here will be terrible if minimumM and foldM do not get sufficiently inlined; you do not want to be allocating list thunks just to execute them shortly thereafter. -- ryan On Sat, Jul 19, 2008 at 6:48 AM, Mitar wrote: > Hi! > > I had to change code somewhat. Now I have a function like: > > worldScene point = case redSphere (0,50,0) 50 point of > v@(Right _) -> v > Left d1 -> case greenSphere (25,-250,0) 50 point of > v@(Right _) -> v > Left d2 -> Left $ d1 `min` d2 > > (Of course there could be more objects.) > > Any suggestion how could I make this less hard-coded? Something which > would take a list of objects (object functions) and then return a > Right if any object function return Right or a minimum value of all > Lefts. But that it would have similar performance? If not on my GHC > version (6.8.3) on something newer (which uses fusion or something). > Is there some standard function for this or should I write my own > recursive function to run over a list of object functions? But I am > afraid that this will be hard to optimize for compiler. > > (It is important to notice that the order of executing object > functions is not important so it could be a good candidate for > parallelism.) > > > Mitar > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mad.one at gmail.com Mon Jul 21 04:47:53 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 21 04:38:04 2008 Subject: [Haskell-cafe] Building NDP with latest GHC Message-ID: <1216628285-sup-8172@existential.local> Hi, After my last issue with GHC's HEAD, I tried checking it out again and getting the patches for the libraries and lo and behold, it worked. So now I'm up to date with the latest libraries and the compiler, but it appears that building NDP itself is proving to be troublesome. (This is on GHC 6.9.20080720, btw) I've pulled the latest ndp package from http://darcs.haskell.org/packages/ndp into ./libraries. Instructions that are listed in [1]: > % cd libraries > % darcs get http://darcs.haskell.org/packages/ndp/ > % make make.library.ndp > % cd ndp/examples > % make This fails on step 3; the Makefile in the libraries subdirectory doesn't recognize 'make.library.ndp' as a valid target. Instructions in the actual README that comes with package ndp: > cd ndp > make boot > make > cd examples > make This fails on the 'make boot' step, because if you look at the Makefile, it thinks the top of the GHC source tree is at '..', when it's actually '../..' in relation to ./libraries/ndp: > TOP=.. > include $(TOP)/mk/boilerplate.mk > include ndp.mk > ... rest of makefile ... No big deal in this case, just a fix of changing TOP to '../..' Having done that, however, now it fails because it it cannot correctly parse bootstrapping.conf which is located in ./libraries: > $ make boot > ../../mk/target.mk:454: warning: overriding commands for target `libHSndp' > ../../mk/package.mk:249: warning: ignoring old commands for target `libHSndp' > ../../mk/target.mk:454: warning: overriding commands for target `ghc-prim.a' > ../../mk/package.mk:249: warning: ignoring old commands for target `ghc-prim.a' > /Users/austinseipp/src/ghc-head/ghc/stage1-inplace/bin/ghc -M > -optdep-f -optdep.depend -osuf o -package-conf > /Users/austinseipp/src/ghc-head/libraries/bootstrapping.conf -H32m > -O -fasm -Rghc-timing -package-name ndp ghc-prim-0.1 -O -fgenerics > -package base -XGenerics -fglasgow-exts -fbang-patterns -O2 > -funbox-strict-fields -fdicts-cheap -fno-method-sharing > -fno-spec-constr-threshold -fmax-simplifier-iterations20 -threaded > -XTypeFamilies -fcpr-off > > ... lots of files trying to get compiled here ... > > : > Warning: -fgenerics is deprecated: Use the Generics language > instead > > : > Warning: -fbang-patterns is deprecated: Use the BangPatterns > language instead > ghc: > /Users/austinseipp/src/ghc-head/libraries/bootstrapping.conf:1:62: > parse error on input `"' > < samples), 31M in use, 0.00 INIT (0.00 elapsed), 0.08 MUT (0.12 > elapsed), 0.01 GC (0.02 elapsed) :ghc>> > make: *** [depend] Error 1 For the record, the thing it fails on is the *first* occurance of a quotation mark, and that's here in bootstrapping.conf: > [InstalledPackageInfo {package = PackageIdentifier {pkgName = > "filepath", pkgVersion = ... So it's failing when it sees the quote at the start of "filepath" I have also attempted to follow the instructions at the top ./libraries/Makefile, which are: > # To do a fresh build: > # > # make clean > # make boot > # make > # > # To rebuild a particular library : > # > # make clean.library. > # make make.library. > # > # or the following is equivalent: > # > # make remake.library. > # > # To add a new library to the tree, do > # > # darcs get http://darcs.haskell.org/packages/foo > # [ -e foo/configure.ac ] && ( cd foo && autoreconf ) > # make make.library.foo As said above, 'make.library.ndp' does not work, doing a full clean, boot and then make again doesn't pick up NDP either, and in the last case (adding a new library,) it doesn't matter because there is no configure.ac at the top level of ./libraries/ndp I think I might simply have a *lot* of outdated information. For the record, this is what I want to try and compile: > {-# OPTIONS_GHC -fglasgow-exts -fparr -fvectorise #-} > module Main where > import GHC.PArr > > dotp :: Num a => [:a:] -> [:a:] -> a > dotp xs ys = sumP [:x * y | x <- xs, y <- ys :] > > main = print $ dotp [:1..5:] [:6..10:] Naturally when trying, it fails because DPH isn't there: > $ ~/ghc-head/bin/ghc --make dotp.hs > > : > Warning: -fparr is deprecated: Use the PArr language instead > [1 of 1] Compiling Main ( dotp.hs, dotp.o ) > GHC error in desugarer lookup in main:Main: > Failed to load interface for `Data.Array.Parallel.Lifted.PArray': > no package matching dph-par was found > ghc: panic! (the 'impossible' happened) > (GHC version 6.9.20080720 for i386-apple-darwin): > initDs user error (IOEnv failure) > > Please report this as a GHC bug: > http://www.haskell.org/ghc/reportabug (This leads me to believe I actually want http://darcs.haskell.org/packages/dph, but it's not mentioned. Anywhere.) If I'm just doing everything wrong, I'd really appreciate knowing and I'd be *more* than happy to update the wiki pages so that more people can try it and have it build successfuly, because as it stands I'm coming to the conclusion that basically all the information in [1] is just old and flat-out wrong, and I'm completely of ideas on how to go about this. Thanks, Austin [1] http://haskell.org/haskellwiki/Data_Parallel_Haskell/PackageNDP From frr149 at easyjob.net Mon Jul 21 07:09:29 2008 From: frr149 at easyjob.net (Fernando Rodriguez) Date: Mon Jul 21 06:59:50 2008 Subject: [Haskell-cafe] Trouble with non-exhaustive patterns Message-ID: Hi, I defiend the following function to get the last element of a list: final [a] = a final (_:t) = final t and it works as expected. Since I didn't want to have a non exhaustive pattern, I added the following case: final [] = [] - I consider that the end of an empty list is the empty list final [a] = a final (_:t) = final t Suddenly, the function stoped working with a rather cryptic (for a newbie at least) error message: *Temp> final [4,5] :1:9: No instance for (Num [a]) arising from the literal `5' at :1:9 Possible fix: add an instance declaration for (Num [a]) In the expr*Temp> ession: 5 In the first argument of `final', namely `[4, 5]' In the expression: final [4, 5] What have I done so wrong? Thanks in advance, Fernando From voigt at tcs.inf.tu-dresden.de Mon Jul 21 07:24:43 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Mon Jul 21 07:07:17 2008 Subject: [Haskell-cafe] Trouble with non-exhaustive patterns In-Reply-To: References: Message-ID: <488471FB.90201@tcs.inf.tu-dresden.de> Fernando Rodriguez wrote: > > Hi, > > I defiend the following function to get the last element of a list: > > final [a] = a > final (_:t) = final t > > and it works as expected. Since I didn't want to have a non exhaustive > pattern, I added the following case: > > final [] = [] - I consider that the end of an empty list is the empty list > final [a] = a > final (_:t) = final t > > Suddenly, the function stoped working with a rather cryptic (for a > newbie at least) error message: > > *Temp> final [4,5] > > :1:9: > No instance for (Num [a]) > arising from the literal `5' at :1:9 > Possible fix: add an instance declaration for (Num [a]) > In the expr*Temp> ession: 5 > In the first argument of `final', namely `[4, 5]' > In the expression: final [4, 5] > > What have I done so wrong? You probably want final to have type final :: [a] -> a But the equation final [] = [] conflicts with this. BTW, you might want to have this kind of discussion at beginners@haskell.org instead. See the announcement: http://thread.gmane.org/gmane.comp.lang.haskell.general/16345 Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From cmb21 at kent.ac.uk Mon Jul 21 07:46:16 2008 From: cmb21 at kent.ac.uk (C.M.Brown) Date: Mon Jul 21 07:36:25 2008 Subject: [Haskell-cafe] Trouble with non-exhaustive patterns In-Reply-To: References: Message-ID: Hi Fernando, I hope you don't mind, but I've moved this over to the Haskell-beginners mailing list, where I think this kind of question will be more appropriate. In Haskell, it helps to think of functions in terms of an input and an output, that is, what is the thing that is going into the function; and what is the thing that is coming out of the function? In your function, final, the input is clearly a list of something (we can denote this by the Haskell type [a] which means a list of some type, a). Its return type is clearly an element of the list, so that must be the something type (the 'a' from the [a]). This gives the Haskell type: final :: [a] -> a (final takes a list of 'a' and gives back a single 'a'. The 'a' is a type variable, and it is used to denote that anything can be put in its place, so we can give final a list of integers, characters, whatever). Now, let's take a look at your definition of final. If we take a closer look, in fact only two equations satisfy this type: final [a] = a final (_:t) = final t The other takes a list and returns a list. The equation, final [] = [] takes an empty list and returns an empty list (its type is therefore [a] -> [a]). This is why you got an error, as Haskell doesn't know how what to do with the conflicting equation. What we need is the final element of the list. How do we do that? Let's think of the simple cases first. The final element of a list containing a single element is just that element, final [a] = a But what about if the list contains more elements? Or is an empty list? The empty list may be confusing, as an empty list contains no elements, so in effect, we can't return anything. We can, however, return an error message. fun [] = error "empty List" And the final element of any list, must be the final element of its tail: final (_:t) = final t this gives us: final :: [a] -> a final [] = error "Empty List" final [a] = a final (_:t) = final t I hope that gives some insight. Kind regards, Chris. On Mon, 21 Jul 2008, Fernando Rodriguez wrote: > > Hi, > > I defiend the following function to get the last element of a list: > > final [a] = a > final (_:t) = final t > > and it works as expected. Since I didn't want to have a non exhaustive pattern, > I added the following case: > > final [] = [] - I consider that the end of an empty list is the empty list > final [a] = a > final (_:t) = final t > > Suddenly, the function stoped working with a rather cryptic (for a newbie > at least) error message: > > *Temp> final [4,5] > > :1:9: > No instance for (Num [a]) > arising from the literal `5' at :1:9 > Possible fix: add an instance declaration for (Num [a]) > In the expr*Temp> ession: 5 > In the first argument of `final', namely `[4, 5]' > In the expression: final [4, 5] > > What have I done so wrong? > > Thanks in advance, > Fernando > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From chaddai.fouche at gmail.com Mon Jul 21 07:46:49 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Mon Jul 21 07:36:55 2008 Subject: [Haskell-cafe] Trouble with non-exhaustive patterns In-Reply-To: References: Message-ID: 2008/7/21 Fernando Rodriguez : > Suddenly, the function stoped working with a rather cryptic (for a newbie at > least) error message: > > *Temp> final [4,5] > > :1:9: > No instance for (Num [a]) > arising from the literal `5' at :1:9 > Possible fix: add an instance declaration for (Num [a]) > In the expr*Temp> ession: 5 > In the first argument of `final', namely `[4, 5]' > In the expression: final [4, 5] > > What have I done so wrong? As Janis said final [] = [] conflicts with the signature you want for final BUT the definition of final is still typeable, it just don't have the type you think it have... and combined with the way Haskell handle number literals you get this confusing error. final's type is [[a]] -> [a] because final [] = [] imply that the return type should be a list and thus (final [a] = a) imply that the input list elements should themselves be lists (because a should be a list since it is returned in this case)... So final wants a list of list. All is well until now and if you try for example : > final [True, False] you'll get a slightly better error message (maybe hard for newbies but very understandable with a little bit of experience) : Couldn't match expected type `[a]' against inferred type `Bool' In the expression: True In the first argument of `final', namely `[True, False]' In the expression: final [True, False] Now your error message is particularly nasty because all integer literals like "5" are treated in the following fashion in Haskell : they're implicitly translated to "fromInteger 5", fromInteger being a function of the Num typeclass that for an instance Num a take an Integer and translate it to the a type. This translation is normally pretty obvious with some bound checking (for Int type) and simple translation (to Double or Float) but you could in theory have some pretty crazy instances of Num, [a] for example. For example here Haskell complains that there are no Num instances for the [a] type since that's what he want to translate the "5" into.... I hope you understood this explanation, even if it's a little bit crazy and blury for now, just remember, most of the time if you have an error like : No instance for (Num X) arising from the literal `5' at :1:9 you can more or less translate it to : Couldn't match expected type `X' against inferred type `Integer' (This is only true for the Num typeclass, since this is the only case of polymorphic literals you'll meet for now). -- Jeda? From mad.one at gmail.com Mon Jul 21 08:14:06 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 21 08:04:16 2008 Subject: [Haskell-cafe] Trouble with non-exhaustive patterns In-Reply-To: References: Message-ID: <1216642185-sup-7337@existential.local> Hi Fernando, > final [] = [] - I consider that the end of an empty list is the empty list > final [a] = a > final (_:t) = final t > > Suddenly, the function stoped working with a rather cryptic (for a newbie > at least) error message: > > *Temp> final [4,5] > > :1:9: > No instance for (Num [a]) > arising from the literal `5' at :1:9 > Possible fix: add an instance declaration for (Num [a]) > In the expr*Temp> ession: 5 > In the first argument of `final', namely `[4, 5]' > In the expression: final [4, 5] The problem is that final has the type [a] -> a, so you cannot have a pattern match that simply returns the empty list; this makes the function partial because taking the tail of an empty list is undefined. If you wish to avoid it, you can wrap it in a Maybe: final :: [a] -> Maybe a final [] = Nothing final [a] = Just a final (_:t) = final t $ cat > final.hs final :: [a] -> Maybe a final [] = Nothing final [a] = Just a final (_:t) = final t $ ghci final.hs GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( final.hs, interpreted ) Ok, modules loaded: Main. *Main> final [1,2] Just 2 *Main> final [] Nothing *Main> Austin From chaddai.fouche at gmail.com Mon Jul 21 08:21:06 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Mon Jul 21 08:11:13 2008 Subject: [Haskell-cafe] Re: Help using Network.Curl In-Reply-To: <87r69pd3og.wl%jim@sdf-eu.org> References: <87r69pd3og.wl%jim@sdf-eu.org> Message-ID: 2008/7/19 Jim Burton : > opts = [CurlEncoding "text/xml" > , CurlHttpHeaders ["X-EBAY-API-COMPATIBILITY-LEVEL="++compatLevel > , "X-EBAY-API-DEV-NAME="++devName > , "X-EBAY-API-APP-NAME="++appName > , "X-EBAY-API-CERT-NAME="++certName > , "X-EBAY-API-CALL-NAME=GeteBayOfficialTime" > , "X-EBAY-API-SITEID=0"]] Isn't it ":" rather than "=" ? Just saying... (Don't know enough to be sure I'm thinking about the right thing) -- Jeda? From jim at sdf-eu.org Mon Jul 21 09:07:13 2008 From: jim at sdf-eu.org (Jim Burton) Date: Mon Jul 21 08:57:36 2008 Subject: [Haskell-cafe] Re: Help using Network.Curl In-Reply-To: References: <87r69pd3og.wl%jim@sdf-eu.org> Message-ID: <874p6j75dq.wl%jim@sdf-eu.org> At Mon, 21 Jul 2008 13:21:06 +0100, =?ISO-8859-1?Q?Chadda=EF_Fouch=E9?= wrote: > > 2008/7/19 Jim Burton : > > opts = [CurlEncoding "text/xml" > > , CurlHttpHeaders ["X-EBAY-API-COMPATIBILITY-LEVEL="++compatLevel > > , "X-EBAY-API-DEV-NAME="++devName > > , "X-EBAY-API-APP-NAME="++appName > > , "X-EBAY-API-CERT-NAME="++certName > > , "X-EBAY-API-CALL-NAME=GeteBayOfficialTime" > > , "X-EBAY-API-SITEID=0"]] > > Isn't it ":" rather than "=" ? Just saying... (Don't know enough to be > sure I'm thinking about the right thing) > Is is indeed, thanks very much. I also had to change to using `perform' rather than curlPost before it would work. Cheers, Jim > -- > Jeda? From felipe.lessa at gmail.com Mon Jul 21 12:56:16 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Jul 21 12:46:23 2008 Subject: [Haskell-cafe] Keeping a set of ForeignPtr's alive Message-ID: Hi! -- Background: -- I have some foreign objects that are mapped to ForeignPtr's, say newtype Obj = O (ForeignPtr Obj) and a foreign "collection" where those objects are added. The adding is something on the lines of addObj, removeObj :: Collection -> Obj -> IO () id est, the C code of the collection maintains a reference to all objects added. That means I have to keep all the ForeignPtr's added alive and that I must not prevent garbage collection of those removed. Of course the 'Collection' isn't just a simple collection, otherwise I would be using normal Haskell counterparts. -- Question: -- What is the best way to keep the added objects alive? Using a list will keep the addition cheap and a low memory overhead, while a Data.Set will make removeObj work in sublinear time (on the Haskell side). Are there any other options? I'm currently heading towards data Collection = C !(ForeignPtr Collection) !(IORef [Obj]) like ForeignPtr itself (although in the case of ForeignPtr's there is no way to remove finalizers). Thanks! -- Felipe. From dons at galois.com Mon Jul 21 13:32:39 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 21 13:22:52 2008 Subject: [Haskell-cafe] A good sign: languages used at Google Code Jam Message-ID: <20080721173239.GC15310@scytale.galois.com> http://www.go-hero.net/jam/lang Haskell as the highest ranked FP language in the Google Code Jam, with more submissions than Lisp, Scheme, SML and OCaml put together :) # C++ (used by 2875 people) # Java (used by 1747 people) # Python (used by 691 people) # C# (used by 609 people) # C (used by 453 people) # Perl (used by 193 people) # Ruby (used by 124 people) # PHP (used by 119 people) # Pascal (used by 90 people) # Haskell (used by 46 people) # Visual Basic (used by 43 people) # Objective-C (used by 24 people) # Lisp (used by 15 people) # Javascript (used by 13 people) # Scheme (used by 11 people) # Lua (used by 10 people) # Objective CAML (used by 10 people) # Basic (used by 9 people) # Bourne Shell (bash) (used by 5 people) # D (used by 4 people) # Groovy (used by 4 people) # J (used by 4 people) # Scala (used by 4 people) # ActionScript (used by 3 people) # Clojure (used by 2 people) # Eiffel (used by 2 people) # Erlang (used by 2 people) # SQL (used by 2 people) # Shell Script (sh) (used by 2 people) # Visual Basic Script (used by 2 people) # AWK (used by 1 people) # Arc (Lisp) (used by 1 people) # AutoIt Ver. 3 Script (used by 1 people) # Brainfuck (used by 1 people) # GNU Data Language (used by 1 people) # Informix 4GL (used by 1 people) # K (used by 1 people) # Maple (used by 1 people) # Standard ML (used by 1 people) From vigalchin at gmail.com Mon Jul 21 13:33:55 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 21 13:24:01 2008 Subject: [Haskell-cafe] Linux kernel/library question Message-ID: <5ae4f2ba0807211033u2201823dncfc1baee86bfa092@mail.gmail.com> Hello, I am working on POSIX stuff. I have used Linux as my POSIX OS and have read source when I could find it. Does anybody in this group of Linux newsgroup where one can ask Linux-related implementation questions? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080721/2ebaf87c/attachment.htm From westondan at imageworks.com Mon Jul 21 13:48:39 2008 From: westondan at imageworks.com (Dan Weston) Date: Mon Jul 21 13:38:54 2008 Subject: [Haskell-cafe] beginners mailing list should be beginner's choice In-Reply-To: References: Message-ID: <4884CBF7.1060909@imageworks.com> Just to avoid any misunderstanding... I am certain that C.M. Brown meant to say "CC'ed the Haskell-beginners mailing list" instead of "moved", but I think it's worth emphasizing that the new beginners list was ostensibly created for various discussed reasons, but all to provide a more tailored forum for beginners, not to restrict participation on haskell-cafe. Words like "move" could sound to a beginner like a dismissal or demotion. (This policy is clearly different from the haskell list, which has a much stronger collegially-enforced moderation policy limited to announcements.) I would hate to think that people on the beginners list might worry that their questions were not "good enough" to join the "grown-ups" on haskell-cafe. I think CC'ing to beginners is hint enough, and soon enough people will choose the best forum for their comfort level. Dan C.M.Brown wrote: > Hi Fernando, > > I hope you don't mind, but I've moved this over to the Haskell-beginners > mailing list, where I think this kind of question will be more > appropriate. From gracjanpolak at gmail.com Mon Jul 21 14:54:09 2008 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Mon Jul 21 14:44:27 2008 Subject: [Haskell-cafe] Optimizing 'sequence' Message-ID: Hi all, On the other day I noticed that we could optimize 'sequence' more. I needed it for my monadic parser. Below is my small experiment. Sequence from standard library needs 2.3s to finish (and additional stack space), my version uses only 0.65s and default stack. Is my version better or am I missing something obvious? -- standard sequence1 :: Monad m => [m a] -> m [a] sequence1 ms = foldr k (return []) ms where k m m' = do { x <- m; xs <- m'; return (x:xs) } -- accumulator version sequence2 :: Monad m => [m a] -> m [a] sequence2 ms = sequence' [] ms where sequence' vs [] = return (reverse vs) sequence' vs (m:ms) = m >>= (\v -> sequence' (v:vs) ms) main = do let l = map return [1..1000000] w <- sequence1 l print (sum w) return () gracjan@home:~/some_faster> time ./Some1 +RTS -K100M 500000500000 real 0m2.318s user 0m2.284s sys 0m0.032s gracjan@home:~/some_faster> time ./Some2 500000500000 real 0m0.652s user 0m0.592s sys 0m0.052s -- Gracjan From frantisek.kocun at gmail.com Mon Jul 21 15:16:13 2008 From: frantisek.kocun at gmail.com (frantisek kocun) Date: Mon Jul 21 15:06:20 2008 Subject: [Haskell-cafe] Linux kernel/library question In-Reply-To: <5ae4f2ba0807211033u2201823dncfc1baee86bfa092@mail.gmail.com> References: <5ae4f2ba0807211033u2201823dncfc1baee86bfa092@mail.gmail.com> Message-ID: Hi Vasili, try one of Linux groups at http://www.nabble.com/Linux-f252.html or maybe Linux kernel group http://www.nabble.com/linux-kernel-f49.html . But I don't know if there are people working with Haskell in Linux as well. But if you would like to ask something only about POSIX, I think they may help. Fero 2008/7/21 Galchin, Vasili : > Hello, > I am working on POSIX stuff. I have used Linux as my POSIX OS and have > read source when I could find it. Does anybody in this > group of Linux newsgroup where one can ask Linux-related implementation > questions? > > Regards, Vasili > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080721/21e8e4f7/attachment.htm From aslatter at gmail.com Mon Jul 21 15:20:02 2008 From: aslatter at gmail.com (Antoine Latter) Date: Mon Jul 21 15:10:08 2008 Subject: [Haskell-cafe] Optimizing 'sequence' In-Reply-To: References: Message-ID: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> On Mon, Jul 21, 2008 at 1:54 PM, Gracjan Polak wrote: > > Hi all, > > On the other day I noticed that we could optimize 'sequence' more. > I needed it for my monadic parser. Below is my small experiment. > Sequence from standard library needs 2.3s to finish (and additional > stack space), my version uses only 0.65s and default stack. > > Is my version better or am I missing something obvious? > How does your version compare with the library version in the following tests: test1 = do (x:_) <- sequence [return 5, undefined] return x test2 = do (x:_) <- sequence $ return 5 : undefined return x main = do print $ runIdentity test1 print $ runIdentity test2 The function "runIdentity" is found in Control.Monad.Identity in the mtl package. (I haven't tried this code yet, so it may not really be syntactically correct, but hopefully you get the idea.) -Antoine From sylvain.nahas at googlemail.com Mon Jul 21 15:21:24 2008 From: sylvain.nahas at googlemail.com (sylvain nahas) Date: Mon Jul 21 15:11:32 2008 Subject: [Haskell-cafe] Linux kernel/library question In-Reply-To: <5ae4f2ba0807211033u2201823dncfc1baee86bfa092@mail.gmail.com> References: <5ae4f2ba0807211033u2201823dncfc1baee86bfa092@mail.gmail.com> Message-ID: Hi Vasili, Please have a look at http://vger.kernel.org/vger-lists.html The main list is "linux-kernel". Depending on the level of your questions, you may also check "linux-newbie". If it concerns a defined subsystem/architecture, there is often a relevant mailing-list. Hope it helps and happy hacking, Sylvain 2008/7/21 Galchin, Vasili : > Hello, > I am working on POSIX stuff. I have used Linux as my POSIX OS and have > read source when I could find it. Does anybody in this > group of Linux newsgroup where one can ask Linux-related implementation > questions? > > Regards, Vasili > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080721/351356f1/attachment.htm From john at repetae.net Mon Jul 21 15:34:43 2008 From: john at repetae.net (John Meacham) Date: Mon Jul 21 15:24:50 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <03F7B11D-BD5F-4BCF-8168-29D375080340@cs.otago.ac.nz> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <20080720062623.GC15843@sliver.repetae.net> <03F7B11D-BD5F-4BCF-8168-29D375080340@cs.otago.ac.nz> Message-ID: <20080721193442.GB26359@sliver.repetae.net> On Mon, Jul 21, 2008 at 01:05:48PM +1200, Richard A. O'Keefe wrote: > I think it may be time for a little clarity about aoicb's. > From the Single Unix Specification: > "The header shall define the aiocb structure > which shall include AT LEAST the following members: > int aio_fildes File descriptor. > off_t aio_offset File offset. > volatile void *aio_buf Location of buffer. > size_t aio_nbytes Length of transfer. > int aio_reqprio Request priority offset. struct > sigevent aio_sigevent Signal number and value. > int aio_lio_opcode Operation to be performed. > " > The "AT LEAST" here means that > - a portable program may rely on these members being present > - a portable program MUST assume that an unknown number of > additional members are also present > - a portable program may freely copy such a record, but may > only pass it to a library function if that function is > expecting to initialise it > > For asynchronous I/O, this means that > - you can allocate an aiocb object > - an aiocb passed to aio_suspend, aio_error, > aio_return, or aio_cancel should have been > filled in by aio_read or aio_write and should > be EXACTLY THE SAME object, not a copy of it. Yes. This is pretty standard as far as what you can count on in terms of standard C structures. The method I use in the RSA.hsc module I posted is compatible with these assumptions. Generally this is pretty much exactly the thing hsc2hs was made to solve. Just a note, if you are doing manual explicit frees of the aiocb structure then you only need a 'Ptr', if you want the structure to be automatically garbage collected when all haskell references to it disappear, then you need to use 'ForeignPtr'. John -- John Meacham - ?repetae.net?john? From ndmitchell at gmail.com Mon Jul 21 18:23:13 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jul 21 18:13:19 2008 Subject: [Haskell-cafe] Re: Extending the GSoC model In-Reply-To: References: Message-ID: <404396ef0807211523w2bbeded1h704e98e124658b6d@mail.gmail.com> Hi Suggested by Andrew Wager on libraries@, moving to haskell-cafe@ since its a really interesting idea and libraries is probably not the best place for it. > Not sure if this is the best place to suggest this, but I was > wondering about the possibility of extending the model that we > currently use for Google's Summer of Code. > > The benefits: > 1.) A place to make suggestions for code you would never be able to > write, and somebody else might not think of > 2.) A place to see what's being worked on, but not yet done > 3.) A way for people who are less confident in their haskell-foo to find mentors > 4.) A way for people who are more confident in their haskell-foo to > contribute without spending a ton of time hacking up actual code > 5.) Overall, more (and higher-quality) libraries And my thoughts: 1) I think as long as the suggestions are small improvements to existing projects it could work really well. New projects are probably less likely to work without the original author having the original motivation. I have one of these for some of my projects: http://code.google.com/p/ndmitchell/issues/list - a bug tracker works quite well. 2) Bug trackers do this. 3, 4) Fantastic idea, coordinating via the IRC channel already gives some of this, but it could be made more direct. Also having a specific person to talk to, and to review/commit/integrate the work makes the work more useful. 5) Always a great idea. So I think these things could be achieved by integrating various bug trackers, ensuring lots of projects on hackage have bug trackrs, and some mailing list for people working on this to allow people to ask for mentors and mentors to be available to respond. My guess that if there are the people who want mentors, then mentors could be found - but the other way round won't happen. Thanks Neil From dons at galois.com Mon Jul 21 18:53:47 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 21 18:43:55 2008 Subject: [Haskell-cafe] Optimizing 'sequence' In-Reply-To: References: Message-ID: <20080721225347.GB16158@scytale.galois.com> If you can demonstrate the required laziness/strictness properties are identical, looks like a nice idea. gracjanpolak: > > Hi all, > > On the other day I noticed that we could optimize 'sequence' more. > I needed it for my monadic parser. Below is my small experiment. > Sequence from standard library needs 2.3s to finish (and additional > stack space), my version uses only 0.65s and default stack. > > Is my version better or am I missing something obvious? > > -- standard > sequence1 :: Monad m => [m a] -> m [a] > sequence1 ms = foldr k (return []) ms > where > k m m' = do { x <- m; xs <- m'; return (x:xs) } > > -- accumulator version > sequence2 :: Monad m => [m a] -> m [a] > sequence2 ms = sequence' [] ms > where > sequence' vs [] = return (reverse vs) > sequence' vs (m:ms) = m >>= (\v -> sequence' (v:vs) ms) > > main = do > let l = map return [1..1000000] > w <- sequence1 l > print (sum w) > return () > > gracjan@home:~/some_faster> time ./Some1 +RTS -K100M > 500000500000 > > real 0m2.318s > user 0m2.284s > sys 0m0.032s > > > gracjan@home:~/some_faster> time ./Some2 > 500000500000 > > real 0m0.652s > user 0m0.592s > sys 0m0.052s > > -- > Gracjan > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ryanbloor at hotmail.com Mon Jul 21 22:33:42 2008 From: ryanbloor at hotmail.com (Ryan Bloor) Date: Mon Jul 21 22:23:47 2008 Subject: [Haskell-cafe] Trees (Rose Trees?) Message-ID: hi I was curious as to whether my implementation of a Rose Tree and a sumTree function was correct. The aumTree adds up the elements of a tree. data Tree a = Leaf a | Node [Tree a] sumTree :: Tree Int -> Int sumTree (Node []) = 0 sumTree (Node xs) = sum (map sumTree xs) The problem with this is I get a pattern matching error. Am I representing trees right... see below. Also, would an empty tree be represented by ... Node [] with this implementation? How would I represent a tree of the form... Tree (Node 2(Node 6 Empty Empty) Empty) taken from a binary one. Like this? Node [ [Leaf 2], Node [ Leaf 6,Node[],Node[] ], Node[] ] Ryan _________________________________________________________________ Find the best and worst places on the planet http://clk.atdmt.com/UKM/go/101719807/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/4081a483/attachment.htm From wagner.andrew at gmail.com Mon Jul 21 23:21:37 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Jul 21 23:11:40 2008 Subject: [Haskell-cafe] Trees (Rose Trees?) In-Reply-To: References: Message-ID: There are a few different kinds of trees, but if you only need to store data on the leaves, that representation will work. As for your sumTree function, you are indeed missing a case...consider sumTree (Leaf 3)! Once you deal with that case, the other two can actually be combined (since sum [] = 0). 2008/7/21 Ryan Bloor : > hi > > I was curious as to whether my implementation of a Rose Tree and a sumTree > function was correct. The aumTree adds up the elements of a tree. > > data Tree a = Leaf a | Node [Tree a] > > sumTree :: Tree Int -> Int > sumTree (Node []) = 0 > sumTree (Node xs) = sum (map sumTree xs) > > The problem with this is I get a pattern matching error. Am I representing > trees right... see below. > > Also, would an empty tree be represented by ... Node [] with this > implementation? > How would I represent a tree of the form... Tree (Node 2(Node 6 Empty Empty) > Empty) taken from a binary one. > Like this? Node [ [Leaf 2], Node [ Leaf 6,Node[],Node[] ], Node[] ] > > Ryan > > > > ________________________________ > Find out how to make Messenger your very own TV! Try it Now! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From voigt at tcs.inf.tu-dresden.de Tue Jul 22 02:29:47 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Tue Jul 22 02:12:13 2008 Subject: [Haskell-cafe] Optimizing 'sequence' In-Reply-To: <20080721225347.GB16158@scytale.galois.com> References: <20080721225347.GB16158@scytale.galois.com> Message-ID: <48857E5B.6000500@tcs.inf.tu-dresden.de> Don Stewart wrote: > If you can demonstrate the required laziness/strictness properties > are identical, looks like a nice idea. I think they are not identical, as something along Antoine's second example demonstrates. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From gracjanpolak at gmail.com Tue Jul 22 03:15:40 2008 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Tue Jul 22 03:05:56 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> Message-ID: Antoine Latter gmail.com> writes: > > The function "runIdentity" is found in Control.Monad.Identity in the > mtl package. > Thanks, I see it now! Laziness is not there! But still... Identity is a bit special monad. What other monads need full laziness in sequence? As far as I know IO is strict. What about lazy/strict state monad? Initially I spotted this possible optimization in context of monadic parser. I am not really sure if I need this property there or not. How do I prove this to myself? Thanks to others who responded. -- Gracjan From voigt at tcs.inf.tu-dresden.de Tue Jul 22 03:44:36 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Tue Jul 22 03:27:02 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' In-Reply-To: References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> Message-ID: <48858FE4.6040607@tcs.inf.tu-dresden.de> Gracjan Polak wrote: > Initially I spotted this possible optimization in context of monadic parser. I > am not really sure if I need this property there or not. How do I prove this to > myself? How about some QuickChecking in connection with the "Chasing bottoms" library (http://citeseer.ist.psu.edu/704350.html)? -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From chak at cse.unsw.edu.au Tue Jul 22 03:46:24 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Tue Jul 22 03:36:32 2008 Subject: [Haskell-cafe] Building NDP with latest GHC In-Reply-To: <1216628285-sup-8172@existential.local> References: <1216628285-sup-8172@existential.local> Message-ID: <319BD208-4650-4905-8E2A-F858517E193C@cse.unsw.edu.au> Austin Seipp: > After my last issue with GHC's HEAD, I tried checking it out again and > getting the patches for the libraries and lo and behold, it worked. So > now I'm up to date with the latest libraries and the compiler, but it > appears that building NDP itself is proving to be troublesome. The NDP libraries are in a state of complete upheaval. Instead of the one package ndp, there will be a set of dph packages with different backends to choose from (initially, there will be two backends, one for sequential code and one for multicore parallel code). > If I'm just doing everything wrong, I'd really appreciate knowing and > I'd be *more* than happy to update the wiki pages so that more people > can try it and have it build successfuly, because as it stands I'm > coming to the conclusion that basically all the information in [1] is > just old and flat-out wrong, and I'm completely of ideas on how to go > about this. [..] > [1] http://haskell.org/haskellwiki/Data_Parallel_Haskell/PackageNDP Due to the completely different new set up, there was no point in trying to track incremental changes on the wiki page. Once, the individual pieces fit together again, we'll update the documentation. Due to a sequence of problems with GHC's build system and its increasing Cabal'isation, the library re-arrangement has taken much longer than originally anticipated. Sorry about that. Manuel From lrpalmer at gmail.com Tue Jul 22 04:17:04 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Jul 22 04:07:08 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' In-Reply-To: References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> Message-ID: <7ca3f0160807220117q1f29bd4asc9af0109bfed8c86@mail.gmail.com> On Tue, Jul 22, 2008 at 1:15 AM, Gracjan Polak wrote: > Antoine Latter gmail.com> writes: >> >> The function "runIdentity" is found in Control.Monad.Identity in the >> mtl package. >> > But still... Identity is a bit special monad. What other monads need full > laziness in sequence? As far as I know IO is strict. What about lazy/strict > state monad? A little formal reasoning reveals that sequence1 = sequence2 exactly when (>>=) is strict in its left argument. There are four common monads which are _not_: Identity, Reader, Writer, State (and RWS by extension). Luke From marlowsd at gmail.com Tue Jul 22 05:11:43 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Tue Jul 22 05:01:50 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: References: <87tzfehfgy.wl%jeremy@n-heptane.com> <200807021626009536167@gmail.com> <20080702171440.GC26461@liouville.galois.com> Message-ID: <4885A44F.6090502@gmail.com> Braden Shepherdson wrote: > So, assuming some GHC dev doesn't swoop down and fix this, what options > are left to the project in the short term? > > An unregisterised build of an old 6.6 should work, that would get us a > working, though aging, GHC. Unfortunately a lot of the porting work to > move from that first unregisterised build to a registerised one (even > without native code-gen) wouldn't be transferable to a later 6.9 or > 6.10, since 6.9 has moved from using the Evil Mangler to libffi. Sorry for the delay in replying. I'm not sure if you're aware, but when you have an unregisterised 6.6 working, you can use that to build an unregisterised 6.8 and later versions. Building the unregisterised 6.6 would just be a stepping stone to the latest version, and only needs to be done once. This may be moot if we get bootstrapping working again, but until then I'd guess going via 6.6 is the easiest route. For the registerised port, you really need a native code generator (the mangler is on death row, yay). At a rough guess, I'd say porting the NCG would take a couple of weeks or so for someone unfamiliar with the code. Hopefully we'll improve that when we refactor the NCG as part of the backend overhaul. Cheers, Simon From chaddai.fouche at gmail.com Tue Jul 22 05:53:00 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Tue Jul 22 05:43:04 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' In-Reply-To: <7ca3f0160807220117q1f29bd4asc9af0109bfed8c86@mail.gmail.com> References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> <7ca3f0160807220117q1f29bd4asc9af0109bfed8c86@mail.gmail.com> Message-ID: 2008/7/22 Luke Palmer : > A little formal reasoning reveals that sequence1 = sequence2 exactly > when (>>=) is strict in its left argument. There are four common > monads which are _not_: Identity, Reader, Writer, State (and RWS by > extension). Still if that makes that much of a difference, maybe we could envision putting a sequence' in the library ? -- Jeda? From aspam at cox.net Tue Jul 22 08:45:07 2008 From: aspam at cox.net (Joe Buehler) Date: Tue Jul 22 08:35:22 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <4885A44F.6090502@gmail.com> References: <87tzfehfgy.wl%jeremy@n-heptane.com> <200807021626009536167@gmail.com> <20080702171440.GC26461@liouville.galois.com> <4885A44F.6090502@gmail.com> Message-ID: Simon Marlow wrote: > For the registerised port, you really need a native code generator (the > mangler is on death row, yay). At a rough guess, I'd say porting the > NCG would take a couple of weeks or so for someone unfamiliar with the > code. Hopefully we'll improve that when we refactor the NCG as part of > the backend overhaul. Is there any documentation on the NCG? I ported 6.6 to HPUX 11 some time ago and looked at the NCG but didn't do it for PA-RISC because it was going to take too much time to understand. I was leaning towards the approach of trying to translate the code generator for another processor into PA-RISC. -- Joe Buehler From qdunkan at gmail.com Tue Jul 22 09:17:59 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Tue Jul 22 09:08:05 2008 Subject: [Haskell-cafe] array fusion interface Message-ID: <2518b95d0807220617s115405acuddd67e63a2118046@mail.gmail.com> With all the noise lately about high performance array libraries with list-like interfaces, such as bytestring, storablevector, uvector, and vector, I thought I would try to make use of one in a project of mine, and I'm either bumping up against the limits of its expressiveness, or am missing out on how to express my problem. I have streams of samples with irregular sampling rates, so they look like [(Time, SampleVal)]. In practice, this means [(Double, Double)]. I can do this with storablevector by either storing two Vector Double, or by making a (Double, Double) Storable instance (more natural but requires -XFleixbleInstances). Now most functions that operate over a sample stream actually want a pair of samples so they can get an exact time with linear interpolation. Combining two streams requires them to both be resampled so their points line up, e.g. with a list implementation (ignoring the edges): resample as@((ax0, ay0) : (ax1, ay1) : _) bs@((bx0, by0) : (bx1, by1) : _) | ax1 == bx1 = (ax1, (ay1, by1)) : resample (tail as) (tail bs) | ax1 < bx1 = (ax1, (ay1, y_at (bx0, by0) (bx1, by1) ax1)) : resample (tail as) bs | otherwise = (bx1, (y_at (ax0, ay0) (ax1, ay1) bx1, by1)) : resample as (tail bs) y_at (x0, y0) (x1, y1) x = (y1 - y0) / (x1 - x0) * (x - x0) + y0 So there are a number of things here that don't seem to work so well with a vector interface. The first is that this returns [(Val, (Val, Val))]. I could either write an instance of Storable for (Double, (Double, Double)), or I could pass a function (Val, Val) -> Val. It looks like uvector handles zips more nicely though. The second is that this, like most such functions, wants a pair of samples to do linear interpolation. With lists I can do pattern matching as above or 'zip xs (drop 1 xs)', and with vectors the slightly less natural mapAccumL. Ok, then the third problem is that this progresses at a variable rate down two vectors, and I don't know any way to express that. Also, as a fourth problem, many functions taking samples will wind up generating more samples, which requires a concatMap kind of thing, which uvector doesn't seem to have, but in storablevector and lazy bytestring involves converting the whole thing to a list and back. What I'd ideally like is a lazy stream of unpacked chunks ala ByteString.Lazy. It seems like it might be possible to do something with ST and mutable arrays, and somehow come up with an abstraction that hides the packing and chunks and freezing but is still flexible enough to write something like 'resample', but I haven't thought about what that would look like. And it would be much nicer to try to fit something into the array fusion kind of interface. Is it possible? Is concatMap and "complicated zip" incompatible with the listlike array interface and fusion? Is there a better way to express this that avoids the problems? Initially this seemed like the perfect application for storablevector or uvector, but maybe it's not actually. From dokondr at gmail.com Tue Jul 22 10:26:45 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Tue Jul 22 10:16:48 2008 Subject: [Haskell-cafe] Newbie: Replacing substring? Message-ID: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> A few simple questions: What standard library function can be used to replace substring in a string (or sub-list in a list) ? I wrote my own version, please criticize: -- replace all occurances of "123" with "58" in a string: test = replStr "abc123def123gh123ikl" "123" "58" {-- In a string replace all occurances of an 'old' substring with a 'new' substring --} replStr str old new = foldr ((\newSub before after -> before ++ newSub ++ after) new) [] chunks where chunks = splitStr str old {-- Split string into a list of chunks. Chunks are substrings located in a string between 'sub' substrings --} splitStr str sub = mkChunkLst str sub [] where -- mkChunkLst 'src string' 'substr-to-extract' 'list of chunks' -- makes list of chunks located between 'substr-to-extract' pieces in src string mkChunkLst [] _ chunkLst = chunkLst mkChunkLst str sub chunkLst = mkChunkLst after sub (chunkLst ++ [chunk]) where (chunk, _, after) = takeOut str sub [] [] {-- Take out substring from a string. String is divided into: "before substr" ++ "match" ++ "after substr" where 'match' is substring to split out --} takeOut after [] before match = (before, match, after) takeOut [] _ before match = (before, match, []) takeOut (x:xs) (y:ys) before match | x == y = takeOut xs ys before (match ++ [x]) | otherwise = takeOut xs (y:ys) (before ++ match ++ [x]) [] -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/2cde5308/attachment.htm From jgbailey at gmail.com Tue Jul 22 11:13:08 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Tue Jul 22 11:03:14 2008 Subject: [Haskell-cafe] Portland & OSCon In-Reply-To: <48726BFA.3060007@complete.org> References: <48726BFA.3060007@complete.org> Message-ID: The PDX functional programming interest group will have a dinner meeting at the location below tonight. John Goerzen had asked if there would be a Haskell get together in Portland during OSCON. Here is one opportunity! ---------- Forwarded message ---------- From: Igal Koshevoy Date: Mon, Jul 21, 2008 at 6:34 PM Subject: [pdxfunc] DINNER MEETING: Tuesday, July 22, 5pm, Old Town Pizza, upstairs To: pdxfunc@googlegroups.com Old Town Pizza is at 226 NW Davis St, Portland, OR Let's just meet up there. If someone wants to do a reservation, they're welcome to do so but please be sure to post to the list so everyone knows to bring cash to pay you back for the single tab. See you there. -igal On Mon, Jul 7, 2008 at 12:18 PM, John Goerzen wrote: > Hi, > > OSCon is happening in Portland, OR starting 2 weeks from today, with > probably the largest number of people there on July 23 and 24. I know > there are a number of Haskellers that live in the Portland area, and I > suspect a few more may be going to OSCon. > > Anyone interested in a Haskell gathering someplace? > > -- John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From zunino at di.unipi.it Tue Jul 22 11:39:40 2008 From: zunino at di.unipi.it (Roberto Zunino) Date: Tue Jul 22 11:27:14 2008 Subject: [Haskell-cafe] Newbie: Replacing substring? In-Reply-To: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> References: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> Message-ID: <4885FF3C.4090007@di.unipi.it> Dmitri O.Kondratiev wrote: > I wrote my own version, please criticize: > > -- replace all occurances of "123" with "58" in a string: > test = replStr "abc123def123gh123ikl" "123" "58" This is a tricky problem: first of all, you fail your own test! ;-) *Main> test "abc58def58gh58ikl58" (Note the extra 58 at the end.) Other common pitfalls: *Main> replStr "abc1123def" "123" "58" "abc1158def58" (extra 1 ?) *Main> replStr "abc12123def" "123" "58" "abc121258def58" (extra 12 ?) A useful function from Data.List: stripPrefix (Of course, there are more efficient string match algorithms) Regards, Zun. From dokondr at gmail.com Tue Jul 22 12:21:51 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Tue Jul 22 12:11:55 2008 Subject: [Haskell-cafe] Newbie: Replacing substring? In-Reply-To: <4885FF3C.4090007@di.unipi.it> References: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> <4885FF3C.4090007@di.unipi.it> Message-ID: <53396d9e0807220921o74630a51ub435420f37f21bf9@mail.gmail.com> Roberto thanks! Shame on me, to post code without enough testing :( Yet, thanks to your comments *I think* I have found the bugs you wrote about and now my code works, please see corrected version below. Extra substring at the end was a result of using foldr with initial element of []. I fixed this with foldl and first chunk as its initial element. Incomplete substitution in case of duplicate elements in the pattern was a bug in my 'takeOut' function that I have also fixed. Stiil the problem that I have not yet designed solution for is when a substring to replace extends from the end of a string to the next string. In other words - first part of substring ends the first string and second part of substring starts the second string. My algorithm currently does not account for such a case. On the side: The more I use Haskell - the more I like it ! It helps me think about the problem I solve much more clearly then when I use imperative language. Corrected code: -- replace all occurances of "123" with "58" in a string: test = replStr "abc123def123gh123ikl" "123" "58" {-- In a string replace all occurances of an 'old' substring with a 'new' substring --} replStr str old new = foldl ((\newSub before after -> before ++ newSub ++ after) new) firstChunk otherChunks where chunks = splitStr str old firstChunk = head chunks otherChunks = tail chunks {-- Split string into a list of chunks. Chunks are substrings located in a string between 'sub' substrings --} splitStr str sub = mkChunkLst str sub [] where -- mkChunkLst 'src string' 'substr-to-extract' 'list of chunks' -- makes list of chunks located between 'substr-to-extract' pieces in src string mkChunkLst [] _ chunkLst = chunkLst mkChunkLst str sub chunkLst = mkChunkLst after sub (chunkLst ++ [chunk]) where (chunk, _, after) = takeOut str sub [] [] {-- Take out substring from a string. String is divided into: "before substr" ++ "match" ++ "after substr" where 'match' is substring to split out --} takeOut after [] before match = (before, match, after) takeOut [] _ before match = (before, match, []) takeOut (x:xs) (y:ys) before match | x == y = takeOut xs ys before (match ++ [x]) | otherwise = takeOut xs (y:ys) (before ++ [x]) [] On Tue, Jul 22, 2008 at 7:39 PM, Roberto Zunino wrote: > Dmitri O.Kondratiev wrote: > >> I wrote my own version, please criticize: >> >> -- replace all occurances of "123" with "58" in a string: >> test = replStr "abc123def123gh123ikl" "123" "58" >> > > This is a tricky problem: first of all, you fail your own test! ;-) > > *Main> test > "abc58def58gh58ikl58" > > (Note the extra 58 at the end.) > > Other common pitfalls: > > *Main> replStr "abc1123def" "123" "58" > "abc1158def58" > > (extra 1 ?) > > *Main> replStr "abc12123def" "123" "58" > "abc121258def58" > > (extra 12 ?) > > A useful function from Data.List: stripPrefix > > (Of course, there are more efficient string match algorithms) > > Regards, > Zun. > -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/b90fc294/attachment.htm From zl29ah at gmail.com Tue Jul 22 13:18:41 2008 From: zl29ah at gmail.com (L29Ah) Date: Tue Jul 22 13:08:43 2008 Subject: [Haskell-cafe] Point-free style in guards Message-ID: outStanza | (isMessage) = outMessage | (isPresence) = outPresence | (isIQ) = outIQ Why such a style doesn't work, so I must write ugly code like that: outStanza a | (isMessage a) = outMessage a | (isPresence a) = outPresence a | (isIQ a) = outIQ a so, guards can't be useful in point-free function definitions in any way -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/9ec2f017/attachment.htm From ndmitchell at gmail.com Tue Jul 22 13:27:07 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jul 22 13:17:10 2008 Subject: [Haskell-cafe] Point-free style in guards In-Reply-To: References: Message-ID: <404396ef0807221027t2c82dc8fi4faee742b74a307c@mail.gmail.com> Hi > Why such a style doesn't work, so I must write ugly code like that: > > outStanza a | (isMessage a) = outMessage a > | (isPresence a) = outPresence a > | (isIQ a) = outIQ a You can make it slightly prettier, since the brackets are not necessary: outStanza a | isMessage a = outMessage a | isPresence a = outPresence a | isIQ a = outIQ a Although I suspect that outMessage crashes if isMessage returns False? And perhaps outMessage is written as outMessage (Message a b) = ... In which case, I'd write: outStanza (Message a b) = ... And then the code no longer looks ugly, uses pattern matching nicely, requires no "is..." functions and won't crash if things like outMessage are called incorrectly. [Note, everything beyond the no need for brackets is a bit of a guess, just possible ideas to think about] Thanks Neil From allbery at ece.cmu.edu Tue Jul 22 13:32:17 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Jul 22 13:22:19 2008 Subject: [Haskell-cafe] Point-free style in guards In-Reply-To: References: Message-ID: <74B01836-C113-413F-B207-72D88404FF9D@ece.cmu.edu> On Jul 22, 2008, at 13:18 , L29Ah wrote: > outStanza | (isMessage) = outMessage > | (isPresence) = outPresence > | (isIQ) = outIQ > > Why such a style doesn't work, so I must write ugly code like that: Because the Haskell 98 Report specifies that guards are rewritten in a specific way, which in your case produces invalid code. See http://haskell.org/onlinereport/decls.html#pattern-bindings for details. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/054f1c0c/attachment.htm From qdunkan at gmail.com Tue Jul 22 13:33:54 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Tue Jul 22 13:23:58 2008 Subject: [Haskell-cafe] Point-free style in guards In-Reply-To: <404396ef0807221027t2c82dc8fi4faee742b74a307c@mail.gmail.com> References: <404396ef0807221027t2c82dc8fi4faee742b74a307c@mail.gmail.com> Message-ID: <2518b95d0807221033m2593c2d2sd64d6662db98ba60@mail.gmail.com> On Tue, Jul 22, 2008 at 10:27 AM, Neil Mitchell wrote: > Hi > >> Why such a style doesn't work, so I must write ugly code like that: >> >> outStanza a | (isMessage a) = outMessage a >> | (isPresence a) = outPresence a >> | (isIQ a) = outIQ a > > You can make it slightly prettier, since the brackets are not necessary: > > outStanza a | isMessage a = outMessage a > | isPresence a = outPresence a > | isIQ a = outIQ a Also, if it really is in that format, maybe you can write something like: switch v pairs = maybe (error "no match") ($v) (lookupWith ($v) pairs) And then you can write the list point-free, though you don't get the nice guard syntax. I guess lookupWith must be one of my local functions, but it's easy to write too. From claus.reinke at talk21.com Tue Jul 22 14:25:40 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Jul 22 14:15:44 2008 Subject: [Haskell-cafe] Point-free style in guards References: Message-ID: <017301c8ec28$5966b790$de418351@cr3lt> > outStanza | (isMessage) = outMessage > | (isPresence) = outPresence > | (isIQ) = outIQ > > Why such a style doesn't work, so I must write ugly code like that: > > outStanza a | (isMessage a) = outMessage a > | (isPresence a) = outPresence a > | (isIQ a) = outIQ a > > so, guards can't be useful in point-free function definitions in any way You just have to avoid all those pointless language constructs that let mere Haskellers deal with points, and define your own: import Control.Monad import Data.Maybe import Control.Arrow((&&&)) g |= rhs = uncurry (>>) . ((guard . g) &&& (return . rhs)) a +++ b = uncurry mplus . (a &&& b) (=|) = (fromJust .) outStanza = (=|) (((=="m") |= ("message: "++)) +++ ((=="p") |= ("presence: "++)) +++ ((=="i") |= ("iq: "++)) ) Sorry about mentioning those Strings, but then the names shouldn't really mention the points (Stanza/Message/..), either, right? Or have I missed the point of this exercise?-) Claus From darrinth at gmail.com Tue Jul 22 16:09:24 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Tue Jul 22 15:59:28 2008 Subject: [Haskell-cafe] BLAS Solve Example Message-ID: I'm stuck on something that I thought would be easy. I have a matrix and a vector. > module Main where > import Data.Vector.Dense > import Data.Matrix.Dense > import BLAS.Matrix.Solve > > m = listMatrix (2, 3) ([1, 2, 3, 4, 5, 6]::[Double]) > v = listVector 2 ([1, 2]::[Double]) > > main = do ??? Can I use one of the haskell libraries to solve that system? My goal is to automate some tedium on small exercises from the Linear Algebra text by Jim Heffron. -- Darrin From oddron at gmail.com Tue Jul 22 16:38:53 2008 From: oddron at gmail.com (Ronald Guida) Date: Tue Jul 22 16:28:56 2008 Subject: [Haskell-cafe] Newbie: Replacing substring? In-Reply-To: <53396d9e0807220921o74630a51ub435420f37f21bf9@mail.gmail.com> References: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> <4885FF3C.4090007@di.unipi.it> <53396d9e0807220921o74630a51ub435420f37f21bf9@mail.gmail.com> Message-ID: <62728db30807221338i73420728kf3d52c28bc7f3938@mail.gmail.com> 2008/7/22 Dmitri O.Kondratiev : > On the side: The more I use Haskell - the more I like it ! It helps me think > about the problem I solve much more clearly then when I use imperative > language. If I want to replace a substring in a string, then I would search my string left to right, looking for any occurrence of the substring. If I find such an occurrence, I would replace it and continue searching from immediately after the replacement. This algorithm can be directly expressed in Haskell. More efficient algorithms do exist. replaceStr :: String -> String -> String -> String replaceStr [] old new = [] replaceStr str old new = loop str where loop [] = [] loop str = let (prefix, rest) = splitAt n str in if old == prefix -- found an occurrence? then new ++ loop rest -- yes: replace it else head str : loop (tail str) -- no: keep looking n = length old From jno at di.uminho.pt Tue Jul 22 17:40:33 2008 From: jno at di.uminho.pt (J.N. Oliveira) Date: Tue Jul 22 17:30:36 2008 Subject: [Haskell-cafe] Point-free style in guards In-Reply-To: <74B01836-C113-413F-B207-72D88404FF9D@ece.cmu.edu> References: <74B01836-C113-413F-B207-72D88404FF9D@ece.cmu.edu> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3109 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/c9ce71b9/smime.bin From lrpalmer at gmail.com Tue Jul 22 18:39:24 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Jul 22 18:29:26 2008 Subject: [Haskell-cafe] Point-free style in guards In-Reply-To: References: <74B01836-C113-413F-B207-72D88404FF9D@ece.cmu.edu> Message-ID: <7ca3f0160807221539x30f30632u861d53360169c9f9@mail.gmail.com> 2008/7/22 J.N. Oliveira : > But you still need the extra parentheses... Not so! infixl 0 .| infixl 0 .|... -- 'otherwise' construct infix 1 .= (.=) :: (a -> Bool) -> (a -> b) -> (a -> Maybe b) (.|) :: (a -> Maybe b) -> (a -> Maybe b) -> (a -> Maybe b) (.|...) :: (a -> Maybe b) -> (a -> b) -> (a -> b) -- implementations left as exercise for the reader outStanza = isMessage .= outMessage .| isPresence .= outPresence .| isIQ .= outIQ .|... const 42 Hooray for abusing operators! Luke From patperry at stanford.edu Tue Jul 22 21:21:11 2008 From: patperry at stanford.edu (Patrick Perry) Date: Tue Jul 22 21:11:17 2008 Subject: [Haskell-cafe] BLAS Solve Example Message-ID: <9AC64322-AD81-4248-A39A-FE7E4CF53FD4@stanford.edu> Sorry Darrin, the BLAS library only includes matrix multiplication and solving triangular systems. To solve a general system, you would need to use LAPACK, but there aren't any bindings for that library yet. I would suggest you take a look at the hmatrix package, which includes a lot more linear algebra than blas does.. Patrick From wren at freegeek.org Tue Jul 22 22:46:01 2008 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 22 22:36:05 2008 Subject: [Haskell-cafe] ANN: list-extras 0.1.0 Message-ID: <48869B69.8070103@freegeek.org> hello all~ I'm pleased to announce the initial version of list-extras, a home for common not-so-common list functions. There are many simple but non-trivial functions for lists which Data.List lacks. Typically we write a version and include it in a larger project or store it in a local source tree for personal jobs. But neither of these approaches makes it easy to distribute the code and take advantage of open-source development for improving the code. Since I had code from both approaches, I'm taking the first step and putting a package out there. So far it's not too large though I'll be adding things as they come up. If you have functions you think would belong, feel free to contact me. list-extras includes: - Prelude.Listless This module provides the "Prelude" but removing all the list functions. This is helpful for modules that overload those function names to work for other types. - Data.List.Extras.LazyLength This module provides least-strict functions for getting a list's length and doing natural things with it. On GHC this module also uses rewrite rules to convert certain calls to 'length' into our least-strict versions. [We could do this inefficiently by defining a version of 'length' which returns a Peano integer, but this module is more efficient.] - Data.List.Extras.Pair This module provides safe zipping functions which will fail (return 'Nothing') on uneven length lists. [We could do this by getting the lengths first and comparing, but this module is less strict when the lengths are uneven, and we only traverse the lists once.] - Data.List.Extras.ArgMax This module provides variants of the 'maximum' and 'minimum' functions which return the element for which some function is maximized or minimized. [We could do this by a decorate-fold-undecorate pattern, but this version is more space efficient.] Links to the hackage and darcs copies of list-extras can be found at: http://code.haskell.org/~wren/ -- Live well, ~wren From vigalchin at gmail.com Wed Jul 23 00:10:14 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jul 23 00:00:16 2008 Subject: [Haskell-cafe] Linux kernel/library question In-Reply-To: References: <5ae4f2ba0807211033u2201823dncfc1baee86bfa092@mail.gmail.com> Message-ID: <5ae4f2ba0807222110t3c621adfj78b9fb067bb095f0@mail.gmail.com> Thank you, Fero and Sylvain! Vasili On Mon, Jul 21, 2008 at 2:21 PM, sylvain nahas wrote: > Hi Vasili, > > Please have a look at http://vger.kernel.org/vger-lists.html > > The main list is "linux-kernel". Depending on the level of your questions, > you may also check "linux-newbie". > > If it concerns a defined subsystem/architecture, there is often a relevant > mailing-list. > > Hope it helps and happy hacking, > Sylvain > > 2008/7/21 Galchin, Vasili : > >> Hello, >> >> I am working on POSIX stuff. I have used Linux as my POSIX OS and have >> read source when I could find it. Does anybody in this >> group of Linux newsgroup where one can ask Linux-related >> implementation questions? >> >> Regards, Vasili >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080722/a41c4803/attachment.htm From bulat.ziganshin at gmail.com Wed Jul 23 01:10:02 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 23 01:03:00 2008 Subject: [Haskell-cafe] ANN: list-extras 0.1.0 In-Reply-To: <48869B69.8070103@freegeek.org> References: <48869B69.8070103@freegeek.org> Message-ID: <1368409738.20080723091002@gmail.com> Hello wren, Wednesday, July 23, 2008, 6:46:01 AM, you wrote: > I'm pleased to announce the initial version of list-extras, a home for > common not-so-common list functions. MissingH library contained a lot of them too. i know that John Goerzen started to break it into area-specific libs, so may be you can join your efforts? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From aruiz at um.es Wed Jul 23 02:12:42 2008 From: aruiz at um.es (Alberto Ruiz) Date: Wed Jul 23 02:02:46 2008 Subject: [Haskell-cafe] BLAS Solve Example In-Reply-To: References: Message-ID: <4886CBDA.2060603@um.es> Darrin Thompson wrote: > I'm stuck on something that I thought would be easy. > > I have a matrix and a vector. > >> module Main where >> import Data.Vector.Dense >> import Data.Matrix.Dense >> import BLAS.Matrix.Solve >> >> m = listMatrix (2, 3) ([1, 2, 3, 4, 5, 6]::[Double]) >> v = listVector 2 ([1, 2]::[Double]) >> >> main = do ??? > > Can I use one of the haskell libraries to solve that system? My goal > is to automate some tedium on small exercises from the Linear Algebra > text by Jim Heffron. > > -- > Darrin Using hmatrix: > import Numeric.LinearAlgebra > > m = (2><3) [1, 2, 3, > 4, 5, 6] > > v = 2 |> [1, 2 :: Double] > > sol = m <\> v $ ghci solve.hs *Main> sol 3 |> [-5.555555555555511e-2,0.11111111111111113,0.2777777777777776] Best regards, Alberto From t.h at gmx.info Wed Jul 23 05:04:02 2008 From: t.h at gmx.info (Timo B. =?utf-8?q?H=C3=BCbel?=) Date: Wed Jul 23 04:54:32 2008 Subject: [Haskell-cafe] ANN: Hayoo! beta 0.2 Message-ID: <200807231104.03210.t.h@gmx.info> Hello, we are pleased to announce the second beta release of Hayoo!, a Haskell API search engine providing advanced features like suggestions, find-as-you-type, fuzzy queries and much more. Visit Hayoo! here: http://holumbus.fh-wedel.de/hayoo The major change is the inclusion of all packages available on Hackage, i.e. the documentation of the latest versions of all packages is included in the index. Unfortunately we had to drop the direct links to the source code, as the documentation on Hackage is currently generated without source code. But as soon as this changes, we will include these links again. Additionally, we added some tweaks to the interface which make the browser history/the back button work (at least in Firefox). Please bear in mind that this is still a beta release and we are continuously working on further improvements. Any suggestions and feedback is highly welcomed. Cheers, Timo & Sebastian From gracjanpolak at gmail.com Wed Jul 23 05:20:39 2008 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Wed Jul 23 05:10:58 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> <7ca3f0160807220117q1f29bd4asc9af0109bfed8c86@mail.gmail.com> Message-ID: Chadda? Fouch? gmail.com> writes: > 2008/7/22 Luke Palmer gmail.com>: > > A little formal reasoning reveals that sequence1 = sequence2 exactly > > when (>>=) is strict in its left argument. There are four common > > monads which are _not_: Identity, Reader, Writer, State (and RWS by > > extension). > > Still if that makes that much of a difference, maybe we could envision > putting a sequence' in the library ? > Yes, in my experiments this is to be or not to be. Stack space is limited. Also processing time goes down by 800%, so it is a big deal sometimes. Incomplete list of functions affected: sequence mapM foldM Text.ParserCombinators.Parsec.Combinator(many1,sepBy,endBy,manyTill) Text.ParserCombinators.ReadP(many,many1,count,sepBy,endBy,manyTill) ... As far as I know sequence could be specialized to IO monad and use my transformation. How do I reason if >>= for parsers is lazy in its first argument? -- Gracjan From voigt at tcs.inf.tu-dresden.de Wed Jul 23 06:23:04 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Jul 23 06:05:22 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' In-Reply-To: References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> <7ca3f0160807220117q1f29bd4asc9af0109bfed8c86@mail.gmail.com> Message-ID: <48870688.4070406@tcs.inf.tu-dresden.de> Gracjan Polak wrote: > How do I reason if >>= for parsers is lazy in its first argument? Well, to quote from the abstract of the paper I already mentioned (http://citeseer.ist.psu.edu/704350.html): "By testing before proving we avoid wasting time trying to prove statements that are not valid." I think the library described in the paper, available here: http://www.cs.nott.ac.uk/~nad/software/#Chasing%20Bottoms has what you need. For example, you can check for isBottom, combine this with random test case generation, and thus should be able to quickly get an informed hypothesis about whether or not your >>= is lazy. For then proving that hypothesis, the paper (and probably other papers it cites) also provides some techniques that might be of use to you. Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From chaddai.fouche at gmail.com Wed Jul 23 09:20:58 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Wed Jul 23 09:10:58 2008 Subject: [Haskell-cafe] Newbie: Replacing substring? In-Reply-To: <62728db30807221338i73420728kf3d52c28bc7f3938@mail.gmail.com> References: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> <4885FF3C.4090007@di.unipi.it> <53396d9e0807220921o74630a51ub435420f37f21bf9@mail.gmail.com> <62728db30807221338i73420728kf3d52c28bc7f3938@mail.gmail.com> Message-ID: 2008/7/22 Ronald Guida : > 2008/7/22 Dmitri O.Kondratiev : >> On the side: The more I use Haskell - the more I like it ! It helps me think >> about the problem I solve much more clearly then when I use imperative >> language. > > If I want to replace a substring in a string, then I would search my > string left to right, looking for any occurrence of the substring. If > I find such an occurrence, I would replace it and continue searching > from immediately after the replacement. This algorithm can be > directly expressed in Haskell. More efficient algorithms do exist. Your idea but expressed in a more elegant fashion (maybe...) : replace :: (Eq a) => [a] -> [a] -> [a] -> [a] replace _ _ [] = [] replace old new xs@(y:ys) = case stripPrefix old xs of Nothing -> y : replace old new ys Just ys' -> new ++ replace old new ys' -- Jeda? From dokondr at gmail.com Wed Jul 23 09:33:20 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Wed Jul 23 09:23:22 2008 Subject: [Haskell-cafe] Newbie: Replacing substring? In-Reply-To: <53396d9e0807220921o74630a51ub435420f37f21bf9@mail.gmail.com> References: <53396d9e0807220726m27a652dcp339e918825586ae3@mail.gmail.com> <4885FF3C.4090007@di.unipi.it> <53396d9e0807220921o74630a51ub435420f37f21bf9@mail.gmail.com> Message-ID: <53396d9e0807230633h553d3a84hc61c92f0f877528a@mail.gmail.com> Ronald, Your algoritm is more simple and so it is better, I agree. My algorithm is different and consists of two steps: 1) Split source string into a list of chunks not containing substring to be replaced. 2) Concatenate chunks inserting new substring in between chuncks. With this approach I get a 'bonus' function of spliting string into chunks :) * Tue Jul 22 16:38:53 EDT 2008 **Ronald Guida* oddron at gmail.comwrote: * * If I want to replace a substring in a string, then I would search my string left to right, looking for any occurrence of the substring. If I find such an occurrence, I would replace it and continue searching from immediately after the replacement. This algorithm can be directly expressed in Haskell. More efficient algorithms do exist. replaceStr :: String -> String -> String -> String replaceStr [] old new = [] replaceStr str old new = loop str where loop [] = [] loop str = let (prefix, rest) = splitAt n str in if old == prefix -- found an occurrence? then new ++ loop rest -- yes: replace it else head str : loop (tail str) -- no: keep looking n = length old On Tue, Jul 22, 2008 at 8:21 PM, Dmitri O.Kondratiev wrote: > Roberto thanks! > Shame on me, to post code without enough testing :( > Yet, thanks to your comments *I think* I have found the bugs you wrote > about and now my code works, please see corrected version below. > Extra substring at the end was a result of using foldr with initial element > of []. I fixed this with foldl and first chunk as its initial element. > Incomplete substitution in case of duplicate elements in the pattern was a > bug in my 'takeOut' function that I have also fixed. > Stiil the problem that I have not yet designed solution for is when a > substring to replace extends from the end of a string to the next string. In > other words - first part of substring ends the first string and second part > of substring starts the second string. My algorithm currently does not > account for such a case. > > On the side: The more I use Haskell - the more I like it ! It helps me > think about the problem I solve much more clearly then when I use imperative > language. > > Corrected code: > > -- replace all occurances of "123" with "58" in a string: > test = replStr "abc123def123gh123ikl" "123" "58" > > {-- > In a string replace all occurances of an 'old' substring with a 'new' > substring > --} > replStr str old new = foldl ((\newSub before after -> before ++ newSub ++ > after) new) firstChunk otherChunks > where chunks = splitStr str old > firstChunk = head chunks > otherChunks = tail chunks > {-- > Split string into a list of chunks. > Chunks are substrings located in a string between 'sub' substrings > --} > splitStr str sub = mkChunkLst str sub [] > where > -- mkChunkLst 'src string' 'substr-to-extract' 'list of chunks' > -- makes list of chunks located between 'substr-to-extract' pieces in > src string > mkChunkLst [] _ chunkLst = chunkLst > mkChunkLst str sub chunkLst = mkChunkLst after sub (chunkLst ++ > [chunk]) > where > (chunk, _, after) = takeOut str sub [] [] > > {-- > Take out substring from a string. > String is divided into: > "before substr" ++ "match" ++ "after substr" > where 'match' is substring to split out > --} > > takeOut after [] before match = (before, match, after) > takeOut [] _ before match = (before, match, []) > takeOut (x:xs) (y:ys) before match > | x == y = takeOut xs ys before (match ++ [x]) > | otherwise = takeOut xs (y:ys) (before ++ [x]) [] > > > > > On Tue, Jul 22, 2008 at 7:39 PM, Roberto Zunino > wrote: > >> Dmitri O.Kondratiev wrote: >> >>> I wrote my own version, please criticize: >>> >>> -- replace all occurances of "123" with "58" in a string: >>> test = replStr "abc123def123gh123ikl" "123" "58" >>> >> >> This is a tricky problem: first of all, you fail your own test! ;-) >> >> *Main> test >> "abc58def58gh58ikl58" >> >> (Note the extra 58 at the end.) >> >> Other common pitfalls: >> >> *Main> replStr "abc1123def" "123" "58" >> "abc1158def58" >> >> (extra 1 ?) >> >> *Main> replStr "abc12123def" "123" "58" >> "abc121258def58" >> >> (extra 12 ?) >> >> A useful function from Data.List: stripPrefix >> >> (Of course, there are more efficient string match algorithms) >> >> Regards, >> Zun. >> > > > > -- > Dmitri O. Kondratiev > dokondr@gmail.com > http://www.geocities.com/dkondr > -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080723/d85887e6/attachment-0001.htm From darrinth at gmail.com Wed Jul 23 09:42:24 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Wed Jul 23 09:32:25 2008 Subject: [Haskell-cafe] BLAS Solve Example In-Reply-To: <4886CBDA.2060603@um.es> References: <4886CBDA.2060603@um.es> Message-ID: On Wed, Jul 23, 2008 at 2:12 AM, Alberto Ruiz wrote: > $ ghci solve.hs > *Main> sol > 3 |> [-5.555555555555511e-2,0.11111111111111113,0.2777777777777776] > I was hoping for rational solutions. If I were a true jedi master I'd write my own solver, which might be the right thing to do. All I know so far is gauss' method. Probably I'd learn something implementing the back substitution. hmm.... Thanks. -- Darrin From darrinth at gmail.com Wed Jul 23 10:17:44 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Wed Jul 23 10:07:44 2008 Subject: [Haskell-cafe] ANN: Hayoo! beta 0.2 In-Reply-To: <200807231104.03210.t.h@gmx.info> References: <200807231104.03210.t.h@gmx.info> Message-ID: On Wed, Jul 23, 2008 at 5:04 AM, Timo B. H?bel wrote: > Unfortunately we had to drop the direct links to the source code, as the > documentation on Hackage is currently generated without source code. But as > soon as this changes, we will include these links again. > Someone is working on hscolors for hackage? (Oh how hard that would rock.) -- Darrin From duncan.coutts at worc.ox.ac.uk Wed Jul 23 11:52:13 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 23 11:40:54 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC Message-ID: <1216828333.12754.30.camel@localhost> http://haskell.org/opensparc/ I am very pleased to announce a joint project between Sun Microsystems and the Haskell.org community to exploit the high performance capabilities of Sun's latest multi-core OpenSPARC systems via Haskell! http://opensparc.net/ Sun has donated a powerful 8 core SPARC Enterprise T5120 Server to the Haskell community, and $10,000 to fund a student, to further develop support for high performance Haskell on the SPARC. The aim of the project is to improve the SPARC native code generator in GHC and to demonstrate and improve the results of parallel Haskell benchmarks. The student will work with a mentor from Haskell.org and an adviser from Sun's SPARC compiler team. ** We are now inviting applications from students ** Please forward this announcement to any and all mailing lists where you think interested students might be lurking. Further details for students may be found below, and on the project website. Haskell and Multi-core Systems ------------------------------ The latest generation of multi-core machines pose a number of problems for traditional languages and parallel programming techniques. Haskell, in contrast, supports a wealth of approaches for writing correct parallel programs: traditional explicit threads and locks (forkIO and MVars), pure parallel evaluation strategies (par) and also Software Transactional Memory (STM). GHC has supported lightweight preemptable threads for a long time, and for the last couple of years it has been able to take advantage of machines with multiple CPUs or CPU cores. The GHC runtime has also recently gained a parallel garbage collector. OpenSPARC --------- We think the UltraSPARC T1/T2 architecture is a very interesting platform for Haskell. In particular the way that each core multiplexes many threads as a way of hiding memory latency. Memory latency is a performance bottleneck for Haskell code because the execution model uses a lot of memory indirections. Essentially, when one thread blocks due to a main memory read, the next thread is able to continue. This is in contrast to traditional architectures where the CPU core would stall until the result of the memory read was available. This approach can achieve high utilisation as long as there is enough parallelism available. The Project ----------- GHC is increasingly relying on its native code backend for high performance. Respectable single-threaded performance is a prerequisite for decent parallel performance. The first stage of the project therefore is to implement a new SPARC native code generator, taking advantage of the recent and ongoing infrastructure improvements in the C-- and native layers of the GHC backend. There is some existing support for SPARC in the native code generator but it has not kept up with changes in the GHC backend in the last few years. Once the code generator is working we will want to get a range of single threaded and parallel benchmarks running and look for various opportunities for improvement. There is plenty of ongoing work on the generic parts of the GHC backend and run-time system so the project will focus on SPARC-specific aspects. The UltraSPARC T1/T2 architecture supports very fast thread synchronisation (by taking advantage of the fact that all threads share the same L2 cache). We would like to optimise the synchronisation primitives in the GHC libraries and run-time system to take advantage of this. This should provide the basis for exploring whether the lower synchronisation costs make it advantageous to use more fine-grained parallelism. The Server ---------- The T5120 server has a T2 UltraSPARC processor with 8 cores running at 1.2GHz. Each core multiplexes 8 threads giving 64 hardware threads overall. It comes equipped with 32GB of memory. It also has two 146GB 10k RPM SAS disks. http://www.sun.com/servers/coolthreads/t5120/ http://www.sun.com/processors/UltraSPARC-T2/ This server is a donation to the whole Haskell community. We will make accounts available on the same basis as the existing community server as soon as is practical. Our friends at Chalmers University of Technology are kindly hosting the server on our behalf. We will encourage people to use the server for building, testing and benchmarking their Haskell software on SPARC, under both Solaris and Linux. Student applications -------------------- This is a challenging and exciting project and will need a high calibre student. Familiarity with Haskell is obviously important as is some experience with code generation for RISC instruction sets. The summer is now upon us so we do not expect students to be able to work 3 months all in one go. We are inviting students to suggest their own schedule when they apply. This may involve blocks of time in the next 9 months or so. It should add up to the equivalent of 3 months full time work. The application process is relatively informal. Students should send their application to: opensparc@community.haskell.org The deadline for applications in Friday 5th September 2008. If that deadline likely to be a problem for you then do get in touch. The application should detail skills and experience. Applications will be reviewed by a panel including the mentor, the adviser from Sun and a number of other Haskell.org community members who have helped with reviewing student projects in the past. The review will be partly interactive; students can expect to get questions and feedback from the reviewers. Students are welcome to contact myself or anyone else to help improve the quality of their application or if they have any questions. The $10k student funding will be paid in three phases, at the beginning ($3k), an intermediate point ($3k) and at the end ($4k). The exact timing will depend on the agreed schedule. The intermediate and final payments will be subject to positive reviews from the mentor. Duncan (project coordinator) From apfelmus at quantentunnel.de Wed Jul 23 11:53:57 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Jul 23 11:44:06 2008 Subject: [Haskell-cafe] Re: BLAS Solve Example In-Reply-To: References: <4886CBDA.2060603@um.es> Message-ID: Darrin Thompson wrote: > On Wed, Jul 23, 2008 at 2:12 AM, Alberto Ruiz wrote: >> $ ghci solve.hs >> *Main> sol >> 3 |> [-5.555555555555511e-2,0.11111111111111113,0.2777777777777776] >> > > I was hoping for rational solutions. If I were a true jedi master I'd > write my own solver, which might be the right thing to do. All I know > so far is gauss' method. Probably I'd learn something implementing the > back substitution. hmm.... The Hugs interpreter has a few nice Haskell demos, including a simple gauss elimination http://darcs.haskell.org/hugs98/demos/Matrix.hs Of course, this is unsuitable for serious floating point calculations. Regards, apfelmus From dons at galois.com Wed Jul 23 13:48:23 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 23 13:38:24 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' In-Reply-To: References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> <7ca3f0160807220117q1f29bd4asc9af0109bfed8c86@mail.gmail.com> Message-ID: <20080723174823.GA813@scytale.galois.com> gracjanpolak: > Chadda? Fouch? gmail.com> writes: > > 2008/7/22 Luke Palmer gmail.com>: > > > A little formal reasoning reveals that sequence1 = sequence2 exactly > > > when (>>=) is strict in its left argument. There are four common > > > monads which are _not_: Identity, Reader, Writer, State (and RWS by > > > extension). > > > > Still if that makes that much of a difference, maybe we could envision > > putting a sequence' in the library ? > > > > Yes, in my experiments this is to be or not to be. Stack space is limited. > Also processing time goes down by 800%, so it is a big deal sometimes. > > Incomplete list of functions affected: > > sequence > mapM > foldM > Text.ParserCombinators.Parsec.Combinator(many1,sepBy,endBy,manyTill) > Text.ParserCombinators.ReadP(many,many1,count,sepBy,endBy,manyTill) > ... > > As far as I know sequence could be specialized to IO monad and use my > transformation. > > How do I reason if >>= for parsers is lazy in its first argument? How about adding Control.Monad.Strict for the strict package? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/strict From coreyoconnor at gmail.com Wed Jul 23 14:10:05 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Wed Jul 23 14:00:05 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) Message-ID: I have the need to regularly write tiny programs that analyze output logs. The output logs don't have a consistent formatting so I typically choose Perl for these tasks. The latest instance of having to write such a program was simple enough I figured I'd try my hand at using Haskell instead. The short story is that I could quickly write a Haskell program that achieved the goal. Yay! However, the performance was ~8x slower than a comparable Perl implementation. With a lot of effort I got the Haskell version to only 2x slower. A lot of the optimization was done with guesses that the performance difference was due to how each line was being read from the file. I couldn't determine much using GHC's profiler. I still have two questions after all this: - Can I get a Haskell implementation as fast as the Perl? - What do I need to do to get GHC's profiler to provide me usable information? Telling me that 98% of the time was in "main" is not very enlightening ;-) All the code and data for this little experiment I've placed here: http://tothepowerofdisco.com/repo/sum_optimization/ My first, and shortest, version is SumTiny.hs. The optimized version is SumFast.hs. The long version for the curious: The (cleaned up) data was a 78k line file consisting of lines like the following: framerate (prev == no pts): 15 framerate (delta): 25 framerate (invalid timebase): 12.5 ... and so on. The need was for a program that calculated 1.0 / framerate for each line and produced the sum. Easy no? My straightforward Haskell solution was: ------------------------------------------------------------------- import Text.Regex.Posix main = do f_lines <- readFile "test.out" >>= return . lines let duration = foldl add_line 0.0 f_lines add_line sum line = let [[_,m]] = line =~ "([0-9.]+)" framerate = read m delta = 1.0 / framerate in sum + delta putStrLn $ "Duration (sec): " ++ show duration ------------------------------------------------------------------- Just for fun I decided to compare it to a Perl implementation: ------------------------------------------------------------------- #!/usr/bin/perl my @f_lines = split(/\n/,`cat test.out`); my $sum = 0.0; foreach(@f_lines) { /([0-9.]+)/; my $delta = 1.0 / $1; $sum += $delta; } print("Duration (sec): ", $sum, "\n"); ------------------------------------------------------------------- (I'm sure there are other ways to write this same program in both languages.) I was pretty happy with how the Haskell implementation's code compared to the Perl implementation's just in terms of looks. Though I think the Perl implementation is easier to understand at the part where the regex match is extracted. For fun I compared the performance of the two: (64bit linux running on a 2.4ghz Core2Duo) $ time perl ./Sum.pl Duration (sec): 3155.62666666438 real 0m0.121s user 0m0.103s sys 0m0.016s $ time ./SumTiny Duration (sec): 3155.626666664377 real 0m1.099s user 0m1.073s sys 0m0.009s Youch! ~1s is fast enough that I don't care, but I'm still curious why there is a 8x performance difference. Profiling with manual cost center annotations (See SumTinyProf.hs) indicated the "do" expression main is equal to was responsible 90% of the tiny. Which isn't revealing at all! Some experimenting led me to find a 2x slower implementation (SumFast.hs). Quick notes ont he changes I made: - Used ByteStrings instead of String. - Used hGetLine instead of reading the entire file lazily and splitting on "\n" - Fusing the foldl' with the loop of reading each line from the file. - Using bang patterns to make the fused loop strict on the accumulator argument. I think the largest performance gain was from changing how each line was read from the file. The lazy read and split seemed very slow compared to a loop that used hGetLine. -- -Corey O'Connor From dons at galois.com Wed Jul 23 14:18:49 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 23 14:08:54 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: References: Message-ID: <20080723181849.GC813@scytale.galois.com> coreyoconnor: > I have the need to regularly write tiny programs that analyze output > logs. The output logs don't have a consistent formatting so I > typically choose Perl for these tasks. > > The latest instance of having to write such a program was simple > enough I figured I'd try my hand at using Haskell instead. The short > story is that I could quickly write a Haskell program that achieved > the goal. Yay! However, the performance was ~8x slower than a > comparable Perl implementation. With a lot of effort I got the Haskell > version to only 2x slower. A lot of the optimization was done with > guesses that the performance difference was due to how each line was > being read from the file. I couldn't determine much using GHC's > profiler. > > I still have two questions after all this: > - Can I get a Haskell implementation as fast as the Perl? > - What do I need to do to get GHC's profiler to provide me usable > information? Telling me that 98% of the time was in "main" is not very > enlightening ;-) > > All the code and data for this little experiment I've placed here: > http://tothepowerofdisco.com/repo/sum_optimization/ > My first, and shortest, version is SumTiny.hs. The optimized version > is SumFast.hs. > > The long version for the curious: > > The (cleaned up) data was a 78k line file consisting of lines like the > following: > framerate (prev == no pts): 15 > framerate (delta): 25 > framerate (invalid timebase): 12.5 > ... and so on. > > The need was for a program that calculated 1.0 / framerate for each > line and produced the sum. Easy no? > > My straightforward Haskell solution was: > ------------------------------------------------------------------- > import Text.Regex.Posix > > main = do > f_lines <- readFile "test.out" >>= return . lines > let duration = foldl add_line 0.0 f_lines > add_line sum line = > let [[_,m]] = line =~ "([0-9.]+)" > framerate = read m > delta = 1.0 / framerate > in sum + delta > putStrLn $ "Duration (sec): " ++ show duration Could you try using lazy and/or strict bytestrings. For *any* IO performance issue, that should be your first stop. See, e.g., this sum-file example, http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=ghc&id=6 which outperforms C on the benchmark. The second point would be to avoid Text.Regex.Posix, which is algorithmically much worse than the PCRE regexes used by perl. Instead, try the pcre-light or regex-pcre packages, which have both better complexity, and operate on efficient bytestrings. Finally, there's some small details about writing efficient loops. Give type declarations for atomic types like Int and Double, and use strict folds or explicit recursion, as in this post, http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast For your task here, with those simple changes, it should be relatively easy to produce competitive-with-C performance. -- Don From coreyoconnor at gmail.com Wed Jul 23 14:26:51 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Wed Jul 23 14:16:51 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: <20080723181849.GC813@scytale.galois.com> References: <20080723181849.GC813@scytale.galois.com> Message-ID: Sounds great! Thanks for the advice. :-) -Corey On Wed, Jul 23, 2008 at 1:18 PM, Don Stewart wrote: > coreyoconnor: >> I have the need to regularly write tiny programs that analyze output >> logs. The output logs don't have a consistent formatting so I >> typically choose Perl for these tasks. >> >> The latest instance of having to write such a program was simple >> enough I figured I'd try my hand at using Haskell instead. The short >> story is that I could quickly write a Haskell program that achieved >> the goal. Yay! However, the performance was ~8x slower than a >> comparable Perl implementation. With a lot of effort I got the Haskell >> version to only 2x slower. A lot of the optimization was done with >> guesses that the performance difference was due to how each line was >> being read from the file. I couldn't determine much using GHC's >> profiler. >> >> I still have two questions after all this: >> - Can I get a Haskell implementation as fast as the Perl? >> - What do I need to do to get GHC's profiler to provide me usable >> information? Telling me that 98% of the time was in "main" is not very >> enlightening ;-) >> >> All the code and data for this little experiment I've placed here: >> http://tothepowerofdisco.com/repo/sum_optimization/ >> My first, and shortest, version is SumTiny.hs. The optimized version >> is SumFast.hs. >> >> The long version for the curious: >> >> The (cleaned up) data was a 78k line file consisting of lines like the >> following: >> framerate (prev == no pts): 15 >> framerate (delta): 25 >> framerate (invalid timebase): 12.5 >> ... and so on. >> >> The need was for a program that calculated 1.0 / framerate for each >> line and produced the sum. Easy no? >> >> My straightforward Haskell solution was: >> ------------------------------------------------------------------- >> import Text.Regex.Posix >> >> main = do >> f_lines <- readFile "test.out" >>= return . lines >> let duration = foldl add_line 0.0 f_lines >> add_line sum line = >> let [[_,m]] = line =~ "([0-9.]+)" >> framerate = read m >> delta = 1.0 / framerate >> in sum + delta >> putStrLn $ "Duration (sec): " ++ show duration > > Could you try using lazy and/or strict bytestrings. For *any* IO > performance issue, that should be your first stop. > > See, e.g., this sum-file example, > > http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=ghc&id=6 > > which outperforms C on the benchmark. > > The second point would be to avoid Text.Regex.Posix, which is > algorithmically much worse than the PCRE regexes used by perl. Instead, > try the pcre-light or regex-pcre packages, which have both better > complexity, and operate on efficient bytestrings. > > Finally, there's some small details about writing efficient loops. Give > type declarations for atomic types like Int and Double, and use strict > folds or explicit recursion, as in this post, > > http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast > > For your task here, with those simple changes, it should be relatively > easy to produce competitive-with-C performance. > > -- Don > -- -Corey O'Connor From marcot at riseup.net Wed Jul 23 14:50:33 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Wed Jul 23 14:40:07 2008 Subject: [Haskell-cafe] InterleavableIO Message-ID: <1216839033.3225.16.camel@quindinho.domain.invalid> Hello, I've done a package based on the Jules Bean's e-mail [1] to Haskell-Caf?, with a more generalized implementation. In the original version, you could use InterleavableIO with StateT Int IO (), but not with StateT Int (ReaderT Char IO) (). In this version, this is possible. The package, interleavableIO, is available at [2]. I've also done an application that generates a version of a module with generalized parameters, called interleavableGen, available at [3]. This is very alpha, and interleavableGen has been tested only with Control.Exception yet. Comments are very welcome. Greetings. [1]: http://www.haskell.org/pipermail/haskell-cafe/2007-July/028501.html [2]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/interleavableIO-0.0.1 [3]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/interleavableGen-0.0.1 -- ?Marco T?lio Gontijo e Silva P?gina: http://marcotmarcot.googlepages.com/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From dons at galois.com Wed Jul 23 15:01:24 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 23 14:51:26 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: References: Message-ID: <20080723190124.GD813@scytale.galois.com> coreyoconnor: > I have the need to regularly write tiny programs that analyze output > logs. The output logs don't have a consistent formatting so I > typically choose Perl for these tasks. > > The latest instance of having to write such a program was simple > enough I figured I'd try my hand at using Haskell instead. The short > story is that I could quickly write a Haskell program that achieved > the goal. Yay! However, the performance was ~8x slower than a > comparable Perl implementation. With a lot of effort I got the Haskell > version to only 2x slower. A lot of the optimization was done with > guesses that the performance difference was due to how each line was > being read from the file. I couldn't determine much using GHC's > profiler. {-# OPTIONS -fbang-patterns #-} import qualified Data.ByteString.Char8 as S import Data.ByteString.Lex.Double import Debug.Trace main = print . go 0 =<< S.getContents where go !n !s = case readDouble str of Nothing -> n Just (k,t) -> let delta = 1.0 / k in go (n+delta) t where (_, xs) = S.break ((==) ':') s str = S.drop 2 xs It uses the bytestring-lexing package on Hackage to read the Doubles out, $ ghc --make Fast.hs -O2 -fvia-C -optc-O2 $ time ./Fast < test.out 3155.626666664377 ./Fast < test.out 0.07s user 0.01s system 97% cpu 0.078 total So that's twice as fast as the perl entry on my box, $ time perl Sum.pl < test.out Duration (sec): 3155.62666666438 perl Sum.pl < test.out 0.15s user 0.03s system 100% cpu 0.180 total Note that the safe Double lexer uses a bit of copying, so we can in fact do better still with a non-copying Double parser, but that's only for the hardcore. -- Don From jgbailey at gmail.com Wed Jul 23 15:23:48 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Wed Jul 23 15:13:47 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: References: Message-ID: On Wed, Jul 23, 2008 at 11:10 AM, Corey O'Connor wrote: > I still have two questions after all this: > - Can I get a Haskell implementation as fast as the Perl? > - What do I need to do to get GHC's profiler to provide me usable > information? Telling me that 98% of the time was in "main" is not very > enlightening ;-) Don did a great job answering teh first question. To get better profiling information, add "SCC" annotations to your code. That will tell you how much time is spent in a particular expression. For your main function, take a divide and conquer approach - add SCCs to determine what is taking the most time. Take Don's advice first though before benchmarking - you probably won't care after switching to bytestring & a better regex engine. Justin From greenspan.levi at googlemail.com Wed Jul 23 15:28:32 2008 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Wed Jul 23 15:18:38 2008 Subject: [Haskell-cafe] Libevent FFI problems Message-ID: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> Dear list members, This is my first attempt to create a FFI to libevent (http://monkey.org/~provos/libevent/) which is an event notification library. A simple usage example is for instance given here: http://unx.ca/log/libevent_echosrv1c/ . In C one basically creates struct event instances which are initialized with a callback function and the kind of event (e.g. read) one is intested in. Optionally a data argument can be given which will be passed to the callback function when invoked eventually. An event dispatcher loop will invoke the callback when the event occurs. I have attached my first attempt at a FFI to libevent. However it doesn't work correctly. In the client code I want to pass 99 as data to the callback function, but what is printed out is 0. I guess there is an issue with pointer derefencing, but I don't know. Also I am not sure how to handle the FunPtr deallocation. Since the FunPtr is stored in the foreign event structure I don't know when I can free it. I would be grateful for any advices, hints or comments. And I really look forward to the FFI section in the "Real World Haskell" book. Thank you very much. - Levi -------------- next part -------------- A non-text attachment was scrubbed... Name: hsevent.hsc Type: application/octet-stream Size: 3708 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080723/7fd47e30/hsevent.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: main.hs Type: text/x-haskell Size: 1188 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080723/7fd47e30/main.bin From brad.larsen at gmail.com Wed Jul 23 15:37:00 2008 From: brad.larsen at gmail.com (Brad Larsen) Date: Wed Jul 23 15:27:00 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: <20080723190124.GD813@scytale.galois.com> References: <20080723190124.GD813@scytale.galois.com> Message-ID: And against gawk 3.1.5: $ time awk -F: '{sum += 1 / $2} END{print sum}' test.out 3155.63 real 0m0.197s user 0m0.184s sys 0m0.004s compared to Don's Haskell version: $ time ./fastSum < test.out 3155.626666664377 real 0m0.072s user 0m0.056s sys 0m0.004s compared to the Corey's perl version: $ time perl Sum.pl Duration (sec): 3155.62666666438 real 0m0.181s user 0m0.164s sys 0m0.012s Regards, Brad Larsen On Wed, 23 Jul 2008 15:01:24 -0400, Don Stewart wrote: > coreyoconnor: >> I have the need to regularly write tiny programs that analyze output >> logs. The output logs don't have a consistent formatting so I >> typically choose Perl for these tasks. >> >> The latest instance of having to write such a program was simple >> enough I figured I'd try my hand at using Haskell instead. The short >> story is that I could quickly write a Haskell program that achieved >> the goal. Yay! However, the performance was ~8x slower than a >> comparable Perl implementation. With a lot of effort I got the Haskell >> version to only 2x slower. A lot of the optimization was done with >> guesses that the performance difference was due to how each line was >> being read from the file. I couldn't determine much using GHC's >> profiler. > > {-# OPTIONS -fbang-patterns #-} > > import qualified Data.ByteString.Char8 as S > import Data.ByteString.Lex.Double > import Debug.Trace > > main = print . go 0 =<< S.getContents > where > go !n !s = case readDouble str of > Nothing -> n > Just (k,t) -> let delta = 1.0 / k in go (n+delta) t > where > (_, xs) = S.break ((==) ':') s > str = S.drop 2 xs > > It uses the bytestring-lexing package on Hackage to read the Doubles > out, > > $ ghc --make Fast.hs -O2 -fvia-C -optc-O2 > $ time ./Fast < test.out > 3155.626666664377 > ./Fast < test.out 0.07s user 0.01s system 97% cpu 0.078 total > > So that's twice as fast as the perl entry on my box, > > $ time perl Sum.pl < test.out > Duration (sec): 3155.62666666438 > perl Sum.pl < test.out 0.15s user 0.03s system 100% cpu 0.180 total > > Note that the safe Double lexer uses a bit of copying, so > we can in fact do better still with a non-copying Double parser, > but that's only for the hardcore. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From coreyoconnor at gmail.com Wed Jul 23 15:37:08 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Wed Jul 23 15:27:19 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: References: Message-ID: On Wed, Jul 23, 2008 at 2:23 PM, Justin Bailey wrote: > On Wed, Jul 23, 2008 at 11:10 AM, Corey O'Connor wrote: >> I still have two questions after all this: >> - Can I get a Haskell implementation as fast as the Perl? >> - What do I need to do to get GHC's profiler to provide me usable >> information? Telling me that 98% of the time was in "main" is not very >> enlightening ;-) > > Don did a great job answering teh first question. To get better > profiling information, add "SCC" annotations to your code. That will > tell you how much time is spent in a particular expression. For your > main function, take a divide and conquer approach - add SCCs to > determine what is taking the most time. I did write a version of SumTiny.hs with SCC annotations: http://tothepowerofdisco.com/repo/sum_optimization/SumTinyProf.hs Maybe I'm missing something, but the profiling still gives me poor results. Here is the results from the profiler (cut down and, no doubt, with poor post-email formatting): ------------------------------------------------------------------- COST CENTRE %time %alloc do 92.8 87.6 regex 2.8 4.8 add_line 2.2 0.4 div 1.1 0.3 readFile 0.6 6.2 individual inherited COST CENTRE %time %alloc %time %alloc MAIN CAF 0.0 0.0 100.0 100.0 main 0.0 0.0 100.0 100.0 do 92.8 87.6 100.0 100.0 show 0.0 0.0 0.0 0.0 foldl 0.0 0.3 0.0 0.3 add_line 2.2 0.4 6.6 5.9 regex 2.8 4.8 2.8 4.8 sum 0.0 0.1 0.0 0.1 div 1.1 0.3 1.1 0.3 read Double 0.6 0.2 0.6 0.2 readFile 0.6 6.2 0.6 6.2 ------------------------------------------------------------------- Which tells me the "do" expression that main is equal to is responsible for 92.8% of the run time. Which really doesn't tell me anything. -- -Corey O'Connor From eeoam at ukfsn.org Wed Jul 23 16:05:39 2008 From: eeoam at ukfsn.org (Eric) Date: Wed Jul 23 15:56:10 2008 Subject: [Haskell-cafe] Literate program implementing text editor Message-ID: <48878F13.4050306@ukfsn.org> Hi all, I wanted to embark on a Haskell program that implements a simple text editor. Before doing so, however, I thought that I should ask: Does anyone know of a literate Haskell program already in existence that does the job? Eric M. From byorgey at seas.upenn.edu Wed Jul 23 16:13:45 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jul 23 16:03:43 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 78 - July 23, 2008 Message-ID: <20080723201344.GA29302@minus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080723 Issue 78 - July 23, 2008 --------------------------------------------------------------------------- Welcome to issue 78 of HWN, a newsletter covering developments in the [1]Haskell community. Issue 78: In Which Michi and Neil Become Doctors, Sun Donates Some Sweet Loot, and Jules Is Revealed To Be A Helpful Anthropomorphic Robot Community News Congratulations are in order this week to two members of the community who have completed PhDs. Neil Mitchell (ndm) passed his PhD viva last week, subject to minor corrections. Mikael Johansson (Syzygy-) [2]has also completed his PhD and will soon be starting a postdoc at Stanford with the topology in computer science working group. Congratulations, Drs. Mitchell and Johansson! Announcements rosezipper. Eric Kow (kowey) [3]announced the release of [4]rosezipper, Krasimir Angelov and Iavor S. Diatchki's Data.Tree implementation of zippers. list-extras 0.1.0. wren ng thornton (koninkje) [5]announced the initial release of [6]list-extras, a home for common not-so-common list functions. Sun Microsystems and Haskell.org joint project on OpenSPARC. Duncan Coutts (dcoutts) [7]announced a [8]joint project between Sun Microsystems and the Haskell.org community to exploit the high performance capabilities of Sun's latest multi-core [9]OpenSPARC systems via Haskell! Sun has donated a powerful 8 core SPARC Enterprise T5120 Server to the Haskell community, and $10,000 to fund a student to further develop support for high performance Haskell on the SPARC. The student will work with a mentor from Haskell.org and an adviser from Sun's SPARC compiler team. If you're a student and this sounds interesting to you, send in those applications!! Hayoo! beta 0.2. Timo B. [10]announced the second beta release of [11]Hayoo!, a Haskell API search engine providing advanced features like suggestions, find-as-you-type, fuzzy queries and much more. The major change in this release is the inclusion of all packages available on Hackage in the index. Haskell-beginners mailing list. Benjamin L. Russell [12]announced the creation of the [13]Haskell-Beginners Mailing List, beginners at haskell.org, devoted to discussion of primarily beginner-level topics related to Haskell. It's already off to a great start, so if you're a Haskell beginner, or someone interested in answering beginner questions, please subscribe! Haskeline 0.2. Judah Jacobson [14]announced the initial (alpha-ish) release of [15]Haskeline, a library for line input in command-line programs. It is similar in purpose to editline or readline, but is written in Haskell and thus (hopefully) more easily used in other Haskell programs. Google Summer of Code Progress updates from participants in the 2008 [16]Google Summer of Code. Generic tries. Jamie Brandon is working on a library for efficient maps using generalized tries. [17]This week, he ran QuickCheck on his test suite for the first time, and found a large number of failing tests! He's got his work cut out for him straightening those out over the next few days. DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a [18]physics engine using [19]Data Parallel Haskell. [20]This week, he implemented full handling of rigid body collisions, including angular velocity. Next he plans to explore various ways to make the engine faster, including broad-phase collision detection. GHC plugins. Max Bolingbroke is working on dynamically loaded plugins for GHC. [21]This week, he revealed his "mystery project": an HTML pretty-printer for GHC core! [22]Here is a sample. Now his focus turns to tidying things up and solidifying documentation in preparation for getting his patches merged into GHC HEAD. Hoogle 4. Neil Mitchell (ndm) is working on [23]Hoogle 4. [24]This week, he fleshed out the final part of type search, including support for instances and alpha renaming of variables. Unfortunately, it uses too much memory to be feasibly run on the base libraries! Neil has some ideas on how to fix this, however, which he plans to tackle next week. Language.C. Benedikt Huber (visq) is [25]working on Language.C, a standalone parser/pretty printer library for C99. He has finally completed a working implementation for analysing declarations and definitions, and [26]presents a working example of the library's use. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a [27]make-like dependency analysis framework for Cabal. GHC API. Thomas Schilling (nominolo) is working on [28]improvements to the GHC API. Libraries Proposals and extensions to the [29]standard libraries. generalize mapAccumL/R. Ross Paterson [30]proposed adding generalized versions of mapAccumL and mapAccumR to Data.Traversable. signal-handling API. Simon Marlow [31]proposed a [32]new signal-handling API. Discussion Point-free style in guards. L29Ah [33]asked a question about using a points-free style in guard expressions, leading to a number of clever suggestions involving custom combinators. Optimizing sequence. Gracjan Polak started a [34]discussion on the strictness properties of the sequence function, and its implications for optimization. It sounds as though adding an alternate strict version of sequence to the libraries could be a good idea. Blog noise [35]Haskell news from the [36]blogosphere. * Eric Kow (kowey): [37]rose zipper on hackage. Eric has uploaded an implementation of a zipper for Data.Tree to hackage. * Jamie Brandon: [38]QuickCheck strikes again. An update on Jamie's Google Summer of Code project. Lots of failing QuickCheck tests mean Jamie has his work cut out for him. * >>> Ayumilove: [39]Haskell Programming Tutorial Part 1. A video introduction to Haskell? * Roman Cheplyaka (Feuerbach): [40]Status report: week 7-8. An update on Roman's Google Summer of Code project. * Conal Elliott (conal): [41]Designing for the future. * Benedikt Huber (visq): [42]Language.C: Analysing Definitions. An update on Benedikt's Google Summer of Code project. * Max Bolingbroke: [43]Compiler Plugins For GHC: Week Six. An update on Max's Google Summer of Code project. * Arnar Birgisson (Arnar): [44]Playing with Haskell's lazy lists. Arnar implements Eric Rowland's [45]simple prime-generating recurrence using lazy lists in Haskell. * Neil Mitchell (ndm): [46]GSoC Hoogle: Week 8. An update on Neil's Google Summer of Code project. * Matthew Sackman: [47]What is the point?. Matthew had his submission rejected from the Haskell Symposium, and isn't happy about it. * Tupil: [48]Stemming with Haskell reloaded. An updated, more functional/Haskellish interface to the stemmer library. * Luke Palmer (luqui): [49]Semantic Design. Luke's reflections on a design approach learned from Conal Elliott. * Muad`Dib (vixey): [50]Rascal - Mini-haskell like language. * Jeremy Shaw: [51]HTML Templating in HAppS using HSP. Jeremy writes a very cool introduction/tutorial to using HSP (Haskell Server Pages) with HAppS. * >>> Duane Johnson: [52]Lazy Evaluation at Work. Duane likes the idea of lazy file I/O. * >>> Duane Johnson: [53]A Glimmer of Monadic Hope. Duane figures out do-notation. * >>> Duane Johnson: [54]Using 'foldr' in Haskell. Duane figures out how to define (++) and concat in terms of foldr. * Mikael Johansson (Syzygy-): [55]Dr rer nat, Magna cum laude. * >>> Holden Karau: [56]Integrating your HUnit (or other) tests into your cabal package. * Real-World Haskell: [57]Beta availability hiccups. * >>> Antoine Hersen: [58]ICFP 2008 Postmortem. * Edward Kmett (edwardk): [59]A Sort of Difference. Edward uses an analysis of quicksort in Haskell as a jumping-off point for an introduction to difference lists. * Ralf Lammel: [60]The Expression Lemma -- Explained. Ralf explains the relationship between OOP and FP. * >>> Greg McClure: [61]Learning languages through problem-solving. Greg extols the virtues of [62]Project Euler for learning new languages, and exhibits a solution to the first problem in Haskell, Erlang, and Python. Quotes of the Week * kryptiskt: my point is that our brain isn't some logic machine, it's a jury-rigged contraption to help us get food, friends and sex. It's the Perl of intelligences. * Fallacy: peyton `simon` jones * Quadrescence: [on #haskell] Well, the nice population here attracts people. Unlike other pla_C_es. How'd those underscores get there? * mauke: hmm, regexes get even more cryptic after z-encoding: ZLz3fUZCZLz3fUzlznzrwZRZLz3fUzezrwZRzbZLz3fUzlzezrwZRZLz3fUznzrwZRZR * BMeph: Haskell: Where even the newest newcomer acts monadically: join :: ask (ask something) -> ask something * Quadrescence: quicksilver: You must be an anthropomorphic robot or something. About the Haskell Weekly News New editions are posted to [63]the Haskell mailing list as well as to [64]the Haskell Sequence and [65]Planet Haskell. [66]RSS is also available, and headlines appear on [67]haskell.org. Headlines are available as [68]PDF. To help create new editions of this newsletter, please see the information on [69]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [70]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://blog.mikael.johanssons.org/archive/2008/07/dr-rer-nat-magna-cum-laude/ 3. http://koweycode.blogspot.com/2008/07/rose-zipper-on-hackage.html 4. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rosezipper 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42485 6. http://code.haskell.org/~wren/ 7. http://article.gmane.org/gmane.comp.lang.haskell.general/16351 8. http://haskell.org/opensparc/ 9. http://opensparc.net/ 10. http://article.gmane.org/gmane.comp.lang.haskell.general/16349 11. http://holumbus.fh-wedel.de/hayoo 12. http://article.gmane.org/gmane.comp.lang.haskell.general/16345 13. http://www.haskell.org/mailman/listinfo/beginners 14. http://article.gmane.org/gmane.comp.lang.haskell.general/16343 15. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskeline 16. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 17. http://jamiiecb.blogspot.com/2008/07/quickcheck-strikes-again.html 18. http://haskell.org/haskellwiki/Hpysics 19. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 20. http://physics-dph.blogspot.com/2008/07/status-report-week-7-8.html 21. http://blog.omega-prime.co.uk/2008/07/21/compiler-plugins-for-ghc-week-six/ 22. http://www.omega-prime.co.uk/files/GHC-Core-HTML.html 23. http://code.haskell.org/hoogle/ 24. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-8.html 25. http://www.sivity.net/projects/language.c/wiki/ 26. http://hsbene.blogspot.com/2008/07/languagec-analysing-definitions.html 27. http://code.haskell.org/~Saizan/cabal 28. http://hackage.haskell.org/trac/ghc/wiki/GhcApiStatus 29. http://haskell.org/haskellwiki/Library_submissions 30. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9649 31. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9599 32. http://hackage.haskell.org/trac/ghc/ticket/2451 33. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42475 34. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42453 35. http://planet.haskell.org/ 36. http://haskell.org/haskellwiki/Blog_articles 37. http://koweycode.blogspot.com/2008/07/rose-zipper-on-hackage.html 38. http://jamiiecb.blogspot.com/2008/07/quickcheck-strikes-again.html 39. http://www.5min.com/Video/Ayumilove-Haskell-Programming-Tutorial-Part-1-31180892 40. http://physics-dph.blogspot.com/2008/07/status-report-week-7-8.html 41. http://feeds.feedburner.com/~r/conal/~3/342784118/ 42. http://hsbene.blogspot.com/2008/07/languagec-analysing-definitions.html 43. http://blog.omega-prime.co.uk/2008/07/21/compiler-plugins-for-ghc-week-six/ 44. http://www.hvergi.net/2008/07/playing-with-haskells-lazy-lists/ 45. http://recursed.blogspot.com/2008/07/rutgers-graduate-student-finds-new.html 46. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-8.html 47. http://www.wellquite.org/what_is_the_point.html 48. http://blog.tupil.com/stemming-with-haskell-reloaded/ 49. http://luqui.org/blog/archives/2008/07/18/semantic-design/ 50. http://muaddibspace.blogspot.com/2008/07/rascal-mini-haskell-like-language.html 51. http://nhlab.blogspot.com/2008/07/html-templating-in-happs-using-hsp.html 52. http://blog.inquirylabs.com/2008/07/18/lazy-evaluation-at-work/ 53. http://blog.inquirylabs.com/2008/07/17/a-glimmer-of-monadic-hope/ 54. http://blog.inquirylabs.com/2008/07/17/using-foldr-in-haskell/ 55. http://blog.mikael.johanssons.org/archive/2008/07/dr-rer-nat-magna-cum-laude/ 56. http://feeds.feedburner.com/~r/holdenkarau/iYtm/~3/337908379/integrating-your-hunit-or-other-tests.html 57. http://www.realworldhaskell.org/blog/2008/07/16/beta-availability-hiccups/ 58. http://endymion2021.livejournal.com/17117.html 59. http://comonad.com/reader/2008/a-sort-of-difference/ 60. http://blogs.msdn.com/ralflammel/archive/2008/07/16/the-expression-lemma-explained.aspx 61. http://www.codechops.com/?p=15 62. http://www.projecteuler.net/ 63. http://www.haskell.org/mailman/listinfo/haskell 64. http://sequence.complete.org/ 65. http://planet.haskell.org/ 66. http://sequence.complete.org/node/feed 67. http://haskell.org/ 68. http://code.haskell.org/~byorgey/code/hwn/archives/20080723.pdf 69. http://haskell.org/haskellwiki/HWN 70. http://code.haskell.org/~byorgey/code/hwn/ From andrewcoppin at btinternet.com Wed Jul 23 14:45:56 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jul 23 16:04:21 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour Message-ID: <48877C64.6060809@btinternet.com> A while back I found a page somewhere containing some rather amusing IRC quotes. Unfortunately it seems to have vanished. I can't remember where on earth I found it, but I've scoured the Internet trying to track it down. (In particular, it contained a quote of somebody impersonating a typical Haskell newbie - lots of enthusiasm and no attention span! Well it amused *me* anyway...) Anybody have any ideas where this has gone? Also... the current Humour page on the Haskell wiki contains a link to Lambdabot's quotes database, but on my system, clicking this link just displays a few hundred pages of gibberish. Is this normal? As I final note... http://www.haskell.org/haskellwiki/Humor/Goldilocks Damn, I wish *I* thought of that! ;-) From andrewcoppin at btinternet.com Wed Jul 23 15:52:45 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jul 23 16:04:28 2008 Subject: [Haskell-cafe] Re: Optimizing 'sequence' In-Reply-To: <48858FE4.6040607@tcs.inf.tu-dresden.de> References: <694519c50807211220k40093967y86a81b09d62876d2@mail.gmail.com> <48858FE4.6040607@tcs.inf.tu-dresden.de> Message-ID: <48878C0D.5020904@btinternet.com> Janis Voigtlaender wrote: > How about some QuickChecking in connection with the "Chasing bottoms" > library (http://citeseer.ist.psu.edu/704350.html)? Ah, finally a reference to what this curios phrase is actually about...! From list at phaedrusdeinus.org Wed Jul 23 16:29:31 2008 From: list at phaedrusdeinus.org (John Melesky) Date: Wed Jul 23 16:19:40 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <48877C64.6060809@btinternet.com> References: <48877C64.6060809@btinternet.com> Message-ID: <869669B2-B3EE-4790-B2C5-ADDC82BC988D@phaedrusdeinus.org> On Jul 23, 2008, at 1:45 PM, Andrew Coppin wrote: > A while back I found a page somewhere containing some rather amusing > IRC quotes. Are you perhaps thinking of the "Quotes of the Week" section in the Haskell Weekly News? Back issues seem to be at http://sequence.complete.org/hwn if you want to check. -johnnnnnn From miguelimo38 at yandex.ru Wed Jul 23 16:35:43 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Jul 23 16:25:51 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <48877C64.6060809@btinternet.com> References: <48877C64.6060809@btinternet.com> Message-ID: <1417EFF2-C179-4E10-815B-EA29AEDED26C@yandex.ru> > Also... the current Humour page on the Haskell wiki contains a link > to Lambdabot's quotes database, but on my system, clicking this link > just displays a few hundred pages of gibberish. Is this normal? Of course it's not. But deciphering is very simple, it's named "gunzip". From simonpj at microsoft.com Wed Jul 23 16:47:00 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Jul 23 16:37:01 2008 Subject: [Haskell-cafe] Re: Profiling nested case In-Reply-To: <2f9b2d30807210036j45a7f79eie87c80e04c1b19ea@mail.gmail.com> References: <2f9b2d30807210036j45a7f79eie87c80e04c1b19ea@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE762AE67@EA-EXMSG-C334.europe.corp.microsoft.com> | I had similar experiences as you when attempting to write "high | performance Haskell"; the language makes you want to use high-level | abstracted functions but the optimizer (while amazing, to be honest) | seems to miss a few cases that it seems like it should hit. Ryan, if you find any of these, do please submit them to GHC's Trac bug-tracker. There's a special category for performance bugs. Small programs of the form "GHC should hit this, but doesn't" are incredibly useful. Thanks Simon From simonpj at microsoft.com Wed Jul 23 16:47:06 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Jul 23 16:37:16 2008 Subject: [Haskell-cafe] Re: Aren't type system extensions fun? [Further analysis] In-Reply-To: <483DAC79.9070604@btinternet.com> References: <483B254E.1040709@btinternet.com> <483B2D07.4050001@btinternet.com> <483C4AF6.7000705@btinternet.com> <483D3AE2.2070003@di.unipi.it> <483DAC79.9070604@btinternet.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE762AE68@EA-EXMSG-C334.europe.corp.microsoft.com> Andrew writes | I have complete confidence that whoever wrote the GHC manual knew | exactly what they meant. I am also fairly confident that this was the | same person who implemented and even designed this particular feature. | And that they probably have an advanced degree in type system theory. I, | however, do not. So if in future the GHC manual could explain this in | less opaque language, that would be most appreciated. :-} As the person who wrote the offending section of the GHC user manual (albeit lacking a qualification of any sort in type theory), I am painfully aware of its shortcomings. Much of the manual is imprecise, and explains things only by examples. The wonder is that it apparently serves the purpose for many people. Nevertheless, the fact is that it didn't do the job for Andrew, at least not first time around. After some useful replies to his email, he wrote | Thank you for coming up with a clear and comprehensible answer. I would very much welcome anyone who felt able to improve on the text in the manual, even if it's only a paragraph or two. If you stub your toe on the manual, once you find the solution, take a few minutes to write the words you wish you had read to begin with, and send them to me. Meanwhile, Andrew, I recommend the paper "Practical type inference for arbitrary rank types", which is, compared to the user manual at least, rather carefully written. Simon From andrewcoppin at btinternet.com Wed Jul 23 16:45:45 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jul 23 16:41:04 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <1417EFF2-C179-4E10-815B-EA29AEDED26C@yandex.ru> References: <48877C64.6060809@btinternet.com> <1417EFF2-C179-4E10-815B-EA29AEDED26C@yandex.ru> Message-ID: <48879879.5090509@btinternet.com> Miguel Mitrofanov wrote: >> Also... the current Humour page on the Haskell wiki contains a link >> to Lambdabot's quotes database, but on my system, clicking this link >> just displays a few hundred pages of gibberish. Is this normal? > > Of course it's not. But deciphering is very simple, it's named "gunzip". Right... so why does it have the MIME type "text/plain"? o_O (Also... how do you know it's ZIP, and not, say, gzip, bz2, RAR, LHA...? I can't see anything that looks like an identifying header in there.) From jeremy at n-heptane.com Wed Jul 23 16:57:37 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Jul 23 16:44:21 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <48877C64.6060809@btinternet.com> References: <48877C64.6060809@btinternet.com> Message-ID: <874p6g8gji.wl%jeremy@n-heptane.com> At Wed, 23 Jul 2008 19:45:56 +0100, Andrew Coppin wrote: > > A while back I found a page somewhere containing some rather amusing IRC > quotes. Unfortunately it seems to have vanished. I can't remember where > on earth I found it, but I've scoured the Internet trying to track it > down. (In particular, it contained a quote of somebody impersonating a > typical Haskell newbie - lots of enthusiasm and no attention span! Well > it amused *me* anyway...) Anybody have any ideas where this has gone? http://web.archive.org/web/20070609061216/http://www.haskell.org/hawiki/QuotesPage j. From dons at galois.com Wed Jul 23 17:00:12 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 23 16:50:14 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: References: <20080723190124.GD813@scytale.galois.com> Message-ID: <20080723210012.GE813@scytale.galois.com> brad.larsen: > And against gawk 3.1.5: > > $ time awk -F: '{sum += 1 / $2} END{print sum}' test.out > 3155.63 > > real 0m0.197s > user 0m0.184s > sys 0m0.004s > > compared to Don's Haskell version: > > $ time ./fastSum < test.out > 3155.626666664377 > > real 0m0.072s > user 0m0.056s > sys 0m0.004s > > compared to the Corey's perl version: > > $ time perl Sum.pl > Duration (sec): 3155.62666666438 > > real 0m0.181s > user 0m0.164s > sys 0m0.012s > Another variant, using a non-copying readDouble (available in bytestring-lexing package 0.1.2), {-# OPTIONS -fbang-patterns #-} import qualified Data.ByteString.Char8 as S import qualified Data.ByteString.Unsafe as S import Data.ByteString.Lex.Double main = print . go 0 =<< S.getContents where go :: Double -> S.ByteString -> Double go !n !s = case unsafeReadDouble s' of Nothing -> n Just (k,t) -> let delta = 1 / k in go (n+delta) t where s' = case S.elemIndex ':' s of Nothing -> S.empty Just i -> S.unsafeDrop (i+2) s Computes in: $ time ./Fast < test.out 3155.626666664377 ./Fast < test.out 0.02s user 0.00s system 80% cpu 0.025 total So that's probably a good place to stop. Note the general rules: * strict bytestrings * tight tail-recursive loops with strict, atomic accumulators * non-copying parsing. -- Don From jefferson.r.heard at gmail.com Wed Jul 23 17:00:50 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Wed Jul 23 16:50:49 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <48877C64.6060809@btinternet.com> References: <48877C64.6060809@btinternet.com> Message-ID: <4165d3a70807231400m619cb592i153efcbb43d39ac8@mail.gmail.com> http://bash.org ? On Wed, Jul 23, 2008 at 2:45 PM, Andrew Coppin wrote: > A while back I found a page somewhere containing some rather amusing IRC > quotes. Unfortunately it seems to have vanished. I can't remember where on > earth I found it, but I've scoured the Internet trying to track it down. (In > particular, it contained a quote of somebody impersonating a typical Haskell > newbie - lots of enthusiasm and no attention span! Well it amused *me* > anyway...) Anybody have any ideas where this has gone? > > Also... the current Humour page on the Haskell wiki contains a link to > Lambdabot's quotes database, but on my system, clicking this link just > displays a few hundred pages of gibberish. Is this normal? > > As I final note... > http://www.haskell.org/haskellwiki/Humor/Goldilocks > Damn, I wish *I* thought of that! ;-) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From andrewcoppin at btinternet.com Wed Jul 23 17:09:08 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jul 23 17:00:36 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <874p6g8gji.wl%jeremy@n-heptane.com> References: <48877C64.6060809@btinternet.com> <874p6g8gji.wl%jeremy@n-heptane.com> Message-ID: <48879DF4.3090104@btinternet.com> Jeremy Shaw wrote: > At Wed, 23 Jul 2008 19:45:56 +0100, > Andrew Coppin wrote: > >> A while back I found a page somewhere containing some rather amusing IRC >> quotes. Unfortunately it seems to have vanished. I can't remember where >> on earth I found it, but I've scoured the Internet trying to track it >> down. (In particular, it contained a quote of somebody impersonating a >> typical Haskell newbie - lots of enthusiasm and no attention span! Well >> it amused *me* anyway...) Anybody have any ideas where this has gone? >> > > http://web.archive.org/web/20070609061216/http://www.haskell.org/hawiki/QuotesPage > LOL! Thanks, that's the one... From miguelimo38 at yandex.ru Wed Jul 23 17:12:57 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Jul 23 17:03:05 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <48879879.5090509@btinternet.com> References: <48877C64.6060809@btinternet.com> <1417EFF2-C179-4E10-815B-EA29AEDED26C@yandex.ru> <48879879.5090509@btinternet.com> Message-ID: On 24 Jul 2008, at 00:45, Andrew Coppin wrote: > Miguel Mitrofanov wrote: >>> Also... the current Humour page on the Haskell wiki contains a >>> link to Lambdabot's quotes database, but on my system, clicking >>> this link just displays a few hundred pages of gibberish. Is this >>> normal? >> >> Of course it's not. But deciphering is very simple, it's named >> "gunzip". > > Right... so why does it have the MIME type "text/plain"? o_O Probably because it should be in "Content-Encoding" header. See, most web browsers are capable of gunzipping content - but only if they know it's gzipped, so they look at the Content-Encoding header, and if it's present and says "gzip", it decompresses the content. This is perfectly safe, since before receiving content browser lets the server know it accepts compressed pages (by sending "Accept-Encoding" header), so the server knows it can send compressed content. > (Also... how do you know it's ZIP, and not, say, gzip, bz2, RAR, > LHA...? I can't see anything that looks like an identifying header > in there.) Hmmm... your "file" tool doesn't know about gzip archives? From westondan at imageworks.com Wed Jul 23 18:30:16 2008 From: westondan at imageworks.com (Dan Weston) Date: Wed Jul 23 18:20:27 2008 Subject: [Haskell-cafe] BLAS Solve Example In-Reply-To: References: <4886CBDA.2060603@um.es> Message-ID: <4887B0F8.7000505@imageworks.com> A jedi master might stick with the existing double precision solver, then convert the results to best rational approximation [1], then do a forward solve on the rational versions of matrices, adjusting numerator and denominator to eliminate the residual error (with a heuristic to favor common factors). If you are very lucky, such a rational number will exist, depending on your limits of humongous. [1] e.g. http://www.dtashley.com/howtos/2007/01/best_rational_approximation/ Darrin Thompson wrote: > On Wed, Jul 23, 2008 at 2:12 AM, Alberto Ruiz wrote: >> $ ghci solve.hs >> *Main> sol >> 3 |> [-5.555555555555511e-2,0.11111111111111113,0.2777777777777776] >> > > I was hoping for rational solutions. If I were a true jedi master I'd > write my own solver, which might be the right thing to do. All I know > so far is gauss' method. Probably I'd learn something implementing the > back substitution. hmm.... > > Thanks. > > -- > Darrin > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lrpalmer at gmail.com Wed Jul 23 18:33:20 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jul 23 18:23:18 2008 Subject: [Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl) In-Reply-To: References: Message-ID: <7ca3f0160807231533ga867146qbf0de66d98a29b50@mail.gmail.com> On Wed, Jul 23, 2008 at 6:10 PM, Corey O'Connor wrote: > My straightforward Haskell solution was: > ------------------------------------------------------------------- > import Text.Regex.Posix > > main = do > f_lines <- readFile "test.out" >>= return . lines > let duration = foldl add_line 0.0 f_lines > add_line sum line = > let [[_,m]] = line =~ "([0-9.]+)" > framerate = read m > delta = 1.0 / framerate > in sum + delta > putStrLn $ "Duration (sec): " ++ show duration > ------------------------------------------------------------------- I'm sure the other suggestions have improved performance far more than this suggestion will, but it's still worth a shot. I don't think I've _ever_ seen a case where using foldl was a good idea. foldl interacts poorly with laziness; use foldr when the function you are folding is nonstrict, and use foldl' (from Data.List), a strict version of foldl, when the function you are folding is strict. This is, of course, only a rule of thumb. Changing that foldl to foldl' will probably speed this up a decent amount. Luke From duncan.coutts at worc.ox.ac.uk Wed Jul 23 18:44:08 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 23 18:32:45 2008 Subject: [Haskell-cafe] Literate program implementing text editor In-Reply-To: <48878F13.4050306@ukfsn.org> References: <48878F13.4050306@ukfsn.org> Message-ID: <1216853048.12754.52.camel@localhost> On Wed, 2008-07-23 at 21:05 +0100, Eric wrote: > Hi all, > > I wanted to embark on a Haskell program that implements a simple text > editor. Before doing so, however, I thought that I should ask: Does > anyone know of a literate Haskell program already in existence that does > the job? I don't know about simple, but there is Yi and once upon a time it was simple before everyone added lots of features to it. It's probably not literate Haskell though. Duncan From ok at cs.otago.ac.nz Thu Jul 24 00:43:59 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu Jul 24 00:34:01 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <1216828333.12754.30.camel@localhost> References: <1216828333.12754.30.camel@localhost> Message-ID: On 24 Jul 2008, at 3:52 am, Duncan Coutts wrote: [Sun have donated a T5120 server + USD10k to develop support for Haskell on the SPARC.] This is wonderful news. I have a 500MHz UltraSPARC II on my desktop running Solaris 2.10. Some time ago I tried to install GHC 6.6.1 on it, but ended up with something that compiles to C ok, but then invokes some C compiler with option "-fwrapv", which no compiler on that machine accepts, certainly none that was present when I installed it. I would really love to be able to use GHC on that machine. I also have an account on a T1 server, but the research group who Sun gave it to chose to run Linux on it, of all things. So binary distributions for SPARC/Solaris and SPARC/Linux would be very very nice things for this new project to deliver early. (Or some kind of source distribution that doesn't need a working GHC to start with.) From allbery at ece.cmu.edu Thu Jul 24 01:03:01 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jul 24 00:53:00 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> Message-ID: On 2008 Jul 24, at 0:43, Richard A. O'Keefe wrote: > So binary distributions for SPARC/Solaris and SPARC/Linux would > be very very nice things for this new project to deliver early. > (Or some kind of source distribution that doesn't need a working > GHC to start with. I'm still working on SPARC/Solaris here as well. (Still trying to get a build that doesn't produce executables that throw "schedule re- entered unsafely" immediately on startup.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From newsham at lava.net Thu Jul 24 03:04:21 2008 From: newsham at lava.net (Tim Newsham) Date: Thu Jul 24 02:54:20 2008 Subject: [Haskell-cafe] ghc socket weirdness Message-ID: FreeBSD/7.0 amd64: GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :module +Network Prelude Network> listenOn $ PortNumber 8765 Loading package parsec-2.1.0.0 ... linking ... done. Loading package network-2.1.0.0 ... linking ... done. *** Exception: getAddrInfo: does not exist (servname not supported for ai_socktype) (same error when compiled). Anyone seen this before? I have multiple NICs, could that be confusing listenOn (does it not just bind on 0.0.0.0?) Tim Newsham http://www.thenewsh.com/~newsham/ From jungleji at gmail.com Thu Jul 24 03:33:15 2008 From: jungleji at gmail.com (Ji YongGang) Date: Thu Jul 24 03:23:20 2008 Subject: [Haskell-cafe] ghc socket weirdness In-Reply-To: (Tim Newsham's message of "Wed, 23 Jul 2008 21:04:21 -1000 (HST)") References: Message-ID: <87wsjbbutg.fsf@devpc.softforge.3322.org> Tim Newsham writes: > FreeBSD/7.0 amd64: > > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> :module +Network > Prelude Network> listenOn $ PortNumber 8765 > Loading package parsec-2.1.0.0 ... linking ... done. > Loading package network-2.1.0.0 ... linking ... done. > *** Exception: getAddrInfo: does not exist (servname not supported for > ai_socktype) > > (same error when compiled). > > Anyone seen this before? I have multiple NICs, could that be > confusing listenOn (does it not just bind on 0.0.0.0?) > ghc 6.8.2 has the same problem on NetBSD/i386, it fixed with ghc 6.8.3: http://hackage.haskell.org/trac/ghc/ticket/2103 -- jungle From duncan.coutts at worc.ox.ac.uk Thu Jul 24 07:07:44 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jul 24 06:56:18 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> Message-ID: <1216897664.12754.154.camel@localhost> On Thu, 2008-07-24 at 16:43 +1200, Richard A. O'Keefe wrote: > On 24 Jul 2008, at 3:52 am, Duncan Coutts wrote: > [Sun have donated a T5120 server + USD10k to develop > support for Haskell on the SPARC.] > > This is wonderful news. > > I have a 500MHz UltraSPARC II on my desktop running Solaris 2.10. I have 500MHz UltraSPARC II on my desktop running Gentoo Linux. :-) > Some time ago I tried to install GHC 6.6.1 on it, but ended up > with something that compiles to C ok, but then invokes some C > compiler with option "-fwrapv", which no compiler on that machine > accepts, certainly none that was present when I installed it. I've got ghc 6.8.2 working, but only -fvia-C and only unregisterised. "-fwrapv" is an option to some version of gcc, but I couldn't tell you which. > I would really love to be able to use GHC on that machine. Me too :-), or in my case use it a bit quicker. Unregisterised ghc builds are pretty slow. > I also have an account on a T1 server, but the research group > who Sun gave it to chose to run Linux on it, of all things. Our tentative plan is to partition our T2 server using logical domains and run both Solaris and Linux. We'd like to set up ghc build bots on both OSs. > So binary distributions for SPARC/Solaris and SPARC/Linux would > be very very nice things for this new project to deliver early. I guess this is something that anyone with an account on the box could do. So once we get to the stage where we're handing out accounts then hopefully this would follow. The project isn't aiming to get the registerised C backend working nicely, we're aiming to get a decent native backend. That should also be much less fragile by not depending on the version of gcc so closely. > (Or some kind of source distribution that doesn't need a working > GHC to start with.) That's a tad harder. Needs lot of build system hacking. Duncan From ryani.spam at gmail.com Thu Jul 24 17:06:02 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 24 16:56:01 2008 Subject: [Haskell-cafe] Re: Profiling nested case In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C32AE762AE67@EA-EXMSG-C334.europe.corp.microsoft.com> References: <2f9b2d30807210036j45a7f79eie87c80e04c1b19ea@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C32AE762AE67@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <2f9b2d30807241406l26ca987bw387cc27881b01065@mail.gmail.com> Done. http://hackage.haskell.org/trac/ghc/ticket/2465 -- ryan On 7/23/08, Simon Peyton-Jones wrote: > | I had similar experiences as you when attempting to write "high > | performance Haskell"; the language makes you want to use high-level > | abstracted functions but the optimizer (while amazing, to be honest) > | seems to miss a few cases that it seems like it should hit. > > Ryan, if you find any of these, do please submit them to GHC's Trac bug-tracker. There's a special category for performance bugs. Small programs of the form "GHC should hit this, but doesn't" are incredibly useful. > > Thanks > > Simon > From john at repetae.net Thu Jul 24 17:38:24 2008 From: john at repetae.net (John Meacham) Date: Thu Jul 24 17:28:23 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <1216828333.12754.30.camel@localhost> References: <1216828333.12754.30.camel@localhost> Message-ID: <20080724213824.GA11895@sliver.repetae.net> Neat stuff. I used to work at Sun in the solaris kernel group, the SPARC architecture is quite elegant. I wonder if we can find an interesting use for the register windows in a haskell compiler. Many compilers for non c-like languages (such as boquist's one that jhc is based on (in spirit, if not code)) just ignore the windows and treat the architecture as having a flat 32 register file. John -- John Meacham - ?repetae.net?john? From john at repetae.net Thu Jul 24 18:14:46 2008 From: john at repetae.net (John Meacham) Date: Thu Jul 24 18:04:40 2008 Subject: [Haskell-cafe] ansi2html - one program, several issues In-Reply-To: <488343C3.7060904@charter.net> References: <220e47b40807190939q66c4446hbc1d26f55bf0339c@mail.gmail.com> <782623184.20080720023409@gmail.com> <20080720061719.GB15843@sliver.repetae.net> <200807200255.11107.dan.doel@gmail.com> <488343C3.7060904@charter.net> Message-ID: <20080724221446.GB11895@sliver.repetae.net> On Sun, Jul 20, 2008 at 09:55:15AM -0400, Isaac Dupree wrote: >> It doesn't stop it from parsing the entire file strictly. However, what >> it does do is prevent the parser from backtracking out of arbitrary >> amounts of lookahead. So, unless you use try (which allows for >> lookahead), when any token is consumed by the parser, it can be garbage >> collected (assuming the parser is the only thing pointing to the token >> stream). So, it consumes its input strictly, but with limited overhead >> (ideally using try only for some small bounded lookahead where it's >> needed). > > So with Parsec, you can keep the *input* from filling up memory, but if > you do, the *result* will still take up space (e.g. Right (value)). For > a simple transformation where the output is a similar string to the > input, it will be just as large, so not much space is actually saved > (maybe a factor of 2 -- just keeping the output, not also the input), it > seems. Yeah, this is my understanding. frisby combats this via 'irrefutable' parser combinators. An irrefutable combinator is one that always succeeds, a prime example is the 'many' combinator. Since 'many' consumes only as many of its arguments as it can and is perfectly fine consuming nothing, it inherently always succeeds so the parser can immediately begin returning results (before consuming all of the input). Ironically, this means frisby often uses less space than other parsers, despite being based on PEGs which generally are known for taking a lot of space. It is not too hard to ensure your optimizer is irrefutable, for instance, the parser for a simple language might be > many statement <> eof however, the 'eof' makes the parser non-irrefutabel. however it is easy to gain back by doing > many statement <> (eof // pure (error "unexpected data")) frisbys static analysis realizes that (irrefutable // ... ) and ( ... // irrefutable) are irrefutable. John -- John Meacham - ?repetae.net?john? From duncan.coutts at worc.ox.ac.uk Thu Jul 24 18:55:31 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jul 24 18:44:02 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <20080724213824.GA11895@sliver.repetae.net> References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> Message-ID: <1216940131.12754.183.camel@localhost> On Thu, 2008-07-24 at 14:38 -0700, John Meacham wrote: > Neat stuff. I used to work at Sun in the solaris kernel group, the SPARC > architecture is quite elegant. I wonder if we can find an interesting > use for the register windows in a haskell compiler. Many compilers for > non c-like languages (such as boquist's one that jhc is based on (in > spirit, if not code)) just ignore the windows and treat the architecture > as having a flat 32 register file. Right. GHC on SPARC has also always disabled the register window when running Haskell code (at least for registerised builds) and only uses it when using the C stack and calling C functions. We should discuss this with our project adviser from the SPARC compiler group. The problem of course is recursion and deeply nested call stacks which don't make good use of register windows because they keep having to interrupt to spill them to the save area. I vaguely wondered if they might be useful for leaf calls or more generally where we can see statically that the call depth is small (and we can see all callers of said function, since it'd change the calling convention). But now you mention it, I wonder if there is anything even more cunning we could do, perhaps with lightweight threads or something. Or perhaps an area to quickly save registers at GC safe points. Duncan From patperry at stanford.edu Thu Jul 24 19:22:34 2008 From: patperry at stanford.edu (Patrick Perry) Date: Thu Jul 24 19:12:40 2008 Subject: [Haskell-cafe] Re: blas bindings, why are they so much slower the C? Message-ID: Last month Anatoly Yakovenko published some disturbing numbers about the Haskell BLAS bindings I wrote being significantly slower than using plain C. I wanted to let everyone know that I've closed the performance gap, and now for doing ten million dot products, the overhead for using Haskell instead of C is about 0.6 seconds on my machine, regardless of the size of the vectors. The next version will incorporate the changes. If you can't wait for a formal release, the darcs repository is at http://www-stat.stanford.edu/~patperry/code/blas/ Anyone interested in more details can check out my blog: http://quantile95.com/2008/07/24/addressing-haskell-blas-performance-issues/ Thanks everyone for the input on this (especially Anatoly). If any else finds any performance discrepancies, please let me know and I will do whatever I can to fix them. Patrick From dons at galois.com Thu Jul 24 19:26:36 2008 From: dons at galois.com (Don Stewart) Date: Thu Jul 24 19:16:32 2008 Subject: [Haskell-cafe] Re: blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: <20080724232636.GI3928@scytale.galois.com> patperry: > Last month Anatoly Yakovenko published some disturbing numbers about > the Haskell BLAS bindings I wrote being significantly slower than > using plain C. I wanted to let everyone know that I've closed the > performance gap, and now for doing ten million dot products, the > overhead for using Haskell instead of C is about 0.6 seconds on my > machine, regardless of the size of the vectors. The next version will > incorporate the changes. If you can't wait for a formal release, the > darcs repository is at http://www-stat.stanford.edu/~patperry/code/blas/ > > Anyone interested in more details can check out my blog: > http://quantile95.com/2008/07/24/addressing-haskell-blas-performance-issues/ > > Thanks everyone for the input on this (especially Anatoly). If any > else finds any performance discrepancies, please let me know and I > will do whatever I can to fix them. > Great work, Patrick! So if I read correctly, the main change was to flatten the representation (and thus in loops the vector's structure will be unpacked and kept in registers, which isn't possible for sum types). -- Don From patperry at stanford.edu Thu Jul 24 19:41:16 2008 From: patperry at stanford.edu (Patrick Perry) Date: Thu Jul 24 19:31:20 2008 Subject: [Haskell-cafe] Re: blas bindings, why are they so much slower the C? In-Reply-To: <20080724232636.GI3928@scytale.galois.com> References: <20080724232636.GI3928@scytale.galois.com> Message-ID: <7C1EE30C-7859-40D4-A212-D392C8D2BE29@stanford.edu> Yeah, I think that's where most of the performance gains came from. I also added a re-write rule for unsafeGet dot (since it doesn't matter if the arguments are conjugated or not if the vectors are real) that shaved off about a tenth of a second. Patrick On Jul 24, 2008, at 4:26 PM, Don Stewart wrote: > patperry: >> Last month Anatoly Yakovenko published some disturbing numbers about >> the Haskell BLAS bindings I wrote being significantly slower than >> using plain C. I wanted to let everyone know that I've closed the >> performance gap, and now for doing ten million dot products, the >> overhead for using Haskell instead of C is about 0.6 seconds on my >> machine, regardless of the size of the vectors. The next version >> will >> incorporate the changes. If you can't wait for a formal release, the >> darcs repository is at http://www-stat.stanford.edu/~patperry/code/blas/ >> >> Anyone interested in more details can check out my blog: >> http://quantile95.com/2008/07/24/addressing-haskell-blas-performance-issues/ >> >> Thanks everyone for the input on this (especially Anatoly). If any >> else finds any performance discrepancies, please let me know and I >> will do whatever I can to fix them. >> > > Great work, Patrick! > > So if I read correctly, the main change was to flatten the > representation (and thus in loops the vector's structure will be > unpacked and kept in registers, which isn't possible for sum types). > > -- Don From Ben.Lippmeier at anu.edu.au Thu Jul 24 20:38:04 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Thu Jul 24 20:28:04 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <1216940131.12754.183.camel@localhost> References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> Message-ID: On 25/07/2008, at 8:55 AM, Duncan Coutts wrote: > Right. GHC on SPARC has also always disabled the register window when > running Haskell code (at least for registerised builds) and only > uses it > when using the C stack and calling C functions. > I'm not sure whether register windows and continuation based back-ends are ever going to be very good matches - I don't remember the last time I saw a 'ret' instruction in the generated code :). If there's a killer application for register windows in GHC it'd be something tricky. I'd be more interested in the 8 x hardware threads per core, [1] suggests that (single threaded) GHC code spends over half its time stalled due to L2 data cache miss. 64 threads per machine is a good incentive for trying out a few `par` calls.. Ben. [1] http://www.cl.cam.ac.uk/~am21/papers/msp02.ps.gz From Ben.Lippmeier at anu.edu.au Thu Jul 24 20:54:13 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Thu Jul 24 20:44:14 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> Message-ID: ... The UltraSPARC T1/T2 architecture supports very fast thread synchronisation (by taking advantage of the fact that all threads share the same L2 cache). ... Ah, scratch that second part then - though this is perhaps less of an issue when you have 4MB of L2 cache, vs the 256k cache for the machine in the paper. Ben. On 25/07/2008, at 10:38 AM, Ben Lippmeier wrote: > > On 25/07/2008, at 8:55 AM, Duncan Coutts wrote: >> Right. GHC on SPARC has also always disabled the register window when >> running Haskell code (at least for registerised builds) and only >> uses it >> when using the C stack and calling C functions. >> > > I'm not sure whether register windows and continuation based back- > ends are ever going to be very good matches - I don't remember the > last time I saw a 'ret' instruction in the generated code :). If > there's a killer application for register windows in GHC it'd be > something tricky. > > I'd be more interested in the 8 x hardware threads per core, [1] > suggests that (single threaded) GHC code spends over half its time > stalled due to L2 data cache miss. 64 threads per machine is a good > incentive for trying out a few `par` calls.. > > Ben. > > [1] http://www.cl.cam.ac.uk/~am21/papers/msp02.ps.gz From duncan.coutts at worc.ox.ac.uk Thu Jul 24 22:42:39 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jul 24 22:31:08 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> Message-ID: <1216953759.12754.195.camel@localhost> On Fri, 2008-07-25 at 10:38 +1000, Ben Lippmeier wrote: > I'd be more interested in the 8 x hardware threads per core, [1] > suggests that (single threaded) GHC code spends over half its time > stalled due to L2 data cache miss. Right, that's what I think is most interesting and why I wanted to get this project going in the first place. If we spend so long blocked on memory reads that we're only utilising 50% of a core's time then there's lots of room for improvements if we can fill in that wasted time by running another thread. So that's the supposed advantage of multiplexing several threads per core. If Haskell is suffering more than other languages with the memory latency and low utilisation then we've also got most to gain with this multiplexing approach. > 64 threads per machine is a good incentive for trying out a few `par` > calls.. Of course then it means we need to have enough work to do. Indeed we need quite a bit just to break even because each core is relatively stripped down without all the out-of-order execution etc. Duncan From DekuDekuplex at Yahoo.com Thu Jul 24 23:11:10 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Jul 24 23:01:14 2008 Subject: [Haskell-cafe] Re: [Off-topic] Loss of humour References: <48877C64.6060809@btinternet.com> <874p6g8gji.wl%jeremy@n-heptane.com> <48879DF4.3090104@btinternet.com> Message-ID: <3vgi84tu8ln307jtngnqlt3lqucgjojq3t@4ax.com> On Wed, 23 Jul 2008 22:09:08 +0100, Andrew Coppin wrote: >Jeremy Shaw wrote: >> At Wed, 23 Jul 2008 19:45:56 +0100, >> Andrew Coppin wrote: >> >>> A while back I found a page somewhere containing some rather amusing IRC >>> quotes. Unfortunately it seems to have vanished. I can't remember where >>> on earth I found it, but I've scoured the Internet trying to track it >>> down. (In particular, it contained a quote of somebody impersonating a >>> typical Haskell newbie - lots of enthusiasm and no attention span! Well >>> it amused *me* anyway...) Anybody have any ideas where this has gone? >>> >> >> http://web.archive.org/web/20070609061216/http://www.haskell.org/hawiki/QuotesPage >> > >LOL! > >Thanks, that's the one... You're referring to this one from that page, right? > Ninja Jones does a not-too-far-off parody of a certain flavor of visitor to #haskell > > *** highlyInterested (~ijones) has joined channel #haskell > hi! I'm highly interested, but have no attention span!!! > Can anyone help me?!?!? > * highlyInterested runs around!! > *** highlyInterested (~ijones) has quit: Client Quit -- Benjamin L. Russell From ok at cs.otago.ac.nz Thu Jul 24 23:47:25 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu Jul 24 23:37:25 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <1216940131.12754.183.camel@localhost> References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> Message-ID: On 25 Jul 2008, at 10:55 am, Duncan Coutts wrote: > The problem of course is recursion and deeply nested call stacks which > don't make good use of register windows because they keep having to > interrupt to spill them to the save area. A fair bit of thought was put into SPARC V9 to making saving and restoring register windows a lot cheaper than it used to be. (And the Sun C compiler learned how to do TRO.) It's nice to have 3 windows: startup normal Haskell code special support code so that normal code doesn't have to leave registers spare for millicode routines. From Ben.Lippmeier at anu.edu.au Fri Jul 25 00:19:13 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Fri Jul 25 00:09:12 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <1216953759.12754.195.camel@localhost> References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: <0F4D098B-9A2F-4204-891C-C5C5F81A41DF@anu.edu.au> On 25/07/2008, at 12:42 PM, Duncan Coutts wrote: > Of course then it means we need to have enough work to do. Indeed we > need quite a bit just to break even because each core is relatively > stripped down without all the out-of-order execution etc. I don't think that will hurt too much. The code that GHC emits is very regular and the basic blocks tend to be small. A good proportion of it is just for copying data between the stack and the heap. On the upside, it's all very clean and amenable to some simple peephole optimization / compile time reordering. I remember someone telling me that one of the outcomes of the Itanium project was that they didn't get the (low level) compile-time optimizations to perform as well as they had hoped. The reasoning was that a highly speculative/out-of-order processor with all the trimmings had a lot more dynamic information about the state of the program, and could make decisions on the fly which were better than what you could ever get statically at compile time. -- does anyone have a reference for this? Anyway, this problem is moot with GHC code. There's barely any instruction level parallelism to exploit anyway, but adding an extra hardware thread is just a `par` away. To quote a talk from that paper earlier: "GHC programs turn an Athlon into a 486 with a high clock speed!" Ben. From dermiste at gmail.com Fri Jul 25 04:21:32 2008 From: dermiste at gmail.com (dermiste) Date: Fri Jul 25 04:11:28 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <874p6g8gji.wl%jeremy@n-heptane.com> References: <48877C64.6060809@btinternet.com> <874p6g8gji.wl%jeremy@n-heptane.com> Message-ID: The sixth quote : --- Michael Schuerig wrote: > On Wednesday 25 September 2002 05:27, Edward Wilson > wrote: > > The real question is: if you were a Jedi Knight, > and > > you could only master *one* language as your > weapon of > > choice, what would it be--Common Lisp? > > Probably. In particular, considering that the Jedi > seem to be somewhat > conservative and CL beautifully captures the > anachronistic elegance and > power of a programming lightsaber. Future Jedi > generations might choose > more modern weapons; Haskell, OCaml and Oz being > among the contenders. http://www.xkcd.com/297/ xD I love this guy On Wed, Jul 23, 2008 at 10:57 PM, Jeremy Shaw wrote: > At Wed, 23 Jul 2008 19:45:56 +0100, > Andrew Coppin wrote: >> >> A while back I found a page somewhere containing some rather amusing IRC >> quotes. Unfortunately it seems to have vanished. I can't remember where >> on earth I found it, but I've scoured the Internet trying to track it >> down. (In particular, it contained a quote of somebody impersonating a >> typical Haskell newbie - lots of enthusiasm and no attention span! Well >> it amused *me* anyway...) Anybody have any ideas where this has gone? > > http://web.archive.org/web/20070609061216/http://www.haskell.org/hawiki/QuotesPage > > j. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From marlowsd at gmail.com Fri Jul 25 04:55:14 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Jul 25 04:45:12 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: References: <87tzfehfgy.wl%jeremy@n-heptane.com> <200807021626009536167@gmail.com> <20080702171440.GC26461@liouville.galois.com> <4885A44F.6090502@gmail.com> Message-ID: <488994F2.4040606@gmail.com> Joe Buehler wrote: > Simon Marlow wrote: > >> For the registerised port, you really need a native code generator >> (the mangler is on death row, yay). At a rough guess, I'd say porting >> the NCG would take a couple of weeks or so for someone unfamiliar with >> the code. Hopefully we'll improve that when we refactor the NCG as >> part of the backend overhaul. > > Is there any documentation on the NCG? I ported 6.6 to HPUX 11 some > time ago > and looked at the NCG but didn't do it for PA-RISC because it was going > to take too > much time to understand. I was leaning towards the approach of trying > to translate > the code generator for another processor into PA-RISC. There's some old documentation, some of it is still relevant but probably much of it is out of date now: http://darcs.haskell.org/ghc/docs/comm/the-beast/ncg.html the best doc is the code, I'm afraid (but it has lot of illuminating comments and you can get a long way with cut-and-paste). Cheers, Simon From tittoassini at gmail.com Fri Jul 25 07:37:17 2008 From: tittoassini at gmail.com (Pasqualino 'Titto' Assini) Date: Fri Jul 25 07:27:15 2008 Subject: [Haskell-cafe] Italian Haskellers Summer Meeting? Message-ID: <200807251237.17121.tittoassini@gmail.com> As a prerequisite for atttending is proficiency in "la bella lingua del si" (also known as Italian) I think I will just write the rest of this message in it. Ottimi, ma non particolarmente abbondanti, haskeller italiani, abbiamo avuto una piccola discussione su #haskell.it circa la possibilita' di organizzare un incontro estivo. Non credo che ne sia stato mai organizzato uno e quindi vorrei intanto che mi faceste sapere: - se vi interessa - dove siete/sarete d'agosto - che formato debba avere l'incontro Riguardo quest'ultimo punto, direi che ci sono almeno tre possibilita' : a) Ritiro spirituale. Luogo: rifugio di montagna, monastero benedettino. Gli adepti giungono al luogo designato dopo un lungo percorso a piedi attraverso regioni desertiche. Hanno barbe lunghe ed occhi severi ma in cui brilla la luce di una pura fede monoidale. Riunitisi davanti ad un semplice pasto gli adepti spezzano il pane e bevono il vino e si scambiano parabole illuminanti circa la vera natura del Monoide, della Monade e del Funtore Applicativo. Un neofita, che non sa spiegare la differenza fra left e right fold, viene giudicato impuro e ritualmente lapidato. b) Scampagnata fuori porta Luogo: ridente localita' marina od agreste. Gli haskeller arrivano alla spicciolata su una spiaggia animata. Hanno costumi colorati e capelli rasta. Qualcuno ha portato i bambini, tutti hanno portato la paletta ed il secchiello. Si fanno castelli di sabbia, qualcuno passa una canna, si divide una pizza e si chiacchiera' in liberta di haskell, zen e viaggi in motocicletta. L'atmosfera si rabbuia pero' improvvisamente quando viene scoperto un infiltrato provocatore che non sa spiegare la differenza fra left e right fold. Sommariamente giudicato da un tribunale del popolo, l'infelice viene affogato ed abbandonato sulla spiaggia, nell'indifferenza dei bagnanti che continuano a giocare a solitario sui telefonini. c) Seminario accademico Luogo: tetra aula universitaria. Serie presentazioni accademiche si susseguono senza posa. Per ragioni di principio nessuno dei relatori usa power point e riempiono le lavagne nere con suggestivi ma incomprensibili sgorbi. Si suda copiosamente nel caldo estivo e l'olezzo di accademici poco lavati riempie la stanza. Un dottorando dell'universita' di Pisa emoziona l'auditorio, dimostrando in maniera inconfutabile la mirabile corrispondenza fra monoidi destrorsi e logica lineare. Un addottorato del politecnico di Torino, geloso, cerca di staccargli un occhio con un gessetto. Un neofita, che non sa spiegare la differenza fra left e right fold, russa in un angolo. Personalmente, vista la stagione, suggerirei di: - Se c'e' disponibilita' a passare un paio di giorni insieme optare per l'opzione a. Paolino ha proposto a questo proposito di riunirci in un rifugio delle Apuane. - Se invece vogliamo fare una cosa in giornata allora andrei per l'opzione b e suggerirei di vederci sulla spiaggia di Monterosso (5 Terre). Come data, suggerirei l'11 agosto (o 11-12 in caso di opzione a). Per registrarsi, proporre date/luoghi etc, proporrei di utilizzare la pagina wiki dedicata: http://www.haskell.org/haskellwiki/ItaloHaskell/Summer_2008 A presto, titto P.S. Io saro' offline per una settimana a partire da domenica. -------------------------------- Pasqualino "Titto" Assini PhD 25 Heath Road - Wivenhoe CO79PT - Colchester - U.K. From hakim.cassimally at gmail.com Fri Jul 25 08:32:22 2008 From: hakim.cassimally at gmail.com (Hakim Cassimally) Date: Fri Jul 25 08:22:15 2008 Subject: [Haskell-cafe] Italian Haskellers Summer Meeting? In-Reply-To: <200807251237.17121.tittoassini@gmail.com> References: <200807251237.17121.tittoassini@gmail.com> Message-ID: <82cfa8030807250532l6e7076d0vfa3acabfee44696b@mail.gmail.com> 2008/7/25 Pasqualino 'Titto' Assini : > As a prerequisite for atttending is proficiency in "la bella lingua del si" > (also known as Italian) I think I will just write the rest of this message in > it. > > Ottimi, ma non particolarmente abbondanti, haskeller italiani, > Come data, suggerirei l'11 agosto (o 11-12 in caso di opzione a). Che peccato, mi sarebbe piaciuto tornare in Italia (ed il mare a Monterosso e' un bel posto effettivamente) per partecipare al summer meeting, ma in quel periodo sono in vacanza (Copenhagen, prima della conferenza YAPC dei perlisti :-) Purtroppo perdo anche Anglohaskell per la stessa ragione... comunque, sarei interessato a partecipare a futuri meeting di questo genere. Saluti, Hakim (osfameron) From DekuDekuplex at Yahoo.com Fri Jul 25 08:33:08 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Jul 25 08:23:07 2008 Subject: [Haskell-cafe] Re: [Off-topic] Loss of humour References: <48877C64.6060809@btinternet.com> <874p6g8gji.wl%jeremy@n-heptane.com> Message-ID: On Fri, 25 Jul 2008 10:21:32 +0200, dermiste wrote: >The sixth quote : > >--- Michael Schuerig wrote: > > On Wednesday 25 September 2002 05:27, Edward Wilson > > wrote: > > > The real question is: if you were a Jedi Knight, > > and > > > you could only master *one* language as your > > weapon of > > > choice, what would it be--Common Lisp? > > > > Probably. In particular, considering that the Jedi > > seem to be somewhat > > conservative and CL beautifully captures the > > anachronistic elegance and > > power of a programming lightsaber. Future Jedi > > generations might choose > > more modern weapons; Haskell, OCaml and Oz being > > among the contenders. > >http://www.xkcd.com/297/ But you missed the punchline: > seen on The Pragmatic Programmer's yahoo mailing list: > > From: Ronald Legere > Subject: Re: Jedi Programming (was: [pragprog] Common List or Dylan?) > To: pragprog@yahoogroups.com > Date: Wed, 25 Sep 2002 03:29:01 -0700 (PDT) > Reply-To: pragprog@yahoogroups.com > > No no no, a jedi master must fashion his > OWN language. > > <*grin*> > > --- Michael Schuerig wrote: > > On Wednesday 25 September 2002 05:27, Edward Wilson > > wrote: > > > The real question is: if you were a Jedi Knight, > > and > > > you could only master *one* language as your > > weapon of > > > choice, what would it be--Common Lisp? > > > > Probably. In particular, considering that the Jedi > > seem to be somewhat > > conservative and CL beautifully captures the > > anachronistic elegance and > > power of a programming lightsaber. Future Jedi > > generations might choose > > more modern weapons; Haskell, OCaml and Oz being > > among the contenders. -- Benjamin L. Russell From nbloomf at gmail.com Fri Jul 25 10:25:45 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Fri Jul 25 10:15:46 2008 Subject: [Haskell-cafe] FPers in Northwest Arkansas? Message-ID: <9858b5620807250725p63250625q67105dc6adffe8e8@mail.gmail.com> Greetings, Haskell-cafe. I am interested in joining or starting a functional programming interest group in my area. Are there any haskellers in the Northwest Arkansas region? Nathan Bloomfield -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080725/ac25518e/attachment.htm From jefferson.r.heard at gmail.com Fri Jul 25 10:40:37 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jul 25 10:30:31 2008 Subject: [Haskell-cafe] FPers in Northwest Arkansas? In-Reply-To: <9858b5620807250725p63250625q67105dc6adffe8e8@mail.gmail.com> References: <9858b5620807250725p63250625q67105dc6adffe8e8@mail.gmail.com> Message-ID: <4165d3a70807250740g248ac46eg43340ec22f01f03a@mail.gmail.com> Dunno about that, but I'm a NW arkansas expat. 2008/7/25 Nathan Bloomfield : > Greetings, Haskell-cafe. I am interested in joining or starting a functional > programming interest group in my area. Are there any haskellers in the > Northwest Arkansas region? > > Nathan Bloomfield > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From claus.reinke at talk21.com Fri Jul 25 12:57:58 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jul 25 12:47:58 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs Message-ID: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> FYI: Haskell's OpenGL binding has just been dropped from GHC's extralibs, which means that it will no longer be kept in sync with GHC development, at least not by GHC HQ. GHC HQ has its hands full and -generally speaking - extralibs are to be replaced by H(L)P, the Haskell (Library) Platform: http://haskell.org/haskellwiki/Haskell_Platform so this part is understandable. But OpenGL has been dropped before H(L)P is ready to take over from extralibs, and at the recent GHC Irc meeting on the topic http://hackage.haskell.org/trac/ghc/attachment/wiki/IRC_Meetings/ghc-2008-07-16.log the mood seemed to favour not including OpenGL&co in the initial versions of H(L)P. Sven put a lot of good work into these libraries, but he is often not around for a long time, and it would be a shame if these gems were orphaned and went out of sync in the meantime. While I haven't used OpenGL in a while, I've always hoped to come back to that, not to mention Sven's spatial audio binding additions. And if I'm not mistaken, there are other community members who are using these libs right now for research, possibly even prototyping in connection with a startup? So, if one of you wanted to step forward and offer to keep these Haskell bindings for OpenGL&co maintained, perhaps steward them into the H(L)P, now would probably be a good time. Just thought I'd forward this, for those not following cvs-ghc, Claus ----- Original Message ----- From: "Ian Lynagh" To: Sent: Friday, July 25, 2008 12:11 AM Subject: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs > Thu Jul 24 03:27:36 PDT 2008 Ian Lynagh > * Remove the OpenGL family of libraries from extralibs > > M ./libraries/Makefile -4 > M ./libraries/extra-packages -4 > > View patch online: > http://darcs.haskell.org/ghc/_darcs/patches/20080724102736-3fd76-f5601cb7a290661124c44e9ec6c113812c12d08d.gz > > _______________________________________________ > Cvs-ghc mailing list > Cvs-ghc@haskell.org > http://www.haskell.org/mailman/listinfo/cvs-ghc From jefferson.r.heard at gmail.com Fri Jul 25 13:05:33 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jul 25 12:55:27 2008 Subject: [Haskell-cafe] Re: [HOpenGL] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> Message-ID: <4165d3a70807251005y6f2b6611ucff6c65c52cebcdf@mail.gmail.com> I don't know how much I can do to keep them in sync, as I don't know anything about the HLP, however, I'm actively using OpenGL 2.1 in Haskell for research and prototyping and the inclusion of OpenGL in Haskell has been central to my case for using it in my workplace. I don't know what I can do to help, but if anyone will point me in the right direction, I'll try to throw some inertia at it... -- Jeff On Fri, Jul 25, 2008 at 12:57 PM, Claus Reinke wrote: > FYI: Haskell's OpenGL binding has just been dropped from GHC's > extralibs, which means that it will no longer be kept in sync with GHC > development, at least not by GHC HQ. > > GHC HQ has its hands full and -generally speaking - extralibs are to > be replaced by H(L)P, the Haskell (Library) Platform: > > http://haskell.org/haskellwiki/Haskell_Platform > > so this part is understandable. But OpenGL has been dropped before > H(L)P is ready to take over from extralibs, and at the recent GHC Irc > meeting on the topic > > http://hackage.haskell.org/trac/ghc/attachment/wiki/IRC_Meetings/ghc-2008-07-16.log > > the mood seemed to favour not including OpenGL&co in the initial > versions of H(L)P. Sven put a lot of good work into these libraries, > but he is often not around for a long time, and it would be a shame > if these gems were orphaned and went out of sync in the meantime. > > While I haven't used OpenGL in a while, I've always hoped to come > back to that, not to mention Sven's spatial audio binding additions. > And if I'm not mistaken, there are other community members who > are using these libs right now for research, possibly even prototyping > in connection with a startup? > > So, if one of you wanted to step forward and offer to keep these > Haskell bindings for OpenGL&co maintained, perhaps steward them > into the H(L)P, now would probably be a good time. > > Just thought I'd forward this, for those not following cvs-ghc, > Claus > > ----- Original Message ----- From: "Ian Lynagh" > To: > Sent: Friday, July 25, 2008 12:11 AM > Subject: patch applied (ghc): Remove the OpenGL family of libraries > fromextralibs > > >> Thu Jul 24 03:27:36 PDT 2008 Ian Lynagh >> * Remove the OpenGL family of libraries from extralibs >> >> M ./libraries/Makefile -4 >> M ./libraries/extra-packages -4 >> >> View patch online: >> >> http://darcs.haskell.org/ghc/_darcs/patches/20080724102736-3fd76-f5601cb7a290661124c44e9ec6c113812c12d08d.gz >> >> _______________________________________________ >> Cvs-ghc mailing list >> Cvs-ghc@haskell.org >> http://www.haskell.org/mailman/listinfo/cvs-ghc > > _______________________________________________ > HOpenGL mailing list > HOpenGL@haskell.org > http://www.haskell.org/mailman/listinfo/hopengl > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From duncan.coutts at worc.ox.ac.uk Fri Jul 25 13:15:13 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Jul 25 13:03:37 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> Message-ID: <1217006113.12754.227.camel@localhost> On Fri, 2008-07-25 at 17:57 +0100, Claus Reinke wrote: > So, if one of you wanted to step forward and offer to keep these > Haskell bindings for OpenGL&co maintained, perhaps steward them > into the H(L)P, now would probably be a good time. I fully expect the GL and AL binding libs to join the Haskell platform set on a subsequent iteration (along with many other popular high quality libs). The intention is to not give ourselves too large a workload on the first iteration. Duncan From agl at imperialviolet.org Fri Jul 25 13:21:40 2008 From: agl at imperialviolet.org (Adam Langley) Date: Fri Jul 25 13:11:33 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> Message-ID: <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> 2008/7/23 Levi Greenspan : > I would be grateful for any advices, hints or comments. And I really > look forward to the FFI section in the "Real World Haskell" book. Generally it looks pretty good. I think I'm missing some C code (function "wrapper"). However, libevent is an odd choice to wrap. The RTS already multiplexes IO for Haskell programs. In order not to block the RTS, the libevent using code would have to be in its own kernel thread. Really, the RTS needs to be ported to libevent rather than an FFI wrapping. For your specific problem, I see you're allocating xptr, but I don't see that you're ever poking a value into it. Indeed, I can't see that createEvent ever uses 'x'. Hope that helps. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From dons at galois.com Fri Jul 25 13:27:37 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 25 13:19:41 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> Message-ID: <20080725172737.GB6953@scytale.galois.com> claus.reinke: > FYI: Haskell's OpenGL binding has just been dropped from GHC's > extralibs, which means that it will no longer be kept in sync with GHC > development, at least not by GHC HQ. > > GHC HQ has its hands full and -generally speaking - extralibs are to > be replaced by H(L)P, the Haskell (Library) Platform: > > http://haskell.org/haskellwiki/Haskell_Platform > > so this part is understandable. But OpenGL has been dropped before > H(L)P is ready to take over from extralibs, and at the recent GHC Irc > meeting on the topic > > http://hackage.haskell.org/trac/ghc/attachment/wiki/IRC_Meetings/ghc-2008-07-16.log > > the mood seemed to favour not including OpenGL&co in the initial > versions of H(L)P. Sven put a lot of good work into these libraries, > but he is often not around for a long time, and it would be a shame > if these gems were orphaned and went out of sync in the meantime. > > While I haven't used OpenGL in a while, I've always hoped to come > back to that, not to mention Sven's spatial audio binding additions. > And if I'm not mistaken, there are other community members who > are using these libs right now for research, possibly even prototyping > in connection with a startup? > > So, if one of you wanted to step forward and offer to keep these > Haskell bindings for OpenGL&co maintained, perhaps steward them > into the H(L)P, now would probably be a good time. > > Just thought I'd forward this, for those not following cvs-ghc, > Claus Note the OpenGL are still just as maintained as they used to be -- that is, it hasn't had a maintainer for several years. The only change is that the GHC developers don't put them in a tarball on haskell.org/ghc prior to releasing GHC itself. -- Don From jefferson.r.heard at gmail.com Fri Jul 25 13:47:25 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jul 25 13:37:20 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <20080725172737.GB6953@scytale.galois.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> Message-ID: <4165d3a70807251047x1bb7b812l90d1c25470884907@mail.gmail.com> Well, since HOpenGL seems to support practically all of OpenGL 2.1, I don't see that there's much to maintain, except compatibility with upcoming releases of GHC and possibly some optimization. Maybe I'm missing something, though. Is there a list of outstanding bugs somewhere? I personally know of one bug that I found some time ago, which I simply worked around, but a comprehensive list, I'm not aware of. -- Jeff On Fri, Jul 25, 2008 at 1:27 PM, Don Stewart wrote: > claus.reinke: >> FYI: Haskell's OpenGL binding has just been dropped from GHC's >> extralibs, which means that it will no longer be kept in sync with GHC >> development, at least not by GHC HQ. >> >> GHC HQ has its hands full and -generally speaking - extralibs are to >> be replaced by H(L)P, the Haskell (Library) Platform: >> >> http://haskell.org/haskellwiki/Haskell_Platform >> >> so this part is understandable. But OpenGL has been dropped before >> H(L)P is ready to take over from extralibs, and at the recent GHC Irc >> meeting on the topic >> >> http://hackage.haskell.org/trac/ghc/attachment/wiki/IRC_Meetings/ghc-2008-07-16.log >> >> the mood seemed to favour not including OpenGL&co in the initial >> versions of H(L)P. Sven put a lot of good work into these libraries, >> but he is often not around for a long time, and it would be a shame >> if these gems were orphaned and went out of sync in the meantime. >> >> While I haven't used OpenGL in a while, I've always hoped to come >> back to that, not to mention Sven's spatial audio binding additions. >> And if I'm not mistaken, there are other community members who >> are using these libs right now for research, possibly even prototyping >> in connection with a startup? >> >> So, if one of you wanted to step forward and offer to keep these >> Haskell bindings for OpenGL&co maintained, perhaps steward them >> into the H(L)P, now would probably be a good time. >> >> Just thought I'd forward this, for those not following cvs-ghc, >> Claus > > Note the OpenGL are still just as maintained as they used to be -- that > is, it hasn't had a maintainer for several years. > > The only change is that the GHC developers don't put them in a tarball > on haskell.org/ghc prior to releasing GHC itself. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From greenspan.levi at googlemail.com Fri Jul 25 15:24:29 2008 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Fri Jul 25 15:14:24 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> Message-ID: <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> Thanks Adam. It took me some time to realize what you recognized immediately - xptr is useless. Instead I now bind the additional value which might be provided on event creation in a closure since the C code never has to deal with it. And yes, there are many functions missing. For now I just need the event notification to detect file descritor (or socket) changes. Regarding your remark, that the RTS multiplexes IO already I am usure how this works out in practice. The reason I write this wrapper is that I want a network server which can handle thousands of connections. And to not require a permanent thread for each I would like to use something like select in C or Selector in Java. I haven't found something like this in Haskell, hence the libevent wrapper. If you have any information how to write something like this without this wrapper I would be more than happy. Finally the code still leaks FunPtrs as so far I never free them and honestly I don't know when to do this. Any ideas? For reference I have attached a newer version of the wrapper code (removed the TimeVal stuff since I don't need it). Thanks again, Levi On Fri, Jul 25, 2008 at 7:21 PM, Adam Langley wrote: > 2008/7/23 Levi Greenspan : >> I would be grateful for any advices, hints or comments. And I really >> look forward to the FFI section in the "Real World Haskell" book. > > Generally it looks pretty good. I think I'm missing some C code > (function "wrapper"). However, libevent is an odd choice to wrap. The > RTS already multiplexes IO for Haskell programs. In order not to block > the RTS, the libevent using code would have to be in its own kernel > thread. > > Really, the RTS needs to be ported to libevent rather than an FFI wrapping. > > For your specific problem, I see you're allocating xptr, but I don't > see that you're ever poking a value into it. Indeed, I can't see that > createEvent ever uses 'x'. > > Hope that helps. > > > > > AGL > > -- > Adam Langley agl@imperialviolet.org http://www.imperialviolet.org > -------------- next part -------------- A non-text attachment was scrubbed... Name: hsevent.hsc Type: application/octet-stream Size: 4062 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080725/9306ab95/hsevent.obj From gtener at gmail.com Fri Jul 25 16:00:27 2008 From: gtener at gmail.com (=?ISO-8859-2?Q?Krzysztof_Skrz=EAtnicki?=) Date: Fri Jul 25 15:50:19 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> Message-ID: <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> 2008/7/25 Levi Greenspan : > And to not require a permanent thread for each I would > like to use something like select in C or Selector in Java. I haven't > found something like this in Haskell, hence the libevent wrapper. As far as I know GHC's scheduler uses select() internally. At least it was using at the time of writing this paper: "Developing a high-performance web server in Concurrent Haskell" http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf (see page 15) Perhaps you might be interested in this paper also because of its topic. Christopher Skrz?tnicki From agl at imperialviolet.org Fri Jul 25 16:05:43 2008 From: agl at imperialviolet.org (Adam Langley) Date: Fri Jul 25 15:55:37 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> Message-ID: <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> 2008/7/25 Krzysztof Skrz?tnicki : > "Developing a high-performance web server in Concurrent Haskell" > http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf (see page 15) > > Perhaps you might be interested in this paper also because of its topic. That's a good reference. Also note that the paper is 6 years old and GHC has come a long way since then. I'd suspect that the graph on page 15 would look much more favourable to Haskell these days. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From dons at galois.com Fri Jul 25 16:11:59 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 25 16:01:55 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> Message-ID: <20080725201159.GI6953@scytale.galois.com> agl: > 2008/7/25 Krzysztof Skrz?tnicki : > > "Developing a high-performance web server in Concurrent Haskell" > > http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf (see page 15) > > > > Perhaps you might be interested in this paper also because of its topic. > > That's a good reference. Also note that the paper is 6 years old and > GHC has come a long way since then. I'd suspect that the graph on page > 15 would look much more favourable to Haskell these days. Ask Johan about the minimum 5k/sec web server using heavy concurrency he's hacking on. -- Don From greenspan.levi at googlemail.com Fri Jul 25 16:32:03 2008 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Fri Jul 25 16:21:56 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> Message-ID: <3e62d4360807251332x50406262rdff72d9b5ee4be12@mail.gmail.com> Thank you (and Christopher) for the link. I have one question though - I read this ticket in the GHC trac: http://hackage.haskell.org/trac/ghc/ticket/635 which plans to use epoll instead of select. The reason I thought of libevent is exactly the support for epoll and other better-than-select mechanisms. Is there progress in GHC with regard to this? This is very important for me since I awill not write a web-server, but rather want to play with Comet (i.e. having thousands of open connections as it is common for long-polling in addition to many relatively short request/response based connections). However it seems no quite attractive to go with what is offered by GHC currently instead of writing the libevent wrapper. Just for the sake of completeness - any insights into the freeFunPtr issue I wrote about? ;-) Many thanks to all of you. - Levi On Fri, Jul 25, 2008 at 10:05 PM, Adam Langley wrote: > 2008/7/25 Krzysztof Skrz?tnicki : >> "Developing a high-performance web server in Concurrent Haskell" >> http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf (see page 15) >> >> Perhaps you might be interested in this paper also because of its topic. > > That's a good reference. Also note that the paper is 6 years old and > GHC has come a long way since then. I'd suspect that the graph on page > 15 would look much more favourable to Haskell these days. > > > AGL > > -- > Adam Langley agl@imperialviolet.org http://www.imperialviolet.org > From chaddai.fouche at gmail.com Fri Jul 25 16:33:01 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Fri Jul 25 16:22:54 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> Message-ID: 2008/7/25 Levi Greenspan : > Regarding your remark, that the RTS multiplexes IO already I am usure > how this works out in practice. The reason I write this wrapper is > that I want a network server which can handle thousands of > connections. And to not require a permanent thread for each I would > like to use something like select in C or Selector in Java. I haven't > found something like this in Haskell, hence the libevent wrapper. If > you have any information how to write something like this without this > wrapper I would be more than happy. The current model for concurrency in Haskell is m lightweight user-threads working on n kernel threads, thus the threads are very cheap in Haskell and take advantage of a multicore. I think with the current model, the right choice for a web server in Haskell is a multi-threaded model. As a point of comparison, I remember that blog post which noted that its FastCGI was able to withstand more than 3000 hits by second (on a quite normal setting). -- Jeda? From agl at imperialviolet.org Fri Jul 25 16:45:21 2008 From: agl at imperialviolet.org (Adam Langley) Date: Fri Jul 25 16:35:15 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <3e62d4360807251332x50406262rdff72d9b5ee4be12@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> <3e62d4360807251332x50406262rdff72d9b5ee4be12@mail.gmail.com> Message-ID: <396556a20807251345g210a6075y2876a3fe871ca510@mail.gmail.com> On Fri, Jul 25, 2008 at 1:32 PM, Levi Greenspan wrote: > Thank you (and Christopher) for the link. I have one question though - > I read this ticket in the GHC trac: > http://hackage.haskell.org/trac/ghc/ticket/635 which plans to use > epoll instead of select. The reason I thought of libevent is exactly > the support for epoll and other better-than-select mechanisms. Is > there progress in GHC with regard to this? This is very important for > me since I awill not write a web-server, but rather want to play with > Comet (i.e. having thousands of open connections as it is common for > long-polling in addition to many relatively short request/response > based connections). Bryan O'Sullivan make an off-the-cuff remark about doing this work at a talk a few months back, however I haven't heard anything about him starting. I think it's safe to assume that no one has taken it up yet. Personally, some of my other projects are higher priorities at the moment. I'd suggest that you write your server on the select() based system as-is for now. Then, when you need epoll you'll be sufficiently motivated to hack up the RTS to include it ;) AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From lane at downstairspeople.org Fri Jul 25 16:58:35 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Fri Jul 25 16:48:28 2008 Subject: [Haskell-cafe] Re: [HOpenGL] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <4165d3a70807251005y6f2b6611ucff6c65c52cebcdf@mail.gmail.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <4165d3a70807251005y6f2b6611ucff6c65c52cebcdf@mail.gmail.com> Message-ID: HOpenGL is in remarkably good shape for being unmaintained for several years. I think the quiet on the HOpenGL mailing list speaks positively to the quality of the library. Perhaps those of us who have an interest in HOpenGL can arrange to work as comaintainers. I think I could be bothered to do weekly builds against GHC to make sure we stay up to date. I'll set that up in the next month or so. Jeff, please point me to your bug. I'd like to take a look. --Lane On Fri, 25 Jul 2008, Jefferson Heard wrote: > I don't know how much I can do to keep them in sync, as I don't know > anything about the HLP, however, I'm actively using OpenGL 2.1 in > Haskell for research and prototyping and the inclusion of OpenGL in > Haskell has been central to my case for using it in my workplace. I > don't know what I can do to help, but if anyone will point me in the > right direction, I'll try to throw some inertia at it... > > -- Jeff From claus.reinke at talk21.com Fri Jul 25 17:07:12 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jul 25 16:57:10 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> Message-ID: <013901c8ee9a$69a25640$58237ad5@cr3lt> >> So, if one of you wanted to step forward and offer to keep these >> Haskell bindings for OpenGL&co maintained, perhaps steward them >> into the H(L)P, now would probably be a good time. >> >> Just thought I'd forward this, for those not following cvs-ghc, >> Claus > > Note the OpenGL are still just as maintained as they used to be -- that > is, it hasn't had a maintainer for several years. Some people post the funniest rumours as if they were facts. $ ghc-pkg field OpenGL maintainer maintainer: sven.panne@aedion.de At the end of this message, I also append the output of darcs changes since OpenGL 2.1 was supported, for those interested in what might be involved in maintainance: Fri Nov 10 10:14:54 GMT Standard Time 2006 sven.panne@aedion.de * Updated Haddock module headers (now OpenGL 2.1 support, API is stable) It just so happens that the library is very stable (unlike other libraries I could think of;-) - Sven's last bug-fix patch was in March 2007, the patches since then have been build system evolution/maintainance. So the problem is not with the library, but with the environment - since its creation, the library has seen FFI tools appear and disappear, FFI spec and library hierarchy take shape, darcs appear and be taken on, Cabal appear and be taken on, packages and tools move on, split up, change their API, etc. - thanks to Sven and others, the binding has weathered all that, without making a lot of noise. And now, there is another enviroment change, with extralibs going and the Haskell Platform aiming to improve the Haskell installation experience. And new quality criteria will be prescribed that this old library will have to meet to be allowed in with the new kids on the block. > The only change is that the GHC developers don't put them in a tarball > on haskell.org/ghc prior to releasing GHC itself. It isn't the tarballing, it is (a) whether the library is run in the HEAD buildbots to flush out breaking changes to the environment early (b) whether enviroment changes are reflected in the library to unbreak its build before user installations are affected (c) whether the library can be relied on as being available on default Haskell installations (this would seem to be less of a problem with Cabal/hackage and user installs, but not all clients have install privileges/tools - OpenGL building uses configure, which in itself might not be installed on Windows; and in some University contexts, installation for public PCs is on a centralised, yearly basis, not per student; etc.; adding the GLUT dll has been a popular request ever since GHC had Windows installers, meaning that every single time someone forgets to put that dll in the installer, someone has reported it as a bug/feature request) I'm not aware of any urgent breakage in the OpenGL binding, nor is the current source going away, and as Duncan says, he expects OpenGL to reappear in the Haskell Platform later on. But neither do I believe the rumour that OpenGL isn't much used, and forwarding the removal notice gives those users the opportunity to speak up now if they prefer no gaps in OpenGL presence, or forever to hold their peace, as they say. Unless Sven wants to do the job himself, a maintainer would mainly have to adapt the library to the Haskell Platform criteria, keep up with the forever changing build environments, and counter rumours about the OpenGL binding being unmaintained or unused. Claus $ darcs changes --from-patch=stable Thu Jun 19 13:43:50 GMT Daylight Time 2008 Ian Lynagh tagged GHC 6.8.3 release Fri Jun 6 00:56:57 GMT Daylight Time 2008 Ian Lynagh tagged 2008-06-06 Sat Nov 10 01:11:04 GMT Standard Time 2007 Ian Lynagh tagged GHC 6.8.1 release Sat Nov 10 01:09:54 GMT Standard Time 2007 Ian Lynagh tagged 2.2.1.1 release Sat Oct 27 13:48:05 GMT Daylight Time 2007 Ian Lynagh * Bump version number Thu Oct 18 18:31:37 GMT Daylight Time 2007 Duncan Coutts * Specify build-type: Configure Mon Jun 4 12:59:36 GMT Daylight Time 2007 Ross Paterson * --configure-option and --ghc-option are now provided by Cabal Thu May 24 15:56:14 GMT Daylight Time 2007 Ian Lynagh * Remove Makefile and package.conf.in (used in the old GHC build system) Thu May 17 10:49:12 GMT Daylight Time 2007 Simon Marlow * add includes: field Mon Apr 30 12:17:32 GMT Daylight Time 2007 Ian Lynagh * Make configure fail if the package cannot be built Sat Apr 28 20:58:51 GMT Daylight Time 2007 Ian Lynagh tagged GHC 6.6.1 release Sat Apr 28 20:56:55 GMT Daylight Time 2007 Ian Lynagh tagged 2.2.1 release Tue Apr 24 12:39:29 GMT Daylight Time 2007 Ian Lynagh tagged GHC 6.6.1 release Tue Apr 24 12:38:31 GMT Daylight Time 2007 Ian Lynagh tagged Version 2.2.1 Sun Apr 22 20:50:57 GMT Daylight Time 2007 Ian Lynagh * Bump version to 2.2.1 Wed Apr 18 13:13:30 GMT Daylight Time 2007 Ian Lynagh * Follow Cabal changes in Setup.*hs Wed Apr 11 02:22:21 GMT Daylight Time 2007 Ian Lynagh * Fix -Wall warnings Sat Apr 7 18:41:16 GMT Daylight Time 2007 Ian Lynagh * Make Setup.hs suitable for building in a GHC tree Tue Mar 13 17:46:09 GMT Standard Time 2007 sven.panne> * README about building from darcs Mon Jan 1 12:50:21 GMT Standard Time 2007 sven.panne> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> Message-ID: <20080725211323.GM6953@scytale.galois.com> claus.reinke: > But neither do I believe the rumour that OpenGL isn't much > used, and forwarding the removal notice gives those users the > opportunity to speak up now if they prefer no gaps in OpenGL > presence, or forever to hold their peace, as they say. I for one have noticed this library *is* actively used. Many of the fun new games that have appeared are using it, in particular. Such as: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Monadius http://hackage.haskell.org/cgi-bin/hackage-scripts/package/roguestar-gl http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rsagl http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing http://hackage.haskell.org/cgi-bin/hackage-scripts/package/topkata The tutorial was also translated to the wiki last week, http://haskell.org/haskellwiki/Opengl It's a good, reliable package, in active use, widely ported. -- Don From mmitar at gmail.com Fri Jul 25 21:02:51 2008 From: mmitar at gmail.com (Mitar) Date: Fri Jul 25 20:52:45 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: <1216953759.12754.195.camel@localhost> References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: Hi! > If we spend so long blocked on memory reads that we're only utilising > 50% of a core's time then there's lots of room for improvements if we > can fill in that wasted time by running another thread. How can you see how much does your program wait because of L2 misses? I have been playing lately with dual Quad-Core Intel Xeon Mac Pros with 12 MB L2 cache per CPU and 1.6 GHz bus speed and it would be interesting to check this things there. Mitar From Ben.Lippmeier at anu.edu.au Fri Jul 25 21:17:02 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Fri Jul 25 21:07:13 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: http://valgrind.org/info/tools.html On 26/07/2008, at 11:02 AM, Mitar wrote: > Hi! > >> If we spend so long blocked on memory reads that we're only utilising >> 50% of a core's time then there's lots of room for improvements if we >> can fill in that wasted time by running another thread. > > How can you see how much does your program wait because of L2 misses? > I have been playing lately with dual Quad-Core Intel Xeon Mac Pros > with 12 MB L2 cache per CPU and 1.6 GHz bus speed and it would be > interesting to check this things there. > > > Mitar From dons at galois.com Fri Jul 25 21:38:37 2008 From: dons at galois.com (Don Stewart) Date: Fri Jul 25 21:28:46 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: <20080726013837.GA7952@scytale.galois.com> A tool originally developed to measure cache misses in GHC :) Ben.Lippmeier: > > http://valgrind.org/info/tools.html > > On 26/07/2008, at 11:02 AM, Mitar wrote: > > >Hi! > > > >>If we spend so long blocked on memory reads that we're only utilising > >>50% of a core's time then there's lots of room for improvements if we > >>can fill in that wasted time by running another thread. > > > >How can you see how much does your program wait because of L2 misses? > >I have been playing lately with dual Quad-Core Intel Xeon Mac Pros > >with 12 MB L2 cache per CPU and 1.6 GHz bus speed and it would be > >interesting to check this things there. > > > > > >Mitar > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Sat Jul 26 00:31:19 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jul 26 00:19:39 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: <1217046679.12754.235.camel@localhost> On Sat, 2008-07-26 at 03:02 +0200, Mitar wrote: > Hi! > > > If we spend so long blocked on memory reads that we're only utilising > > 50% of a core's time then there's lots of room for improvements if we > > can fill in that wasted time by running another thread. > > How can you see how much does your program wait because of L2 misses? > I have been playing lately with dual Quad-Core Intel Xeon Mac Pros > with 12 MB L2 cache per CPU and 1.6 GHz bus speed and it would be > interesting to check this things there. Take a look at the paper that Ben referred to http://www.cl.cam.ac.uk/~am21/papers/msp02.ps.gz They use hardware performance counters. Duncan From wren at freegeek.org Sat Jul 26 03:43:53 2008 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 26 03:33:52 2008 Subject: [Haskell-cafe] ANN: list-extras 0.2.0 Message-ID: <488AD5B9.4020801@freegeek.org> hello all~ After some talks with Aditya Mahajan I've overhauled the Data.List.Extras.Argmax module so it's not quite so braindead. Since it breaks backwards compatibility so soon after the initial announcement, I figured it was worth a mention. I also changed the case of the module's name, so beware on case-sensitive file systems. As always, the code and latest documentation is available from: http://code.haskell.org/~wren/ -- Live well, ~wren From vigalchin at gmail.com Sat Jul 26 05:17:04 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Jul 26 05:06:56 2008 Subject: [Haskell-cafe] Hi Nathan .... Message-ID: <5ae4f2ba0807260217i55d5a6c1pd4c5e1a618625bdc@mail.gmail.com> Hi Nathan, I am in Houston and want to start a serious Haskell "dialog/group" in the US Southeast! ... Let's rock because Haskell rocks!!!! Very kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080726/27899306/attachment.htm From aruiz at um.es Sat Jul 26 06:46:23 2008 From: aruiz at um.es (Alberto Ruiz) Date: Sat Jul 26 06:36:20 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs In-Reply-To: <20080725211323.GM6953@scytale.galois.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> <20080725211323.GM6953@scytale.galois.com> Message-ID: <488B007F.6050901@um.es> Don Stewart wrote: > claus.reinke: >> But neither do I believe the rumour that OpenGL isn't much >> used, and forwarding the removal notice gives those users the >> opportunity to speak up now if they prefer no gaps in OpenGL >> presence, or forever to hold their peace, as they say. > > I for one have noticed this library *is* actively used. Many of the fun > new games that have appeared are using it, in particular. > > Such as: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Monadius > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/roguestar-gl > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rsagl > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/topkata > > The tutorial was also translated to the wiki last week, > > http://haskell.org/haskellwiki/Opengl > > It's a good, reliable package, in active use, widely ported. I'd just like to say that HOpenGL is essential for me. It is one of the reasons why I finally decided to use Haskell for all my work... Alberto From greenspan.levi at googlemail.com Sat Jul 26 07:34:13 2008 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Sat Jul 26 07:24:06 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <396556a20807251345g210a6075y2876a3fe871ca510@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> <3e62d4360807251332x50406262rdff72d9b5ee4be12@mail.gmail.com> <396556a20807251345g210a6075y2876a3fe871ca510@mail.gmail.com> Message-ID: <1217072053.6478.19.camel@localhost> On Fri, 2008-07-25 at 13:45 -0700, Adam Langley wrote: > I'd suggest that you write your server on the select() based system > as-is for now. Then, when you need epoll you'll be sufficiently > motivated to hack up the RTS to include it ;) The problem with a select() based approach is that I can not have more than 1024 parallel connections on my Linux system, since this is the upper limit for the number of file descriptors in the FD_SET used by select(). Eg. # ulimit -n 10000 # client: internal error: awaitEvent: descriptor out of range (GHC version 6.8.3 for i386_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Aborted This is caused by having more file descriptors than FD_SETSIZE (which is 1024) on my system. So clearly select() doesn't scale to the numbers I need :-( Thanks, Levi From mmitar at gmail.com Sat Jul 26 07:35:20 2008 From: mmitar at gmail.com (Mitar) Date: Sat Jul 26 07:25:11 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: Hi! On Sat, Jul 26, 2008 at 3:17 AM, Ben Lippmeier wrote: > http://valgrind.org/info/tools.html No support for Mac OS X. :-( Mitar From mmitar at gmail.com Sat Jul 26 08:30:39 2008 From: mmitar at gmail.com (Mitar) Date: Sat Jul 26 08:20:29 2008 Subject: [Haskell-cafe] ANNOUNCE: Sun Microsystems and Haskell.org joint project on OpenSPARC In-Reply-To: References: <1216828333.12754.30.camel@localhost> <20080724213824.GA11895@sliver.repetae.net> <1216940131.12754.183.camel@localhost> <1216953759.12754.195.camel@localhost> Message-ID: Hi! On Sat, Jul 26, 2008 at 1:35 PM, Mitar wrote: > No support for Mac OS X. :-( Apple provides Shark in Xcode Tools which has something called "L2 Cache Miss Profile". I will just have to understand results it produces. Mitar From jefferson.r.heard at gmail.com Sat Jul 26 08:38:58 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Sat Jul 26 08:28:49 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs In-Reply-To: <488B007F.6050901@um.es> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> <20080725211323.GM6953@scytale.galois.com> <488B007F.6050901@um.es> Message-ID: <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> Yes, same here; don't worry, it's not going away. It would be nice to know, though, how many people are using it and what they're using it for. I'm using it for information visualization, and slowly evolving/cribbing together something like the Processing (http://www.processing.org) framework for Haskell as I do more things. On Sat, Jul 26, 2008 at 5:46 AM, Alberto Ruiz wrote: > Don Stewart wrote: >> >> claus.reinke: >>> >>> But neither do I believe the rumour that OpenGL isn't much >>> used, and forwarding the removal notice gives those users the >>> opportunity to speak up now if they prefer no gaps in OpenGL presence, or >>> forever to hold their peace, as they say. >> >> I for one have noticed this library *is* actively used. Many of the fun >> new games that have appeared are using it, in particular. >> >> Such as: >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Monadius >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/roguestar-gl >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rsagl >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/topkata >> >> The tutorial was also translated to the wiki last week, >> >> http://haskell.org/haskellwiki/Opengl >> >> It's a good, reliable package, in active use, widely ported. > > I'd just like to say that HOpenGL is essential for me. It is one of the > reasons why I finally decided to use Haskell for all my work... > > Alberto > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From jwlato at gmail.com Sat Jul 26 21:23:09 2008 From: jwlato at gmail.com (John Lato) Date: Sat Jul 26 21:12:58 2008 Subject: [Haskell-cafe] Cabal files on Windows Message-ID: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> Hello, Can anyone point me to a method for including path names with spaces in a cabal file? I would like to add a line similar to the following: include-dirs: C:\Program Files\program\include and of course a corresponding library as well. I've tried various methods of escaping the space and quoting, and nothing seems to work. Is this possible at all? I'm using Cabal-1.2.4.0 on Windows. I've tried running with a Windows shell and MSYS bash, with the same results. Thanks, John Lato From aslatter at gmail.com Sat Jul 26 23:29:57 2008 From: aslatter at gmail.com (Antoine Latter) Date: Sat Jul 26 23:19:48 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Hipmunk 0.1 and HipmunkPlayground 0.1 In-Reply-To: References: Message-ID: <694519c50807262029n14cb6d72n6d5c83b6a41a376@mail.gmail.com> On Sat, Jul 26, 2008 at 9:50 PM, Felipe Lessa wrote: > 6.8.1). > > You may get Cabal packages for both on Hackage at: > - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Hipmunk > - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HipmunkPlayground > Felipe, I'm getting the following error trying to cabal-install HipmunkPlayground: +++++ Building HipmunkPlayground-0.1... [1 of 1] Compiling Main ( ./Playground.hs, dist/build/HipmunkPlayground/HipmunkPlayground-tmp/Main.o ) Linking dist/build/HipmunkPlayground/HipmunkPlayground ... ld: duplicate symbol _deRefStablePtr in /Library/Frameworks/GHC.framework/Versions/608/usr/lib/ghc-6.8.2.20080211/libHSrts.a(Stable.o) and /Users/alatter/.cabal/lib/Hipmunk-0.1/ghc-6.8.2.20080211/libHSHipmunk-0.1.a(Space_stub.o) collect2: ld returned 1 exit status cabal: Error: some packages failed to install: HipmunkPlayground-0.1 failed during the building phase. The exception was: exit: ExitFailure 1 +++++ I simply typed "cabal install HipmuckPlayground". Should I need to do anything else? I'm running Mac OS 10.5 on Intel. Does this error look useful to anyone? -Antoine From dons at galois.com Sat Jul 26 23:32:19 2008 From: dons at galois.com (Don Stewart) Date: Sat Jul 26 23:22:09 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Hipmunk 0.1 and HipmunkPlayground 0.1 In-Reply-To: <694519c50807262029n14cb6d72n6d5c83b6a41a376@mail.gmail.com> References: <694519c50807262029n14cb6d72n6d5c83b6a41a376@mail.gmail.com> Message-ID: <20080727033219.GC10380@scytale.galois.com> aslatter: > On Sat, Jul 26, 2008 at 9:50 PM, Felipe Lessa wrote: > > 6.8.1). > > > > You may get Cabal packages for both on Hackage at: > > - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Hipmunk > > - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HipmunkPlayground > > > > Felipe, > > I'm getting the following error trying to cabal-install HipmunkPlayground: > > +++++ > > Building HipmunkPlayground-0.1... > [1 of 1] Compiling Main ( ./Playground.hs, > dist/build/HipmunkPlayground/HipmunkPlayground-tmp/Main.o ) > Linking dist/build/HipmunkPlayground/HipmunkPlayground ... > ld: duplicate symbol _deRefStablePtr in > /Library/Frameworks/GHC.framework/Versions/608/usr/lib/ghc-6.8.2.20080211/libHSrts.a(Stable.o) > and /Users/alatter/.cabal/lib/Hipmunk-0.1/ghc-6.8.2.20080211/libHSHipmunk-0.1.a(Space_stub.o) > > collect2: ld returned 1 exit status > cabal: Error: some packages failed to install: > HipmunkPlayground-0.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > +++++ > > I simply typed "cabal install HipmuckPlayground". Should I need to do > anything else? I had this too, on Linux. The solution is to configure with --enable-split-objs -- Don From felipe.lessa at gmail.com Sat Jul 26 23:34:38 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Jul 26 23:24:27 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Hipmunk 0.1 and HipmunkPlayground 0.1 In-Reply-To: <694519c50807262029n14cb6d72n6d5c83b6a41a376@mail.gmail.com> References: <694519c50807262029n14cb6d72n6d5c83b6a41a376@mail.gmail.com> Message-ID: On Sun, Jul 27, 2008 at 12:29 AM, Antoine Latter wrote: > On Sat, Jul 26, 2008 at 9:50 PM, Felipe Lessa wrote: >> 6.8.1). >> >> You may get Cabal packages for both on Hackage at: >> - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Hipmunk >> - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HipmunkPlayground >> > > Felipe, > > I'm getting the following error trying to cabal-install HipmunkPlayground: [duplicate symbol _deRefStablePtr] Well, I guess this isn't a random problem then. I had this in one of the Linux boxes but the first thing I tried to solve it worked so dismissed it as something not so important. Now dons had this problem as well. The solution: compile Hipmunk with --enable-split-objs . Now, why that happens is something I don't know. Why split-objs helps I don't know either. On the other Linux box and on the Windows one it worked flawless without --enable-split-objs. Some GHC hacker around to shed some light, please? -- Felipe. From felipe.lessa at gmail.com Sun Jul 27 09:36:56 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Jul 27 09:26:44 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Hipmunk 0.1 and HipmunkPlayground 0.1 In-Reply-To: References: <694519c50807262029n14cb6d72n6d5c83b6a41a376@mail.gmail.com> Message-ID: On Sun, Jul 27, 2008 at 12:34 AM, Felipe Lessa wrote: > On Sun, Jul 27, 2008 at 12:29 AM, Antoine Latter wrote: >> I'm getting the following error trying to cabal-install HipmunkPlayground: > [duplicate symbol _deRefStablePtr] > > Well, I guess this isn't a random problem then. I had this in one of > the Linux boxes but the first thing I tried to solve it worked so > dismissed it as something not so important. Now dons had this problem > as well. I've filled a GHC ticket at http://hackage.haskell.org/trac/ghc/ticket/2469 . Thanks, -- Felipe. From jeanphilippe.bernardy at gmail.com Sun Jul 27 11:08:04 2008 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Sun Jul 27 10:58:00 2008 Subject: [Haskell-cafe] ANN: Yi 0.4.1 Message-ID: I'm very pleased to announce the 0.4.1 release of the Yi editor. == Yi == Yi is a text editor written and extensible in Haskell. The long-term goal of the Yi project is to provide the editor of choice for Haskell programmers. In the meantime, we have fun by hacking an editor in a decent language :) Yi is not a finished product. This is an alpha-quality release. However, Yi has become a lot more accessible than previously, so if you feel like testing it, now might be a good time to take a look. == Installation == Using cabal install: cabal install yi-0.4.1 If you want gtk support, first install gtk2hs 0.9.13. If you want vty support, pass the -fvty option to cabal install. == Features == * A purely functional editor core; * Key-bindings written as parsers of the input; * Emacs, Vim and (partial) Cua emulations provided by default; * Vty, Gtk2Hs, and (experimental) Cocoa front-ends; * Static configuration (XMonad style) for fast load; * Simple Haskell support: * Syntax highlighting * Auto-indentation * Call cabal-build within the editor == Links == * download: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/yi * FAQ: http://haskell.org/haskellwiki/Yi/FAQ * homepage: http://haskell.org/haskellwiki/Yi * check and report issues: http://code.google.com/p/yi-editor/issues/list * darcs repository: http://code.haskell.org/yi * get involved: mailto:yi-devel@googlegroups.com * release notes: http://code.google.com/p/yi-editor/wiki/ReleaseNotes0o4 == Acks == This release is brought to you by: Allan Clark Andrew Birkett Corey O'Connor Duncan Coutts Evan Martin Fraser Wilson Gustav Munkby Gwern Branwen Jean-Philippe Bernardy Krasimr Angelov Nicolas Pouillard Sean Leather Thomas Schilling and all the contributors to the previous versions. From jgm at berkeley.edu Sun Jul 27 12:54:47 2008 From: jgm at berkeley.edu (John MacFarlane) Date: Sun Jul 27 12:43:48 2008 Subject: [Haskell-cafe] library for zip compression? Message-ID: <20080727165447.GA14726@berkeley.edu> Haskellers, Is there a library for compressing and uncompressing zip archives? I see zlib and bzlib on HackageDB, but unless I'm mistaken these won't help with a .zip archive. (See http://zlib.net/zlib_faq.html#faq11.) Any help here would be appreciated. John From lane at downstairspeople.org Sun Jul 27 13:05:22 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sun Jul 27 12:55:15 2008 Subject: [HOpenGL] Re: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs In-Reply-To: <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> <20080725211323.GM6953@scytale.galois.com> <488B007F.6050901@um.es> <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> Message-ID: There is a section "Projects using the OpenGL bindings" (http://www.haskell.org/haskellwiki/OpenGL) on the wiki that is pretty bare. A quick search of HCAR lists five projects using OpenGL. --L On Sat, 26 Jul 2008, Jefferson Heard wrote: > It would be nice to know, though, how many people are using it and what > they're using it for. I'm using it for information visualization, and > slowly evolving/cribbing together something like the Processing > (http://www.processing.org) framework for Haskell as I do more things. From aneumann at inf.fu-berlin.de Sun Jul 27 13:23:14 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sun Jul 27 13:13:16 2008 Subject: [Haskell-cafe] Exceptions Message-ID: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> Hello, I think it'd be nice if the compiler could warn me if there are any exceptions which I'm not catching, similar to checked exceptions in Java. Does anyone know of a possibility to do that in Haskell? Adrian -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080727/33186642/PGP.bin From gtener at gmail.com Sun Jul 27 13:58:05 2008 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Sun Jul 27 13:47:52 2008 Subject: [Haskell-cafe] Exceptions In-Reply-To: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> References: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> Message-ID: <220e47b40807271058q48d956exb426a15fb48b9777@mail.gmail.com> I don't really think this is possible: consider asynchronous exceptions and throwTo. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#v%3AthrowTo Since it can throw just *any* exception into thread. And this thread might not be aware that anyone can throw him anything. Therefore it is not possible to catch it while compiling it's code. But Maybe I'm Just wrong. Christopher Skrz?tnicki 2008/7/27 Adrian Neumann : > Hello, > > I think it'd be nice if the compiler could warn me if there are any > exceptions which I'm not catching, similar to checked exceptions in Java. > Does anyone know of a possibility to do that in Haskell? > > Adrian > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From tanimoto at arizona.edu Sun Jul 27 15:18:51 2008 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Sun Jul 27 15:08:38 2008 Subject: [Haskell-cafe] ANN: Yi 0.4.1 In-Reply-To: References: Message-ID: Fantastic release, thank you! It's never been so easy to start playing with Yi. : ) Paulo On Sun, Jul 27, 2008 at 10:08 AM, Jean-Philippe Bernardy wrote: > I'm very pleased to announce the 0.4.1 release of the Yi editor. > > == Yi == > Yi is a text editor written and extensible in Haskell. The > long-term goal of the Yi project is to provide the editor of > choice for Haskell programmers. In the meantime, we have fun by > hacking an editor in a decent language :) > > Yi is not a finished product. This is an alpha-quality release. > However, Yi has become a lot more accessible than > previously, so if you feel like testing it, now might be a good time > to take a look. > > == Installation == > > Using cabal install: > > cabal install yi-0.4.1 > > If you want gtk support, first install gtk2hs 0.9.13. > If you want vty support, pass the -fvty option to cabal install. > > == Features == > * A purely functional editor core; > * Key-bindings written as parsers of the input; > * Emacs, Vim and (partial) Cua emulations provided by default; > * Vty, Gtk2Hs, and (experimental) Cocoa front-ends; > * Static configuration (XMonad style) for fast load; > * Simple Haskell support: > * Syntax highlighting > * Auto-indentation > * Call cabal-build within the editor > > == Links == > * download: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/yi > * FAQ: http://haskell.org/haskellwiki/Yi/FAQ > * homepage: http://haskell.org/haskellwiki/Yi > * check and report issues: http://code.google.com/p/yi-editor/issues/list > * darcs repository: http://code.haskell.org/yi > * get involved: mailto:yi-devel@googlegroups.com > * release notes: http://code.google.com/p/yi-editor/wiki/ReleaseNotes0o4 > > == Acks == > > This release is brought to you by: > > Allan Clark > Andrew Birkett > Corey O'Connor > Duncan Coutts > Evan Martin > Fraser Wilson > Gustav Munkby > Gwern Branwen > Jean-Philippe Bernardy > Krasimr Angelov > Nicolas Pouillard > Sean Leather > Thomas Schilling > > and all the contributors to the previous versions. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Sun Jul 27 15:22:09 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 27 15:12:01 2008 Subject: [Haskell-cafe] Exceptions In-Reply-To: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> References: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> Message-ID: <20080727192209.GA13904@scytale.galois.com> aneumann: > Hello, > > I think it'd be nice if the compiler could warn me if there are any > exceptions which I'm not catching, similar to checked exceptions in > Java. Does anyone know of a possibility to do that in Haskell? > > Adrian You could provide exception-safe wrappers for the functions you use, that catch any exception and flatten it to an Either type (or something similar). Then GHC's usual coverage checking will enforce the handling. import qualified System.IO import Control.Exception maybeReadFile :: FilePath -> IO (Maybe String) maybeReadFile f = handle (\_ -> return Nothing) (Just `fmap` System.IO.readFile f) {- *A> maybeReadFile "/tmp/DOESNOTEXIST" Nothing -} main = do mf <- maybeReadFile "DOESNOTEXIST" case mf of Nothing -> return () Just s -> print s The ability to control exceptions seems like something we should have more solutions for. -- Don From hjgtuyl at chello.nl Sun Jul 27 15:36:32 2008 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sun Jul 27 15:26:19 2008 Subject: [Haskell-cafe] Cabal files on Windows In-Reply-To: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> References: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> Message-ID: On Sun, 27 Jul 2008 03:23:09 +0200, John Lato wrote: > Hello, > > Can anyone point me to a method for including path names with spaces > in a cabal file? I would like to add a line similar to the following: > include-dirs: C:\Program Files\program\include > and of course a corresponding library as well. > [...] Have you tried replacing "Program Files" with PROGRA~1? This is the old MS-Dos version of the directory name; you can find the old name with command dir /x C:\ , this displays the old version next to the new version of the name. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From duncan.coutts at worc.ox.ac.uk Sun Jul 27 16:25:23 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jul 27 16:13:30 2008 Subject: [Haskell-cafe] Cabal files on Windows In-Reply-To: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> References: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> Message-ID: <1217190323.12754.252.camel@localhost> On Sat, 2008-07-26 at 20:23 -0500, John Lato wrote: > Hello, > > Can anyone point me to a method for including path names with spaces > in a cabal file? I would like to add a line similar to the following: > include-dirs: C:\Program Files\program\include > and of course a corresponding library as well. Use Haskell String syntax for paths that contain spaces: include-dirs: "C:\\Program Files\\program\\include" Duncan From niklas.broberg at gmail.com Sun Jul 27 16:33:18 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Jul 27 16:23:04 2008 Subject: [Haskell-cafe] ANN: Yi 0.4.1 In-Reply-To: References: Message-ID: Hi Jean-Philippe, > Using cabal install: > > cabal install yi-0.4.1 when I do this on my Windows machine, cabal-install tries to download the unix-2.3.0.0 package, which clearly won't work. How do I get yi to install on Windows? Cheers, /Niklas From dons at galois.com Sun Jul 27 16:49:32 2008 From: dons at galois.com (Don Stewart) Date: Sun Jul 27 16:39:20 2008 Subject: [Haskell-cafe] ANN: Yi 0.4.1 In-Reply-To: References: Message-ID: <20080727204932.GC13904@scytale.galois.com> jeanphilippe.bernardy: > I'm very pleased to announce the 0.4.1 release of the Yi editor. > > == Yi == > Yi is a text editor written and extensible in Haskell. The > long-term goal of the Yi project is to provide the editor of > choice for Haskell programmers. In the meantime, we have fun by > hacking an editor in a decent language :) > > Yi is not a finished product. This is an alpha-quality release. > However, Yi has become a lot more accessible than > previously, so if you feel like testing it, now might be a good time > to take a look. While the vty frontend is working, the gtk / pango frontends are erroring for me with, $ yi -f pango Launching custom yi: "/home/dons/.yi/yi-x86_64-linux" yi: exception :: System.Glib.GError.GError Anyone seen this? -- Don From jeanphilippe.bernardy at gmail.com Sun Jul 27 16:56:17 2008 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Sun Jul 27 16:46:17 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 References: Message-ID: Niklas Broberg gmail.com> writes: > > Hi Jean-Philippe, > > > Using cabal install: > > > > cabal install yi-0.4.1 > > when I do this on my Windows machine, cabal-install tries to download > the unix-2.3.0.0 package, which clearly won't work. How do I get yi to > install on Windows? Vty frontend does not work on win32, so you must install gtk2hs (latest) beforehand. Additionally, I recommend to use cabal install yi-0.4.1 -f-vty -fgtk to force choosing the right options. Cheers, JP. From jeanphilippe.bernardy at gmail.com Sun Jul 27 16:58:27 2008 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Sun Jul 27 16:49:52 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 References: <20080727204932.GC13904@scytale.galois.com> Message-ID: Don Stewart galois.com> writes: > $ yi -f pango > Launching custom yi: "/home/dons/.yi/yi-x86_64-linux" > yi: exception :: System.Glib.GError.GError > > Anyone seen this? Consistently on x64. The pango stuff is generally unstable anyway. I'm not sure what's to blame. -- JP From duncan.coutts at worc.ox.ac.uk Sun Jul 27 17:20:35 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jul 27 17:08:43 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 In-Reply-To: References: <20080727204932.GC13904@scytale.galois.com> Message-ID: <1217193635.12754.257.camel@localhost> On Sun, 2008-07-27 at 20:58 +0000, Jean-Philippe Bernardy wrote: > Don Stewart galois.com> writes: > > > > $ yi -f pango > > Launching custom yi: "/home/dons/.yi/yi-x86_64-linux" > > yi: exception :: System.Glib.GError.GError > > > > Anyone seen this? > > Consistently on x64. The pango stuff is generally unstable anyway. I'm not sure > what's to blame. That's interesting. That's a Haskell exception (dynamic type). I doubt it's being thrown by the Pango code, there's only one use of it there, in parseMarkup and that should throw parsing errors pretty much independent of platform. You can catch those GError exceptions and print more interesting info. Use: > catchGError > (do ... > ...) > (\(GError dom code msg) -> fail msg) Duncan From bulat.ziganshin at gmail.com Sun Jul 27 16:27:11 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jul 27 17:28:12 2008 Subject: [Haskell-cafe] Cabal files on Windows In-Reply-To: References: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> Message-ID: <1622019944.20080728002711@gmail.com> Hello Henk-Jan, Sunday, July 27, 2008, 11:36:32 PM, you wrote: >> Can anyone point me to a method for including path names with spaces >> in a cabal file? I would like to add a line similar to the following: > Have you tried replacing "Program Files" with PROGRA~1? This is the old i don't followed discussion but if this meant for distributable packages, the following problems exist: 1. it may be progra~2 or ~3 2. it's possible to entirely disable short names generation on ntfs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From niklas.broberg at gmail.com Sun Jul 27 18:28:21 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Jul 27 18:18:07 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 In-Reply-To: References: <20080727204932.GC13904@scytale.galois.com> Message-ID: Thanks, after installing gtk2hs and using the flags you told me I managed to install it just fine. However... > > $ yi -f pango > > Launching custom yi: "/home/dons/.yi/yi-x86_64-linux" > > yi: exception :: System.Glib.GError.GError > > > > Anyone seen this? > > > Consistently on x64. The pango stuff is generally unstable anyway. I'm not sure > what's to blame. ... I got this error too, and I'm on Win32. :-( Cheers, /Niklas From jeanphilippe.bernardy at gmail.com Sun Jul 27 18:43:10 2008 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Sun Jul 27 18:33:09 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 References: <20080727204932.GC13904@scytale.galois.com> Message-ID: Niklas Broberg gmail.com> writes: > > Thanks, after installing gtk2hs and using the flags you told me I > managed to install it just fine. However... Good :) > The pango stuff is generally unstable anyway. I'm not sure > > what's to blame. > > ... I got this error too, and I'm on Win32. > The gtk frontend should not suffer from this: yi -fgtk -- JP. From niklas.broberg at gmail.com Sun Jul 27 19:02:33 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Jul 27 18:52:18 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 In-Reply-To: References: <20080727204932.GC13904@scytale.galois.com> Message-ID: > The gtk frontend should not suffer from this: > > yi -fgtk C:\Documents and Settings\Niklas Broberg>yi -fgtk yi: exception :: System.Glib.GError.GError :-( Cheers, /Niklas ps. If I installed it with -f-vty -fgtk, shouldn't gtk be the default when running? :-) From sk at k-hornz.de Sun Jul 27 19:08:07 2008 From: sk at k-hornz.de (stefan kersten) Date: Sun Jul 27 18:58:31 2008 Subject: [Haskell-cafe] ANN: Yi 0.4.1 In-Reply-To: References: Message-ID: <20080727230807.GD3357@self.local> On Sun, Jul 27, 2008 at 03:08:04PM +0000, Jean-Philippe Bernardy wrote: > I'm very pleased to announce the 0.4.1 release of the Yi editor. great, i can't wait to check it out ... i get the following error when installing via hackage/cabal (ghc 6.8.1, cabal 1.4.0.1): Yi/Buffer.hs:253:0: No instance for (Typeable4 RWS) arising from the 'deriving' clause of a data type declaration at Yi/Buffer.hs:(253,0)-(254,101) Possible fix: add an instance declaration for (Typeable4 RWS) When deriving the instance for (Typeable1 BufferM) Yi/Buffer.hs:256:0: Can't make a derived instance of `Typeable4 RWS' (even with cunning newtype deriving: the representation type has wrong kind) In the stand-alone deriving instance for `Typeable4 RWS' any ideas what's going wrong? is it finally time to upgrade my ghc installation? From ben.franksen at online.de Sun Jul 27 19:29:30 2008 From: ben.franksen at online.de (Ben Franksen) Date: Sun Jul 27 19:19:49 2008 Subject: [Haskell-cafe] Re: ANN: Hayoo! beta 0.2 References: <200807231104.03210.t.h@gmx.info> Message-ID: Timo B. H?bel wrote: > we are pleased to announce the second beta release of Hayoo!, a Haskell > API search engine providing advanced features like suggestions, > find-as-you-type, fuzzy queries and much more. > > Visit Hayoo! here: http://holumbus.fh-wedel.de/hayoo > > The major change is the inclusion of all packages available on Hackage, > i.e. the documentation of the latest versions of all packages is included > in the index. > > Unfortunately we had to drop the direct links to the source code, as the > documentation on Hackage is currently generated without source code. But > as soon as this changes, we will include these links again. > > Additionally, we added some tweaks to the interface which make the browser > history/the back button work (at least in Firefox). > > Please bear in mind that this is still a beta release and we are > continuously working on further improvements. > > Any suggestions and feedback is highly welcomed. Well, it is currently not in a usable state: the page randomly inserts funny characters into the text input field. (I'm using Konqueror) Cheers Ben From duncan.coutts at worc.ox.ac.uk Sun Jul 27 20:29:30 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jul 27 20:17:36 2008 Subject: [Haskell-cafe] Cabal files on Windows In-Reply-To: <1622019944.20080728002711@gmail.com> References: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> <1622019944.20080728002711@gmail.com> Message-ID: <1217204970.12754.262.camel@localhost> On Mon, 2008-07-28 at 00:27 +0400, Bulat Ziganshin wrote: > Hello Henk-Jan, > > Sunday, July 27, 2008, 11:36:32 PM, you wrote: > > >> Can anyone point me to a method for including path names with spaces > >> in a cabal file? I would like to add a line similar to the following: > > Have you tried replacing "Program Files" with PROGRA~1? This is the old > > i don't followed discussion but if this meant for distributable > packages, the following problems exist: > > 1. it may be progra~2 or ~3 > 2. it's possible to entirely disable short names generation on ntfs None of this is necessary. Paths with spaces are just fine if you use the Haskell String syntax. Duncan From jwlato at gmail.com Sun Jul 27 22:01:29 2008 From: jwlato at gmail.com (John Lato) Date: Sun Jul 27 21:51:15 2008 Subject: [Haskell-cafe] Cabal files on Windows In-Reply-To: <1217190323.12754.252.camel@localhost> References: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> <1217190323.12754.252.camel@localhost> Message-ID: <9979e72e0807271901h337738b2iefb751f24ef7a987@mail.gmail.com> On Sun, Jul 27, 2008 at 3:25 PM, Duncan Coutts wrote: > > On Sat, 2008-07-26 at 20:23 -0500, John Lato wrote: >> Hello, >> >> Can anyone point me to a method for including path names with spaces >> in a cabal file? I would like to add a line similar to the following: >> include-dirs: C:\Program Files\program\include >> and of course a corresponding library as well. > > Use Haskell String syntax for paths that contain spaces: > > include-dirs: "C:\\Program Files\\program\\include" Hi Duncan, Thanks, this worked (mostly). Although I had to change the line to include-dirs: "\"C:\\Program Files\\program\\include\"" so that the path would be passed properly to cpp through c2hs. Is this documented anywhere? I've been poring over the cabal guide trying to find this, with no success. Thank you, John From mblazevic at stilo.com Sun Jul 27 22:49:43 2008 From: mblazevic at stilo.com (=?UTF-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sun Jul 27 22:37:17 2008 Subject: [Haskell-cafe] Control.Concurrent.forkIO versus Control.Parallel.par Message-ID: <54682.1217213383@magma.ca> Hello. I have a question about parallel computation in Haskell. After browsing the GHC library documentation, I was left with impression that there are two separate mechanisms for expressing concurrency: Control.Parallel.par for pure computations and Control.Concurrent.forkIO for computations in IO monad. This dichotomy becomes a problem when one tries to use concurrency from a monad transformer, though I'm sure that's not the only such situation. One cannot assume that the base monad is IO so forkIO cannot be used, while Control.Parallel.par won't run monads. My first solution was to replace the base monad class for the monad transformer by the following ParallelizableMonad class: ---------------------------------------------------------------------------- class Monad m => ParallelizableMonad m where parallelize :: m a -> m b -> m (a, b) parallelize ma mb = do a <- ma b <- mb return (a, b) instance ParallelizableMonad Identity where parallelize (Identity a) (Identity b) = Identity (a `par` (b `pseq` (a, b))) instance ParallelizableMonad IO where parallelize ma mb = do va <- newEmptyMVar vb <- newEmptyMVar forkIO (ma >>= putMVar va) forkIO (mb >>= putMVar vb) a <- takeMVar va b <- takeMVar vb return (a, b) ---------------------------------------------------------------------------- I tested this solution, and it worked for IO computations in the sense that they used both CPUs. The test also ran slower on two CPUs that on one, but that's beside the point. Then I realized that par can, in fact, be used on any monad, it just needs a little nudge: ---------------------------------------------------------------------------- parallelize :: m a -> m b -> m (a, b) parallelize ma mb = let a = ma >>= return b = mb >>= return in a `par` (b `pseq` liftM2 (,) a b) ---------------------------------------------------------------------------- However, in this version the IO monadic computations still appear to use only one CPU. I cannot get par to parallelize monadic computations. I've used the same command-line options in both examples: -O -threaded and +RTS -N2. What am I missing? From vigalchin at gmail.com Mon Jul 28 00:54:42 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 00:44:28 2008 Subject: [Haskell-cafe] multicore programming ... Message-ID: <5ae4f2ba0807272154k5e96114ej5d4825a8b78b7938@mail.gmail.com> Hello, I have written quite a bit of multi-threaded code in ANSI C and C++ using mainly Posix threads and some using Win32 API threads. IMO now seems to be a huge opportunity for FPLs to shine .. In any case, now there seems to be an emerging crisis in the computer industry in multithread scalability over large multicore: http://www.hackinthebox.org/modules.php?op=modload&name=News&file=article&sid=27292&mode=thread&order=0&thold=0. This is kind of a "wrag" quote. Do others have more substantial URLs on programming large multi-cores? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080727/7d85fca6/attachment.htm From s.clover at gmail.com Mon Jul 28 01:20:50 2008 From: s.clover at gmail.com (Sterling Clover) Date: Mon Jul 28 01:10:41 2008 Subject: [Haskell-cafe] Control.Concurrent.forkIO versus Control.Parallel.par In-Reply-To: <54682.1217213383@magma.ca> References: <54682.1217213383@magma.ca> Message-ID: I think a better way to look at it is that Haskell has two separate mechanisms for different *notions* of concurrency -- forkIO for actual concurrent computation which needs explicit threads and communication (and within that, either semaphore-based communication with MVars or transactional control with TVars and STM), and par for parallelism which is to express computations that are innately parallel. See, e.g. the GHC users manual which defines them as such: * Parallelism means running a Haskell program on multiple processors, with the goal of improving performance. Ideally, this should be done invisibly, and with no semantic changes. * Concurrency means implementing a program by using multiple I/O- performing threads. While a concurrent Haskell program can run on a parallel machine, the primary goal of using concurrency is not to gain performance, but rather because that is the simplest and most direct way to write the program. Since the threads perform I/O, the semantics of the program is necessarily non-deterministic. (http://www.haskell.org/ghc/docs/latest/html/users_guide/lang- parallel.html) In any case, I suspect that your second parallelize function doesn't work right because \x -> x >>= return is an effective no-op, modulo strictness characteristics of >>=. And in any case, it can't be evaluated until it is called in a particular monadic "environment" which is provided, sequencing and all, via liftM2. One can't parallelize in an arbitrary monad in any case, at least without making a number of decisions. E.g., what's the resultant state after two parallel computations are run in a state monad? So if you're using concurrency with a monad transformer, you probably might want to start by stripping back the layers of the concurrent part of your algorithm to the minimum possible, and then explicitly managing passing state into the various forked computations, which can then be wrapped in as many runReaderT or such calls as necessary. On another, general, note, unless you're very careful, mixing IO into your algorithm will probably result in very underperformant parallel code, since it will be IO rather than processor bound. Again the point from the GHC manual that "the primary goal of using concurrency is not to gain performance, but rather because that is the simplest and most direct way to write the program" seems appropriate. Additionally, many have found it easier at this stage to get good performance out of writing parallel code with concurrent mechanisms rather than `par`, because careless use of `par` will tend to add as much overhead in spark creation as is saved with multiprocessing, while an explicit work queue can be easier to reason about. Regards, S. On Jul 27, 2008, at 10:49 PM, Mario Bla?evi? wrote: > > Hello. I have a question about parallel computation in Haskell. > After browsing the GHC library documentation, I was left with > impression that there are two separate mechanisms for expressing > concurrency: Control.Parallel.par for pure computations and > Control.Concurrent.forkIO for computations in IO monad. > > This dichotomy becomes a problem when one tries to use > concurrency from a monad transformer, though I'm sure that's not > the only such situation. One cannot assume that the base monad is > IO so forkIO cannot be used, while Control.Parallel.par won't run > monads. My first solution was to replace the base monad class for > the monad transformer by the following ParallelizableMonad class: > > ---------------------------------------------------------------------- > ------ > class Monad m => ParallelizableMonad m where > parallelize :: m a -> m b -> m (a, b) > parallelize ma mb = do a <- ma > b <- mb > return (a, b) > > instance ParallelizableMonad Identity where > parallelize (Identity a) (Identity b) = Identity (a `par` (b > `pseq` (a, b))) > > instance ParallelizableMonad IO where > parallelize ma mb = do va <- newEmptyMVar > vb <- newEmptyMVar > forkIO (ma >>= putMVar va) > forkIO (mb >>= putMVar vb) > a <- takeMVar va > b <- takeMVar vb > return (a, b) > ---------------------------------------------------------------------- > ------ > > I tested this solution, and it worked for IO computations in the > sense that they used both CPUs. The test also ran slower on two > CPUs that on one, but that's beside the point. > > Then I realized that par can, in fact, be used on any monad, it > just needs a little nudge: > > ---------------------------------------------------------------------- > ------ > parallelize :: m a -> m b -> m (a, b) > parallelize ma mb = let a = ma >>= return > b = mb >>= return > in a `par` (b `pseq` liftM2 (,) a b) > ---------------------------------------------------------------------- > ------ > > However, in this version the IO monadic computations still appear > to use only one CPU. I cannot get par to parallelize monadic > computations. I've used the same command-line options in both > examples: -O -threaded and +RTS -N2. What am I missing? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lrpalmer at gmail.com Mon Jul 28 01:32:55 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 28 01:22:40 2008 Subject: [Haskell-cafe] Control.Concurrent.forkIO versus Control.Parallel.par In-Reply-To: <54682.1217213383@magma.ca> References: <54682.1217213383@magma.ca> Message-ID: <7ca3f0160807272232s526fdf3emadda29bb996caa9d@mail.gmail.com> On Mon, Jul 28, 2008 at 2:49 AM, Mario Bla?evi? wrote: > parallelize :: m a -> m b -> m (a, b) > parallelize ma mb = let a = ma >>= return > b = mb >>= return > in a `par` (b `pseq` liftM2 (,) a b) See Sterling's reply for an actual answer to your question, but note that one of the monad laws is: m >>= return = m (i.e. return is a right identity of bind) That means your code can be reduced to: parallelize ma mb = ma `par` (mb `pseq` liftM2 (,) ma mb) Which, as Sterling points out, is *not* doing what you think it is. Luke From vigalchin at gmail.com Mon Jul 28 01:54:04 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 01:43:50 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <1216554681.6279.345.camel@localhost> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> Message-ID: <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> Hi Duncan and Brandon, I am moving to the ForeignPtr strategy. However, I always try to learn from where I am before going to a new approach. I have discovered by debugging that the AIOCB peek is working; however, passing the "peeked" AIOCB back to the caller(i.e. the test program) is not working .. please let me try to demonstrate below. I have been staring at my Haskell code many, many times .... sigh ... 0) IN PEEK CODE .. aioErrorCode => 115 IN PEEK CODE .. aioReturnValue => 0 aioWrite after aio_write IN PEEK CODE .. aioErrorCode => 115 IN PEEK CODE .. aioReturnValue => 0 *************aiocb dump*************** fd => 3 opcode => 1 prio => 0 offset => 0 nbytes => 20 next => 0x00000000 absprio => 0 policy => 0 errocode => 115 <<<< correct ... INPROGRESS errno return value => 0 <<<<<<<<<<<<<<<<<<<< return from call of Haskell function aioWrite here ... below "errocode" has changed from 115 to 0 ... somehow my "return AIOCB" is corrupting the "state"/value of AIOCB .... *****************aioWrite dumpAIOCB *************aiocb dump*************** fd => 3 opcode => 0 prio => 0 offset => 0 nbytes => 20 next => 0x00000000 absprio => 0 policy => 0 errocode => 0 <<<< incorrect "Errno" ... should still be IN PROGRESS. return value => 0 1) aioWrite ... the function marshalling(poke) and unmarshalling(peek) an AIOCB: aioWrite :: AIOCB -> IO AIOCB aioWrite aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb putStrLn "aioWrite before aio_write" aiocb1 <- peek p_aiocb dumpAIOCB aiocb1 throwErrnoIfMinus1 "aioWrite" (c_aio_write p_aiocb) aiocb <- peek p_aiocb putStrLn "aioWrite after aio_write" aiocb <- peek p_aiocb dumpAIOCB aiocb -- putStrLn "aioWrite after aio_write" -- aiocb1 <- peek p_aiocb -- dumpAIOCB aiocb1 return (aiocb) foreign import ccall safe "aio.h aio_write" c_aio_write :: Ptr AIOCB -> IO CInt 2) an AIOCB: data LioOps = LioRead | LioWrite | LioNop data AIOCB = AIOCB { aioFd :: Fd, aioLioOpcode :: Int, aioReqPrio :: Int, aioOffset :: FileOffset, aioBuf :: Ptr Word8, aioBytes :: ByteCount, aioSigevent :: Sigevent, -- Internal members aioNext :: Ptr AIOCB, aioAbsPrio :: Int, aioPolicy :: Int, aioErrorCode :: Int, aioReturnValue :: ByteCount } 3) poke/peek instance Storable AIOCB where sizeOf _ = (#const sizeof (struct aiocb)) alignment _ = 1 poke p_AIOCB (AIOCB aioFd aioLioOpcode aioReqPrio aioOffset aioBuf aioBytes aioSigevent aioNext aioAbsPrio aioPolicy aioErrorCode aioReturnValue) = do (#poke struct aiocb, aio_fildes) p_AIOCB aioFd (#poke struct aiocb, aio_lio_opcode) p_AIOCB aioLioOpcode (#poke struct aiocb, aio_reqprio) p_AIOCB aioReqPrio (#poke struct aiocb, aio_offset) p_AIOCB aioOffset (#poke struct aiocb, aio_buf) p_AIOCB aioBuf (#poke struct aiocb, aio_nbytes) p_AIOCB aioBytes (#poke struct aiocb, aio_sigevent) p_AIOCB aioSigevent (#poke struct aiocb, __next_prio) p_AIOCB aioNext (#poke struct aiocb, __abs_prio) p_AIOCB aioAbsPrio (#poke struct aiocb, __policy) p_AIOCB aioPolicy (#poke struct aiocb, __error_code) p_AIOCB aioErrorCode (#poke struct aiocb, __return_value) p_AIOCB aioReturnValue peek p_AIOCB = do aioFd <- (#peek struct aiocb, aio_fildes) p_AIOCB aioLioOpcode <- (#peek struct aiocb, aio_lio_opcode) p_AIOCB aioReqPrio <- (#peek struct aiocb, aio_reqprio) p_AIOCB aioOffset <- (#peek struct aiocb, aio_offset) p_AIOCB aioBuf <- (#peek struct aiocb, aio_buf) p_AIOCB aioBytes <- (#peek struct aiocb, aio_nbytes) p_AIOCB aioSigevent <- (#peek struct aiocb, aio_sigevent) p_AIOCB aioNext <- (#peek struct aiocb, __next_prio) p_AIOCB aioAbsPrio <- (#peek struct aiocb, __abs_prio) p_AIOCB aioPolicy <- (#peek struct aiocb, __policy) p_AIOCB aioErrorCode <- (#peek struct aiocb, __error_code) p_AIOCB putStrLn ("IN PEEK CODE .. aioErrorCode => " ++ (show aioErrorCode)) aioReturnValue <- (#peek struct aiocb, __return_value) p_AIOCB putStrLn ("IN PEEK CODE .. aioReturnValue => " ++ (show aioReturnValue)) return (AIOCB aioFd aioLioOpcode aioReqPrio aioOffset aioBuf aioBytes aioSigevent aioNext aioAbsPrio aioPolicy aioErrorCode aioReturnValue) Kind regards, Vasili On Sun, Jul 20, 2008 at 6:51 AM, Duncan Coutts wrote: > > On Sat, 2008-07-19 at 23:55 -0500, Galchin, Vasili wrote: > > yes Duncan I am trying to pass-by-value. I am familiar with > > ForeignPtr; however, I don't comprehend what you and Brandon are > > suggesting to do. Could either of you provide a code illustration or > > point at existing code to illustrate your approach? > > Take a look at John Meacham's RSA example. > > So at the moment you're using using Storable and a Haskell record, say: > > data AIOCB = AIOCB { > ... > } > > and we're suggesting instead: > > newtype AIOCB = AIOCB (ForeignPtr AIOCB) > > then to access a member use hsc2hs: > > getBlah :: AIOCB -> IO Blah > getBlah (AIOCB fptr) = > withForeignPtr fptr $ \ptr -> {# peek aiocb,blah #} ptr > > So you only access the parts you need and keep the aiocb C struct > allocated on the heap (use mallocForeignPtr). > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/ce8c9b18/attachment.htm From allbery at ece.cmu.edu Mon Jul 28 02:09:19 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jul 28 01:59:05 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> Message-ID: On 2008 Jul 28, at 1:54, Galchin, Vasili wrote: > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb As I understand it, you can't do this;you must use the same aiocb throughout (that is, the same chunk of memory, not merely the same values; there is quite possibly a kernel mapping to it which you can't change or copy, or a pointer to the original aiocb is kept as internal state in the aio library so it can update the errno and result on the fly). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/6aff1081/attachment.htm From vigalchin at gmail.com Mon Jul 28 02:36:06 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 02:25:52 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> Message-ID: <5ae4f2ba0807272336j20129d39lce374acab4b5ee70@mail.gmail.com> Hi Brandon, So even if I go to ForeignPtr is a problem? And/Or is this a "by reference" vs "by value" issue? Kind regards, Vasili On Mon, Jul 28, 2008 at 1:09 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On 2008 Jul 28, at 1:54, Galchin, Vasili wrote: > > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb > > > As I understand it, you can't do this;you must use the same aiocb > throughout (that is, the same chunk of memory, not merely the same values; > there is quite possibly a kernel mapping to it which you can't change or > copy, or a pointer to the original aiocb is kept as internal state in the > aio library so it can update the errno and result on the fly). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/ce05499d/attachment.htm From vigalchin at gmail.com Mon Jul 28 02:41:25 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 02:31:11 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> Message-ID: <5ae4f2ba0807272341m3be26b41h774335cc380f010a@mail.gmail.com> Hi Brandon, So based on what you are saying I kind of need a Haskell AIO "imperative"/monadic function that basically returns a handle that is associated with this AIOCB chunk-of-memory .... This handle gets passed around during an AIO I/O session?? Sorry for talking too "imperatively" ;^) <<< smiley face ;^) Vasili On Mon, Jul 28, 2008 at 1:09 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On 2008 Jul 28, at 1:54, Galchin, Vasili wrote: > > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb > > > As I understand it, you can't do this;you must use the same aiocb > throughout (that is, the same chunk of memory, not merely the same values; > there is quite possibly a kernel mapping to it which you can't change or > copy, or a pointer to the original aiocb is kept as internal state in the > aio library so it can update the errno and result on the fly). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/e82bc90a/attachment.htm From allbery at ece.cmu.edu Mon Jul 28 03:04:22 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jul 28 02:54:08 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807272336j20129d39lce374acab4b5ee70@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> <5ae4f2ba0807272336j20129d39lce374acab4b5ee70@mail.gmail.com> Message-ID: <41FF38BF-BE70-44BC-A64E-23C0936FEDCC@ece.cmu.edu> On 2008 Jul 28, at 2:36, Galchin, Vasili wrote: > Hi Brandon, > > So even if I go to ForeignPtr is a problem? And/Or is this a > "by reference" vs "by value" issue? As I read your code, you're allocating a C object, poking the Haskell fields into it, and passing it on, then peeking the values back out. This won't work; the C pointer value passed to aio_write() is the value that must be passed to subsequent operations on that aiocb (such as aio_return()). More to the point: the exact chunk of memory passed to aio_write(), unmodified, must be passed to any other aio functions checking for or blocking on completion of the write. You may not move it around or arbitrarily change values within it. You could do this if your Haskell aiocb also retained the ForeignPtr to the originally allocated C object... but after the initial pokes, the only thing you can safely do with that object is pass it to C and peek the current values out of it, unless the C API specifically says you can modify fields within it while I/O operations are pending (and I'd be rather surprised if it did). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/760ac09e/attachment.htm From allbery at ece.cmu.edu Mon Jul 28 03:14:26 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jul 28 03:04:12 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807272341m3be26b41h774335cc380f010a@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> <5ae4f2ba0807272341m3be26b41h774335cc380f010a@mail.gmail.com> Message-ID: <23FCA242-DCEC-4B53-9A36-875010EDA353@ece.cmu.edu> On 2008 Jul 28, at 2:41, Galchin, Vasili wrote: > So based on what you are saying I kind of need a Haskell AIO > "imperative"/monadic function that basically returns a handle that > is associated with this AIOCB chunk-of-memory .... This handle gets > passed around during an AIO I/O session?? Sorry for talking too > "imperatively" ;^) <<< smiley face ;^) I/O *is* monadic in Haskell, so you're kinda there anyway. I would in fact use a custom state (AIO = StateT ForeignPtr IO) if I were doing it; I would hide the constructor so that the only way to alter values is to call specific function(s) returning filled-in aiocbs as initialized and passed to aio_read/aio_write, then provide accessors for the contents (which if necessary can call aio_return, aio_suspend, or aio_error). Returning from the monad would invoke aio_suspend to wait for completion or aio_cancel to abort. (Hm. Could be argued that we want ContT here to represent the two possibilities.) I note from my local documentation that (a) indeed you must not modify the aiocb after passing it to aio_read/aio_write and (b) the offset value should not be read, much less modified, because it could change during the async I/O (and not in a reliably useful fashion; consider buffering). And as I said earlier, the exact same memory block (not merely a copy of it) must be used for the same aiocb. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/9991851e/attachment.htm From jeanphilippe.bernardy at gmail.com Mon Jul 28 03:39:37 2008 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Mon Jul 28 03:29:28 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 References: <20080727204932.GC13904@scytale.galois.com> Message-ID: Niklas Broberg gmail.com> writes: > > > The gtk frontend should not suffer from this: > > > > yi -fgtk > > C:\Documents and Settings\Niklas Broberg>yi -fgtk > yi: exception :: System.Glib.GError.GError I'm out of ideas. Maybe you could ask Krasimir Angelov, which did the win32 port. > ps. If I installed it with -f-vty -fgtk, shouldn't gtk be the default > when running? It is; I was just making sure. Cheers, JP. From jeanphilippe.bernardy at gmail.com Mon Jul 28 03:41:08 2008 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Mon Jul 28 03:34:49 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 References: <20080727230807.GD3357@self.local> Message-ID: stefan kersten k-hornz.de> writes: > any ideas what's going wrong? is it finally time to upgrade my ghc > installation? Yep; I think this is fixed in later GHCs. -- JP From frantisek.kocun at gmail.com Mon Jul 28 04:41:50 2008 From: frantisek.kocun at gmail.com (fero) Date: Mon Jul 28 04:31:35 2008 Subject: [Haskell-cafe] Best book/tutorial on category theory and its applications Message-ID: <18686250.post@talk.nabble.com> Hi, I would like to buy some booke on category theory and its applications. Can you recommend me the best? Here is what I like: 1. Easy to understatnd, concise book. I like e.g. "Gentle introduction to Haskell" it was quite good with a little of text. There are bigger tutorials in number of pages but there is much less in them. I downloaded "Categories for Software Engineering". I read 2 first chapters, but there is a lot of text and sometimes I need to look on internet to seach for exact definitions/equations which I can understand better. That's why I don't like books "for Dummies" - lot of text, little of content, very shallow and lot of slang. I like "The Haskell: School of expression" and I am searching for another book to read after I finish this. The style of SOE is suitable for me. It is very clear with good theory and examples. But now I want book mainly about theory and the examples as second. 2. With applications and its examples. I would like to see some examples. I doesn't matter if it will be only in pseudo-language in Haskell or another language. What do you think about "Categories and Computer Science (Cambridge Computer Science Texts)" at http://www.amazon.com/Categories-Computer-Science-Cambridge-Texts/dp/0521422264/ref=si3_rdr_bb_product ? Thanks Fero -- View this message in context: http://www.nabble.com/Best-book-tutorial-on-category-theory-and-its-applications-tp18686250p18686250.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From d.kahlenberg at googlemail.com Mon Jul 28 05:49:20 2008 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Mon Jul 28 05:39:04 2008 Subject: [Haskell-cafe] [Haskell Beginner] Compiling wxhaskell fails for me Message-ID: <5d4de89e0807280249g1bb95c79ra9d607e234147182@mail.gmail.com> Hi, I try to build the current wxhaskell stuff from the darcs repository on the sh provided by msys with mingw32 (`uname -a' : MINGW32_NT-5.1 ... 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys), but it fails with the message `wx/graphics.h' isn't found, when it comes to build the wxc part. On the wxhaskell site they advice to use the 2.6.x version of the wxWidgets distribution, which I followed so far. The tool call which sets the wxversion variable (`wx-config --version') is executed and returns 2.6.4. The searched hosted graphics.h as I determined seems available as part of the 2.8.x version of wxwidgets at first. Now my question: Why does the build process search for it, especially how do I get it to succeed. Would I have to use the 2.8.x version against the recommendation? Has anyone of you successfully built the recommended version of the bindings, if yes - how? Could you share? Did I forget to build something on the wxwidgets side? Thank you so far Daniel. From Malcolm.Wallace at cs.york.ac.uk Mon Jul 28 06:11:18 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Jul 28 06:05:52 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> Message-ID: <20080728111118.7eafcacf.Malcolm.Wallace@cs.york.ac.uk> > FYI: Haskell's OpenGL binding has just been dropped from GHC's > extralibs, which means that it will no longer be kept in sync with GHC > development, at least not by GHC HQ. > > GHC HQ has its hands full and -generally speaking - extralibs are to > be replaced by H(L)P, the Haskell (Library) Platform: As someone who uses HOpenGL as a component for my own research, I must say that I don't entirely follow the logic of dropping it from extralibs. I mean, I fully appreciate that ghc-HQ wants to remove extralibs from its sphere of responsibility. And I also very much support the new Haskell Platform idea. But I did also get the impression that the HP was going to start from extralibs and build outwards. I can't see how dropping existing working and tested libraries from a mini-platform, is any help at all to the new maintainers of HP. It is only likely to give grief to users who expect HOpenGL to be part of HP, and then later more grief to the HP maintainers when they try to re-integrate it, after allowing it to suffer a period of bit-rot. Regards, Malcolm From vigalchin at gmail.com Mon Jul 28 06:19:01 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 06:08:49 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <41FF38BF-BE70-44BC-A64E-23C0936FEDCC@ece.cmu.edu> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807272254s5ae23f6ex752dfca960999838@mail.gmail.com> <5ae4f2ba0807272336j20129d39lce374acab4b5ee70@mail.gmail.com> <41FF38BF-BE70-44BC-A64E-23C0936FEDCC@ece.cmu.edu> Message-ID: <5ae4f2ba0807280319k1a3b29e8q6857fd6342f7a21@mail.gmail.com> Brandon, Your reading on my code is quite correct. So you are suggesting that the Haskell aiocb contain a ForeignPtr to actual aiocb that is passed the C functions. In this scenario, whose responsibility to allocate the "chunk" of memory for the aiocb? Vasili On Mon, Jul 28, 2008 at 2:04 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On 2008 Jul 28, at 2:36, Galchin, Vasili wrote: > > Hi Brandon, > > So even if I go to ForeignPtr is a problem? And/Or is this a "by > reference" vs "by value" issue? > > > As I read your code, you're allocating a C object, poking the Haskell > fields into it, and passing it on, then peeking the values back out. This > won't work; the C pointer value passed to aio_write() is the value that must > be passed to subsequent operations on that aiocb (such as aio_return()). > More to the point: the exact chunk of memory passed to aio_write(), > unmodified, must be passed to any other aio functions checking for or > blocking on completion of the write. You may not move it around or > arbitrarily change values within it. > > You could do this if your Haskell aiocb also retained the ForeignPtr to the > originally allocated C object... but after the initial pokes, the only thing > you can safely do with that object is pass it to C and peek the current > values out of it, unless the C API specifically says you can modify fields > within it while I/O operations are pending (and I'd be rather surprised if > it did). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/ab3d755d/attachment-0001.htm From DekuDekuplex at Yahoo.com Mon Jul 28 07:04:17 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Jul 28 06:54:09 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications References: <18686250.post@talk.nabble.com> Message-ID: On Mon, 28 Jul 2008 01:41:50 -0700 (PDT), fero wrote: > >Hi, >I would like to buy some booke on category theory and its applications. Can >you recommend me the best? Recently, I had to study some category theory in order to prepare for a local category theory study group meeting, and after some comparison, settled on the following relatively short set (128 pp.) of notes, condensed from a much thicker book (303 pp.) on category theory: Category Theory Lecture Notes for ESSLLI Michael Barr, Department of Mathematics and Statistics, McGill University Charles Wells, Department of Mathematics, Case Western Reserve University http://www.math.upatras.gr/~cdrossos/Docs/B-W-LectureNotes.pdf The above-mentioned lecture notes were condensed from the following book, and then rearranged to present category theory from a computer science perspective: Toposes, Triples and Theories by Michael Barr and Charles Wells http://www.cwru.edu/artsci/math/wells/pub/ttt.html According to the above-referenced home page for this book: > The original book, Grundlehren der math. Wissenschaften 278. Springer-Verlag, 1983, is now out of print. A revised and corrected version is now available free for downloading. An even shorter book on category theory is the following: A Gentle Introduction to Category Theory - the calculational approach by Maarten M Fokkinga http://wwwhome.cs.utwente.nl/~fokkinga/mmf92b.html However, I did not prefer the above book, despite its brevity, because unlike the other two titles, it did not including any specific material on monads. >What do you think about "Categories and Computer Science (Cambridge Computer >Science Texts)" at >http://www.amazon.com/Categories-Computer-Science-Cambridge-Texts/dp/0521422264/ref=si3_rdr_bb_product >? I haven't read it, so I would need to review it before giving an opinion. I shall keep it in mind, however; thank you for the reference. -- Benjamin L. Russell From igloo at earth.li Mon Jul 28 07:38:42 2008 From: igloo at earth.li (Ian Lynagh) Date: Mon Jul 28 07:28:28 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <4165d3a70807251047x1bb7b812l90d1c25470884907@mail.gmail.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <4165d3a70807251047x1bb7b812l90d1c25470884907@mail.gmail.com> Message-ID: <20080728113842.GA18816@matrix.chaos.earth.li> On Fri, Jul 25, 2008 at 01:47:25PM -0400, Jefferson Heard wrote: > > Is there a list of outstanding bugs somewhere? A few of these are OpenGL/GLUT/OpenAL/ALUT bugs: http://hackage.haskell.org/trac/ghc/query?status=new&status=assigned&status=reopened&component=libraries+%28other%29&order=priority It would be nice to set up an opengl bug tracker so that we can move them out of GHC's trac, incidentally. Thanks Ian From DekuDekuplex at Yahoo.com Mon Jul 28 08:14:04 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Jul 28 08:03:57 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications References: <18686250.post@talk.nabble.com> Message-ID: On Mon, 28 Jul 2008 20:04:17 +0900, Benjamin L.Russell wrote: >>What do you think about "Categories and Computer Science (Cambridge Computer >>Science Texts)" at >>http://www.amazon.com/Categories-Computer-Science-Cambridge-Texts/dp/0521422264/ref=si3_rdr_bb_product >>? > >I haven't read it, so I would need to review it before giving an >opinion. I shall keep it in mind, however; thank you for the >reference. I have just added information on _Categories and Computer Science (Cambridge Computer Science Texts)_ to the HaskellWiki; viz.: Books and tutorials - HaskellWiki http://www.haskell.org/haskellwiki/Books_and_tutorials Incidentally, my earlier references to books on category theory all originally were obtained from the HaskellWiki page on Category Theory: Category theory - HaskellWiki http://haskell.org/haskellwiki/Category_theory#See_also You may find some other useful references there as well. -- Benjamin L. Russell From frantisek.kocun at gmail.com Mon Jul 28 08:41:54 2008 From: frantisek.kocun at gmail.com (frantisek kocun) Date: Mon Jul 28 08:31:37 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications In-Reply-To: References: <18686250.post@talk.nabble.com> Message-ID: Thanks Benjamin, especially for http://haskell.org/haskellwiki/Category_theory#See_also and I found there Haskell wiki. I will take a look at the books as well. Fero On Mon, Jul 28, 2008 at 2:14 PM, Benjamin L. Russell wrote: > On Mon, 28 Jul 2008 20:04:17 +0900, Benjamin L.Russell > wrote: > > > >>What do you think about "Categories and Computer Science (Cambridge > Computer > >>Science Texts)" at > >> > http://www.amazon.com/Categories-Computer-Science-Cambridge-Texts/dp/0521422264/ref=si3_rdr_bb_product > >>? > > > >I haven't read it, so I would need to review it before giving an > >opinion. I shall keep it in mind, however; thank you for the > >reference. > > I have just added information on _Categories and Computer Science > (Cambridge Computer Science Texts)_ to the HaskellWiki; viz.: > > Books and tutorials - HaskellWiki > http://www.haskell.org/haskellwiki/Books_and_tutorials > > Incidentally, my earlier references to books on category theory all > originally were obtained from the HaskellWiki page on Category Theory: > > Category theory - HaskellWiki > http://haskell.org/haskellwiki/Category_theory#See_also > > You may find some other useful references there as well. > > -- Benjamin L. Russell > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/9bf8cef6/attachment.htm From duncan.coutts at worc.ox.ac.uk Mon Jul 28 09:31:15 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jul 28 09:19:23 2008 Subject: [Haskell-cafe] Cabal files on Windows In-Reply-To: <9979e72e0807271901h337738b2iefb751f24ef7a987@mail.gmail.com> References: <9979e72e0807261823h2eb0dcefk82ed2174737ff212@mail.gmail.com> <1217190323.12754.252.camel@localhost> <9979e72e0807271901h337738b2iefb751f24ef7a987@mail.gmail.com> Message-ID: <1217251875.12754.271.camel@localhost> On Sun, 2008-07-27 at 21:01 -0500, John Lato wrote: > On Sun, Jul 27, 2008 at 3:25 PM, Duncan Coutts > > Use Haskell String syntax for paths that contain spaces: > > > > include-dirs: "C:\\Program Files\\program\\include" > > Hi Duncan, > > Thanks, this worked (mostly). Although I had to change the line to > > include-dirs: "\"C:\\Program Files\\program\\include\"" > > so that the path would be passed properly to cpp through c2hs. Oh, that must be a bug. Can you file it here please with details of exactly how to reproduce it: http://hackage.haskell.org/trac/hackage/ > Is this documented anywhere? I've been poring over the cabal guide > trying to find this, with no success. Yes, though perhaps not very clearly: http://haskell.org/cabal/release/latest/doc/users-guide/authors.html#pkg-descr The syntax of the value depends on the field. Field types include: token , filename , directory Either a sequence of one or more non-space non-comma characters, or a quoted string in Haskell 98 lexical syntax. Unless otherwise stated, relative filenames and directories are interpreted from the package root directory. Suggestions for improvement welcome. Even better would be patches. The user guide is in the Cabal repo in doc/Cabal.xml in docbook format. Duncan From duncan.coutts at worc.ox.ac.uk Mon Jul 28 09:33:25 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jul 28 09:21:28 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 In-Reply-To: References: <20080727204932.GC13904@scytale.galois.com> Message-ID: <1217252005.12754.273.camel@localhost> On Mon, 2008-07-28 at 07:39 +0000, Jean-Philippe Bernardy wrote: > Niklas Broberg gmail.com> writes: > > > > > > The gtk frontend should not suffer from this: > > > > > > yi -fgtk > > > > C:\Documents and Settings\Niklas Broberg>yi -fgtk > > yi: exception :: System.Glib.GError.GError > > I'm out of ideas. > Maybe you could ask Krasimir Angelov, which did the win32 port. Try catching the exception and see what message it contains. Use catchGError. Duncan From mblazevic at stilo.com Mon Jul 28 10:30:03 2008 From: mblazevic at stilo.com (Mario Blazevic) Date: Mon Jul 28 10:19:49 2008 Subject: [Haskell-cafe] Control.Concurrent.forkIO versus Control.Parallel.par In-Reply-To: References: <54682.1217213383@magma.ca> Message-ID: <488DD7EB.6060907@stilo.com> Sterling Clover wrote: > I think a better way to look at it is that Haskell has two separate > mechanisms for different *notions* of concurrency -- forkIO for actual > concurrent computation which needs explicit threads and communication > (and within that, either semaphore-based communication with MVars or > transactional control with TVars and STM), and par for parallelism which > is to express computations that are innately parallel. See, e.g. the GHC > users manual which defines them as such: > > ... Yes, I do understand the distinction. My problem is that I'm working on a new concurrency mechanism, in the form of a monad transformer. It should allow user to specify that particular monadic computation should be run in parallel. It appears that will be possible only if the underlying monad is IO, because I can't get par to work. > In any case, I suspect that your second parallelize function doesn't > work right because \x -> x >>= return is an effective no-op, modulo > strictness characteristics of >>=. And in any case, it can't be > evaluated until it is called in a particular monadic "environment" which > is provided, sequencing and all, via liftM2. One can't parallelize in an > arbitrary monad in any case, at least without making a number of > decisions. E.g., what's the resultant state after two parallel > computations are run in a state monad? I see the problem now, thanks. I wonder if it would make sense to add a new defaulted method to Monad class, perhaps a variant of the existing sequence parallelSequence :: [m a] -> m [a] parallelSequence = sequence Then monads that have a way of forking and recombining parallel computations could override the method. > So if you're using concurrency with a monad transformer, you probably > might want to start by stripping back the layers of the concurrent part > of your algorithm to the minimum possible, and then explicitly managing > passing state into the various forked computations, which can then be > wrapped in as many runReaderT or such calls as necessary. I don't have any state to pass, the question is simply whether two monadic values can be run in parallel and then recombined. I can see why that's impossible for State, Cont, and probably some other monads. > On another, general, note, unless you're very careful, mixing IO into > your algorithm will probably result in very underperformant parallel > code, since it will be IO rather than processor bound. I know, the idea was to let the user control which concurrent computations should be run in parallel, if resources allow. > > On Jul 27, 2008, at 10:49 PM, Mario Bla?evi? wrote: > >> >> Hello. I have a question about parallel computation in Haskell. >> After browsing the GHC library documentation, I was left with >> impression that there are two separate mechanisms for expressing >> concurrency: Control.Parallel.par for pure computations and >> Control.Concurrent.forkIO for computations in IO monad. >> >> This dichotomy becomes a problem when one tries to use concurrency >> from a monad transformer, though I'm sure that's not the only such >> situation. One cannot assume that the base monad is IO so forkIO >> cannot be used, while Control.Parallel.par won't run monads. My first >> solution was to replace the base monad class for the monad transformer >> by the following ParallelizableMonad class: >> >> ---------------------------------------------------------------------------- >> >> class Monad m => ParallelizableMonad m where >> parallelize :: m a -> m b -> m (a, b) >> parallelize ma mb = do a <- ma >> b <- mb >> return (a, b) >> >> instance ParallelizableMonad Identity where >> parallelize (Identity a) (Identity b) = Identity (a `par` (b `pseq` >> (a, b))) >> >> instance ParallelizableMonad IO where >> parallelize ma mb = do va <- newEmptyMVar >> vb <- newEmptyMVar >> forkIO (ma >>= putMVar va) >> forkIO (mb >>= putMVar vb) >> a <- takeMVar va >> b <- takeMVar vb >> return (a, b) >> ---------------------------------------------------------------------------- >> >> >> I tested this solution, and it worked for IO computations in the sense >> that they used both CPUs. The test also ran slower on two CPUs that on >> one, but that's beside the point. >> >> Then I realized that par can, in fact, be used on any monad, it just >> needs a little nudge: >> >> ---------------------------------------------------------------------------- >> >> parallelize :: m a -> m b -> m (a, b) >> parallelize ma mb = let a = ma >>= return >> b = mb >>= return >> in a `par` (b `pseq` liftM2 (,) a b) >> ---------------------------------------------------------------------------- >> >> >> However, in this version the IO monadic computations still appear to >> use only one CPU. I cannot get par to parallelize monadic >> computations. I've used the same command-line options in both >> examples: -O -threaded and +RTS -N2. What am I missing? >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Mario Blazevic mblazevic@stilo.com Stilo Corporation This message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, copying, or distribution is strictly prohibited. If you are not the intended recipient(s) please contact the sender by reply email and destroy all copies of the original message and any attachments. From jefferson.r.heard at gmail.com Mon Jul 28 11:20:42 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Mon Jul 28 11:10:27 2008 Subject: [Haskell-cafe] Re: [HOpenGL] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <4165d3a70807251005y6f2b6611ucff6c65c52cebcdf@mail.gmail.com> Message-ID: <4165d3a70807280820j2081bd47wae0afff9eb19e22@mail.gmail.com> Right. Just got back from being on travel, but the bug was that genNames hangs and fails to return on WinXP 32 when trying to return display list objects. It turns out that you can pretend that display lists are already allocated with most video cards, so it's not a big deal, but it was a seriously confusing bug for a day or two. when I get back to the office, I'll forward the offending code. On Fri, Jul 25, 2008 at 4:58 PM, Christopher Lane Hinson wrote: > > HOpenGL is in remarkably good shape for being unmaintained for several > years. I think the quiet on the HOpenGL mailing list speaks positively to > the quality of the library. > > Perhaps those of us who have an interest in HOpenGL can arrange to work as > comaintainers. > > I think I could be bothered to do weekly builds against GHC to make sure we > stay up to date. I'll set that up in the next month or so. > > Jeff, please point me to your bug. I'd like to take a look. > > --Lane > > On Fri, 25 Jul 2008, Jefferson Heard wrote: > >> I don't know how much I can do to keep them in sync, as I don't know >> anything about the HLP, however, I'm actively using OpenGL 2.1 in >> Haskell for research and prototyping and the inclusion of OpenGL in >> Haskell has been central to my case for using it in my workplace. I >> don't know what I can do to help, but if anyone will point me in the >> right direction, I'll try to throw some inertia at it... >> >> -- Jeff > > _______________________________________________ > HOpenGL mailing list > HOpenGL@haskell.org > http://www.haskell.org/mailman/listinfo/hopengl > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From nielsadb at gmail.com Mon Jul 28 12:22:34 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Mon Jul 28 12:12:22 2008 Subject: [Haskell-cafe] Literate program implementing text editor In-Reply-To: <1216853048.12754.52.camel@localhost> References: <48878F13.4050306@ukfsn.org> <1216853048.12754.52.camel@localhost> Message-ID: <488DF24A.5070502@gmail.com> Duncan Coutts wrote: > On Wed, 2008-07-23 at 21:05 +0100, Eric wrote: > >> Hi all, >> >> I wanted to embark on a Haskell program that implements a simple text >> editor. Before doing so, however, I thought that I should ask: Does >> anyone know of a literate Haskell program already in existence that does >> the job? >> > > I don't know about simple, but there is Yi and once upon a time it was > simple before everyone added lots of features to it. It's probably not > literate Haskell though. > I've found it very hard to compile Yi, at least using the stock Haskell packages that come with my Ubuntu system. For starters, it requires GHC 6.8.3. The latest milestone release (M3) is quite old already. Does anyone know when M4 is planned to come out? And will it require a bleeding edge Haskell environment like the development version? Niels From gwern0 at gmail.com Mon Jul 28 14:05:09 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Jul 28 13:56:19 2008 Subject: [Haskell-cafe] ANN: Mueval 0.3.1, 0.4, 0.4.5, 0.4.6, 0.5 Message-ID: <20080728180509.GA21396@craft> Hi everyone. So there've been a number of releases of Mueval lately. I figured I'd tell you about them. WHERE As always, you can 'cabal install mueval', or get it from Hackage , or get it from the new Darcs repository . Usage remains as before, but see below for numerous examples, or the file 'tests.sh'. WHAT'S INTERESTING Mueval is now even more capable. I've fixed the big security hole Spencer identified, so right now I know of no vulnerabilities in Mueval (or even potentially dangerous aspects). More interestingly is how close Mueval is now to Lambdabot's capabilities: we can evaluate all the same expressions, and Mueval now even can do QuickCheck tests. The only missing pieces is that currently there's no interface to Smallcheck yet (but hardly anyone in #haskell seems to use that, so I'm considering not even bothering), and currently there's no way to do @let or qualified imports. I hope to add these two missing pieces for the next release - and then I can finally remove hs-plugins from Lambdabot. CHANGES 0.5 Adds support for Unicode in expressions! bash$ mueval -e 'let (?) = (+) in ? 5 5' 10" Adds support for QuickCheck tests! bash-3.2$ mueval -E -e 'myquickcheck (\x -> x == x)' "\"OK, passed 500 tests.\\n\"" bash-3.2$ mueval -E -e 'myquickcheck (\x -> x+1 == x+2)' "\"Falsifiable, after 0 tests:\\n0\\n\"" --inferred-type prints out even more information! bash-3.2$ mueval --inferred-type --expression 'foldr (\x y -> concat ["(f ",x," ",y,")"]) "z" (map show [1..5])' foldr (\x y -> concat ["(f ",x," ",y,")"]) "z" (map show [1..5]) [Char] "\"(f 1 (f 2 (f 3 (f 4 (f 5 z)))))\"" 0.4.6 A README! --print-type was renamed to --inferred-type so as to avoid short-option ambiguity! Refactoring! Haddocks look somewhat nicer! 0.4.5 Even more refactoring and modularization! Performance improvements! (ie. 'call error sooner so mueval doesn't hang around waiting for the timeout to expire') 0.4 Close major security hole! No more: mueval --expression "Foreign.unsafePerformIO $ readFile \"foo\"" (Since now one must declare module imports, and cannot circumvent them due to a certain bad behaviour of the GHC API.) 0.3.1 Blacklist unsafe keywords! mueval --expression "Foreign.unsafePerformIO $ readFile \"/etc/passwd\"" mueval: Unsafe functions to use mentioned. Looser resource limits (so hopefully more people can run it)! A Darcs repository! darcs get http://code.haskell.org/mubot/ (And of course mixed in throughout these changes are various test additions; it's a respectable little suite now.) -- gwern Propaganda Security rip CIO VIP Pershing O/S MPRI JASON AMEMB -------------- 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/20080728/de56bf56/attachment.bin From agl at imperialviolet.org Mon Jul 28 14:28:48 2008 From: agl at imperialviolet.org (Adam Langley) Date: Mon Jul 28 14:18:32 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <1217072053.6478.19.camel@localhost> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> <3e62d4360807251332x50406262rdff72d9b5ee4be12@mail.gmail.com> <396556a20807251345g210a6075y2876a3fe871ca510@mail.gmail.com> <1217072053.6478.19.camel@localhost> Message-ID: <396556a20807281128h17363fefs9d4a4c3900714c57@mail.gmail.com> On Sat, Jul 26, 2008 at 4:34 AM, Levi Greenspan wrote: > client: internal error: awaitEvent: descriptor out of range > (GHC version 6.8.3 for i386_unknown_linux) > Please report this as a GHC bug: > http://www.haskell.org/ghc/reportabug > Aborted > > This is caused by having more file descriptors than FD_SETSIZE (which is > 1024) on my system. So clearly select() doesn't scale to the numbers I > need :-( Now, *thats* a good point. I'd still suggest that taking the time to add epoll support to the threaded runtime would be better for you(, and for everyone else!) than avoiding the use of GHC threads. But, with that error, you're correct that the current select based system is insufficient. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From catamorphism at gmail.com Mon Jul 28 14:52:43 2008 From: catamorphism at gmail.com (Tim Chevalier) Date: Mon Jul 28 14:42:26 2008 Subject: [Haskell-cafe] Best book/tutorial on category theory and its applications In-Reply-To: <18686250.post@talk.nabble.com> References: <18686250.post@talk.nabble.com> Message-ID: <4683d9370807281152v5565fcf2x79a2da91e7ed5215@mail.gmail.com> I've only read the beginning, but I recommend _Conceptual Mathematics_ by Lawvere and Schanuel for a *very* gentle introduction (seriously, you could probably teach category theory to ten-year-olds out of this book.) Nothing about applications there, though. Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "I haven't got the slightest idea how to change people, but still I keep a long list of prospective candidates just in case I should ever figure it out." --David Sedaris From dpiponi at gmail.com Mon Jul 28 16:40:51 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Jul 28 16:30:34 2008 Subject: [Haskell-cafe] Best book/tutorial on category theory and its applications In-Reply-To: <18686250.post@talk.nabble.com> References: <18686250.post@talk.nabble.com> Message-ID: <625b74080807281340x7fcafb23xa30652fce914d2db@mail.gmail.com> fero asked: > Hi, > I would like to buy some booke on category theory and its applications. Can > you recommend me the best? I got a lot out of Basic Category Theory for Computer Scientists by Benjamin C. Pierce. Short and with examples biased towards CS. No monads but it covers the essentials with F-algebras as a bonus. Finishes with some extended CS-motivated examples. -- Dan From ndmitchell at gmail.com Mon Jul 28 17:55:43 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jul 28 17:45:26 2008 Subject: [Haskell-cafe] Re: [Haskell] Re: ANN: Hayoo! beta 0.2 In-Reply-To: References: <200807231104.03210.t.h@gmx.info> Message-ID: <404396ef0807281455x792422a2u71610d371cfd4fb8@mail.gmail.com> Hi >> Any suggestions and feedback is highly welcomed. > > Well, it is currently not in a usable state: the page randomly inserts funny > characters into the text input field. (I'm using Konqueror) It also deletes characters in some cases in the text input field using Opera. Still very impressive though, and definitely something for Hoogle to aim at :-) Thanks Neil From philip.weaver at gmail.com Mon Jul 28 18:02:21 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Mon Jul 28 17:52:05 2008 Subject: [Haskell-cafe] Cabal and Strings and CPP Message-ID: Hello all, I'm trying to use CPP-defined strings in a Haskell module, like this: main :: IO () main = putStrLn FOO This of course will not work: ghc -DFOO="hello world" --make Main.hs -o test You'll get this error message: ./Main.hs:6:16: Not in scope: `hello' ./Main.hs:6:22: Not in scope: `world' Either of these will do what I want: ghc -DFOO="\"hello world\"" --make Main.hs -o test ghc -DFOO='"hello world"' --make Main.hs -o test # (that's double quotes inside single quotes) However, passing the same CPP definition via cabal does not work. runhaskell Setup.hs build --ghc-options=-DFOO="\"hello world\"" runhaskell Setup.hs build --ghc-options=-DFOO='"hello world"' With either of these commands, I get the same error message as above. This is understandable, since cabal has to evaluate the string before sending it to GHC, so I lose my escaped quotes. Any idea how I could change the Haskell module or the command line argument so that I get what I want? I've tried many combinations of quotes and escaped quotes with no luck. Thanks, - Phil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/e5d02c65/attachment.htm From duncan.coutts at worc.ox.ac.uk Mon Jul 28 18:54:38 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jul 28 18:42:35 2008 Subject: [Haskell-cafe] Cabal and Strings and CPP In-Reply-To: References: Message-ID: <1217285678.12754.296.camel@localhost> On Mon, 2008-07-28 at 15:02 -0700, Philip Weaver wrote: > However, passing the same CPP definition via cabal does not work. > > runhaskell Setup.hs build --ghc-options=-DFOO="\"hello world\"" > > runhaskell Setup.hs build --ghc-options=-DFOO='"hello world"' > > With either of these commands, I get the same error message as above. > This is understandable, since cabal has to evaluate the string before > sending it to GHC, so I lose my escaped quotes. Cabal has both --prog-option= and --prog-options=. The latter tokenises the options and passes them as separate flags (like what the shell does), the former passes the whole arg as one option. So you want to use: cabal build --ghc-option=-DFOO="\"hello world\"" When you want to put this in the .cabal file, use cpp-options (not ghc-options) and you can use Haskell String syntax for options that contain spaces. Duncan From lrpalmer at gmail.com Mon Jul 28 19:33:26 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 28 19:23:08 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications In-Reply-To: References: <18686250.post@talk.nabble.com> Message-ID: <7ca3f0160807281633r1461e6d6ke7dcd11591031b6d@mail.gmail.com> On Mon, Jul 28, 2008 at 5:04 AM, Benjamin L. Russell wrote: > Category Theory Lecture Notes for ESSLLI > Michael Barr, Department of Mathematics and Statistics, McGill > University > Charles Wells, Department of Mathematics, Case Western Reserve > University > http://www.math.upatras.gr/~cdrossos/Docs/B-W-LectureNotes.pdf So far this has been an excellent read for someone failing to grok category theory for a while! Thanks! Luke > The above-mentioned lecture notes were condensed from the following > book, and then rearranged to present category theory from a computer > science perspective: > > Toposes, Triples and Theories > by Michael Barr and Charles Wells > http://www.cwru.edu/artsci/math/wells/pub/ttt.html > > According to the above-referenced home page for this book: > >> The original book, Grundlehren der math. Wissenschaften 278. Springer-Verlag, 1983, is now out of print. A revised and corrected version is now available free for downloading. > > An even shorter book on category theory is the following: > > A Gentle Introduction to Category Theory - the calculational approach > by Maarten M Fokkinga > http://wwwhome.cs.utwente.nl/~fokkinga/mmf92b.html > > However, I did not prefer the above book, despite its brevity, because > unlike the other two titles, it did not including any specific > material on monads. > >>What do you think about "Categories and Computer Science (Cambridge Computer >>Science Texts)" at >>http://www.amazon.com/Categories-Computer-Science-Cambridge-Texts/dp/0521422264/ref=si3_rdr_bb_product >>? > > I haven't read it, so I would need to review it before giving an > opinion. I shall keep it in mind, however; thank you for the > reference. > > -- Benjamin L. Russell > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From vigalchin at gmail.com Mon Jul 28 20:14:47 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 20:04:31 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <1216554681.6279.345.camel@localhost> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> Message-ID: <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> > So at the moment you're using using Storable and a Haskell record, say: > > data AIOCB = AIOCB { > ... > } > > and we're suggesting instead: > > newtype AIOCB = AIOCB (ForeignPtr AIOCB) ^^^ I am somewhat new to Haskell. Not a total newbie! But what exactly does the above mean? Are the three references of "AIOCB" in different namespaces? If it too much trouble to explain, can you point me at Haskell URL to read? > > > then to access a member use hsc2hs: > > getBlah :: AIOCB -> IO Blah > getBlah (AIOCB fptr) = > withForeignPtr fptr $ \ptr -> {# peek aiocb,blah #} ptr > > So you only access the parts you need and keep the aiocb C struct > allocated on the heap (use mallocForeignPtr). > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/32b2edb7/attachment.htm From felipe.lessa at gmail.com Mon Jul 28 21:01:15 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Jul 28 20:50:59 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> Message-ID: 2008/7/28 Galchin, Vasili : >> and we're suggesting instead: >> >> newtype AIOCB = AIOCB (ForeignPtr AIOCB) > > ^^^ I am somewhat new to Haskell. Not a total newbie! But what exactly > does the above mean? Are the three references of "AIOCB" in different > namespaces? The first and the third are the type AIOCB, the second is the type constructor AIOCB. That is, it is equivalent (up to renaming) to newtype T = C (ForeignPtr T) Now, why use Type in Type's definition? It is obvious that if we were creating data T = D T it would be pretty useless, however the type that ForeignPtr requires is just a phantom type. In other words, the ForeignPtr will never use the C constructor. An analogy to C: if you have typeA *pa; typeB *pb; then of course pa and pb have different types, however their internal representation are the same: an integral type of 32/64 bits. The C compiler only uses the type to provide warnings, to know the fields' offsets, the size of the structure, etc. The same goes for Haskell, if you have pa :: ForeignPtr A pb :: ForeignPtr B then both pa and pb have different types, but again they have the same internal representation. However, for example, if you allocate memory for pa via Storable then the compiler will find the correct sizeOf definition because will gave the type hint. The compiler also won't you let mix pa and pb like in [pa,pb]. So, if you declare newtype T = C (ForeignPtr T) you are: 1) Hiding the ForeignPtr from the users of your library if you don't export C. 2) Having type safeness by using ForeignPtr T instead of something generic like ForeignPtr () -- the same as using typeA* instead of void*. 3) Not needing to create a different type, like data InternalT = InternalT newtype T = C (ForeignPtr InternalT) Well.. did it help at all? =) -- Felipe. From bd at fushizen.net Mon Jul 28 21:32:58 2008 From: bd at fushizen.net (Bryan Donlan) Date: Mon Jul 28 21:22:44 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types Message-ID: <20080729013258.GA19607@shion.is.fushizen.net> Hi, Is there any theoretical reason that functional dependencies can't be used to resolve a polymorphic type to a concrete type? For example: > -- compile with -fglasgow-exts > > class DeriveType a b | a -> b > > data A = A > data B = B > > instance DeriveType A B > > simpleNarrow :: DeriveType A b => b -> B > simpleNarrow = id Since 'b' is uniquely determined by the fundep in DeriveType, it seems that this ought to work; ie, since the only type equation satisfying DeriveType A b is B -> B, it should reduce to that before trying to fit its type against its body. The motivation is this case: > data ComplexType a where > SomeConstructor :: DeriveType a b => a -> b -> ComplexType a > > specialCaseFunc :: ComplexType A -> B > specialCaseFunc (SomeConstructor _ b) = b Essentially, if I have a data structure with two types used as fields, and one uniquely determines the other, I'd like to use these instances to avoid re-stating the implied one in the type equations, if possible. Is there some theoretical reason for this not to work, or is it just a limitation of GHC's current implementation? (Note, I'm testing with GHC 6.8.2, so it's possible this might be fixed in trunk already...) Thanks, Bryan Donlan From vigalchin at gmail.com Mon Jul 28 21:43:39 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 21:33:22 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> Message-ID: <5ae4f2ba0807281843k1ffd925du2668b5692d70010f@mail.gmail.com> Thanks, Felipe. On Mon, Jul 28, 2008 at 8:01 PM, Felipe Lessa wrote: > 2008/7/28 Galchin, Vasili : > >> and we're suggesting instead: > >> > >> newtype AIOCB = AIOCB (ForeignPtr AIOCB) > > > > ^^^ I am somewhat new to Haskell. Not a total newbie! But what > exactly > > does the above mean? Are the three references of "AIOCB" in different > > namespaces? > > The first and the third are the type AIOCB, the second is the type > constructor AIOCB. That is, it is equivalent (up to renaming) to > > newtype T = C (ForeignPtr T) > > Now, why use Type in Type's definition? It is obvious that if we were > creating > > data T = D T > > it would be pretty useless, however the type that ForeignPtr requires > is just a phantom type. In other words, the ForeignPtr will never use > the C constructor. > > An analogy to C: if you have > > typeA *pa; > typeB *pb; > > then of course pa and pb have different types, however their internal > representation are the same: an integral type of 32/64 bits. The C > compiler only uses the type to provide warnings, to know the fields' > offsets, the size of the structure, etc. The same goes for Haskell, if > you have > > pa :: ForeignPtr A > pb :: ForeignPtr B > > then both pa and pb have different types, but again they have the same > internal representation. However, for example, if you allocate memory > for pa via Storable then the compiler will find the correct sizeOf > definition because will gave the type hint. The compiler also won't > you let mix pa and pb like in [pa,pb]. > > > > So, if you declare > > newtype T = C (ForeignPtr T) > > you are: > > 1) Hiding the ForeignPtr from the users of your library if you don't export > C. > 2) Having type safeness by using ForeignPtr T instead of something > generic like ForeignPtr () -- the same as using typeA* instead of > void*. > 3) Not needing to create a different type, like > > data InternalT = InternalT > newtype T = C (ForeignPtr InternalT) > > > Well.. did it help at all? =) > > -- > Felipe. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/8371a053/attachment.htm From vigalchin at gmail.com Mon Jul 28 21:48:23 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 21:38:06 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> Message-ID: <5ae4f2ba0807281848m487cb8bbu61f139b3b2efb0e4@mail.gmail.com> what does a datatype with no constructors mean? E.g. data RSAStruct data EVP_PKEY data EVP_CIPHER data EVP_CIPHER_CTX data EVP_MD_CTX data EVP_MD data BIGNUM On Mon, Jul 28, 2008 at 8:01 PM, Felipe Lessa wrote: > 2008/7/28 Galchin, Vasili : > >> and we're suggesting instead: > >> > >> newtype AIOCB = AIOCB (ForeignPtr AIOCB) > > > > ^^^ I am somewhat new to Haskell. Not a total newbie! But what > exactly > > does the above mean? Are the three references of "AIOCB" in different > > namespaces? > > The first and the third are the type AIOCB, the second is the type > constructor AIOCB. That is, it is equivalent (up to renaming) to > > newtype T = C (ForeignPtr T) > > Now, why use Type in Type's definition? It is obvious that if we were > creating > > data T = D T > > it would be pretty useless, however the type that ForeignPtr requires > is just a phantom type. In other words, the ForeignPtr will never use > the C constructor. > > An analogy to C: if you have > > typeA *pa; > typeB *pb; > > then of course pa and pb have different types, however their internal > representation are the same: an integral type of 32/64 bits. The C > compiler only uses the type to provide warnings, to know the fields' > offsets, the size of the structure, etc. The same goes for Haskell, if > you have > > pa :: ForeignPtr A > pb :: ForeignPtr B > > then both pa and pb have different types, but again they have the same > internal representation. However, for example, if you allocate memory > for pa via Storable then the compiler will find the correct sizeOf > definition because will gave the type hint. The compiler also won't > you let mix pa and pb like in [pa,pb]. > > > > So, if you declare > > newtype T = C (ForeignPtr T) > > you are: > > 1) Hiding the ForeignPtr from the users of your library if you don't export > C. > 2) Having type safeness by using ForeignPtr T instead of something > generic like ForeignPtr () -- the same as using typeA* instead of > void*. > 3) Not needing to create a different type, like > > data InternalT = InternalT > newtype T = C (ForeignPtr InternalT) > > > Well.. did it help at all? =) > > -- > Felipe. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/012eea96/attachment.htm From bd at fushizen.net Mon Jul 28 21:53:37 2008 From: bd at fushizen.net (Bryan Donlan) Date: Mon Jul 28 21:43:24 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807281848m487cb8bbu61f139b3b2efb0e4@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> <5ae4f2ba0807281848m487cb8bbu61f139b3b2efb0e4@mail.gmail.com> Message-ID: <20080729015337.GA20378@shion.is.fushizen.net> On Mon, Jul 28, 2008 at 08:48:23PM -0500, Galchin, Vasili wrote: > what does a datatype with no constructors mean? > > E.g. > > data RSAStruct > data EVP_PKEY > data EVP_CIPHER > data EVP_CIPHER_CTX > data EVP_MD_CTX > data EVP_MD > data BIGNUM It's simply a datatype that can never have a value - a so-called 'phantom type'. They're useful when you need a type (eg as the argument for a ForeignPointer) but no need for an actual value. You can of course create values of these types using 'undefined', 'error' and friends, but this is perhaps not very useful most of the time :) From mad.one at gmail.com Mon Jul 28 22:01:21 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 28 21:51:07 2008 Subject: [Haskell-cafe] ANN: RandomDotOrg-0.1 Message-ID: <1217296445-sup-1628@existential.local> Hi, I've just uploaded a package to hackage which is an interface to the random.org random number generator. For those who don't know, random.org provides random data through the use of atmospheric noise rather than a PRNG that would typically be invoked if you were to use the System.Random module or somesuch. As of current, it can only generate a list of random numbers. However, random.org also provides an interface to generate random strings, randomize an input list and a random sequence generator (the difference being that the sequence generator will not repeat itself, while the integer one may.) Would anybody find these interfaces useful? I think the random number generator alone is pretty nice, but I'm thinking of expanding it in the future with these other things since they're nice to have if you want randomness anyway. You can get it from [1] or just: $ cabal install RandomDotOrg The development repository is tracked using git; you can get yourself a clone by doing $ git clone git://github.com/thoughtpolice/randomdotorg.git Austin [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/RandomDotOrg-0.1 From vigalchin at gmail.com Mon Jul 28 22:14:56 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jul 28 22:04:38 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <20080729015337.GA20378@shion.is.fushizen.net> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> <5ae4f2ba0807281848m487cb8bbu61f139b3b2efb0e4@mail.gmail.com> <20080729015337.GA20378@shion.is.fushizen.net> Message-ID: <5ae4f2ba0807281914o4fef6ce1ge5d03866b719eb0@mail.gmail.com> ok guys .. what is this "phantom type" concept? Is it a type theory thing or just Haskell type concept? Vasili On Mon, Jul 28, 2008 at 8:53 PM, Bryan Donlan wrote: > On Mon, Jul 28, 2008 at 08:48:23PM -0500, Galchin, Vasili wrote: > > what does a datatype with no constructors mean? > > > > E.g. > > > > data RSAStruct > > data EVP_PKEY > > data EVP_CIPHER > > data EVP_CIPHER_CTX > > data EVP_MD_CTX > > data EVP_MD > > data BIGNUM > > It's simply a datatype that can never have a value - a so-called > 'phantom type'. They're useful when you need a type (eg as the argument > for a ForeignPointer) but no need for an actual value. > > You can of course create values of these types using 'undefined', > 'error' and friends, but this is perhaps not very useful most of the > time :) > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080728/f4a469c0/attachment.htm From dons at galois.com Mon Jul 28 22:21:10 2008 From: dons at galois.com (Don Stewart) Date: Mon Jul 28 22:10:54 2008 Subject: [Haskell-cafe] ANN: RandomDotOrg-0.1 In-Reply-To: <1217296445-sup-1628@existential.local> References: <1217296445-sup-1628@existential.local> Message-ID: <20080729022110.GA27598@scytale.galois.com> mad.one: > Hi, > > I've just uploaded a package to hackage which is an interface to the > random.org random number generator. > > For those who don't know, random.org provides random data through the > use of atmospheric noise rather than a PRNG that would typically be > invoked if you were to use the System.Random module or somesuch. > > As of current, it can only generate a list of random numbers. However, > random.org also provides an interface to generate random strings, > randomize an input list and a random sequence generator (the > difference being that the sequence generator will not repeat itself, > while the integer one may.) > > Would anybody find these interfaces useful? I think the random number > generator alone is pretty nice, but I'm thinking of expanding it in > the future with these other things since they're nice to have if you > want randomness anyway. > > You can get it from [1] or just: > > $ cabal install RandomDotOrg > > The development repository is tracked using git; you can get yourself > a clone by doing > > $ git clone git://github.com/thoughtpolice/randomdotorg.git > Can we expose it as a library, perhaps as a PRNG for System.Random? Also, can I get the noise directly off the network as a bytestring (maybe via download-curl ?) -- Don From mad.one at gmail.com Mon Jul 28 23:01:40 2008 From: mad.one at gmail.com (Austin Seipp) Date: Mon Jul 28 22:51:26 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807281914o4fef6ce1ge5d03866b719eb0@mail.gmail.com> References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> <5ae4f2ba0807281848m487cb8bbu61f139b3b2efb0e4@mail.gmail.com> <20080729015337.GA20378@shion.is.fushizen.net> <5ae4f2ba0807281914o4fef6ce1ge5d03866b719eb0@mail.gmail.com> Message-ID: <1217298006-sup-3439@existential.local> Excerpts from Galchin, Vasili's message of Mon Jul 28 21:14:56 -0500 2008: > ok guys .. what is this "phantom type" concept? Is it a type theory thing or > just Haskell type concept? > > Vasili Phantom types are more of an idiom than anything else; they are types with no real concrete representation, i.e. they only exist at compile time, and not at runtime. They can be used to hijack the type system, essentially. For example: > data Expr = EInt Int > | EBool Bool > | ECond Expr Expr Expr > | EAdd Expr Expr > deriving (Show) This basically represents the constructs for a simple expression language. However, wouldn't it be nice if we could say that 'EAdd' can only take an 'EInt' or that ECond's first parameter must be 'EBool' and check that at *compile* time? In this case, we can't. We would have to check at runtime when we try to evaluate things that indeed, the types fit together properly for our little 'expression language.' But not all is lost. With phantom types, we can 'hijack' the type system so that it'll verify this for us. We can do this by simply making a newtype over 'Expr' and giving it a type variable that does not show up on the right side: > newtype Expression a = E Expr > deriving (Show) In this case, the 'a' is the phantom type. It does not show up in the constructors, so it does not exist at runtime. Now all we simply have to do is 'lift' all of the constructors of Expr into their own functions that stick the data into an 'Expression' using the E constructor: > intE :: Int -> Expression Int > intE = E . EInt > > boolE :: Bool -> Expression Bool > boolE = E . EBool > > condE :: Expression Bool > -> Expression a > -> Expression a > -> Expression a > condE (E a) (E b) (E c) = E $ ECond a b c > > addE :: Expression Int -> Expression Int -> Expression Int > addE (E a) (E b) = E $ EAdd a b You'll notice: in the type signatures above, we give the phantom type of Expression a concrete type such as 'Int' or 'Bool'. What does this get is? It means that if we construct values via intE and boolE, and then subsequently use them with condE or addE, we can't use values of the wrong type in place of one another and the type system will make sure of it. For example: $ ghci ... Prelude> :l phantom.lhs [1 of 1] Compiling Main ( phantom.lhs, interpreted ) Ok, modules loaded: Main. *Main> let e1 = boolE True *Main> let e2 = intE 12 *Main> let e3 = intE 21 *Main> condE e1 e2 e3 E (ECond (EBool True) (EInt 12) (EInt 21)) *Main> condE e2 e1 e3 :1:6: Couldn't match expected type `Bool' against inferred type `Int' Expected type: Expression Bool Inferred type: Expression Int In the first argument of `condE', namely `e2' In the expression: condE e2 e1 e3 *Main> As you can see, we 'hijack' the type system so we can specify exactly what type of 'Expression' functions like intE/boolE will return. We then simply have other functions which operate over them, and also specify *exactly* what kind of expression is necessary for them to work. The phantom type never exists, it only is there to verify we're "doing the right thing." That was a bit OT though. In the case of empty data declarations, it's essentially the same idea. It's just a type with no actual runtime representation. You can exploit them to force invariants in your types or numerous other things; a good example is type arithmetic which can be found on the wiki: http://www.haskell.org/haskellwiki/Type_arithmetic The example here is based off of Lennart's blog post about representing DSLs in haskell, and he also shows an example of the same thing which uses GADTs which allow you to do the same thing (roughly.) So I'd say give the credit wholly to him. :) http://augustss.blogspot.com/2007/06/representing-dsl-expressions-in-haskell.html Austin From DekuDekuplex at Yahoo.com Mon Jul 28 23:11:34 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Jul 28 23:01:23 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications References: <18686250.post@talk.nabble.com> <4683d9370807281152v5565fcf2x79a2da91e7ed5215@mail.gmail.com> Message-ID: On Mon, 28 Jul 2008 11:52:43 -0700, "Tim Chevalier" wrote: >I've only read the beginning, but I recommend _Conceptual Mathematics_ >by Lawvere and Schanuel for a *very* gentle introduction (seriously, >you could probably teach category theory to ten-year-olds out of this >book.) Nothing about applications there, though. Does _Conceptual Mathematics_ discuss monads? -- Benjamin L. Russell From kenn at kenn.frap.net Mon Jul 28 23:23:34 2008 From: kenn at kenn.frap.net (Kenn Knowles) Date: Mon Jul 28 23:13:16 2008 Subject: [Haskell-cafe] Data Types a la Carte - automatic injections (help!) Message-ID: <476d7e8c0807282023i6b87ac33u9a9a45bc6a0a3070@mail.gmail.com> I have a question about Data Types a la Carte (http://www.cs.nott.ac.uk/~wss/Publications/DataTypesALaCarte.pdf) and more generally hacking smart coproduct injections into Haskell (all extensions are fair game). > {-# LANGUAGE MultiParamTypeClasses,TypeOperators,UndecidableInstances,IncoherentInstances,FlexibleInstances,FlexibleContexts #-} Here are the definitions from Wouter's paper, which cleverly manage the instances of (:<:) > data (f :+: g) a = Inl (f a) | Inr (g a) > infixr 6 :+: > instance (Functor f, Functor g) => Functor (f :+: g) where > fmap f (Inl x) = Inl (fmap f x) > fmap f (Inr x) = Inr (fmap f x) > class (Functor sub, Functor sup) => sub :<: sup where > inj :: sub a -> sup a > instance Functor f => (:<:) f f where > inj = id > instance (Functor f, Functor g) => (:<:) f (f :+: g) where > inj = Inl > instance (Functor f, Functor g, Functor h, (f :<: g)) => (:<:) f (h :+: g) where > inj = Inr . inj Now in my case, I want to be able to inject an arbitrary coproduct into a larger one, assuming the components are in the same order, so it is a subsequence of the larger sum, for example: > coprodInject1 :: (Functor f, Functor g, Functor h, Functor i) => (f :+: g :+: h) a -> (f :+: g :+: h :+: i) a > coprodInject1 = inj > coprodInject2 :: (Functor f, Functor g, Functor h, Functor i) => (f :+: g :+: i) a -> (f :+: g :+: h :+: i) a > coprodInject2 = inj > instance (Functor f, Functor g, Functor h, (g :<: h)) => (:<:) (f :+: g) (f :+: h) where > inj (Inl x) = Inl x > inj (Inr x) = Inr (inj x) The above works fine, and maybe I could manipulate my code to only have injections of those forms, but I want this next one to work too: > coprodInject3 :: (Functor f, Functor g, Functor h, Functor i) => (f :+: g :+: i :+: j) a -> (f :+: g :+: h :+: i :+: j) a > coprodInject3 = inj It fails because after "passing up" the h in the search, it can either use the reflexivity rule or decompose the sum on (i :+: j). The full error is: Overlapping instances for (i :+: j) :<: (i :+: j) arising from a use of `inj' ... Matching instances: instance [incoherent] (Functor f) => f :<: f -- Defined at ... instance [incoherent] (Functor f, Functor g, Functor h, g :<: h) => (f :+: g) :<: (f :+: h) -- Defined at ... In the expression: inj In the definition of `coprodInject3': coprodInject3 = inj What confuses me is that IncoherentInstances is on, but it is still rejected by GHC 6.8.3 seemingly for being incoherent. I haven't tried it with any other version. Am I missing something? Any suggestions or pointers? From sedillard at gmail.com Mon Jul 28 23:42:55 2008 From: sedillard at gmail.com (scodil) Date: Mon Jul 28 23:32:37 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs In-Reply-To: <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> <20080725211323.GM6953@scytale.galois.com> <488B007F.6050901@um.es> <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> Message-ID: <18704556.post@talk.nabble.com> I'll chime in with a "me too". I use Haskell and OpenGL for prototyping scientific visualization software, 3D models and such. Not that I think it couldn't be used for production software, its just that I just don't produce much :) The library really is fantastic. I don't think it gets enough fanfare. The only other GL API that rivals it is the C API itself. Most other languages provide a shoddy & incomplete interface to that, instead of an idiomatic interpretation of the OpenGL spec. I can't think of a single language, not even python, whose OpenGL bindings come close. I get the impression (from a inadequate sample of irc logs and list chatter) that many Haskellers see HOpenGL as 'just an OpenGL binding', like it was readline or curses or something. It just plugs a hole in the Haskell/OS interface, and its worth is merely a function of the size and importance of that hole. Instead I advocate, as Claus and others have done, that it's a shining example of how to write a Haskell interface to a well known API. If you never used C OpenGL and learned GL using Haskell, you might not notice anything special about it. But that's kind of my point, its just so damn good it blends into the background. The only people who notice this, I think, are experienced C OpenGL programmers, and the overlap between them and the Haskell community in general is small I bet. Their voice in that community smaller still. This probably has little bearing on the issue of whether to keep or drop HOpenGL in the near future, but I think that if 'the community' (or whoever has a say in these things) like the style of HOpenGL, and want to encourage bindings to be written in that style, they should place the library prominently in the pantheon of Haskell libs. Demoting it has the opposite effect. Anyway, I just wanted to take advantage of a rare opportunity to sing its praise. Scott > Yes, same here; don't worry, it's not going away. It would be nice > to know, though, how many people are using it and what they're using > it for. I'm using it for information visualization, and slowly > evolving/cribbing together something like the Processing > (http://www.processing.org) framework for Haskell as I do more things. > > On Sat, Jul 26, 2008 at 5:46 AM, Alberto Ruiz wrote: >> Don Stewart wrote: >>> >>> claus.reinke: >>>> >>>> But neither do I believe the rumour that OpenGL isn't much >>>> used, and forwarding the removal notice gives those users the >>>> opportunity to speak up now if they prefer no gaps in OpenGL presence, >>>> or >>>> forever to hold their peace, as they say. >>> >>> I for one have noticed this library *is* actively used. Many of the fun >>> new games that have appeared are using it, in particular. >>> >>> Such as: >>> >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Monadius >>> >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/roguestar-gl >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rsagl >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/topkata >>> >>> The tutorial was also translated to the wiki last week, >>> >>> http://haskell.org/haskellwiki/Opengl >>> >>> It's a good, reliable package, in active use, widely ported. >> >> I'd just like to say that HOpenGL is essential for me. It is one of the >> reasons why I finally decided to use Haskell for all my work... >> >> Alberto >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > I try to take things like a crow; war and chaos don't always ruin a > picnic, they just mean you have to be careful what you swallow. > > -- Jessica Edwards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- View this message in context: http://www.nabble.com/Fw%3A-patch-applied-%28ghc%29%3A-Remove-the-OpenGL-family-of-libraries-fromextralibs-tp18655695p18704556.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From allbery at ece.cmu.edu Tue Jul 29 00:03:38 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jul 28 23:53:21 2008 Subject: [Haskell-cafe] Data Types a la Carte - automatic injections (help!) In-Reply-To: <476d7e8c0807282023i6b87ac33u9a9a45bc6a0a3070@mail.gmail.com> References: <476d7e8c0807282023i6b87ac33u9a9a45bc6a0a3070@mail.gmail.com> Message-ID: On 2008 Jul 28, at 23:23, Kenn Knowles wrote: > What confuses me is that IncoherentInstances is on, but it is still > rejected by GHC 6.8.3 seemingly for being incoherent. I haven't tried > it with any other version. Am I missing something? Any suggestions > or pointers? Er? Looks to me like it wants the OverlappingInstances language extension. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From nicolas.frisby at gmail.com Tue Jul 29 02:12:38 2008 From: nicolas.frisby at gmail.com (Nicolas Frisby) Date: Tue Jul 29 02:02:20 2008 Subject: [Haskell-cafe] Data Types a la Carte - automatic injections (help!) In-Reply-To: References: <476d7e8c0807282023i6b87ac33u9a9a45bc6a0a3070@mail.gmail.com> Message-ID: <5ce89fb50807282312m4bb1cd9cg5fba728068956ffc@mail.gmail.com> I have accomplished this in two ways. Either drop the reflexive rule and introduce a void sentinel type or use TypeEq (... you said everything was fair game!) to explicitly specify the preference for the reflexive case over the inductive case. An advantage of TypeEq is that you can avoid overlapping (and also incoherent) instances and so play nice with functional dependencies. A disadvantage is its hyper-instability in terms of regressions via compiler development (none yet, though). There are better participants in the cafe for explaining the details if you choose this path. HTH On Mon, Jul 28, 2008 at 11:03 PM, Brandon S. Allbery KF8NH wrote: > > On 2008 Jul 28, at 23:23, Kenn Knowles wrote: > >> What confuses me is that IncoherentInstances is on, but it is still >> rejected by GHC 6.8.3 seemingly for being incoherent. I haven't tried >> it with any other version. Am I missing something? Any suggestions >> or pointers? > > Er? Looks to me like it wants the OverlappingInstances language extension. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ketil at malde.org Tue Jul 29 02:23:16 2008 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 29 02:12:08 2008 Subject: [Haskell-cafe] carry "state" around .... In-Reply-To: <5ae4f2ba0807281914o4fef6ce1ge5d03866b719eb0@mail.gmail.com> (Vasili Galchin's message of "Mon\, 28 Jul 2008 21\:14\:56 -0500") References: <5ae4f2ba0807182340j53ab1ad9q3f4d50a9186f5e55@mail.gmail.com> <1216474118.6279.292.camel@localhost> <5ae4f2ba0807192155v685bc927j9738a300df3b5905@mail.gmail.com> <1216554681.6279.345.camel@localhost> <5ae4f2ba0807281714u1af1793q90fb55c948b67916@mail.gmail.com> <5ae4f2ba0807281848m487cb8bbu61f139b3b2efb0e4@mail.gmail.com> <20080729015337.GA20378@shion.is.fushizen.net> <5ae4f2ba0807281914o4fef6ce1ge5d03866b719eb0@mail.gmail.com> Message-ID: <871w1d5huz.fsf@malde.org> "Galchin, Vasili" writes: > ok guys .. what is this "phantom type" concept? Is it a type theory thing or > just Haskell type concept? Here's another example. Say you want to use bytestrings with different encodings. You obviously don't want to concatenate a string representing Latin characters with a string in Cyrillic. One way to do this, is to define phantom types for the encodings, and a bytestring type that takes additional type parameter data KOI8 data ISO8859_1 : data Bytestring enc = MkBS ... Operations like concat work on same-typed bytestrings: concat :: Bytestring e -> Bytestring e -> Bytestring e The parameter (enc) isn't used on the right hand side, so all Bytestrings will have the same representation, but Bytestring KOI8 and Bytestring ISO8859_1 will have different types, so although the runtime won't know the difference, trying to 'concat' them will give you a type error at compile time. -k -- If I haven't seen further, it is by standing in the footprints of giants From wren at freegeek.org Tue Jul 29 03:12:48 2008 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 29 03:02:33 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: <20080729013258.GA19607@shion.is.fushizen.net> References: <20080729013258.GA19607@shion.is.fushizen.net> Message-ID: <488EC2F0.9060100@freegeek.org> Bryan Donlan wrote: > Hi, > > Is there any theoretical reason that functional dependencies can't be used > to resolve a polymorphic type to a concrete type? For example: > >> -- compile with -fglasgow-exts >> >> class DeriveType a b | a -> b >> >> data A = A >> data B = B >> >> instance DeriveType A B >> > >> simpleNarrow :: DeriveType A b => b -> B >> simpleNarrow = id I'm not entirely sure what your use case is, but the reason this fails is that you gave a type signature which is more general than what the body can possibly be. Even with fundeps, the signature is claiming that the function works for *any* b provided it happens to be the right one for DeriveType A. That is, the signature is somewhat agnostic to whatever actual implementations happen to exist [though it must be consistent with them]. A true (DeriveType A b => b -> B) function would work even if we edited the instance declaration to be for DeriveType A C instead. And naturally 'id' is (a -> a) so giving a return type of B requires that the input type must also be B. It compiles just fine with (DeriveType A b => b -> b) after all, which resolves directly to (B -> B) [which I think is what you want?]. Though again, if we changed the instance then it would resolve to (C -> C) instead. > The motivation is this case: > >> data ComplexType a where >> SomeConstructor :: DeriveType a b => a -> b -> ComplexType a >> >> specialCaseFunc :: ComplexType A -> B >> specialCaseFunc (SomeConstructor _ b) = b Again the issue is that while the instance declaration says that the result happens to be B now, that's not what the "real" type of the result is-- it's (DeriveType A b => b) where b is *exactly* the one from the SomeConstructor signature, and hence the signature (DeriveType A b => ComplexType A -> b) doesn't work either since that's a different b. Since b --whatever it happens to be-- is fixed by A it seems like the (DeriveType A b => ComplexType A -> b) signature should work and consider it the same b. However, since the GADT is doing existential quantification, even though the b type is fixed we've lost that information and so we can't be certain that it *really* is the same b. If you're familiar with existential quantification then the behavior makes sense, though I agree it isn't quite what would be expected at first. I'm not sure off hand whether it should really be called a bug however. If you don't really need the existential in there, then this version works just fine: > {-# OPTIONS_GHC -fglasgow-exts #-} > > class DeriveType a b | a -> b > > data A = A > data B = B > > instance DeriveType A B > > simpleNarrow :: DeriveType A b => b -> b > simpleNarrow = id > > data ComplexType a b where > SomeConstructor :: DeriveType a b => a -> b -> ComplexType a b > > specialCaseFunc :: ComplexType A b -> b > specialCaseFunc (SomeConstructor _ b) = b > Essentially, if I have a data structure with two types used as fields, and > one uniquely determines the other, I'd like to use these instances to avoid > re-stating the implied one in the type equations, if possible. If you do want the existential after all, you can keep it provided the context restriction [i.e. DeriveType] gives you a method to get it back. If all you're doing is type passing then an implementation like this works just fine: > class DeriveType a b | a -> b where > someDestructor :: ComplexType a -> b > > instance DeriveType A B where > someDestructor _ = B > > data ComplexType a where > SomeConstructor :: DeriveType a b => a -> b -> ComplexType a [1 of 1] Compiling Main ( fundep.hs, interpreted ) Ok, modules loaded: Main. *Main> someDestructor (SomeConstructor undefined undefined :: ComplexType A) B *Main> But if you have actual values rather than just unit types, note that this won't work: > instance DeriveType A B where > someDestructor (SomeConstructor _ b) = b The key to note here is that when we existentially quantify over b and loose the type information, any class dictionaries for b are packaged up with the value and can still be used to get views onto the value of b. We can only get *views* onto b but can't do anything which might recover information about the actual type of b, however [aka "existential escapes"]. So this may or may not be sufficient for your needs. The fact that existential quantification looses information which can never be recovered is one of the reasons why they can be difficult to deal with. -- Live well, ~wren From ryani.spam at gmail.com Tue Jul 29 03:22:14 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 29 03:11:58 2008 Subject: [Haskell-cafe] How can I get the mutable array out of an IOUArray for FFI use? Message-ID: <2f9b2d30807290022s4a588512x2cd772cfd9ebaac7@mail.gmail.com> I wrote some fast bit-twiddling functions in C because my Haskell performance wasn't good enough. Now I'm trying to recompile with GHC6.8.3 and failing. This code worked on GHC6.6.1. I get the following error: > ghc --make main.hs Bitmap.hs:11:7: Could not find module `Data.Array.IO.Internals': it is hidden (in package array-0.1.0.0) I suppose I can declare a copy of the internal type and use unsafeCoerce#, but that seems like a terrible idea if there is a better way. What's the right way to make this work? Can I force that module to be unhidden? Should I file a GHC bug? -- ryan {-# OPTIONS_GHC -fffi -fglasgow-exts #-} {-# INCLUDE "bitmap_operations.h" #-} module Bitmap ( clearBitmap, ) where import Foreign.Ptr import Data.Array.Base import Data.Array.IO.Internals import GHC.Exts import Data.Word foreign import ccall unsafe clear_bitmap :: MutableByteArray# RealWorld -> Word32 -> Word32 -> IO () {-# INLINE unsafeGetMutableArray# #-} unsafeGetMutableArray# :: IOUArray Int Word32 -> MutableByteArray# RealWorld unsafeGetMutableArray# (IOUArray (STUArray _ _ array#)) = array# clearBitmap :: IOUArray Int Word32 -> Word32 -> Word32 -> IO () clearBitmap a1 color size = clear_bitmap (unsafeGetMutableArray# a1) color size From ryani.spam at gmail.com Tue Jul 29 03:31:12 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 29 03:20:54 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: <20080729013258.GA19607@shion.is.fushizen.net> References: <20080729013258.GA19607@shion.is.fushizen.net> Message-ID: <2f9b2d30807290031t1643d23dye51d4bd9c3674920@mail.gmail.com> This seems like an appropriate place to use type families. {-# LANGUAGE TypeFamilies, GADTs #-} module DeriveType where type family DeriveType a data A = A data B = B type instance DeriveType A = B data ComplexType a where SomeConstructor :: a -> DeriveType a -> ComplexType a specialCaseFunc :: ComplexType A -> B specialCaseFunc (SomeConstructor _ b) = b On Mon, Jul 28, 2008 at 6:32 PM, Bryan Donlan wrote: > Hi, > > Is there any theoretical reason that functional dependencies can't be used > to resolve a polymorphic type to a concrete type? For example: > >> -- compile with -fglasgow-exts >> >> class DeriveType a b | a -> b >> >> data A = A >> data B = B >> >> instance DeriveType A B >> > >> simpleNarrow :: DeriveType A b => b -> B >> simpleNarrow = id > > Since 'b' is uniquely determined by the fundep in DeriveType, it seems that > this ought to work; ie, since the only type equation satisfying DeriveType A b > is B -> B, it should reduce to that before trying to fit its type against its > body. > > The motivation is this case: > >> data ComplexType a where >> SomeConstructor :: DeriveType a b => a -> b -> ComplexType a >> >> specialCaseFunc :: ComplexType A -> B >> specialCaseFunc (SomeConstructor _ b) = b > > Essentially, if I have a data structure with two types used as fields, and > one uniquely determines the other, I'd like to use these instances to avoid > re-stating the implied one in the type equations, if possible. > > Is there some theoretical reason for this not to work, or is it just a > limitation of GHC's current implementation? (Note, I'm testing with GHC 6.8.2, > so it's possible this might be fixed in trunk already...) > > Thanks, > > Bryan Donlan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From pablo at babel.ls.fi.upm.es Tue Jul 29 05:07:34 2008 From: pablo at babel.ls.fi.upm.es (Pablo Nogueira) Date: Tue Jul 29 04:57:16 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: <488EC2F0.9060100@freegeek.org> References: <20080729013258.GA19607@shion.is.fushizen.net> <488EC2F0.9060100@freegeek.org> Message-ID: Wren ng thornton wrote: > It compiles just fine with (DeriveType A b => b -> b) after all, which resolves directly to (B -> B) That's not the case: simpleNarrow :: DeriveType A b => b -> b simpleNarrow = id Couldn't match expected type `b' (a rigid variable) against inferred type `B' `b' is bound by the type signature for `simpleNarrow' ... When using functional dependencies to combine DeriveType A B, arising from the instance declaration ... DeriveType A b, arising from is bound by the type signature for `simpleNarrow' ... I think Bryan got the order in which type inference/checking works wrong. The dependency is not "resolved" before calculating the type as he suggested. >*Main> someDestructor (SomeConstructor undefined undefined :: ComplexType A) > B Why not this: *Main> someDestructor (SomeConstructor A B) B > But if you have actual values rather than just unit types, note that this > won't work: > > > instance DeriveType A B where > > someDestructor (SomeConstructor _ b) = b I couldn't understand the sentence "actual values rather than unit types". What do you have in mind? P. From Malcolm.Wallace at cs.york.ac.uk Tue Jul 29 06:14:37 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Jul 29 06:05:57 2008 Subject: [Haskell-cafe] Cabal and Strings and CPP In-Reply-To: References: Message-ID: <20080729111437.3438de53.Malcolm.Wallace@cs.york.ac.uk> "Philip Weaver" wrote: > I'm trying to use CPP-defined strings in a Haskell module, like this: > main :: IO () > main = putStrLn FOO > This of course will not work: > ghc -DFOO="hello world" --make Main.hs -o test Have you tried using ANSI cpp's stringification operator? {-# LANGUAGE CPP #-} #define STRING(bar) #bar main :: IO () main = putStrLn FOO ghc -DFOO="STRING(hello world)" --make Main.hs -o test Regards, Malcolm From pablo at babel.ls.fi.upm.es Tue Jul 29 06:28:58 2008 From: pablo at babel.ls.fi.upm.es (Pablo Nogueira) Date: Tue Jul 29 06:18:40 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: References: <20080729013258.GA19607@shion.is.fushizen.net> <488EC2F0.9060100@freegeek.org> Message-ID: >> But if you have actual values rather than just unit types, note that this >> won't work: >> >> > instance DeriveType A B where >> > someDestructor (SomeConstructor _ b) = b > > I couldn't understand the sentence "actual values rather than unit > types". What do you have in mind? I didn't pay attention to the |b| value returned. So what you meant was that only a constant function will do, not a function that returns the value |b|. P. From duncan.coutts at worc.ox.ac.uk Tue Jul 29 07:15:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jul 29 07:03:24 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <20080728111118.7eafcacf.Malcolm.Wallace@cs.york.ac.uk> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080728111118.7eafcacf.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <1217330120.12754.312.camel@localhost> On Mon, 2008-07-28 at 11:11 +0100, Malcolm Wallace wrote: > > FYI: Haskell's OpenGL binding has just been dropped from GHC's > > extralibs, which means that it will no longer be kept in sync with GHC > > development, at least not by GHC HQ. > > > > GHC HQ has its hands full and -generally speaking - extralibs are to > > be replaced by H(L)P, the Haskell (Library) Platform: > > As someone who uses HOpenGL as a component for my own research, I must > say that I don't entirely follow the logic of dropping it from > extralibs. > > I mean, I fully appreciate that ghc-HQ wants to remove extralibs from > its sphere of responsibility. And I also very much support the new > Haskell Platform idea. > > But I did also get the impression that the HP was going to start from > extralibs and build outwards. I can't see how dropping existing working > and tested libraries from a mini-platform, is any help at all to the new > maintainers of HP. I think there's been a bit too much ho ha over this. For one thing it was only a suggestion to reduce work and for another we've not even got the infrastructure set up so we don't know how much work it's going to be. If someone wants to do the work (of the maintainer) then I'm sure it'll happen, and judging by the number of responses that would seem likely. > It is only likely to give grief to users who expect HOpenGL to be part > of HP, and then later more grief to the HP maintainers when they try > to re-integrate it, after allowing it to suffer a period of bit-rot. I don't think that's right. The HP maintainers are not (and cannot be) the maintainers of each individual package. That just does not scale. If a package is suffering bit rot then it's the responsibility of the package maintainer(s) to sort out. Also, something not being in the platform does not at all imply bit rot. Lack of a maintainer tends to imply bit rot. It's still on hackage and has its existing users who would hopefully contribute fixes if the maintainer was not to be found. Duncan From marlowsd at gmail.com Tue Jul 29 07:28:18 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Tue Jul 29 07:18:04 2008 Subject: [Haskell-cafe] Re: Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs In-Reply-To: <18704556.post@talk.nabble.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> <20080725211323.GM6953@scytale.galois.com> <488B007F.6050901@um.es> <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> <18704556.post@talk.nabble.com> Message-ID: <488EFED2.6090005@gmail.com> scodil wrote: > I'll chime in with a "me too". I use Haskell and OpenGL for prototyping > scientific visualization software, 3D models and such. Not that I think it > couldn't be used for production software, its just that I just don't produce > much :) > > The library really is fantastic. I don't think it gets enough fanfare. The > only > other GL API that rivals it is the C API itself. Most other languages > provide a > shoddy & incomplete interface to that, instead of an idiomatic > interpretation of the OpenGL spec. I can't think of a single language, not > even > python, whose OpenGL bindings come close. > > I get the impression (from a inadequate sample of irc logs and list chatter) > that many Haskellers see HOpenGL as 'just an OpenGL binding', like it was > readline or curses or something. It just plugs a hole in the Haskell/OS > interface, and its worth is merely a function of the size and importance of > that hole. Instead I advocate, as Claus and others have done, that it's a > shining example of how to write a Haskell interface to a well known API. > > If you never used C OpenGL and learned GL using Haskell, you might not > notice > anything special about it. But that's kind of my point, its just so damn > good > it blends into the background. The only people who notice this, I think, are > experienced C OpenGL programmers, and the overlap between them and the > Haskell > community in general is small I bet. Their voice in that community smaller > still. > > This probably has little bearing on the issue of whether to keep or drop > HOpenGL in the near future, but I think that if 'the community' (or whoever > has > a say in these things) like the style of HOpenGL, and want to encourage > bindings to be written in that style, they should place the library > prominently > in the pantheon of Haskell libs. Demoting it has the opposite effect. > > Anyway, I just wanted to take advantage of a rare opportunity to sing its > praise. I have nothing to add except... what a great post. Thanks for being both enlightening and eloquent. Simon From jefferson.r.heard at gmail.com Tue Jul 29 09:29:13 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Tue Jul 29 09:18:53 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL familyof libraries fromextralibs In-Reply-To: <18704556.post@talk.nabble.com> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080725172737.GB6953@scytale.galois.com> <013901c8ee9a$69a25640$58237ad5@cr3lt> <20080725211323.GM6953@scytale.galois.com> <488B007F.6050901@um.es> <4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com> <18704556.post@talk.nabble.com> Message-ID: <4165d3a70807290629w18f333f0q22fe77450d70e44d@mail.gmail.com> Scott, I couldn't have said it better. My impression has always been that HOpenGL looks like OpenGL would have looked like if they'd had a flexible language to work with when they desgned it. My only quibble would be with the documentation. Is there any way out there for haddock to produce a linked and indexed PDF, so that I can better guess where one function will be relative to another that feels like it ought to be related? On Mon, Jul 28, 2008 at 11:42 PM, scodil wrote: > > I'll chime in with a "me too". I use Haskell and OpenGL for prototyping > scientific visualization software, 3D models and such. Not that I think it > couldn't be used for production software, its just that I just don't produce > much :) > > The library really is fantastic. I don't think it gets enough fanfare. The > only > other GL API that rivals it is the C API itself. Most other languages > provide a > shoddy & incomplete interface to that, instead of an idiomatic > interpretation of the OpenGL spec. I can't think of a single language, not > even > python, whose OpenGL bindings come close. > > I get the impression (from a inadequate sample of irc logs and list chatter) > that many Haskellers see HOpenGL as 'just an OpenGL binding', like it was > readline or curses or something. It just plugs a hole in the Haskell/OS > interface, and its worth is merely a function of the size and importance of > that hole. Instead I advocate, as Claus and others have done, that it's a > shining example of how to write a Haskell interface to a well known API. > > If you never used C OpenGL and learned GL using Haskell, you might not > notice > anything special about it. But that's kind of my point, its just so damn > good > it blends into the background. The only people who notice this, I think, are > experienced C OpenGL programmers, and the overlap between them and the > Haskell > community in general is small I bet. Their voice in that community smaller > still. > > This probably has little bearing on the issue of whether to keep or drop > HOpenGL in the near future, but I think that if 'the community' (or whoever > has > a say in these things) like the style of HOpenGL, and want to encourage > bindings to be written in that style, they should place the library > prominently > in the pantheon of Haskell libs. Demoting it has the opposite effect. > > Anyway, I just wanted to take advantage of a rare opportunity to sing its > praise. > > Scott > > >> Yes, same here; don't worry, it's not going away. It would be nice >> to know, though, how many people are using it and what they're using >> it for. I'm using it for information visualization, and slowly >> evolving/cribbing together something like the Processing >> (http://www.processing.org) framework for Haskell as I do more things. >> >> On Sat, Jul 26, 2008 at 5:46 AM, Alberto Ruiz wrote: >>> Don Stewart wrote: >>>> >>>> claus.reinke: >>>>> >>>>> But neither do I believe the rumour that OpenGL isn't much >>>>> used, and forwarding the removal notice gives those users the >>>>> opportunity to speak up now if they prefer no gaps in OpenGL presence, >>>>> or >>>>> forever to hold their peace, as they say. >>>> >>>> I for one have noticed this library *is* actively used. Many of the fun >>>> new games that have appeared are using it, in particular. >>>> >>>> Such as: >>>> >>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag >>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Monadius >>>> >>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/roguestar-gl >>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rsagl >>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing >>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/topkata >>>> >>>> The tutorial was also translated to the wiki last week, >>>> >>>> http://haskell.org/haskellwiki/Opengl >>>> >>>> It's a good, reliable package, in active use, widely ported. >>> >>> I'd just like to say that HOpenGL is essential for me. It is one of the >>> reasons why I finally decided to use Haskell for all my work... >>> >>> Alberto >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> >> -- >> I try to take things like a crow; war and chaos don't always ruin a >> picnic, they just mean you have to be careful what you swallow. >> >> -- Jessica Edwards >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > View this message in context: http://www.nabble.com/Fw%3A-patch-applied-%28ghc%29%3A-Remove-the-OpenGL-family-of-libraries-fromextralibs-tp18655695p18704556.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From matthew at wellquite.org Tue Jul 29 10:27:54 2008 From: matthew at wellquite.org (Matthew Sackman) Date: Tue Jul 29 10:17:47 2008 Subject: [Haskell-cafe] Re: Anglo Haskell 2008 In-Reply-To: <20080707153853.GB6240@wellquite.org> References: <20080701121531.GB1808@arkansas.doc.ic.ac.uk> <20080707153853.GB6240@wellquite.org> Message-ID: <20080729142754.GF5180@koba.home.wellquite.org> Anglo Haskell is a gathering of all people Haskell-related from beginners, to seasoned hackers to academic giants. All and more are welcomed by large fuzzy green lambdas.[0] Anglo Haskell 2009 is nearly upon us and planning has been going well! We are delighted to be able to confirm Simon Marlow is headlining this year's event which is being held at Imperial College, London on the 8th and 9th of August (Friday and Saturday). We are also very happy to be able to announce there will be talks on both days: 5 talks on the Friday and at least 3 and possibly 4 on the Saturday. There will be an evening meal at local resturant on the Friday evening followed by the odd drink for those that way inclined; a lazy brunch on the Saturday morning, and then potentially some group hacking on the Saturday afternoon and evening. We are truly excited about this and should very much like to see you *all* there! Full details are available at: http://www.haskell.org/haskellwiki/AngloHaskell/2008 Things that are still to be added to that page which will appear over the next week: o) Phone numbers for myself and Tristan so that should you get lost you can ring one of us; o) Video or photos of how to navigate to the correct room at Imperial - should somehow signs fail to materialise. Please think about coming along - even if it's just for a single day. It's FREE after all! If you are coming please put your name down on the list on the wiki page, and further, if you'd like to come out to dinner with us on the Friday evening, there's a separate list for that - please add yourself to that too. Many thanks, Matthew -- On behalf of the AH2008 team. [0] We've been unable to obtain any large fuzzy green lambdas. If anyone has any knocking about or knows where we can get some, please let us know. From Malcolm.Wallace at cs.york.ac.uk Tue Jul 29 10:34:46 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Jul 29 10:27:53 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <1217330120.12754.312.camel@localhost> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080728111118.7eafcacf.Malcolm.Wallace@cs.york.ac.uk> <1217330120.12754.312.camel@localhost> Message-ID: <20080729153446.07b01145.Malcolm.Wallace@cs.york.ac.uk> > I don't think that's right. The HP maintainers are not (and cannot be) > the maintainers of each individual package. That just does not scale. Oh absolutely, but I was imagining that (at least part of) the purpose of the Platform is to generate automatic notifications to package owners, when a change in either ghc or the packaging infrastructure or the package's dependencies, leads to their own package breaking. So the Platform effectively generates an auto-prompt when maintenance is required. Given that such a lot of package-breakage is not due to changes in the functionality of the library itself, but purely to changes in the packaging system surrounding it, this would in my eyes shift a certain amount of responsibility in the right direction. :-) (Not the responsibility to fix, but the responsibility to notify.) As a package author (rather than a user), I would see this as a primary benefit of having my packages added to the Platform. And as a package user (rather than author), there is the corresponding antibenefit of removing a package like HOpenGL from the Platform: a diminished likelihood of the maintainer being already aware of packaging flaws. Regards, Malcolm From jefferson.r.heard at gmail.com Tue Jul 29 11:57:13 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Tue Jul 29 11:46:54 2008 Subject: [Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution Message-ID: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> Please ignore the obvious security holes, as this is not a script meant for public consumption, but some internal testing and prototyping. I would like to write the result of my computation out to a file inside of cgiMain, but the type of the monad inside cgiMain is this odd CGIT IO CGIResult. I tried using liftM on writeFile, but it then complained that "newanns" was a string instead of a list of strings, which I don't understand at all. Here's the code: DeleteAnnotation.hs: -------------------------------------------------------------------------------- import Network.CGI import Annotations import Graphics.Rendering.OpenGL.GL (GLfloat) import Control.Monad (liftM) import Data.List (filter) getInput' v = do x <- getInput v case x of Nothing -> fail "essential variable not found" Just y -> return y cgiMain :: String -> CGI CGIResult cgiMain anns_dot_txt = do ordnl <- (liftM read) $ getInput' "ordinal" let anns = (filter (notequal ordnl) . read $ anns_dot_txt) :: [Annotation] newanns = show anns output $ newanns writeFile "Annotations.txt" $ newanns notequal :: String -> Annotation -> Bool notequal ordnl ann = ordnl == ordinal ann main :: IO () main = do f <- readFile "Annotations.txt" runCGI (handleErrors (cgiMain f)) -------------------------------------------------------------------------------- $ ghc --make DeleteAnnotation DeleteAnnotation.hs:19:2: Couldn't match expected type `CGIT IO CGIResult' against inferred type `IO ()' In the expression: writeFile "Annotations.txt" $ newanns In the expression: do ordnl <- (liftM read) $ getInput' "ordinal" let anns = ... newanns = show anns output $ newanns writeFile "Annotations.txt" $ newanns In the definition of `cgiMain': cgiMain anns_dot_txt = do ordnl <- (liftM read) $ getInput' "ordinal" let anns = ... .... output $ newanns .... If I change writeFile "Annotations.txt" to (liftM (writeFile "Annotations.txt")): $ ghc --make DeleteAnnotation DeleteAnnotation.hs:19:42: Couldn't match expected type `String' against inferred type `Char' Expected type: [String] Inferred type: String In the second argument of `($)', namely `newanns' In the expression: (liftM (writeFile "Annotations.txt")) $ newanns From a.d.clark at ed.ac.uk Tue Jul 29 12:07:23 2008 From: a.d.clark at ed.ac.uk (allan) Date: Tue Jul 29 11:55:12 2008 Subject: [Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution In-Reply-To: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> References: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> Message-ID: <488F403B.1070600@ed.ac.uk> Hi I had this same problem and I'm not sure my way is correct but I used 'Control.Monad.Trans.liftIO' Here is some code that I am using {- The main program is pretty simple we just run the CGI action. -} main :: IO () main = Cgi.runCGI $ Cgi.handleErrors cgiMain {- To be able to produce graphs which we can then display in the output webpage we require that our main function, that is the one which creates the page be in the IO monad. -} cgiMain :: CGI CGIResult cgiMain = do visitInfo <- getAnalysisData page <- Monad.Trans.liftIO $ createPage visitInfo Cgi.output $ Xhtml.renderHtml page createPage :: Visit -> IO Html createPage ..... blah stuff you don't care about getAnalysisData :: CGI Visit Visit is a data type I've made to hold the information obtained from the page. Hope this helps allan Jefferson Heard wrote: > Please ignore the obvious security holes, as this is not a script > meant for public consumption, but some internal testing and > prototyping. I would like to write the result of my computation out > to a file inside of cgiMain, but the type of the monad inside cgiMain > is this odd CGIT IO CGIResult. I tried using liftM on writeFile, but > it then complained that "newanns" was a string instead of a list of > strings, which I don't understand at all. Here's the code: > > DeleteAnnotation.hs: > [snip code] -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From jefferson.r.heard at gmail.com Tue Jul 29 12:14:52 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Tue Jul 29 12:04:33 2008 Subject: [Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution In-Reply-To: <488F403B.1070600@ed.ac.uk> References: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> <488F403B.1070600@ed.ac.uk> Message-ID: <4165d3a70807290914p3b61c0e8u99d55716e5b58f2f@mail.gmail.com> Beautiful, thank you. That worked. On Tue, Jul 29, 2008 at 12:07 PM, allan wrote: > Hi > > I had this same problem and I'm not sure my way is correct but I used 'Control.Monad.Trans.liftIO' > Here is some code that I am using > > {- > The main program is pretty simple we just run the CGI action. > -} > main :: IO () > main = Cgi.runCGI $ Cgi.handleErrors cgiMain > > {- > To be able to produce graphs which we can then display in the output > webpage we require that our main function, that is the one which creates > the page be in the IO monad. > -} > cgiMain :: CGI CGIResult > cgiMain = > do visitInfo <- getAnalysisData > page <- Monad.Trans.liftIO $ createPage visitInfo > Cgi.output $ Xhtml.renderHtml page > > createPage :: Visit -> IO Html > createPage ..... blah stuff you don't care about > > getAnalysisData :: CGI Visit > > Visit is a data type I've made to hold the information obtained from the page. > > Hope this helps > allan > > > Jefferson Heard wrote: >> Please ignore the obvious security holes, as this is not a script >> meant for public consumption, but some internal testing and >> prototyping. I would like to write the result of my computation out >> to a file inside of cgiMain, but the type of the monad inside cgiMain >> is this odd CGIT IO CGIResult. I tried using liftM on writeFile, but >> it then complained that "newanns" was a string instead of a list of >> strings, which I don't understand at all. Here's the code: >> >> DeleteAnnotation.hs: >> > [snip code] > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards From philip.weaver at gmail.com Tue Jul 29 13:02:50 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Tue Jul 29 12:52:31 2008 Subject: [Haskell-cafe] Cabal and Strings and CPP In-Reply-To: <20080729111437.3438de53.Malcolm.Wallace@cs.york.ac.uk> References: <20080729111437.3438de53.Malcolm.Wallace@cs.york.ac.uk> Message-ID: On Tue, Jul 29, 2008 at 3:14 AM, Malcolm Wallace < Malcolm.Wallace@cs.york.ac.uk> wrote: > "Philip Weaver" wrote: > > > I'm trying to use CPP-defined strings in a Haskell module, like this: > > main :: IO () > > main = putStrLn FOO > > This of course will not work: > > ghc -DFOO="hello world" --make Main.hs -o test > > Have you tried using ANSI cpp's stringification operator? > > {-# LANGUAGE CPP #-} > #define STRING(bar) #bar > main :: IO () > main = putStrLn FOO > > ghc -DFOO="STRING(hello world)" --make Main.hs -o test > Yes, I have. It does not seem to be supported. > Regards, > Malcolm > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080729/cc42bc14/attachment.htm From wren at freegeek.org Tue Jul 29 13:37:17 2008 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 29 13:26:58 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: References: <20080729013258.GA19607@shion.is.fushizen.net> <488EC2F0.9060100@freegeek.org> Message-ID: <19707.192.12.13.2.1217353037.squirrel@mail.freegeek.org> Pablo Nogueira wrote: > wren ng thornton wrote: > > It compiles just fine with (DeriveType A b => b -> b) after all, which > > resolves directly to (B -> B) > > That's not the case: > > simpleNarrow :: DeriveType A b => b -> b > simpleNarrow = id > > Couldn't match expected type `b' (a rigid variable) > against inferred type `B' > `b' is bound by the type signature for `simpleNarrow' ... > When using functional dependencies to combine > DeriveType A B, arising from the instance declaration ... > DeriveType A b, arising from is bound by the type signature for > `simpleNarrow' ... [0] wren@xenobia:~/test $ cat fundep.hs {-# OPTIONS_GHC -fglasgow-exts #-} class DeriveType a b | a -> b data A = A data B = B instance DeriveType A B simpleNarrow :: DeriveType A b => b -> b simpleNarrow = id [0] wren@xenobia:~/test $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 [0] wren@xenobia:~/test $ ghci fundep.hs GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( fundep.hs, interpreted ) Ok, modules loaded: Main. *Main> :t simpleNarrow simpleNarrow :: B -> B > I think Bryan got the order in which type inference/checking works > wrong. The dependency is not "resolved" before calculating the type as > he suggested. Indeed. "Resolved" was a sloppy word choice on my part, but the point is that after all the inference is done you do end up with (B -> B) because B just so happens to be (DeriveType A b => b). However, the function's actual type is indeed (DeriveType A b => b -> b) since contexts are only a constraint on polymorphism and never take part in driving the inference. > > *Main> :t someDestructor (SomeConstructor undefined undefined :: ComplexType A) > > B > > Why not this: > > *Main> someDestructor (SomeConstructor A B) > B That works too, I just didn't have deriving Show in place at the time. > > But if you have actual values rather than just unit types, note that this > > won't work: > > > > > instance DeriveType A B where > > > someDestructor (SomeConstructor _ b) = b > > I couldn't understand the sentence "actual values rather than unit > types". What do you have in mind? [...] > I didn't pay attention to the |b| value returned. So what you meant > was that only a constant function will do, not a function that returns > the value |b|. Yeah, pretty much. The types A and B given were both unit types, i.e. they have only one value each namely A and B. Hence we could do the other version with someDestructor _ = B since we're throwing away the old value of type (b quantified by SomeConstructor) and constructing a new value of type (forall b. DeriveType A b => b). This is safe because we're never actually peeking into the existential. And yet, since there's only one value of the type we can safely reconstruct it knowing that we're not leaking any information about SomeConstructor's internals. But what happens if there's more than one value of type B? If we tried the version above in order to return the second field of the ComplexType, that would allow the existential to escape. Hence my comments that the methods of DeriveType can only be used to gain views onto the value b but never to recover its actual type. If we had some non-dependent type that we could convert the existential into, then we can still safely use that view as below: [0] wren@xenobia:~/test $ cat fundep2.hs {-# OPTIONS_GHC -fglasgow-exts #-} class DeriveType a b | a -> b, b -> a where someDestructor :: b -> Int data A = A deriving Show data B = B1 | B2 deriving Show instance DeriveType A B where someDestructor B1 = 1 someDestructor B2 = 2 simpleNarrow :: DeriveType A b => b -> b simpleNarrow = id data ComplexType a where SomeConstructor :: DeriveType a b => a -> b -> ComplexType a unComplexType :: ComplexType a -> Int unComplexType (SomeConstructor _ b) = someDestructor b [0] wren@xenobia:~/test $ ghci fundep2.hs GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( fundep.hs, interpreted ) Ok, modules loaded: Main. *Main> unComplexType (SomeConstructor A B1) 1 *Main> The thing to bear in mind with all of this is what should the type signature of unComplexType be? If someDestructor returned the second field directly then there would be no way for us to give a type signature to unComplexType. The "b" it would return is only scoped in the type of SomeConstructor and so we have no way of referring to that exact variable. What we can do however is return a monomorphic type or a non-dependent polymorphic type [e.g. (forall a. Num a => a) is just fine, even rank-2 types are fine, just not ones that depend on the existential b]. You'll also notice that we had to add a fundep from b back to a in order to get this to type check. Otherwise we can't be sure that the type a for the existential b is the same as the a (namely A) from ComplexType. This might be too restrictive for the application in question however. Again, I'm not sure any of this really helps the OP. If Ryan Ingram's type families code works, then I'd say to go for that. The whole point of existentials is that they loose information (that's how ST ensures safety). If loosing information in order to block introspection isn't the goal, then existential types really aren't what you want. If the whole goal is just to reduce the size of type signatures that need to be written out, then type aliases could also be used in order to save on the, er, typing without even resorting to any sort of sexy types. -- Live well, ~wren From t.h at gmx.info Tue Jul 29 15:35:59 2008 From: t.h at gmx.info (Timo B. =?utf-8?q?H=C3=BCbel?=) Date: Tue Jul 29 15:27:03 2008 Subject: [Haskell-cafe] ANN: Hayoo! beta 0.2 In-Reply-To: <200807231104.03210.t.h@gmx.info> References: <200807231104.03210.t.h@gmx.info> Message-ID: <200807292135.59673.t.h@gmx.info> Hi all, thanks for all the feedback! We have just uploaded a new Hayoo! index, which fixes several small glitches (for example, in the function descriptions) but the most important thing is, that it does include the docs for Gtk2hs now. Additionally, we are working on a function to restrict the search to specific packages and will hopefully finish it this week. I will also soon have a look into all these interface related JavaScript issues, but as this unfortunately does not involve Haskell coding, it may not be on my high priority list ;) Stay tuned! Timo & Sebastian From claus.reinke at talk21.com Tue Jul 29 15:41:00 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Jul 29 15:30:46 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGLfamilyof libraries fromextralibs References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt><20080725172737.GB6953@scytale.galois.com><013901c8ee9a$69a25640$58237ad5@cr3lt><20080725211323.GM6953@scytale.galois.com> <488B007F.6050901@um.es><4165d3a70807260538o100d6f1cs5eecc4e7f97d0d90@mail.gmail.com><18704556.post@talk.nabble.com> <4165d3a70807290629w18f333f0q22fe77450d70e44d@mail.gmail.com> Message-ID: <028201c8f1b3$0888c440$71338351@cr3lt> > Scott, I couldn't have said it better. My impression has always been > that HOpenGL looks like OpenGL would have looked like if they'd had a > flexible language to work with when they desgned it. My only quibble > would be with the documentation. Is there any way out there for > haddock to produce a linked and indexed PDF, so that I can better > guess where one function will be relative to another that feels like > it ought to be related? It is probably a bit obscured in the alphabetically sorted Haddock main contents listing, but if you look at something like http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL-GL.html http://www.haskell.org/ghc/docs/latest/html/libraries/GLUT/Graphics-UI-GLUT.html you'll find that the layout closely follows the relevant specs (at least, it used to). So you can use the PDF files for the official specs to find what you need, and then those doc layout pages to translate to HOpenGL. Just as the examples follow the red book, to make translation easy. Do I need to mention that I agree with Scott?-) Claus > On Mon, Jul 28, 2008 at 11:42 PM, scodil wrote: >> >> I'll chime in with a "me too". I use Haskell and OpenGL for prototyping >> scientific visualization software, 3D models and such. Not that I think it >> couldn't be used for production software, its just that I just don't produce >> much :) >> >> The library really is fantastic. I don't think it gets enough fanfare. The >> only >> other GL API that rivals it is the C API itself. Most other languages >> provide a >> shoddy & incomplete interface to that, instead of an idiomatic >> interpretation of the OpenGL spec. I can't think of a single language, not >> even >> python, whose OpenGL bindings come close. >> >> I get the impression (from a inadequate sample of irc logs and list chatter) >> that many Haskellers see HOpenGL as 'just an OpenGL binding', like it was >> readline or curses or something. It just plugs a hole in the Haskell/OS >> interface, and its worth is merely a function of the size and importance of >> that hole. Instead I advocate, as Claus and others have done, that it's a >> shining example of how to write a Haskell interface to a well known API. >> >> If you never used C OpenGL and learned GL using Haskell, you might not >> notice >> anything special about it. But that's kind of my point, its just so damn >> good >> it blends into the background. The only people who notice this, I think, are >> experienced C OpenGL programmers, and the overlap between them and the >> Haskell >> community in general is small I bet. Their voice in that community smaller >> still. >> >> This probably has little bearing on the issue of whether to keep or drop >> HOpenGL in the near future, but I think that if 'the community' (or whoever >> has >> a say in these things) like the style of HOpenGL, and want to encourage >> bindings to be written in that style, they should place the library >> prominently >> in the pantheon of Haskell libs. Demoting it has the opposite effect. >> >> Anyway, I just wanted to take advantage of a rare opportunity to sing its >> praise. >> >> Scott >> >> >>> Yes, same here; don't worry, it's not going away. It would be nice >>> to know, though, how many people are using it and what they're using >>> it for. I'm using it for information visualization, and slowly >>> evolving/cribbing together something like the Processing >>> (http://www.processing.org) framework for Haskell as I do more things. >>> >>> On Sat, Jul 26, 2008 at 5:46 AM, Alberto Ruiz wrote: >>>> Don Stewart wrote: >>>>> >>>>> claus.reinke: >>>>>> >>>>>> But neither do I believe the rumour that OpenGL isn't much >>>>>> used, and forwarding the removal notice gives those users the >>>>>> opportunity to speak up now if they prefer no gaps in OpenGL presence, >>>>>> or >>>>>> forever to hold their peace, as they say. >>>>> >>>>> I for one have noticed this library *is* actively used. Many of the fun >>>>> new games that have appeared are using it, in particular. >>>>> >>>>> Such as: >>>>> >>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag >>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Monadius >>>>> >>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/roguestar-gl >>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rsagl >>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing >>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/topkata >>>>> >>>>> The tutorial was also translated to the wiki last week, >>>>> >>>>> http://haskell.org/haskellwiki/Opengl >>>>> >>>>> It's a good, reliable package, in active use, widely ported. >>>> >>>> I'd just like to say that HOpenGL is essential for me. It is one of the >>>> reasons why I finally decided to use Haskell for all my work... >>>> >>>> Alberto >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> >>> >>> -- >>> I try to take things like a crow; war and chaos don't always ruin a >>> picnic, they just mean you have to be careful what you swallow. >>> >>> -- Jessica Edwards >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/Fw%3A-patch-applied-%28ghc%29%3A-Remove-the-OpenGL-family-of-libraries-fromextralibs-tp18655695p18704556.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > I try to take things like a crow; war and chaos don't always ruin a > picnic, they just mean you have to be careful what you swallow. > > -- Jessica Edwards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Tue Jul 29 16:21:53 2008 From: dons at galois.com (Don Stewart) Date: Tue Jul 29 16:11:34 2008 Subject: [Haskell-cafe] #haskell irc channel reaches 500 users Message-ID: <20080729202153.GA1585@scytale.galois.com> A small announcement :) 6 1/2 years after its inception, under the guiding hand of Shae Erisson (aka shapr), the #haskell IRC channel[1] on freenode has finally reached 500 users! To chart the growth, we can note that the channel was founded in late 2001, and had slow growth till 2006, reaching 200 users in January of that year. Since then growth in the user base has been far more rapid, reaching 300 users in Dec 2006, 400 users in August 2007, and 500 users by July 2008. This puts the channel at around the 12th largest community of the 7000 freenode channels. For comparision, a sample of the state of the other language communities, with comments comapred to their status a year ago: #php 720 #python 640 -- up from 5th place #perl 620 ##c++ 585 ##c 530 > #haskell 502 #rubyonrails 428 #ruby-lang 350 -- down from 420 max. ##javascript 308 #lisp 295 #erlang 178 #perl6 129 -- unchanged #scheme 148 -- unchanged #lua 120 #ocaml 70 -- unchanged You can see the growth of the channel over here: http://www.cse.unsw.edu.au/~dons/irc If you've not dropped by the channel yet, feel free to come and chat, and toss around some lambdas! :) Cheers, Don From isaacdupree at charter.net Tue Jul 29 17:03:45 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Tue Jul 29 16:53:37 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <20080729153446.07b01145.Malcolm.Wallace@cs.york.ac.uk> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080728111118.7eafcacf.Malcolm.Wallace@cs.york.ac.uk> <1217330120.12754.312.camel@localhost> <20080729153446.07b01145.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <488F85B1.5070600@charter.net> Malcolm Wallace wrote: > As a package author (rather than a user), I would see this as a primary > benefit of having my packages added to the Platform. And as a package > user (rather than author), there is the corresponding antibenefit of > removing a package like HOpenGL from the Platform: a diminished > likelihood of the maintainer being already aware of packaging flaws. perhaps we can work on getting set up automatic testing etc. with a relatively basic Haskell Platform. If that turns out to be easily done, we can look at making a facility for all package authors (at least, ones on Hackage) to volunteer to have their packages automatically checked for such breakages. Sure, it could still help a little to be part of an official Haskell Platform, but there are reasons we're trying to designate a Haskell Platform smaller than Hackage. -Isaac From ryani.spam at gmail.com Tue Jul 29 17:48:54 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 29 17:38:35 2008 Subject: [Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution In-Reply-To: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> References: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> Message-ID: <2f9b2d30807291448q2f6dccbne4a76478eba09b29@mail.gmail.com> On Tue, Jul 29, 2008 at 8:57 AM, Jefferson Heard wrote: > I tried using liftM on writeFile, but it then complained that "newanns" > was a string instead of a list of strings, which I don't understand at all. liftM isn't what you think it is. > liftM :: (a -> b) -> (m a -> m b) which is doing something weird depending how you inserted it: > liftM (writeFile "x") :: Monad m => m String -> m (IO ()) which could theoretically have m get forced to be a list as the typechecker tries to figure out how to decipher this mess... > liftM (writeFile "x") :: [String] -> [IO ()] or something else weird. You are looking for either lift or liftIO, from Control.Monad.Trans > lift :: (Monad m, MonadTrans t) => m a -> t m a > liftIO :: MonadIO m => IO a -> m a -- ryan From lrpalmer at gmail.com Tue Jul 29 18:08:07 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Jul 29 17:57:49 2008 Subject: [Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution In-Reply-To: <2f9b2d30807291448q2f6dccbne4a76478eba09b29@mail.gmail.com> References: <4165d3a70807290857y1b2ed18fv67e261d3b5d0bfd3@mail.gmail.com> <2f9b2d30807291448q2f6dccbne4a76478eba09b29@mail.gmail.com> Message-ID: <7ca3f0160807291508n3e0bc87erc91fdbfb41609d37@mail.gmail.com> On Tue, Jul 29, 2008 at 3:48 PM, Ryan Ingram wrote: > On Tue, Jul 29, 2008 at 8:57 AM, Jefferson Heard > wrote: >> I tried using liftM on writeFile, but it then complained that "newanns" >> was a string instead of a list of strings, which I don't understand at all. > > liftM isn't what you think it is. > >> liftM :: (a -> b) -> (m a -> m b) > which is doing something weird depending how you inserted it: >> liftM (writeFile "x") :: Monad m => m String -> m (IO ()) > which could theoretically have m get forced to be a list as the > typechecker tries to figure out how to decipher this mess... >> liftM (writeFile "x") :: [String] -> [IO ()] > or something else weird. Probably: writeFile :: FilePath -> String -> IO () liftM writeFile :: Monad m => m FilePath -> m (String -> IO ()) liftM writeFile "path" Will unify "path"::[Char] with m Filepath. Instantiate m to [] (by head matching), but [Char] does not match [Filepath] (= [String]), giving the error the OP mentioned. From pedagand at gmail.com Tue Jul 29 18:31:24 2008 From: pedagand at gmail.com (Pierre-Evariste Dagand) Date: Tue Jul 29 18:21:07 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications In-Reply-To: References: <18686250.post@talk.nabble.com> <4683d9370807281152v5565fcf2x79a2da91e7ed5215@mail.gmail.com> Message-ID: <6cb897b30807291531y477a56et6870584d62d2eb8c@mail.gmail.com> > Does _Conceptual Mathematics_ discuss monads? I'm currently working on it, I'm at section 13 with Monoids but there are no Monads at the horizon. I have briefly gone through the end of the book and did not recognize anything similar to a Monad. But I might not be able to recognize a Monad in a category theory presentation, though. However, as a complete n00b in category theory, I find this book perfect. I tried Mac Lane's book ("Categories for the working mathematician") first but I was distracted by the notations and the long, painful mathematical sentences. Nevertheless, none of these books are computer scientist-oriented. I have been recommended "Categories for Types" by Crole. I plan to work on it after Conceptual Mathematic and Mac Lane's book. Right now, I've now real opinion about it: at first glance, it looks as technical as Mac Lane's book. I believe some enlightened people here could give more useful review of it. HTH, -- Pierre-Evariste DAGAND http://perso.eleves.bretagne.ens-cachan.fr/~dagand/ From duncan.coutts at worc.ox.ac.uk Tue Jul 29 19:58:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jul 29 19:46:56 2008 Subject: [Haskell-cafe] Fw: patch applied (ghc): Remove the OpenGL family of libraries fromextralibs In-Reply-To: <20080729153446.07b01145.Malcolm.Wallace@cs.york.ac.uk> References: <00f001c8ee77$98b0ed70$58237ad5@cr3lt> <20080728111118.7eafcacf.Malcolm.Wallace@cs.york.ac.uk> <1217330120.12754.312.camel@localhost> <20080729153446.07b01145.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <1217375900.12754.334.camel@localhost> On Tue, 2008-07-29 at 15:34 +0100, Malcolm Wallace wrote: > > I don't think that's right. The HP maintainers are not (and cannot be) > > the maintainers of each individual package. That just does not scale. > > Oh absolutely, but I was imagining that (at least part of) the purpose > of the Platform is to generate automatic notifications to package > owners, when a change in either ghc or the packaging infrastructure or > the package's dependencies, leads to their own package breaking. So the > Platform effectively generates an auto-prompt when maintenance is > required. I hope that this is something that hackage will provide to all packages, including those in the platform. > Given that such a lot of package-breakage is not due to changes in the > functionality of the library itself, but purely to changes in the > packaging system surrounding it, this would in my eyes shift > a certain amount of responsibility in the right direction. :-) > (Not the responsibility to fix, but the responsibility to notify.) > > As a package author (rather than a user), I would see this as a primary > benefit of having my packages added to the Platform. And as a package > user (rather than author), there is the corresponding antibenefit of > removing a package like HOpenGL from the Platform: a diminished > likelihood of the maintainer being already aware of packaging flaws. I really want to build the platform on the hackage infrastructure and have all packages benefit from additional checks. Then users and maintainers can act on that extra information. It should also make it easier for new packages to join the platform because it'll be easier to demonstrate that the various quality hoops have been jumped through. So yes, we might expect platform volunteers to send occasional patches to keep existing packages working, but really a package being in the platform requires a maintainer rather than guaranteeing maintenance. Duncan From weihu at cs.virginia.edu Tue Jul 29 21:28:06 2008 From: weihu at cs.virginia.edu (Wei Hu) Date: Tue Jul 29 21:19:44 2008 Subject: [Haskell-cafe] A question about mfix Message-ID: What's wrong about giving mfix the following general definition? > mfix :: (a -> m a) -> m a > mfix f = (mfix f) >>= f I know it diverges if (>>=) is strict on the first argument. My question is, is this definition correct for all lazy monads? The documentation (http://haskell.org/ghc/docs/latest/html/libraries/base/ Control-Monad-Fix.html#v%3Amfix) says "mfix f executes the action f only once, with the eventual output fed back as the input.". So my definition looks like a valid one, doesn't it? I haven't fully wrapped my head around this monadic fixed-point thing yet. So, if you can give an example showing how my definition differs from a standard monad, that'll be great. From ryani.spam at gmail.com Tue Jul 29 22:12:45 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 29 22:02:24 2008 Subject: [Haskell-cafe] A question about mfix In-Reply-To: References: Message-ID: <2f9b2d30807291912t43a32742s6f70a40bca0ee17a@mail.gmail.com> These aren't equivalent, at least with respect to sharing; consider the sharing behavior with respect to the Identity monad: > import Control.Monad.Fix > import Control.Monad.Identity > mfixWei f = mfix f >>= f > v1, v2 :: [Int] > v1 = runIdentity $ mfix $ \a -> return (0:a) > v2 = runIdentity $ mfixWei $ \a -> return (0:a) > cons = (:) While v1 and v2 are both infinite lists of zeros, v1 takes constant memory: v1 = cons 0 v1 but v2 takes memory linear in size to the last element evaluated: v2 = cons 0 t0 where t0 = cons 0 t1 t1 = cons 0 t2 t2 = cons 0 t3 t3 = ... This is where the specification about "executes the action f only once" comes from; your implementation expands to mfix f = mfix f >>= f = (mfix f >>= f) >>= f = ((mfix f >>= f) >>= f) >>= f = ... As you can see, f might get executed an arbitrary number of times depending on "how lazy" >>= is. Now, I don't know the answer if you "fix" (pardon the pun) your definition of mfix to > mfixLazy f = let x = x >>= f in x which gives the correct sharing results in the "runIdentity" case. -- ryan On Tue, Jul 29, 2008 at 6:28 PM, Wei Hu wrote: > What's wrong about giving mfix the following general definition? > > >> mfix :: (a -> m a) -> m a >> mfix f = (mfix f) >>= f > > > I know it diverges if (>>=) is strict on the first argument. My > question is, is this definition correct for all lazy monads? The > documentation (http://haskell.org/ghc/docs/latest/html/libraries/base/ > Control-Monad-Fix.html#v%3Amfix) says "mfix f executes the action f > only once, with the eventual output fed back as the input.". So my > definition looks like a valid one, doesn't it? > > I haven't fully wrapped my head around this monadic fixed-point thing > yet. So, if you can give an example showing how my definition differs > from a standard monad, that'll be great. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From DekuDekuplex at Yahoo.com Tue Jul 29 22:58:35 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Jul 29 22:48:20 2008 Subject: [Haskell-cafe] www.haskell.org is currently very slow in responding to HTTP requests Message-ID: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> Currently, www.haskell.org is very slow in responding to HTTP requests, taking over a minute just to display the main home page. This problem is causing difficulties in displaying options for mailing lists or in displaying HaskellWiki pages. Perhaps the server needs to be rebooted? Could somebody responsible for maintaining the server please look into this issue? It seems to have been persisting for at least about half an hour. Thank you.... -- Benjamin L. Russell From weihu at cs.virginia.edu Wed Jul 30 00:18:12 2008 From: weihu at cs.virginia.edu (Wei Hu) Date: Wed Jul 30 00:08:07 2008 Subject: [Haskell-cafe] Re: A question about mfix References: <2f9b2d30807291912t43a32742s6f70a40bca0ee17a@mail.gmail.com> Message-ID: So that's also why the fix function from Data.Function is defined as > fix f = let x = f x in x instead of > fix f = f $ fix f right? But, I think my mfix definition and your mfixLazy definition are still semantically equivalent because they expand to the same thing. See the following example: > import Control.Monad.Identity > -- Strict Identity monad > data IdentityS a = IdentityS { runIdentityS :: a } deriving Show > instance Monad IdentityS where > return = IdentityS > (IdentityS m) >>= k = k m > mfix' f = mfix' f >>= f > mfixLazy f = let x = x >>= f in x > facFM f = return (\i -> > if i == 0 > then 1 > else i * f (i - 1) > ) > -- correctly outputs 3! = 6 > test = runIdentity (mfix facFM) 3 > -- stack overflows > test2 = runIdentityS (mfix' facFM) 3 > -- hangs > test3 = runIdentityS (mfixLazy facFM) 3 Thanks for pointing out the sharing part. My original question is still unanswered: for lazy monads, can we give such a general mfix definition? From agentzh at gmail.com Wed Jul 30 01:17:22 2008 From: agentzh at gmail.com (Agent Zhang) Date: Wed Jul 30 01:07:01 2008 Subject: [Haskell-cafe] www.haskell.org is currently very slow in responding to HTTP requests In-Reply-To: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> References: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> Message-ID: On Wed, Jul 30, 2008 at 10:58 AM, Benjamin L. Russell wrote: > Currently, www.haskell.org is very slow in responding to HTTP > requests, taking over a minute just to display the main home page. It seems to take forever here ;) Cheers, -agentzh From lrpalmer at gmail.com Wed Jul 30 01:38:06 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jul 30 01:27:45 2008 Subject: [Haskell-cafe] Re: A question about mfix In-Reply-To: References: <2f9b2d30807291912t43a32742s6f70a40bca0ee17a@mail.gmail.com> Message-ID: <7ca3f0160807292238p41768586i8ea88563fdb22e0b@mail.gmail.com> On Wed, Jul 30, 2008 at 4:18 AM, Wei Hu wrote: > Thanks for pointing out the sharing part. My original question is still > unanswered: for lazy monads, can we give such a general mfix definition? I dunno. I played around with your definition and the mfix laws, and was unable to get anywhere. * mfix (return . h) = return (fix h) * mfix (\x -> a >>= \y -> f x y) = \y -> mfix (\x -> f x y) * if h is strict, mfix (liftM h . f) = liftM h (mfix (f . h)) * mfix (\x -> mfix (\y -> f x y)) = mfix (\x -> f x x) But I think this is the way to approach it. There are many kinds of "lazy monads", so presumably an exploration of this form will help characterize the kinds of monads for which this definition does work. Luke From voigt at tcs.inf.tu-dresden.de Wed Jul 30 02:00:16 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Jul 30 01:41:43 2008 Subject: [Haskell-cafe] Re: A question about mfix In-Reply-To: References: <2f9b2d30807291912t43a32742s6f70a40bca0ee17a@mail.gmail.com> Message-ID: <48900370.3020708@tcs.inf.tu-dresden.de> Wei Hu wrote: > Thanks for pointing out the sharing part. My original question is still > unanswered: for lazy monads, can we give such a general mfix definition? I think Section 4.1 of http://doi.acm.org/10.1145/351240.351257 has the answer to that. The problem with the proposed general definition is that it computes the fixpoint not only for the values that are manipulated, but also for the involved effects. This doesn't show up for the Identity monad, since there are no effects then, but for more interesting monads the difference should become visible, not only with respect to sharing, but really with respect to the expected outcome of the computation. (Constructing an explicit counterexample is left as an exercise ;-) Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From voigt at tcs.inf.tu-dresden.de Wed Jul 30 02:37:44 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Jul 30 02:29:33 2008 Subject: [Haskell-cafe] Re: A question about mfix In-Reply-To: <48900370.3020708@tcs.inf.tu-dresden.de> References: <2f9b2d30807291912t43a32742s6f70a40bca0ee17a@mail.gmail.com> <48900370.3020708@tcs.inf.tu-dresden.de> Message-ID: <48900C38.60607@tcs.inf.tu-dresden.de> Janis Voigtlaender wrote: > Wei Hu wrote: > >> Thanks for pointing out the sharing part. My original question is >> still unanswered: for lazy monads, can we give such a general mfix >> definition? > > ... > (Constructing an explicit counterexample is left as an exercise ;-) Oh, I couldn't resist to do my own exercise ... > import Control.Monad.Fix > import Control.Monad.State.Lazy > > data Nat = S Nat | Z deriving Show > > tick :: State Nat () > tick = get >>= put . S > > test1 = runState (mfix (const tick)) Z > > test2 = runState (mfix (const tick)) Z > where mfix f = (mfix f) >>= f Now: *Main> test1 ((),S Z) *Main> test2 ((),S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S ........ I think that proves the point. Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From jason.dusek at gmail.com Wed Jul 30 03:02:22 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Jul 30 03:02:25 2008 Subject: [Haskell-cafe] [Haskell Beginner] Compiling wxhaskell fails for me In-Reply-To: <5d4de89e0807280249g1bb95c79ra9d607e234147182@mail.gmail.com> References: <5d4de89e0807280249g1bb95c79ra9d607e234147182@mail.gmail.com> Message-ID: <42784f260807300002l223e3aa6s1b397567817a93f9@mail.gmail.com> Maybe you could try building it with 2.8 and let us know how it goes? -- _jsn From jason.dusek at gmail.com Wed Jul 30 03:15:12 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Jul 30 03:15:14 2008 Subject: [Haskell-cafe] haddock build failure Message-ID: <42784f260807300015m7e88b455u9919905e95fb0755@mail.gmail.com> I am unable to build Haddock 2.1, with the odd error: src/Haddock/GHC/Typecheck.hs:82:4: Constructor `HsModule' should have 7 arguments, but has been given 8 What is the root of it, you think? -- _jsn Configuring haddock-2.1.0... Dependency base-any: using base-3.0.2.0 Dependency haskell98-any: using haskell98-1.0.1.0 Dependency ghc>=6.8.2&&<6.9: using ghc-6.8.3 Dependency filepath-any: using filepath-1.1.0.0 Dependency directory-any: using directory-1.0.0.1 Dependency pretty-any: using pretty-1.0.0.0 Dependency containers-any: using containers-0.1.0.2 Dependency array-any: using array-0.1.0.0 Using compiler: ghc-6.8.3 Using install prefix: /usr/local Binaries installed in: /usr/local/bin Libraries installed in: /usr/local/lib/haddock-2.1.0/ghc-6.8.3 Private binaries installed in: /usr/local/libexec Data files installed in: /usr/local/share/haddock-2.1.0 Documentation installed in: /usr/local/share/doc/haddock-2.1.0 No alex found Using ar found on system at: /usr/bin/ar No c2hs found No cpphs found No ffihugs found Using ghc version 6.8.3 found on system at: /usr/bin/ghc Using ghc-pkg version 6.8.3 found on system at: /usr/bin/ghc-pkg No greencard found No haddock found No happy found No hmake found Using hsc2hs version 0.66-ghc found on system at: /usr/bin/hsc2hs No hscolour found No hugs found No jhc found Using ld found on system at: /usr/bin/ld No nhc98 found No pfesetup found Using pkg-config version 0.23 found on system at: /opt/local/bin/pkg-config Using ranlib found on system at: /usr/bin/ranlib Using tar found on system at: /usr/bin/tar Creating dist/build (and its parents) Creating dist/build/autogen (and its parents) Preprocessing library haddock-2.1.0... Preprocessing executables for haddock-2.1.0... Building haddock-2.1.0... Building library... Creating dist/build (and its parents) Creating dist/build (and its parents) /usr/bin/ghc -package-name haddock-2.1.0 --make -hide-all-packages -i -idist/build/autogen -idist/build -isrc -Idist/build -odir dist/build -hidir dist/build -stubdir dist/build -package base-3.0.2.0 -package haskell98-1.0.1.0 -package ghc-6.8.3 -package filepath-1.1.0.0 -package directory-1.0.0.1 -package pretty-1.0.0.0 -package containers-0.1.0.2 -package array-0.1.0.0 -O -XCPP -XPatternGuards -XDeriveDataTypeable -XPatternSignatures -XMagicHash Distribution.Haddock Haddock.Types Haddock.InterfaceFile Haddock.Exception Linking... /usr/bin/ar q dist/build/libHShaddock-2.1.0.a dist/build/Distribution/Haddock.o dist/build/Haddock/Types.o dist/build/Haddock/InterfaceFile.o dist/build/Haddock/Exception.o ar: creating archive dist/build/libHShaddock-2.1.0.a /usr/bin/ld -x -r -o dist/build/HShaddock-2.1.0.o.tmp dist/build/Distribution/Haddock.o dist/build/Haddock/Types.o dist/build/Haddock/InterfaceFile.o dist/build/Haddock/Exception.o Building executable: haddock... Creating dist/build/haddock (and its parents) Creating dist/build/haddock/haddock-tmp (and its parents) Creating dist/build/haddock/haddock-tmp (and its parents) /usr/bin/ghc -o dist/build/haddock/haddock --make -hide-all-packages -i -idist/build/autogen -idist/build/haddock/haddock-tmp -isrc -Idist/build/haddock/haddock-tmp -odir dist/build/haddock/haddock-tmp -hidir dist/build/haddock/haddock-tmp -stubdir dist/build/haddock/haddock-tmp -package base-3.0.2.0 -package haskell98-1.0.1.0 -package ghc-6.8.3 -package filepath-1.1.0.0 -package directory-1.0.0.1 -package pretty-1.0.0.0 -package containers-0.1.0.2 -package array-0.1.0.0 -O -funbox-strict-fields -O2 -XCPP -XPatternGuards -XDeriveDataTypeable -XPatternSignatures -XMagicHash src/Main.hs [ 8 of 24] Compiling Paths_haddock ( dist/build/autogen/Paths_haddock.hs, dist/build/haddock/haddock-tmp/Paths_haddock.o ) [15 of 24] Compiling Haddock.GHC.Typecheck ( src/Haddock/GHC/Typecheck.hs, dist/build/haddock/haddock-tmp/Haddock/GHC/Typecheck.o ) src/Haddock/GHC/Typecheck.hs:82:4: Constructor `HsModule' should have 7 arguments, but has been given 8 In the pattern: HsModule _ _ _ _ _ mbOpts _ _ In a pattern binding: HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed In the definition of `mkGhcModule': mkGhcModule (mod, file, checkedMod) dynflags = GhcModule {ghcModule = mod, ghcFilename = file, ghcMbDocOpts = mbOpts, ghcHaddockModInfo = info, ghcMbDoc = mbDoc, ghcGroup = group, ghcMbExports = mbExports, ghcExportedNames = modInfoExports modInfo, ghcNamesInScope = fromJust $ modInfoTopLevelScope modInfo, ghcInstances = modInfoInstances modInfo} where HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed (group, _, mbExports, mbDoc, info) = renamed (parsed, renamed, _, modInfo) = checkedMod From shelarcy at gmail.com Wed Jul 30 03:18:31 2008 From: shelarcy at gmail.com (shelarcy) Date: Wed Jul 30 03:18:43 2008 Subject: [Haskell-cafe] [Haskell Beginner] Compiling wxhaskell fails for me In-Reply-To: <42784f260807300002l223e3aa6s1b397567817a93f9@mail.gmail.com> References: <5d4de89e0807280249g1bb95c79ra9d607e234147182@mail.gmail.com> <42784f260807300002l223e3aa6s1b397567817a93f9@mail.gmail.com> Message-ID: Hi, On Wed, 30 Jul 2008 16:02:22 +0900, Jason Dusek wrote: > Maybe you could try building it with 2.8 and let us know how > it goes? We are discussing his problem in wxhaskell-users mailing-list now. http://www.mail-archive.com/wxhaskell-users@lists.sourceforge.net/msg00488.html I send patch to fix that. And patch is already pushed in latest darcs repository. http://www.mail-archive.com/wxhaskell-devel@lists.sourceforge.net/msg00224.html I'm waiting for his answer now. Best Regards, -- shelarcy http://page.freett.com/shelarcy/ From yann at kierun.org Wed Jul 30 03:34:05 2008 From: yann at kierun.org (Yann Golanski) Date: Wed Jul 30 03:34:08 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. Message-ID: <20080730073405.GA19682@kierun.org> I cannot seem to be able to install yi via cabal install. The error I get is as follows. I suspect alex is not installed in the correct place. ; sudo cabal install yi Resolving dependencies... Downloading yi-0.4.3... Configuring yi-0.4.3... cabal: alex version >=2.0.1 && <3 is required but it could not be found. cabal: Error: some packages failed to install: yi-0.4.3 failed during the configure step. The exception was: exit: ExitFailure 1 ; sudo cabal install alex Resolving dependencies... Downloading alex-2.2... [1 of 1] Compiling Main ( Setup.lhs, dist/setup/Main.o ) Linking dist/setup/setup ... Warning: defaultUserHooks in Setup script is deprecated. Configuring alex-2.2... Warning: No 'build-type' specified. If you do not need a custom Setup.hs or ./configure script then use 'build-type: Simple'. Preprocessing executables for alex-2.2... Building alex-2.2... [...] Linking dist/build/alex/alex ... Installing: /home/yann/.cabal/bin ; sudo cabal install yi Resolving dependencies... 'yi-0.4.3' is cached. Configuring yi-0.4.3... cabal: alex version >=2.0.1 && <3 is required but it could not be found. cabal: Error: some packages failed to install: yi-0.4.3 failed during the configure step. The exception was: exit: ExitFailure 1 -- yann@kierun.org -= H+ =- www.kierun.org PGP: 009D 7287 C4A7 FD4F 1680 06E4 F751 7006 9DE2 6318 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/91f86b31/attachment.bin From agentzh at gmail.com Wed Jul 30 03:44:02 2008 From: agentzh at gmail.com (Agent Zhang) Date: Wed Jul 30 03:44:04 2008 Subject: [Haskell-cafe] Network.FastCGI does not emit stderr outputs to lighttpd's error.log? Message-ID: Hi, I'm trying Network.FastCGI + lighttpd 1.4.9 to develop a RESTful service platform. I've found that stderr (especially those from Debug.Trace) get lost in the error.log file. But plain CGI mode with Network.CGI works perfectly (all stderr outputs appear in error.log). Besides, my Perl fastcgi script also logs stderr with the same lighttpd. So it does seem that my lighttpd's mod_fastcgi module is OK. Is this a known issue in the Haskell fastcgi library? Is there a workaround or a fix? Thanks in advance :) Cheers, -agentzh From duncan.coutts at worc.ox.ac.uk Wed Jul 30 03:49:27 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 30 03:47:38 2008 Subject: [Haskell-cafe] www.haskell.org is currently very slow in responding to HTTP requests In-Reply-To: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> References: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> Message-ID: <1217404167.12754.348.camel@localhost> On Wed, 2008-07-30 at 11:58 +0900, Benjamin L.Russell wrote: > Currently, www.haskell.org is very slow in responding to HTTP > requests, taking over a minute just to display the main home page. > This problem is causing difficulties in displaying options for mailing > lists or in displaying HaskellWiki pages. > > Perhaps the server needs to be rebooted? Could somebody responsible > for maintaining the server please look into this issue? It seems to > have been persisting for at least about half an hour. Thank you.... Should now be sorted out for the moment. We have this recurring problem where a single client can hog all the download slots. Not using a lot of bandwidth, just taking up slots which eventually means the number of slots hits the maximum and so no new connections can be made. I'm not sure how other people configure apache to avoid this problem. It seems like a really cheap DoS attack so other apache users must get similar problems and so there must be a solution somewhere. Sadly, I've not seen anything obvious. Duncan From d.kahlenberg at googlemail.com Wed Jul 30 04:00:18 2008 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Wed Jul 30 04:00:25 2008 Subject: [Haskell-cafe] [Haskell Beginner] Compiling wxhaskell fails for me In-Reply-To: References: <5d4de89e0807280249g1bb95c79ra9d607e234147182@mail.gmail.com> <42784f260807300002l223e3aa6s1b397567817a93f9@mail.gmail.com> Message-ID: <5d4de89e0807300100l474118f3p7ada9c295f08c836@mail.gmail.com> Hi, for a comprehension, when trying to compile the wxwidgets 2.8.8 version with the configure flag `--enable-graphics_ctx' the make process fails with the error messages ../../src/msw/graphics.cpp:92:21: gdiplus.h: No such file or directory ../../src/msw/graphics.cpp:93: error: `Gdiplus' is not a namespace-name in front, you can find my config.log and makeerrors.log attached 2008/7/30 shelarcy : > Hi, > > On Wed, 30 Jul 2008 16:02:22 +0900, Jason Dusek wrote: >> Maybe you could try building it with 2.8 and let us know how >> it goes? > > We are discussing his problem in wxhaskell-users mailing-list now. > > http://www.mail-archive.com/wxhaskell-users@lists.sourceforge.net/msg00488.html > > I send patch to fix that. And patch is already pushed in latest darcs repository. > > http://www.mail-archive.com/wxhaskell-devel@lists.sourceforge.net/msg00224.html > > I'm waiting for his answer now. > > > Best Regards, > > -- > shelarcy > http://page.freett.com/shelarcy/ > -------------- next part -------------- A non-text attachment was scrubbed... Name: config.log Type: application/octet-stream Size: 200456 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/9cd9c490/config-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: makeerrors.log Type: application/octet-stream Size: 155718 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/9cd9c490/makeerrors-0001.obj From jason.dusek at gmail.com Wed Jul 30 04:09:47 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Jul 30 04:09:52 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <874p6g8gji.wl%jeremy@n-heptane.com> References: <48877C64.6060809@btinternet.com> <874p6g8gji.wl%jeremy@n-heptane.com> Message-ID: <42784f260807300109p6d0acc4axb0854b61503b27b4@mail.gmail.com> for example: "head (filter (\x -> x > 5) [1..])" in a strict language, you can't easily play with infinite lists In a strict language, you would write that as "6" :) -- _jsn From pablo at babel.ls.fi.upm.es Wed Jul 30 04:17:30 2008 From: pablo at babel.ls.fi.upm.es (Pablo Nogueira) Date: Wed Jul 30 04:17:35 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: <19707.192.12.13.2.1217353037.squirrel@mail.freegeek.org> References: <20080729013258.GA19607@shion.is.fushizen.net> <488EC2F0.9060100@freegeek.org> <19707.192.12.13.2.1217353037.squirrel@mail.freegeek.org> Message-ID: > [0] wren@xenobia:~/test $ ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.8.2 I have an older version and wonder what goes wrong. Now that I think of it, other stuff that I coudn't compile might actually work in 6.8 It does make sense that |b| is resolved to |B| because of the functional dependency. P. From david.waern at gmail.com Wed Jul 30 04:37:49 2008 From: david.waern at gmail.com (David Waern) Date: Wed Jul 30 04:37:52 2008 Subject: [Haskell-cafe] haddock build failure In-Reply-To: <42784f260807300015m7e88b455u9919905e95fb0755@mail.gmail.com> References: <42784f260807300015m7e88b455u9919905e95fb0755@mail.gmail.com> Message-ID: This is a bug in the haddock.cabal file. Haddock 2.1 doesn't support GHC 6.8.3. The next release will, and it will come out soon. David 2008/7/30 Jason Dusek : > I am unable to build Haddock 2.1, with the odd error: > > src/Haddock/GHC/Typecheck.hs:82:4: > Constructor `HsModule' should have 7 arguments, but has been given 8 > > What is the root of it, you think? > > -- > _jsn > > > > > Configuring haddock-2.1.0... > Dependency base-any: using base-3.0.2.0 > Dependency haskell98-any: using haskell98-1.0.1.0 > Dependency ghc>=6.8.2&&<6.9: using ghc-6.8.3 > Dependency filepath-any: using filepath-1.1.0.0 > Dependency directory-any: using directory-1.0.0.1 > Dependency pretty-any: using pretty-1.0.0.0 > Dependency containers-any: using containers-0.1.0.2 > Dependency array-any: using array-0.1.0.0 > Using compiler: ghc-6.8.3 > Using install prefix: /usr/local > Binaries installed in: /usr/local/bin > Libraries installed in: /usr/local/lib/haddock-2.1.0/ghc-6.8.3 > Private binaries installed in: /usr/local/libexec > Data files installed in: /usr/local/share/haddock-2.1.0 > Documentation installed in: /usr/local/share/doc/haddock-2.1.0 > No alex found > Using ar found on system at: /usr/bin/ar > No c2hs found > No cpphs found > No ffihugs found > Using ghc version 6.8.3 found on system at: /usr/bin/ghc > Using ghc-pkg version 6.8.3 found on system at: /usr/bin/ghc-pkg > No greencard found > No haddock found > No happy found > No hmake found > Using hsc2hs version 0.66-ghc found on system at: /usr/bin/hsc2hs > No hscolour found > No hugs found > No jhc found > Using ld found on system at: /usr/bin/ld > No nhc98 found > No pfesetup found > Using pkg-config version 0.23 found on system at: /opt/local/bin/pkg-config > Using ranlib found on system at: /usr/bin/ranlib > Using tar found on system at: /usr/bin/tar > Creating dist/build (and its parents) > Creating dist/build/autogen (and its parents) > Preprocessing library haddock-2.1.0... > Preprocessing executables for haddock-2.1.0... > Building haddock-2.1.0... > Building library... > Creating dist/build (and its parents) > Creating dist/build (and its parents) > /usr/bin/ghc -package-name haddock-2.1.0 --make -hide-all-packages -i > -idist/build/autogen -idist/build -isrc -Idist/build -odir dist/build > -hidir dist/build -stubdir dist/build -package base-3.0.2.0 -package > haskell98-1.0.1.0 -package ghc-6.8.3 -package filepath-1.1.0.0 > -package directory-1.0.0.1 -package pretty-1.0.0.0 -package > containers-0.1.0.2 -package array-0.1.0.0 -O -XCPP -XPatternGuards > -XDeriveDataTypeable -XPatternSignatures -XMagicHash > Distribution.Haddock Haddock.Types Haddock.InterfaceFile > Haddock.Exception > Linking... > /usr/bin/ar q dist/build/libHShaddock-2.1.0.a > dist/build/Distribution/Haddock.o dist/build/Haddock/Types.o > dist/build/Haddock/InterfaceFile.o dist/build/Haddock/Exception.o > ar: creating archive dist/build/libHShaddock-2.1.0.a > /usr/bin/ld -x -r -o dist/build/HShaddock-2.1.0.o.tmp > dist/build/Distribution/Haddock.o dist/build/Haddock/Types.o > dist/build/Haddock/InterfaceFile.o dist/build/Haddock/Exception.o > Building executable: haddock... > Creating dist/build/haddock (and its parents) > Creating dist/build/haddock/haddock-tmp (and its parents) > Creating dist/build/haddock/haddock-tmp (and its parents) > /usr/bin/ghc -o dist/build/haddock/haddock --make -hide-all-packages > -i -idist/build/autogen -idist/build/haddock/haddock-tmp -isrc > -Idist/build/haddock/haddock-tmp -odir dist/build/haddock/haddock-tmp > -hidir dist/build/haddock/haddock-tmp -stubdir > dist/build/haddock/haddock-tmp -package base-3.0.2.0 -package > haskell98-1.0.1.0 -package ghc-6.8.3 -package filepath-1.1.0.0 > -package directory-1.0.0.1 -package pretty-1.0.0.0 -package > containers-0.1.0.2 -package array-0.1.0.0 -O -funbox-strict-fields -O2 > -XCPP -XPatternGuards -XDeriveDataTypeable -XPatternSignatures > -XMagicHash src/Main.hs > [ 8 of 24] Compiling Paths_haddock ( > dist/build/autogen/Paths_haddock.hs, > dist/build/haddock/haddock-tmp/Paths_haddock.o ) > [15 of 24] Compiling Haddock.GHC.Typecheck ( > src/Haddock/GHC/Typecheck.hs, > dist/build/haddock/haddock-tmp/Haddock/GHC/Typecheck.o ) > > src/Haddock/GHC/Typecheck.hs:82:4: > Constructor `HsModule' should have 7 arguments, but has been given 8 > In the pattern: HsModule _ _ _ _ _ mbOpts _ _ > In a pattern binding: HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed > In the definition of `mkGhcModule': > mkGhcModule (mod, file, checkedMod) dynflags > = GhcModule > {ghcModule = mod, ghcFilename = file, > ghcMbDocOpts = mbOpts, > ghcHaddockModInfo = info, ghcMbDoc = mbDoc, > ghcGroup = group, > ghcMbExports = mbExports, > ghcExportedNames = modInfoExports modInfo, > ghcNamesInScope = fromJust $ > modInfoTopLevelScope modInfo, > ghcInstances = modInfoInstances modInfo} > where > HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed > (group, _, mbExports, mbDoc, info) = renamed > (parsed, renamed, _, modInfo) = checkedMod > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mad.one at gmail.com Wed Jul 30 04:45:49 2008 From: mad.one at gmail.com (Austin Seipp) Date: Wed Jul 30 04:45:56 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <20080730073405.GA19682@kierun.org> References: <20080730073405.GA19682@kierun.org> Message-ID: <1217407476-sup-5296@existential.local> Excerpts from Yann Golanski's message of Wed Jul 30 02:34:05 -0500 2008: > I cannot seem to be able to install yi via cabal install. The error I > get is as follows. I suspect alex is not installed in the correct > place. > ... Hi, cabal-install will put installed binaries in $HOME/.cabal/bin by default as far as I can tell, you should move the binary somewhere in your $PATH if you want cabal-install to pick it up for installing yi. Austin From yann at kierun.org Wed Jul 30 04:59:35 2008 From: yann at kierun.org (Yann Golanski) Date: Wed Jul 30 04:59:39 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <1217407476-sup-5296@existential.local> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> Message-ID: <20080730085935.GA19968@kierun.org> Quoth Austin Seipp on Wed, Jul 30, 2008 at 03:45:49 -0500 > Excerpts from Yann Golanski's message of Wed Jul 30 02:34:05 -0500 2008: > > I cannot seem to be able to install yi via cabal install. The error I > > get is as follows. I suspect alex is not installed in the correct > > place. > > ... > > Hi, > > cabal-install will put installed binaries in $HOME/.cabal/bin by > default as far as I can tell, you should move the binary somewhere in > your $PATH if you want cabal-install to pick it up for installing yi. Well, that indeed sorted that one. But still no luck: ; sudo cabal install yi Resolving dependencies... 'yi-0.4.3' is cached. Configuring yi-0.4.3... Preprocessing library yi-0.4.3... Preprocessing executables for yi-0.4.3... Building yi-0.4.3... Yi/UI/Vty.hs:42:7: Could not find module `Graphics.Vty': Use -v to see a list of the files searched for. cabal: Error: some packages failed to install: yi-0.4.3 failed during the building phase. The exception was: exit: ExitFailure 1 -- yann@kierun.org -= H+ =- www.kierun.org PGP: 009D 7287 C4A7 FD4F 1680 06E4 F751 7006 9DE2 6318 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/376afd2b/attachment.bin From DekuDekuplex at Yahoo.com Wed Jul 30 05:03:44 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Jul 30 05:03:54 2008 Subject: [Haskell-cafe] Re: www.haskell.org is currently very slow in responding to HTTP requests References: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> <1217404167.12754.348.camel@localhost> Message-ID: <9gb094tbofvfucq3uc6qu808kf2783sc3d@4ax.com> On Wed, 30 Jul 2008 08:49:27 +0100, Duncan Coutts wrote: > >On Wed, 2008-07-30 at 11:58 +0900, Benjamin L.Russell wrote: >> Currently, www.haskell.org is very slow in responding to HTTP >> requests, taking over a minute just to display the main home page. >> This problem is causing difficulties in displaying options for mailing >> lists or in displaying HaskellWiki pages. >> >> Perhaps the server needs to be rebooted? Could somebody responsible >> for maintaining the server please look into this issue? It seems to >> have been persisting for at least about half an hour. Thank you.... > >Should now be sorted out for the moment. Yes; it works fine now. >We have this recurring problem where a single client can hog all the >download slots. Not using a lot of bandwidth, just taking up slots which >eventually means the number of slots hits the maximum and so no new >connections can be made. I'm not sure how other people configure apache >to avoid this problem. It seems like a really cheap DoS attack so other >apache users must get similar problems and so there must be a solution >somewhere. Sadly, I've not seen anything obvious. Thanks; I'll keep your description in mind. If I come across anything that looks helpful, I'll post it on this mailing list. -- Benjamin L. Russell From nicolas.pouillard at gmail.com Wed Jul 30 05:06:43 2008 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Wed Jul 30 05:07:27 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <20080730085935.GA19968@kierun.org> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> <20080730085935.GA19968@kierun.org> Message-ID: <1217408744-sup-6870@port-ext16.ensta.fr> Excerpts from Yann Golanski's message of Wed Jul 30 10:59:35 +0200 2008: > Quoth Austin Seipp on Wed, Jul 30, 2008 at 03:45:49 -0500 > > Excerpts from Yann Golanski's message of Wed Jul 30 02:34:05 -0500 2008: > > > I cannot seem to be able to install yi via cabal install. The error I > > > get is as follows. I suspect alex is not installed in the correct > > > place. > > > ... > > > > Hi, > > > > cabal-install will put installed binaries in $HOME/.cabal/bin by > > default as far as I can tell, you should move the binary somewhere in > > your $PATH if you want cabal-install to pick it up for installing yi. > > Well, that indeed sorted that one. But still no luck: > > ; sudo cabal install yi > Resolving dependencies... > 'yi-0.4.3' is cached. > Configuring yi-0.4.3... > Preprocessing library yi-0.4.3... > Preprocessing executables for yi-0.4.3... > Building yi-0.4.3... > > Yi/UI/Vty.hs:42:7: > Could not find module `Graphics.Vty': > Use -v to see a list of the files searched for. > cabal: Error: some packages failed to install: > yi-0.4.3 failed during the building phase. The exception was: > exit: ExitFailure 1 > Can you try the vty flag: $ sudo cabal install yi -fvty -- Nicolas Pouillard aka Ertai -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/3df4fa33/signature.bin From duncan.coutts at worc.ox.ac.uk Wed Jul 30 05:20:03 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 30 05:18:13 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <1217407476-sup-5296@existential.local> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> Message-ID: <1217409603.12754.350.camel@localhost> On Wed, 2008-07-30 at 03:45 -0500, Austin Seipp wrote: > Excerpts from Yann Golanski's message of Wed Jul 30 02:34:05 -0500 2008: > > I cannot seem to be able to install yi via cabal install. The error I > > get is as follows. I suspect alex is not installed in the correct > > place. > > ... > > Hi, > > cabal-install will put installed binaries in $HOME/.cabal/bin by > default as far as I can tell, you should move the binary somewhere in > your $PATH if you want cabal-install to pick it up for installing yi. Yep. See this ticket: http://hackage.haskell.org/trac/hackage/ticket/289 Of course if anyone would like to volunteer to implement this we'd all appreciate it. Duncan From yann at kierun.org Wed Jul 30 05:23:45 2008 From: yann at kierun.org (Yann Golanski) Date: Wed Jul 30 05:23:46 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <1217408744-sup-6870@port-ext16.ensta.fr> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> <20080730085935.GA19968@kierun.org> <1217408744-sup-6870@port-ext16.ensta.fr> Message-ID: <20080730092345.GA20138@kierun.org> Quoth Nicolas Pouillard on Wed, Jul 30, 2008 at 11:06:43 +0200 > Excerpts from Yann Golanski's message of Wed Jul 30 10:59:35 +0200 2008: > > ; sudo cabal install yi > > Resolving dependencies... > > 'yi-0.4.3' is cached. > > Configuring yi-0.4.3... > > Preprocessing library yi-0.4.3... > > Preprocessing executables for yi-0.4.3... > > Building yi-0.4.3... > > > > Yi/UI/Vty.hs:42:7: > > Could not find module `Graphics.Vty': > > Use -v to see a list of the files searched for. > > cabal: Error: some packages failed to install: > > yi-0.4.3 failed during the building phase. The exception was: > > exit: ExitFailure 1 > > > > Can you try the vty flag: > > $ sudo cabal install yi -fvty Sadly, I get the same error as before. What debugging output would you need? -- yann@kierun.org -= H+ =- www.kierun.org PGP: 009D 7287 C4A7 FD4F 1680 06E4 F751 7006 9DE2 6318 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/caffaa9f/attachment.bin From ashley at semantic.org Wed Jul 30 05:54:55 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Wed Jul 30 05:54:58 2008 Subject: [Haskell-cafe] Re: www.haskell.org is currently very slow in responding to HTTP requests In-Reply-To: <1217404167.12754.348.camel@localhost> References: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> <1217404167.12754.348.camel@localhost> Message-ID: <48903A6F.8030808@semantic.org> Duncan Coutts wrote: >> Perhaps the server needs to be rebooted? Could somebody responsible >> for maintaining the server please look into this issue? It seems to >> have been persisting for at least about half an hour. Thank you.... > > Should now be sorted out for the moment. I noticed this too a few hours ago and restarted the apache server. I also reset the clock (which was about 10 minutes behind) with ntpdate (ntp seems to be installed but not running). The OS is kind of old on that machine. It's RHEL AS release 3, which dates from October 2003, though with the latest update (update 9, June 2007). Latest is RHEL 5.2. Other software versions: Linux 2.4.21 (latest is 2.6.26) Apache 2.0.46 (latest is 2.2.9) MySQL 3.23.58 (latest is 5.0.51a) PHP 4.3.2 (latest is 5.2.6) MediaWiki 1.5.4 (latest is 1.12) It might be worth upgrading some of that, though if that includes Linux or RHEL overall it would probably require physical access to the box. I'm more familiar with Ubuntu, and I couldn't figure out offhand if there is some kind of mechanism to automatically download and install software similar to apt. I couldn't get up2date to work. -- Ashley Yakeley From dav.vire+haskell at gmail.com Wed Jul 30 07:05:49 2008 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 30 07:05:54 2008 Subject: [Haskell-cafe] haddock build failure In-Reply-To: References: <42784f260807300015m7e88b455u9919905e95fb0755@mail.gmail.com> Message-ID: <4c88418c0807300405w79614253t8d1a773f8f9b7c0d@mail.gmail.com> On Wed, Jul 30, 2008 at 10:37 AM, David Waern wrote: > This is a bug in the haddock.cabal file. Haddock 2.1 doesn't support > GHC 6.8.3. The next release will, and it will come out soon. I had the same problem, 2.2 fixes it. From gwern0 at gmail.com Wed Jul 30 09:21:23 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Jul 30 09:22:22 2008 Subject: [Haskell-cafe] [Off-topic] Loss of humour In-Reply-To: <42784f260807300109p6d0acc4axb0854b61503b27b4@mail.gmail.com> References: <48877C64.6060809@btinternet.com> <874p6g8gji.wl%jeremy@n-heptane.com> <42784f260807300109p6d0acc4axb0854b61503b27b4@mail.gmail.com> Message-ID: <20080730132123.GB24331@craft> On 2008.07.30 01:09:47 -0700, Jason Dusek scribbled 0.2K characters: > for example: "head (filter (\x -> x > 5) [1..])" > in a strict language, you can't easily play with infinite lists > In a strict language, you would write that as "6" :) > > -- > _jsn Fear not! That quote is preserved in the Lambdabot darcs repo. It shall yet remember when we are but dust. -- gwern Sponge Uzbekistan enigma bird assassinate Bunny CAVE zone burned Comirex -------------- 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/20080730/e0429df6/attachment.bin From dons at galois.com Wed Jul 30 13:56:12 2008 From: dons at galois.com (Don Stewart) Date: Wed Jul 30 13:56:38 2008 Subject: [Haskell-cafe] Network.FastCGI does not emit stderr outputs to lighttpd's error.log? In-Reply-To: References: Message-ID: <20080730175612.GC15694@scytale.galois.com> agentzh: > Hi, > > I'm trying Network.FastCGI + lighttpd 1.4.9 to develop a RESTful > service platform. I've found that stderr (especially those from > Debug.Trace) get lost in the error.log file. But plain CGI mode with > Network.CGI works perfectly (all stderr outputs appear in error.log). > Besides, my Perl fastcgi script also logs stderr with the same > lighttpd. So it does seem that my lighttpd's mod_fastcgi module is OK. > > Is this a known issue in the Haskell fastcgi library? Is there a > workaround or a fix? Thanks in advance :) We've had no problems with this and apache at least. Is lighttpd doing something funny with error logging? -- Don From nbloomf at gmail.com Wed Jul 30 14:43:33 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Wed Jul 30 14:43:35 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications In-Reply-To: <6cb897b30807291531y477a56et6870584d62d2eb8c@mail.gmail.com> References: <18686250.post@talk.nabble.com> <4683d9370807281152v5565fcf2x79a2da91e7ed5215@mail.gmail.com> <6cb897b30807291531y477a56et6870584d62d2eb8c@mail.gmail.com> Message-ID: <9858b5620807301143j5e536f31k15b91905e8524e27@mail.gmail.com> If you want to see a human being explain some categorical ideas, there is a nice (and growing) collection of video mini-tutorials on youtube by the Catsters. http://www.youtube.com/user/TheCatsters -Nathan Bloomfield (I first sent this just to Pierre by accident - sorry!) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/69d10e28/attachment.htm From ryani.spam at gmail.com Wed Jul 30 14:44:02 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jul 30 14:44:03 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: <19707.192.12.13.2.1217353037.squirrel@mail.freegeek.org> References: <20080729013258.GA19607@shion.is.fushizen.net> <488EC2F0.9060100@freegeek.org> <19707.192.12.13.2.1217353037.squirrel@mail.freegeek.org> Message-ID: <2f9b2d30807301144j6e7ae8e7p1f0abed7a383eb39@mail.gmail.com> Hmm, I'm kind of confused by this now. I feel like the following code really should compile, but it doesn't. There's no use of existentials to hide type information at all. The functional dependency seems like it should give us the constraint (b1 ~ b2) allowing Refl to typecheck. > {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, GADTs #-} > module DeriveType where > > class DeriveType a b | a -> b > data TypeEq a b where Refl :: TypeEq a a > > test :: (DeriveType a b1, DeriveType a b2) => a -> TypeEq b1 b2 > test _ = Refl But... derivetype.hs:8:9: Couldn't match expected type `b1' against inferred type `b2' `b1' is a rigid type variable bound by the type signature for `test' at derivetype.hs:7:22 `b2' is a rigid type variable bound by the type signature for `test' at derivetype.hs:7:39 Expected type: TypeEq b1 b2 Inferred type: TypeEq b2 b2 In the expression: Refl In the definition of `test': test _ = Refl Is there a good reason this doesn't typecheck? -- ryan On Tue, Jul 29, 2008 at 10:37 AM, wren ng thornton wrote: > Pablo Nogueira wrote: >> wren ng thornton wrote: >> > It compiles just fine with (DeriveType A b => b -> b) after all, which >> > resolves directly to (B -> B) >> >> That's not the case: >> >> simpleNarrow :: DeriveType A b => b -> b >> simpleNarrow = id >> >> Couldn't match expected type `b' (a rigid variable) >> against inferred type `B' >> `b' is bound by the type signature for `simpleNarrow' ... >> When using functional dependencies to combine >> DeriveType A B, arising from the instance declaration ... >> DeriveType A b, arising from is bound by the type signature for >> `simpleNarrow' ... > > [0] wren@xenobia:~/test $ cat fundep.hs > {-# OPTIONS_GHC -fglasgow-exts #-} > > class DeriveType a b | a -> b > > data A = A > data B = B > > instance DeriveType A B > > simpleNarrow :: DeriveType A b => b -> b > simpleNarrow = id > > [0] wren@xenobia:~/test $ ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.8.2 > > [0] wren@xenobia:~/test $ ghci fundep.hs > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > [1 of 1] Compiling Main ( fundep.hs, interpreted ) > Ok, modules loaded: Main. > *Main> :t simpleNarrow > simpleNarrow :: B -> B > > >> I think Bryan got the order in which type inference/checking works >> wrong. The dependency is not "resolved" before calculating the type as >> he suggested. > > Indeed. "Resolved" was a sloppy word choice on my part, but the point is > that after all the inference is done you do end up with (B -> B) because B > just so happens to be (DeriveType A b => b). However, the function's > actual type is indeed (DeriveType A b => b -> b) since contexts are only a > constraint on polymorphism and never take part in driving the inference. > > >> > *Main> :t someDestructor (SomeConstructor undefined undefined :: > ComplexType A) >> > B >> >> Why not this: >> >> *Main> someDestructor (SomeConstructor A B) >> B > > That works too, I just didn't have deriving Show in place at the time. > > >> > But if you have actual values rather than just unit types, note that this >> > won't work: >> > >> > > instance DeriveType A B where >> > > someDestructor (SomeConstructor _ b) = b >> >> I couldn't understand the sentence "actual values rather than unit >> types". What do you have in mind? > [...] >> I didn't pay attention to the |b| value returned. So what you meant >> was that only a constant function will do, not a function that returns >> the value |b|. > > Yeah, pretty much. > > The types A and B given were both unit types, i.e. they have only one > value each namely A and B. Hence we could do the other version with > someDestructor _ = B since we're throwing away the old value of type (b > quantified by SomeConstructor) and constructing a new value of type > (forall b. DeriveType A b => b). This is safe because we're never actually > peeking into the existential. And yet, since there's only one value of the > type we can safely reconstruct it knowing that we're not leaking any > information about SomeConstructor's internals. > > But what happens if there's more than one value of type B? If we tried the > version above in order to return the second field of the ComplexType, that > would allow the existential to escape. Hence my comments that the methods > of DeriveType can only be used to gain views onto the value b but never to > recover its actual type. If we had some non-dependent type that we could > convert the existential into, then we can still safely use that view as > below: > > > [0] wren@xenobia:~/test $ cat fundep2.hs > {-# OPTIONS_GHC -fglasgow-exts #-} > > class DeriveType a b | a -> b, b -> a where > someDestructor :: b -> Int > > data A = A deriving Show > data B = B1 | B2 deriving Show > > instance DeriveType A B where > someDestructor B1 = 1 > someDestructor B2 = 2 > > simpleNarrow :: DeriveType A b => b -> b > simpleNarrow = id > > > data ComplexType a where > SomeConstructor :: DeriveType a b => a -> b -> ComplexType a > > unComplexType :: ComplexType a -> Int > unComplexType (SomeConstructor _ b) = someDestructor b > > [0] wren@xenobia:~/test $ ghci fundep2.hs > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > [1 of 1] Compiling Main ( fundep.hs, interpreted ) > Ok, modules loaded: Main. > *Main> unComplexType (SomeConstructor A B1) > 1 > *Main> > > > The thing to bear in mind with all of this is what should the type > signature of unComplexType be? If someDestructor returned the second field > directly then there would be no way for us to give a type signature to > unComplexType. The "b" it would return is only scoped in the type of > SomeConstructor and so we have no way of referring to that exact variable. > What we can do however is return a monomorphic type or a non-dependent > polymorphic type [e.g. (forall a. Num a => a) is just fine, even rank-2 > types are fine, just not ones that depend on the existential b]. > > You'll also notice that we had to add a fundep from b back to a in order > to get this to type check. Otherwise we can't be sure that the type a for > the existential b is the same as the a (namely A) from ComplexType. This > might be too restrictive for the application in question however. > > > Again, I'm not sure any of this really helps the OP. If Ryan Ingram's type > families code works, then I'd say to go for that. The whole point of > existentials is that they loose information (that's how ST ensures > safety). If loosing information in order to block introspection isn't the > goal, then existential types really aren't what you want. If the whole > goal is just to reduce the size of type signatures that need to be written > out, then type aliases could also be used in order to save on the, er, > typing without even resorting to any sort of sexy types. > > -- > Live well, > ~wren > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From haskell at colquitt.org Wed Jul 30 14:58:26 2008 From: haskell at colquitt.org (John Dorsey) Date: Wed Jul 30 14:58:27 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <1217408744-sup-6870@port-ext16.ensta.fr> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> <20080730085935.GA19968@kierun.org> <1217408744-sup-6870@port-ext16.ensta.fr> Message-ID: <20080730185826.GA10438@colquitt.org> > [problems with cabal install yi] Curious, I tried this out, on a Debian etch box with GHC 6.8.3. "cabal update ; cabal install yi --global" complained about needing alex >=2.0.something and <3. Then "cabal install alex" happily installed alex version 2.2. Finally, "cabal install yi --global" worked fine. Is something amiss with cabal-install? Shouldn't it have automatically installed alex? Or does it only do that with libraries, by design? For that matter, "ghc-pkg list | grep -i alex" doesn't list anything, after I cabal-installed it. How does cabal verify the prerequisite alex version? (Or does it?) I'm enjoying cabal since I've begun using it, but it's still somewhat opaque to me. Regards, John Dorsey From jstrait at moonloop.net Wed Jul 30 15:27:58 2008 From: jstrait at moonloop.net (Jon Strait) Date: Wed Jul 30 15:38:28 2008 Subject: [Haskell-cafe] Re: ANN: Yi 0.4.1 In-Reply-To: <1217193635.12754.257.camel@localhost> References: <20080727204932.GC13904@scytale.galois.com> <1217193635.12754.257.camel@localhost> Message-ID: <4890C0BE.2040004@moonloop.net> I had the same problem on x86_64 linux using the Gtk front and no custom config with the current Yi on Hackage (0.4.3). Using catchGError revealed: user error (Failed to open file '/home/bernardy/.cabal/share/yi-0.4.3/art/yi+lambda-fat.32.png': No such file or directory) Tracked down to Paths_yi.hs : bindir = "/home/bernardy/.cabal/bin" libdir = "/home/bernardy/.cabal/lib/yi-0.4.3/ghc-6.8.3" datadir = "/home/bernardy/.cabal/share/yi-0.4.3" libexecdir = "/home/bernardy/.cabal/libexec" I just built the latest Yi from Darcs and this seems to have been fixed. - Jon Duncan Coutts wrote: > On Sun, 2008-07-27 at 20:58 +0000, Jean-Philippe Bernardy wrote: > >> Don Stewart galois.com> writes: >> >> >> >>> $ yi -f pango >>> Launching custom yi: "/home/dons/.yi/yi-x86_64-linux" >>> yi: exception :: System.Glib.GError.GError >>> >>> Anyone seen this? >>> >> Consistently on x64. The pango stuff is generally unstable anyway. I'm not sure >> what's to blame. >> > > That's interesting. That's a Haskell exception (dynamic type). I doubt > it's being thrown by the Pango code, there's only one use of it there, > in parseMarkup and that should throw parsing errors pretty much > independent of platform. > > You can catch those GError exceptions and print more interesting info. > Use: > > >> catchGError >> (do ... >> ...) >> (\(GError dom code msg) -> fail msg) >> > > > Duncan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From sic at lerp.com Wed Jul 30 16:22:04 2008 From: sic at lerp.com (Scott Cruzen) Date: Wed Jul 30 16:22:06 2008 Subject: [Haskell-cafe] Libevent FFI problems In-Reply-To: <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> References: <3e62d4360807231228h31fbd2d5t665c6242ff8eb778@mail.gmail.com> <396556a20807251021v450c5acdvbb44f638c9b4cdfb@mail.gmail.com> <3e62d4360807251224m4c683643n994ac54029bdbabb@mail.gmail.com> <220e47b40807251300v367b63deo3f98fb9a5304b95@mail.gmail.com> <396556a20807251305la6cb008kc55d23cfce3b8292@mail.gmail.com> Message-ID: <20080730202204.GA2021@harlan.lerp.com> * Adam Langley [080725 13:05]: > 2008/7/25 Krzysztof Skrz?tnicki : > > "Developing a high-performance web server in Concurrent Haskell" > > http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf (see page 15) > > > > Perhaps you might be interested in this paper also because of its topic. > > That's a good reference. Also note that the paper is 6 years old and > GHC has come a long way since then. I'd suspect that the graph on page > 15 would look much more favourable to Haskell these days. http://www.seas.upenn.edu/~lipeng/homepage/unify.html This paper (and included code) should be relevant and useful. There's an epoll wrapper and a lot of good stuff. From mad.one at gmail.com Wed Jul 30 17:21:30 2008 From: mad.one at gmail.com (Austin Seipp) Date: Wed Jul 30 17:21:36 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <20080730185826.GA10438@colquitt.org> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> <20080730085935.GA19968@kierun.org> <1217408744-sup-6870@port-ext16.ensta.fr> <20080730185826.GA10438@colquitt.org> Message-ID: <1217452516-sup-5176@existential.local> Excerpts from John Dorsey's message of Wed Jul 30 13:58:26 -0500 2008: > Is something amiss with cabal-install? Shouldn't it have automatically > installed alex? Or does it only do that with libraries, by design? AFAICT, dependencies are only downloaded and installed if they are listed in a .cabal files 'dependency' field (providing they aren't already installed) which yes, means libraries by design. I've not had cabal-install ever track down necessary applications in my experience. As well, this issue came up on #haskell the other day and my conclusion is that no, cabal does not track down and install any *applications* that are necessary (someone tried to install yi, needed alex, build failed, and after 'cabal-install alex' everything was peachy.) > For that matter, "ghc-pkg list | grep -i alex" doesn't list anything, > after I cabal-installed it. How does cabal verify the prerequisite alex > version? (Or does it?) ghc-pkg lists libraries that are registered with the ghc package manager (globally and locally); alex is simply an application, not a library, so there's really nothing for GHC to register. As for telling what version is necessary, I haven't the slightest. Duncan, can you shed some light here? Austin From jason.dusek at gmail.com Wed Jul 30 19:07:06 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Jul 30 19:07:06 2008 Subject: [Haskell-cafe] haddock build failure In-Reply-To: <4c88418c0807300405w79614253t8d1a773f8f9b7c0d@mail.gmail.com> References: <42784f260807300015m7e88b455u9919905e95fb0755@mail.gmail.com> <4c88418c0807300405w79614253t8d1a773f8f9b7c0d@mail.gmail.com> Message-ID: <42784f260807301607w4e051152tddf07ce4aadc766e@mail.gmail.com> Thank you. -- _jsn From duncan.coutts at worc.ox.ac.uk Wed Jul 30 19:55:15 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 30 19:55:24 2008 Subject: [Haskell-cafe] Cabal + yi + alex problem. In-Reply-To: <20080730185826.GA10438@colquitt.org> References: <20080730073405.GA19682@kierun.org> <1217407476-sup-5296@existential.local> <20080730085935.GA19968@kierun.org> <1217408744-sup-6870@port-ext16.ensta.fr> <20080730185826.GA10438@colquitt.org> Message-ID: <1217462115.12754.378.camel@localhost> On Wed, 2008-07-30 at 14:58 -0400, John Dorsey wrote: > > [problems with cabal install yi] > > Curious, I tried this out, on a Debian etch box with GHC 6.8.3. > > "cabal update ; cabal install yi --global" > complained about needing alex >=2.0.something and <3. > > Then "cabal install alex" happily installed alex version 2.2. Finally, > "cabal install yi --global" worked fine. > > Is something amiss with cabal-install? Shouldn't it have automatically > installed alex? Or does it only do that with libraries, by design? Right, currently it only tracks library dependencies, not tools. See: http://hackage.haskell.org/trac/hackage/ticket/227 "cabal-install does consider build-tools as dependencies" > For that matter, "ghc-pkg list | grep -i alex" doesn't list anything, > after I cabal-installed it. The ghc package database is of libraries. Applications are not registered anywhere. > How does cabal verify the prerequisite alex version? (Or does it?) It calls alex --version > I'm enjoying cabal since I've begun using it, but it's still somewhat > opaque to me. There's still plenty of work to do. You and indeed everyone else is most welcome to get involved and have a go at fixing bugs or adding frequently requested features. Easy tickets: http://hackage.haskell.org/trac/hackage/report/13 Guide to the source code: http://hackage.haskell.org/trac/hackage/wiki/SourceGuide Duncan From vigalchin at gmail.com Thu Jul 31 00:45:54 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jul 31 00:45:55 2008 Subject: [Haskell-cafe] a really dumb posting question ;^( Message-ID: <5ae4f2ba0807302145j13a92fc4v18d6c76e9596444a@mail.gmail.com> Hello, What do I do to do a followup haskell cafe posting? E.g. I want to put a posting on the category theory thread! Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080730/f8ffaf71/attachment.htm From brad.larsen at gmail.com Thu Jul 31 01:00:10 2008 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Jul 31 01:00:11 2008 Subject: [Haskell-cafe] a really dumb posting question ;^( In-Reply-To: <5ae4f2ba0807302145j13a92fc4v18d6c76e9596444a@mail.gmail.com> References: <5ae4f2ba0807302145j13a92fc4v18d6c76e9596444a@mail.gmail.com> Message-ID: Vasili, You respond to whatever message interests you, just like normal email. Make sure the message is CC'd or addressed to haskell-cafe@haskell.org to allow everyone to see it. Regards, Brad Larsen 2008/7/31 Galchin, Vasili : > Hello, > > What do I do to do a followup haskell cafe posting? E.g. I want to put a > posting on the category theory thread! > > Kind regards, Vasili > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From vigalchin at gmail.com Thu Jul 31 02:22:47 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jul 31 02:22:46 2008 Subject: [Haskell-cafe] message-passing IPC for Haskell? Message-ID: <5ae4f2ba0807302322i40854d7aw4b302157fd2538ec@mail.gmail.com> Hello, I have seen postings about work on message-passing IPCs for Haskell. I like STM but want to keep an open mind ... I can't find those postings. Can something remind of this work and where/how I can read about? Very kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080731/1e847288/attachment.htm From wren at freegeek.org Thu Jul 31 03:05:56 2008 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 31 03:05:59 2008 Subject: [Haskell-cafe] Using fundeps to resolve polymorphic types to concrete types In-Reply-To: <2f9b2d30807301144j6e7ae8e7p1f0abed7a383eb39@mail.gmail.com> References: <20080729013258.GA19607@shion.is.fushizen.net> <488EC2F0.9060100@freegeek.org> <19707.192.12.13.2.1217353037.squirrel@mail.freegeek.org> <2f9b2d30807301144j6e7ae8e7p1f0abed7a383eb39@mail.gmail.com> Message-ID: <48916454.20903@freegeek.org> Ryan Ingram wrote: > Hmm, I'm kind of confused by this now. I feel like the following code > really should compile, but it doesn't. There's no use of existentials > to hide type information at all. The functional dependency seems like > it should give us the constraint (b1 ~ b2) allowing Refl to typecheck. It may be worth noting that GADTs subsume existential types. Not that that matters here. >> {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, GADTs #-} >> module DeriveType where >> >> class DeriveType a b | a -> b >> data TypeEq a b where Refl :: TypeEq a a >> >> test :: (DeriveType a b1, DeriveType a b2) => a -> TypeEq b1 b2 >> test _ = Refl > > But... > > derivetype.hs:8:9: > Couldn't match expected type `b1' against inferred type `b2' Like I was saying, contexts are only ever verified as constraints on polymorphism, they never drive the type inference algorithm. Think of them as something that happens after the fact, "delayed constraints" if you will. The constructor Refl defines a constant of type (forall t. TypeEq t t). This constrains the return type of 'test' to have the same type, namely that the two arguments to the TypeEq type constructor are both the same. The signature you gave is more polymorphic than that, it allows for the possibility that they might be different. This is the same as the previous example using 'id' and wanting to give it the type (b -> B). If we simplify the example it might be more apparent why it fails. [0] wren@xenobia:~/test $ cat wacky2.lhs && ghci wacky2.lhs > module DeriveType where > > data TypeEq a b = TE > > refl :: TypeEq a a > refl = TE > > test :: a -> TypeEq b1 b2 > test _ = refl GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling DeriveType ( wacky2.lhs, interpreted ) wacky2.lhs:9:11: Couldn't match expected type `b1' against inferred type `b2' `b1' is a rigid type variable bound by the type signature for `test' at wacky2.lhs:8:22 `b2' is a rigid type variable bound by the type signature for `test' at wacky2.lhs:8:25 Expected type: TypeEq b1 b2 Inferred type: TypeEq b2 b2 In the expression: refl In the definition of `test': test _ = refl Failed, modules loaded: none. Prelude> In your version we'd like the fundeps to kick in and say there can be only one type paired with 'a' and so we can infer that 'b1' and 'b2' are the same, but fundeps are part of type classes and so they too are just delayed constraints.[1] At the time of determining what the principal type of the function is, we don't see the type classes or the fundeps associated with them. While inferring the principal type we build up a set of delayed constraints (i.e. requisite type class instances, based on the functions used). After we've determined the principal type, we then verify that we can fulfill all the delayed requirements if we assume the type class instances in the context actually exist. If we pass type inference and context verification, then we deem the function OK. The main use of fundeps is to assist type inference at *use* sites for the function. Say we have a function (foo :: DeriveType a b => a -> b). If somewhere we use that function in the expression (foo x), if we've already determined that x has type A, this will let us infer some type B for specializing the polymorphism of foo in this expression. Without fundeps we would have to give a type signature in order to clarify which B should be used, if it couldn't otherwise be inferred. But this is all fundeps do, they don't help in determining what the type of foo itself is when we're defining it. There are some cute tricks that can be played with fundeps in order to do type arithmetic and such, but Haskell doesn't really have dependent types and so it doesn't really use contexts to drive inference either. Sadly fundeps aren't quite as well integrated or general as they could be, but trying to resolve the MPTC/fundep/type families/... stuff into a single coherent approach is part of what the haskell' committee is trying to work out. One of the tricks in all this is to figure out how to have enough of dependent typing to do what we want, but without sacrificing decidability(/verifiability) of type inference. [1] Also, Haskell has only one way of representing that two types are identical, namely unification i.e. using the same type variable. So even if fundeps did drive type inference, that type signature would still be wrong because the principal type is (DeriveType a b => a -> TypeEq b b) since it's guaranteed that DeriveType a is defined at only one 'b'. -- Live well, ~wren From agentzh at gmail.com Thu Jul 31 03:22:07 2008 From: agentzh at gmail.com (Agent Zhang) Date: Thu Jul 31 03:22:07 2008 Subject: [Haskell-cafe] Network.FastCGI does not emit stderr outputs to lighttpd's error.log? In-Reply-To: <20080730175612.GC15694@scytale.galois.com> References: <20080730175612.GC15694@scytale.galois.com> Message-ID: On Thu, Jul 31, 2008 at 1:56 AM, Don Stewart wrote: > > We've had no problems with this and apache at least. Is lighttpd > doing something funny with error logging? It seems that Apache is doing something funny :) According to my teammate chaoslawful, apache redirects stderr to its error log files (if any) but the fastcgi spec actually says everything should go through the socket. And lighttpd seems to be following the spec exactly :) chaoslawful++ finally come up with the following patch for lighttpd 1.4.19 to make lighttpd behave in the same way as apache. Devel.Debug is now finally working for me for my Haskell fastcgi hacking :)) --- lighttpd-1.4.19/src/log.c 2007-08-22 01:40:03.000000000 +0800 +++ lighttpd-1.4.19-patched/src/log.c 2008-07-31 15:13:10.000000000 +0800 @@ -83,9 +83,14 @@ /* move stderr to /dev/null */ if (close_stderr && -1 != (fd = open("/dev/null", O_WRONLY))) { - close(STDERR_FILENO); + // XXX: modified by chaoslawful, don't close stderr when log into file + close(STDERR_FILENO); + if (srv->errorlog_mode == ERRORLOG_FILE && srv->errorlog_fd >=0 ) { + dup2(srv->errorlog_fd,STDERR_FILENO); + } else { dup2(fd, STDERR_FILENO); - close(fd); + } + close(fd); } return 0; } Best, -agentzh From dominic.steinitz at blueyonder.co.uk Thu Jul 31 03:43:44 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Thu Jul 31 03:43:55 2008 Subject: [Haskell-cafe] Re: Best book/tutorial on category theory and its applications References: <18686250.post@talk.nabble.com> Message-ID: fero gmail.com> writes: > > What do you think about "Categories and Computer Science (Cambridge Computer > Science Texts)" at > http://www.amazon.com/Categories-Computer-Science-Cambridge- Texts/dp/0521422264/ref=si3_rdr_bb_product > ? > I couldn't see monads or the Yoneda lemma in the index. As a Haskell programmer, the lack of the former might be a concern; the latter is a standard result. Dominic. From bos at serpentine.com Thu Jul 31 12:36:37 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Jul 31 12:36:36 2008 Subject: [Haskell-cafe] Re: www.haskell.org is currently very slow in responding to HTTP requests In-Reply-To: <48903A6F.8030808@semantic.org> References: <5ulv849bu9lc0uc7tdamrct5lvhnqgcuuq@4ax.com> <1217404167.12754.348.camel@localhost> <48903A6F.8030808@semantic.org> Message-ID: On Wed, Jul 30, 2008 at 2:54 AM, Ashley Yakeley wrote: > Other software versions: > > Linux 2.4.21 (latest is 2.6.26) > Apache 2.0.46 (latest is 2.2.9) > MySQL 3.23.58 (latest is 5.0.51a) > PHP 4.3.2 (latest is 5.2.6) > MediaWiki 1.5.4 (latest is 1.12) > > > It might be worth upgrading some of that, though if that includes Linux or > RHEL overall it would probably require physical access to the box. The concurrent connection problem is a baked-in limitation of Apache, and is unfortunately not something that will be fixed by a painful upgrade. From dons at galois.com Thu Jul 31 13:37:44 2008 From: dons at galois.com (Don Stewart) Date: Thu Jul 31 13:38:00 2008 Subject: [Haskell-cafe] Network.FastCGI does not emit stderr outputs to lighttpd's error.log? In-Reply-To: References: <20080730175612.GC15694@scytale.galois.com> Message-ID: <20080731173744.GF9849@scytale.galois.com> agentzh: > On Thu, Jul 31, 2008 at 1:56 AM, Don Stewart wrote: > > > > We've had no problems with this and apache at least. Is lighttpd > > doing something funny with error logging? > > It seems that Apache is doing something funny :) According to my > teammate chaoslawful, apache redirects stderr to its error log files > (if any) but the fastcgi spec actually says everything should go > through the socket. And lighttpd seems to be following the spec > exactly :) > > chaoslawful++ finally come up with the following patch for lighttpd > 1.4.19 to make lighttpd behave in the same way as apache. Devel.Debug > is now finally working for me for my Haskell fastcgi hacking :)) > > --- lighttpd-1.4.19/src/log.c 2007-08-22 01:40:03.000000000 +0800 > +++ lighttpd-1.4.19-patched/src/log.c 2008-07-31 15:13:10.000000000 +0800 > @@ -83,9 +83,14 @@ > /* move stderr to /dev/null */ > if (close_stderr && > -1 != (fd = open("/dev/null", O_WRONLY))) { > - close(STDERR_FILENO); > + // XXX: modified by chaoslawful, don't close stderr > when log into file > + close(STDERR_FILENO); > + if (srv->errorlog_mode == ERRORLOG_FILE && > srv->errorlog_fd >=0 ) { > + dup2(srv->errorlog_fd,STDERR_FILENO); > + } else { > dup2(fd, STDERR_FILENO); > - close(fd); > + } > + close(fd); > } > return 0; > } > > Best, > -agentzh Interesting result, thanks for looking into this. From byorgey at seas.upenn.edu Thu Jul 31 16:47:57 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu Jul 31 17:00:07 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 79 - July 31, 2008 Message-ID: <20080731204757.GA11023@minus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080731 Issue 79 - July 31, 2008 --------------------------------------------------------------------------- Welcome to issue 79 of HWN, a newsletter covering developments in the [1]Haskell community. Apologies for the slightly late issue this week, attributable to a combination of having to transfer all my files onto a different computer (my former employer had the audacity to request the return of their laptop, now that I no longer work for them) and packing up to move to Philadelphia on Saturday. At any rate, some exciting news this week, including #haskell passing the 500 mark and a new release of Yi -- enjoy! Community News Correction from last week's issue: congratulations were bestowed upon a certain "Dr. Johansson" who does not, in fact, exist, having been replaced almost a year ago by the happily married but otherwise identical Dr. Mikael Vejdemo-Johansson. Announcements A fancier Get monad or two (a la binary and binary-strict). Chris Kuklewicz [2]announced two new Get-like monads for binary data, with a number of additional features. #haskell irc channel reaches 500 users. Don Stewart [3]announced that 6 1/2 years after its inception, under the guiding hand of Shae Erisson (aka shapr), the [4]#haskell IRC channel on freenode has finally reached 500 users! This puts the channel at around the 12th largest (and mostest friendliest) community of the 7000 freenode channels. RandomDotOrg-0.1. Austin Seipp [5]announced the release of the [6]RandomDotOrg package, an interface to the [7]random.org random number generator. Mueval 0.3.1, 0.4, 0.4.5, 0.4.6, 0.5. Gwern Branwen [8]announced a number of releases of [9]Mueval, a package allowing dynamic runtime evaluation of Haskell expressions. As far as anyone knows, all possible security holes have been plugged, and it's missing only a few features before it can replace hs-plugins as lambdabot's evaluation mechanism. Need functional programmers for debugging study. Chris Bogart [10]asked for functional programmers currently developing or maintaining a medium to large-sized program, willing to let him look over their shoulder while they do debugging or coding on the project. Yi 0.4.1. Jean-Philippe Bernardy [11]announced the 0.4.1 release of the Yi editor, a text editor written and extensible in Haskell. The long-term goal of the Yi project is to provide the editor of choice for Haskell programmers. Hipmunk 0.1 and HipmunkPlayground 0.1. Felipe Lessa [12]announced the availability of [13]Hipmunk, containing bindings for the [14]Chipmunk 2D physics engine, and [15]Hipmunk Playground, where you may see some of Hipmunk's features in action. The bindings are low-level but try to hide most of the nasty details of the C code. faster BLAS bindings. Patrick Perry [16]announced that he has [17]largely closed the C performance gap with his recent [18]Haskell BLAS bindings. Expect a new release shortly. FPers in Northwest Arkansas?. Nathan Bloomfield [19]is wondering if there are any Haskellers in the NW Arkansas region to start a functional programming interest group in the area. Italian Haskellers Summer Meeting. Pasqualino 'Titto' Assini [20]announced something about a summer meeting for Italian Haskellers. If you would like to know precisely what it was that was announced, I suggest you learn Italian. InterleavableIO. Marco Tulio Gontijo e Silva [21]announced a package, [22]interleavableIO, based on Jules Bean (quicksilver)'s [23]monadic tunneling code. Google Summer of Code Progress updates from participants in the 2008 [24]Google Summer of Code. Hoogle 4. Neil Mitchell (ndm) is working on [25]Hoogle 4. [26]This week, he rewrote type search: after three days of coding, it required only a few minor debugging tweaks to get it to work. Haskell FTW! Expect a public beta of the command line interface next week. Generic tries. Jamie Brandon is working on a library for efficient maps using generalized tries. [27]This week, he has finally got everything up and running bug free on the new API, except the internals are still using association lists instead of AVL trees. He also exhibits a promising benchmark. DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a [28]physics engine using [29]Data Parallel Haskell. GHC plugins. Max Bolingbroke is working on dynamically loaded plugins for GHC. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a [30]make-like dependency analysis framework for Cabal. Language.C. Benedikt Huber (visq) is [31]working on Language.C, a standalone parser/pretty printer library for C99. GHC API. Thomas Schilling (nominolo) is working on [32]improvements to the GHC API. Discussion Build system woes. Roman Leshchinskiy began a [33]discussion on Cabal and GHC's new build system, with some suggestions for improving the process. Syb Renovations? Issues with Data.Generics. Claus Reinke [34]brought up a number of issues with Data.Generics, with suggestions for improvement. A question about mfix. Wei Hu [35]asked a question about the definition and semantics of mfix, the monadic fix operation. Using fundeps to resolve polymorphic types to concrete types. Bryan Donlan [36]asked a question about the interaction between functional dependencies and type checking, with a rather subtle answer. Best book/tutorial on category theory and its applications. fero [37]asked for recommendations on a book about category theory. Loss of humour. Andrew Coppin [38]laments the loss of some of Haskell's humorous heritage. Blog noise [39]Haskell news from the [40]blogosphere. * Ketil Malde: [41]Updates and other trivialities. * Ulisses Costa: [42]Lex/yacc. A short lex/yacc tutorial. * Luke Plant: [43]Haskell Regex replace. Luke wonders if anyone knows how to do regex replace in Haskell. * Eric Kow (kowey): [44]simple random numbers in Haskell. Eric writes a simple tutorial for the System.Random module. * Jamie Brandon: [45]Week 7 progress (respect my formatting damnit). An update on Jamie's Google Summer of Code project. * Tupil: [46]Formlets in Haskell. * John Goerzen (CosmicRay): [47]Seen in the Haskell wiki. * Ulisses Costa: [48]Type inference. * Dennis Bueno: [49]ICFP Contest 2008 -- The One Liners. Dennis describes his experiences participating in this year's ICFP Programming Contest. * Magnus Therning: [50]More prefixes. * Don Stewart (dons): [51]Haskell: Batteries Included. * >>> Harry Pierson: [52]Monadic Philosophy Part 2 - The LINQ Monad. * >>> Harry Pierson: [53]Monadic Philosophy. Harry begins a series explaining his journey through understanding monads. * Ulisses Costa: [54]Pointfree Calculator. * Eric Kow (kowey): [55]pandoc gets mediawiki support. * Dan Piponi (sigfpe): [56]The Fibonacci Numbers, Coalgebraicaly. * Twan van Laarhoven: [57]Solving nonograms. * >>> Ayumilove: [58]Haskell Programming Tutorial Part 2A. * >>> Ayumilove: [59]Haskell Programming Tutorial Part 2B. * >>> Ayumilove: [60]Haskell Programming Tutorial Part 3. * >>> Darren Moffat: [61]T5120 donated to Haskell Community. Sun's donation inspires Darren to get back into Haskell and maybe contribute some code to GHC again, like he did back when he was a student at Glasgow. * Mikael Vejdemo-Johansson (DrSyzygy): [62]Blackbox computing of A-infinity algebras. The last results from Mikael's thesis have made it into article form, and are [63]available on the arXiv. * John Goerzen (CosmicRay): [64]OSCon Update. * Real-World Haskell: [65]Beta availability hiccups. * John Goerzen (CosmicRay): [66]First 2 Days of OSCon. John reports live from OSCon. * Neil Mitchell: [67]GSoC Hoogle: Week 9. An update on Neil's Google Summer of Code project. * Patrick Perry: [68]Addressing Haskell BLAS Performance Issues. Patrick's Haskell BLAS bindings are now significantly sped up, and he explains what made the difference. * Arnar Birgisson (Arnar): [69]Parsing annotated postfix operators with Haskell. Arnar exhibits a neat pattern for constructing certain types of parsers, which makes essential use of first-class functions. Quotes of the Week * mauke: a hint to beginners: typing 'fix error' in ghci does not have the intended effect. * mauke: Hungarian Notation constructs a type system in the mind of the programmer. * rwbarton: I was hoping for a pile of Functors. * Baughn: [on lambdabot] Yes, PMS is a real issue. Poor memory size, that is. * Cale: There should be a website called "Static Equilibrium or Not" where you rate pictures according to whether you think the depicted objects are in static equilibrium. * sahko: xmonad is an ancient african word for "you dont need to use a mouse fool". * doidydoidy: Category theory is exactly like a comic book alternative universe, except they use the prefix "co-" instead of "bizarro". About the Haskell Weekly News New editions are posted to [70]the Haskell mailing list as well as to [71]the Haskell Sequence and [72]Planet Haskell. [73]RSS is also available, and headlines appear on [74]haskell.org. Headlines are available as [75]PDF. To help create new editions of this newsletter, please see the information on [76]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [77]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9691 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42671 4. http://haskell.org/haskellwiki/IRC_channel 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42643 6. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/RandomDotOrg 7. http://random.org/ 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42629 9. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mueval 10. http://article.gmane.org/gmane.comp.lang.haskell.general/16360 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42582 12. http://article.gmane.org/gmane.comp.lang.haskell.general/16355 13. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Hipmunk 14. http://wiki.slembcke.net/main/published/Chipmunk 15. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HipmunkPlayground 16. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42534 17. http://quantile95.com/2008/07/24/addressing-haskell-blas-performance-issues/ 18. http://www-stat.stanford.edu/~patperry/code/blas/ 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42548 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42545 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/42502 22. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/interleavableIO 23. http://www.haskell.org/pipermail/haskell-cafe/2007-July/028501.html 24. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 25. http://code.haskell.org/hoogle/ 26. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-9.html 27. http://jamiiecb.blogspot.com/2008/07/week-7-progress-respect-my-formatting.html 28. http://haskell.org/haskellwiki/Hpysics 29. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 30. http://code.haskell.org/~Saizan/cabal 31. http://www.sivity.net/projects/language.c/wiki/ 32. http://hackage.haskell.org/trac/ghc/wiki/GhcApiStatus 33. http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/14800 34. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9672 35. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42677 36. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42639 37. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42616 38. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/42510 39. http://planet.haskell.org/ 40. http://haskell.org/haskellwiki/Blog_articles 41. http://blog.malde.org/index.php/2008/07/31/updates-and-other-trivialities/ 42. http://caos.di.uminho.pt/~ulisses/blog/2008/07/31/lexyacc/ 43. http://lukeplant.me.uk/blog.php?id=1107301690 44. http://koweycode.blogspot.com/2008/07/simple-random-numbers-in-haskell.html 45. http://jamiiecb.blogspot.com/2008/07/week-7-progress-respect-my-formatting.html 46. http://blog.tupil.com/formlets-in-haskell/ 47. http://changelog.complete.org/posts/736-Seen-in-the-Haskell-wiki.html 48. http://caos.di.uminho.pt/~ulisses/blog/2008/07/30/type-inference/ 49. http://obfuscatedcode.wordpress.com/2008/07/30/icfp-contest-2008-the-one-liners/ 50. http://therning.org/magnus/archives/355 51. http://www.cse.unsw.edu.au/~dons/blog/2008/07/29#batteries 52. http://devhawk.net/2008/07/30/Monadic+Philosophy+Part+2+The+LINQ+Monad.aspx 53. http://devhawk.net/2008/07/30/Monadic+Philosophy.aspx 54. http://caos.di.uminho.pt/~ulisses/blog/2008/07/29/pointfree-calculator/ 55. http://koweycode.blogspot.com/2008/07/pandoc-gets-mediawiki-support.html 56. http://sigfpe.blogspot.com/2008/07/fibonacci-numbers-coalgebraicaly.html 57. http://twan.home.fmf.nl/blog/haskell/Nonograms.details 58. http://www.5min.com/Video/-Ayumilove-Haskell-Programming-Tutorial-Part-2-A-31821112 59. http://www.5min.com/Video/Ayumilove-Haskell-Programming-Tutorial-Part-2-B-31824556 60. http://www.5min.com/Video/Ayumilove-Haskell-Programming-Tutorial-Part-3-31855373 61. http://blogs.sun.com/darren/entry/t5120_donated_to_haskell_community 62. http://blog.mikael.johanssons.org/archive/2008/07/blackbox-computing-of-a-infinity-algebras/ 63. http://arxiv.org/abs/0807.3869 64. http://changelog.complete.org/posts/733-OSCon-Update.html 65. http://www.realworldhaskell.org/blog/2008/07/16/beta-availability-hiccups/ 66. http://changelog.complete.org/posts/732-First-2-Days-of-OSCon.html 67. http://neilmitchell.blogspot.com/2008/07/gsoc-hoogle-week-9.html 68. http://quantile95.com/2008/07/24/addressing-haskell-blas-performance-issues/ 69. http://www.hvergi.net/2008/07/parsing-annotated-postfix-operators-with-haskell/ 70. http://www.haskell.org/mailman/listinfo/haskell 71. http://sequence.complete.org/ 72. http://planet.haskell.org/ 73. http://sequence.complete.org/node/feed 74. http://haskell.org/ 75. http://code.haskell.org/~byorgey/code/hwn/archives/20080731.pdf 76. http://haskell.org/haskellwiki/HWN 77. http://code.haskell.org/~byorgey/code/hwn/ From thomas.dubuisson at gmail.com Thu Jul 31 17:13:00 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Thu Jul 31 17:13:00 2008 Subject: [Haskell-cafe] message-passing IPC for Haskell? In-Reply-To: <5ae4f2ba0807302322i40854d7aw4b302157fd2538ec@mail.gmail.com> References: <5ae4f2ba0807302322i40854d7aw4b302157fd2538ec@mail.gmail.com> Message-ID: <1217538780.6467.5.camel@tom-laptop> > I have seen postings about work on message-passing IPCs for > Haskell. I like STM but want to keep an open mind ... I can't find > those postings. Can something remind of this work and where/how I can > read about? I made a quick hack composing BSD sockets from Network.Socket for higher level IPC. It was for a one use deal, but you're free to use and improve on the library - called 'ipc' on hackage. Tom Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ipc Basic homepage: http://www.haskell.org/haskellwiki/IPC From lemming at henning-thielemann.de Thu Jul 31 19:29:49 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 31 19:29:47 2008 Subject: [Haskell-cafe] array fusion interface In-Reply-To: <2518b95d0807220617s115405acuddd67e63a2118046@mail.gmail.com> References: <2518b95d0807220617s115405acuddd67e63a2118046@mail.gmail.com> Message-ID: On Tue, 22 Jul 2008, Evan Laforge wrote: > With all the noise lately about high performance array libraries with > list-like interfaces, such as bytestring, storablevector, uvector, and > vector, I thought I would try to make use of one in a project of mine, > and I'm either bumping up against the limits of its expressiveness, or > am missing out on how to express my problem. > > I have streams of samples with irregular sampling rates, so they look > like [(Time, SampleVal)]. In practice, this means [(Double, Double)]. Maybe I have already mentioned my eventlist package on Hackage which supports such resampling operations - but is based on lists. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/event-list From lemming at henning-thielemann.de Thu Jul 31 19:37:12 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 31 19:37:08 2008 Subject: [Haskell-cafe] Point-free style in guards In-Reply-To: References: Message-ID: On Tue, 22 Jul 2008, L29Ah wrote: > outStanza | (isMessage) = outMessage > | (isPresence) = outPresence > | (isIQ) = outIQ > > Why such a style doesn't work, so I must write ugly code like that: > > outStanza a | (isMessage a) = outMessage a > | (isPresence a) = outPresence a > | (isIQ a) = outIQ a > > so, guards can't be useful in point-free function definitions in any way It's sad that syntactic sugar makes people want even more syntactic sugar (some people thus call it syntactic heroin). You can easily achieve the wanted effect by a function like 'select' http://www.haskell.org/haskellwiki/Case and that way you can also avoid guards in many cases. From lemming at henning-thielemann.de Thu Jul 31 19:51:47 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 31 19:51:44 2008 Subject: [Haskell-cafe] Exceptions In-Reply-To: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> References: <674EFCEB-35A8-4DFF-88DC-A9E42FA6FADC@inf.fu-berlin.de> Message-ID: On Sun, 27 Jul 2008, Adrian Neumann wrote: > Hello, > > I think it'd be nice if the compiler could warn me if there are any > exceptions which I'm not catching, similar to checked exceptions in > Java. Does anyone know of a possibility to do that in Haskell? Please refer to the long "extensible extension" thread: http://www.haskell.org/pipermail/libraries/2008-July/010095.html In my posts I sketched possibilities to do that.