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