From coreyoconnor at gmail.com Thu Oct 1 01:06:35 2009 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Thu Oct 1 00:44:29 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.1 In-Reply-To: <20090930043530.GA31155@janrain.com> References: <20090930043530.GA31155@janrain.com> Message-ID: On Tue, Sep 29, 2009 at 9:35 PM, Jonathan Daugherty wrote: > vty-ui is: > > An extensible library of user interface widgets for composing and > laying out Vty user interfaces. This library provides a collection of > widgets and a type class for rendering widgets to Vty Images. Cool! I'll be sure to test these out when working on Vty :-D Thanks! Corey O'Connor From cjs at starling-software.com Thu Oct 1 02:13:14 2009 From: cjs at starling-software.com (Curt Sampson) Date: Thu Oct 1 01:51:08 2009 Subject: Fwd: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> Message-ID: <20091001061314.GF1315@analytic.cynic.net> On 2009-09-30 21:27 +0200 (Wed), Alberto G. Corona wrote: > > Do you really want, in 2020, to look back at the 2010 revision of the > > Haskell standard and think, "we entrenched things that for a decade > > everybody agreed was dumb"? > > I see no problem in haskell having both. experimental and fixed versions. > Haskell 2020 for you and me and haskell 2010 for my commercial code. Both > woukd ve maintained and enriched by far more people. If so, why hasn't this happened with Haskell98? > Become more stupid may mean "give exactly what the people want" that > transaltes to be more stable, give libraries, platforms etc. Not entering the mainstream seems a small price to pay to avoid this fate. Haskell has pretty nice niche right now that it's filling very well; emptying this nich to move into competition for other niches that already have languages filling them seems to me bad for everybody all around. I suspect that main hope a lot of Haskell promoters have (certainly this is mine) is not that more people do what they do now but in Haskell, but people do things in the better ways that Haskell allows. In other words, we don't want to move into the mainstream, we want the mainstream to come over here. And as far as something like dealing with a changing language and libraries, the mainstream already has well-established and popular techniques for doing just: agile development. If anything, the FP community could be learning from them on this score. So in some of your marketing ideas, you're actually marketing to a problem that has better solutions already in the mainstream. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From ketil at malde.org Thu Oct 1 03:36:03 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 1 03:13:54 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <67d0527e0909300945y7dcba09av560f338f767526aa@mail.gmail.com> (namekuseijin@gmail.com's message of "Wed, 30 Sep 2009 13:45:47 -0300") References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <67d0527e0909300945y7dcba09av560f338f767526aa@mail.gmail.com> Message-ID: <87eipnh8gs.fsf@malde.org> namekuseijin writes: > Point is: >>= . $ : ! `` and meaningful whitespace are all nice > shortcuts, but also hairy confusing... As somebody pointed out, these are rather idiomatic, and only confusing to beginners. (I'm not sure what you refer to with whitespace, some think layout makes code difficult to write, but I don't think it hurts legibility? If you refer to extension that makes 'x?y' and 'x ? y' mean different things, then I agree: that way lies madness.) I agree it's usually better to use real names, but one problem with many operators (and Haskell functions in general) is their extreme generality. For instance, the >>= cominator is usually pronounced 'bind'. Does this really help? exp1 >>= exp2 vs exp1 `bind` exp2 or even bind exp1 exp2 In some cases where names are used, it just increases confusion, e.g. the Monoid function 'mappend' is nice for concatenating two lists, but a rather odd name for mulitplying two integers. -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Thu Oct 1 03:51:15 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 1 03:29:24 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC36E80.4080802@btinternet.com> (Andrew Coppin's message of "Wed, 30 Sep 2009 15:43:12 +0100") References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> Message-ID: <877hvfh7rg.fsf@malde.org> Andrew Coppin writes: > Peter Verswyvelen wrote: >> I really doubt people tend to think in either way. It's not even >> sure our thinking can be modeled with computing no? > Well, try this: Go ask a random person how you add up a list of > numbers. Although the question of how we "naturally" think often comes up, I'm not sure it's a very important one. In my experience, the natural thing for humans appear rather to be the absence of thinking, and instead slouching in front of the TV eating unhealthy food. After all, we give people who program computers several years of education to learn about unnatural things like counters and temporary variables, or recursion and folds. The question shouldn't be what comes more natural for average Joe, but rather what skills can we teach a reasonably bright student in three to five years that will make her the most effective programmer. (That's what the question should be, of course what the question really *is* is what curriculum can we present that looks entertaining, fashionable, and trivial enough that enough high-school kids will apply for the department not to be starved of funds... ) -k -- If I haven't seen further, it is by standing in the footprints of giants From andrewcoppin at btinternet.com Thu Oct 1 03:53:53 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 1 03:31:46 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <20091001031019.GA8837@colquitt.org> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> Message-ID: <4AC46011.4090203@btinternet.com> John Dorsey wrote: >> Well, try this: Go ask a random person how you add up a list of numbers. >> Most of them will say something about adding the first two together, >> adding the third to that total, and so forth. In other words, the step >> by step instructions. >> > > You word the (hypothetical) question with a bias toward imperative > thinking. You're asking "How do you do this action?" > > Why isn't the question "What is the sum of a list of numbers?", which is > biased toward the declarative? > Sure. But what is a computer program? It's a *list of instructions* that tells a computer *how to do something*. And yet, the Haskell definition of sum looks more like a definition of what a sum is rather than an actual, usable procedure for *computing* that sum. (Of course, we know that it /is/ in fact executable... it just doesn't look it at first sight.) Whatever; I'm leaning more and more towards the concept that FP is only hard for people who already learned some other way... From andrewcoppin at btinternet.com Thu Oct 1 03:59:17 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 1 03:37:10 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <877hvfh7rg.fsf@malde.org> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <877hvfh7rg.fsf@malde.org> Message-ID: <4AC46155.7000308@btinternet.com> Ketil Malde wrote: > Although the question of how we "naturally" think often comes up, I'm > not sure it's a very important one. In my experience, the natural > thing for humans appear rather to be the absence of thinking, and > instead slouching in front of the TV eating unhealthy food. > > After all, we give people who program computers several years of > education to learn about unnatural things like counters and temporary > variables, or recursion and folds. The question shouldn't be what comes > more natural for average Joe, but rather what skills can we teach a > reasonably bright student in three to five years that will make her the > most effective programmer. > I'll go along with that. Although, to all the people who ask "why is Ruby so popular?", I might suggest "because it's easy to learn"... From ekirpichov at gmail.com Thu Oct 1 03:59:41 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Oct 1 03:37:34 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC46011.4090203@btinternet.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> Message-ID: <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> 2009/10/1 Andrew Coppin : > John Dorsey wrote: >>> >>> Well, try this: Go ask a random person how you add up a list of numbers. >>> ?Most of them will say something about adding the first two together, >>> ?adding the third to that total, and so forth. In other words, the step ?by >>> step instructions. >>> >> >> You word the (hypothetical) question with a bias toward imperative >> thinking. ?You're asking "How do you do this action?" >> >> Why isn't the question "What is the sum of a list of numbers?", which is >> biased toward the declarative? >> > > Sure. But what is a computer program? It's a *list of instructions* that > tells a computer *how to do something*. And yet, the Haskell definition of > sum looks more like a definition of what a sum is rather than an actual, > usable procedure for *computing* that sum. (Of course, we know that it /is/ > in fact executable... it just doesn't look it at first sight.) Well, we are not writing computer programs directly, even in C, that's what compilers are for. That's why I find arguments about the sequential essence of computer programs to be weak. > > Whatever; I'm leaning more and more towards the concept that FP is only hard > for people who already learned some other way... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From ketil at malde.org Thu Oct 1 03:57:29 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 1 03:38:15 2009 Subject: [Haskell-cafe] error on "--++ bla bla bla" In-Reply-To: (Hong Yang's message of "Wed, 30 Sep 2009 21:41:39 -0500") References: Message-ID: <873a63h7h2.fsf@malde.org> Hong Yang writes: > But in my program, I did not define "--++". And that's what the error tells you, no? Defining operators (or not) doesn't change the syntax. Since the lexeme --++ is syntactially a valid operator, it will be parsed as such, regardless of whether it is defined or not. -k -- If I haven't seen further, it is by standing in the footprints of giants From apfelmus at quantentunnel.de Thu Oct 1 04:17:50 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Oct 1 03:56:05 2009 Subject: [Haskell-cafe] Re: Splitting data and function declarations over multiple files In-Reply-To: References: Message-ID: Peter Verswyvelen wrote: > I guess this is related to the expression problem. > Suppose I have a datatype > > *data Actor = Ball ... | Paddle ... | Wall ...* > > and a function > > *move (Ball ...) = * > *move (Paddle ...) = * > *move (Wall ...) = * > > in Haskell one must put *Actor* and *move* into a single file. Just a nitpick: you don't have to put Actor and move into the same module. module A where data Actor = Ball | Paddle | Wall module B where import A (Actor) move Ball = ... move Paddle = ... move Wall = ... But that's probably not what you meant. Regards, apfelmus -- http://apfelmus.nfshost.com From andrewcoppin at btinternet.com Thu Oct 1 04:26:44 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 1 04:04:40 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> Message-ID: <4AC467C4.4070303@btinternet.com> Eugene Kirpichov wrote: > 2009/10/1 Andrew Coppin : > >> Sure. But what is a computer program? It's a *list of instructions* that >> tells a computer *how to do something*. And yet, the Haskell definition of >> sum looks more like a definition of what a sum is rather than an actual, >> usable procedure for *computing* that sum. (Of course, we know that it /is/ >> in fact executable... it just doesn't look it at first sight.) >> > > Well, we are not writing computer programs directly, even in C, that's > what compilers are for. > That's why I find arguments about the sequential essence of computer > programs to be weak. > It might be a better argument to say that human thinking is fundamentally sequential; parallel computers have been around for a little while now... From ekirpichov at gmail.com Thu Oct 1 04:32:09 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Oct 1 04:10:05 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC467C4.4070303@btinternet.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> Message-ID: <5e0214850910010132u29c6b07exeab3b8e9ac922086@mail.gmail.com> 2009/10/1 Andrew Coppin : > Eugene Kirpichov wrote: >> >> 2009/10/1 Andrew Coppin : >> >>> >>> Sure. But what is a computer program? It's a *list of instructions* that >>> tells a computer *how to do something*. And yet, the Haskell definition >>> of >>> sum looks more like a definition of what a sum is rather than an actual, >>> usable procedure for *computing* that sum. (Of course, we know that it >>> /is/ >>> in fact executable... it just doesn't look it at first sight.) >>> >> >> Well, we are not writing computer programs directly, even in C, that's >> what compilers are for. >> That's why I find arguments about the sequential essence of computer >> programs to be weak. >> > > It might be a better argument to say that human thinking is fundamentally > sequential; parallel computers have been around for a little while now... > I don't buy this argument, either; human thinking is far too broad a concept to say that it is simply "sequential". If it were sequential, it could barely express non-sequential concepts, and natural languages would have rather few of them, which we all know is false. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From bugfact at gmail.com Thu Oct 1 04:45:55 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Oct 1 04:23:50 2009 Subject: [Haskell-cafe] Splitting data and function declarations over multiple files In-Reply-To: <7ca3f0160909301215s9a09a00pbe14c2f048d8cb3@mail.gmail.com> References: <7ca3f0160909301215s9a09a00pbe14c2f048d8cb3@mail.gmail.com> Message-ID: I'm not sure if I understand what you mean with this co-algebraic approach, but I guess you mean that functions - like move - don't work directly on any datatype; you need to provide other functions that give access to the data. But that's basically what type classes do no? And that's also related to my earlier post of "strong duck typing" in Haskell. At least also in C#, that's the way I usually write code that works on any type, just make an interface or pass in a delegate. I also know that my OO background keeps pushing me in the wrong direction when it comes to Haskell ;-) The collision handling approach is always interesting :) In OO this is usually solved using multi-methods or visitors: http://en.wikipedia.org/wiki/Multiple_dispatch. What I usually did in old games of mine to handle collisions is not look at the type, but at the "collision specific features" of a type (which are again functions that extract information from the object), and that is most likely again the co-algebraic approach? On Wed, Sep 30, 2009 at 9:15 PM, Luke Palmer wrote: > On Wed, Sep 30, 2009 at 9:54 AM, Peter Verswyvelen > wrote: > > I guess this is related to the expression problem. > > Suppose I have a datatype > > data Actor = Ball ... | Paddle ... | Wall ... > > and a function > > move (Ball ...) = > > move (Paddle ...) = > > move (Wall ...) = > > in Haskell one must put Actor and move into a single file. > > This is rather cumbersome if you work with multiple people or want to > keep > > the files small and readable. > > Surely it is possible to use type classes, existentials, etc to split the > > data type into multiple ones, but that's already advanced stuff in a > sense. > > You can do it without type classes and existentials. The > functionality you want is already supported by Haskell, you just have > to let go of your syntactical expectations. The trick is that you > should rewrite your data type not as an algebra (a set of > constructors), but as a coalgebra (a set of projections). > > Let's say your two open functions are: > > move :: Actor -> Actor > isAlive :: Actor -> Bool > > This gives rise to the definition of an Actor type: > > data Actor = Actor { move :: Actor, isAlive :: Bool } > > And then the alternatives of your open data type are just values of type > Actor: > > ball :: Vector -> Vector -> Actor > ball pos vel = Actor { > move = ball (pos + vel) vel, > isAlive = True > } > > etc. > > This trick works well until you get to the encoding of functions that > pattern match on multiple Actors at the same time. As far as I can > tell, that cannot be encoded in this style in any reasonable way. > Such functions must be rephrased in a coalgebraic style; i.e. instead > of asking about constructors, using projection functions it knows are > available. > > So for example instead of implementing "collide" by asking about > pairs, add functions which report a shape function and a normal, or > whatever your collide algorithm needs from shapes. > > You would probably end up having to do this anyway even with your > proposed extension, because watch: > > partial data Actor = Ball ... > > collide (Ball ...) (Ball ...) = ... > collide (Ball ...) x = ... > > We don't know about any other constructors, so the second line has to > contain a pattern-free x. So you would have to use projection > functions to get any information about it, exactly as you would when > you're writing in the coalgebraic style. > > So, Yes! Haskell can do that! > > Luke > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/04a3d134/attachment.html From maydwell at gmail.com Thu Oct 1 04:51:28 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Thu Oct 1 04:29:22 2009 Subject: [Haskell-cafe] Exceptions during exception unwinding In-Reply-To: References: Message-ID: Exception handling code should generally be assumed to work, so if something goes wrong there you would normally like to know about it. Also, there is nothing preventing you from wrapping the rescue code in further exception handling, however, if the initial error were raised upon encountering a second error, you would not be able to choose to handle the second error. This is how I see it anyway. On Thu, Oct 1, 2009 at 11:29 AM, Brian Bloniarz wrote: > > I had a question about onException & friends: what's the rationale > for having: > (error "foo") `onException` (error "bar") > > give bar and not foo? I.e. why does an exception raised during > exception handling get propagated past the exception that triggered > the handler? > > Most examples I can think for exception unwinding code would prefer the > original exception be propagated -- for example, HDBC has a function which > rolls back a DB transaction on exception; it implements it like so: >> withTransaction conn func = >>?? do r <- onException (func conn) doRollback >>????? commit conn >>????? return r >>?? where doRollback = >>???????????? -- Discard any exception from (rollback conn) so original >>???????????? -- exception can be re-raised >>???????????? Control.Exception.catch (rollback conn) doRollbackHandler >>???????? doRollbackHandler :: SomeException -> IO () >>???????? doRollbackHandler _ = return () > IMHO, it'd be easier to just write: >> withTransaction conn func = >>?? do r <- onException (func conn) (rollback conn) >>????? commit conn >>????? return r > > This same argument applies to bracket, bracket_, bracketOnError & finally; > even the common: >> bracket openSomeHandle closeSomeHandle doAction > If some error arises during doAction, there's a chance closeSomeHandle might fail > (even a good chance, given that exception unwinding paths are usually poorly > tested), and probably doAction has more accurate information about what went > wrong than closeSomeHandle. > > This is just a thought; I hadn't seen this discussed somewhere. I know for > example that Java has the same approach as the current Control.Exception, so > there must be good arguments for that too. One that I can think of: using > onException to rethrow an exception as a different type, though that's what > mapException is for, correct? > > Thanks, > -Brian > _________________________________________________________________ > Microsoft brings you a new way to search the web. ?Try ?Bing? now > http://www.bing.com?form=MFEHPG&publ=WLHMTAG&crea=TEXT_MFEHPG_Core_tagline_try bing_1x1_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at googlemail.com Thu Oct 1 05:26:41 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Oct 1 05:04:39 2009 Subject: [Haskell-cafe] Exceptions during exception unwinding In-Reply-To: References: Message-ID: <1254389201.7656.3.camel@localhost> On Thu, 2009-10-01 at 03:29 +0000, Brian Bloniarz wrote: > I had a question about onException & friends: what's the rationale > for having: > (error "foo") `onException` (error "bar") > > give bar and not foo? > I.e. why does an exception raised during exception handling get > propagated past the exception that triggered the handler? Because it's the obvious and sensible thing to do and it what every other mainstream language with exceptions does. The behaviour you want, to automatically discard any exceptions raised in the handler and to always re-raise the original exception can be implemented using the current semantics, but the reverse is not true. > Most examples I can think for exception unwinding code would prefer the > original exception be propagated Then do not rethrow a different exception. > This same argument applies to bracket, bracket_, bracketOnError & finally; > even the common: > > bracket openSomeHandle closeSomeHandle doAction > If some error arises during doAction, there's a chance closeSomeHandle might fail > (even a good chance, given that exception unwinding paths are usually poorly > tested), and probably doAction has more accurate information about what went > wrong than closeSomeHandle. Then catch and ignore the exception from closeSomeHandle (though not all exceptions or you'd block ^C etc). That said, how will you know that closeSomeHandle ever works if you always ignore any exceptions it raises? For example in the case of your database transaction, having the transaction fail and roll back is something your application may be set up to handle. But transation failing during the rollback may be much more catastrophic and may want to be treated differently. If it fails in the rollback it might be leaking resources and at the very least you may want to log it differently from just a transaction that was successfully rolled back. > This is just a thought; I hadn't seen this discussed somewhere. I know for > example that Java has the same approach as the current Control.Exception, so > there must be good arguments for that too. One that I can think of: using > onException to rethrow an exception as a different type, though that's what > mapException is for, correct? mapException is for the case of exceptions raised by pure code. As you say, being able to rethrow a different kind of exception, or simply handle the exception there and then are useful. I think using onException is the best one for your use case. If you really really want to ignore an exception raised by rollback then you have the tools available to do so. As I mentioned earlier do not just catch and discard all exceptions, see: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#4 Duncan From ekirpichov at gmail.com Thu Oct 1 07:31:57 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Oct 1 07:09:53 2009 Subject: [Haskell-cafe] Journals on Haskell and FP? Message-ID: <5e0214850910010431r18077bb2o856ea4c8aa13321e@mail.gmail.com> Hi. I was going to add a reference to the recently born Russian journal "Practice of functional programming" (http://fprog.ru/ ; had its 1st issue in July and 2nd was Sep.28) to haskellwiki into a section devoted specifically to journals, but it turned out there is no such section and, consequently, no information on journals: just books, tutorials and research papers. I think this is very valuable information and it's a shame that it's not listed on haskellwiki. So, I added such a subsection to http://haskell.org/haskellwiki/Books_and_tutorials#Journals and added a reference to Monad.Reader (the only other openly available journal on FP that I am aware of) , and I encourage the community to mention some more journals there. I also encourage the Russian readers who have not yet seen the aforementioned journal to give it a look :) -- Eugene Kirpichov Web IR developer, market.yandex.ru From dav.vire+haskell at gmail.com Thu Oct 1 07:36:18 2009 From: dav.vire+haskell at gmail.com (david48) Date: Thu Oct 1 07:14:11 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <4AC261B8.4020902@btinternet.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <4AC261B8.4020902@btinternet.com> Message-ID: <4c88418c0910010436l491fa69axa30ab3a48d3727d@mail.gmail.com> On Tue, Sep 29, 2009 at 9:36 PM, Andrew Coppin wrote: > Similarly, Parsec has some lovely external documentation (unfortunately as a single giant HTML page), but the Haddock stuff is bare. The last version (3.x) improves things. From cjs at starling-software.com Thu Oct 1 07:37:28 2009 From: cjs at starling-software.com (Curt Sampson) Date: Thu Oct 1 07:15:21 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC46155.7000308@btinternet.com> <4AC46011.4090203@btinternet.com> References: <877hvfh7rg.fsf@malde.org> <4AC46155.7000308@btinternet.com> <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> Message-ID: <20091001113726.GD18507@analytic.cynic.net> On 2009-10-01 08:53 +0100 (Thu), Andrew Coppin wrote: > Sure. But what is a computer program? It's a *list of instructions* that > tells a computer *how to do something*. Some are. Some aren't, as proven by the Haskell definition of sum, which is certainly a "program." I like to think of a program as a specification. A list of instructions can certainly qualify, but so can other things, depending on what's interpreting and executing that specification. On 2009-10-01 08:59 +0100 (Thu), Andrew Coppin wrote: > Although, to all the people who ask "why is Ruby so popular?", I might > suggest "because it's easy to learn"... Actually, Ruby isn't terribly easy to learn. If you have previous experience in another imperative or OO language, you'll pick up the parts of Ruby that are similar to that fairly quickly, but you're not really learning anything so much as just doing a simple translation of a few concepts you already know. You're still going to run into problems with a number of standard Ruby constructions, probably not be writing clean or idiomatic code, and you'll be a long way from writing DSLs. In particular, you're likely to be writing highly repetitive code which could easily be refactored into something much smaller and nicer. (I'm constantly seeing people who have programmed in Ruby for years come up with six- to ten-line chunks of code that are could be replaced with a single line if they, e.g., only know that there was such as thing as a "modulo" function.) >From reading a lot of the code out there (particularly disasters such as Rails), I suspect a lot of Ruby programmers don't get much past this level. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From ivan.miljenovic at gmail.com Thu Oct 1 08:04:16 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu Oct 1 07:42:18 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph 0.5.1.0 Message-ID: <8763azjp6n.fsf@gmail.com> This is an updated version of my graph-theoretic static analysis tool for Haskell, SourceGraph. This version is available from http://hackage.haskell.org/package/SourceGraph-0.5.1.0 (now with docs on the Hackage page!). This version provides the ability to pass in a single Haskell source file rather than a Cabal file for analysis purposes. Note that the Cabal version is still preferred as it is better able to determine the project name and which modules are exported: when using a single source file, that file is presumed to be the only exported module and its module name is used as the overall project name. This feature was requested by Curt Sampson. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From jpm at cs.uu.nl Thu Oct 1 08:06:56 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Thu Oct 1 07:45:09 2009 Subject: [Haskell-cafe] Any generic serializer to String? was: Any working example of using genericserialize? In-Reply-To: References: <9d4d38820909300653ke3e50e5la793149e491cd9d8@mail.gmail.com> <168893184.20090930180709@gmail.com> Message-ID: <52f14b210910010506u479ce886j3a6d88fe8f88a036@mail.gmail.com> Hi Dimitry, On Thu, Oct 1, 2009 at 05:23, Dimitry Golubovsky wrote: > OK, I got it to work with gread/gshow. > > However I have noticed this: > > *Main> (gread $ gshow $ FuncExpr 0 [] (EmptyStmt 0)) :: [(Expression > Int, String)] > [(FuncExpr 0 [] (EmptyStmt 0),"")] > > vs. > > *Main> (gread $ gshow $ FuncExpr () [] (EmptyStmt ())) :: [(Expression > (), String)] > [] > > Or even narrower: > > *Main> (gread $ gshow 1)::[(Int, String)] > [(1,"")] > > vs. > > *Main> (gread $ gshow ())::[((), String)] > [] > > that is, the unit type does not work well with gread/gshow, likely > because inner parentheses are not parsed as a constructor. > > *Main> gshow () > "(())" > > Is this a known bug? > I don't think this was noticed before. I wrote it down on the SYB tracker [1]. It should be fixed for the next release. Thanks, Pedro [1] http://code.google.com/p/scrapyourboilerplate/issues/detail?id=9 > > Thanks. > > On Wed, Sep 30, 2009 at 10:19 AM, Dimitry Golubovsky > wrote: > > Bulat, > > > > OK, gread/gshow seem to be like the basis primitives. If they work > > properly, then it is what is needed. > > > > Thanks. > > > > On 9/30/09, Bulat Ziganshin wrote: > >> Hello Max, > >> > >> Wednesday, September 30, 2009, 5:53:37 PM, you wrote: > >> > >> afaik, SYB just provides gshow/gread functions what serialize any Data > >> instance to String > > -- > Dimitry Golubovsky > > Anywhere on the Web > _______________________________________________ > 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/20091001/146e899c/attachment.html From agocorona at gmail.com Thu Oct 1 08:45:49 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Oct 1 08:23:42 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <20091001113726.GD18507@analytic.cynic.net> References: <877hvfh7rg.fsf@malde.org> <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46155.7000308@btinternet.com> <4AC46011.4090203@btinternet.com> <20091001113726.GD18507@analytic.cynic.net> Message-ID: 2009/10/1 Curt Sampson > On 2009-10-01 08:53 +0100 (Thu), Andrew Coppin wrote: > > > Sure. But what is a computer program? It's a *list of instructions* that > > tells a computer *how to do something*. > > Some are. Some aren't, as proven by the Haskell definition of sum, which > is certainly a "program." > > I like to think of a program as a specification. A list of instructions > can certainly qualify, but so can other things, depending on what's > interpreting and executing that specification. > > Lets say that how to do a sum is pure abstract knowledge, and this translates nicely to a declarative haskell sentence. But to perform a sum of two concrete numbers is procedural, because either the program or the compiler or yourself have to extract from the available knowledge a sequence of steps in order to obtain a new knowledge, that is , the result. In imperative languages the sequentiation is more explicit. in functional languages this is more implicit, because the compiler+ runtime do the sequentiation. In fact, a C compiler also perform an automatic sequentiation for this simple operation and generates a sequence of assembler code for either a sum or any mathematical expression, but the haskell compiler is way more powerful for extracting sequences of steps from declarative statements. moreover, haskell promote a declarative style because laziness avoid to express abstract knowledge as sequences. Referential transparency avoid also dependencies of expressions from other expressions, and thus avoids artificial sequencing. however every time the program has to interact with the external world, even for printing the result,, sequencing is necessary. That?s why the compilers and interpreters exist!!!. If the program has to interact many times with the external world in a given sequence, the compiler can not guess such sequence if you don't write it explicitly. The perfect declarative haskell program has no main, no IO monad and no executable. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/1fca004f/attachment.html From batterseapower at hotmail.com Thu Oct 1 08:52:16 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Thu Oct 1 08:30:08 2009 Subject: [Haskell-cafe] Fwd: Uniplate + strict fields = fail. Why? In-Reply-To: <45047e50909301058y12874a32n30f694b1751e58a4@mail.gmail.com> References: <45047e50909301055g5d950015i736e56ef1dcbec1e@mail.gmail.com> <45047e50909301058y12874a32n30f694b1751e58a4@mail.gmail.com> Message-ID: <9d4d38820910010552v23093aabted1acdbf6f2bf921@mail.gmail.com> 2009/10/1 Dmitry Astapov : > Hi, > > I've been playing with generics in general (pardon the pun) and Uniplate in > particular, and found out that strict data fields somehow derail Uniplate. I think this is related to Neil's bug report about Ratio: http://hackage.haskell.org/trac/ghc/ticket/2782 The issue is that the Data instance for your types is stricter than he is expecting. I don't know enough about Uniplate to work out why he can't tunnel the undefined's he's trying to send through Data by hiding then within a box. Cheers, Max From phunge0 at hotmail.com Thu Oct 1 09:07:07 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Thu Oct 1 08:44:58 2009 Subject: [Haskell-cafe] Exceptions during exception unwinding In-Reply-To: <1254389201.7656.3.camel@localhost> References: Message-ID: <1254389201.7656.3.camel@localhost> Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 > On Thu=2C 2009-10-01 at 03:29 +0000=2C Brian Bloniarz wrote: >> I.e. why does an exception raised during exception handling get >> propagated past the exception that triggered the handler? > > Because it's the obvious and sensible thing to do and it what every > other mainstream language with exceptions does. Good to know ... C++ (the mainstream language I'm most familiar with) treats throwing from a destructor during unwinding as a fatal error. >>> bracket openSomeHandle closeSomeHandle doAction > Then catch and ignore the exception from closeSomeHandle (though not all > exceptions or you'd block ^C etc). That said=2C how will you know that > closeSomeHandle ever works if you always ignore any exceptions it > raises? I was suggesting having bracket ignore exceptions from closeSomeHandle when doAction threw=2C not that it'd ignore any exceptions from closeSomeHandle. It's only the case where bracket has 2 exceptions to choose from that's ambiguous=2C and I'm saying that there's a fair amount of code out there that'd prefer to see the first one. Your point about ^C gets us i= nto an even grayer area -- maybe code would prefer to propagate whichever of the 2 exceptions is asynchronous=2C or define a criterion to choose which exception is more serious=2C who knows. All these behaviors are easy to implement using the building blocks that Control.Exception exports right now=2C you're right. So I'm free to build my own bracket variants with different behavior and that's what I'll do. I was just wondering if the default behavior that bracket/onException provide (which are themselves built from catch/block/unblock) is the one that most people want. Thanks=2C -Brian =0A= _________________________________________________________________=0A= Microsoft brings you a new way to search the web. Try Bing=99 now=0A= http://www.bing.com?form=3DMFEHPG&publ=3DWLHMTAG&crea=3DTEXT_MFEHPG_Core_ta= gline_try bing_1x1= From phunge0 at hotmail.com Thu Oct 1 09:11:34 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Thu Oct 1 08:49:27 2009 Subject: [Haskell-cafe] Exceptions during exception unwinding Message-ID: Sorry for the garbled post, this should hopefully be plain text: > On Thu, 2009-10-01 at 03:29 +0000, Brian Bloniarz wrote: >> I.e. why does an exception raised during exception handling get >> propagated past the exception that triggered the handler? > > Because it's the obvious and sensible thing to do and it what every > other mainstream language with exceptions does. The behaviour you want, > to automatically discard any exceptions raised in the handler and to > always re-raise the original exception can be implemented using the > current semantics, but the reverse is not true. Good to know ... C++ (the mainstream language I'm most familiar with) treats throwing from a destructor during unwinding as a fatal error. I was suggesting having bracket ignore exceptions from closeSomeHandle when doAction threw, not that it'd ignore any exceptions from closeSomeHandle. ? It's only the case where bracket has 2 exceptions to choose from that's ambiguous, and I'm saying that there's a fair amount of code out there that'd prefer to see the first one. Your point about ^C gets us into an even grayer area -- maybe code would prefer to propagate whichever of the 2 exceptions is asynchronous, or define a criterion to choose which exception is more serious, who knows. ? All these behaviors are easy to implement using the building blocks that Control.Exception exports right now, you're right. So I'm free to build my own bracket variants with different behavior and that's what I'll do. I was just wondering if the default behavior that bracket/onException provide (which are themselves built from catch/block/unblock) is the one that most people want. ? Thanks, -Brian _________________________________________________________________ Microsoft brings you a new way to search the web. Try Bing? now http://www.bing.com?form=MFEHPG&publ=WLHMTAG&crea=TEXT_MFEHPG_Core_tagline_try bing_1x1 From v.dijk.bas at gmail.com Thu Oct 1 09:53:50 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Oct 1 09:31:44 2009 Subject: [Haskell-cafe] ANNOUNCE: usb-0.1 Message-ID: Hello, I would like to announce the release of usb-0.1, a Haskell library for communicating with USB devices from userspace. usb is implemented as a high-level wrapper around Maur?cio C. Antunes' bindings-libusb which is a binding to the C library: libusb-1.* ( http://libusb.org ). All functionality from libusb is provided except for asynchronous IO. I'm still thinking about if and how I should add that. As usual, install usb using cabal: > cabal install usb Or download and install it manually from hackage: http://hackage.haskell.org/package/usb-0.1 Or get the development source using darcs: darcs get http://code.haskell.org/~basvandijk/code/usb Comments and patches are highly welcome. Note that this is the first release, so expect API changes in the future. Note that my brother uploaded 'usb-id-database' to hackage. A small library for associating usb identifiers like vendor, product, class, subclass or prototcol identifiers with their respective names and vice versa: http://hackage.haskell.org/package/usb-id-database This can be helpful when trying to find the right device to operate. In a short while, the package 'ls-usb' will be released. This is a simple program for showing all the usb devices currently attached to your system. It's a nice demonstration on how to use the library. regards, Bas From martijn at van.steenbergen.nl Thu Oct 1 10:02:26 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Oct 1 09:40:25 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: References: Message-ID: <4AC4B672.9000000@van.steenbergen.nl> Bas van Dijk wrote: > Comments and patches are highly welcome. I tried to install on my Mac but bindings-common choked on: > cabal install bindings-common Resolving dependencies... cabal: Error: some packages failed to install: bindings-common-1.1 failed while unpacking the package. The exception was: /var/folders/mR/mRFqQvztFo0URT0d6GN9wE+++TI/-Tmp-/bindings-common-1.174967/bindings-common-1.1/src/Bindings: createDirectory: does not exist (No such file or directory) Not sure if this is interesting to you, Bas, but I thought I'd share. :-) Groetjes, Martijn. From vandijk.roel at gmail.com Thu Oct 1 10:12:21 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Oct 1 09:50:13 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: <4AC4B672.9000000@van.steenbergen.nl> References: <4AC4B672.9000000@van.steenbergen.nl> Message-ID: Yes, that happens. I don't now the cause but the work-around is easy. Simply download the package manually from hackage, unpack and install using cabal. At least the following packages suffer from this problem: bindings-common bindings-libusb bindings-posix Perhaps Maur??cio can shed some light on this. Groetjes, Roel On Thu, Oct 1, 2009 at 4:02 PM, Martijn van Steenbergen wrote: > Bas van Dijk wrote: >> >> Comments and patches are highly welcome. > > I tried to install on my Mac but bindings-common choked on: > >> cabal install bindings-common > Resolving dependencies... > cabal: Error: some packages failed to install: > bindings-common-1.1 failed while unpacking the package. The exception was: > /var/folders/mR/mRFqQvztFo0URT0d6GN9wE+++TI/-Tmp-/bindings-common-1.174967/bindings-common-1.1/src/Bindings: > createDirectory: does not exist (No such file or directory) > > Not sure if this is interesting to you, Bas, but I thought I'd share. :-) > > Groetjes, > > Martijn. From bugfact at gmail.com Thu Oct 1 10:12:59 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Oct 1 09:50:52 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC46011.4090203@btinternet.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> Message-ID: On Thu, Oct 1, 2009 at 9:53 AM, Andrew Coppin wrote: > Sure. But what is a computer program? It's a *list of instructions* that > tells a computer *how to do something*. And yet, the Haskell definition of > sum looks more like a definition of what a sum is rather than an actual, > usable procedure for *computing* that sum. (Of course, we know that it /is/ > in fact executable... it just doesn't look it at first sight.) > Is it? The list of instruction is just an abstraction layer built on top of purely physical process of electrons and transistors; I'm not sure how much imperativeness remains at this level? Not to mention the quantum mechanical processes that take place... And that are also just mathematical models... I mean, it really depends from which angle and at which detail you look at it, no? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/bfe7ae76/attachment.html From vanenkj at gmail.com Thu Oct 1 10:20:11 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Oct 1 09:58:03 2009 Subject: [Haskell-cafe] c2hs, size_t, and CSize -- argh! Message-ID: Hello List, I'm running into a problem with c2hs and how it parses the C typedef 'size_t'. On 32bit systems, this ends up being parsed as a CUInt. On 64bit systems, this ends up as a CULong. This gets especially sticky with function pointers. In order to make bindings with c2hs that work across the different word sizes, I have to write an indirection layer in C that defines wrappers for functions or re-defines typedef's for function pointers to include 'unsigned long' instead of 'size_t'. I see there is a ticket open for this: http://hackage.haskell.org/trac/c2hs/ticket/20 Has any one else run into this issue? Is there a good workaround that doesn't involve writing a C function/typedef for each collision? /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/88c29b8d/attachment.html From martijn at van.steenbergen.nl Thu Oct 1 10:22:29 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Oct 1 10:00:26 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: References: <4AC4B672.9000000@van.steenbergen.nl> Message-ID: <4AC4BB25.7060401@van.steenbergen.nl> Roel van Dijk wrote: > Yes, that happens. I don't now the cause but the work-around is easy. > Simply download the package manually from hackage, unpack and install > using cabal. > > At least the following packages suffer from this problem: > bindings-common > bindings-libusb > bindings-posix > > Perhaps Maur??cio can shed some light on this. That's odd, even cabal unpack fails. Smells like a cabal bug. :-) I'll see if I can find if it's been reported before. Martijn. From vandijk.roel at gmail.com Thu Oct 1 10:25:27 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Oct 1 10:03:21 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: <4AC4BB25.7060401@van.steenbergen.nl> References: <4AC4B672.9000000@van.steenbergen.nl> <4AC4BB25.7060401@van.steenbergen.nl> Message-ID: > That's odd, even cabal unpack fails. Smells like a cabal bug. :-) I'll see > if I can find if it's been reported before. I meant a manual unpack: tar xvf bindings-common-1.1.tar.gz But it is indeed odd. From wss at cs.nott.ac.uk Thu Oct 1 10:33:43 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Thu Oct 1 10:11:36 2009 Subject: [Haskell-cafe] New TMR editor Message-ID: Dear all, After several years at the helm, I've decided to step down as editor of the Monad.Reader. I am happy to announce that Brent Yorgey will take over my role as editor. I'd like to take this opportunity to thank Brent for helping to keep the Monad.Reader alive. I'm sure he'll do a fantastic job. Finally, I'd like to thank all the people who have contributed to the Monad.Reader over the last few years ? you guys have made this publication, and my job as an editor, so much fun. All the best, Wouter From jefferson.r.heard at gmail.com Thu Oct 1 10:39:16 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Oct 1 10:17:27 2009 Subject: [Haskell-cafe] New OpenGL package: efficient way to convert datatypes? In-Reply-To: <4AC42407.9010001@freegeek.org> References: <4AC42327.3020502@freegeek.org> <4AC42407.9010001@freegeek.org> Message-ID: <4165d3a70910010739u21d06c99ue75cda2493db8c3b@mail.gmail.com> Ah, but it takes care of my performance problems, so many thanks from the lurker :-) -- Jeff On Wed, Sep 30, 2009 at 11:37 PM, wren ng thornton wrote: > wren ng thornton wrote: >>> >>> I guess one could make rules for that, but this tickets makes me wander >>> if >>> that really works: >>> http://hackage.haskell.org/trac/ghc/ticket/1434 >> >> The RealToFrac class solves Henning's performance complaint as well. > > > Er, I misread his performance problems. The logfloat package doesn't offer > any particular support for rounding to integral types. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From nenekotan at gmail.com Thu Oct 1 10:50:31 2009 From: nenekotan at gmail.com (Bas van Gijzel) Date: Thu Oct 1 10:28:26 2009 Subject: [Haskell-cafe] river crossing puzzle In-Reply-To: <4AC10D3A.6060703@comp.dit.ie> References: <4AC10D3A.6060703@comp.dit.ie> Message-ID: Or you could look at my blog posts describing the implementation of the Cannibals and Missionaries variant step by step. First a naive approach and secondly using a state monad solution. http://adoseoflogic.blogspot.com/2009/07/cannibals-missionaries-and-state-monad.html Cheers, Bas 2009/9/28 pat browne > Hi, > Does anyone know where there are any Haskell implementations of the the > River Crossing puzzle (AKA Farmer/Fox/Goose/Grain). > There are several variations but the general ideas are explained at: > http://en.wikipedia.org/wiki/River_crossing_puzzle > http://en.wikipedia.org/wiki/Fox,_goose_and_bag_of_beans_puzzle > > I have found one at: > http://www.shido.info/hs/haskell9.html > > > Thanks, > Pat > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- http://adoseoflogic.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/a82d669e/attachment.html From agocorona at gmail.com Thu Oct 1 11:12:03 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Oct 1 10:49:56 2009 Subject: Fwd: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> Message-ID: ;) Off topic: Maybe the entire space time, the universe and his history, is isomorphic to a mathematical structure. http://space.mit.edu/home/tegmark/toe_frames.html 2009/10/1 Peter Verswyvelen > > > On Thu, Oct 1, 2009 at 9:53 AM, Andrew Coppin > wrote: > >> Sure. But what is a computer program? It's a *list of instructions* that >> tells a computer *how to do something*. And yet, the Haskell definition of >> sum looks more like a definition of what a sum is rather than an actual, >> usable procedure for *computing* that sum. (Of course, we know that it /is/ >> in fact executable... it just doesn't look it at first sight.) >> > > Is it? The list of instruction is just an abstraction layer built on top of > purely physical process of electrons and transistors; I'm not sure how much > imperativeness remains at this level? Not to mention the quantum mechanical > processes that take place... And that are also just mathematical models... I > mean, it really depends from which angle and at which detail you look at it, > no? > > > _______________________________________________ > 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/20091001/9168d00a/attachment.html From magnus at therning.org Thu Oct 1 11:17:47 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Oct 1 10:55:40 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.1 In-Reply-To: <20090930043530.GA31155@janrain.com> References: <20090930043530.GA31155@janrain.com> Message-ID: On Wed, Sep 30, 2009 at 5:35 AM, Jonathan Daugherty wrote: > vty-ui is: > > An extensible library of user interface widgets for composing and > laying out Vty user interfaces. This library provides a collection of > widgets and a type class for rendering widgets to Vty Images. Am I correct in saying that the collection of widgets contains a single widget type so far? ;-) What are the plans for adding widgets in the future? The list widget looks useful, does it handle multi-line strings (i.e. strings with a "\n")? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From drcygnus at gmail.com Thu Oct 1 11:23:18 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Thu Oct 1 11:01:15 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.1 In-Reply-To: References: <20090930043530.GA31155@janrain.com> Message-ID: > Am I correct in saying that the collection of widgets contains a > single widget type so far? ;-) Technically, four; vertical and horizontal boxes, a text string widget, and the List you mentioned. It only has a few types because I was just releasing early. I'm going to start using this in a project and add things as needed. > The list widget looks useful, does it handle multi-line strings (i.e. > strings with a "\n")? It currently only handles single-line strings but I'd actually like to generalize it to take a list of Widget instances (possibly with restrictions). -- Jonathan Daugherty From magnus at therning.org Thu Oct 1 11:27:41 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Oct 1 11:05:34 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.1 In-Reply-To: References: <20090930043530.GA31155@janrain.com> Message-ID: On Thu, Oct 1, 2009 at 4:23 PM, Jonathan Daugherty wrote: >> Am I correct in saying that the collection of widgets contains a >> single widget type so far? ?;-) > > Technically, four; vertical and horizontal boxes, a text string > widget, and the List you mentioned. ?It only has a few types because I > was just releasing early. ?I'm going to start using this in a project > and add things as needed. Nice. This sure beats how I've been doing it in the past. Out of curiousity, can you talk about what you're doing with it? >> The list widget looks useful, does it handle multi-line strings (i.e. >> strings with a "\n")? > > It currently only handles single-line strings but I'd actually like to > generalize it to take a list of Widget instances (possibly with > restrictions). Very nice. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From jvranish at gmail.com Thu Oct 1 11:35:43 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Oct 1 11:13:36 2009 Subject: [Haskell-cafe] Splitting data and function declarations over multiple files In-Reply-To: References: <7ca3f0160909301215s9a09a00pbe14c2f048d8cb3@mail.gmail.com> Message-ID: Along the projection/co-algebra lines (I actually didn't know that's what they were called until today :) yay for learning new things!) How about something like this: -- Define "prototypes" for your class of actions here data Actor = Actor {pos::Vector2 Float, move::Vector2 Float -> Actor} -- simple class that selects your actions based on type class ActorClass a where mkActor :: a -> Actor -- object types data Ball = Ball ... -- stuff data Paddle = Paddle ... -- stuff data Wall = Wall ... -- suff -- Functions for working with objects getBallPosition (Ball ...) = ... getPaddlePosition (Paddle ...) = ... moveBall (Ball ...) = ... movePaddle (Ball ...) = ... -- selection actions for Ball instance Actor Ball where mkActor this = let pos' = getBallPosition this move' v = moveBall this in Actor pos' move' -- selection actions for Paddle instance Actor Paddle where mkActor this = let pos' = getPaddlePosition this move' v = movePaddle this in Actor pos' move' Base off a technique I ran across here: http://www.mail-archive.com/haskell@haskell.org/msg04513.html Also, a useful wikipage for doing OO things in haskell: http://www.haskell.org/haskellwiki/OOP_vs_type_classes - Job On Thu, Oct 1, 2009 at 4:45 AM, Peter Verswyvelen wrote: > I'm not sure if I understand what you mean with this co-algebraic approach, > but I guess you mean that functions - like move - don't work directly on any > datatype; you need to provide other functions that give access to the data. > But that's basically what type classes do no? And that's also related to my > earlier post of "strong duck typing" in Haskell. > At least also in C#, that's the way I usually write code that works on any > type, just make an interface or pass in a delegate. I also know that my OO > background keeps pushing me in the wrong direction when it comes to Haskell > ;-) > > The collision handling approach is always interesting :) In OO this is > usually solved using multi-methods or visitors: > http://en.wikipedia.org/wiki/Multiple_dispatch. What I usually did in old > games of mine to handle collisions is not look at the type, but at the > "collision specific features" of a type (which are again functions that > extract information from the object), and that is most likely again the > co-algebraic approach? > > On Wed, Sep 30, 2009 at 9:15 PM, Luke Palmer wrote: > >> On Wed, Sep 30, 2009 at 9:54 AM, Peter Verswyvelen >> wrote: >> > I guess this is related to the expression problem. >> > Suppose I have a datatype >> > data Actor = Ball ... | Paddle ... | Wall ... >> > and a function >> > move (Ball ...) = >> > move (Paddle ...) = >> > move (Wall ...) = >> > in Haskell one must put Actor and move into a single file. >> > This is rather cumbersome if you work with multiple people or want to >> keep >> > the files small and readable. >> > Surely it is possible to use type classes, existentials, etc to split >> the >> > data type into multiple ones, but that's already advanced stuff in a >> sense. >> >> You can do it without type classes and existentials. The >> functionality you want is already supported by Haskell, you just have >> to let go of your syntactical expectations. The trick is that you >> should rewrite your data type not as an algebra (a set of >> constructors), but as a coalgebra (a set of projections). >> >> Let's say your two open functions are: >> >> move :: Actor -> Actor >> isAlive :: Actor -> Bool >> >> This gives rise to the definition of an Actor type: >> >> data Actor = Actor { move :: Actor, isAlive :: Bool } >> >> And then the alternatives of your open data type are just values of type >> Actor: >> >> ball :: Vector -> Vector -> Actor >> ball pos vel = Actor { >> move = ball (pos + vel) vel, >> isAlive = True >> } >> >> etc. >> >> This trick works well until you get to the encoding of functions that >> pattern match on multiple Actors at the same time. As far as I can >> tell, that cannot be encoded in this style in any reasonable way. >> Such functions must be rephrased in a coalgebraic style; i.e. instead >> of asking about constructors, using projection functions it knows are >> available. >> >> So for example instead of implementing "collide" by asking about >> pairs, add functions which report a shape function and a normal, or >> whatever your collide algorithm needs from shapes. >> >> You would probably end up having to do this anyway even with your >> proposed extension, because watch: >> >> partial data Actor = Ball ... >> >> collide (Ball ...) (Ball ...) = ... >> collide (Ball ...) x = ... >> >> We don't know about any other constructors, so the second line has to >> contain a pattern-free x. So you would have to use projection >> functions to get any information about it, exactly as you would when >> you're writing in the coalgebraic style. >> >> So, Yes! Haskell can do that! >> >> Luke >> > > > _______________________________________________ > 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/20091001/bf88ca03/attachment.html From cjs at starling-software.com Thu Oct 1 11:56:27 2009 From: cjs at starling-software.com (Curt Sampson) Date: Thu Oct 1 11:34:21 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20090929153550.GG24761@analytic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> Message-ID: <20091001155627.GB27880@poetic.cynic.net> On 2009-09-29 13:18 +0200 (Tue), Alberto G. Corona wrote: > What is the vehicle that haskell can use to enter the mainstream?. Actually, I have one more thought on that: wait. I'd had the impression that Haskell was becoming fairly well known (if not yet heavily used, in comparison to languages like Java), but I just ran across some hard evidence for this. In the 32 languages ranked on http://www.langpop.com/ , Haskell consistently comes down near the bottom in the various rankings of use. (But hey, we're not so weird we're not in there!) But if you look down near the bottom, at the chart labeled "Normalized Discussion Site Results," you'll notice that Haskell comes out sixth. Even trying to be more fair to the mainstream, and changing the weighting to drop Lambda the Ultimate completely (after all, they're just a bunch of academic wankers, right?) and bring IRC down to a contribution of 0.5 instead of 1 (apparently those academic wankers have lots of time to chat online), Haskell still comes out tenth, with a score over a third that of the leader, Java, and close to half that of PHP and C (2nd and 3rd place, respectively). We've also got at least one undeniably good, production-quality compiler (which is more than PHP or Ruby can say), and have sold many tens of thousands, perhaps even hundreds of thousands, of books. At this point, I don't think many people (John A. De Goes excepted) are looking at people writing major applications in Haskell as if they're aliens living on another planet. Haskell is in the mainstream already as far as being taken seriously; most of the complaints I'm seeing seem to be grasping at the same kinds of straws that the anti-Java guys were back in the late '90s. ("It's hopeless if it uses garbage collection.") We've even got our own over-hyped, under-utilized supposed benefit ("it's good for multicore"). The main whinging seems to be about libraries, of which we have "only" 1585 on hackage. Compare with RubyForge, which has 2059 projects in "beta" or better status, or 2961 if we include "alpha" as well. The Ruby Application Archive has 1768 projects; I have no idea how much overlap there is, or how many of these are real. I think we just need to sit tight for a couple of years. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From korpios at korpios.com Thu Oct 1 12:01:31 2009 From: korpios at korpios.com (Tom Tobin) Date: Thu Oct 1 11:39:24 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC467C4.4070303@btinternet.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> Message-ID: On Thu, Oct 1, 2009 at 3:26 AM, Andrew Coppin wrote: > It might be a better argument to say that human thinking is fundamentally > sequential; parallel computers have been around for a little while now... Perhaps *conscious* human thinking is sequential ??yet our brains are massively parallel processors, and have been around for quite a long time. ;-) From hjgtuyl at chello.nl Thu Oct 1 12:02:05 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu Oct 1 11:40:03 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: References: <4AC4B672.9000000@van.steenbergen.nl> Message-ID: The file bindings-common.tar.gz looks a bit odd: when I unpack it with 7Zip, I get the path: bindings-common-1.1.tar.gz\\home\mauricio\bindings-common-1.1.tar.gz\bindings-common-1.1\ (first part deleted) Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- On Thu, 01 Oct 2009 16:12:21 +0200, Roel van Dijk wrote: > Yes, that happens. I don't now the cause but the work-around is easy. > Simply download the package manually from hackage, unpack and install > using cabal. > > At least the following packages suffer from this problem: > bindings-common > bindings-libusb > bindings-posix > > Perhaps Maur?cio can shed some light on this. > > Groetjes, > Roel > > On Thu, Oct 1, 2009 at 4:02 PM, Martijn van Steenbergen > wrote: >> Bas van Dijk wrote: >>> >>> Comments and patches are highly welcome. >> >> I tried to install on my Mac but bindings-common choked on: >> >>> cabal install bindings-common >> Resolving dependencies... >> cabal: Error: some packages failed to install: >> bindings-common-1.1 failed while unpacking the package. The exception >> was: >> /var/folders/mR/mRFqQvztFo0URT0d6GN9wE+++TI/-Tmp-/bindings-common-1.174967/bindings-common-1.1/src/Bindings: >> createDirectory: does not exist (No such file or directory) >> >> Not sure if this is interesting to you, Bas, but I thought I'd share. >> :-) >> >> Groetjes, >> >> Martijn. > _______________________________________________ -- From duncan.coutts at googlemail.com Thu Oct 1 11:07:54 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Oct 1 11:48:21 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: <4AC4BB25.7060401@van.steenbergen.nl> References: <4AC4B672.9000000@van.steenbergen.nl> <4AC4BB25.7060401@van.steenbergen.nl> Message-ID: <1254409674.7656.41.camel@localhost> On Thu, 2009-10-01 at 16:22 +0200, Martijn van Steenbergen wrote: > Roel van Dijk wrote: > > Yes, that happens. I don't now the cause but the work-around is easy. > > Simply download the package manually from hackage, unpack and install > > using cabal. > > > > At least the following packages suffer from this problem: > > bindings-common > > bindings-libusb > > bindings-posix > > > > Perhaps Maur??cio can shed some light on this. > > That's odd, even cabal unpack fails. Smells like a cabal bug. :-) I'll > see if I can find if it's been reported before. I suspect it is a bug in the tar code (a copy of which is used in cabal-install). Most .tar files contain entries for the directories that precede the entries for the files. This is only by convention however. It looks like this tar file has an entry for "src/Bindings/SomeFile.hs" without any preceding entries for "src/AnotherFile" or for the directory itself "src/Bindings/". The bug is that while the tar code would create the "src/" directory for a file entry "src/AnotherFile", it would not create the "src/" directory for "src/Bindings/SomeFile.hs", just try to create the "src/Bindings" directroy, which then fails since "src/" does not yet exist. I was trying to avoid making all parent directories in a fully recursive way. In particular I don't want it to make the target root directory if it did not already exist. I guess it should at least make the directories between the target root and the directory containing the file to be unpacked. If someone wants to make a patch for this then please do it against the tar package code: darcs get http://code.haskell.org/tar/ Note that tar files constructed using cabal sdist should not have this particular problem due to the order of entries within the archive. Duncan From andrewcoppin at btinternet.com Thu Oct 1 12:20:13 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 1 11:58:06 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> Message-ID: <4AC4D6BD.8050707@btinternet.com> Tom Tobin wrote: > On Thu, Oct 1, 2009 at 3:26 AM, Andrew Coppin > wrote: > >> It might be a better argument to say that human thinking is fundamentally >> sequential; parallel computers have been around for a little while now... >> > > Perhaps *conscious* human thinking is sequential ? yet our brains are > massively parallel processors, and have been around for quite a long > time. ;-) > This is very true. And it's just as well; I read somewhere that the maximum firing rate of a neuron gives the human brain an effective "clock frequency" of about 100 MHz - which isn't terribly fast. But it's massively parallel, as you say. Actually, I just had a flash of inspiration: Maybe the reason programmers tend to think sequentially is because programmers tend to be *men*. Maybe the way to hardness the multicores is to get more women into programming? :-D From duncan.coutts at googlemail.com Thu Oct 1 12:37:12 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Oct 1 12:15:35 2009 Subject: [Haskell-cafe] c2hs, size_t, and CSize -- argh! In-Reply-To: References: Message-ID: <1254415032.7656.55.camel@localhost> On Thu, 2009-10-01 at 10:20 -0400, John Van Enk wrote: > Hello List, > > I'm running into a problem with c2hs and how it parses the C typedef > 'size_t'. On 32bit systems, this ends up being parsed as a CUInt. On > 64bit systems, this ends up as a CULong. This gets especially sticky > with function pointers. Right. Of course that's because on those different platforms size_t really is a typedef for unsigned int or unsigned long. > I see there is a ticket open for this: > http://hackage.haskell.org/trac/c2hs/ticket/20 > > Has any one else run into this issue? Is there a good workaround that > doesn't involve writing a C function/typedef for each collision? So what you would want, presumably, is to map the "size_t" typedef to the Haskell type Foreign.C.Types.CSize, rather than what c2hs discovers as the actual raw type of "size_t". Then you're making the promise that unsigned long, or unsigned int really really does match Foreign.C.Types.CSize. Currently c2hs has no support for remapping basic types like that. As for a workaround, just use fromIntegral to convert to CSize. You know this is always possible because you know CSize matches CUInt or CULong on the appropriate platforms. $ cat foo.h #include size_t foo(void); $ cat foo.c #include "foo.h" size_t foo(void) { return 42; } $ cat foo.chs import Foreign.C.Types foo :: IO CSize foo = fmap fromIntegral {# call foo as bar #} $ gcc -c foo.c $ c2hs foo.h foo.chs $ ghci foo.hs -fffi foo.o Main> foo 42 Duncan From agocorona at gmail.com Thu Oct 1 12:47:28 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Oct 1 12:25:22 2009 Subject: Fwd: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> Message-ID: May be because consciousness is relatively new and thus, not optimized. Sequentiallity is somehow related with lack of information and lack or resources. There is nothing more sequential than a Turing machine. The Von Newman architecture is designed to make as much as possible with a few more resources. The older parts of the brain are fast and parallel because they have a long history of optimizations by natural selection., The new cortex still struggles, step by step, to deduce new information from the available internal and external information at the pace they arrive. 2009/10/1 Tom Tobin On Thu, Oct 1, 2009 at 3:26 AM, Andrew Coppin > wrote: > > It might be a better argument to say that human thinking is fundamentally > > sequential; parallel computers have been around for a little while now... > > Perhaps *conscious* human thinking is sequential ? yet our brains are > massively parallel processors, and have been around for quite a long > time. ;-) > _______________________________________________ > 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/20091001/3967e30a/attachment.html From drcygnus at gmail.com Thu Oct 1 12:50:27 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Thu Oct 1 12:28:24 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.1 In-Reply-To: References: <20090930043530.GA31155@janrain.com> Message-ID: <20091001165024.GA20704@janrain.com> # Nice. This sure beats how I've been doing it in the past. Out of # curiousity, can you talk about what you're doing with it? Yeah, I'd like to use this to write an administration tool for my "dbmigrations" package. I started doing it in hscurses and decided I needed to be able to live with the code (and the process of writing it), so now I'm off in the weeds working on a UI library. :) On the way to work this morning I started working on a Scrollable class to generalize the List's scrolling capabilities and support scrolling of any widget rendered in constrained space. We'll see how that goes.. -- Jonathan Daugherty From jvranish at gmail.com Thu Oct 1 12:54:00 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Oct 1 12:31:51 2009 Subject: [Haskell-cafe] Splitting data and function declarations over multiple files In-Reply-To: References: <7ca3f0160909301215s9a09a00pbe14c2f048d8cb3@mail.gmail.com> Message-ID: Opps, errors, it should be more like: moveBall (Vector2 x y) (Ball ...) = ... movePaddle (Vector2 x y) (Paddle ...) = ... -- selection actions for Ball instance Actor Ball where mkActor this = let pos' = getBallPosition this move' v = mkActor $ moveBall v this in Actor pos' move' -- selection actions for Paddle instance Actor Paddle where mkActor this = let pos' = getPaddlePosition this move' v = mkActor $ movePaddle v this in Actor pos' move' Hmm, I bet some generics, or template haskell could clean up the extra boilerplate associated with this technique. - Job On Thu, Oct 1, 2009 at 11:35 AM, Job Vranish wrote: > Along the projection/co-algebra lines (I actually didn't know that's what > they were called until today :) yay for learning new things!) > > How about something like this: > > -- Define "prototypes" for your class of actions here > data Actor = Actor {pos::Vector2 Float, move::Vector2 Float -> Actor} > > -- simple class that selects your actions based on type > class ActorClass a where > mkActor :: a -> Actor > > -- object types > data Ball = Ball ... -- stuff > data Paddle = Paddle ... -- stuff > data Wall = Wall ... -- suff > > -- Functions for working with objects > getBallPosition (Ball ...) = ... > getPaddlePosition (Paddle ...) = ... > > moveBall (Ball ...) = ... > movePaddle (Ball ...) = ... > > -- selection actions for Ball > instance Actor Ball where > mkActor this = let > pos' = getBallPosition this > move' v = moveBall this > in Actor pos' move' > > -- selection actions for Paddle > instance Actor Paddle where > mkActor this = let > pos' = getPaddlePosition this > move' v = movePaddle this > in Actor pos' move' > > > Base off a technique I ran across here: > http://www.mail-archive.com/haskell@haskell.org/msg04513.html > > Also, a useful wikipage for doing OO things in haskell: > http://www.haskell.org/haskellwiki/OOP_vs_type_classes > > - Job > > > On Thu, Oct 1, 2009 at 4:45 AM, Peter Verswyvelen wrote: > >> I'm not sure if I understand what you mean with this co-algebraic >> approach, but I guess you mean that functions - like move - don't work >> directly on any datatype; you need to provide other functions that give >> access to the data. But that's basically what type classes do no? And that's >> also related to my earlier post of "strong duck typing" in Haskell. >> At least also in C#, that's the way I usually write code that works on any >> type, just make an interface or pass in a delegate. I also know that my OO >> background keeps pushing me in the wrong direction when it comes to Haskell >> ;-) >> >> The collision handling approach is always interesting :) In OO this is >> usually solved using multi-methods or visitors: >> http://en.wikipedia.org/wiki/Multiple_dispatch. What I usually did in old >> games of mine to handle collisions is not look at the type, but at the >> "collision specific features" of a type (which are again functions that >> extract information from the object), and that is most likely again the >> co-algebraic approach? >> >> On Wed, Sep 30, 2009 at 9:15 PM, Luke Palmer wrote: >> >>> On Wed, Sep 30, 2009 at 9:54 AM, Peter Verswyvelen >>> wrote: >>> > I guess this is related to the expression problem. >>> > Suppose I have a datatype >>> > data Actor = Ball ... | Paddle ... | Wall ... >>> > and a function >>> > move (Ball ...) = >>> > move (Paddle ...) = >>> > move (Wall ...) = >>> > in Haskell one must put Actor and move into a single file. >>> > This is rather cumbersome if you work with multiple people or want to >>> keep >>> > the files small and readable. >>> > Surely it is possible to use type classes, existentials, etc to split >>> the >>> > data type into multiple ones, but that's already advanced stuff in a >>> sense. >>> >>> You can do it without type classes and existentials. The >>> functionality you want is already supported by Haskell, you just have >>> to let go of your syntactical expectations. The trick is that you >>> should rewrite your data type not as an algebra (a set of >>> constructors), but as a coalgebra (a set of projections). >>> >>> Let's say your two open functions are: >>> >>> move :: Actor -> Actor >>> isAlive :: Actor -> Bool >>> >>> This gives rise to the definition of an Actor type: >>> >>> data Actor = Actor { move :: Actor, isAlive :: Bool } >>> >>> And then the alternatives of your open data type are just values of type >>> Actor: >>> >>> ball :: Vector -> Vector -> Actor >>> ball pos vel = Actor { >>> move = ball (pos + vel) vel, >>> isAlive = True >>> } >>> >>> etc. >>> >>> This trick works well until you get to the encoding of functions that >>> pattern match on multiple Actors at the same time. As far as I can >>> tell, that cannot be encoded in this style in any reasonable way. >>> Such functions must be rephrased in a coalgebraic style; i.e. instead >>> of asking about constructors, using projection functions it knows are >>> available. >>> >>> So for example instead of implementing "collide" by asking about >>> pairs, add functions which report a shape function and a normal, or >>> whatever your collide algorithm needs from shapes. >>> >>> You would probably end up having to do this anyway even with your >>> proposed extension, because watch: >>> >>> partial data Actor = Ball ... >>> >>> collide (Ball ...) (Ball ...) = ... >>> collide (Ball ...) x = ... >>> >>> We don't know about any other constructors, so the second line has to >>> contain a pattern-free x. So you would have to use projection >>> functions to get any information about it, exactly as you would when >>> you're writing in the coalgebraic style. >>> >>> So, Yes! Haskell can do that! >>> >>> Luke >>> >> >> >> _______________________________________________ >> 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/20091001/1175f14b/attachment.html From vanenkj at gmail.com Thu Oct 1 13:00:15 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Oct 1 12:38:08 2009 Subject: [Haskell-cafe] c2hs, size_t, and CSize -- argh! In-Reply-To: <1254415032.7656.55.camel@localhost> References: <1254415032.7656.55.camel@localhost> Message-ID: Hi Duncan, Yes, I forgot to leave out that I'd like to see 'size_t' mapped to CSize. As a (dirty) workaround, one can use 'castPtr' as the marshaler when dealing with pointers to 'size_t'. I'm a little more concerned about FunPtr's (though 'castPtr' still makes the issue go away). Here's my specific case dealing with function pointers: In 64bit world, it looks like this: type ReadableCallback = Ptr () -> Ptr CUChar -> *Ptr CULong* -> IO CUInt {#fun gcry_ac_io_init_readable_callback { id `ACIO', id `FunPtr ReadableCallback', id `Ptr ()' } -> `()'#} In 32bit world, it looks like this: type ReadableCallback = Ptr () -> Ptr CUChar -> *Ptr CUInt* -> IO CUInt {#fun gcry_ac_io_init_readable_callback { id `ACIO', id `FunPtr ReadableCallback', id `Ptr ()' } -> `()'#} I'd really like it if I could use 'Ptr CSize' (which corresponds to the 'size_t * ptr' in the C code). My current workaround (which doesn't use a cast in Haskell) is to redefine the function pointer type in a C header file to use 'unsigned long' instead of 'size_t', but this gets cludgy in a hurry. If c2hs could translate to CSize directly, I could pass a pointer to CSize. Is it really such a problem to make the conversion? My assumption is that CSize would match 'size_t' for the specific architecture. Thanks for your comment. /jve On Thu, Oct 1, 2009 at 12:37 PM, Duncan Coutts wrote: > On Thu, 2009-10-01 at 10:20 -0400, John Van Enk wrote: > > Hello List, > > > > I'm running into a problem with c2hs and how it parses the C typedef > > 'size_t'. On 32bit systems, this ends up being parsed as a CUInt. On > > 64bit systems, this ends up as a CULong. This gets especially sticky > > with function pointers. > > Right. Of course that's because on those different platforms size_t > really is a typedef for unsigned int or unsigned long. > > > I see there is a ticket open for this: > > http://hackage.haskell.org/trac/c2hs/ticket/20 > > > > Has any one else run into this issue? Is there a good workaround that > > doesn't involve writing a C function/typedef for each collision? > > So what you would want, presumably, is to map the "size_t" typedef to > the Haskell type Foreign.C.Types.CSize, rather than what c2hs discovers > as the actual raw type of "size_t". Then you're making the promise that > unsigned long, or unsigned int really really does match > Foreign.C.Types.CSize. > > Currently c2hs has no support for remapping basic types like that. > > As for a workaround, just use fromIntegral to convert to CSize. You know > this is always possible because you know CSize matches CUInt or CULong > on the appropriate platforms. > > $ cat foo.h > #include > size_t foo(void); > > $ cat foo.c > #include "foo.h" > size_t foo(void) { return 42; } > > $ cat foo.chs > > import Foreign.C.Types > foo :: IO CSize > foo = fmap fromIntegral {# call foo as bar #} > > $ gcc -c foo.c > $ c2hs foo.h foo.chs > $ ghci foo.hs -fffi foo.o > Main> foo > 42 > > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/20dcb9b2/attachment.html From mauricio.antunes at gmail.com Thu Oct 1 13:29:48 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Oct 1 13:08:07 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: <1254409674.7656.41.camel@localhost> References: <4AC4B672.9000000@van.steenbergen.nl> <4AC4BB25.7060401@van.steenbergen.nl> <1254409674.7656.41.camel@localhost> Message-ID: >>> At least the following packages suffer from this problem: >>> bindings-common bindings-libusb bindings-posix > Most .tar files contain entries for the directories that > precede the entries for the files. This is only by convention > however. It looks like this tar file has an entry for > "src/Bindings/SomeFile.hs" without any preceding entries for > "src/AnotherFile" or for the directory itself "src/Bindings/". Thanks for the tip. I used Mercurial archive to create those tars: hg archive -t tgz -p 'bindings-common-1.1' ~/bindings-common-1.1.tar.gz I'll check if this is known in Mercurial, specially the weird output got from 7zip. Meanwhile, I'll be uploading as soon as possible new versions of those packages with runhaskell Setup.hs sdist Best, Maur?cio From paul at cogito.org.uk Thu Oct 1 14:24:47 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Thu Oct 1 14:02:42 2009 Subject: [Haskell-cafe] Haskell for Physicists In-Reply-To: <20090930174257.GA29934@ymonad.members.linode.com> References: <20090930174257.GA29934@ymonad.members.linode.com> Message-ID: <4AC4F3EF.6000809@cogito.org.uk> I can't help with the title, but you might show how Haskell can help avoid the subtle bugs that create erroneous results. Start with the dimensional library (http://hackage.haskell.org/package/dimensional). Paul. From v.dijk.bas at gmail.com Thu Oct 1 15:17:20 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Oct 1 14:55:12 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: References: <4AC4B672.9000000@van.steenbergen.nl> <4AC4BB25.7060401@van.steenbergen.nl> <1254409674.7656.41.camel@localhost> Message-ID: 2009/10/1 Maur??cio CA : > Meanwhile, I'll be uploading as soon as > possible new versions... Thanks Mauricio, I've uploaded usb-0.1.0.1 that now depends on the fixed bindings-libusb-1.2. http://hackage.haskell.org/package/usb-0.1.0.1 regards, Bas From duncan.coutts at googlemail.com Thu Oct 1 15:23:31 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Oct 1 15:01:26 2009 Subject: [Haskell-cafe] c2hs, size_t, and CSize -- argh! In-Reply-To: References: <1254415032.7656.55.camel@localhost> Message-ID: <1254425011.7656.172.camel@localhost> On Thu, 2009-10-01 at 13:00 -0400, John Van Enk wrote: > Hi Duncan, > > Yes, I forgot to leave out that I'd like to see 'size_t' mapped to > CSize. > > As a (dirty) workaround, one can use 'castPtr' as the marshaler when > dealing with pointers to 'size_t'. I'm a little more concerned about > FunPtr's (though 'castPtr' still makes the issue go away). > > Here's my specific case dealing with function pointers: Ohhh, if you're dealing with pointers to CSize then it's easy, c2hs supports that directly. See the c2hs user guide section on the pointer hook. {# pointer *size_t as CSizePtr -> CSize #} This tells c2hs that when it sees a *size_t type in a function argument or result that it should be imported as Ptr CSize. It generates a type alias and uses that when it imports functions eg: {# pointer *size_t as CSizePtr -> CSize #} foo :: Ptr CSize -> IO () foo = {# call foo as raw_foo #} generates: type CSizePtr = Ptr (CSize) foo :: Ptr CSize -> IO () foo = raw_foo foreign import ccall safe "foo.chs.h foo" raw_foo :: CSizePtr -> IO () Duncan From vanenkj at gmail.com Thu Oct 1 15:28:35 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Oct 1 15:06:27 2009 Subject: [Haskell-cafe] c2hs, size_t, and CSize -- argh! In-Reply-To: <1254425011.7656.172.camel@localhost> References: <1254415032.7656.55.camel@localhost> <1254425011.7656.172.camel@localhost> Message-ID: > > Ohhh, if you're dealing with pointers to CSize then it's easy, c2hs > supports that directly. See the c2hs user guide section on the pointer > hook. > > {# pointer *size_t as CSizePtr -> CSize #} > > I seriously should have thought of that. I have #pointer's everywhere, but I didn't think to do it with that. Thanks. /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/fdaebc22/attachment.html From byorgey at seas.upenn.edu Thu Oct 1 15:44:04 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu Oct 1 15:21:56 2009 Subject: [Haskell-cafe] New TMR editor In-Reply-To: References: Message-ID: <20091001194404.GA15114@seas.upenn.edu> On Thu, Oct 01, 2009 at 04:33:43PM +0200, Wouter Swierstra wrote: > Dear all, > > After several years at the helm, I've decided to step down as editor of the > Monad.Reader. > > I am happy to announce that Brent Yorgey will take over my role as editor. > I'd like to take this opportunity to thank Brent for helping to keep the > Monad.Reader alive. I'm sure he'll do a fantastic job. > > Finally, I'd like to thank all the people who have contributed to the > Monad.Reader over the last few years ? you guys have made this > publication, and my job as an editor, so much fun. And let me be the first to thank Wouter for the outstanding job he's done as editor! I think he deserves much thanks for consistently putting together such a high-quality publication. I look forward to continuing the tradition of excellence -- and I hope YOU, the author of an upcoming Monad.Reader article, do too! I'll be sending out a call for copy for the next issue soon. -Brent From jfredett at gmail.com Thu Oct 1 15:48:11 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Oct 1 15:26:05 2009 Subject: [Haskell-cafe] New TMR editor In-Reply-To: <20091001194404.GA15114@seas.upenn.edu> References: <20091001194404.GA15114@seas.upenn.edu> Message-ID: Ah-- so _that's_ why you stopped doing HWN. Moving on to Greener Pastures... :) Congrats Brent! On Oct 1, 2009, at 3:44 PM, Brent Yorgey wrote: > On Thu, Oct 01, 2009 at 04:33:43PM +0200, Wouter Swierstra wrote: >> Dear all, >> >> After several years at the helm, I've decided to step down as >> editor of the >> Monad.Reader. >> >> I am happy to announce that Brent Yorgey will take over my role as >> editor. >> I'd like to take this opportunity to thank Brent for helping to >> keep the >> Monad.Reader alive. I'm sure he'll do a fantastic job. >> >> Finally, I'd like to thank all the people who have contributed to the >> Monad.Reader over the last few years ? you guys have made this >> publication, and my job as an editor, so much fun. > > And let me be the first to thank Wouter for the outstanding job he's > done as editor! I think he deserves much thanks for consistently > putting together such a high-quality publication. > > I look forward to continuing the tradition of excellence -- and I hope > YOU, the author of an upcoming Monad.Reader article, do too! I'll be > sending out a call for copy for the next issue soon. > > -Brent > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gwern0 at gmail.com Thu Oct 1 15:53:36 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Oct 1 15:31:29 2009 Subject: [Haskell-cafe] New TMR editor In-Reply-To: References: <20091001194404.GA15114@seas.upenn.edu> Message-ID: On Thu, Oct 1, 2009 at 3:48 PM, Joe Fredette wrote: > Ah-- so _that's_ why you stopped doing HWN. Moving on to Greener Pastures... At least, less-frequently-released pastures! -- gwern From aeyakovenko at gmail.com Thu Oct 1 16:02:28 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Thu Oct 1 15:40:19 2009 Subject: [Haskell-cafe] Re: a boring parser In-Reply-To: References: Message-ID: so whats pretty cool is that I can traverse arbitrary data structures as well: data Tree a = Tree (Tree a) a (Tree a) | Bottom deriving Show left a = do make $ \ st -> do case(st) of (Bottom) -> eos (Tree left val right) -> case (a < val) of True -> return $ (val, left) False -> noMatch right a = do make $ \ st -> do case(st) of (Bottom) -> eos (Tree left val right) -> case (a > val) of True -> return $ (val, right) False -> noMatch eqT a = do make $ \ st -> do case(st) of (Bottom) -> eos (Tree _ val _) -> case (a == val) of True -> return $ (val, st) False -> noMatch search a = manyTill (left a <|> right a) (eqT a) > run (search 5) $ Tree (Tree Bottom 1 Bottom) 3 (Tree Bottom 5 Bottom) Right (([3],5),Tree Bottom 5 Bottom) On Wed, Sep 30, 2009 at 8:04 PM, Anatoly Yakovenko wrote: > i got annoyed with Parsec and wrote a much more boring parser which > allows me to parse anything with any kind of matching i want. ?Its > basically a combination of State and Error monads. > > So i can use a grep like parser that matches via a regular expression > over a list of lines > > grep re = do > ? vv::B.ByteString <- any > ? let (_,_,_,rv) = (vv =~ > re)::(B.ByteString,B.ByteString,B.ByteString,[B.ByteString]) > ? case (rv) of > ? ? ?[] -> throwError "no match" > ? ? ?_ -> return $ rv > >> run (grep $ C.pack "(hello)") $ [C.pack "hello world"] > Right (["hello"],[]) > > or use the same library to scan over a string by combining regular expressions > > regex re = do > ? make $ \ st -> do > ? ? ?case (B.null st) of > ? ? ? ? True -> throwError "eos" > ? ? ? ? _ -> do > ? ? ? ? ? ?let (_,_,after,rv) = (st =~ > re)::(B.ByteString,B.ByteString,B.ByteString,[B.ByteString]) > ? ? ? ? ? ?case (rv) of > ? ? ? ? ? ? ? [] -> throwError "no match" > ? ? ? ? ? ? ? _ -> return $ (rv,after) > > > >> ?run (do aa <- regex $ C.pack "(hello)"; bb <- regex $ C.pack " (world)"; return (aa,bb) ) $ C.pack "hello world" > Right ((["hello"],["world"]),"") > > or simply match integers in a list, or anything that is of type Eq > >> run (many1 $ eq 1) [1,1,1,2,3,4] > Right ([1,1,1],[2,3,4]) > > i can define lt > > lt cc = do > ? vv <- any > ? case (vv < cc) of > ? ? ?True -> return $ vv > ? ? ?_ -> throwError "no match" > > and do > >> run (many1 $ lt 5 <|> eq 5) [1..10] > Right ([1,2,3,4,5],[6,7,8,9,10]) > > here is the implementation > > module Parser( ParserM ? ? --type alias for the parser ParserM a b is > over "stream" a and returns b > ? ? ? ? ? ? , make ? ? ? ?--makes a parser from a matching function of > type :: stream -> m (match_data,stream) > ? ? ? ? ? ? ? ? ? ? ? ? ? --for example any is implemented via: > ? ? ? ? ? ? ? ? ? ? ? ? ? --any :: ParserM [a] a > ? ? ? ? ? ? ? ? ? ? ? ? ? --any = make $ \ ll -> > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? case (ll) of > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? ? ? ? (hh:tt) -> return $ (hh,tt) > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? ? ? ? ? ? ? _ -> throwError "eos > ? ? ? ? ? ? ? ? ? ? ? ? ? --matches and returns an element from a > list, which makes any of type :: ParserM [a] a > ? ? ? ? ? ? , any ? ? ? ? --matches any element from [a] type stream > ? ? ? ? ? ? , eq ? ? ? ? ?--matches an equal element from [Eq] stream, > trivialy implemented in terms of any > ? ? ? ? ? ? ? ? ? ? ? ? ? --eq :: Eq a => a -> ParserM [a] a > ? ? ? ? ? ? ? ? ? ? ? ? ? --eq cc = do > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? vv <- any > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? case (vv == cc) of > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? ? ?True -> return $ vv > ? ? ? ? ? ? ? ? ? ? ? ? ? -- ? ? ? ? _ -> throwError "no match > ? ? ? ? ? ? , (<|>) ? ? ? --or operator, tries the left one then the right one > ? ? ? ? ? ? , manyTill ? ?--collects the results of parser 1 until > parser 2 succeeds > ? ? ? ? ? ? , many1 ? ? ? --collects the results of the parser, must > succeed at least once > ? ? ? ? ? ? , many ? ? ? ?--collects the results of a parser > ? ? ? ? ? ? , run ? ? ? ? --runs the parser > ? ? ? ? ? ? ) where > > import Control.Monad.State.Lazy > import Control.Monad.Error > import Test.QuickCheck > import Control.Monad.Identity > import Prelude hiding (any) > > type ParserM a c = StateT a (ErrorT [Char] Identity) c > > make pp = do > ? st <- get > ? (rv,nst) <- pp $ st > ? put $ nst > ? return $ rv > > aa <|> bb = aa `catchError` \ _ -> bb > > manyTill :: ParserM a c -> ParserM a d -> ParserM a ([c],d) > manyTill pp ee = do > ? do dd <- ee > ? ? ?return $ ([],dd) > ? `catchError` \ _ -> do > ? ? ?cc <- pp > ? ? ?(ccs,dd) <- manyTill pp ee > ? ? ?return $ (cc:ccs,dd) > > many1 pp = do > ? rv <- pp > ? rest <- many1 pp `catchError` \ _ -> return $ [] > ? return $ rv : rest > > many pp = do many1 pp > ? ? ? ? <|> return [] > > > any :: ParserM [a] a > any = make $ \ ll -> > ? case (ll) of > ? ? ?(hh:tt) -> return $ (hh,tt) > ? ? ?_ -> throwError "eos" > > eq :: Eq a => a -> ParserM [a] a > eq cc = do > ? vv <- any > ? case (vv == cc) of > ? ? ?True -> return $ vv > ? ? ?_ -> throwError "no match" > > lt cc = do > ? vv <- any > ? case (vv < cc) of > ? ? ?True -> return $ vv > ? ? ?_ -> throwError "no match" > > run pp dd = runIdentity $ runErrorT $ runStateT pp dd > run' = flip run > > > prop_MatchA = (Right ('a',"bc")) == (run' "abc" $ eq 'a') > prop_MatchEOS = (Left "eos") == (run' "" ?$ eq 'a') > prop_MatchNoMatch = (Left "no match") == (run' ("bcd") $ eq 'a') > > prop_MatchABC =(Right ('c',""))== (run' "abc" $ do ?eq 'a' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?eq 'b' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?eq 'c') > > prop_MatchA_C = (run' "abc" $ do eq 'a' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? eq 'd' <|> eq 'b' <|> any > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? eq 'c') == (Right ('c',"")) > > prop_Or = ? ? ?(run' "abc" $ do { eq 'a' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?; do ? ? { eq 'b' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ; eq 'd' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<|> do { eq 'b' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ; eq 'c' > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}) == (Right ('c',"")) > > prop_UntilC = (Right (("",'c'),"")) == (run' ("c") $ manyTill any $ eq 'c') > > prop_Until1 ls = > ? let rv = run' (ls ++ [1]) $ manyTill any $ eq 1 > ? in case (rv) of > ? ? ?Right ((ls,1),rest) -> (elem 1 ls) == False > ? ? ?_ -> False > > prop_all1 ls = > ? let rv = run' ([1,1,1] ++ ls) $ many1 $ eq 1 > ? in case (rv) of > ? ? ?Right (_,(1:_)) -> False > ? ? ?Right ((1:1:1:_),_) -> True > ? ? ?_ -> False > From vandijk.roel at gmail.com Thu Oct 1 16:06:31 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Oct 1 15:44:23 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: usb-0.1 In-Reply-To: References: <4AC4B672.9000000@van.steenbergen.nl> <4AC4BB25.7060401@van.steenbergen.nl> <1254409674.7656.41.camel@localhost> Message-ID: > In a short while, the package 'ls-usb' will be released. I've just uploaded usb-id-database-0.4 and ls-usb-0.1: http://hackage.haskell.org/package/usb-id-database-0.4 http://hackage.haskell.org/package/ls-usb-0.1 The utility ls-usb uses the usb package to detect all USB devices connected to you system. It then displays them in a nice list. It behaves very much like the existing utility lsusb and is meant more as an example of using the usb package then as an actual program. Be sure to run with elevated privileges if you want detailed information. Regards, Roel From stircrazynemo at hotmail.com Thu Oct 1 16:13:29 2009 From: stircrazynemo at hotmail.com (ShawnShawn) Date: Thu Oct 1 15:51:25 2009 Subject: [Haskell-cafe] parsing error Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: assi3.lhs Type: application/octet-stream Size: 7928 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/3e79e2e5/assi3-0001.obj From agocorona at gmail.com Thu Oct 1 17:24:20 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Oct 1 17:02:11 2009 Subject: Fwd: [Haskell-cafe] Can this be done? In-Reply-To: References: Message-ID: You can do it almost transparently with the Workflow package:: http://hackage.haskell.org/package/Workflow 2009/2/11 Cristiano Paris On Wed, Feb 11, 2009 at 2:30 PM, Peter Verswyvelen > wrote: > > I haven't looked at the details, but I think this is what a library like > > Reactive from Conal Elliott could do, but as far as I understand it, it > is > > still work in progress. > > I'm interested in the possibility of > stopping/pickling/unpickling/resuming a computation. > > Cristiano > _______________________________________________ > 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/20091001/fda427c8/attachment.html From inforichland at gmail.com Thu Oct 1 18:01:15 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Thu Oct 1 17:39:07 2009 Subject: [Haskell-cafe] Can this be done? In-Reply-To: References: Message-ID: <4335a3260910011501p1842a756gd2a64eab44ed26bd@mail.gmail.com> I was poking around once trying to find something like that and stumbled across this: http://wiki.cs.pdx.edu/forge/riviera.html Cheers, Tim On Wed, Feb 11, 2009 at 8:22 AM, Cristiano Paris wrote: > I wonder whether this can be done in Haskell (see muleherd's comment): > > > http://www.reddit.com/r/programming/comments/7wi7s/how_continuationbased_web_frameworks_work/ > > Cristiano > _______________________________________________ > 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/20091001/d5d9c1d7/attachment.html From gue.schmidt at web.de Thu Oct 1 18:02:22 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Oct 1 17:40:35 2009 Subject: [Haskell-cafe] DSL and GUI Toolkits Message-ID: Hi, I managed to abstract parts of the business logic of my application by employing a very naive DSL and it actually worked quite well. I'll probably replace that with a "Finally Tagless" version, just for the sake of it. But now I'd really try to abstract the hard part, the GUI logic. I had been switching back and forth between wxHaskell and Gtk and eventually settled for wxHaskell. And my gui code is a huge mess, it works, for now, but it'd be hell if I even had to change the tiniest bit. So I'm wondering if I could go the same way as with (parts) of the business logic, using a DSL here too. Now I could do with some input on the merits of this approach. G?nther From ok at cs.otago.ac.nz Thu Oct 1 18:09:58 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Oct 1 17:47:55 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC46011.4090203@btinternet.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> Message-ID: On Oct 1, 2009, at 8:53 PM, Andrew Coppin wrote: > > Sure. But what is a computer program? It depends on the computer. Classical machines do one thing, data flow machines do another, reduction machines another. I once saw a tiny machine at a UK university where the hardware was a combinator reduction gadget. It wasn't combinators on top of conventional instructions, the hardware did nothing _but_ combinators. A computer program, in short, is *whatever we want it to be*. (Within reasonable limits.) From ok at cs.otago.ac.nz Thu Oct 1 18:14:03 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Oct 1 17:51:58 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <4AC467C4.4070303@btinternet.com> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> Message-ID: <7B92392B-26B9-4760-A79F-DD87EAA2DECA@cs.otago.ac.nz> On Oct 1, 2009, at 9:26 PM, Andrew Coppin wrote: > It might be a better argument to say that human thinking is > fundamentally sequential; parallel computers have been around for a > little while now... You've never been talking on the phone while stirring a pot with one hand and wiping down a child with the other? You've never read (part of) a book while watching a TV program and been able to summarize both afterwards? You've never played the piano while talking about something else? Human *verbalisation* is fundamental, human *thinking* is not. (It's not unboundedly parallel either.) From ok at cs.otago.ac.nz Thu Oct 1 18:28:15 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Oct 1 18:06:12 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <7B92392B-26B9-4760-A79F-DD87EAA2DECA@cs.otago.ac.nz> References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> <7B92392B-26B9-4760-A79F-DD87EAA2DECA@cs.otago.ac.nz> Message-ID: On Oct 2, 2009, at 11:14 AM, Richard O'Keefe wrote: > > Human *verbalisation* is fundamental, human *thinking* is not. Sigh. Accidentally lean on the wrong key and half your text disappears. Human *verbalisation* is fundamentally sequential. Human *thinking* is not. I don't know any sign language myself, but I am aware that since people have faces and two hands, there is a limited amount of concurrency in some sign languages. (E.g., you can give place and manner at the same time.) From haskell at colquitt.org Thu Oct 1 19:20:24 2009 From: haskell at colquitt.org (John Dorsey) Date: Thu Oct 1 18:58:15 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: <4AC30978.8060707@btinternet.com> <7b501d5c0909300126o3f7a86a8o99fd099aeb2f50ac@mail.gmail.com> <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> Message-ID: <20091001232024.GB8837@colquitt.org> Andrew Coppin said: >> Sure. But what is a computer program? then Richard O'Keefe said: > A computer program, in short, is *whatever we want it to be*. > (Within reasonable limits.) I agree with Richard's conclusion. >From where I sit, the critical point is that, unless you're breadboarding, programming is working in the abstract, and we choose our abstractions. There's a strong tradition of sequential imperative programming, but that's as far as it goes. John From gregorypropf at yahoo.com Thu Oct 1 19:22:15 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Thu Oct 1 19:00:07 2009 Subject: [Haskell-cafe] Introspection on types. Message-ID: <283327.75090.qm@web112220.mail.gq1.yahoo.com> Is there a way to tell, let's say, how many constructors there are for a type?? Or do I need one of the haskell extensions I've read about? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/23d0423d/attachment.html From derek.a.elkins at gmail.com Thu Oct 1 19:43:59 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Oct 1 19:21:49 2009 Subject: [Haskell-cafe] Introspection on types. In-Reply-To: <283327.75090.qm@web112220.mail.gq1.yahoo.com> References: <283327.75090.qm@web112220.mail.gq1.yahoo.com> Message-ID: <61f84eff0910011643v2a12b01ap6643ecf5c6ce2cc3@mail.gmail.com> On Thu, Oct 1, 2009 at 6:22 PM, Gregory Propf wrote: > > Is there a way to tell, let's say, how many constructors there are for a type?? Or do I need one of the haskell extensions I've read about? Use Data.Data and derive Data for the types you are interested in or instance it for pre-existing types that aren't already instances. Introspection is tedious but trivial. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Data.html From allbery at ece.cmu.edu Thu Oct 1 21:14:25 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Oct 1 20:52:40 2009 Subject: [Haskell-cafe] Introspection on types. In-Reply-To: <283327.75090.qm@web112220.mail.gq1.yahoo.com> References: <283327.75090.qm@web112220.mail.gq1.yahoo.com> Message-ID: <76B9F91D-E4C9-4CAB-A2D3-C6F648D4DCBB@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/d347c3f0/PGP.bin From garious at gmail.com Thu Oct 1 21:31:45 2009 From: garious at gmail.com (Greg Fitzgerald) Date: Thu Oct 1 21:09:56 2009 Subject: [Haskell-cafe] Re: a boring parser In-Reply-To: References: Message-ID: <1f3dc80d0910011831x78522583nfe294964a3214203@mail.gmail.com> Cool, I like how this parser can model the "Look, an Eagle" scenario. For reference: http://www.youtube.com/watch?v=pjh3e198pUQ The parser can "change focus" (that is, change traversal strategy) in response to a successful parse. In the "Look, an Eagle" scenario, the bear is able to interpret and respond to its input serially and interactively, but when the bear's input stream is replaced by a new one, the man is able to capture the prize. -Greg On Thu, Oct 1, 2009 at 1:02 PM, Anatoly Yakovenko wrote: > so whats pretty cool is that I can traverse arbitrary data structures as > well: > > data Tree a = Tree (Tree a) a (Tree a) | Bottom > deriving Show > > left a = do > make $ \ st -> do > case(st) of > (Bottom) -> eos > (Tree left val right) -> > case (a < val) of > True -> return $ (val, left) > False -> noMatch > > right a = do > make $ \ st -> do > case(st) of > (Bottom) -> eos > (Tree left val right) -> > case (a > val) of > True -> return $ (val, right) > False -> noMatch > > eqT a = do > make $ \ st -> do > case(st) of > (Bottom) -> eos > (Tree _ val _) -> > case (a == val) of > True -> return $ (val, st) > False -> noMatch > > search a = manyTill (left a <|> right a) (eqT a) > > > run (search 5) $ Tree (Tree Bottom 1 Bottom) 3 (Tree Bottom 5 Bottom) > Right (([3],5),Tree Bottom 5 Bottom) > > > > On Wed, Sep 30, 2009 at 8:04 PM, Anatoly Yakovenko > wrote: > > i got annoyed with Parsec and wrote a much more boring parser which > > allows me to parse anything with any kind of matching i want. Its > > basically a combination of State and Error monads. > > > > So i can use a grep like parser that matches via a regular expression > > over a list of lines > > > > grep re = do > > vv::B.ByteString <- any > > let (_,_,_,rv) = (vv =~ > > re)::(B.ByteString,B.ByteString,B.ByteString,[B.ByteString]) > > case (rv) of > > [] -> throwError "no match" > > _ -> return $ rv > > > >> run (grep $ C.pack "(hello)") $ [C.pack "hello world"] > > Right (["hello"],[]) > > > > or use the same library to scan over a string by combining regular > expressions > > > > regex re = do > > make $ \ st -> do > > case (B.null st) of > > True -> throwError "eos" > > _ -> do > > let (_,_,after,rv) = (st =~ > > re)::(B.ByteString,B.ByteString,B.ByteString,[B.ByteString]) > > case (rv) of > > [] -> throwError "no match" > > _ -> return $ (rv,after) > > > > > > > >> run (do aa <- regex $ C.pack "(hello)"; bb <- regex $ C.pack " > (world)"; return (aa,bb) ) $ C.pack "hello world" > > Right ((["hello"],["world"]),"") > > > > or simply match integers in a list, or anything that is of type Eq > > > >> run (many1 $ eq 1) [1,1,1,2,3,4] > > Right ([1,1,1],[2,3,4]) > > > > i can define lt > > > > lt cc = do > > vv <- any > > case (vv < cc) of > > True -> return $ vv > > _ -> throwError "no match" > > > > and do > > > >> run (many1 $ lt 5 <|> eq 5) [1..10] > > Right ([1,2,3,4,5],[6,7,8,9,10]) > > > > here is the implementation > > > > module Parser( ParserM --type alias for the parser ParserM a b is > > over "stream" a and returns b > > , make --makes a parser from a matching function of > > type :: stream -> m (match_data,stream) > > --for example any is implemented via: > > --any :: ParserM [a] a > > --any = make $ \ ll -> > > -- case (ll) of > > -- (hh:tt) -> return $ (hh,tt) > > -- _ -> throwError "eos > > --matches and returns an element from a > > list, which makes any of type :: ParserM [a] a > > , any --matches any element from [a] type stream > > , eq --matches an equal element from [Eq] stream, > > trivialy implemented in terms of any > > --eq :: Eq a => a -> ParserM [a] a > > --eq cc = do > > -- vv <- any > > -- case (vv == cc) of > > -- True -> return $ vv > > -- _ -> throwError "no match > > , (<|>) --or operator, tries the left one then the > right one > > , manyTill --collects the results of parser 1 until > > parser 2 succeeds > > , many1 --collects the results of the parser, must > > succeed at least once > > , many --collects the results of a parser > > , run --runs the parser > > ) where > > > > import Control.Monad.State.Lazy > > import Control.Monad.Error > > import Test.QuickCheck > > import Control.Monad.Identity > > import Prelude hiding (any) > > > > type ParserM a c = StateT a (ErrorT [Char] Identity) c > > > > make pp = do > > st <- get > > (rv,nst) <- pp $ st > > put $ nst > > return $ rv > > > > aa <|> bb = aa `catchError` \ _ -> bb > > > > manyTill :: ParserM a c -> ParserM a d -> ParserM a ([c],d) > > manyTill pp ee = do > > do dd <- ee > > return $ ([],dd) > > `catchError` \ _ -> do > > cc <- pp > > (ccs,dd) <- manyTill pp ee > > return $ (cc:ccs,dd) > > > > many1 pp = do > > rv <- pp > > rest <- many1 pp `catchError` \ _ -> return $ [] > > return $ rv : rest > > > > many pp = do many1 pp > > <|> return [] > > > > > > any :: ParserM [a] a > > any = make $ \ ll -> > > case (ll) of > > (hh:tt) -> return $ (hh,tt) > > _ -> throwError "eos" > > > > eq :: Eq a => a -> ParserM [a] a > > eq cc = do > > vv <- any > > case (vv == cc) of > > True -> return $ vv > > _ -> throwError "no match" > > > > lt cc = do > > vv <- any > > case (vv < cc) of > > True -> return $ vv > > _ -> throwError "no match" > > > > run pp dd = runIdentity $ runErrorT $ runStateT pp dd > > run' = flip run > > > > > > prop_MatchA = (Right ('a',"bc")) == (run' "abc" $ eq 'a') > > prop_MatchEOS = (Left "eos") == (run' "" $ eq 'a') > > prop_MatchNoMatch = (Left "no match") == (run' ("bcd") $ eq 'a') > > > > prop_MatchABC =(Right ('c',""))== (run' "abc" $ do eq 'a' > > eq 'b' > > eq 'c') > > > > prop_MatchA_C = (run' "abc" $ do eq 'a' > > eq 'd' <|> eq 'b' <|> any > > eq 'c') == (Right ('c',"")) > > > > prop_Or = (run' "abc" $ do { eq 'a' > > ; do { eq 'b' > > ; eq 'd' > > } > > <|> do { eq 'b' > > ; eq 'c' > > } > > }) == (Right ('c',"")) > > > > prop_UntilC = (Right (("",'c'),"")) == (run' ("c") $ manyTill any $ eq > 'c') > > > > prop_Until1 ls = > > let rv = run' (ls ++ [1]) $ manyTill any $ eq 1 > > in case (rv) of > > Right ((ls,1),rest) -> (elem 1 ls) == False > > _ -> False > > > > prop_all1 ls = > > let rv = run' ([1,1,1] ++ ls) $ many1 $ eq 1 > > in case (rv) of > > Right (_,(1:_)) -> False > > Right ((1:1:1:_),_) -> True > > _ -> False > > > _______________________________________________ > 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/20091001/c2eb1645/attachment.html From mxcantor at gmail.com Thu Oct 1 22:55:46 2009 From: mxcantor at gmail.com (Max Cantor) Date: Thu Oct 1 22:33:52 2009 Subject: [Haskell-cafe] FP Market Place (was Market Place for Haskell development teams?) In-Reply-To: <20091001155627.GB27880@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> Message-ID: <7C4EE277-6A51-4588-B5CC-E105610AE517@gmail.com> Haskell, and FP languages more broadly, are finding a pretty solid niche in small scale, but technically demanding and lucrative projects. Financial modeling and analytics are the first thing that comes to mind. The work of Galois, Atom, etc also sort of fit this mold. While the people on this list are clearly leaning towards Haskell, this is a niche that Haskell shares with OCaml, Erlang, and even Scala and Clojure. Perhaps, combining efforts with those communities (call it lambdajobs or something) would help get closer to a critical mass and aid cross-pollination between communities. Considering the salaries and value-add with skilled FP programmers, and the difficulty in finding them, this could even be a profitable venture in the long run if employers are charged for successful placements or for ads once we get going. Just my 2? Max On Oct 1, 2009, at 11:56 AM, Curt Sampson wrote: > On 2009-09-29 13:18 +0200 (Tue), Alberto G. Corona wrote: > >> What is the vehicle that haskell can use to enter the mainstream?. > > Actually, I have one more thought on that: wait. > > I'd had the impression that Haskell was becoming fairly well known (if > not yet heavily used, in comparison to languages like Java), but I > just > ran across some hard evidence for this. > > In the 32 languages ranked on http://www.langpop.com/ , Haskell > consistently comes down near the bottom in the various rankings of > use. (But hey, we're not so weird we're not in there!) But if you look > down near the bottom, at the chart labeled "Normalized Discussion Site > Results," you'll notice that Haskell comes out sixth. Even trying to > be > more fair to the mainstream, and changing the weighting to drop Lambda > the Ultimate completely (after all, they're just a bunch of academic > wankers, right?) and bring IRC down to a contribution of 0.5 instead > of > 1 (apparently those academic wankers have lots of time to chat > online), > Haskell still comes out tenth, with a score over a third that of the > leader, Java, and close to half that of PHP and C (2nd and 3rd place, > respectively). > > We've also got at least one undeniably good, production-quality > compiler > (which is more than PHP or Ruby can say), and have sold many tens of > thousands, perhaps even hundreds of thousands, of books. At this > point, > I don't think many people (John A. De Goes excepted) are looking at > people writing major applications in Haskell as if they're aliens > living > on another planet. > > Haskell is in the mainstream already as far as being taken seriously; > most of the complaints I'm seeing seem to be grasping at the same > kinds > of straws that the anti-Java guys were back in the late '90s. ("It's > hopeless if it uses garbage collection.") > > We've even got our own over-hyped, under-utilized supposed benefit > ("it's good for multicore"). > > The main whinging seems to be about libraries, of which we have "only" > 1585 on hackage. > > Compare with RubyForge, which has 2059 projects in "beta" or better > status, or 2961 if we include "alpha" as well. The Ruby Application > Archive has 1768 projects; I have no idea how much overlap there is, > or > how many of these are real. > > I think we just need to sit tight for a couple of years. > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jason.dusek at gmail.com Thu Oct 1 23:52:30 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Oct 1 23:30:20 2009 Subject: [Haskell-cafe] ANN: json-b-0.0.4 Message-ID: <42784f260910012052n1d7b466l98ab4860deb277f2@mail.gmail.com> This version fixes defective handling of empty objects and arrays. http://hackage.haskell.org/package/json-b-0.0.4 Thanks to Dmitry Astapov for this fix. -- Jason Dusek From kyagrd at gmail.com Fri Oct 2 00:12:10 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu Oct 1 23:49:25 2009 Subject: [Haskell-cafe] Re: Haskell for Physicists In-Reply-To: <20090930174257.GA29934@ymonad.members.linode.com> References: <20090930174257.GA29934@ymonad.members.linode.com> Message-ID: edgar@ymonad.com ? ?: > Hi, > > I will give a seminar to physicists at USP (Universidade de S?o Paulo, Brazil) university and they asked me for a good title, something that can attract physicists. Anyone has some suggestions? (Will be > a seminar about the use of Haskell to substitute C or Fortran > in a lot of tasks, and how it can be used in some problems instead of > Matlab, Mathematica, etc.) > > Thanks, > Edgar You should also see the well known Haskell story in this area: http://bayern.stanford.edu/~brant/lightning/ From gregorypropf at yahoo.com Fri Oct 2 02:07:39 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Fri Oct 2 01:45:30 2009 Subject: [Haskell-cafe] Introspection on types. In-Reply-To: <76B9F91D-E4C9-4CAB-A2D3-C6F648D4DCBB@ece.cmu.edu> Message-ID: <394016.26236.qm@web112208.mail.gq1.yahoo.com> Thanks, I'll check out Data and Typeable --- On Thu, 10/1/09, Brandon S. Allbery KF8NH wrote: From: Brandon S. Allbery KF8NH Subject: Re: [Haskell-cafe] Introspection on types. To: "Gregory Propf" Cc: "Brandon S. Allbery KF8NH" , "Haskell-Cafe" Date: Thursday, October 1, 2009, 6:14 PM On Oct 1, 2009, at 19:22 , Gregory Propf wrote:Is there a way to tell, let's say, how many constructors there are for a type?? Or do I need one of the haskell extensions I've read about? If the constructors are nullary (that is: ?data MyData = Foo | Bar | Baz) you could derive Enum and Bounded, then (maxBound :: MyData) is one less than the number of constructors. Anything more complicated requires deriving Data or Typeable (I've done it with the latter but don't recall details off the top of my head). --?brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.comsystem administrator [openafs,heimdal,too many hats] allbery@ece.cmu.eduelectrical and computer engineering, carnegie mellon university ? ?KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091002/40a27d52/attachment.html From tphyahoo at gmail.com Fri Oct 2 05:12:30 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Oct 2 04:50:22 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20091001155627.GB27880@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> Message-ID: <910ddf450910020212j409c5425y5c4cf4325565189e@mail.gmail.com> Hey, first of all, in terms of a platform for promoting haskell commercially, happstutorial.com actually implements a job board. Yeah, it's primitive and not feature complete, but on hackage, open source, and ready for anyone who would like to work on it. (Currently maintained by creighton hogg.) This was my baby in 2008, when I was looking to foster happs for web development, as a sort of "smarter" ruby on rails, which I am using in the field in patch-tag.com. 2, the haskell-startup google group at http://groups.google.com/group/haskell-startup It's private, to encourage slightly more courageous business talk away from the panoptic gaze of google, but I approve pretty much anyone who doesn't want in and isn't a bot. Yes. Let's create a world with more jobs for haskell developers, and better software for everyone :) thomas. 2009/10/1 Curt Sampson : > On 2009-09-29 13:18 +0200 (Tue), Alberto G. Corona ?wrote: > >> What is the vehicle that haskell can use to enter the mainstream?. > > Actually, I have one more thought on that: wait. > > I'd had the impression that Haskell was becoming fairly well known (if > not yet heavily used, in comparison to languages like Java), but I just > ran across some hard evidence for this. > > In the 32 languages ranked on http://www.langpop.com/ , Haskell > consistently comes down near the bottom in the various rankings of > use. (But hey, we're not so weird we're not in there!) But if you look > down near the bottom, at the chart labeled "Normalized Discussion Site > Results," you'll notice that Haskell comes out sixth. Even trying to be > more fair to the mainstream, and changing the weighting to drop Lambda > the Ultimate completely (after all, they're just a bunch of academic > wankers, right?) and bring IRC down to a contribution of 0.5 instead of > 1 (apparently those academic wankers have lots of time to chat online), > Haskell still comes out tenth, with a score over a third that of the > leader, Java, and close to half that of PHP and C (2nd and 3rd place, > respectively). > > We've also got at least one undeniably good, production-quality compiler > (which is more than PHP or Ruby can say), and have sold many tens of > thousands, perhaps even hundreds of thousands, of books. At this point, > I don't think many people (John A. De Goes excepted) are looking at > people writing major applications in Haskell as if they're aliens living > on another planet. > > Haskell is in the mainstream already as far as being taken seriously; > most of the complaints I'm seeing seem to be grasping at the same kinds > of straws that the anti-Java guys were back in the late '90s. ("It's > hopeless if it uses garbage collection.") > > We've even got our own over-hyped, under-utilized supposed benefit > ("it's good for multicore"). > > The main whinging seems to be about libraries, of which we have "only" > 1585 on hackage. > > Compare with RubyForge, which has 2059 projects in "beta" or better > status, or 2961 if we include "alpha" as well. The Ruby Application > Archive has 1768 projects; I have no idea how much overlap there is, or > how many of these are real. > > I think we just need to sit tight for a couple of years. > > cjs > -- > Curt Sampson ? ? ? ? ? ? ?+81 90 7737 2974 > ? ? ? ? ? Functional programming in all senses of the word: > ? ? ? ? ? ? ? ? ? http://www.starling-software.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tphyahoo at gmail.com Fri Oct 2 05:13:23 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Oct 2 04:51:13 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <910ddf450910020212j409c5425y5c4cf4325565189e@mail.gmail.com> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <910ddf450910020212j409c5425y5c4cf4325565189e@mail.gmail.com> Message-ID: <910ddf450910020213w1b84334dpc6d13a77a0a1b895@mail.gmail.com> correction, happstutorial is now tutorial.happstack.com. 2009/10/2 Thomas Hartman : > Hey, first of all, in terms of a platform for promoting haskell > commercially, happstutorial.com actually implements a job board. > > Yeah, it's primitive and not feature complete, but on hackage, open > source, and ready for anyone who would like to work on it. (Currently > maintained by creighton hogg.) > > This was my baby in 2008, when I was looking to foster happs for web > development, as a sort of "smarter" ruby on rails, which I am using in > the field in patch-tag.com. > > 2, the haskell-startup google group at > > http://groups.google.com/group/haskell-startup > > It's private, to encourage slightly more courageous business talk away > from the panoptic gaze of google, but I approve pretty much anyone who > doesn't want in and isn't a bot. > > Yes. Let's create a world with more jobs for haskell developers, and > better software for everyone :) > > thomas. > > > 2009/10/1 Curt Sampson : >> On 2009-09-29 13:18 +0200 (Tue), Alberto G. Corona ?wrote: >> >>> What is the vehicle that haskell can use to enter the mainstream?. >> >> Actually, I have one more thought on that: wait. >> >> I'd had the impression that Haskell was becoming fairly well known (if >> not yet heavily used, in comparison to languages like Java), but I just >> ran across some hard evidence for this. >> >> In the 32 languages ranked on http://www.langpop.com/ , Haskell >> consistently comes down near the bottom in the various rankings of >> use. (But hey, we're not so weird we're not in there!) But if you look >> down near the bottom, at the chart labeled "Normalized Discussion Site >> Results," you'll notice that Haskell comes out sixth. Even trying to be >> more fair to the mainstream, and changing the weighting to drop Lambda >> the Ultimate completely (after all, they're just a bunch of academic >> wankers, right?) and bring IRC down to a contribution of 0.5 instead of >> 1 (apparently those academic wankers have lots of time to chat online), >> Haskell still comes out tenth, with a score over a third that of the >> leader, Java, and close to half that of PHP and C (2nd and 3rd place, >> respectively). >> >> We've also got at least one undeniably good, production-quality compiler >> (which is more than PHP or Ruby can say), and have sold many tens of >> thousands, perhaps even hundreds of thousands, of books. At this point, >> I don't think many people (John A. De Goes excepted) are looking at >> people writing major applications in Haskell as if they're aliens living >> on another planet. >> >> Haskell is in the mainstream already as far as being taken seriously; >> most of the complaints I'm seeing seem to be grasping at the same kinds >> of straws that the anti-Java guys were back in the late '90s. ("It's >> hopeless if it uses garbage collection.") >> >> We've even got our own over-hyped, under-utilized supposed benefit >> ("it's good for multicore"). >> >> The main whinging seems to be about libraries, of which we have "only" >> 1585 on hackage. >> >> Compare with RubyForge, which has 2059 projects in "beta" or better >> status, or 2961 if we include "alpha" as well. The Ruby Application >> Archive has 1768 projects; I have no idea how much overlap there is, or >> how many of these are real. >> >> I think we just need to sit tight for a couple of years. >> >> cjs >> -- >> Curt Sampson ? ? ? ? ? ? ?+81 90 7737 2974 >> ? ? ? ? ? Functional programming in all senses of the word: >> ? ? ? ? ? ? ? ? ? http://www.starling-software.com >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From ivan.miljenovic at gmail.com Fri Oct 2 08:20:56 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri Oct 2 07:58:54 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph 0.5.2.0 Message-ID: <87ab0akmvr.fsf@gmail.com> Yes, this is yet another SourceGraph announcement, this time for version 0.5.2.0 [1]. [1] http://hackage.haskell.org/package/SourceGraph-0.5.2.0 The changes in this release are as follows: * Shift overall analysis to the top and per-module analysis to the end, as suggested by Duncan Coutts. * Graph drawing fixups: instances are now drawn correctly, and the module graph now has modules located in the correct directory. * Improve some graph drawing aspects (node margins, colours for module graphs, etc.). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From ramsdell0 at gmail.com Fri Oct 2 09:17:11 2009 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Fri Oct 2 08:55:01 2009 Subject: [Haskell-cafe] Haskell for Physicists In-Reply-To: <20090930174257.GA29934@ymonad.members.linode.com> References: <20090930174257.GA29934@ymonad.members.linode.com> Message-ID: <7687290b0910020617y24823a44s4ed066620f91dcf9@mail.gmail.com> "Haskell for closing the gap between specification and code" On Wed, Sep 30, 2009 at 1:42 PM, wrote: > Hi, > > I will give a seminar to physicists at USP (Universidade de S?o Paulo, Brazil) university and they asked me for a good title, something that can attract physicists. Anyone has some suggestions? (Will be > a seminar about the use of Haskell to substitute C or Fortran > in a lot of tasks, and how it can be used in some problems instead of > Matlab, Mathematica, etc.) > > Thanks, > Edgar > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From john at n-brain.net Fri Oct 2 10:54:31 2009 From: john at n-brain.net (John A. De Goes) Date: Fri Oct 2 10:32:29 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20091001061314.GF1315@analytic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> Message-ID: <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> On Oct 1, 2009, at 12:13 AM, Curt Sampson wrote: > And as far as something like dealing with a changing language and > libraries, the mainstream already has well-established and popular > techniques for doing just: agile development. A project manager's worst nightmare: "Sorry boss, but we're just not going to be able to meet that deadline, because, well, a language extension we were using was dropped from the language, and the syntax for some core operators was changed. Not only is our code broken, but many of the libraries we were using are broken. Don't worry, though, we're 'agile', so our unit tests will tell us when our code is working again." Big business demands stability. Regards, John From noteed at gmail.com Fri Oct 2 11:03:07 2009 From: noteed at gmail.com (minh thu) Date: Fri Oct 2 10:41:16 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> Message-ID: <40a414c20910020803u324ebd23h3beb997ede9d4ac3@mail.gmail.com> 2009/10/2 John A. De Goes : > On Oct 1, 2009, at 12:13 AM, Curt Sampson wrote: > >> And as far as something like dealing with a changing language and >> libraries, the mainstream already has well-established and popular >> techniques for doing just: agile development. > > A project manager's worst nightmare: > > "Sorry boss, but we're just not going to be able to meet that deadline, > because, well, a language extension we were using was dropped from the > language, and the syntax for some core operators was changed. Not only is > our code broken, but many of the libraries we were using are broken. Don't > worry, though, we're 'agile', so our unit tests will tell us when our code > is working again." > > Big business demands stability. Hi, Of course, the haskell community is that immature. People keep dropping extensions without a thought for potential problems. And the package versioning policy is just a joke written for next april fools day. Sorry for the spoiler. Cheers, Thu From john at n-brain.net Fri Oct 2 11:03:40 2009 From: john at n-brain.net (John A. De Goes) Date: Fri Oct 2 10:41:33 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20091001155627.GB27880@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> Message-ID: On Oct 1, 2009, at 9:56 AM, Curt Sampson wrote: > The main whinging seems to be about libraries, of which we have "only" > 1585 on hackage. It's not just about the _number_ of libraries, but the _usefulness_ of them for solving real-world problems. Haskell has a large number of libraries that are of no interest whatsoever to commercial software developers (new numerical hierarchies, category theory libraries, etc.), and is missing many key libraries that would be of great commercial value. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 From john at n-brain.net Fri Oct 2 11:04:54 2009 From: john at n-brain.net (John A. De Goes) Date: Fri Oct 2 10:42:47 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <40a414c20910020803u324ebd23h3beb997ede9d4ac3@mail.gmail.com> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> <40a414c20910020803u324ebd23h3beb997ede9d4ac3@mail.gmail.com> Message-ID: I'm not saying Haskell is unstable. I'm saying that the attitude expressed in the following quote is at odds with the needs of business: "And as far as something like dealing with a changing language and libraries, the mainstream already has well-established and popular techniques for doing just: agile development." Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 2, 2009, at 9:03 AM, minh thu wrote: > 2009/10/2 John A. De Goes : >> On Oct 1, 2009, at 12:13 AM, Curt Sampson wrote: >> >>> And as far as something like dealing with a changing language and >>> libraries, the mainstream already has well-established and popular >>> techniques for doing just: agile development. >> >> A project manager's worst nightmare: >> >> "Sorry boss, but we're just not going to be able to meet that >> deadline, >> because, well, a language extension we were using was dropped from >> the >> language, and the syntax for some core operators was changed. Not >> only is >> our code broken, but many of the libraries we were using are >> broken. Don't >> worry, though, we're 'agile', so our unit tests will tell us when >> our code >> is working again." >> >> Big business demands stability. > > Hi, > > Of course, the haskell community is that immature. People keep > dropping extensions without a thought for potential problems. And the > package versioning policy is just a joke written for next april fools > day. Sorry for the spoiler. > > Cheers, > Thu From vanenkj at gmail.com Fri Oct 2 11:40:07 2009 From: vanenkj at gmail.com (John Van Enk) Date: Fri Oct 2 11:17:56 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> Message-ID: > "Sorry boss, but we're just not going to be able to meet that deadline, > because, well, a language extension we were using was dropped from the > language, and the syntax for some core operators was changed. Not only is > our code broken, but many of the libraries we were using are broken. Don't > worry, though, we're 'agile', so our unit tests will tell us when our code > is working again." > > Big business demands stability. > > And yet they use IE... how many projects have I had to spend substantial time "fixing" because Microsoft releases a new IE... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091002/3ba928c8/attachment.html From Christian.Maeder at dfki.de Fri Oct 2 11:58:15 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Oct 2 11:36:09 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: SourceGraph 0.5.2.0 In-Reply-To: <87ab0akmvr.fsf@gmail.com> References: <87ab0akmvr.fsf@gmail.com> Message-ID: <4AC62317.7060900@dfki.de> Ivan Lazar Miljenovic wrote: > Yes, this is yet another SourceGraph announcement, this time for version > 0.5.2.0 [1]. > > [1] http://hackage.haskell.org/package/SourceGraph-0.5.2.0 installation went well, but I get a rather uninformative error message for 505 source files: cabal build: .... [505 of 505] Compiling Main SourceGraph: Parse error: Last statement in a do-block must be an expression Cheers Christian From gue.schmidt at web.de Fri Oct 2 13:13:11 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Fri Oct 2 12:53:02 2009 Subject: [Haskell-cafe] Designing a DSL? Message-ID: Hi, there are numerous examples on how to implement a DSL, but I haven't been able to figure out how to "design" one. I mean I have a pretty good idea of the problem domain, I've coded it over and over again until I got it right. Now I'd like to express that part as a DSL instead of "hard coding" it as before so I can be more prepared if I need to change or amend it. Ideally I'd only have to change the interpreter, right? And that I find to be the really tricky part, how do I *design* a DSL? G?nther From jake.mcarthur at gmail.com Fri Oct 2 14:37:19 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Fri Oct 2 14:15:06 2009 Subject: [Haskell-cafe] Designing a DSL? In-Reply-To: References: Message-ID: <4AC6485F.4050200@gmail.com> G?nther Schmidt wrote: > And that I find to be the really tricky part, how do I *design* a DSL? My favorite approach is something like as described in these: http://lukepalmer.wordpress.com/2008/07/18/semantic-design/ http://conal.net/papers/type-class-morphisms/ It takes a little bit of time to come up with great abstractions, but when you finally do it's an amazing feeling. - Jake From stephen.tetley at gmail.com Fri Oct 2 16:17:31 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri Oct 2 15:55:21 2009 Subject: [Haskell-cafe] Haskell for Physicists In-Reply-To: <20090930174257.GA29934@ymonad.members.linode.com> References: <20090930174257.GA29934@ymonad.members.linode.com> Message-ID: <5fdc56d70910021317y3385d852wb9471b29c2f12d32@mail.gmail.com> Hi Edgar No-one seems to have pointed you to the Maestro: http://users.info.unicaen.fr/~karczma/arpap/ The quantum mechanics one might be the most directly useful, but they are all great reads: http://users.info.unicaen.fr/~karczma/arpap/hasiqm.pdf Best wishes Stephen 2009/9/30 : > Hi, > > I will give a seminar to physicists at USP (Universidade de S?o Paulo, Brazil) university and they asked me for a good title, something that can attract physicists. Anyone has some suggestions? (Will be > a seminar about the use of Haskell to substitute C or Fortran > in a lot of tasks, and how it can be used in some problems instead of > Matlab, Mathematica, etc.) > > Thanks, > Edgar > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ben.franksen at online.de Fri Oct 2 16:20:34 2009 From: ben.franksen at online.de (Ben Franksen) Date: Fri Oct 2 15:58:39 2009 Subject: [Haskell-cafe] Re: Cal, Clojure, Groovy, Haskell, OCaml, etc. References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: Hong Yang wrote: > Good libraries are not enough for a language to go beyond mere existence. > There must exist good documents, i.e., good tutorials, good books, and > good explanations and examples in the libraries, etc, that are easy for > people to learn and use. In my humble opinion, Haskell has a lot of > libraries, but most of them offer few examples of how to use the modules. > In this regards, Perl is much much better. I wouldn't say 'better' as many, if not most, Perl libraries offer not much beyond example usage as documentation. Even if they do, the docs are often ambiguous, corner cases left to the user's imagination -- which is (at least in my case) regularly different from the library author's -- etc. IMO this is just the other extreme of the spectrum. It sure gets you started quite cheaply, but in the long run you pay an ugly amount of interest as you spend more and more time with debugging due to said ambiguities and corner cases. BTW, apparently, Perl library authors like to model their APIs after their mother language Perl itself, of which one could justly say that its only exact definition /is/ its implementation. Which doesn't mean that documentation of many Haskell libs couldn't be greatly improved... Cheers Ben From robgreayer at gmail.com Fri Oct 2 17:04:18 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Fri Oct 2 16:42:08 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20090929153550.GG24761@analytic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> Message-ID: <4ec472cb0910021404i7eebe43escfc278f5b156daf1@mail.gmail.com> Fairly late to the party on this discussion, but this captured my attention: On Tue, Sep 29, 2009 at 11:35 AM, Curt Sampson wrote: > > This may be somewhat anecdotal evidence, but I disagree with both > of your statements here. I've rarely known anybody to use Java > cross-platform in a non-trival way, barring a few major GUI-centric > projects such as Eclipse. (I've far more cross-platform use of Haskell > than Java myself.) And I know of nobody who did anything serious with > download-execution of Java. > > I agree with the download/execution part of this, but I'd be willing to bet that it is incredibly common for Java developers to write and test code in an environment very different from the actual deployment environment. With Java, it requires no special forethought to write an application on a Windows or Mac laptop, be able to run all the unit tests, etc., locally, and then deploy the production application to a Linux or Solaris or *nix server (or a combination) without any required recompilation. This is a pretty powerful selling point for the JVM as a target platform, and everywhere I've seen Java used, it's been taken advantage of. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091002/eeda27c5/attachment.html From ekmett at gmail.com Fri Oct 2 18:46:12 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Oct 2 18:24:01 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> Message-ID: <7fb8f82f0910021546n183f1f63ga6e7befbd7b38a69@mail.gmail.com> On Fri, Oct 2, 2009 at 10:54 AM, John A. De Goes wrote: > On Oct 1, 2009, at 12:13 AM, Curt Sampson wrote: > > And as far as something like dealing with a changing language and >> libraries, the mainstream already has well-established and popular >> techniques for doing just: agile development. >> > > A project manager's worst nightmare: > > "Sorry boss, but we're just not going to be able to meet that deadline, > because, well, a language extension we were using was dropped from the > language, and the syntax for some core operators was changed. Not only is > our code broken, but many of the libraries we were using are broken. Don't > worry, though, we're 'agile', so our unit tests will tell us when our code > is working again." > While I agree that it probably isn't the right idea to say that we are Agile, so it is safe for us to build on a foundation that is constantly shifting underneath us, this same argument came up from Credit Suisse regarding the standardization of Haskell' at ICFP 06. At the time, as I recall, they were limiting themselves to Haskell 98 + Addenda. I argued that they should be interesting in having _more_ such standardization efforts to bring into the fold more features that they can rely upon. Even so, Haskell' includes only one breaking change (dropping n+k patterns) at this time and really how often do language features get dropped from GHC? (And at the time even the n+k change was laughed at by the audience as a joke proposal, not one that anyone was serious about -- how times have changed). There have been a couple of quirky changes in how big scary types involving scoped type variables change. Otherwise it has been far more stable and consistent over the last 11 year run than any non-toy compiler that *I* can think of. Heck, think how different your C compiler is now than it was in 1999. It feels, to me that there are more breaking changes in just upgrading to, say, C99 than there have been over the entire post-Haskell 98 life of GHC. -Edward Kmett Big business demands stability. > > Regards, > > John > > > > _______________________________________________ > 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/20091002/495bc8be/attachment.html From gcross at phys.washington.edu Fri Oct 2 19:08:49 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Fri Oct 2 18:46:40 2009 Subject: [Haskell-cafe] Mutable data within a (non-IO) monad Message-ID: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> Hey everyone, I am thinking about creating a particular data structure with an immutable and mutable version. The key of my problem is that I would like the user to be able to work with a mutable version of the data within a non-IO monad and then get an immutable value at the end, allowing them to do stateful-like computation in pure code. The key is that I need to enforce the ordering within the monad, but I can't do this using a state-transformer since the state doesn't actually change; instead, the data structure is internally modified, but the original pointer is kept to it. There are many data structures which already have this kind of functionality, such as STRefs and MArrays, however I am having trouble distilling from the source code what the best "trick" is to accomplish mutability of this form within a monad. There seem to be at least a couple of strategies: using "type-threading" with GHC's State# type, and using the ST monad with a rank-2 qualifier over the type of the state. Do you all have any thoughts on ways to solve this problem, and/or a high-level explanation of what is going behind the scenes with STRefs and MArrays? Thanks! - Greg From ivan.miljenovic at gmail.com Fri Oct 2 19:56:07 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri Oct 2 19:34:04 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: SourceGraph 0.5.2.0 In-Reply-To: <4AC62317.7060900@dfki.de> (Christian Maeder's message of "Fri, 02 Oct 2009 17:58:15 +0200") References: <87ab0akmvr.fsf@gmail.com> <4AC62317.7060900@dfki.de> Message-ID: <87r5tlnyeg.fsf@gmail.com> Christian Maeder writes: > Ivan Lazar Miljenovic wrote: > installation went well, but I get a rather uninformative error message > for 505 source files: > > cabal build: > .... > [505 of 505] Compiling Main :o There is no way that there's 505 source files in SourceGraph... and I just did a clean install of SourceGraph and it works fine :s > > SourceGraph: Parse error: Last statement in a do-block must be an expression > This is a parse error from haskell-src-exts. Are you sure that your code is valid? -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From allbery at ece.cmu.edu Fri Oct 2 22:39:39 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 2 22:17:44 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <7fb8f82f0910021546n183f1f63ga6e7befbd7b38a69@mail.gmail.com> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> <7fb8f82f0910021546n183f1f63ga6e7befbd7b38a69@mail.gmail.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091002/dedc30d5/PGP.bin From gcross at phys.washington.edu Fri Oct 2 23:00:48 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Fri Oct 2 22:38:52 2009 Subject: [Haskell-cafe] Mutable data within a (non-IO) monad In-Reply-To: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> References: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> Message-ID: <0F2425EC-11BE-4235-977A-5A180F7F85A9@phys.washington.edu> Sorry to reply to my own posting, but... AHA! I see now what's going on. The purpose of the rank-2 qualifier is to prevent STRefs from leaking outside of the runST call, and what the code does at the lowest level is that it passes around a token "state" object to force the compiler to correctly order the calculations. Very cool. :-) Cheers, Greg On Oct 2, 2009, at 4:08 PM, Gregory Crosswhite wrote: > Hey everyone, > > I am thinking about creating a particular data structure with an > immutable and mutable version. The key of my problem is that I > would like the user to be able to work with a mutable version of the > data within a non-IO monad and then get an immutable value at the > end, allowing them to do stateful-like computation in pure code. > The key is that I need to enforce the ordering within the monad, but > I can't do this using a state-transformer since the state doesn't > actually change; instead, the data structure is internally > modified, but the original pointer is kept to it. > > There are many data structures which already have this kind of > functionality, such as STRefs and MArrays, however I am having > trouble distilling from the source code what the best "trick" is to > accomplish mutability of this form within a monad. There seem to be > at least a couple of strategies: using "type-threading" with GHC's > State# type, and using the ST monad with a rank-2 qualifier over the > type of the state. > > Do you all have any thoughts on ways to solve this problem, and/or a > high-level explanation of what is going behind the scenes with > STRefs and MArrays? > > Thanks! > > - Greg > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at googlemail.com Sat Oct 3 04:57:25 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sat Oct 3 04:35:16 2009 Subject: [Haskell-cafe] Mutable data within a (non-IO) monad In-Reply-To: <0F2425EC-11BE-4235-977A-5A180F7F85A9@phys.washington.edu> References: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> <0F2425EC-11BE-4235-977A-5A180F7F85A9@phys.washington.edu> Message-ID: <1254560245.5687.48.camel@localhost> On Fri, 2009-10-02 at 20:00 -0700, Gregory Crosswhite wrote: > Sorry to reply to my own posting, but... AHA! I see now what's going > on. The purpose of the rank-2 qualifier is to prevent STRefs from > leaking outside of the runST call, and what the code does at the > lowest level is that it passes around a token "state" object to force > the compiler to correctly order the calculations. Very cool. :-) Yep, you got it. If you like the details of this sort of thing there's a paper on it "Lazy Functional State Threads" by John Launchbury and Simon Peyton Jones. The lazy part can also let you do almost magical things. See for example Lennart Augustsson's Mersenne twister code: http://www.augustsson.net/Darcs/MT/MersenneTwister.hs It does all the work using a mutable ST array but the final output is a lazy list of random numbers. mersenneTwister :: Word32 -> [Word32] Internally, each time you demand the next random number, it is mutating the internal ST array. So you get the combination of the mutable state updates and nice lazy results. No 'unsafeBlah' in sight! Duncan From apfelmus at quantentunnel.de Sat Oct 3 05:39:17 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sat Oct 3 05:17:25 2009 Subject: [Haskell-cafe] Re: Designing a DSL? In-Reply-To: References: Message-ID: G?nther Schmidt wrote: > there are numerous examples on how to implement a DSL, but I haven't > been able to figure out how to "design" one. > > I mean I have a pretty good idea of the problem domain, I've coded it > over and over again until I got it right. Now I'd like to express that > part as a DSL instead of "hard coding" it as before so I can be more > prepared if I need to change or amend it. Ideally I'd only have to > change the interpreter, right? > > And that I find to be the really tricky part, how do I *design* a DSL? Since every well-designed DSL is, by definition, a unique experience, it's hard to answer that question in general. I think that designing DSLs in Haskell is best learned from the following classic papers John Hughes. The Design of a Pretty-printing Library. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.8777 Philip Wadler. A prettier printer. http://homepages.inf.ed.ac.uk/wadler/topics/ language-design.html#prettier Richard Bird. A program to solve Sudoku Slides: http://icfp06.cs.uchicago.edu/bird-talk.pdf Paper: http://cs.tufts.decenturl.com/richard-bird-sudoku Simon Peyton Jones, Jean-Marc Eber, Julian Seward. Composing contracts: an adventure in financial engineering. http://research.microsoft.decenturl.com/composing-contracts and Hudak's book Paul Hudak. The Haskell School of Expression. http://www.haskell.org/soe/ The main principle is probably best summarized as: think long and hard to make it as simple and beautiful as possible. Regards, apfelmus -- http://apfelmus.nfshost.com From lemming at henning-thielemann.de Sat Oct 3 06:11:28 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Oct 3 05:49:26 2009 Subject: [Haskell-cafe] Mutable data within a (non-IO) monad In-Reply-To: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> References: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> Message-ID: On Fri, 2 Oct 2009, Gregory Crosswhite wrote: > Do you all have any thoughts on ways to solve this problem, and/or a > high-level explanation of what is going behind the scenes with STRefs and > MArrays? http://www.haskell.org/haskellwiki/Monad/ST From alexey.skladnoy at gmail.com Sat Oct 3 07:23:41 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sat Oct 3 07:04:43 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists In-Reply-To: References: <20090930174257.GA29934@ymonad.members.linode.com> Message-ID: <200910031523.41359.alexey.skladnoy@gmail.com> ? ????????? ?? 30 ???????? 2009 23:42:57 Casey Hawthorne ???????: > On Wed, 30 Sep 2009 21:24:11 +0200, you wrote: > >I?m a physicist, so I think they would be attracted by something like > > > >Haskell: high level physics modelling at Fortran speeds > > > >Haskell: mathematics beyond numerical calculus > > And, > easier to make use of multi-core machines than threaded Fortran. > Yes this is good selling point. Fortran (and C++ too) programs heavily rely on global state. And thus are very difficult to parallelize. Frequently only possibility is process-level parallelism. This however has problems too. > I suppose one could have a Haskell parser convert Fortran to monadal > code. > > Then, a parser to convert, hopefully, most of the resulting code to > pure code. > This is interesting but very challenging task. Conversion fortran-> monadic code is trade of one mess for another. Since local state and global state are ubiquitous it's difficult to factor out pure functions. Another problem is that fortran functions are usually BIG. Most likely this will require manual intervention. From jfredett at gmail.com Sat Oct 3 12:46:25 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Oct 3 12:24:12 2009 Subject: [Haskell-cafe] Haskell Weekly News Message-ID: <4ac77fe1.9753f10a.4fc4.1044@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20091003 Issue 134 - October 03, 2009 --------------------------------------------------------------------------- Welcome to issue 134 of HWN, a newsletter covering developments in the [1]Haskell community. I have a nasty sinus infection this week, so we're somewhat light on content. Lots of good discussion about DSL related stuff this week. Bryan O'Sullivan also release 'Criterion' this week, a new benchmarking library that Don Stewart described (on reddit) as 'awesome and game changing.' A new TMR editor -- someone familiar -- was announced. Also, there was some talk about homework policies on the mailinglists and in the irc channels. There is a [2]page on the Haskell wiki about this, but to sum it up in a maxim, remember, 'Help, don't do'. Until next week, the Haskell Weekly News! Announcements New TMR editor. Wouter Swierstra [3]announced that he would be stepping down from the editorship of 'The Monad Reader', with former HWN editor Brent Yorgey taking his place. Much thanks for Wouter's hard work and good luck to Brent on his new editor job! SourceGraph 0.5.{0,1,2}.0. Ivan Lazar Miljenovic [4]announced three new releases of the SourceGraph packages, this links to the latest release. json-b-0.0.4. Jason Dusek [5]announced a new version of the json-b package, which fixes defective handling of empty objects and arrays. rss2irc 0.4 released. Simon Michael [6]announced a new release of rss2irc, with many new improvements and features. vty-ui 0.1. Jonathan Daugherty [7]announced vty-ui, which is an extensible library of user interface widgets for composing and laying out Vty user interfaces. atom-0.1.1. Tom Hawkins [8]announced Atom, a Haskell DSL for designing hard real-time embedded applications. Graphalyze-0.7.0.0. Ivan Lazar Miljenovic [9]announced (in an apparent effort to take over hackage by submitting dozens of quality packages at absurdly high speed), Graphalyze, a library for using graph-theoretic techniques to analyse the relationships inherent within discrete data. Criterion. Bryan O'Sullivan [10]announced (without tacking on an 'ANN' tag, I might add, I almost missed it!) Criterion, a benchmarking library he describes [11]here. ListTree 0.1. yairchu@gmail.com [12]announced ListTree, a package for combinatorial search and pruning of trees. usb-0.1. Bas van Dijk [13]announced a library for interacting with usb modules from userspace. (Deadline extended to October 5th) APLAS 2009 Call for Posters. Kiminori Matsuzaki [14]announced a deadline extension to the call for posters for the APLAS conference. graphviz-2999.6.0.0. Ivan Lazar Miljenovic [15]announced a new version of the graphviz library, which features various new features and small changes. Discussion Testing polymorphic properties with QuickCheck. Jean-Philippe Bernardy [16]gave an excellent overview about how to use QuickCheck to test polymorphic properties. Designing a DSL? Gunther Schmidt [17]asked about different methods employed for designing a DSL. DSL and GUI Toolkits. Gunther Schmidt [18]also asked about different DSLs for working with GUIs error on "--++ bla bla bla". Hong Yang [19]asked about why '--++' wasn't being parsed in the way he thought it was. Haskell for Physicists. edgar [20]requested name suggestions for the talk he is giving about Physics and Haskell. Blog noise [21]Haskell news from the [22]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Sean Leather: [23]'Extensibility and type safety in formatting: the design of xformat' at the Dutch HUG. * Martijn van Steenbergen: [24]let 5 = 6. * Lee Pike: [25]Writer's unblock. * Manuel M T Chakravarty: [26]NVIDIAs next generation GPU architecture has a lot for HPC to love. * David Amos: [27]Finite geometries, part 4: Lines in PG(n,Fq). * Bryan O'Sullivan: [28]New criterion release works on Macs. * Neil Brown: [29]Poison: Concurrent Termination. * The GHC Team: [30]Heads up: what you need to know about Unicode I/O in GHC 6.12.1. * Galois, Inc: [31]Tech Talk: Roll Your Own Test Bed for Embedded Real-Time Protocols: A Haskell Experience. * Bryan O'Sullivan: [32]Criterion, a new benchmarking library for Haskell. * Tom Schrijvers: [33]Monadic Constraint Programming. * Neil Brown: [34]Growing Sort Pump. Quotes of the Week * dekudekuplex: (Unfortunately (unless intentional)) the preceding (by ksf (in the 'Quotes of the Week' section)) quote had mismatched (one too many opening) parentheses (although it was still funny (even though it could have been edited (to make the parentheses match (even though that is not an important issue)))). * pozic: I think if you want to contact dons, you have to say that you found a bug in ByteString. * Veinor: [about dibblego kicking a whole bunch of spammers] crouching dibblego, hidden op * allbery_b: [on UndecidableInstances] 'this exceeds my easy threshold, turn on wizard mode' (at which point it becomes a lot smarter but may start contemplating its navel without warning) * byorgey: a bus error? try recompiling with -fsubway, perhaps * jafet: 'Zygomorphism' sounds like a reproductive disorder About the Haskell Weekly News New editions are posted to [35]the Haskell mailing list as well as to [36]the Haskell Sequence and [37]Planet Haskell. [38]RSS is also available, and headlines appear on [39]haskell.org. To help create new editions of this newsletter, please see the information on [40]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [41]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://www.haskell.org/haskellwiki/Homework_help 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64213 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64259 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64254 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63838 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64070 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64035 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63989 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63985 11. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63853 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64206 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17529 15. http://article.gmane.org/gmane.comp.lang.haskell.general/17520 16. http://thread.gmane.org/gmane.comp.lang.haskell.general/17535 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64267 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64244 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64161 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64128 21. http://planet.haskell.org/ 22. http://haskell.org/haskellwiki/Blog_articles 23. http://feedproxy.google.com/~r/splonderzoek/~3/BHqNHIZFF7U/extensibility-and-type-safety-in.html 24. http://martijn.van.steenbergen.nl/journal/2009/10/02/let-5-6/ 25. http://leepike.wordpress.com/2009/09/30/writers-unblock/ 26. http://justtesting.org/post/201508784 27. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-4-lines-in-pgnfq.html 28. http://www.serpentine.com/blog/2009/09/30/new-criterion-release-works-on-macs/ 29. http://chplib.wordpress.com/2009/09/30/poison-concurrent-termination/ 30. http://ghcmutterings.wordpress.com/2009/09/30/heads-up-what-you-need-to-know-about-unicode-io-in-ghc-6-12-1/ 31. http://www.galois.com/blog/2009/09/29/pike-haskell0/ 32. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ 33. http://tomschrijvers.blogspot.com/2009/01/monadic-constraint-programming.html 34. http://chplib.wordpress.com/2009/09/28/growing-sort-pump/ 35. http://www.haskell.org/mailman/listinfo/haskell 36. http://sequence.complete.org/ 37. http://planet.haskell.org/ 38. http://sequence.complete.org/node/feed 39. http://haskell.org/ 40. http://haskell.org/haskellwiki/HWN 41. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From del_31416no at hotmail.com Sat Oct 3 14:17:03 2009 From: del_31416no at hotmail.com (=?Windows-1252?B?TWFy7WEgTGF1cmE=?=) Date: Sat Oct 3 13:54:50 2009 Subject: [Haskell-cafe] Alex problem, help needed!!!!!!!!! ASAP :) Message-ID: Dear list, I am trying to make a compiler and we are having a hard time getting Alex to work. We have succeded to work out Alex using older version, but with the the 2.2 version we keep getting this error and we havent been able to figure it out. So this is our tokens definition: { module Lexico where import Alex } %wrapper "posn" $digit = 0-9 -- digits $alpha = [a-zA-Z] -- alphabetic characters tokens :- $white+ ; --Los espacios en blanco los omito \/\/.* ; --Lo que venga despu?s de dos barras omito \/\*.*\*\/ ; --Lo que est? entre las barras de comentario omito $digit+ { \p s -> TokenEntero p (read s) } \' [$alpha $digit \_]* \' { \p s -> TokenString p (read s)} [$digit]+\.[$digit]+ { \p s -> TokenDouble p (read s) } $alpha [$alpha $digit \_]* { \p s -> TokenVar p (read s) } And when we call the alexScanTokens "hello" we get this error: [TokenVar (AlexPn 0 1 1) "*** Exception: Prelude.read: no parse So we are concerned about the "TokenVar p (read s)" . Would that be the way to read a string? We just get this error with TokenVar and TokenString, whenever we call the function like: alexScanTokens 19 , for instance we dont get any problems and the token 19 is recognized ok. Please, any ideas on what am i doing wrong???????? regards, L _________________________________________________________________ Keep your friends updated?even when you?re not signed in. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091003/718ae79c/attachment.html From dons at galois.com Sat Oct 3 14:22:50 2009 From: dons at galois.com (Don Stewart) Date: Sat Oct 3 14:00:42 2009 Subject: [Haskell-cafe] Alex problem, help needed!!!!!!!!! ASAP :) In-Reply-To: References: Message-ID: <20091003182250.GB6559@whirlpool.galois.com> del_31416no: > Dear list, > > I am trying to make a compiler and we are having a hard time getting Alex to > work. We have succeded to work out Alex using older version, but with the the > 2.2 version we keep getting this error and we havent been able to figure it > out. > > So this is our tokens definition: > > { > module Lexico where > import Alex > } > > %wrapper "posn" > > $digit = 0-9 -- digits > $alpha = [a-zA-Z] -- alphabetic characters > > tokens :- > > $white+ ; --Los espacios en blanco los omito > \/\/.* ; --Lo que venga despu s de dos barras > omito > \/\*.*\*\/ ; --Lo que est entre las barras de > comentario omito > $digit+ { \p s -> TokenEntero p (read s) } > \' [$alpha $digit \_]* \' { \p s -> TokenString p (read s)} > [$digit]+\.[$digit]+ { \p s -> TokenDouble p (read s) } > $alpha [$alpha $digit \_]* { \p s -> TokenVar p (read s) } > > > And when we call the alexScanTokens "hello" we get this error: > > [TokenVar (AlexPn 0 1 1) "*** Exception: Prelude.read: no parse > > So we are concerned about the "TokenVar p (read s)" . Would that be the way to > read a string? Use readMaybe rather than read, and check the error. maybeRead :: Read a => String -> Just a maybeRead s = case reads s of [(x, s')] | all isSpace s' -> Just x _ -> Nothing From dpiponi at gmail.com Sat Oct 3 16:02:20 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Sat Oct 3 15:40:06 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists In-Reply-To: <200910031523.41359.alexey.skladnoy@gmail.com> References: <20090930174257.GA29934@ymonad.members.linode.com> <200910031523.41359.alexey.skladnoy@gmail.com> Message-ID: <625b74080910031302p63640663ne021a7c3baf1e02a@mail.gmail.com> Yesterday I was at a talk by Pat Hanrahan on embedded DSLs and GPUs at the nvidia GPU conference: http://www.nvidia.com/object/gpu_technology_conference.html Pat argued that the only way forward to achieve usable computing power for physics on heterogeneous computers (eg. multicore+GPU) is through the use of embedded DSLs to allow physicists to express algorithms without reference to underlying architecture, or even details like data structures. His main example involved using Scala to generate C code for scramjet simulation (ie. we're not talking toy simulations here). He actually mentioned Haskell at one point. I strongly agree with Pat. Unfortunately I can't find slides, or many details of the project, online. It seems to me that Haskell is both an excellent host language for embedding small languages and is also a particularly good language for expressing algorithms for code generation. I think this should be the #1 selling point for Haskell for physicists. The only point I vaguely disagreed with was that Pat seemed to think that dynamic types were essential. For the types of problems he was describing it seemed to me that static types were precisely what you needed. -- Dan On Sat, Oct 3, 2009 at 4:23 AM, Khudyakov Alexey wrote: > ? ????????? ?? 30 ???????? 2009 23:42:57 Casey Hawthorne ???????: >> On Wed, 30 Sep 2009 21:24:11 +0200, you wrote: >> >I?m a physicist, so I think they would be attracted by something like >> > >> >Haskell: high level physics modelling ?at ?Fortran speeds >> > >> >Haskell: mathematics beyond numerical calculus >> >> And, >> easier to make use of multi-core machines than threaded Fortran. >> > Yes this is good selling point. Fortran (and C++ too) programs heavily rely on > global state. And thus are very difficult to parallelize. Frequently only > possibility is process-level parallelism. This however has problems too. > > >> I suppose one could have a Haskell parser convert Fortran to monadal >> code. >> >> Then, a parser to convert, hopefully, most of the resulting code to >> pure code. >> > This is interesting but very challenging task. Conversion fortran-> monadic > code is trade of one mess for another. Since local state and global state are > ubiquitous it's difficult to factor out pure functions. Another problem is that > fortran functions are usually BIG. > > Most likely this will require manual intervention. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Sat Oct 3 16:55:26 2009 From: dons at galois.com (Don Stewart) Date: Sat Oct 3 16:33:15 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists In-Reply-To: <625b74080910031302p63640663ne021a7c3baf1e02a@mail.gmail.com> References: <20090930174257.GA29934@ymonad.members.linode.com> <200910031523.41359.alexey.skladnoy@gmail.com> <625b74080910031302p63640663ne021a7c3baf1e02a@mail.gmail.com> Message-ID: <20091003205526.GB7192@whirlpool.galois.com> And note we are pushing precisely on the use of DSLs in or on Haskell for *portability* of the domain-scientists code in a number of areas right now: * data parallel algorithms (targetting cpu , gpu) Accelerate: http://hackage.haskell.org/package/accelerate-0.6.0.0 Obsidian http://www.cse.chalmers.se/~joels/writing/dccpaper_obsidian.pdf * control systems code: Atom: http://hackage.haskell.org/package/atom * cryptography Cryptol: http://www.galois.com/technology/communications_security/cryptol * avionics verification: http://www.galois.com/blog/2009/05/15/edsls-for-unmanned-autonomous-verification-and-validation/ * financial modelling Paradise: http://www.londonhug.net/2008/08/11/video-paradise-a-dsel-for-derivatives-pricing/ FPF: http://lambda-the-ultimate.org/node/3331 * operating systems: http://www.barrelfish.org/fof_plos09.pdf In all cases we're looking at high level code, the possibility of multiple backends, and constrained semantics enabling extensive optimization and analysis. And -- we're generating code, so there's no benefit to having the language hosted on the JVM or .NET -- Haskell should *own* this space. This may be Haskell's killer app now that DSLs are going mainstream. We have mature technology for good DSLs. Far more resources than Scala. Why isn't Haskell completely dominating this space? I believe it is lack of training and outreach. We need a "Write you a DSL for great good!" -- Don dpiponi: > Yesterday I was at a talk by Pat Hanrahan on embedded DSLs and GPUs at > the nvidia GPU conference: > http://www.nvidia.com/object/gpu_technology_conference.html > > Pat argued that the only way forward to achieve usable computing power > for physics on heterogeneous computers (eg. multicore+GPU) is through > the use of embedded DSLs to allow physicists to express algorithms > without reference to underlying architecture, or even details like > data structures. From dons at galois.com Sat Oct 3 17:10:31 2009 From: dons at galois.com (Don Stewart) Date: Sat Oct 3 16:48:20 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists In-Reply-To: <20091003205526.GB7192@whirlpool.galois.com> References: <20090930174257.GA29934@ymonad.members.linode.com> <200910031523.41359.alexey.skladnoy@gmail.com> <625b74080910031302p63640663ne021a7c3baf1e02a@mail.gmail.com> <20091003205526.GB7192@whirlpool.galois.com> Message-ID: <20091003211031.GD7192@whirlpool.galois.com> dons: > And note we are pushing precisely on the use of DSLs in or on Haskell > for *portability* of the domain-scientists code in a number of areas > right now: > > * data parallel algorithms (targetting cpu , gpu) > Accelerate: > http://hackage.haskell.org/package/accelerate-0.6.0.0 > Obsidian > http://www.cse.chalmers.se/~joels/writing/dccpaper_obsidian.pdf Another good example: Cell DSL, for Maple users: A Domain-Specific Language for the Generation of Optimized SIMD-Parallel Assembly Code http://www.cas.mcmaster.ca/~kahl/Publications/TR/Anand-Kahl-2007a_DSL/ "a domain-specific language embedded into Haskell that allows mathematicians to formulate novel high-performance SIMD-parallel algorithms for the evaluation of special functions. " -- Don From niklas.broberg at gmail.com Sat Oct 3 17:07:24 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Oct 3 16:53:18 2009 Subject: [Haskell-cafe] Alex problem, help needed!!!!!!!!! ASAP :) In-Reply-To: References: Message-ID: > $digit+???????????????????????????????? { \p s -> TokenEntero p (read s) } > \' [$alpha $digit \_]* \'??????????? { \p s -> TokenString p (read s)} > [$digit]+\.[$digit]+???????????????? { \p s -> TokenDouble p (read s) } > $alpha [$alpha $digit \_]*????????{ \p s -> TokenVar p (read s) } You are using 'read' in slightly strange ways here. What read does is to take a string of characters that supposedly represents a value of some type, and tries to create a value of said type from the string. On the first and third lines you read a sequence of digits to an integer resp double, which is fine, the strings you pass to 'read' are representations of integers and doubles resp. On the second line you're trying to read something of the form 'hello', i.e. surrounded by single-quotes, as a Haskell String. But this doesn't represent a Haskell String, which is what 'read' expects. Haskell Strings have double-quotes, so there will be no proper 'read', if you want single-quotes you need to define your own function to do the conversion (hint: init . tail). On the last line, which is the one giving you the error here, you're again trying to 'read' a string of characters into a String. And again, Haskell Strings are surrounded by double-quotes, so 'read' will not find a representation. This time the fix is even simpler. :-) Prelude> read "hello" :: String "*** Exception: Prelude.read: no parse Prelude> read "\"hello\"" :: String "hello" Cheers, /Niklas From mwotton at gmail.com Sat Oct 3 23:08:49 2009 From: mwotton at gmail.com (Mark Wotton) Date: Sat Oct 3 22:46:43 2009 Subject: [Haskell-cafe] killer app sought Message-ID: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> Hi, I've been writing a little binding from Ruby to Haskell called Hubris (http://github.com/mwotton/Hubris ) which I think has some potential both for making Haskell web apps easier to write, and also for bringing the more adventurous Ruby programmers into the Haskell community. Code-wise it's coming along nicely, and once 6.12 is out it'll run without modifications at least on Linux (remains to be seen how long it'll take to get the Mac patches into shape). My real problem is marketing: I need a killer app that shows it's easy either to 1. wrap a kickarse Haskell library in a convenient Ruby web app shell 2. speed up a poorly performing Ruby web app I've been badgering the Ruby guys in Sydney that I know on the second point, but either none of them have performance problems, or none of them want to admit it. The first is entirely possible - if you only attack the subset of problems where your runtime is dominated by the database and network latency, language performance is moot. Conversely, if that's your worldview, the other problems that could be attacked won't ever come to mind (to monstrously abuse the Sapir-Whorf hypothesis). So, I'm asking you guys. What are some really nice Haskell libraries or apps that could benefit from being shown off in one of the plethora of slick, mature web frameworks that exist in Ruby? Manuel Chakravarty suggested something with vector operations in order to take advantage of his 'accelerate' library (once it gets a GPU backend, of course), and more generally, something taking advantage of Haskell's support for multicore would be cool. (The standard edition of Ruby is still unicore, I believe.) Parenthetically yours, Mark From keithshep at gmail.com Sun Oct 4 01:08:02 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sun Oct 4 00:45:48 2009 Subject: [Haskell-cafe] killer app sought In-Reply-To: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> References: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> Message-ID: <92e42b740910032208m5890ed62qe4269d813500f256@mail.gmail.com> I think having access to the parsec library would be a major plus that you can show off. Eg: you can have a RoR based email web app that uses parsec parsing to figure out which sections of an email thread belong to which author... Best -Keith On Sat, Oct 3, 2009 at 11:08 PM, Mark Wotton wrote: > Hi, > > I've been writing a little binding from Ruby to Haskell called Hubris > (http://github.com/mwotton/Hubris) which I think has some potential both for > making Haskell web apps easier to write, and also for bringing the more > adventurous Ruby programmers into the Haskell community. Code-wise it's > coming along nicely, and once 6.12 is out it'll run without modifications at > least on Linux (remains to be seen how long it'll take to get the Mac > patches into shape). My real problem is marketing: I need a killer app that > shows it's easy either to > > 1. wrap a kickarse Haskell library in a convenient Ruby web app shell > 2. speed up a poorly performing Ruby web app > > I've been badgering the Ruby guys in Sydney that I know on the second point, > but either none of them have performance problems, or none of them want to > admit it. The first is entirely possible - if you only attack the subset of > problems where your runtime is dominated by the database and network > latency, language performance is moot. Conversely, if that's your worldview, > the other problems that could be attacked won't ever come to mind (to > monstrously abuse the Sapir-Whorf hypothesis). > > So, I'm asking you guys. What are some really nice Haskell libraries or apps > that could benefit from being shown off in one of the plethora of slick, > mature web frameworks that exist in Ruby? Manuel Chakravarty suggested > something with vector operations in order to take advantage of his > 'accelerate' library (once it gets a GPU backend, of course), and more > generally, something taking advantage of Haskell's support for multicore > would be cool. (The standard edition of Ruby is still unicore, I believe.) > > Parenthetically yours, > Mark > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- keithsheppard.name From james at neurogami.com Sun Oct 4 01:22:55 2009 From: james at neurogami.com (James Britt) Date: Sun Oct 4 01:00:52 2009 Subject: [Haskell-cafe] killer app sought In-Reply-To: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> References: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> Message-ID: <4AC8312F.6010101@neurogami.com> Mark Wotton wrote: > Hi, > > I've been writing a little binding from Ruby to Haskell called Hubris > (http://github.com/mwotton/Hubris) which I think has some potential both > for making Haskell web apps easier to write, and also for bringing the > more adventurous Ruby programmers into the Haskell community. Code-wise > it's coming along nicely, and once 6.12 is out it'll run without > modifications at least on Linux (remains to be seen how long it'll take > to get the Mac patches into shape). My real problem is marketing: I need > a killer app that shows it's easy either to > > 1. wrap a kickarse Haskell library in a convenient Ruby web app shell > 2. speed up a poorly performing Ruby web app > > I've been badgering the Ruby guys in Sydney that I know on the second > point, but either none of them have performance problems, or none of > them want to admit it. Yeah, that can happen with some Rubyists. ;) > The first is entirely possible - if you only > attack the subset of problems where your runtime is dominated by the > database and network latency, language performance is moot. Conversely, > if that's your worldview, the other problems that could be attacked > won't ever come to mind (to monstrously abuse the Sapir-Whorf hypothesis). > > So, I'm asking you guys. What are some really nice Haskell libraries or > apps that could benefit from being shown off in one of the plethora of > slick, mature web frameworks that exist in Ruby? Manuel Chakravarty > suggested something with vector operations in order to take advantage of > his 'accelerate' library (once it gets a GPU backend, of course), and > more generally, something taking advantage of Haskell's support for > multicore would be cool. (The standard edition of Ruby is still unicore, > I believe.) I've been trying to think of a nice back-end app to run via a Ramaze Web front end, to combine the best of Ruby Web dev with the speed and elegance of Haskell. As mentioned, something that demonstrated multi-core-ability out of the box would be sweet. Some thoughts came to mind on image or audio manipulation, though details escape me. Or maybe text analysis. Showing that using Haskell is faster than using Ruby would be nice, but unimpressive, insomuch as people can already do that with C. So, a good example might also play off of the benefit of writing in Haskell instead of C. James Britt -- Neurogami - Smart application development http://www.neurogami.com james@neurogami.com From mwotton at gmail.com Sun Oct 4 01:55:16 2009 From: mwotton at gmail.com (Mark Wotton) Date: Sun Oct 4 01:33:07 2009 Subject: [Haskell-cafe] killer app sought In-Reply-To: <4AC8312F.6010101@neurogami.com> References: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> <4AC8312F.6010101@neurogami.com> Message-ID: On 04/10/2009, at 4:22 PM, James Britt wrote: > Mark Wotton wrote: > > > So, I'm asking you guys. What are some really nice Haskell > libraries or > > apps that could benefit from being shown off in one of the > plethora of > > slick, mature web frameworks that exist in Ruby? Manuel Chakravarty > > suggested something with vector operations in order to take > advantage of > > his 'accelerate' library (once it gets a GPU backend, of course), > and > > more generally, something taking advantage of Haskell's support for > > multicore would be cool. (The standard edition of Ruby is still > unicore, > > I believe.) > > I've been trying to think of a nice back-end app to run via a Ramaze > Web front end, to combine the best of Ruby Web dev with the speed > and elegance of Haskell. As mentioned, something that demonstrated > multi-core-ability out of the box would be sweet. > > Some thoughts came to mind on image or audio manipulation, though > details escape me. Or maybe text analysis. > > Showing that using Haskell is faster than using Ruby would be nice, > but unimpressive, insomuch as people can already do that with C. > So, a good example might also play off of the benefit of writing in > Haskell instead of C. The interesting thing is speed _and_ safety, I guess. although writing fast C on multicore is arguably harder than in Haskell. The Parsec suggestion is interesting, but from the outside, it wouldn't seem significantly different to doing it in C. Maybe if you could specify your own grammars from outside? Hm. Mark From Christian.Maeder at dfki.de Sun Oct 4 05:26:44 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Sun Oct 4 05:04:29 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: SourceGraph 0.5.2.0 In-Reply-To: <87r5tlnyeg.fsf@gmail.com> References: <87ab0akmvr.fsf@gmail.com> <4AC62317.7060900@dfki.de> <87r5tlnyeg.fsf@gmail.com> Message-ID: <4AC86A54.4040006@dfki.de> Ivan Lazar Miljenovic wrote: > Christian Maeder writes: > >> Ivan Lazar Miljenovic wrote: >> installation went well, but I get a rather uninformative error message >> for 505 source files: >> >> cabal build: >> .... >> [505 of 505] Compiling Main > > :o > > There is no way that there's 505 source files in SourceGraph... and I > just did a clean install of SourceGraph and it works fine :s > >> SourceGraph: Parse error: Last statement in a do-block must be an expression >> > > This is a parse error from haskell-src-exts. Are you sure that your > code is valid? My code (505 source files) is valid, as I wanted to indicate above. (I did count SourceGraph source files.) Does SourceGraph maybe pick up more source files than transitively imported from a top-level module? Christian From ivan.miljenovic at gmail.com Sun Oct 4 05:47:15 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sun Oct 4 05:25:04 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: SourceGraph 0.5.2.0 In-Reply-To: <4AC86A54.4040006@dfki.de> (Christian Maeder's message of "Sun, 04 Oct 2009 11:26:44 +0200") References: <87ab0akmvr.fsf@gmail.com> <4AC62317.7060900@dfki.de> <87r5tlnyeg.fsf@gmail.com> <4AC86A54.4040006@dfki.de> Message-ID: <878wfrxzh8.fsf@gmail.com> Christian Maeder writes: > > My code (505 source files) is valid, as I wanted to indicate above. (I > did count SourceGraph source files.) Ahhh, OK. > Does SourceGraph maybe pick up more source files than transitively > imported from a top-level module? At the moment, yes... it find all files with .hs and .lhs extensions (with the exception of Setup.[l]hs, HLint.hs, _darcs/ and dist/). On the whole, SourceGraph is rather "dumb" at the moment. In future I plan on using only files listed in the .cabal file unless otherwise indicated, etc. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From mpm at alumni.caltech.edu Sun Oct 4 05:52:54 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sun Oct 4 05:30:40 2009 Subject: [Haskell-cafe] better way to do this? Message-ID: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> I'm looking for a hint to write the following code with less redundancy. I have a constructor called BoxBounds, and I want to make one with random values. randomBox :: IO BoxBounds randomBox = do x <- getStdRandom (randomR (-10,10)) y <- getStdRandom (randomR (-70,70)) t <- getStdRandom (randomR (5,10)) b <- getStdRandom (randomR (5,10)) l <- getStdRandom (randomR (5,10)) r <- getStdRandom (randomR (5,10)) return (BoxBounds x y l r t b) From ekirpichov at gmail.com Sun Oct 4 05:55:11 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun Oct 4 05:32:55 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> Message-ID: <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...] return (BoxBounds ...) 2009/10/4 Michael Mossey : > I'm looking for a hint to write the following code with less redundancy. I > have a constructor called BoxBounds, and I want to make one with random > values. > > randomBox :: IO BoxBounds > randomBox = do > ?x <- getStdRandom (randomR (-10,10)) > ?y <- getStdRandom (randomR (-70,70)) > ?t <- getStdRandom (randomR (5,10)) > ?b <- getStdRandom (randomR (5,10)) > ?l <- getStdRandom (randomR (5,10)) > ?r <- getStdRandom (randomR (5,10)) > ?return (BoxBounds x y l r t b) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From felipe.lessa at gmail.com Sun Oct 4 07:27:04 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Oct 4 07:04:53 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> Message-ID: <20091004112704.GA26944@kira.casa> On Sun, Oct 04, 2009 at 01:55:11PM +0400, Eugene Kirpichov wrote: > [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...] > return (BoxBounds ...) import Control.Applicative let f = getStdRandom . randomR g1 = \x -> f (-x,x) g2 = f (5,10) in BoxBounds <$> g1 10 <*> g1 70 <*> g2 <*> g2 <*> g2 <*> g2 -- Felipe. From duncan.coutts at googlemail.com Sun Oct 4 07:52:51 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sun Oct 4 07:30:35 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> Message-ID: <1254657171.5687.88.camel@localhost> On Sun, 2009-10-04 at 02:52 -0700, Michael Mossey wrote: > I'm looking for a hint to write the following code with less redundancy. I > have a constructor called BoxBounds, and I want to make one with random > values. > > randomBox :: IO BoxBounds > randomBox = do > x <- getStdRandom (randomR (-10,10)) > y <- getStdRandom (randomR (-70,70)) > t <- getStdRandom (randomR (5,10)) > b <- getStdRandom (randomR (5,10)) > l <- getStdRandom (randomR (5,10)) > r <- getStdRandom (randomR (5,10)) > return (BoxBounds x y l r t b) Others have already answered but I'd like to suggest that you avoid using IO here. There's no need for this to be impure. The getStdRandom function is one that should be avoided IMHO (and indeed removed from the Random module). A much nicer way to do the above is using some random monad, for example from the MonadRandom package. The suggestions from Felipe and Eugene will work just as well using Rand monad as the IO monad. Duncan From mpm at alumni.caltech.edu Sun Oct 4 08:11:33 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sun Oct 4 07:49:23 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <1254657171.5687.88.camel@localhost> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> Message-ID: <4AC890F5.9000307@alumni.caltech.edu> Duncan Coutts wrote: > On Sun, 2009-10-04 at 02:52 -0700, Michael Mossey wrote: >> I'm looking for a hint to write the following code with less redundancy. I >> have a constructor called BoxBounds, and I want to make one with random >> values. >> >> randomBox :: IO BoxBounds >> randomBox = do >> x <- getStdRandom (randomR (-10,10)) >> y <- getStdRandom (randomR (-70,70)) >> t <- getStdRandom (randomR (5,10)) >> b <- getStdRandom (randomR (5,10)) >> l <- getStdRandom (randomR (5,10)) >> r <- getStdRandom (randomR (5,10)) >> return (BoxBounds x y l r t b) > > Others have already answered but I'd like to suggest that you avoid > using IO here. There's no need for this to be impure. The getStdRandom > function is one that should be avoided IMHO (and indeed removed from the > Random module). > > A much nicer way to do the above is using some random monad, for example > from the MonadRandom package. The suggestions from Felipe and Eugene > will work just as well using Rand monad as the IO monad. > > Duncan > Hi Duncan, Can you point me to a tutorial that covers the basics of randomness in Hasell? I find it very confusing. Mike From duncan.coutts at googlemail.com Sun Oct 4 09:20:53 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sun Oct 4 08:58:38 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4AC890F5.9000307@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> Message-ID: <1254662453.5687.119.camel@localhost> On Sun, 2009-10-04 at 05:11 -0700, Michael Mossey wrote: > Duncan Coutts wrote: > > Others have already answered but I'd like to suggest that you avoid > > using IO here. There's no need for this to be impure. > Can you point me to a tutorial that covers the basics of randomness in > Hasell? I find it very confusing. http://en.wikibooks.org/wiki/Haskell/Hierarchical_libraries/Randoms http://learnyouahaskell.com/input-and-output#randomness The main thing to realise is that random number generators are pure and predictable. Given the state of a random number generator, if you ask for a random number, it always gives the same answer. It has to, because it is pure. Let's make one, and seed it with the starting state 12345 ghci> :module System.Random ghci> let g0 = mkStdGen 12345 Now we can ask for the next random number in the sequence: ghci> let (n1, g1) = next g0 ghci> n1 493972152 Now of course if we asked for the random number from g0 again then we must get the same result. But notice that when we use 'next' it also gives us back g1 which is the next state of the random number generator. ghci> let (n2, g2) = next g1 ghci> n2 335387100 So this is the basic way that random number generators work in a pure language. The generator has to be passed around the pure function, for example from one recursion to the next. So you end up with pure functions like: shuffle :: RandomGen g => g -> [x] -> [x] Another approach is to hide the 'g' inside a monad. That's what MonadRandom is all about. eg: shuffle :: [x] -> Rand [x] The tutorials above explain about the other random functions, for getting values of different types (not just Int) and restricted ranges of number etc. Of course at some point you want to seed the random number generator with some initial genuinely random value (not like the 12345 we used above). That is the only place in your random-handling code that needs to do IO. All the rest of it can be pure. Duncan From niklas.broberg at gmail.com Sun Oct 4 12:53:12 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Oct 4 12:30:54 2009 Subject: [Haskell-cafe] Need some help with Alex macros Message-ID: Hi all, I'm going crazy trying to get Alex to do what I want. I have the following regexp macros: @octEscape = [0123]? $octdig{1,2} @hexEscape = 'u' $hexdig{4} @charEscape = '\\' (@octEscape | @hexEscape | b | t | n | f | r | \" | \') and the following rules: \' (. # [\'\\] | @charEscape) \' { \p s -> CharTok (readCharTok s) } \" (. # [\"\\] | @charEscape)* \" { \p s -> StringTok (readStringTok s) } I've tried a lot of variations on where to put the backslashes and quotes to get it to do what I want, what you see above is just one variation, but no matter what I try I can't get it to work. > alexScanTokens $ show '\n' *** Exception: lexical error Can anyone help shed some light on this for me? Why can't I get alex to recognize escapes inside character literals? Cheers, /Niklas From ryani.spam at gmail.com Sun Oct 4 13:16:56 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Oct 4 12:54:39 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <1254662453.5687.119.camel@localhost> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> Message-ID: <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> And, to go further, once you embrace "determinism" in your randomness, you can do all sorts of really cool things. >From the perspective of a games programmer: You can run the same simulation code on two different network nodes, and reliably get the same result, allowing you to just transfer user inputs between the nodes instead of game state. This has applications in reducing latency as well, as you only need to transfer the input one way across the network. You can save off the user inputs and initial into a tiny "replay" buffer, allowing you to re-run the game from the beginning without much memory cost. This is not only a cool end-user feature, but it aids *tremendously* in debugging. When something goes wrong, you can always just rewind as many times as you want while you narrow down the cause of the problem. However, we always had problems with determinism failures, where somebody would use the wrong random-number generator, or forget that they aren't allowed to have the simulation depend on something that came from the graphics RNG. In Haskell you can encode the purity of the simulation into its type and it won't break! -- ryan On Sun, Oct 4, 2009 at 6:20 AM, Duncan Coutts wrote: > On Sun, 2009-10-04 at 05:11 -0700, Michael Mossey wrote: > > Duncan Coutts wrote: > > > > Others have already answered but I'd like to suggest that you avoid > > > using IO here. There's no need for this to be impure. > > > Can you point me to a tutorial that covers the basics of randomness in > > Hasell? I find it very confusing. > > > http://en.wikibooks.org/wiki/Haskell/Hierarchical_libraries/Randoms > > http://learnyouahaskell.com/input-and-output#randomness > > > The main thing to realise is that random number generators are pure and > predictable. Given the state of a random number generator, if you ask > for a random number, it always gives the same answer. It has to, because > it is pure. > > Let's make one, and seed it with the starting state 12345 > > ghci> :module System.Random > ghci> let g0 = mkStdGen 12345 > > Now we can ask for the next random number in the sequence: > > ghci> let (n1, g1) = next g0 > ghci> n1 > 493972152 > > Now of course if we asked for the random number from g0 again then we > must get the same result. But notice that when we use 'next' it also > gives us back g1 which is the next state of the random number generator. > > ghci> let (n2, g2) = next g1 > ghci> n2 > 335387100 > > So this is the basic way that random number generators work in a pure > language. The generator has to be passed around the pure function, for > example from one recursion to the next. > > So you end up with pure functions like: > > shuffle :: RandomGen g => g -> [x] -> [x] > > Another approach is to hide the 'g' inside a monad. That's what > MonadRandom is all about. eg: > > shuffle :: [x] -> Rand [x] > > The tutorials above explain about the other random functions, for > getting values of different types (not just Int) and restricted ranges > of number etc. > > Of course at some point you want to seed the random number generator > with some initial genuinely random value (not like the 12345 we used > above). That is the only place in your random-handling code that needs > to do IO. All the rest of it can be pure. > > Duncan > > _______________________________________________ > 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/20091004/d54dc894/attachment.html From jmillikin at gmail.com Sun Oct 4 13:32:18 2009 From: jmillikin at gmail.com (John Millikin) Date: Sun Oct 4 13:10:14 2009 Subject: [Haskell-cafe] Can HXT and Parsec 3 be used in the same library? Message-ID: <4AC8DC22.3030708@gmail.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm writing a library that needs to parse both plain text (with Parsec) and XML (with HXT). HXT's .cabal file specifies that it only works with parsec (>= 2.1 && < 3), but it still builds when I depend on parsec >= 3. It's only during "cabal install" that the following error is displayed: - -------------------------------------------- Resolving dependencies... cabal-1.7.3: cannot configure hxt-8.3.1. It requires parsec >=2.1 && <3 For the dependency on parsec >=2.1 && <3 there are these packages: parsec-2.1.0.0 and parsec-2.1.0.1. However none of them are available. parsec-2.1.0.0 was excluded because dbus-core-0.5 requires parsec >=3.0.0 parsec-2.1.0.1 was excluded because dbus-core-0.5 requires parsec >=3.0.0 - -------------------------------------------- Is there a good solution to this? I was thinking about changing my library to use Parsec 2, but that just pushes the problem to my users, it doesn't really solve it. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkrI3BgACgkQIkiy1+fm1TrmJACghhgKDBJNIIa9OVhrZ6zrSii+ HEYAnjqfi0KiIQSNrhGCi6eN1DQoHHs+ =aODO -----END PGP SIGNATURE----- From colin at colina.demon.co.uk Sun Oct 4 13:53:32 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Oct 4 13:31:14 2009 Subject: [Haskell-cafe] Where do these warnings come from? Message-ID: Does anyone recognize which module/function would emit the following warnings? WARNING: nonstandard use of escape in a string literal LINE 11: '# Pandoc\r\n\r\nPandoc is a program for converting ... ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. -- Colin Adams Preston Lancashire From anton at appsolutions.com Sun Oct 4 14:28:10 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Sun Oct 4 14:06:37 2009 Subject: [Haskell-cafe] Where do these warnings come from? In-Reply-To: References: Message-ID: <4AC8E93A.4090303@appsolutions.com> Colin Paul Adams wrote: > Does anyone recognize which module/function would emit the following > warnings? > > WARNING: nonstandard use of escape in a string literal > LINE 11: '# Pandoc\r\n\r\nPandoc is a program for converting ... > ^ > HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. PostgreSQL. Perhaps you're trying to save that text in a database? From colin at colina.demon.co.uk Sun Oct 4 14:48:35 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Oct 4 14:26:18 2009 Subject: [Haskell-cafe] Where do these warnings come from? In-Reply-To: <4AC8E93A.4090303@appsolutions.com> (Anton van Straaten's message of "Sun\, 04 Oct 2009 14\:28\:10 -0400") References: <4AC8E93A.4090303@appsolutions.com> Message-ID: >>>>> "Anton" == Anton van Straaten writes: Anton> Colin Paul Adams wrote: >> Does anyone recognize which module/function would emit the >> following warnings? >> >> WARNING: nonstandard use of escape in a string literal LINE 11: >> '# Pandoc\r\n\r\nPandoc is a program for converting ... ^ >> HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. Anton> PostgreSQL. Perhaps you're trying to save that text in a Anton> database? Yes, thanks. I am. Is it safe to just ignore the warnings, or do I need to run some function over the strings before saving, and the reverse when restoring? -- Colin Adams Preston Lancashire From john at n-brain.net Sun Oct 4 16:28:24 2009 From: john at n-brain.net (John A. De Goes) Date: Sun Oct 4 16:06:13 2009 Subject: [Haskell-cafe] killer app sought In-Reply-To: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> References: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> Message-ID: <4A78F8C8-539F-4975-9732-A992064A6492@n-brain.net> With few exceptions, no such thing as a killer server-side app. The Web 3.0 paradigm is simple: all work except sharing and persistence of data is done on the client. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 3, 2009, at 9:08 PM, Mark Wotton wrote: > Hi, > > I've been writing a little binding from Ruby to Haskell called > Hubris (http://github.com/mwotton/Hubris) which I think has some > potential both for making Haskell web apps easier to write, and also > for bringing the more adventurous Ruby programmers into the Haskell > community. Code-wise it's coming along nicely, and once 6.12 is out > it'll run without modifications at least on Linux (remains to be > seen how long it'll take to get the Mac patches into shape). My real > problem is marketing: I need a killer app that shows it's easy > either to > > 1. wrap a kickarse Haskell library in a convenient Ruby web app shell > 2. speed up a poorly performing Ruby web app > > I've been badgering the Ruby guys in Sydney that I know on the > second point, but either none of them have performance problems, or > none of them want to admit it. The first is entirely possible - if > you only attack the subset of problems where your runtime is > dominated by the database and network latency, language performance > is moot. Conversely, if that's your worldview, the other problems > that could be attacked won't ever come to mind (to monstrously abuse > the Sapir-Whorf hypothesis). > > So, I'm asking you guys. What are some really nice Haskell libraries > or apps that could benefit from being shown off in one of the > plethora of slick, mature web frameworks that exist in Ruby? Manuel > Chakravarty suggested something with vector operations in order to > take advantage of his 'accelerate' library (once it gets a GPU > backend, of course), and more generally, something taking advantage > of Haskell's support for multicore would be cool. (The standard > edition of Ruby is still unicore, I believe.) > > Parenthetically yours, > Mark > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From agocorona at gmail.com Sun Oct 4 17:55:05 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Sun Oct 4 17:32:49 2009 Subject: Fwd: [Haskell-cafe] killer app sought In-Reply-To: References: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> <4A78F8C8-539F-4975-9732-A992064A6492@n-brain.net> Message-ID: Yes, Maybe The piece of the web that desperately need a boost in performance, declarativeness, safety, static typing threading, modularity etc etc etc is the Web Browser. 2009/10/4 John A. De Goes > With few exceptions, no such thing as a killer server-side app. > > The Web 3.0 paradigm is simple: all work except sharing and persistence of > data is done on the client. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > > On Oct 3, 2009, at 9:08 PM, Mark Wotton wrote: > > Hi, >> >> I've been writing a little binding from Ruby to Haskell called Hubris ( >> http://github.com/mwotton/Hubris) which I think has some potential both >> for making Haskell web apps easier to write, and also for bringing the more >> adventurous Ruby programmers into the Haskell community. Code-wise it's >> coming along nicely, and once 6.12 is out it'll run without modifications at >> least on Linux (remains to be seen how long it'll take to get the Mac >> patches into shape). My real problem is marketing: I need a killer app that >> shows it's easy either to >> >> 1. wrap a kickarse Haskell library in a convenient Ruby web app shell >> 2. speed up a poorly performing Ruby web app >> >> I've been badgering the Ruby guys in Sydney that I know on the second >> point, but either none of them have performance problems, or none of them >> want to admit it. The first is entirely possible - if you only attack the >> subset of problems where your runtime is dominated by the database and >> network latency, language performance is moot. Conversely, if that's your >> worldview, the other problems that could be attacked won't ever come to mind >> (to monstrously abuse the Sapir-Whorf hypothesis). >> >> So, I'm asking you guys. What are some really nice Haskell libraries or >> apps that could benefit from being shown off in one of the plethora of >> slick, mature web frameworks that exist in Ruby? Manuel Chakravarty >> suggested something with vector operations in order to take advantage of his >> 'accelerate' library (once it gets a GPU backend, of course), and more >> generally, something taking advantage of Haskell's support for multicore >> would be cool. (The standard edition of Ruby is still unicore, I believe.) >> >> Parenthetically yours, >> Mark >> _______________________________________________ >> 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/20091004/78c2e362/attachment.html From keithshep at gmail.com Sun Oct 4 18:08:13 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sun Oct 4 17:45:58 2009 Subject: [Haskell-cafe] killer app sought In-Reply-To: References: <29B03977-1C95-420F-932D-D72B70296385@gmail.com> <4A78F8C8-539F-4975-9732-A992064A6492@n-brain.net> Message-ID: <92e42b740910041508r71722ab2lae6569e3c8f87195@mail.gmail.com> IMO google web toolkit has done this for Java and I haven't tried it but maybe http://www.haskell.org/haskellwiki/Haskell_in_web_browser does or will do this for Haskell. I still think that there is a place for web applications that are smart on the server side though. Best -Keith On Sun, Oct 4, 2009 at 5:55 PM, Alberto G. Corona wrote: > > > Yes, Maybe The piece of the web that desperately need a boost in > performance, declarativeness, safety, static typing threading, modularity > etc etc etc ?is the Web Browser. > > 2009/10/4 John A. De Goes >> >> With few exceptions, no such thing as a killer server-side app. >> >> The Web 3.0 paradigm is simple: all work except sharing and persistence of >> data is done on the client. >> >> Regards, >> >> John A. De Goes >> N-Brain, Inc. >> The Evolution of Collaboration >> >> http://www.n-brain.net ? ?| ? ?877-376-2724 x 101 >> >> On Oct 3, 2009, at 9:08 PM, Mark Wotton wrote: >> >>> Hi, >>> >>> I've been writing a little binding from Ruby to Haskell called Hubris >>> (http://github.com/mwotton/Hubris) which I think has some potential both for >>> making Haskell web apps easier to write, and also for bringing the more >>> adventurous Ruby programmers into the Haskell community. Code-wise it's >>> coming along nicely, and once 6.12 is out it'll run without modifications at >>> least on Linux (remains to be seen how long it'll take to get the Mac >>> patches into shape). My real problem is marketing: I need a killer app that >>> shows it's easy either to >>> >>> 1. wrap a kickarse Haskell library in a convenient Ruby web app shell >>> 2. speed up a poorly performing Ruby web app >>> >>> I've been badgering the Ruby guys in Sydney that I know on the second >>> point, but either none of them have performance problems, or none of them >>> want to admit it. The first is entirely possible - if you only attack the >>> subset of problems where your runtime is dominated by the database and >>> network latency, language performance is moot. Conversely, if that's your >>> worldview, the other problems that could be attacked won't ever come to mind >>> (to monstrously abuse the Sapir-Whorf hypothesis). >>> >>> So, I'm asking you guys. What are some really nice Haskell libraries or >>> apps that could benefit from being shown off in one of the plethora of >>> slick, mature web frameworks that exist in Ruby? Manuel Chakravarty >>> suggested something with vector operations in order to take advantage of his >>> 'accelerate' library (once it gets a GPU backend, of course), and more >>> generally, something taking advantage of Haskell's support for multicore >>> would be cool. (The standard edition of Ruby is still unicore, I believe.) >>> >>> Parenthetically yours, >>> Mark >>> _______________________________________________ >>> 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 > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- keithsheppard.name From keithshep at gmail.com Sun Oct 4 21:42:38 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sun Oct 4 21:20:21 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.4.0 Message-ID: <92e42b740910041842o6c699416h57f6d504df62876@mail.gmail.com> Hello Cafe, I've just uploaded TxtSushi 0.4.0 to hackage. TxtSushi is a collection of command line utilities for processing comma-separated and tab-delimited files. I posted details on my blog (along with an advertisement to see if others are interested in hacking TxtSushi): http://blog.keithsheppard.name/2009/10/txtsushi-040.html Best Regards Keith -- keithsheppard.name From nowgate at yahoo.com Mon Oct 5 00:18:56 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Oct 4 23:56:37 2009 Subject: [Haskell-cafe] Curried function terminology Message-ID: <948472.30597.qm@web31105.mail.mud.yahoo.com> This is from Learn You A Haskell: ========== "Curried functions Every function in Haskell officially only takes one parameter. So how is it possible that we defined and used several functions that take more than one parameter so far? Well, it's a clever trick! All the functions that accepted several parameters so far have been curried functions. What does that mean? You'll understand it best on an example. Let's take our good friend, the max function. It looks like it takes two parameters and returns the one that's bigger. Doing max 4 5 first creates a function that takes a parameter and returns either 4 or that parameter, depending on which is bigger. Then, 5 IS APPLIED TO THAT FUNCTION and that function produces our desired result. What really happens when we do multThree 3 5 9 or ((multThree 3) 5) 9? First, 3 is applied to multThree, because they're separated by a space. That creates a function that takes one parameter and returns a function. So then 5 IS APPLIED TO THAT, which creates a function that will take a parameter and multiply it by 15. 9 IS APPLIED TO THAT FUNCTION and the result is 135 or something." ======= The language (in CAPS) in the above two paragraphs seems to be backwards. In the first paragraph, since functions are conventionally "applied" to parameters shouldn't it read something like THE PARTIALLY APPLIED FUNCTION IS THEN APPLIED TO the 5? Or is the terminology different for Haskell, as opposed to say, Scheme or just about any other language? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091004/a31e100a/attachment.html From xs at xaph.net Mon Oct 5 01:18:30 2009 From: xs at xaph.net (Rafal Kolanski) Date: Mon Oct 5 00:56:19 2009 Subject: [Haskell-cafe] Is c2hs able to generate FunPtr rather than just the function? Message-ID: <4AC981A6.2000205@xaph.net> Hi Everyone, I'm trying to figure out an elegant way of letting the Haskell garbage collector deal with structures allocated from C. So I have the C pair: fluid_event_t* new_fluid_event(void); void delete_fluid_event(fluid_event_t* evt); I've handled the new_fluid_event thing nicely, ForeignPtr and all. Now if I want to add a finalizer to the ForeignPtr via newForeignPtr, and for that I need a FunPtr. So what I need is: foreign import ccall safe "fluidsynth.h &delete_fluid_event" deleteFluidEvent'' :: FunPtr (((Ptr (Event)) -> (IO ()))) (if I use that as a finalizer, everything works nicely) But the closest I can get to generating something similar with c2hs is: {# fun delete_fluid_event as ^ {fromEvent `Event'} -> `()' #} which results in: foreign import ccall safe "Event.chs.h delete_fluid_event" deleteFluidEvent'_ :: ((Ptr (Event)) -> (IO ())) Is there a neat way to have c2hs generate the FunPtr version for me? Sincerely, Rafal Kolanski. From bulat.ziganshin at gmail.com Mon Oct 5 03:36:43 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Oct 5 03:16:04 2009 Subject: [Haskell-cafe] Is c2hs able to generate FunPtr rather than just the function? In-Reply-To: <4AC981A6.2000205@xaph.net> References: <4AC981A6.2000205@xaph.net> Message-ID: <1029001809.20091005113643@gmail.com> Hello Rafal, Monday, October 5, 2009, 9:18:30 AM, you wrote: > Is there a neat way to have c2hs generate the FunPtr version for me? from my program: -- |My callback function type type CALLBACK_FUNC = Ptr CChar -> IO CInt foreign import ccall threadsafe "wrapper" mkCALL_BACK :: CALLBACK_FUNC -> IO (FunPtr CALLBACK_FUNC) key word here is "wrapper" in foreign import statement. read FFI specs for that -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jon.fairbairn at cl.cam.ac.uk Mon Oct 5 05:52:17 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Mon Oct 5 05:30:23 2009 Subject: [Haskell-cafe] Re: Curried function terminology References: <948472.30597.qm@web31105.mail.mud.yahoo.com> Message-ID: michael rice writes: > This is from Learn You A Haskell: > > ========== > > "Curried functions > > Every function in Haskell officially only takes one > parameter. So how is it possible that we defined and used > several functions that take more than one parameter so far? > Well, it's a clever trick! All the functions that accepted > several parameters so far have been curried functions. What > does that mean? You'll understand it best on an example. > Let's take our good friend, the max function. It looks like > it takes two parameters and returns the one that's bigger. > Doing max 4 5 first creates a function that takes a > parameter and returns either 4 or that parameter, depending > on which is bigger. Then, 5 IS APPLIED TO THAT FUNCTION and > that function produces our desired result. > > What really happens when we do multThree 3 5 9 or > ((multThree 3) 5) 9? First, 3 is applied to multThree, > because they're separated by a space. That creates a > function that takes one parameter and returns a function. So > then 5 IS APPLIED TO THAT, which creates a function that > will take a parameter and multiply it by 15. 9 IS APPLIED TO > THAT FUNCTION and the result is 135 or something." > > ======= > > The language (in CAPS) in the above two paragraphs seems to > be backwards. It is. "5 is applied to that function" should be "5 is supplied to that function" (or that function is applied to 5) and so on. It's a fairly common error in writing this sort of thing?, and given that the title "Learn You A Haskell" is totally ungrammatical, hardly seems surprising. > In the first paragraph, since functions are > conventionally "applied" to parameters shouldn't it read > something like THE PARTIALLY APPLIED FUNCTION IS THEN > APPLIED TO the 5? Or is the terminology different for > Haskell, No, but Haskell does have a lot of non-native users of English among its users. [1] A pet peeve of mine is "x supports y" being used backwards (as in "our application supports windows Vista", which would only make sense if it were something like a system tool that stopped Vista crashing. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From frank at geoinfo.tuwien.ac.at Mon Oct 5 06:42:57 2009 From: frank at geoinfo.tuwien.ac.at (Andrew U. Frank) Date: Mon Oct 5 06:20:43 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <20091002143236.681743241FC@www.haskell.org> References: <20091002143236.681743241FC@www.haskell.org> Message-ID: <200910051242.58088.frank@geoinfo.tuwien.ac.at> writing a gui is a mess (independent of wx or gtk) - too much detail is shown and not enough abstraction is done. haskell can help. i have written an experimental way of producing the GUI automatically with a description of the semantics of the types and operations involved (a la ontology, evnetually comparable what protege produces). the input is a descriptionof the entity ypes, the fields used, the functional dependencies between the fiels, plus the operations used. the division in screens and their layout. the rest ist automatic. the result is a GUI (with preferably gtk but i had also a wx version running). the ideas were inspired by eliot conal's work and wxgeneric, which seemed for administrative applications either too restricted or to specific. if somebody wants to try it out for his application, please write frank@geoinfo.tuwien.ac.at (there is not much documentation and the code is not yet completely clean - testing by somebody else would be very valuable!) andrew From gue.schmidt at web.de Mon Oct 5 07:16:32 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Oct 5 06:54:35 2009 Subject: [Haskell-cafe] Re: dsl and gui toolkit References: <20091002143236.681743241FC@www.haskell.org> <200910051242.58088.frank@geoinfo.tuwien.ac.at> Message-ID: lemme have it please! G?nther Am 05.10.2009, 12:42 Uhr, schrieb Andrew U. Frank : > writing a gui is a mess (independent of wx or gtk) - too much detail is > shown > and not enough abstraction is done. haskell can help. > > i have written an experimental way of producing the GUI automatically > with a > description of the semantics of the types and operations involved (a la > ontology, evnetually comparable what protege produces). > the input is a descriptionof the entity ypes, the fields used, the > functional > dependencies between the fiels, plus the operations used. > the division in screens and their layout. > > the rest ist automatic. > the result is a GUI (with preferably gtk but i had also a wx version > running). > > the ideas were inspired by eliot conal's work and wxgeneric, which > seemed for > administrative applications either too restricted or to specific. > > if somebody wants to try it out for his application, please write > frank@geoinfo.tuwien.ac.at > > (there is not much documentation and the code is not yet completely > clean - > testing by somebody else would be very valuable!) > > andrew From burger.gregor at gmail.com Mon Oct 5 07:34:11 2009 From: burger.gregor at gmail.com (Gregor Burger) Date: Mon Oct 5 07:11:51 2009 Subject: [Haskell-cafe] Re: dsl and gui toolkit In-Reply-To: References: <20091002143236.681743241FC@www.haskell.org> <200910051242.58088.frank@geoinfo.tuwien.ac.at> Message-ID: <11bd6bba0910050434j71a81c47vd742c5cc6a01ef6f@mail.gmail.com> hi there, i can't resist to post grun here! although its python based the ideas behind are great! maybe some excellent haskell hackers can borrow some ideas from it. http://pypi.python.org/pypi/grun/ gregor 2009/10/5 G?nther Schmidt > lemme have it please! > > G?nther > > > Am 05.10.2009, 12:42 Uhr, schrieb Andrew U. Frank < > frank@geoinfo.tuwien.ac.at>: > > > writing a gui is a mess (independent of wx or gtk) - too much detail is >> shown >> and not enough abstraction is done. haskell can help. >> >> i have written an experimental way of producing the GUI automatically >> with a >> description of the semantics of the types and operations involved (a la >> ontology, evnetually comparable what protege produces). >> the input is a descriptionof the entity ypes, the fields used, the >> functional >> dependencies between the fiels, plus the operations used. >> the division in screens and their layout. >> >> the rest ist automatic. >> the result is a GUI (with preferably gtk but i had also a wx version >> running). >> >> the ideas were inspired by eliot conal's work and wxgeneric, which seemed >> for >> administrative applications either too restricted or to specific. >> >> if somebody wants to try it out for his application, please write >> frank@geoinfo.tuwien.ac.at >> >> (there is not much documentation and the code is not yet completely clean >> - >> testing by somebody else would be very valuable!) >> >> andrew >> > > _______________________________________________ > 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/20091005/34b8d9f1/attachment.html From alp at mestan.fr Mon Oct 5 07:49:16 2009 From: alp at mestan.fr (Alp Mestan) Date: Mon Oct 5 07:26:57 2009 Subject: [Haskell-cafe] Re: dsl and gui toolkit In-Reply-To: <11bd6bba0910050434j71a81c47vd742c5cc6a01ef6f@mail.gmail.com> References: <20091002143236.681743241FC@www.haskell.org> <200910051242.58088.frank@geoinfo.tuwien.ac.at> <11bd6bba0910050434j71a81c47vd742c5cc6a01ef6f@mail.gmail.com> Message-ID: It'd be great if you could at least paste some sample lines of usage of your library. On 10/5/09, Gregor Burger wrote: > hi there, > i can't resist to post grun here! although its python based > the ideas behind are great! maybe some excellent haskell > hackers can borrow some ideas from it. > > http://pypi.python.org/pypi/grun/ > > gregor > > 2009/10/5 G?nther Schmidt > >> lemme have it please! >> >> G?nther >> >> >> Am 05.10.2009, 12:42 Uhr, schrieb Andrew U. Frank < >> frank@geoinfo.tuwien.ac.at>: >> >> >> writing a gui is a mess (independent of wx or gtk) - too much detail is >>> shown >>> and not enough abstraction is done. haskell can help. >>> >>> i have written an experimental way of producing the GUI automatically >>> with a >>> description of the semantics of the types and operations involved (a la >>> ontology, evnetually comparable what protege produces). >>> the input is a descriptionof the entity ypes, the fields used, the >>> functional >>> dependencies between the fiels, plus the operations used. >>> the division in screens and their layout. >>> >>> the rest ist automatic. >>> the result is a GUI (with preferably gtk but i had also a wx version >>> running). >>> >>> the ideas were inspired by eliot conal's work and wxgeneric, which >>> seemed >>> for >>> administrative applications either too restricted or to specific. >>> >>> if somebody wants to try it out for his application, please write >>> frank@geoinfo.tuwien.ac.at >>> >>> (there is not much documentation and the code is not yet completely >>> clean >>> - >>> testing by somebody else would be very valuable!) >>> >>> andrew >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > -- Alp Mestan http://alpmestan.wordpress.com/ http://alp.developpez.com/ From shahn at cs.tu-berlin.de Mon Oct 5 08:40:31 2009 From: shahn at cs.tu-berlin.de (=?utf-8?q?S=C3=B6nke_Hahn?=) Date: Mon Oct 5 08:18:16 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types Message-ID: <200910051440.32119.shahn@cs.tu-berlin.de> Hi! I often stumble upon 2- (or 3-) dimensional numerical data types like (Double, Double) or similar self defined ones. I like the idea of creating instances for Num for these types. The meaning of (+), (-) and negate is clear and very intuitive, i think. I don't feel sure about (*), abs, signum and fromInteger. I used to implement fromInteger n = (r, r) where r = fromInteger n , but thinking about it, fromInteger n = (fromInteger n, 0) seems very reasonable, too. Any thoughts on that? How would you do it? btw: These are two examples i looked at in hackage: Data.Complex.Complex (which is special, cause it is mathematically defined, what (*), abs, signum and fromInteger should do (i think)) and Physics.Hipmunk.Common.Vector (http://hackage.haskell.org/packages/archive/Hipmunk/5.0.0/doc/html/Physics- Hipmunk-Common.html#9) S?nke From jvranish at gmail.com Mon Oct 5 09:07:55 2009 From: jvranish at gmail.com (Job Vranish) Date: Mon Oct 5 08:45:35 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <200910051440.32119.shahn@cs.tu-berlin.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> Message-ID: You are in luck! Such an instance is very simple with Applicative. If the type you want a Num instance for is a member of the Applicative type class you can define it like this: instance (Num a) => Num (Vector2 a) where a + b = pure (+) <*> a <*> b a - b = pure (-) <*> a <*> b a * b = pure (*) <*> a <*> b negate a = pure negate <*> a abs a = pure abs <*> a signum = fmap signum fromInteger = pure . fromInteger If you want to define a Num instance for _all_ applicatives, you can do this (you'll need a couple extensions): instance (Num a, Applicative f, Eq (f a), Show (f a)) => Num (f a) where a + b = pure (+) <*> a <*> b a - b = pure (-) <*> a <*> b a * b = pure (*) <*> a <*> b negate a = pure negate <*> a abs a = pure abs <*> a signum = fmap signum fromInteger = pure . fromInteger I am currently working on a vector and matrix library for haskell that uses instances of this form, which you can find here: http://github.com/jvranish/VectorMatix. The matrix half is very unfinished, but the vector half is pretty much done. Applicative is a pretty fantastic typeclass, it's definitly worth the time to figure out how it works. However, this technique won't work with tuples as they don't behave as Functors in the way you would like. (too many type parameters, tuples don't force all elements to be the same type so maps don't work, etc...) Hope that helps :) - Job On Mon, Oct 5, 2009 at 8:40 AM, S?nke Hahn wrote: > Hi! > > I often stumble upon 2- (or 3-) dimensional numerical data types like > > (Double, Double) > > or similar self defined ones. I like the idea of creating instances for Num > for > these types. The meaning of (+), (-) and negate is clear and very > intuitive, i > think. I don't feel sure about (*), abs, signum and fromInteger. I used to > implement > > fromInteger n = (r, r) where r = fromInteger n > > , but thinking about it, > > fromInteger n = (fromInteger n, 0) > > seems very reasonable, too. > > Any thoughts on that? How would you do it? > > btw: These are two examples i looked at in hackage: > Data.Complex.Complex (which is special, cause it is mathematically defined, > what (*), abs, signum and fromInteger should do (i think)) > > and > > Physics.Hipmunk.Common.Vector > ( > http://hackage.haskell.org/packages/archive/Hipmunk/5.0.0/doc/html/Physics- > Hipmunk-Common.html#9 > ) > > > S?nke > _______________________________________________ > 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/20091005/b4b2e288/attachment.html From miguelimo38 at yandex.ru Mon Oct 5 09:12:04 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 08:51:53 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <200910051440.32119.shahn@cs.tu-berlin.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> Message-ID: <4AC9F0A4.2000005@yandex.ru> S?nke Hahn wrote: > I used to implement > > fromInteger n = (r, r) where r = fromInteger n > > , but thinking about it, > > fromInteger n = (fromInteger n, 0) > > seems very reasonable, too. Stop pretending something is a number when it's not. From daniel.is.fischer at web.de Mon Oct 5 09:30:14 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Oct 5 09:09:09 2009 Subject: [Haskell-cafe] Re: Curried function terminology In-Reply-To: References: <948472.30597.qm@web31105.mail.mud.yahoo.com> Message-ID: <200910051530.14479.daniel.is.fischer@web.de> Am Montag 05 Oktober 2009 11:52:17 schrieb Jon Fairbairn: > michael rice writes: > > This is from Learn You A Haskell: > > The language (in CAPS) in the above two paragraphs seems to > > be backwards. > > It is. "5 is applied to that function" should be "5 is supplied to that > function" (or that function is applied to 5) and so on. It's a fairly > common error in writing this sort of thing?, and given that the title > "Learn You A Haskell" is totally ungrammatical, hardly seems surprising. > > > In the first paragraph, since functions are > > conventionally "applied" to parameters shouldn't it read > > something like THE PARTIALLY APPLIED FUNCTION IS THEN > > APPLIED TO the 5? Or is the terminology different for > > Haskell, That would be correct but awkward. IMO it would be better to say that 5 is then supplied (or fed) to (the partially applied function). I tend to feed arguments to functions if I don't want to apply a function to an argument. > > No, but Haskell does have a lot of non-native users of English among its > users. I'm not sure that's relevant for this kind of error. I think it's more a lack of familiarity with mathematical terminology. > > > [1] A pet peeve of mine is "x supports y" being used backwards (as in > "our application supports windows Vista", which would only make sense if > it were something like a system tool that stopped Vista crashing. Or if Microsoft uses the profits from App X to compensate deficits incurred by Vista. Or if the application sports banners "Vista is great! Get you a Vista today!" :D But seriously, yes, it's annoying. From john at n-brain.net Mon Oct 5 09:33:47 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Oct 5 09:11:32 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4AC9F0A4.2000005@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: <8EDD9AFA-EC81-4D40-92D7-3425BD786F0E@n-brain.net> That's not gonna happen until when/if Haskell supports name/operator overloading. There's a scarcity of good symbols/function names and everyone wants to use them. So naturally, type class abuse follows. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 5, 2009, at 7:12 AM, Miguel Mitrofanov wrote: > > > S?nke Hahn wrote: > >> I used to implement >> fromInteger n = (r, r) where r = fromInteger n >> , but thinking about it, fromInteger n = (fromInteger n, 0) >> seems very reasonable, too. > > Stop pretending something is a number when it's not. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From maria.boghiu at gmail.com Mon Oct 5 09:48:56 2009 From: maria.boghiu at gmail.com (Maria Boghiu) Date: Mon Oct 5 09:26:57 2009 Subject: [Haskell-cafe] I/O Haskell question Message-ID: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> Hey. I'm trying to configure Xmonad, the window manager. for this purpose, I'm trying to read the *workspaces* variable in the code below from file. As you can see, I do workspaces = readWS where * readWS = do l <- readFile "~/bla" return l* I get an error saying I am mismatching types IO [String] and [String]. But I thought that once one does * l <- readFile "~/bla"*, l is the a string or, in this case, a String list. If I run that line in prelude it seems to be working fine, prints the content of the file "~/bla" on screen (though I'm not sure if as a String or as a list of Strings, i.e. [String]) Can anyone help please? I've been struggling with this for days... 94 main = do 95 xmonad 96 $ defaultConfig { 97 manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig, 98 layoutHook = avoidStruts $ layoutHook defaultConfig, 99 logHook = dynamicLogWithPP $ conkyPP "", 100 terminal = "gnome-terminal", 101 keys = myKeys, 102 workspaces = readWS, 103 mouseBindings = myMouseBindings, 104 focusedBorderColor = "#008E00", 105 borderWidth = 3 106 --modMask = mod1Mask, --This is to rebind mod key 107 } `additionalKeys` -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091005/f5a74403/attachment.html From lennart at augustsson.net Mon Oct 5 09:55:04 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Oct 5 09:32:44 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4AC9F0A4.2000005@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: And what is a number? Are complex numbers numbers? On Mon, Oct 5, 2009 at 3:12 PM, Miguel Mitrofanov wrote: > > > S?nke Hahn wrote: > >> I used to implement >> >> ? ?fromInteger n = (r, r) where r = fromInteger n >> >> , but thinking about it, >> ? ?fromInteger n = (fromInteger n, 0) >> >> seems very reasonable, too. > > Stop pretending something is a number when it's not. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From deniz.a.m.dogan at gmail.com Mon Oct 5 10:06:07 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Mon Oct 5 09:44:12 2009 Subject: [Haskell-cafe] I/O Haskell question In-Reply-To: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> References: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> Message-ID: <7b501d5c0910050706k7d592142p935f4507b2eba550@mail.gmail.com> 2009/10/5 Maria Boghiu : > I get an error saying I am mismatching types IO [String] and [String]. Something of the type IO [String] is a computation which does some IO (reading files, launching nukes, etc.) and then returns a list of strings. Something of the type [String] is merely a list of strings. It is impossible (I'm lying here, but for a good cause) to "convert" something on the form "IO a" to just "a". Try something like this: main = do fileContent <- readFile "/path/to/file" xmonad $ defaultConfig { ... workspaces = lines fileContent, ... } ... -- Deniz Dogan From icfp.publicity at googlemail.com Mon Oct 5 10:06:33 2009 From: icfp.publicity at googlemail.com (Wouter Swierstra) Date: Mon Oct 5 09:44:19 2009 Subject: [Haskell-cafe] ICFP videos now available Message-ID: <53ff55480910050706v4411ecdfr36b3a838c1419870@mail.gmail.com> I am happy to announce that videos of all talks at ICFP and some of the associated workshops this year have made available online: http://www.vimeo.com/user2191865/albums I'm sure you'll join me in thanking Malcolm Wallace for the time and effort he put into making this possible. Thank you Malcolm! Wouter From doaitse at swierstra.net Mon Oct 5 10:06:35 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Mon Oct 5 09:44:25 2009 Subject: [Haskell-cafe] Designing a DSL? In-Reply-To: <4AC6485F.4050200@gmail.com> References: <4AC6485F.4050200@gmail.com> Message-ID: <0DFADF77-10EA-4CFA-B9AF-7E49965FE1CD@swierstra.net> On 2 okt 2009, at 20:37, Jake McArthur wrote: > G?nther Schmidt wrote: >> And that I find to be the really tricky part, how do I *design* a >> DSL? I once wrote a tutorial on this subject in which I explain that designing a DSL is not so much different from an ordinary programming language; the only difference is that you do not have to think about type systems and abstraction mechanisms. The tutorial can be found in: @inproceedings{SwieAzSar98Braga, Author = {Swierstra, S. Doaitse and Azero~Alcocer, Pablo R. and Saraiva, Jo{\~a}o A.}, Booktitle = {Advanced Functional Programming, Third International School, AFP'98}, Date-Added = {2008-07-15 17:22:15 +0200}, Date-Modified = {2009-01-16 17:35:05 +0100}, Editor = {Swierstra, S. D. and Henriques, Pedro and Oliveira, Jos \'{e}}, Pages = {150-206}, Publisher = {Springer-Verlag}, Series = {LNCS}, Title = {Designing and Implementing Combinator Languages}, Volume = {1608}, Year = {1999}} It basically describes the origins of the Utrecht Attribute Grammar System, uuagc, available from hackage; the basic message is that when you implement a language you use compiler construction tools! An example of this can be found in a paper Olaf Chitil and I recently published in the JFP: @article{CambridgeJournals:2837460, Author = {SWIERSTRA, S. DOAITSE and CHITIL, OLAF}, Date-Added = {2009-02-13 10:17:23 +0100}, Date-Modified = {2009-02-13 10:17:23 +0100}, Doi = {10.1017/S0956796808006990}, Eprint = {http://journals.cambridge.org/article_S0956796808006990}, Journal = {Journal of Functional Programming}, Number = {01}, Pages = {1-16}, Title = {Linear, bounded, functional pretty-printing}, Url = {http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=2837460&fulltextType=RC&fileId=S0956796808006990 }, Volume = {19}, Year = {2009}, Abstract = { ABSTRACT We present two implementations of Oppen's pretty-printing algorithm in Haskell that meet the efficiency of Oppen's imperative solution but have a simpler and a clear structure. We start with an implementation that uses lazy evaluation to simulate two co-operating processes. Then we present an implementation that uses higher-order functions for delimited continuations to simulate co- routines with explicit scheduling. }, Bdsk-Url-1 = {http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=2837460&fulltextType=RC&fileId=S0956796808006990 }, Bdsk-Url-2 = {http://dx.doi.org/10.1017/S0956796808006990}} This paper describes two implementation of a functional pretty printing, finally solving the problem how to do so with limited alook- ahead, as in Oppen's orginal paper. One of the solutions was created using an attribute grammar way of thinking and the attribute grammar can be found at the end of the technical report, and I hope that this example convinces you of the elegance of this approach: @techreport{PPTr2004, Author = {Swierstra, S.D.}, Date-Added = {2009-01-04 17:21:54 +0100}, Date-Modified = {2009-01-04 17:21:54 +0100}, Institution = {Inst. of Information and Comp. Science, Utrecht Univ.}, Note = {submitted for publication}, Number = {UU-CS-2004-025a}, Pubcat = {techreport}, Title = {Linear, Online, Functional Pretty printing (extended and corrected version)}, Urlpdf = {{http://archive.cs.uu.nl/pub/RUU/CS/techreps/CS-2004/2004-025a.pdf }}, Year = 2004} In a more abstract setting your question is also "How do I design a library", "How do I design a consistent theory", and "How do I model something". These questions are harder to answer ;-} Doaitse Swierstra From jake.mcarthur at gmail.com Mon Oct 5 10:10:18 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Mon Oct 5 09:47:56 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <200910051242.58088.frank@geoinfo.tuwien.ac.at> References: <20091002143236.681743241FC@www.haskell.org> <200910051242.58088.frank@geoinfo.tuwien.ac.at> Message-ID: <4AC9FE4A.6060009@gmail.com> If you could throw it on Hackage or a public repo you will get more exposure. :) - Jake From jerzy.karczmarczuk at info.unicaen.fr Mon Oct 5 10:09:31 2009 From: jerzy.karczmarczuk at info.unicaen.fr (jerzy.karczmarczuk@info.unicaen.fr) Date: Mon Oct 5 09:48:15 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4AC9F0A4.2000005@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: Miguel Mitrofanov rebukes S?nke Hahn, who -: > wrote: >> I used to implement >> fromInteger n = (r, r) where r = fromInteger n >> , but thinking about it, >> fromInteger n = (fromInteger n, 0) >> seems very reasonable, too. > Stop pretending something is a number when it's not. Miguel Mitrofanov, please kindly stop pretending that you KNOW what is a number, and what is not. The numeric classes in standard Haskell are disgraceful, and the idea that if something can be added, it is a number is bad. Vectors are not numbers, but inventing "special" (+) for all kinds of Abelian additions is awkward. So, people call "numbers" what they wish, and it is *their* business. I needed to add functions (of course, without Eq nor Show membership), I had to fake... Pairs (a,b) may be "numbers" in various contexts, for example (value,derivative) in automatic differentiation. Or (mainTerm,otherOrders) in some infinitesimal calculus. Or pairs (scalar, 3vector) for quaternions. The idea of putting fromInteger in the same class, is a design bug (my personal opinion, of course). There are plenty of examples where conversions from integers are legitimate, but no addition or (*)seem natural. Or the other way round ; apparently S?nke Hahn is in that situation, so he fakes... Jerzy Karczmarczuk From mpm at alumni.caltech.edu Mon Oct 5 10:22:15 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Oct 5 10:00:13 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> Message-ID: <4ACA0117.7080906@alumni.caltech.edu> Eugene Kirpichov wrote: > [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...] > return (BoxBounds ...) Thanks. I'm curious about the idea of "pattern matching in do-statements that can fail." This particular pattern cannot fail. I read that the "fail" function was introduced to Monad in order to handle pattern matches that fail, and that most members of haskell-cafe seem to think that was a mistake---that MonadZero should have been used instead. I.e., any do-block with a pattern that can fail should explicitly have a MonadZero class constraint. This leads to my question about detecting pattern matches that could fail. We can easily prove the above pattern will never fail. I'm wondering if the compiler infers this. And if a future version of Haskell dumps "fail" and used MonadZero to replace it, would that future Haskell compiler need to infer, in all cases, whether a pattern can fail? Is it simple enough to make that correct inference? Thanks, Mike From ekirpichov at gmail.com Mon Oct 5 10:24:17 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Oct 5 10:02:01 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4ACA0117.7080906@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> <4ACA0117.7080906@alumni.caltech.edu> Message-ID: <5e0214850910050724n45139a59vf4f5824340da1b2a@mail.gmail.com> 2009/10/5 Michael Mossey : > > > Eugene Kirpichov wrote: >> >> [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...] >> return (BoxBounds ...) > > Thanks. > > I'm curious about the idea of "pattern matching in do-statements that can > fail." This particular pattern cannot fail. I read that the "fail" function > was introduced to Monad in order to handle pattern matches that fail, and > that most members of haskell-cafe seem to think that was a mistake---that > MonadZero should have been used instead. I.e., any do-block with a pattern > that can fail should explicitly have a MonadZero class constraint. > > This leads to my question about detecting pattern matches that could fail. > We can easily prove the above pattern will never fail. I'm wondering if the > compiler infers this. Try proving it by hand and judge the result with respect to whether it could have been done by the compiler. > And if a future version of Haskell dumps "fail" and > used MonadZero to replace it, would that future Haskell compiler need to > infer, in all cases, whether a pattern can fail? Is it simple enough to make > that correct inference? > > Thanks, > Mike > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From mpm at alumni.caltech.edu Mon Oct 5 10:24:00 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Oct 5 10:02:12 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <20091004112704.GA26944@kira.casa> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> <20091004112704.GA26944@kira.casa> Message-ID: <4ACA0180.3000101@alumni.caltech.edu> If I understand correctly, this works because IO is an instance of Applicative, correct? I wonder if any of the random monads are instances of Applicative. Felipe Lessa wrote: > On Sun, Oct 04, 2009 at 01:55:11PM +0400, Eugene Kirpichov wrote: >> [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...] >> return (BoxBounds ...) > > import Control.Applicative > > let f = getStdRandom . randomR > g1 = \x -> f (-x,x) > g2 = f (5,10) > in BoxBounds <$> g1 10 <*> g1 70 <*> g2 <*> g2 <*> g2 <*> g2 > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From keithshep at gmail.com Mon Oct 5 10:27:23 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Mon Oct 5 10:05:04 2009 Subject: [Haskell-cafe] I/O Haskell question In-Reply-To: <7b501d5c0910050706k7d592142p935f4507b2eba550@mail.gmail.com> References: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> <7b501d5c0910050706k7d592142p935f4507b2eba550@mail.gmail.com> Message-ID: <92e42b740910050727x7032f7cj7207c49b4bffd300@mail.gmail.com> I have to nominate "I'm lying here, but for a good cause" as a quote of the week. -Keith On Mon, Oct 5, 2009 at 10:06 AM, Deniz Dogan wrote: > 2009/10/5 Maria Boghiu : >> I get an error saying I am mismatching types IO [String] and [String]. > > Something of the type IO [String] is a computation which does some IO > (reading files, launching nukes, etc.) and then returns a list of > strings. Something of the type [String] is merely a list of strings. > It is impossible (I'm lying here, but for a good cause) to "convert" > something on the form "IO a" to just "a". > > Try something like this: > > main = do > ?fileContent <- readFile "/path/to/file" > ?xmonad $ defaultConfig { > ? ?... > ? ?workspaces = lines fileContent, > ? ?... > ?} ... > > -- > Deniz Dogan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- keithsheppard.name From jvranish at gmail.com Mon Oct 5 10:29:02 2009 From: jvranish at gmail.com (Job Vranish) Date: Mon Oct 5 10:06:45 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4AC9F0A4.2000005@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: In what way is it not a number? data MyNumber a = MyNum a a deriving (Show, Eq) instance Functor MyNum where fmap f (MyNum a b) = MyNum (f a) (f b) instance Applicative MyNum where pure a = MyNum a a MyNum f g <*> MyNum a b = MyNum (f a) (g b) instance (Num a) => Num (MyNum a) where a + b = pure (+) <*> a <*> b a - b = pure (-) <*> a <*> b a * b = pure (*) <*> a <*> b negate a = pure negate <*> a abs a = pure abs <*> a signum = fmap signum fromInteger = pure . fromInteger This instance obeys the commutative, distributive, and associative laws, and the multiplicative, and additive identities. (at least, if the numbers it contains satisfy those laws) How is MyNum not a number? S?nke Hahn: btw, I forgot to mention in my first email, but fromInteger n = (r, r) where r = fromInteger n is better than: fromInteger n = (fromInteger n, 0) as you get a lot of corner cases otherwise. I use fromInteger = pure . fromInteger, which when combined with my Applicative instance, is effectively the same as your: fromInteger n = (r, r) where r = fromInteger n - Job On Mon, Oct 5, 2009 at 9:12 AM, Miguel Mitrofanov wrote: > > > S?nke Hahn wrote: > > I used to implement >> >> fromInteger n = (r, r) where r = fromInteger n >> >> , but thinking about it, >> fromInteger n = (fromInteger n, 0) >> >> seems very reasonable, too. >> > > Stop pretending something is a number when it's not. > > _______________________________________________ > 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/20091005/4aaff28b/attachment-0001.html From nowgate at yahoo.com Mon Oct 5 10:31:08 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Oct 5 10:08:50 2009 Subject: [Haskell-cafe] Re: Curried function terminology In-Reply-To: Message-ID: <167601.23310.qm@web31104.mail.mud.yahoo.com> Yeah, and Haskell supports Linux, AND Windows. ;-) Thanks for the explanation. My shorts weren't in a knot; just said Huh? upon reading it, thinking maybe I misunderstood something along the way. Michael --- On Mon, 10/5/09, Jon Fairbairn wrote: From: Jon Fairbairn Subject: [Haskell-cafe] Re: Curried function terminology To: haskell-cafe@haskell.org Date: Monday, October 5, 2009, 5:52 AM michael rice writes: > This is from Learn You A Haskell: > > ========== > > "Curried functions > > Every function in Haskell officially only takes one > parameter. So how is it possible that we defined and used > several functions that take more than one parameter so far? > Well, it's a clever trick! All the functions that accepted > several parameters so far have been curried functions. What > does that mean? You'll understand it best on an example. > Let's take our good friend, the max function. It looks like > it takes two parameters and returns the one that's bigger. > Doing max 4 5 first creates a function that takes a > parameter and returns either 4 or that parameter, depending > on which is bigger. Then, 5 IS APPLIED TO THAT FUNCTION and > that function produces our desired result. > > What really happens when we do multThree 3 5 9 or > ((multThree 3) 5) 9? First, 3 is applied to multThree, > because they're separated by a space. That creates a > function that takes one parameter and returns a function. So > then 5 IS APPLIED TO THAT, which creates a function that > will take a parameter and multiply it by 15. 9 IS APPLIED TO > THAT FUNCTION and the result is 135 or something." > > ======= > > The language (in CAPS) in the above two paragraphs seems to > be backwards. It is. "5 is applied to that function" should be "5 is supplied to that function" (or that function is applied to 5) and so on. It's a fairly common error in writing this sort of thing?, and given that the title "Learn You A Haskell" is totally ungrammatical, hardly seems surprising. > In the first paragraph, since functions are > conventionally "applied" to parameters shouldn't it read > something like THE PARTIALLY APPLIED FUNCTION IS THEN > APPLIED TO the 5? Or is the terminology different for > Haskell, No, but Haskell does have a lot of non-native users of English among its users. [1] A pet peeve of mine is "x supports y" being used backwards (as in "our application supports windows Vista", which would only make sense if it were something like a system tool that stopped Vista crashing. -- J?n Fairbairn? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ???Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html? (updated 2009-01-31) _______________________________________________ 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/20091005/f140c9df/attachment.html From mpm at alumni.caltech.edu Mon Oct 5 10:34:19 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Oct 5 10:12:14 2009 Subject: [Haskell-cafe] apply function arguments in a list Message-ID: <4ACA03EB.7020101@alumni.caltech.edu> If I have a list containing the arguments I want to give to a function, is there a general way to supply those arguments in a compact syntax? In other words, I could have args = [1,2,3] f x y z = ... I would write t = f (args!!0) (args!!1) (args!!2) but there may be a neater, more general syntax. I tried writing a fold with $, but I don't think that works because the type of each step is different. I.e. f :: a -> a -> a -> a f x :: a -> a -> a f x y :: a -> a f x y z :: a This would seem to preclude a general way of writing a function that supplies arguments from a list. From gwern0 at gmail.com Mon Oct 5 10:38:03 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Oct 5 10:15:37 2009 Subject: [Haskell-cafe] I/O Haskell question In-Reply-To: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> Message-ID: On Mon, Oct 5, 2009 at 9:48 AM, Maria Boghiu wrote: > Hey. > > I'm trying to configure Xmonad, the window manager. > > for this purpose, I'm trying to read the workspaces variable in the code > below from file. > As you can see, I do workspaces = readWS where > > readWS = do > ???????? l <- readFile "~/bla" > ???????? return l > > I get an error saying I am mismatching types IO [String] and [String]. > But I thought that once one does l <- readFile "~/bla", l is the a string > or, in this case, a String list. If I run that line in prelude it seems to > be working fine, prints the content of the file "~/bla" on screen (though > I'm not sure if as a String or as a list of Strings, i.e. [String]) > > Can anyone help please? > I've been struggling with this for days... > > 94 main = do > ?95???????? xmonad > ?96???????? $ defaultConfig { > ?97???????? manageHook???????? = manageDocks <+> myManageHook <+> manageHook > defaultConfig, > ?98???????? layoutHook???????? = avoidStruts $ layoutHook defaultConfig, > ?99???????? logHook??????????? = dynamicLogWithPP $ conkyPP "", > 100???????? terminal?????????? = "gnome-terminal", > 101???????? keys?????????????? = myKeys, > 102???????? workspaces???????? = readWS, > 103???????? mouseBindings????? = myMouseBindings, > 104???????? focusedBorderColor = "#008E00", > 105???????? borderWidth??????? = 3 > 106???????? --modMask??????????? = mod1Mask, --This is to rebind mod key > 107???????? } `additionalKeys` A quick tip: when GHC gives you a compile error like that, it's because you've made an error where 'what I say' is not 'what I [want to] do'. In this case, you're *saying* 'use readFile, which returns a String', and *doing* 'ok, here, use this [String]'. The way to know that it's an issue is to find out what type readFile is; in ghci you can do ':type readFile' and it'll tell you String -> IO String. Now you know workspaces needs [String], so you need something which goes 'String -> [String]'. If you don't already know that that is 'lines', then you can ask Hoogle http://www.haskell.org/hoogle/ that question: http://www.haskell.org/hoogle/?hoogle=String+-%3E+[String] and it will give you as the first hit exactly what you need. (Hoogle is great for beginners who don't know the libraries.) Obviously, this is a real issue; there's no way the compiler could possibly figure out what the right thing to do because there are so many ways to do String->[String] (just consider the specific example of 'lines' - how does it handle Windows v Unix line-endings?). So you have to tell it. The monad issue with the difference between IO [String] and [String] I will leave to others to explain. :) -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091005/597b78be/signature.bin From miguelimo38 at yandex.ru Mon Oct 5 10:36:22 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 10:16:10 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: <4ACA0466.4040406@yandex.ru> > Miguel Mitrofanov, please kindly stop pretending that you KNOW > what is a number, and what is not. Never said that. Sometimes it's debatable. But if you can't figure out a way to multiply things so that it would make some kind of sense - you haven't made them numbers (yet). > The numeric classes in standard Haskell are disgraceful, and the idea > that if something can be added, it is a number is bad. Which is kinda my point. > So, people call "numbers" what they wish, and it is *their* business. I'm not sure what do you mean here. Of course, it's OK to call anything "numbers" provided that you stated explicitly what exactly you would mean by that. But then you have to drop all kind of stuff mathematicians developed for the usual notion of numbers. In the same way, you shouldn't use the "Num" class for your "numbers". On the other hand, people can (ab)use the "Num" class as they wish, and it's their business until they ask a question about it somewhere outside - which makes the business not only theirs. > Pairs (a,b) may be "numbers" in various contexts, for example > (value,derivative) in automatic differentiation. Or (mainTerm,otherOrders) > in some infinitesimal calculus. Or pairs (scalar, 3vector) for quaternions. Or (real, imaginary) for complex numbers. That's right. All these notions are very different - which is why "pairs of numbers" are NOT numbers - but "complex numbers" are, as well as "value-derivative pairs". Isn't that what we have newtypes for? > There are plenty of examples where conversions from integers are legitimate, > but no addition or (*)seem natural. Certainly. I think it's commonplace that numerical classes in Haskell Prelude are not exactly an example of perfect design. Still, it doesn't make it good to abuse classes like "Num" just because we want a fancy plus sign. From miguelimo38 at yandex.ru Mon Oct 5 10:38:10 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 10:17:56 2009 Subject: [Haskell-cafe] apply function arguments in a list In-Reply-To: <4ACA03EB.7020101@alumni.caltech.edu> References: <4ACA03EB.7020101@alumni.caltech.edu> Message-ID: <4ACA04D2.5010502@yandex.ru> t = let [x,y,z] = args in f x y z Michael Mossey wrote: > t = f (args!!0) (args!!1) (args!!2) From miguelimo38 at yandex.ru Mon Oct 5 10:40:28 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 10:20:14 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: <4ACA055C.2030708@yandex.ru> Lennart Augustsson wrote: > And what is a number? Can't say. You know, it's kinda funny to ask a biologist what it means to be alive. > Are complex numbers numbers? Beyond any reasonable doubt. Just like you and me are most certainly alive. From nccb2 at kent.ac.uk Mon Oct 5 10:43:49 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon Oct 5 10:21:32 2009 Subject: [Haskell-cafe] apply function arguments in a list In-Reply-To: <4ACA03EB.7020101@alumni.caltech.edu> References: <4ACA03EB.7020101@alumni.caltech.edu> Message-ID: <4ACA0625.5020900@kent.ac.uk> Michael Mossey wrote: > If I have a list containing the arguments I want to give to a > function, is there a general way to supply those arguments in a > compact syntax? > > In other words, I could have > > args = [1,2,3] > f x y z = ... > > I would write > > t = f (args!!0) (args!!1) (args!!2) > > but there may be a neater, more general syntax. In general, the problem is that you can't guarantee ahead of time that the list will have three elements, so however you write it, you'll turn a compile-time error (wrong number of args to function) into a run-time error (!! says index is invalid). The neatest way is probably: t [x,y,z] = f x y z Which will give a slightly better error if the list is the wrong size. If your function takes many arguments of the same type, perhaps you could generalise it to take a list of arbitrary size, and do away with requiring three arguments? Alternatively, use tuples if you want an easy way to carry the arguments around together: args = (1, 2, 3) f x y z = ... uncurry3 f (x,y,z) = f x y z t = uncurry3 f (uncurry already exists, I think uncurry3 is one you have to add yourself). Neil. From lennart at augustsson.net Mon Oct 5 10:49:03 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Oct 5 10:26:45 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4ACA055C.2030708@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> Message-ID: But complex numbers are just pairs of numbers. So pairs of numbers can obviously be numbers then. On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov wrote: > Lennart Augustsson wrote: >> >> And what is a number? > > Can't say. You know, it's kinda funny to ask a biologist what it means to be > alive. > >> Are complex numbers numbers? > > Beyond any reasonable doubt. Just like you and me are most certainly alive. > From daniel.is.fischer at web.de Mon Oct 5 10:50:20 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Oct 5 10:29:16 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4ACA0117.7080906@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> <4ACA0117.7080906@alumni.caltech.edu> Message-ID: <200910051650.21118.daniel.is.fischer@web.de> Am Montag 05 Oktober 2009 16:22:15 schrieb Michael Mossey: > Eugene Kirpichov wrote: > > [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...] > > return (BoxBounds ...) > > Thanks. > > I'm curious about the idea of "pattern matching in do-statements that can > fail." This particular pattern cannot fail. It can. It won't fail in this particular context, but it's a refutable pattern, that's what counts. Whether or not a pattern matching in a do-block can fail is intrinsic to the pattern. > I read that the "fail" function > was introduced to Monad in order to handle pattern matches that fail, and > that most members of haskell-cafe seem to think that was a mistake---that > MonadZero should have been used instead. I.e., any do-block with a pattern > that can fail should explicitly have a MonadZero class constraint. > > This leads to my question about detecting pattern matches that could fail. > We can easily prove the above pattern will never fail. We can. And we could make the compiler able to prove it, too. > I'm wondering if the compiler infers this. Not worth the hassle. One could make the compiler infer any finite number of special cases, but you can't have an algorithm that can for an arbitrary refutable pattern and an arbitrary monadic action (of appropriate type) decide whether the pattern match in pat <- act will always succeed. > And if a future version of > Haskell dumps "fail" and used MonadZero to replace it, would that > future Haskell compiler need to infer, in all cases, whether a pattern > can fail? Is it simple enough to make that correct inference? Using a refutable pattern would add the MonadZero constraint, while do-blocks with only irrefutable patterns can be had in any Monad. Whether a pattern is refutable or irrefutable is easy to decide (cf. http://haskell.org/onlinereport/exps.html#sect3.17). > > Thanks, > Mike From brad.larsen at gmail.com Mon Oct 5 10:51:39 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Mon Oct 5 10:29:22 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA0466.4040406@yandex.ru> Message-ID: On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov wrote: [...] > Of course, it's OK to call anything "numbers" provided that you stated > explicitly what exactly you would mean by that. But then you have to drop > all kind of stuff mathematicians developed for the usual notion of numbers. > In the same way, you shouldn't use the "Num" class for your "numbers". > > On the other hand, people can (ab)use the "Num" class as they wish, and it's > their business until they ask a question about it somewhere outside - which > makes the business not only theirs. [...] The Num class has `negate' as part of its definition. ?Natural numbers are numbers, but I don't believe there is any sensible definition of `negate' for them. Haskell 98's numeric hierarchy combines many operations which should be separate. ?As further evidence, every bit of Haskell I have seen that does symbolic manipulation of numeric expressions either leaves out instances that would make the syntax more convenient, or else defines partial instances because certain class functions have no sensible definition for symbolic expressions. Sincerely, Brad From lennart at augustsson.net Mon Oct 5 10:56:27 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Oct 5 10:34:08 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA0466.4040406@yandex.ru> Message-ID: Everyone agrees that the Haskell numeric hierarchy is flawed, but I've yet to see a good replacement. On Mon, Oct 5, 2009 at 4:51 PM, Brad Larsen wrote: > On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov > wrote: > [...] >> Of course, it's OK to call anything "numbers" provided that you stated >> explicitly what exactly you would mean by that. But then you have to drop >> all kind of stuff mathematicians developed for the usual notion of numbers. >> In the same way, you shouldn't use the "Num" class for your "numbers". >> >> On the other hand, people can (ab)use the "Num" class as they wish, and it's >> their business until they ask a question about it somewhere outside - which >> makes the business not only theirs. > [...] > > The Num class has `negate' as part of its definition. ?Natural numbers > are numbers, but I don't believe there is any sensible definition of > `negate' for them. > > Haskell 98's numeric hierarchy combines many operations which should > be separate. ?As further evidence, every bit of Haskell I have seen > that does symbolic manipulation of numeric expressions either leaves > out instances that would make the syntax more convenient, or else > defines partial instances because certain class functions have no > sensible definition for symbolic expressions. > > Sincerely, > Brad > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Mon Oct 5 10:55:11 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 10:34:57 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> Message-ID: <4ACA08CF.2030704@yandex.ru> No, they aren't. They are polynomials in one variable "i" modulo i^2+1. Seriously, if you say complex numbers are just pairs of real numbers - you have to agree that double numbers (sorry, don't know the exact English term), defined by (a,b)+(c,d) = (a+c,b+d) (a,b)(c,d) = (ac, ad+bc) are just pairs of real numbers too. After that, you have two choices: a) admit that complex numbers and double numbers are the same - and most mathematicians would agree they aren't - or b) admit that the relation "be the same" is not transitive - which is simply bizarre. Lennart Augustsson wrote: > But complex numbers are just pairs of numbers. So pairs of numbers > can obviously be numbers then. > > On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov wrote: >> Lennart Augustsson wrote: >>> And what is a number? >> Can't say. You know, it's kinda funny to ask a biologist what it means to be >> alive. >> >>> Are complex numbers numbers? >> Beyond any reasonable doubt. Just like you and me are most certainly alive. >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Mon Oct 5 11:02:19 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Oct 5 10:43:16 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: <200910051702.19827.daniel.is.fischer@web.de> Am Montag 05 Oktober 2009 16:29:02 schrieb Job Vranish: > In what way is it not a number? > If there's a natural[1] implementation of fromInteger, good. If there isn't, *don't provide one*. fromInteger _ = error "Not sensible" is better than doing something strange. [1] In the case of residue class rings, you may choose between restricting the range of legitimate arguments for fromInteger or doing a modulo operation on the argument, both ways are natural and meet expectations sufficiently well. > > S?nke Hahn: > btw, I forgot to mention in my first email, but > fromInteger n = (r, r) where r = fromInteger n > is better than: > fromInteger n = (fromInteger n, 0) > as you get a lot of corner cases otherwise. > > I use fromInteger = pure . fromInteger, which when combined with my > Applicative instance, is effectively the same as your: fromInteger n = (r, > r) where r = fromInteger n > > > - Job > > On Mon, Oct 5, 2009 at 9:12 AM, Miguel Mitrofanov wrote: > > S?nke Hahn wrote: > > > > I used to implement > > > >> fromInteger n = (r, r) where r = fromInteger n > >> > >> , but thinking about it, > >> fromInteger n = (fromInteger n, 0) > >> > >> seems very reasonable, too. > > > > Stop pretending something is a number when it's not. From jfredett at gmail.com Mon Oct 5 11:07:30 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 5 10:45:13 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4ACA08CF.2030704@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> <4ACA08CF.2030704@yandex.ru> Message-ID: <4F59BAED-59AB-4AA1-B53E-E905144FE165@gmail.com> Shouldn't the question not be "Is this a number?" but rather "What is a number?" -- I mean, from an abstract point of view, there's really no such thing, right? We have sets of things which we define an operation that has certain properties, and suddenly we start calling them numbers. Are the Symmetric groups -- which you can multiply and divide, but not add -- numbers? If they aren't, why should Z_n be numbers? What _is_ true, is that you can define a notion of addition and multiplication for both complexes and 'double' "numbers", that doesn't mean they are "numbers", rather, it means they are both Rings. Nor does it imply that they must be "the same" They are both rings over the same set of elements (Lets say, RxR), but with different operations. Furthermore, can't you construct the Rational's from the Integers in a similar way as you construct the complexes from the reals (by modding out an ideal/polynomial (resp)) -- I actually don't know for certain, we haven't gotten that far in my Alg. Class yet. :), but my intuition says that it's likely possible. Point is -- there are lots of classes for which you can implement a useful notion of addition in more than one way -- or a useful notion of some other class function (monad stuff for Lists and Ziplists, for example), but that doesn't necessarily mean that the two things are the same structure, right? /Joe On Oct 5, 2009, at 10:55 AM, Miguel Mitrofanov wrote: > No, they aren't. They are polynomials in one variable "i" modulo > i^2+1. > > Seriously, if you say complex numbers are just pairs of real numbers > - you have to agree that double numbers (sorry, don't know the exact > English term), defined by > > (a,b)+(c,d) = (a+c,b+d) > (a,b)(c,d) = (ac, ad+bc) > > are just pairs of real numbers too. After that, you have two > choices: a) admit that complex numbers and double numbers are the > same - and most mathematicians would agree they aren't - or b) admit > that the relation "be the same" is not transitive - which is simply > bizarre. > > > Lennart Augustsson wrote: >> But complex numbers are just pairs of numbers. So pairs of numbers >> can obviously be numbers then. >> On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov > > wrote: >>> Lennart Augustsson wrote: >>>> And what is a number? >>> Can't say. You know, it's kinda funny to ask a biologist what it >>> means to be >>> alive. >>> >>>> Are complex numbers numbers? >>> Beyond any reasonable doubt. Just like you and me are most >>> certainly alive. >>> >> _______________________________________________ >> 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 carette at mcmaster.ca Mon Oct 5 11:11:22 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Mon Oct 5 10:49:37 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA0466.4040406@yandex.ru> Message-ID: <4ACA0C9A.6090106@mcmaster.ca> Lennart Augustsson wrote: > Everyone agrees that the Haskell numeric hierarchy is flawed, but I've > yet to see a good replacement. > That's because the "good replacement" which is mathematically sound would be a real mess to work with -- for exactly the same reason that Functor , Applicative and Monad are unrelated classes. See [1]. In a prototype language I am playing with, my version of Num depends on 15 'previous' classes, and that's likely to increase, not decrease. Jacques [1] http://repetae.net/recent/out/classalias.html From lennart at augustsson.net Mon Oct 5 11:17:26 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Oct 5 10:55:06 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4ACA08CF.2030704@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> <4ACA08CF.2030704@yandex.ru> Message-ID: Complex numbers are just pairs of numbers, and then the various operations on them are defined in a specific way. There may be other ways to define the operations on pairs of numbers that makes sense too. You can also view complex numbers as polynomials if you wish. Or two element lists of numbers. My real point is that you shouldn't tell others what they should regard as numbers and what not. Being a number is in the eye of the beholder. :) On Mon, Oct 5, 2009 at 4:55 PM, Miguel Mitrofanov wrote: > No, they aren't. They are polynomials in one variable "i" modulo i^2+1. > > Seriously, if you say complex numbers are just pairs of real numbers - you > have to agree that double numbers (sorry, don't know the exact English > term), defined by > > (a,b)+(c,d) = (a+c,b+d) > (a,b)(c,d) = (ac, ad+bc) > > are just pairs of real numbers too. After that, you have two choices: a) > admit that complex numbers and double numbers are the same - and most > mathematicians would agree they aren't - or b) admit that the relation "be > the same" is not transitive - which is simply bizarre. > > > Lennart Augustsson wrote: >> >> But complex numbers are just pairs of numbers. ?So pairs of numbers >> can obviously be numbers then. >> >> On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov >> wrote: >>> >>> Lennart Augustsson wrote: >>>> >>>> And what is a number? >>> >>> Can't say. You know, it's kinda funny to ask a biologist what it means to >>> be >>> alive. >>> >>>> Are complex numbers numbers? >>> >>> Beyond any reasonable doubt. Just like you and me are most certainly >>> alive. >>> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From gue.schmidt at web.de Mon Oct 5 11:29:31 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Oct 5 11:08:04 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" Message-ID: Hi all, I'm playing around with finally tagless. Here is the class for my Syntax: class HOAS repr where lam :: (repr a -> repr b) -> repr (a -> b) app :: repr (a -> b) -> repr a -> repr b fix :: (repr a -> repr a) -> repr a let_ :: repr a -> (repr a -> repr b) -> repr b int :: Int -> repr Int add :: repr Int -> repr Int -> repr Int sub :: repr Int -> repr Int -> repr Int mul :: repr Int -> repr Int -> repr Int and here is one instance of that class for semantics. newtype I a = I { unI :: IO a } instance HOAS I where app e1 e2 = I (do e1' <- unI e1 e2' <- unI e2 return $ e1' e2') int i = I (putStrLn ("setting an integer: " ++ show i) >> return i) add e1 e2 = I (do e1' <- unI e1 e2' <- unI e2 putStrLn (printf "adding %d with %d" e1' e2') return $ e1' + e2') sub e1 e2 = I (do e1' <- unI e1 e2' <- unI e2 putStrLn (printf "subtracting %d from %d" e1' e2') return $ e1' - e2') mul e1 e2 = I (do e1' <- unI e1 e2' <- unI e2 putStrLn (printf "multiplying %d with %d" e1' e2') return $ e1' * e2') I'm stuck with the "lam" method, for 2 days now I've been trying to get it right, but failed. Is there a possibility that it isn't even possible? G?nther From jerzy.karczmarczuk at info.unicaen.fr Mon Oct 5 11:33:20 2009 From: jerzy.karczmarczuk at info.unicaen.fr (jerzy.karczmarczuk@info.unicaen.fr) Date: Mon Oct 5 11:11:02 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> Message-ID: L.A. says: > complex numbers are just pairs of numbers. Later : > Being a number is in the eye of the beholder. :) Now, the readers of this forum will with horror witness a discussion about the meaning of the word "just"... American people will call it a discussion about "semantics", and we, European will not understand why this word is used in a pejorative context... "Just pairs" have no natural arithmetic upon them. All the standard set theory will not help in "making numbers", unless we inject the notion of equivalence ? la Gottlob Frege. And this is surely contextual, but perhaps "the eye of the beholder" should be somehow objectivized... BTW. the missing term of M.M. is DUAL NUMBERS. Lennart continues : > Everyone agrees that the Haskell numeric hierarchy is flawed, > but I've yet to see a good replacement. There *are* some "mathematical preludes" for Haskell. There were attempts to emulate the structures of, say, the C.A.S. Magma in FP (I lost the references...) http://www.haskell.org/haskellwiki/Mathematical_prelude_discussion The problem is, that Haskell is a huge factory, people responsible NOW for its evolution have other priorities. But the story has at least 15 years. Jeroen Fokker did something then, I worked on it at the same period. Now Jacques Carette has his own system, and Sergey Mechveliani another one... But other people don't care, so the efforts are atomized. Please, keep cool. Jerzy Karczmarczuk From carette at mcmaster.ca Mon Oct 5 12:06:46 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Mon Oct 5 11:44:58 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: References: Message-ID: <4ACA1996.7060807@mcmaster.ca> It's possible, but it's not nice. You need to be able to "get out of the monad" to make the types match, i.e. lam f = I (return $ \x -> let y = I (return x) in unsafePerformIO $ unI (f y)) The use of IO 'forces' lam to transform its effectful input into an even more effectful result. Actually, same goes for any monad used inside a 'repr'. let_ and fix follow a similar pattern (although you can hide that somewhat by re-using lam if you wish). Jacques G?nther Schmidt wrote: > Hi all, > > I'm playing around with finally tagless. > > Here is the class for my Syntax: > > > class HOAS repr where > lam :: (repr a -> repr b) -> repr (a -> b) > app :: repr (a -> b) -> repr a -> repr b > fix :: (repr a -> repr a) -> repr a > let_ :: repr a -> (repr a -> repr b) -> repr b > > int :: Int -> repr Int > add :: repr Int -> repr Int -> repr Int > sub :: repr Int -> repr Int -> repr Int > mul :: repr Int -> repr Int -> repr Int > > > and here is one instance of that class for semantics. > > > > newtype I a = I { unI :: IO a } > > instance HOAS I where > app e1 e2 = I (do > e1' <- unI e1 > e2' <- unI e2 > return $ e1' e2') > int i = I (putStrLn ("setting an integer: " ++ show i) >> return i) > add e1 e2 = I (do > e1' <- unI e1 > e2' <- unI e2 > putStrLn (printf "adding %d with %d" e1' e2') > return $ e1' + e2') > sub e1 e2 = I (do > e1' <- unI e1 > e2' <- unI e2 > putStrLn (printf "subtracting %d from %d" e1' e2') > return $ e1' - e2') > mul e1 e2 = I (do > e1' <- unI e1 > e2' <- unI e2 > putStrLn (printf "multiplying %d with %d" e1' e2') > return $ e1' * e2') > > > I'm stuck with the "lam" method, for 2 days now I've been trying to > get it right, but failed. > > Is there a possibility that it isn't even possible? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From anton at appsolutions.com Mon Oct 5 12:11:33 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Mon Oct 5 11:49:15 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> Message-ID: <4ACA1AB5.1030405@appsolutions.com> jerzy.karczmarczuk@info.unicaen.fr wrote: > American people will call it a discussion about "semantics", and > we, European will not understand why this word is used in a pejorative > context... "Semantics" *should* be a pejorative word unless it refers to something formally specified, and preferably executable or machine-checkable. Those subtle Contintental critics of informal semantics, namely Derrida, Irigaray, et al, showed us why. From miguelimo38 at yandex.ru Mon Oct 5 12:44:46 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 12:22:29 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> <4ACA08CF.2030704@yandex.ru> Message-ID: <473A3435-A37D-4924-93F2-B730139804FB@yandex.ru> On 5 Oct 2009, at 19:17, Lennart Augustsson wrote: > Complex numbers are just pairs of numbers, What about dual numbers? (Yes, I've remembered the term) Aren't they also just pairs of numbers? > There may be other ways to define the operations on pairs of numbers > that makes sense too. But these aren't the ways to define pairs of numbers, right? > My real point is that you shouldn't tell others what they should > regard as numbers and what not. Suppose somebody asks why his Haskell program doesn't work, and after some interrogation he reveals that he just renamed Program.hs to Program.exe. Shouldn't we tell him NOT to do this? > Being a number is in the eye of the beholder. :) Yes, and some points of view aren't as good as other. That's why we have psychiatric hospitals. > > On Mon, Oct 5, 2009 at 4:55 PM, Miguel Mitrofanov > wrote: >> No, they aren't. They are polynomials in one variable "i" modulo >> i^2+1. >> >> Seriously, if you say complex numbers are just pairs of real >> numbers - you >> have to agree that double numbers (sorry, don't know the exact >> English >> term), defined by >> >> (a,b)+(c,d) = (a+c,b+d) >> (a,b)(c,d) = (ac, ad+bc) >> >> are just pairs of real numbers too. After that, you have two >> choices: a) >> admit that complex numbers and double numbers are the same - and most >> mathematicians would agree they aren't - or b) admit that the >> relation "be >> the same" is not transitive - which is simply bizarre. >> >> >> Lennart Augustsson wrote: >>> >>> But complex numbers are just pairs of numbers. So pairs of numbers >>> can obviously be numbers then. >>> >>> On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov >> > >>> wrote: >>>> >>>> Lennart Augustsson wrote: >>>>> >>>>> And what is a number? >>>> >>>> Can't say. You know, it's kinda funny to ask a biologist what it >>>> means to >>>> be >>>> alive. >>>> >>>>> Are complex numbers numbers? >>>> >>>> Beyond any reasonable doubt. Just like you and me are most >>>> certainly >>>> alive. >>>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> From miguelimo38 at yandex.ru Mon Oct 5 12:46:20 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 12:24:20 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> Message-ID: <2FFE48F2-1487-4933-8331-791BF5F6F6AB@yandex.ru> > "Just pairs" have no natural arithmetic upon them. Exactly my point. > BTW. the missing term of M.M. is DUAL NUMBERS. Remembered this already. Thanks anyway. From lennart at augustsson.net Mon Oct 5 13:06:27 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Oct 5 12:44:08 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: <2FFE48F2-1487-4933-8331-791BF5F6F6AB@yandex.ru> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> <2FFE48F2-1487-4933-8331-791BF5F6F6AB@yandex.ru> Message-ID: OK, "just pairs" have no arithmetic, but one way of defining arithmetic is to treat the pairs as complex numbers. Or as mantissa and exponent. Or as something else. So there's nothing wrong, IMO, to make pairs an instance of Num if you so desire. (Though I'd probably introduce a new type.) On Mon, Oct 5, 2009 at 6:46 PM, Miguel Mitrofanov wrote: >> "Just pairs" have no natural arithmetic upon them. > > Exactly my point. > >> BTW. the missing term of M.M. is DUAL NUMBERS. > > Remembered this already. Thanks anyway. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Mon Oct 5 13:24:37 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 5 13:02:24 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> <2FFE48F2-1487-4933-8331-791BF5F6F6AB@yandex.ru> Message-ID: And I agree that sometimes it can be suitable. But simply "defining an instance of Num" without a single word on the problem one is trying to solve is not just pointless. It's something that should not be done. On 5 Oct 2009, at 21:06, Lennart Augustsson wrote: > OK, "just pairs" have no arithmetic, but one way of defining > arithmetic is to treat the pairs as complex numbers. Or as mantissa > and exponent. Or as something else. So there's nothing wrong, IMO, > to make pairs an instance of Num if you so desire. (Though I'd > probably introduce a new type.) > > On Mon, Oct 5, 2009 at 6:46 PM, Miguel Mitrofanov > wrote: >>> "Just pairs" have no natural arithmetic upon them. >> >> Exactly my point. >> >>> BTW. the missing term of M.M. is DUAL NUMBERS. >> >> Remembered this already. Thanks anyway. >> >> _______________________________________________ >> 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 shahn at cs.tu-berlin.de Mon Oct 5 14:02:52 2009 From: shahn at cs.tu-berlin.de (=?iso-8859-1?q?S=F6nke_Hahn?=) Date: Mon Oct 5 13:40:34 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> Message-ID: <200910052002.52723.shahn@cs.tu-berlin.de> > > On 5 Oct 2009, at 21:06, Lennart Augustsson wrote: > > OK, "just pairs" have no arithmetic, but one way of defining > > arithmetic is to treat the pairs as complex numbers. Or as mantissa > > and exponent. Or as something else. So there's nothing wrong, IMO, > > to make pairs an instance of Num if you so desire. (Though I'd > > probably introduce a new type.) I was looking for one intuitive way of instantiating pairs of numbers as Num. One where i wouldn't have to look in the documentation to remember what (+) does. So considering all these examples of what pairs of numbers could be, i agree with Miguel Mitrofanov: "It's something that should not be done." Two questions remain, i think: 1. How can i have some notion of addition and subtraction for something that i don't want to put in the Num class? That's easy: I could just write a class that defines binary operators (like (+~) and (-~), for example). I don't get the fanciness of (+), but that's okay. 2. How can i use numeric literals to construct values, whose types are not in the Num class? Haskell could provide a class IsNumber (like IsString for string literals). Is that something we would want? BTW, interesting discussion, thanks! S?nke On Monday 05 October 2009 07:24:37 pm Miguel Mitrofanov wrote: > And I agree that sometimes it can be suitable. > > But simply "defining an instance of Num" without a single word on the > problem one > is trying to solve is not just pointless. It's something that should > not be done. > > > > On Mon, Oct 5, 2009 at 6:46 PM, Miguel Mitrofanov > > > > wrote: > > > > >>> "Just pairs" have no natural arithmetic upon them. > >> > >> Exactly my point. > >> > >>> BTW. the missing term of M.M. is DUAL NUMBERS. > >> > >> Remembered this already. Thanks anyway. > >> > >> _______________________________________________ > >> 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 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tphyahoo at gmail.com Mon Oct 5 15:39:15 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Oct 5 15:16:55 2009 Subject: [Haskell-cafe] suggestions for doing date/time values with Data.Generics ? Message-ID: <910ddf450910051239y431a5c66te8a63b174534d462@mail.gmail.com> I want to patch the time package, which I darcs got head on. Goal is to be able to do newtype deriving for UTCTime which I reckon is the base time value, for use in happstack applications state. basically, need instances for UTCTime, for Data and Typeable. ********** on #haskell: I just darcs got time package and attempted to install. cabal install didn't work because missing configure fle. there's a .ac file there, so I tried first autoconf, then cabal install. configure file got created, but failed with config.status: error: cannot find input file: include/HsTimeConfig.h.in. now what? my goal is to patch time package so can do data generics deriving. patch-tag, use System.Time instead? * Berengal shrugs and sighs [12:20] could try that... *** o-regalia (n=o-regali@host-0-130.mimpvbg.clients.pavlovmedia.com) has quit: "Lost terminal" It already has a Serializeable instance defined in one of the happstack modules, so there's probably a Typeable and Data instance somewhere as well patch-tag, unfortunately, UTCTime has a component of a hidden datatype which isn't an instance of Typeable or Data, and since it's not exported it's impossible to create the instance as well If it were exported, it'd be pretty easy hw can I use UTCTime, deriving Typeable and Data? (want to use UTCTime in happstack). http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=4278#a4278 I guess I should have said I'd like to use newtype deriving rather than define instance myself if that's possible. patch-tag, that's possible, but could break other things. The correct solution is to patch the existing package, but that takes time patch-tag, Day, or something. Can't remember off the top of my head *** paolino (n=paolino@87.7.161.162) has quit: "Leaving." Philonous : if you can't implement both operations (satisfying laws), though, it is probably better to make a new class [12:09] Berengal: a package is hidden if when you do :info in ghci, it comes out as fully qualified, right? pity also that newtype deriving doesn't give you a nicer error message like "deriving choked at type blah" patch-tag, it comes fully qualified if it's not imported, so you'll have to try to import it to see if it's really hidden [12:10] ********* Seems like the right thing to do is patch the time package anyway. File Edit Options Buffers Tools Haskell Help {-# LANGUAGE DeriveDataTypeable #-} module TypeableTime where import Data.Time import Data.Data import Data.Generics import Data.Typeable -- doesn't work --data MyUTCTime = MyUTCTime UTCTime -- deriving (Typeable,Data) -- should I work up to UTCTime by doing this...? data MyDay = MyDay {toMyDayModifiedJulianDay :: Integer} deriving (Typeable,Data) newtype MyString = MyString String deriving (Read,Show,Ord,Eq,Typeable,Data) -- should I just modify time package? is this easier? From tphyahoo at gmail.com Mon Oct 5 15:54:33 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Oct 5 15:32:12 2009 Subject: [Haskell-cafe] Re: suggestions for doing date/time values with Data.Generics ? In-Reply-To: <910ddf450910051239y431a5c66te8a63b174534d462@mail.gmail.com> References: <910ddf450910051239y431a5c66te8a63b174534d462@mail.gmail.com> Message-ID: <910ddf450910051254w3901f436odd42e535b49f9c80@mail.gmail.com> fwiw, this s what I'm doing till I figure out a better way: import System.Time data MyTime = MyTime Integer Integer deriving (Typeable,Data) myTimeToClockTime (MyTime a b) = TOD a b myTimeFromClockTime (TOD a b) = MyTime a b and use MyTime in the happstack state. 2009/10/5 Thomas Hartman : > I want to patch the time package, which I darcs got head on. Goal is > to be able to do newtype deriving for UTCTime which I reckon is the > base time value, for use in happstack applications state. > > > basically, need instances for UTCTime, for Data and Typeable. > > ********** > on #haskell: > > I just darcs got time package and attempted to install. > cabal > ? ? ? ? ? install didn't work because missing configure fle. there's > a .ac > ? ? ? ? ? file there, so I tried first autoconf, then cabal > ? ? ? ? ? install. configure file got created, but failed with > ? ? ? ? ? config.status: error: cannot find input file: > ? ? ? ? ? include/HsTimeConfig.h.in. now what? > my goal is to patch time package so can do data generics deriving. > > patch-tag, use System.Time instead? > * Berengal shrugs and sighs ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [12:20] > could try that... > *** o-regalia (n=o-regali@host-0-130.mimpvbg.clients.pavlovmedia.com) > has > ? quit: "Lost terminal" > It already has a Serializeable instance defined in one of > the > ? ? ? ? ?happstack modules, so there's probably a Typeable and Data > instance > ? ? ? ? ?somewhere as well > > > > patch-tag, unfortunately, UTCTime has a component of a > hidden > ? ? ? ? ?datatype which isn't an instance of Typeable or Data, and > since > ? ? ? ? ?it's not exported it's impossible to create the instance as well > If it were exported, it'd be pretty easy > hw can I use UTCTime, deriving Typeable and Data? (want to > use > ? ? ? ? ? UTCTime in happstack). > http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=4278#a4278 > I guess I should have said I'd like to use newtype > deriving rather > ? ? ? ? ? than define instance myself if that's possible. > > > patch-tag, that's possible, but could break other things. > The > ? ? ? ? ?correct solution is to patch the existing package, but that > takes > ? ? ? ? ?time > patch-tag, Day, or something. Can't remember off the top of my head > *** paolino (n=paolino@87.7.161.162) has quit: "Leaving." > Philonous : if you can't implement both operations (satisfying > laws), > ? ? though, it is probably better to make a new class ? ? ? ? ? ? ? ? [12:09] > Berengal: a package is hidden if when you do :info in > ghci, it > ? ? ? ? ? comes out as fully qualified, right? > pity also that newtype deriving doesn't give you a nicer > error > ? ? ? ? ? message like "deriving choked at type blah" > patch-tag, it comes fully qualified if it's not imported, > so you'll > ? ? ? ? ?have to try to import it to see if it's really hidden ? ? ? ?[12:10] > > > ********* > > Seems like the right thing to do is patch the time package anyway. > > > File Edit Options Buffers Tools Haskell Help > {-# LANGUAGE DeriveDataTypeable #-} > module TypeableTime where > > import Data.Time > import Data.Data > import Data.Generics > import Data.Typeable > > -- doesn't work > --data MyUTCTime = MyUTCTime UTCTime > -- ? deriving (Typeable,Data) > > -- should I work up to UTCTime by doing this...? > data MyDay = MyDay {toMyDayModifiedJulianDay :: Integer} > ?deriving (Typeable,Data) > > newtype MyString = MyString String > ?deriving (Read,Show,Ord,Eq,Typeable,Data) > > -- should I just modify time package? is this easier? > From p.f.moore at gmail.com Mon Oct 5 16:05:50 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Mon Oct 5 15:43:29 2009 Subject: [Haskell-cafe] Haskell Platform - changing the global install dir Message-ID: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> I've installed the Haskell Platform to a non-default location (D:\Apps\Haskell) to avoid some of the Win7 funniness over writing to C:\Program Files. However, even though I've done this, the cabal global install directory is still C:\Program Files\haskell. This has been added to my PATH and is used by default. Is there a way I could have specified that I want the global install directory in D:\Apps\Haskell? I guess I could hack my cabal\config file (and presumably change PATH) but that seems a bit ugly. Is the use of Program Files even when the install was to somewhere else a bug? It's not a big deal - I can easily stick to user installs for now. Thanks, Paul. From lemming at henning-thielemann.de Mon Oct 5 16:14:02 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Oct 5 15:50:55 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <200910051440.32119.shahn@cs.tu-berlin.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> Message-ID: <4ACA538A.2010802@henning-thielemann.de> S?nke Hahn schrieb: > Hi! > > I often stumble upon 2- (or 3-) dimensional numerical data types like > > (Double, Double) > > or similar self defined ones. I like the idea of creating instances for Num for > these types. The meaning of (+), (-) and negate is clear and very intuitive, i > think. I don't feel sure about (*), abs, signum and fromInteger. I used to > implement > > fromInteger n = (r, r) where r = fromInteger n > > , but thinking about it, > > fromInteger n = (fromInteger n, 0) > > seems very reasonable, too. > > Any thoughts on that? How would you do it? I use NumericPrelude that has more fine grained type classes. E.g. (+) is in Additive and (*) is in Ring. http://hackage.haskell.org/package/numeric-prelude From p.f.moore at gmail.com Mon Oct 5 16:20:05 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Mon Oct 5 15:57:43 2009 Subject: [Haskell-cafe] System.Random.Mersenne - no randomR variants Message-ID: <79990c6b0910051320h7ea3fa8dsa7c13712488878b@mail.gmail.com> I notice that System.Random.Mersenne has no randomR variants. Is there a reason for this, or is it just an oversight? It makes porting code from System.Random a little more complicated than it needs to be. I know it's possible to write a function mapping a Double (or other value, as appropriate) to a range, effectively replacing randomR, but it's fiddly to get the edge cases right. A standard implementation would be helpful. Paul From dons at galois.com Mon Oct 5 16:28:20 2009 From: dons at galois.com (Don Stewart) Date: Mon Oct 5 16:06:01 2009 Subject: [Haskell-cafe] System.Random.Mersenne - no randomR variants In-Reply-To: <79990c6b0910051320h7ea3fa8dsa7c13712488878b@mail.gmail.com> References: <79990c6b0910051320h7ea3fa8dsa7c13712488878b@mail.gmail.com> Message-ID: <20091005202820.GO16378@whirlpool.galois.com> p.f.moore: > I notice that System.Random.Mersenne has no randomR variants. Is there > a reason for this, or is it just an oversight? It makes porting code > from System.Random a little more complicated than it needs to be. I > know it's possible to write a function mapping a Double (or other > value, as appropriate) to a range, effectively replacing randomR, but > it's fiddly to get the edge cases right. A standard implementation > would be helpful. Basically, to use the type class interface defined in System.Random, you will suffer a 100x decrease in performance, as the instances all convert via Integer. Rather than give people a surprise, I chose not to implement that interface. -- Don From p.f.moore at gmail.com Mon Oct 5 16:48:20 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Mon Oct 5 16:26:00 2009 Subject: [Haskell-cafe] System.Random.Mersenne - no randomR variants In-Reply-To: <20091005202820.GO16378@whirlpool.galois.com> References: <79990c6b0910051320h7ea3fa8dsa7c13712488878b@mail.gmail.com> <20091005202820.GO16378@whirlpool.galois.com> Message-ID: <79990c6b0910051348i2aa065aam6c763fcc5a8c0952@mail.gmail.com> 2009/10/5 Don Stewart : > p.f.moore: >> I notice that System.Random.Mersenne has no randomR variants. Is there >> a reason for this, or is it just an oversight? It makes porting code >> from System.Random a little more complicated than it needs to be. I >> know it's possible to write a function mapping a Double (or other >> value, as appropriate) to a range, effectively replacing randomR, but >> it's fiddly to get the edge cases right. A standard implementation >> would be helpful. > > Basically, to use the type class interface defined in System.Random, you > will suffer a 100x decrease in performance, as ?the instances all > convert via Integer. > > Rather than give people a surprise, I chose not to implement that > interface. Sounds fair enough :-) Excuse my ignorance, but although System.Random uses Integer, why can't your implementation work with Int and other fast types? Is this something to do with how classes work? Also, a minor documentation question - the documentation for getStdRandom seems confused (or I am!): getStdRandom :: (MTGen -> IO a) -> IO a Source Uses the supplied function to get a value from the current global random generator, and updates the global generator with the new generator returned by the function. For example, rollDice gets a random integer between 1 and 6: rollDice :: IO Int rollDice = getMTRandom (randomR (1,6)) Is this right? It seems to imply there is a way to use randomR. If I did, would performance be impacted as you mention above? Thanks, and sorry for the dumb questions. Paul. From gue.schmidt at web.de Mon Oct 5 16:49:13 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Oct 5 16:26:55 2009 Subject: [Haskell-cafe] Designing a DSL? In-Reply-To: <0DFADF77-10EA-4CFA-B9AF-7E49965FE1CD@swierstra.net> References: <4AC6485F.4050200@gmail.com> <0DFADF77-10EA-4CFA-B9AF-7E49965FE1CD@swierstra.net> Message-ID: Hello Doaitse, thank you very much! Best regards G?nther From gue.schmidt at web.de Mon Oct 5 16:50:22 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Oct 5 16:28:01 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: <4ACA1996.7060807@mcmaster.ca> References: <4ACA1996.7060807@mcmaster.ca> Message-ID: Hello Jacques, thanks, that is disappointing in some way, guess I still have a lot to learn. G?nther Am 05.10.2009, 18:06 Uhr, schrieb Jacques Carette : > It's possible, but it's not nice. You need to be able to "get out of > the monad" to make the types match, i.e. > lam f = I (return $ \x -> let y = I (return x) in > unsafePerformIO $ unI (f y)) > > The use of IO 'forces' lam to transform its effectful input into an even > more effectful result. Actually, same goes for any monad used inside a > 'repr'. > > let_ and fix follow a similar pattern (although you can hide that > somewhat by re-using lam if you wish). > > Jacques > > G?nther Schmidt wrote: >> Hi all, >> >> I'm playing around with finally tagless. >> >> Here is the class for my Syntax: >> >> >> class HOAS repr where >> lam :: (repr a -> repr b) -> repr (a -> b) >> app :: repr (a -> b) -> repr a -> repr b >> fix :: (repr a -> repr a) -> repr a >> let_ :: repr a -> (repr a -> repr b) -> repr b >> >> int :: Int -> repr Int >> add :: repr Int -> repr Int -> repr Int >> sub :: repr Int -> repr Int -> repr Int >> mul :: repr Int -> repr Int -> repr Int >> >> >> and here is one instance of that class for semantics. >> >> >> >> newtype I a = I { unI :: IO a } >> >> instance HOAS I where >> app e1 e2 = I (do >> e1' <- unI e1 >> e2' <- unI e2 >> return $ e1' e2') >> int i = I (putStrLn ("setting an integer: " ++ show i) >> return i) >> add e1 e2 = I (do >> e1' <- unI e1 >> e2' <- unI e2 >> putStrLn (printf "adding %d with %d" e1' e2') >> return $ e1' + e2') >> sub e1 e2 = I (do >> e1' <- unI e1 >> e2' <- unI e2 >> putStrLn (printf "subtracting %d from %d" e1' e2') >> return $ e1' - e2') >> mul e1 e2 = I (do >> e1' <- unI e1 >> e2' <- unI e2 >> putStrLn (printf "multiplying %d with %d" e1' e2') >> return $ e1' * e2') >> >> >> I'm stuck with the "lam" method, for 2 days now I've been trying to get >> it right, but failed. >> >> Is there a possibility that it isn't even possible? >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From chris at eidhof.nl Mon Oct 5 16:57:39 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Oct 5 16:35:19 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <200910051242.58088.frank@geoinfo.tuwien.ac.at> References: <20091002143236.681743241FC@www.haskell.org> <200910051242.58088.frank@geoinfo.tuwien.ac.at> Message-ID: <2B0578B5-A120-4920-82E6-9BED2EF58C0F@eidhof.nl> That sounds really interesting, it would be great if you could share some of your work by putting it on hackage or posting a link to the repository! -chris On 5 okt 2009, at 12:42, Andrew U. Frank wrote: > writing a gui is a mess (independent of wx or gtk) - too much detail > is shown > and not enough abstraction is done. haskell can help. > > i have written an experimental way of producing the GUI > automatically with a > description of the semantics of the types and operations involved (a > la > ontology, evnetually comparable what protege produces). > the input is a descriptionof the entity ypes, the fields used, the > functional > dependencies between the fiels, plus the operations used. > the division in screens and their layout. > > the rest ist automatic. > the result is a GUI (with preferably gtk but i had also a wx version > running). > > the ideas were inspired by eliot conal's work and wxgeneric, which > seemed for > administrative applications either too restricted or to specific. > > if somebody wants to try it out for his application, please write > frank@geoinfo.tuwien.ac.at > > (there is not much documentation and the code is not yet completely > clean - > testing by somebody else would be very valuable!) > > andrew > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From shahn at cs.tu-berlin.de Mon Oct 5 17:20:13 2009 From: shahn at cs.tu-berlin.de (Soenke Hahn) Date: Mon Oct 5 16:57:58 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <4ACA538A.2010802@henning-thielemann.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4ACA538A.2010802@henning-thielemann.de> Message-ID: <200910052320.13075.shahn@cs.tu-berlin.de> On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote: > S?nke Hahn schrieb: > > Hi! > > > > I often stumble upon 2- (or 3-) dimensional numerical data types like > > > > (Double, Double) > > > > or similar self defined ones. I like the idea of creating instances for > > Num for these types. The meaning of (+), (-) and negate is clear and very > > intuitive, i think. I don't feel sure about (*), abs, signum and > > fromInteger. I used to implement > > > > fromInteger n = (r, r) where r = fromInteger n > > > > , but thinking about it, > > > > fromInteger n = (fromInteger n, 0) > > > > seems very reasonable, too. > > > > Any thoughts on that? How would you do it? > > I use NumericPrelude that has more fine grained type classes. E.g. (+) > is in Additive and (*) is in Ring. > > http://hackage.haskell.org/package/numeric-prelude > That is pretty cool, thanks. How do your import statements look like, when you use numeric-prelude? Mine look a bit ugly: import Prelude hiding ((+), (-), negate) import Algebra.Additive ((+), (-), negate) S?nke From carette at mcmaster.ca Mon Oct 5 17:33:29 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Mon Oct 5 17:11:37 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: References: <4ACA1996.7060807@mcmaster.ca> Message-ID: <4ACA6629.4090801@mcmaster.ca> BTW, here is a more symmetric version of the same code: lam f = I . return $ unsafePerformIO . unI . f . I . return which has a very clear pattern of lam f = embed $ extract . f. embed where 'embed' is often called "return". Implementations of lam in "tagless final" style tend to follow the above pattern of embed/extract, each specialized to the particular repr implementation. In some cases, one only needs a "context-sensitive" extract, i.e. an extract which is only valid in the context of an outer 'embed'. The most important example is code-generation in metaocaml where the 'compiler' version of lam reads let lam f = . .~(f ..)>. where the .~ does an extract -- but *only* in the context of a surrounding code bracket (i.e. .< >. ). If there is such a context-sensitive "extract" for the IO monad, i.e. something which allows you to pretend you've got a result in IO only valid *inside* IO, then you can use that to write a nicer lam. I tried all the obvious things with monadic operators to get this done, but did not succeed in the time I had. Maybe Oleg or Ken can. So don't give up hope quite yet! Jacques G?nther Schmidt wrote: > Hello Jacques, > > thanks, that is disappointing in some way, guess I still have a lot to > learn. > > G?nther > > > Am 05.10.2009, 18:06 Uhr, schrieb Jacques Carette : > >> It's possible, but it's not nice. You need to be able to "get out of >> the monad" to make the types match, i.e. >> lam f = I (return $ \x -> let y = I (return x) in >> unsafePerformIO $ unI (f y)) >> >> The use of IO 'forces' lam to transform its effectful input into an >> even more effectful result. Actually, same goes for any monad used >> inside a 'repr'. >> >> let_ and fix follow a similar pattern (although you can hide that >> somewhat by re-using lam if you wish). >> >> Jacques From tdchayes at pacbell.net Mon Oct 5 17:45:23 2009 From: tdchayes at pacbell.net (Terry Hayes) Date: Mon Oct 5 17:23:04 2009 Subject: [Haskell-cafe] I/O Haskell question In-Reply-To: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> References: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> Message-ID: <740415.60241.qm@web81501.mail.mud.yahoo.com> I found the handling of (IO t) by the interpreter (GHCI in my case) to be somewhat confusing. As pointed out below, I can type: readFile "bla" :: IO String and GHCI happily displays the contents of the file. However neither of the following work print $ readFile "bla" putStr $ readFile "bla" In other words, GHCI seems perfectly willing to "unwrap" a type (IO t) and display it (assuming Show t). This bit of helpfulness may just confuse us novice users by allowing us to stray from the correct way to deal with wrapped types (monads). content <- readFile "bla" print content putStr content Terry ________________________________ From: Maria Boghiu To: haskell-cafe@haskell.org Sent: Monday, October 5, 2009 6:48:56 AM Subject: [Haskell-cafe] I/O Haskell question Hey. I'm trying to configure Xmonad, the window manager. for this purpose, I'm trying to read the workspaces variable in the code below from file. As you can see, I do workspaces = readWS where readWS = do l <- readFile "~/bla" return l I get an error saying I am mismatching types IO [String] and [String]. But I thought that once one does l <- readFile "~/bla", l is the a string or, in this case, a String list. If I run that line in prelude it seems to be working fine, prints the content of the file "~/bla" on screen (though I'm not sure if as a String or as a list of Strings, i.e. [String]) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091005/568a974e/attachment.html From bob.atkey at ed.ac.uk Mon Oct 5 17:42:53 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Mon Oct 5 17:23:27 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: References: <4ACA1996.7060807@mcmaster.ca> Message-ID: <1254778973.3675.42.camel@bismuth> Hi G?nther, The underlying problem with the implementation of 'lam' is that you have to pick an evaluation order for the side effects you want in the semantics of your embedded language. The two obvious options are call-by-name and call-by-value. The tricky point is that the types of the embedded language cannot be interpreted directly as Haskell types wrapped in a monad. You need to either take the call-by-name or the call-by-value interpretation of types: For CBN: [[ Int ]] = IO Int [[ A -> B ]] = [[ A ]] -> [[ B ]] For CBV: [[ Int ]] = Int [[ A -> B ]] = [[ A ]] -> IO [[ B ]] (obviously, there is nothing special about the IO monad here, or in the rest of this email: we could replace it with any other monad). To implement the translation of embedded language types to Haskell types in Haskell we use type families. Here is the code for call-by-name: > module CBN where First of all, we define some dummy types so that we have a different representation of types in the embedded language than those in the meta-language, and we don't get confused: > data IntT > data a :-> b > infixr 5 :-> Now we give the definition of the higher-order abstract syntax of our embedded language: > class HOAS exp where > lam :: (exp a -> exp b) -> exp (a :-> b) > app :: exp (a :-> b) -> exp a -> exp b > > int :: Int -> exp IntT > add :: exp IntT -> exp IntT -> exp IntT This is as in your definition, except I have used the different type names to highlight the distinction between embedded and meta-language types. Next, we give the CBN semantics for the types, using the definition above, with a type family. > type family Sem a :: * > type instance Sem IntT = IO Int > type instance Sem (a :-> b) = Sem a -> Sem b Now we can give an instance of the syntax's type class, that translates a piece of embedded code into its denotational semantics. > newtype S a = S { unS :: Sem a } > instance HOAS S where > int = S . return > add (S x) (S y) = S $ do a <- x > b <- y > putStrLn "Adding" > return (a + b) > > lam f = S (unS . f . S) > app (S x) (S y) = S (x y) As an example, we can give a term and see what happens when we evaluate it: > let_ :: HOAS exp => exp a -> (exp a -> exp b) -> exp b > let_ x y = (lam y) `app` x > t :: HOAS exp => exp IntT > t = (lam $ \x -> let_ (x `add` x) $ \y -> y `add` y) `app` int 10 Evaluating 'unS t' in GHCi gives the output: Adding Adding Adding 40 Note that the add operation is invoked three times: the "x `add` x" that is let-bound is evaluated twice. The second option is call-by-value. This is a bit more interesting because we have to change the syntax of the embedded language to deal with the different substitution rules for CBV. > module CBV where Again, we use a different representation for embedded-language types: > data IntT > data a :-> b > infixr 5 :-> There is a difference in the syntax between CBN and CBV that is not always obvious from the usual paper presentations. There is a split between pieces of syntax that are "values" and those that are "computations". Values do not have side-effects, while computations may. In this presentation, I have chosen that the only values are variables, while everything else is a computation. To represent this split, we use a multi-parameter type class. Note that the technique of using multi-parameter type classes is generally useful for representing abstract syntaxes in the HOAS style with multiple mutually defined syntactic categories. > class HOAS exp val | exp -> val, val -> exp where > val :: val a -> exp a > > lam :: (val a -> exp b) -> exp (a :-> b) > app :: exp (a :-> b) -> exp a -> exp b > > int :: Int -> exp IntT > add :: exp IntT -> exp IntT -> exp IntT The 'val' operation injects values into computations: this will be interpreted by the 'return' of the monad. We now give the semantics of types for CBV, following the definition above: > type family Sem a :: * > type instance Sem IntT = Int > type instance Sem (a :-> b) = Sem a -> IO (Sem b) We need two newtypes for the two different syntactic categories. Values are interpeted by 'SV', and are just pure values; computations are interpreted by wrapping them in the monad. > newtype SV a = SV { unSV :: Sem a } > newtype SC a = SC { unSC :: IO (Sem a) } Now we can define the semantics of the syntax in terms of these types: > instance HOAS SC SV where > val = SC . return . unSV > > lam f = SC $ return (unSC . f . SV) > app (SC x) (SC y) = SC $ do f <- x; a <- y; f a > > int i = SC $ return i > add (SC x) (SC y) = SC $ do a <- x > b <- y > putStrLn "Adding" > return (a + b) The same example term is expressed in CBV as follows: > let_ :: HOAS exp val => exp a -> (val a -> exp b) -> exp b > let_ x y = (lam y) `app` x > t :: HOAS exp val => exp IntT > t = (lam $ \x -> let_ (val x `add` val x) > $ \y -> val y `add` val y) `app` int 10 Running 'unSC t' in GHCi gives the output: Adding Adding 40 Note that the add operation is only invoked twice this time: the let-bound expression is evaluated to a value, and then this value is used twice in the body of the let. The other obvious evaluation strategy is call-by-need, as used by Haskell itself, but I don't know if it is possible to implement this. I guess it may be possible using the ST monad as the mutable storage of thunks. Hope this was helpful. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From bos at serpentine.com Mon Oct 5 17:55:47 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Oct 5 17:33:26 2009 Subject: [Haskell-cafe] Mutable data within a (non-IO) monad In-Reply-To: <1254560245.5687.48.camel@localhost> References: <96117E14-B165-4501-9743-E2B7530D31AC@phys.washington.edu> <0F2425EC-11BE-4235-977A-5A180F7F85A9@phys.washington.edu> <1254560245.5687.48.camel@localhost> Message-ID: On Sat, Oct 3, 2009 at 1:57 AM, Duncan Coutts wrote: > > Internally, each time you demand the next random number, it is mutating > the internal ST array. This is the same thing that the Statistics.RandomVariate code in the statistics package does, and it can be very fast: http://www.serpentine.com/blog/2009/09/19/a-new-pseudo-random-number-generator-for-haskell/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091005/023c4880/attachment.html From lemming at henning-thielemann.de Mon Oct 5 17:58:28 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Oct 5 17:35:38 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <200910052320.13075.shahn@cs.tu-berlin.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4ACA538A.2010802@henning-thielemann.de> <200910052320.13075.shahn@cs.tu-berlin.de> Message-ID: On Mon, 5 Oct 2009, Soenke Hahn wrote: > On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote: >> >> I use NumericPrelude that has more fine grained type classes. E.g. (+) >> is in Additive and (*) is in Ring. >> >> http://hackage.haskell.org/package/numeric-prelude >> > > That is pretty cool, thanks. How do your import statements look like, when you > use numeric-prelude? Mine look a bit ugly: > > import Prelude hiding ((+), (-), negate) > import Algebra.Additive ((+), (-), negate) {-# LANGUAGE NoImplicitPrelude #-} or import Prelude () and import qualified Algebra.Additive as Additive (e.g. for Additive.C) import NumericPrelude import PreludeBase The first form is necessary if you use number literals, what is the case for you I think. From shahn at cs.tu-berlin.de Mon Oct 5 18:39:34 2009 From: shahn at cs.tu-berlin.de (Soenke Hahn) Date: Mon Oct 5 18:17:18 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910052320.13075.shahn@cs.tu-berlin.de> Message-ID: <200910060039.34814.shahn@cs.tu-berlin.de> On Monday 05 October 2009 11:58:28 pm Henning Thielemann wrote: > On Mon, 5 Oct 2009, Soenke Hahn wrote: > > On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote: > >> I use NumericPrelude that has more fine grained type classes. E.g. (+) > >> is in Additive and (*) is in Ring. > >> > >> http://hackage.haskell.org/package/numeric-prelude > > > > That is pretty cool, thanks. How do your import statements look like, > > when you use numeric-prelude? Mine look a bit ugly: > > > > import Prelude hiding ((+), (-), negate) > > import Algebra.Additive ((+), (-), negate) > > {-# LANGUAGE NoImplicitPrelude #-} > > or > > import Prelude () > > and > > import qualified Algebra.Additive as Additive (e.g. for Additive.C) > import NumericPrelude > import PreludeBase > > The first form is necessary if you use number literals, what is the case > for you I think. > Thanks. If you want to use number literals, you have to implement an instance for Algebra.Ring.C, if i understand correctly. Is there any special reason, why fromInteger is a method of Algebra.Ring.C? S?nke From dave at zednenem.com Mon Oct 5 19:22:59 2009 From: dave at zednenem.com (David Menendez) Date: Mon Oct 5 19:00:40 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: <1254778973.3675.42.camel@bismuth> References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> Message-ID: <49a77b7a0910051622q36130cdaxd54b6a2c49bfc30e@mail.gmail.com> 2009/10/5 Robert Atkey : > Hi G?nther, > > The underlying problem with the implementation of 'lam' is that > you have to pick an evaluation order for the side effects you want in > the semantics of your embedded language. The two obvious options are > call-by-name and call-by-value. I wonder how easily one can provide both, like in Algol. > The other obvious evaluation strategy is call-by-need, as used by > Haskell itself, but I don't know if it is possible to implement this. I > guess it may be possible using the ST monad as the mutable storage of > thunks. Perhaps something along the lines of "Purely Functional Lazy Non-deterministic Programming"? Obviously, doing a deterministic version is simpler. You can probably get away with representing values as simple self-evaluating thunks. data Thunk s a = STRef s (Either a (ST s a)) evalThunk :: Thunk s a -> ST s a evalThunk r = readSTRef r >>= either return update where update m = m >>= \x -> writeSTRef r (Left x) >> return x -- Dave Menendez From flopticalogic at gmail.com Mon Oct 5 19:56:50 2009 From: flopticalogic at gmail.com (Floptical Logic) Date: Mon Oct 5 19:34:29 2009 Subject: [Haskell-cafe] Generalizing IO Message-ID: The code below is a little interactive program that uses some state. It uses StateT with IO to keep state. My question is: what is the best way to generalize this program to work with any IO-like monad/medium? For example, I would like the program to function as it does now using stdin but I would also like it to function over IRC using the Net monad from . Thanks for any suggestions. -- begin code -- import Control.Monad import Control.Monad.State import Data.List data PD = PD { pdCount :: Int , pdList :: [String] } deriving (Show) type PDState = StateT PD IO main = runStateT loop (PD { pdCount = 0, pdList = [] }) loop :: PDState a loop = forever $ do cmd <- liftIO getLine runCmd cmd runCmd :: String -> PDState () runCmd "Inc" = increment runCmd "PrintCount" = liftIO . print =<< getCount runCmd "PrintList" = liftIO . print =<< getList runCmd str | "Add " `isPrefixOf` str = addToList $ drop 4 str runCmd _ = return () getCount :: PDState Int getCount = pdCount `liftM` get getList :: PDState [String] getList = pdList `liftM` get increment :: PDState () increment = modify $ \st -> st { pdCount = pdCount st + 1 } addToList :: String -> PDState () addToList str = modify $ \st -> st { pdList = pdList st ++ [str]} -- end code -- From dave at zednenem.com Mon Oct 5 20:23:35 2009 From: dave at zednenem.com (David Menendez) Date: Mon Oct 5 20:01:15 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: Message-ID: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> On Mon, Oct 5, 2009 at 7:56 PM, Floptical Logic wrote: > The code below is a little interactive program that uses some state. > It uses StateT with IO to keep state. ?My question is: what is the > best way to generalize this program to work with any IO-like > monad/medium? ?For example, I would like the program to function as it > does now using stdin but I would also like it to function over IRC > using the Net monad from > . ?Thanks for > any suggestions. Instead of specifying the monad implementation, specify the interface. That is, you are using state operations (from MonadState) and IO operations (from MonadIO). Try removing all the type signatures that mention PDState and see what you get. E.g., loop :: (MonadState PD m, MonadIO m) => m a -- Dave Menendez From gcross at phys.washington.edu Mon Oct 5 20:27:33 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Oct 5 20:05:15 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: Message-ID: <49882DCE-185A-4E0C-96BE-D3EDB7159CDB@phys.washington.edu> My thought is that you could simply drop the IO from your type definition, type PDState = StateT PD You will need to change all of your type signature from "PDState " to "PDState m " to make them all polymorphic over the choice of monad. Then all you should need to do is to generalize the loop function to accept a line-fetching monad from the user: loop :: m a -> PDState m a loop getLine = forever $ do cmd <- lift getLine runCmd cmd Note how liftIO was changed to lift, which works for any monad and comes built-in with the StateT monad. Hope this helps! Cheers, Greg On Oct 5, 2009, at 4:56 PM, Floptical Logic wrote: > The code below is a little interactive program that uses some state. > It uses StateT with IO to keep state. My question is: what is the > best way to generalize this program to work with any IO-like > monad/medium? For example, I would like the program to function as it > does now using stdin but I would also like it to function over IRC > using the Net monad from > . Thanks for > any suggestions. > > -- begin code -- > import Control.Monad > import Control.Monad.State > import Data.List > > data PD = PD > { pdCount :: Int > , pdList :: [String] > } deriving (Show) > > type PDState = StateT PD IO > > main = runStateT loop (PD { pdCount = 0, pdList = [] }) > > loop :: PDState a > loop = forever $ do > cmd <- liftIO getLine > runCmd cmd > > runCmd :: String -> PDState () > runCmd "Inc" = increment > runCmd "PrintCount" = liftIO . print =<< getCount > runCmd "PrintList" = liftIO . print =<< getList > runCmd str | "Add " `isPrefixOf` str = addToList $ drop 4 str > runCmd _ = return () > > getCount :: PDState Int > getCount = pdCount `liftM` get > > getList :: PDState [String] > getList = pdList `liftM` get > > increment :: PDState () > increment = modify $ \st -> st { pdCount = pdCount st + 1 } > > addToList :: String -> PDState () > addToList str = modify $ \st -> st { pdList = pdList st ++ [str]} > -- end code -- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From the.dead.shall.rise at gmail.com Mon Oct 5 22:47:02 2009 From: the.dead.shall.rise at gmail.com (Mikhail Glushenkov) Date: Mon Oct 5 22:25:05 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> Message-ID: Hi Paul, Paul Moore gmail.com> writes: > Is there a way I could have specified that I want the global install > directory in D:\Apps\Haskell? I guess I could hack my cabal\config > file (and presumably change PATH) but that seems a bit ugly. A bit ugly? Why? That's precisely what the config files are for. > Is the > use of Program Files even when the install was to somewhere else a > bug? Not really, the Windows installer just doesn't tinker with the default cabal-install install location. There are plans, though, to implement an "install only for the current user" mode for the next release. From ccshan at post.harvard.edu Mon Oct 5 22:06:25 2009 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Mon Oct 5 22:38:15 2009 Subject: [Haskell-cafe] Re: Finally tagless - stuck with implementation of?"lam" References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> Message-ID: <1alqp6-d3p.ln1@mantle.rutgers.edu> Robert Atkey wrote in article <1254778973.3675.42.camel@bismuth> in gmane.comp.lang.haskell.cafe: > To implement the translation of embedded language types to Haskell types > in Haskell we use type families. This type-to-type translation is indeed the crux of the trickiness. By the way, Section 4.3 of our (JFP) paper describes how to follow such a translation without type families. If I were to avoid type families in Haskell, I would make Symantics into a multiparameter type class class HOAS repr arrow int where lam :: (repr a -> repr b) -> repr (arrow a b) app :: repr (arrow a b) -> repr a -> repr b fix :: (repr a -> repr a) -> repr a let_ :: repr a -> (repr a -> repr b) -> repr b int :: int -> repr int add :: repr int -> repr int -> repr int sub :: repr int -> repr int -> repr int mul :: repr int -> repr int -> repr int > The underlying problem with the implementation of 'lam' is that > you have to pick an evaluation order for the side effects you want in > the semantics of your embedded language. The two obvious options are > call-by-name and call-by-value. (Section 5 of our (JFP) paper addresses both CBN and CBV.) -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig Here's a souvenir of it. He made me write this down so I'd remember to get this book and read it. Transcendent Speculations on Apparent Design in the Fate of the Individual, that's a mouthful isn't it. I wrote this down at gun-point. - Gaddis From joerg.rudnick at t-online.de Mon Oct 5 23:09:26 2009 From: joerg.rudnick at t-online.de (=?ISO-8859-1?Q?J=F6rg_Roman_Rudnick?=) Date: Mon Oct 5 22:47:22 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <4AC29FB2.2060404@t-online.de> Message-ID: <4ACAB4E6.7090503@t-online.de> Hi Alberto, you are working on *second order scalibility*?? Great. May I regard you a one of the first of a breed of Haskell business evangelists?? ;-)) Somebody stated here - sorry, the name's missing - the relevance of Hackage being diminuished by the great amount of *scientific* libraries, no joke... Personally, I don't think Haskell should become like Java & Co. So for at least for two reasons, I see at least two reasons to speak open about what you are seemingly interested: o to support Haskell library developers to better realize the value of their work, and teams intending software projects in the non-standard areas to realize advantages of using Haskell, once they are given o to prevent conflicts, when Haskell grows economically more successful, and allowing a harmonious transition between both cultures Keep on the work ;-) Nick Alberto G. Corona wrote: > >> > This reminds me of the whole agent thing -- pretty much dominated > by Java (e.g., Jade, Jason, Jack) nowadays --, for which I would > bet lots things are done more straigthforward using Haskell -- > especially those parts the Java coders are usually proud of... > Let's maybe speak of *second order scalability*: > > As first order scalability would rather be a matter in space time > load increased by repetitions, the concern of second order > scalability would be more about a *fractal* expansion of concepts > like a *closure* -- Haskell, already in a vivid exchange with > interactive theorem proving (e.g. Coq adopts type classes from > Haskell and dependent types vice versa) seems excellently > prepared... :-) > > > Interesting. I?m working in something like second order scalability. > Instead of brute performance by redundancy, high speed networks and > fast disks, scalability can be achieved by looking at the properties > of the data. > > > I ever tended to say financial applications are especially prone > to be boring -- the prototype of repetitive IT, even for strategy > the stupid 'traffic lights cockpits' or OLAP(!) ... But this > problem is rather supply driven to me. > > For sure. This is supply driven. There are a lack of new ideas mainly > because the technology is low level and obsolete. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091005/353ec8c8/attachment.html From dons at galois.com Mon Oct 5 23:10:54 2009 From: dons at galois.com (Don Stewart) Date: Mon Oct 5 22:48:42 2009 Subject: [Haskell-cafe] Re: Finally tagless - stuck with implementation of?"lam" In-Reply-To: <1alqp6-d3p.ln1@mantle.rutgers.edu> References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> <1alqp6-d3p.ln1@mantle.rutgers.edu> Message-ID: <20091006031054.GB18549@whirlpool.galois.com> ccshan: > class HOAS repr arrow int where > > lam :: (repr a -> repr b) -> repr (arrow a b) > app :: repr (arrow a b) -> repr a -> repr b > fix :: (repr a -> repr a) -> repr a > let_ :: repr a -> (repr a -> repr b) -> repr b > > int :: int -> repr int > add :: repr int -> repr int -> repr int > sub :: repr int -> repr int -> repr int > mul :: repr int -> repr int -> repr int > > > The underlying problem with the implementation of 'lam' is that > > you have to pick an evaluation order for the side effects you want in > > the semantics of your embedded language. The two obvious options are > > call-by-name and call-by-value. > > (Section 5 of our (JFP) paper addresses both CBN and CBV.) Do you have a link to the paper? -- Don From joerg.rudnick at t-online.de Mon Oct 5 23:27:32 2009 From: joerg.rudnick at t-online.de (=?ISO-8859-1?Q?J=F6rg_Roman_Rudnick?=) Date: Mon Oct 5 23:06:05 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20091001155627.GB27880@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> Message-ID: <4ACAB924.6010901@t-online.de> Hi Curt, in case you regard as 'mainstream' big industry projects, this is not the thing at least I am speaking about. I am speaking about small and especially medium sized projects. Frankly, I think that: o there are people among us which at some times have influence on decisions about the software platform of projects - which tend to hesitate in proposing Haskell, as they do not see an appropriate infrastructure at hand. This not necessarily needs to be the 'classical' enterprise-employee thing - the occasion to know a group of experts to be able to engage in a looser cooperation might serve well, too, etc., etc. o there are, on the other side, people among us, wanting exactly to do this... Why not let them cooperate, no matter how big it will grow in comparison to Java & Co, in a way appropriate to the Haskell community? Nick From joerg.rudnick at t-online.de Mon Oct 5 23:33:39 2009 From: joerg.rudnick at t-online.de (=?ISO-8859-1?Q?J=F6rg_Roman_Rudnick?=) Date: Mon Oct 5 23:11:32 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <910ddf450910020212j409c5425y5c4cf4325565189e@mail.gmail.com> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <910ddf450910020212j409c5425y5c4cf4325565189e@mail.gmail.com> Message-ID: <4ACABA93.9040204@t-online.de> Hi Thomas, two very substantial contributions... :-) (a) Yes, let's do it with Happstack. (b) I just applied for the group. Nick Thomas Hartman wrote: > Hey, first of all, in terms of a platform for promoting haskell > commercially, happstutorial.com actually implements a job board. > > Yeah, it's primitive and not feature complete, but on hackage, open > source, and ready for anyone who would like to work on it. (Currently > maintained by creighton hogg.) > > This was my baby in 2008, when I was looking to foster happs for web > development, as a sort of "smarter" ruby on rails, which I am using in > the field in patch-tag.com. > > 2, the haskell-startup google group at > > http://groups.google.com/group/haskell-startup > > It's private, to encourage slightly more courageous business talk away > from the panoptic gaze of google, but I approve pretty much anyone who > doesn't want in and isn't a bot. > > Yes. Let's create a world with more jobs for haskell developers, and > better software for everyone :) > > thomas. > From joerg.rudnick at t-online.de Mon Oct 5 23:44:45 2009 From: joerg.rudnick at t-online.de (=?ISO-8859-1?Q?J=F6rg_Roman_Rudnick?=) Date: Mon Oct 5 23:23:30 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> Message-ID: <4ACABD2D.1030306@t-online.de> Hi John, IMHO, with medium sized projects which are not application software to be installed on a greater number of unknown systems, the problem described by you is less aggravating: Hackage offers a fairly good track of version history and I for myself have adapted versions a good deal of times and found it - easy, to be honest. Speaking about small and especially medium sized projects, I think agile development fits well this scope. Please do not forget this. Nick John A. De Goes wrote: > On Oct 1, 2009, at 12:13 AM, Curt Sampson wrote: > >> And as far as something like dealing with a changing language and >> libraries, the mainstream already has well-established and popular >> techniques for doing just: agile development. > > A project manager's worst nightmare: > > "Sorry boss, but we're just not going to be able to meet that > deadline, because, well, a language extension we were using was > dropped from the language, and the syntax for some core operators was > changed. Not only is our code broken, but many of the libraries we > were using are broken. Don't worry, though, we're 'agile', so our unit > tests will tell us when our code is working again." > > Big business demands stability. > > Regards, > > John > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From flopticalogic at gmail.com Mon Oct 5 23:54:29 2009 From: flopticalogic at gmail.com (Floptical Logic) Date: Mon Oct 5 23:32:07 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> Message-ID: > Instead of specifying the monad implementation, specify the interface. > That is, you are using state operations (from MonadState) and IO > operations (from MonadIO). Try removing all the type signatures that > mention PDState and see what you get. > > E.g., loop :: (MonadState PD m, MonadIO m) => m a If I were to make an instance of MonadIO be a parameter to StateT and I wanted to use the Net monad (from Roll your own IRC bot on the wiki) with it, I would need to make Net an instance of MonadIO. What would this instance look like? I think the loop function is the least of my worries. I am more concerned about the runCmd function. What would go in place of print in runCmd? Thanks From aslatter at gmail.com Tue Oct 6 00:08:37 2009 From: aslatter at gmail.com (Antoine Latter) Date: Mon Oct 5 23:46:16 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> Message-ID: <694519c50910052108q7ad83415t1483238e43aa78c0@mail.gmail.com> On Mon, Oct 5, 2009 at 10:54 PM, Floptical Logic wrote: > > If I were to make an instance of MonadIO be a parameter to StateT and > I wanted to use the Net monad (from Roll your own IRC bot on the wiki) > with it, I would need to make Net an instance of MonadIO. ?What would > this instance look like? If you define 'Net' as in the tutorial above, it will already be an instance of MonadIO :-) > I think the loop function is the least of my worries. ?I am more > concerned about the runCmd function. ?What would go in place of print > in runCmd? The function 'liftIO . print' will work in any monad which is an instance of MonadIO. Take a look at http://hackage.haskell.org/packages/archive/mtl/1.1.0.2/doc/html/Control-Monad-Trans.html#v:liftIO for where 'liftIO' comes from. Antoine From dave at zednenem.com Tue Oct 6 00:12:23 2009 From: dave at zednenem.com (David Menendez) Date: Mon Oct 5 23:50:02 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> Message-ID: <49a77b7a0910052112u6b6468e1k46d3ff21eb008@mail.gmail.com> On Mon, Oct 5, 2009 at 11:54 PM, Floptical Logic wrote: >> Instead of specifying the monad implementation, specify the interface. >> That is, you are using state operations (from MonadState) and IO >> operations (from MonadIO). Try removing all the type signatures that >> mention PDState and see what you get. >> >> E.g., loop :: (MonadState PD m, MonadIO m) => m a > > If I were to make an instance of MonadIO be a parameter to StateT and > I wanted to use the Net monad (from Roll your own IRC bot on the wiki) > with it, I would need to make Net an instance of MonadIO. ?What would > this instance look like? You're referring to this type? type Net = ReaderT Bot IO That already is an instance of MonadIO. The relevant instances are instance MonadIO IO where liftIO = id instance MonadIO m => MonadIO (ReaderT r m) where liftIO = lift . liftIO > I think the loop function is the least of my worries. ?I am more > concerned about the runCmd function. ?What would go in place of print > in runCmd? You're already using liftIO from MonadIO in the definition of runCmd, so no changes need to be made. Now, I didn't notice that getCount, getList, and increment don't take arguments, so you either need to provide explicit type signatures or set NoMonomorphismRestriction. If you do the latter and load the code into ghci, you get: *Main> :t runCmd runCmd :: (MonadState PD m, MonadIO m) => [Char] -> m () -- Dave Menendez From ccshan at post.harvard.edu Tue Oct 6 00:44:08 2009 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Tue Oct 6 00:38:14 2009 Subject: [Haskell-cafe] Re: Finally tagless - stuck with implementation?of?"lam" References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> <1alqp6-d3p.ln1@mantle.rutgers.edu> <20091006031054.GB18549@whirlpool.galois.com> Message-ID: Don Stewart wrote in article <20091006031054.GB18549@whirlpool.galois.com> in gmane.comp.lang.haskell.cafe: > ccshan: > > (Section 5 of our (JFP) paper addresses both CBN and CBV.) > Do you have a link to the paper? Sorry, here it is. http://www.cs.rutgers.edu/~ccshan/tagless/jfp.pdf -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig Here's a souvenir of it. He made me write this down so I'd remember to get this book and read it. Transcendent Speculations on Apparent Design in the Fate of the Individual, that's a mouthful isn't it. I wrote this down at gun-point. - Gaddis From dagit at codersbase.com Tue Oct 6 02:49:08 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Oct 6 02:26:47 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: <200910052002.52723.shahn@cs.tu-berlin.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910052002.52723.shahn@cs.tu-berlin.de> Message-ID: On Mon, Oct 5, 2009 at 11:02 AM, S?nke Hahn wrote: > > > > On 5 Oct 2009, at 21:06, Lennart Augustsson wrote: > > > OK, "just pairs" have no arithmetic, but one way of defining > > > arithmetic is to treat the pairs as complex numbers. Or as mantissa > > > and exponent. Or as something else. So there's nothing wrong, IMO, > > > to make pairs an instance of Num if you so desire. (Though I'd > > > probably introduce a new type.) > > I was looking for one intuitive way of instantiating pairs of numbers as > Num. > One where i wouldn't have to look in the documentation to remember what (+) > does. So considering all these examples of what pairs of numbers could be, > i > agree with Miguel Mitrofanov: "It's something that should not be done." > > Two questions remain, i think: > > 1. How can i have some notion of addition and subtraction for something > that i > don't want to put in the Num class? > > That's easy: I could just write a class that defines binary operators (like > (+~) and (-~), for example). I don't get the fanciness of (+), but that's > okay. > I don't know how well it works in practice, but you could hide the prelude in your module and then import it qualified. This would allow your module to redefine the normal symbols as the operators you want them to be. > > 2. How can i use numeric literals to construct values, whose types are not > in > the Num class? > This I don't know how to do without a pre-processor or maybe Template Haskell would work. > > Haskell could provide a class IsNumber (like IsString for string literals). > Is > that something we would want? > Seems like IsBoolean would also be useful if you went this route. And perhaps, IsList :) I'm sure we could think of more. I can see how they would be handy for anyone making an eDSL, especially if combine with view patterns. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/05f0122a/attachment.html From p.f.moore at gmail.com Tue Oct 6 03:11:37 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 02:49:14 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir In-Reply-To: References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> Message-ID: <79990c6b0910060011q45acb6fdr6c3c17383839d030@mail.gmail.com> 2009/10/6 Mikhail Glushenkov : > Hi Paul, > > Paul Moore gmail.com> writes: > >> Is there a way I could have specified that I want the global install >> directory in D:\Apps\Haskell? I guess I could hack my cabal\config >> file (and presumably change PATH) but that seems a bit ugly. > > A bit ugly? Why? That's precisely what the config files are for. The "ugliness" (a bad word, I agree) was the need to change multiple items - (at least) 2 places in the config file and (presumably) the PATH entry. Is that all I need to change? Actually, on a related note, is there documentation on cabal I should have found which contains the information on how to do this? >> Is the >> use of Program Files even when the install was to somewhere else a >> bug? > > Not really, the Windows installer just doesn't tinker with the > default cabal-install install location. There are plans, though, > to implement an "install only for the current user" mode > for the next release. OK. But given that I said "install Haskell" in *this* location, I sort of expected all my Haskell stuff to go there. But thanks for the information, I can fix this now. Paul. From gcross at phys.washington.edu Tue Oct 6 03:36:43 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Oct 6 03:14:40 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> Message-ID: <8AA33C09-A638-4AB3-BC9A-3ADC023FAE7A@phys.washington.edu> It isn't clear what it is that you are trying to generalize the code to do. If you are trying to generalize it to work with an arbitrary input/output stream of lines, then unless you are doing arbitrary I/O it seems to me that all of these instance declarations are overkill. All that you need is to know how to get a line from the stream, and how to send a line. Assuming that this is the case, you have a couple of options. If you are only going to write to the stream within runCmd, then I'd just pass in the line writing function as an extra argument: type PDState = StateT PD loop :: (m String) -> (String -> m ()) -> PDState m a loop fetchLine sendLine = forever $ lift fetchLine >>= runCmd (lift sendLine) runCmd :: (String -> PDState m ()) -> PDstate m () runCmd sendLine cmd = case cmd of "Inc" -> increment "PrintCount" -> getCount >>= sendLine . show "PrintList" -> getList >>= sendLine . show ... If you forsee doing reading and writing at other points in your code, you could use the RWS monad to supply your code not only with a state but also with an environment with the reading and writing functions: data StreamFunctions m = StreamFunctions { streamLineFetcher :: m String , streamLineSender :: String -> m () } fetchLineFromStream = lift $ asks streamLineFetcher sendLineDownStream cmd = lift (asks streamLineSender >>= return . ($ cmd)) data PDMonad = RWST (StreamFunctions m) () PD m main = evalRWST loop (StreamFunctions ...) (PD { pdCount = 0, pdList = [] }) loop :: PDMonad m () loop = forever $ fetchLineFromStream >>= runCmd runCmd :: String -> PDMonad m () runCmd "Inc" = increment runCmd "PrintCount" = getCount >>= sendLineDownStream runCmd "PrintList" = getList >>= sendLineDownStream Note that we didn't have to put any additional constraints on the monad type variable "m", because other than the fact that we can get a line and send a line within it we don't otherwise care what it is. If you want to do other arbitrary I/O within this framework, though, then you will need to add a "MonadIO m" constraint. Cheers, Greg On Oct 5, 2009, at 8:54 PM, Floptical Logic wrote: >> Instead of specifying the monad implementation, specify the >> interface. >> That is, you are using state operations (from MonadState) and IO >> operations (from MonadIO). Try removing all the type signatures that >> mention PDState and see what you get. >> >> E.g., loop :: (MonadState PD m, MonadIO m) => m a > > If I were to make an instance of MonadIO be a parameter to StateT and > I wanted to use the Net monad (from Roll your own IRC bot on the wiki) > with it, I would need to make Net an instance of MonadIO. What would > this instance look like? > > I think the loop function is the least of my worries. I am more > concerned about the runCmd function. What would go in place of print > in runCmd? > > Thanks > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gcross at phys.washington.edu Tue Oct 6 03:54:56 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Oct 6 03:32:50 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: <8AA33C09-A638-4AB3-BC9A-3ADC023FAE7A@phys.washington.edu> References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> <8AA33C09-A638-4AB3-BC9A-3ADC023FAE7A@phys.washington.edu> Message-ID: Oh, and I just thought of one more approach: class StreamMonad m where fetchLine = m sendLine = String -> m () instance StreamMonad IO where fetchLine = getLine sendLine = putLine fetchLineFromStream = lift fetchLine sendLineToStream = lift . sendLine type PDState = StateT PD main = runStateT loop (PD { pdCount = 0, pdList = [] }) loop :: (StreamMonad m) => PDState m a loop = forever $ fetchLineFromStream >>= runCmd runCmd :: (StreamMonad m) => String -> PDState m () runCmd "Inc" = increment runCmd "PrintCount" = getCount >>= sendLineToStream . . . i.e., you could use type-classes instead of passing around a datatype to specify how to send/fetch lines. On Oct 6, 2009, at 12:36 AM, Gregory Crosswhite wrote: > It isn't clear what it is that you are trying to generalize the code > to do. If you are trying to generalize it to work with an arbitrary > input/output stream of lines, then unless you are doing arbitrary I/ > O it seems to me that all of these instance declarations are > overkill. All that you need is to know how to get a line from the > stream, and how to send a line. > > Assuming that this is the case, you have a couple of options. If > you are only going to write to the stream within runCmd, then I'd > just pass in the line writing function as an extra argument: > > > type PDState = StateT PD > > loop :: (m String) -> (String -> m ()) -> PDState m a > loop fetchLine sendLine = forever $ lift fetchLine >>= runCmd (lift > sendLine) > > runCmd :: (String -> PDState m ()) -> PDstate m () > runCmd sendLine cmd = > case cmd of > "Inc" -> increment > "PrintCount" -> getCount >>= sendLine . show > "PrintList" -> getList >>= sendLine . show > ... > > If you forsee doing reading and writing at other points in your > code, you could use the RWS monad to supply your code not only with > a state but also with an environment with the reading and writing > functions: > > > data StreamFunctions m = StreamFunctions > { streamLineFetcher :: m String > , streamLineSender :: String -> m () > } > > fetchLineFromStream = lift $ asks streamLineFetcher > sendLineDownStream cmd = lift (asks streamLineSender >>= return . ($ > cmd)) > > data PDMonad = RWST (StreamFunctions m) () PD m > > main = evalRWST loop (StreamFunctions ...) (PD { pdCount = 0, pdList > = [] }) > > loop :: PDMonad m () > loop = forever $ fetchLineFromStream >>= runCmd > > runCmd :: String -> PDMonad m () > runCmd "Inc" = increment > runCmd "PrintCount" = getCount >>= sendLineDownStream > runCmd "PrintList" = getList >>= sendLineDownStream > > > Note that we didn't have to put any additional constraints on the > monad type variable "m", because other than the fact that we can get > a line and send a line within it we don't otherwise care what it > is. If you want to do other arbitrary I/O within this framework, > though, then you will need to add a "MonadIO m" constraint. > > > Cheers, > Greg > > > On Oct 5, 2009, at 8:54 PM, Floptical Logic wrote: > >>> Instead of specifying the monad implementation, specify the >>> interface. >>> That is, you are using state operations (from MonadState) and IO >>> operations (from MonadIO). Try removing all the type signatures that >>> mention PDState and see what you get. >>> >>> E.g., loop :: (MonadState PD m, MonadIO m) => m a >> >> If I were to make an instance of MonadIO be a parameter to StateT and >> I wanted to use the Net monad (from Roll your own IRC bot on the >> wiki) >> with it, I would need to make Net an instance of MonadIO. What would >> this instance look like? >> >> I think the loop function is the least of my worries. I am more >> concerned about the runCmd function. What would go in place of print >> in runCmd? >> >> Thanks >> _______________________________________________ >> 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 the.dead.shall.rise at gmail.com Tue Oct 6 04:05:27 2009 From: the.dead.shall.rise at gmail.com (Mikhail Glushenkov) Date: Tue Oct 6 03:43:04 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir In-Reply-To: <79990c6b0910060011q45acb6fdr6c3c17383839d030@mail.gmail.com> References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> <79990c6b0910060011q45acb6fdr6c3c17383839d030@mail.gmail.com> Message-ID: <3cb898890910060105w7305436cpe08b35c3b93e856f@mail.gmail.com> Hi Paul, On Tue, Oct 6, 2009 at 9:11 AM, Paul Moore > The "ugliness" (a bad word, I agree) was the need to change multiple > items - (at least) 2 places in the config file and (presumably) the > PATH entry. > > Is that all I need to change? I'm not a Cabal expert, but it looks like you could just change the "user-install" setting to True (and alter the PATH variable accordingly) to achieve what you want. > OK. But given that I said "install Haskell" in *this* location, I sort > of expected all my Haskell stuff to go there. You have a point, maybe we'll change this in the next release. I've filed a ticket [1]. [1] http://trac.haskell.org/haskell-platform/ticket/97 -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments From p.f.moore at gmail.com Tue Oct 6 04:12:35 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 03:50:12 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir In-Reply-To: <3cb898890910060105w7305436cpe08b35c3b93e856f@mail.gmail.com> References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> <79990c6b0910060011q45acb6fdr6c3c17383839d030@mail.gmail.com> <3cb898890910060105w7305436cpe08b35c3b93e856f@mail.gmail.com> Message-ID: <79990c6b0910060112t546b6fc0g79775ba64c4e87a9@mail.gmail.com> 2009/10/6 Mikhail Glushenkov : > Hi Paul, > > On Tue, Oct 6, 2009 at 9:11 AM, Paul Moore >> The "ugliness" (a bad word, I agree) was the need to change multiple >> items - (at least) 2 places in the config file and (presumably) the >> PATH entry. >> >> Is that all I need to change? > > I'm not a Cabal expert, but it looks like you could just change the > "user-install" setting to True (and alter the PATH variable > accordingly) to achieve what you want. I can do a user install using cabal install --user and that works fine. It's just the global one that hits the permission issue. As I'm the only user on the PC, it doesn't make much difference which I use in practice :-) >> OK. But given that I said "install Haskell" in *this* location, I sort >> of expected all my Haskell stuff to go there. > > You have a point, maybe we'll change this in the next release. I've > filed a ticket [1]. > > [1] http://trac.haskell.org/haskell-platform/ticket/97 Thanks - I hadn't realised there was a bug tracker for the Haskell Platform. Paul. From dav.vire+haskell at gmail.com Tue Oct 6 04:25:45 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Tue Oct 6 04:03:23 2009 Subject: [Haskell-cafe] Re: Curried function terminology In-Reply-To: References: <948472.30597.qm@web31105.mail.mud.yahoo.com> Message-ID: <4c88418c0910060125j68825bf8m8dd7418abea847b@mail.gmail.com> On Mon, Oct 5, 2009 at 11:52 AM, Jon Fairbairn wrote: > [1] A pet peeve of mine is "x supports y" being used backwards (as in > "our application supports windows Vista", which would only make sense if > it were something like a system tool that stopped Vista crashing. (Not a native English speaker here) How would you say "x works well with y" ? From jon.fairbairn at cl.cam.ac.uk Tue Oct 6 04:32:20 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Tue Oct 6 04:11:11 2009 Subject: [Haskell-cafe] Re: Curried function terminology References: <948472.30597.qm@web31105.mail.mud.yahoo.com> <4c88418c0910060125j68825bf8m8dd7418abea847b@mail.gmail.com> Message-ID: David Virebayre writes: > On Mon, Oct 5, 2009 at 11:52 AM, Jon Fairbairn > wrote: > >> [1] A pet peeve of mine is "x supports y" being used backwards (as in >> "our application supports windows Vista", which would only make sense if >> it were something like a system tool that stopped Vista crashing. > > (Not a native English speaker here) > > How would you say "x works well with y" ? I think I would say "x works well with y". There's no reason to abuse "support" (which carries an implication of one thing being on top of another) for this. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From lemming at henning-thielemann.de Tue Oct 6 05:37:05 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Oct 6 05:14:14 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910052002.52723.shahn@cs.tu-berlin.de> Message-ID: On Mon, 5 Oct 2009, Jason Dagit wrote: >> 2. How can i use numeric literals to construct values, whose types are not >> in >> the Num class? Numeric literals are treated as Integer or Rational, and are then converted with the function fromInteger or fromRational, respectively, to the required type. Whatever fromInteger function is in scope, will be used. If fromInteger is in a class other than Num (in NumericPrelude it is Ring, but it can be also a function that is not a class method), then number literals have a type like: 2 :: MyNumClass a => a From p.f.moore at gmail.com Tue Oct 6 08:34:01 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 08:11:38 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir In-Reply-To: References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> Message-ID: <79990c6b0910060534g277c72dbydaf6335bab848f43@mail.gmail.com> 2009/10/6 Mikhail Glushenkov : > Hi Paul, > > Paul Moore gmail.com> writes: > >> Is there a way I could have specified that I want the global install >> directory in D:\Apps\Haskell? I guess I could hack my cabal\config >> file (and presumably change PATH) but that seems a bit ugly. > > A bit ugly? Why? That's precisely what the config files are for. Looks like it also doesn't work :-( >grep global -A7 "D:\Documents and Settings\uk03306\Application Data\cabal\config" install-dirs global -- prefix: "D:\\Apps\\Haskell\\Cabal" -- bindir: $prefix\bin -- libdir: $prefix -- libsubdir: $pkgid\$compiler -- libexecdir: $prefix\$pkgid -- datadir: "D:\\Apps\\Haskell\\Cabal" -- datasubdir: $pkgid >cabal install mersenne-random -fuse_sse2 Resolving dependencies... Downloading mersenne-random-1.0... Configuring mersenne-random-1.0... Preprocessing library mersenne-random-1.0... Building mersenne-random-1.0... [1 of 1] Compiling System.Random.Mersenne ( System\Random\Mersenne.hs, dist\build\System\Random\Mersenne.o ) D:\Utils\Mingw\bin\ar.exe: creating dist\build\libHSmersenne-random-1.0.a Installing library in C:\Program Files\Haskell\mersenne-random-1.0\ghc-6.10.4 Registering mersenne-random-1.0... Reading package info from "dist\\installed-pkg-config" ... done. Writing new package config file... done. Note - "Installing library in C:\Program Files\Haskell\mersenne-random-1.0\ghc-6.10.4" >cabal --version cabal-install version 0.6.2 using version 1.6.0.3 of the Cabal library http://hackage.haskell.org/trac/hackage/ticket/365 may be relevant, but it says it's fixed :-( Paul From bertram.felgenhauer at googlemail.com Tue Oct 6 08:38:11 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Tue Oct 6 08:15:53 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir In-Reply-To: <79990c6b0910060534g277c72dbydaf6335bab848f43@mail.gmail.com> References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> <79990c6b0910060534g277c72dbydaf6335bab848f43@mail.gmail.com> Message-ID: <20091006123811.GA2428@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Paul Moore wrote: > >grep global -A7 "D:\Documents and Settings\uk03306\Application Data\cabal\config" > install-dirs global > -- prefix: "D:\\Apps\\Haskell\\Cabal" ^^^ You should remove the '-- '. Lines beginning with '--' are comments. So this line has no effect. HTH, Bertram From allbery at ece.cmu.edu Tue Oct 6 09:43:21 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Oct 6 09:21:23 2009 Subject: [Haskell-cafe] I/O Haskell question In-Reply-To: <740415.60241.qm@web81501.mail.mud.yahoo.com> References: <8aaf95030910050648x4d005ffao4d6237f17c5ef463@mail.gmail.com> <740415.60241.qm@web81501.mail.mud.yahoo.com> Message-ID: <48516375-3241-4DBF-B0B5-22B3D204997C@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/f02692a0/PGP.bin From flopticalogic at gmail.com Tue Oct 6 11:22:58 2009 From: flopticalogic at gmail.com (Floptical Logic) Date: Tue Oct 6 11:00:35 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> <8AA33C09-A638-4AB3-BC9A-3ADC023FAE7A@phys.washington.edu> Message-ID: > class StreamMonad m where > ? ? ? ?fetchLine = m > ? ? ? ?sendLine = String -> m () > > instance StreamMonad IO where > ? ? ? ?fetchLine = getLine > ? ? ? ?sendLine = putLine > > fetchLineFromStream = lift fetchLine > sendLineToStream = lift . sendLine This approach makes more sense to me. The equivalent to printing something to the screen in the Net (IRC) monad is privmsg and it is easy to make that connection using type classes. I don't see how to make this connection using MonadIO. From p.f.moore at gmail.com Tue Oct 6 11:49:39 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 11:27:15 2009 Subject: [Haskell-cafe] Re: Haskell Platform - changing the global install dir In-Reply-To: <20091006123811.GA2428@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> References: <79990c6b0910051305o34b09d81yb47dcc19364edb5c@mail.gmail.com> <79990c6b0910060534g277c72dbydaf6335bab848f43@mail.gmail.com> <20091006123811.GA2428@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Message-ID: <79990c6b0910060849x75a8129bo3b259f45e83d7e92@mail.gmail.com> 2009/10/6 Bertram Felgenhauer : > Paul Moore wrote: >> >grep global -A7 "D:\Documents and Settings\uk03306\Application Data\cabal\config" >> install-dirs global >> ? -- prefix: "D:\\Apps\\Haskell\\Cabal" > ? ?^^^ > You should remove the '-- '. Lines beginning with '--' are comments. > So this line has no effect. Ah, that worked. Thanks. Paul. From ivan.miljenovic at gmail.com Tue Oct 6 11:50:02 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Oct 6 11:27:47 2009 Subject: [Haskell-cafe] ANNOUNCE: Graphalyze-0.8.0.0 and SourceGraph-0.5.5.0 Message-ID: <87my44wmhh.fsf@gmail.com> To keep Joe Fredette happy [1] this time, I've combined these two announcements into one. [1] http://sequence.complete.org/hwn/20091003 I'm pleased to announce the latest versions of Graphalyze [2] and SourceGraph [3]. The only change to Graphalyze has been the addition of Legend support (which necessitated a slight change in the data structures used, hence the large version bump) but SourceGraph contains more substantial changes. [2] http://hackage.haskell.org/package/Graphalyze-0.8.0.0 [3] http://hackage.haskell.org/package/SourceGraph-0.5.5.0 Changes to SourceGraph include: * A legend so that you know what all the fancy symbols, etc. actually mean. * Class instances now drawn correctly. * Better colour support. * Clean up printing of cliques, etc. I've also put some sample SourceGraph reports online at http://code.haskell.org/~ivanm/Sample_SourceGraph/SampleReports.html so that you can see what kind of results it produces. Enjoy! -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From frank at geoinfo.tuwien.ac.at Tue Oct 6 12:22:30 2009 From: frank at geoinfo.tuwien.ac.at (Andrew U. Frank) Date: Tue Oct 6 12:00:10 2009 Subject: [Haskell-cafe] dsl and gui toolkit Message-ID: <200910061822.30363.frank@geoinfo.tuwien.ac.at> thanks for the connection to the gui runner - it is interesting and worthwile, but a different approach. my approach is strictly declarative and does not describe sequences of process. it describes screens and links operations to buttons. then it takes inputs from the screen and runs the operations and posts the result on the screen. some operations open new screens etc. i started with the idea that ontologies describe the semantics of data in a static way; this should be (nearly) enough to create the user interface - which is all about semantics of the data. of course, you have to include in the ontology the semantics of the operations (as class with functions). the implementation is close to a reactive framework - adding a representation of all what is visible on the screen (the universer of discourse) in a format usable by the operations. then you have only to connect this 'universe of discourse' to the programs which operate on the data and post their reaction in the UoD and map the UoD to the screen the details are messy as i attempted to construct the internal data structures etc. as automatically as possible and with minimal designer input I did not use template haskell, yet, but will need to (i think). i am happy to share it with interested parties and hear the comments and perhaps somebody can help me with using templates to reduce the . it is IMHO not yet ready for posting in a library - but this is certainly the goal. From gcross at phys.washington.edu Tue Oct 6 12:23:29 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Oct 6 12:01:23 2009 Subject: [Haskell-cafe] Generalizing IO In-Reply-To: References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> <8AA33C09-A638-4AB3-BC9A-3ADC023FAE7A@phys.washington.edu> Message-ID: <7BF03B2A-628C-44A1-9DF6-3487724FE4B9@phys.washington.edu> Putting a constraint on the MonadIO class actually makes your code less general rather than more since it prevents your code from ever being used in a purely functional setting. If you leave out this constraint, you can actually turn your code into a pure function by doing things like feeding it a wrapper monad that supplies a list of strings as input and returns the list of written strings at the end. The only reason why you would add a MonadIO constraint would be if you wanted to do other things that require the IO monad (e.g., connecting to a database, working with files, etc.) and so you wanted to require that the IO monad be ultimately present somewhere in the type so that you could use it. Cheers, Greg On Oct 6, 2009, at 8:22 AM, Floptical Logic wrote: >> class StreamMonad m where >> fetchLine = m >> sendLine = String -> m () >> >> instance StreamMonad IO where >> fetchLine = getLine >> sendLine = putLine >> >> fetchLineFromStream = lift fetchLine >> sendLineToStream = lift . sendLine > > This approach makes more sense to me. The equivalent to printing > something to the screen in the Net (IRC) monad is privmsg and it is > easy to make that connection using type classes. I don't see how to > make this connection using MonadIO. From john at n-brain.net Tue Oct 6 12:26:38 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Oct 6 12:04:18 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <200910061822.30363.frank@geoinfo.tuwien.ac.at> References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> Message-ID: This is the right approach to a GUI toolkit. Note that personally, I believe the details of the presentation should be separate from Haskell, stored in a separate file that is machine- friendly, so designers can work in concert and in parallel with developers. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 6, 2009, at 10:22 AM, Andrew U. Frank wrote: > thanks for the connection to the gui runner - it is interesting and > worthwile, > but a different approach. my approach is strictly declarative and > does not > describe sequences of process. it describes screens and links > operations to > buttons. then it takes inputs from the screen and runs the > operations and > posts the result on the screen. some operations open new screens etc. > > i started with the idea that ontologies describe the semantics of > data in a > static way; this should be (nearly) enough to create the user > interface - > which is all about semantics of the data. > of course, you have to include in the ontology the semantics of the > operations > (as class with functions). > > the implementation is close to a reactive framework - adding a > representation > of all what is visible on the screen (the universer of discourse) in > a format > usable by the operations. then you have only to connect this > 'universe of > discourse' to the programs which operate on the data and post their > reaction > in the UoD and map the UoD to the screen > > the details are messy as i attempted to construct the internal data > structures > etc. as automatically as possible and with minimal designer input > > I did not use template haskell, yet, but will need to (i think). > > i am happy to share it with interested parties and hear the comments > and > perhaps somebody can help me with using templates to reduce the . it > is IMHO > not yet ready for posting in a library - but this is certainly the > goal. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From velman at cox.net Tue Oct 6 12:44:16 2009 From: velman at cox.net (John Velman) Date: Tue Oct 6 12:21:55 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? Message-ID: <20091006164416.GA960@cox.net> I think if I knew which libraries to add to the gcc link, I could make this work, but can't seem to find out from the documentation. Here are more specifics: I'd like to build a Cocoa program on OS X with the Aqua user interface using Xcode, but using a Haskell module with functions accessed through the foreign export interface. In fact this seems to fit in well with the Apple Model-View-Control programming pattern, with Haskell implementation of the Model, maybe some of the Control, and Cocoa implementation of the View and some of the Control. I've put together a short program (from the Wiki calling Haskell from C example) and compiling and linking with ghc it runs as advertised. As an experiment, I put the c main program into an Xcode project, added the haskell module .o and stub.o, stub.h files. Also added the HsFFI.h. Then did a build and run. As expected I got a bunch of missing entry points (26, if I recall correctly). Adding libffi.a and libHSrts.a brings me up to 56 missing entry points. Searching the other lib files for these seems pretty hopeless. Any pointers to documentation, or other help will be greatly appreciated! Thanks, John Velman From colin at colina.demon.co.uk Tue Oct 6 12:44:54 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Oct 6 12:22:36 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: (John A. De Goes's message of "Tue\, 6 Oct 2009 10\:26\:38 -0600") References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> Message-ID: >>>>> "John" == John A De Goes writes: John> This is the right approach to a GUI toolkit. John> Note that personally, I believe the details of the John> presentation should be separate from Haskell, stored in a John> separate file that is machine- friendly, so designers can John> work in concert and in parallel with developers. Like CSS? -- Colin Adams Preston Lancashire From john at n-brain.net Tue Oct 6 12:47:36 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Oct 6 12:25:16 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> Message-ID: <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> CSS is a good start by it's beset by all the problems of a 1st generation presentation language, and is not particularly machine- friendly. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 6, 2009, at 10:44 AM, Colin Paul Adams wrote: >>>>>> "John" == John A De Goes writes: > > John> This is the right approach to a GUI toolkit. > > John> Note that personally, I believe the details of the > John> presentation should be separate from Haskell, stored in a > John> separate file that is machine- friendly, so designers can > John> work in concert and in parallel with developers. > > Like CSS? > -- > Colin Adams > Preston Lancashire From thomas.dubuisson at gmail.com Tue Oct 6 12:48:44 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Oct 6 12:26:24 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091006164416.GA960@cox.net> References: <20091006164416.GA960@cox.net> Message-ID: <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> Generally you should be able to tell which library you're missing based on the names of the undefined symbols. Have you link in... libgmp.a? libm.a? libc.a? What are the missing symbols? Thomas On Tue, Oct 6, 2009 at 9:44 AM, John Velman wrote: > I think if I knew which libraries to add to the gcc link, I could make this > work, but can't seem to find out from the documentation. > > Here are more specifics: > > I'd like to build a Cocoa ?program on OS X with the Aqua user interface > using Xcode, but using a Haskell module with functions accessed through the > foreign export ?interface. ?In fact this seems to fit in well with the > Apple Model-View-Control programming pattern, with Haskell implementation > of the Model, maybe some of the Control, ?and Cocoa implementation of the > View and some of the Control. > > I've put together a short program (from the Wiki calling Haskell from C > example) and compiling and linking with ghc it runs as advertised. > > As an experiment, I put the c main program into an Xcode project, added the > haskell module .o and stub.o, stub.h files. ?Also added the HsFFI.h. ?Then > did a build and run. ?As expected I got a bunch of missing entry points > (26, if I recall correctly). ?Adding libffi.a and libHSrts.a brings me up > to 56 missing entry points. Searching the other lib files for these seems > pretty hopeless. > > Any pointers to documentation, or other help will be greatly appreciated! > > Thanks, > > John Velman > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From deniz.a.m.dogan at gmail.com Tue Oct 6 12:49:47 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Tue Oct 6 12:27:43 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> Message-ID: <7b501d5c0910060949s6c6e0cc5red32e677cd8d1df4@mail.gmail.com> 2009/10/6 John A. De Goes : > > CSS is a good start by it's beset by all the problems of a 1st generation > presentation language, and is not particularly machine-friendly. I think CSS is neat for websites, but I'm not so sure about using it in "normal" applications. -- Deniz Dogan From iavor.diatchki at gmail.com Tue Oct 6 13:35:47 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Tue Oct 6 13:13:24 2009 Subject: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types) In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910052002.52723.shahn@cs.tu-berlin.de> Message-ID: <5ab17e790910061035w1508b3cek2d2615eb404105f8@mail.gmail.com> Hi, On Tue, Oct 6, 2009 at 2:37 AM, Henning Thielemann wrote: > Numeric literals are treated as Integer or Rational, and are then converted > with the function fromInteger or fromRational, respectively, to the required > type. Whatever fromInteger function is in scope, will be used. If > fromInteger is in a class other than Num (in NumericPrelude it is Ring, but > it can be also a function that is not a class method), then number literals > have a type like: > ?2 :: MyNumClass a => a This is only the case if you use GHC's NoImplicitPrelude extension, otherwise the "fromInteger" of the Prelude is used, even if it is not in scope. Here is an example: module A where boolLit :: Integer -> Bool boolLit 0 = False boolLit _ = True {-# LANGUAGE NoImplicitPrelude #-} module Main where import A(boolLit) import Prelude(Integer,Bool,print) fromInteger :: Integer -> Bool fromInteger = boolLit main = print 0 Note that 0 means different things in the different modules! -Iavor From arne.d.h at gmail.com Tue Oct 6 14:41:15 2009 From: arne.d.h at gmail.com (Arne Dehli Halvorsen) Date: Tue Oct 6 14:18:52 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs Message-ID: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> This may be a little off-topic, but if someone could help me, I'd be grateful.I am trying to get to a working gtk2hs environment in MacOSX Snow Leopard I have a Macbook Pro 2.1 with Snow Leopard. While I had Leopard, I had the Haskell Platform installed, and it worked fine. I also had the MacPorts edition of gtk, and compiled gtk2hs by hand. After I got Snow Leopard, I installed the Haskell Platform. I have made the necessary changes to make it compile (flags to ghc), and it compiles normal programs. I installed the standalone version of the GTK+ platform, and then tried to compile gtk2hs from /gtk2hs . ./configure works, but make results in this: adhmac:gtk2hs arne$ make make all-am rm -rf gtk/Graphics/UI/Gtk/Types.o gtk/Graphics/UI/Gtk/Types_split/; mkdir -p gtk/Graphics/UI/Gtk/Types_split /usr/bin/ghc +RTS -RTS -split-objs -c gtk/Graphics/UI/Gtk/Types.hs -o gtk/Graphics/UI/Gtk/Types.o -O -XForeignFunctionInterface -fglasgow-exts -igtk -package-conf package.conf.inplace -hide-all-packages -ignore-package gtk -package base-4.1.0.0 -package mtl-1.1.0.2 -package containers-0.2.0.1 -package array-0.2.0.0 -package glib-0.10.1 -package cairo-0.10.1 -package-name gtk-0.10.1 '-#include' -I/Library/Frameworks/GLib.framework/Headers -I/Library/Frameworks/Cairo.framework/Headers -I/Library/Frameworks/Gtk.framework/Headers -I. /var/folders/G8/G8LY9MSBEGuyatB+JjSWq++++TI/-Tmp-/ghc4162_0/ghc4162_0.split__2870.s:35:0: invalid character '_' in mnemonic /var/folders/G8/G8LY9MSBEGuyatB+JjSWq++++TI/-Tmp-/ghc4162_0/ghc4162_0.split__2870.s:953:0: FATAL:Symbol L_gtk_misc_get_type$stub already defined. make[1]: *** [gtk/Graphics/UI/Gtk/Types.o] Error 1 make: *** [all] Error 2 I also have gtk installed via macports recently, but I am not sure whether this makes a difference. I don't think there is any point currently in trying to go MacPorts all the way, and install ghc+gtk2hs via MacPorts. Does anyone have a recipe for getting ghc + gtk2hs + gtk working on MacOSX Snow Leopard? Best regards, Arne D Halvorsen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/344fdc18/attachment.html From jfredett at gmail.com Tue Oct 6 14:43:27 2009 From: jfredett at gmail.com (Joe Fredette) Date: Tue Oct 6 14:21:10 2009 Subject: [Haskell-cafe] ANNOUNCE: Graphalyze-0.8.0.0 and SourceGraph-0.5.5.0 In-Reply-To: <87my44wmhh.fsf@gmail.com> References: <87my44wmhh.fsf@gmail.com> Message-ID: Hehe, very cool. Keep the good work coming, Ivan. /Joe On Oct 6, 2009, at 11:50 AM, Ivan Lazar Miljenovic wrote: > > To keep Joe Fredette happy [1] this time, I've combined these two > announcements into one. > > [1] http://sequence.complete.org/hwn/20091003 > > I'm pleased to announce the latest versions of Graphalyze [2] and > SourceGraph [3]. The only change to Graphalyze has been the > addition of > Legend support (which necessitated a slight change in the data > structures used, hence the large version bump) but SourceGraph > contains > more substantial changes. > > [2] http://hackage.haskell.org/package/Graphalyze-0.8.0.0 > [3] http://hackage.haskell.org/package/SourceGraph-0.5.5.0 > > Changes to SourceGraph include: > > * A legend so that you know what all the fancy symbols, etc. actually > mean. > > * Class instances now drawn correctly. > > * Better colour support. > > * Clean up printing of cliques, etc. > > I've also put some sample SourceGraph reports online at > http://code.haskell.org/~ivanm/Sample_SourceGraph/SampleReports.html > so > that you can see what kind of results it produces. > > Enjoy! > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic@gmail.com > IvanMiljenovic.wordpress.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From greg at gregorycollins.net Tue Oct 6 14:49:50 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Tue Oct 6 14:27:28 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> (Arne Dehli Halvorsen's message of "Tue, 6 Oct 2009 20:41:15 +0200") References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> Message-ID: <8763asl5m9.fsf@gregorycollins.net> Arne Dehli Halvorsen writes: > This may be a little off-topic, but if someone could help me, I'd be grateful. > I am trying to get to a working gtk2hs environment in MacOSX Snow Leopard Have you patched: /usr/bin/ghc /usr/bin/ghci /usr/bin/runhaskell /usr/bin/runghc /usr/bin/hsc2hs -- discovered this one only recently with the 32-bit flags? G. -- Gregory Collins From velman at cox.net Tue Oct 6 14:51:36 2009 From: velman at cox.net (John Velman) Date: Tue Oct 6 14:29:13 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> Message-ID: <20091006185136.GB960@cox.net> On Tue, Oct 06, 2009 at 09:48:44AM -0700, Thomas DuBuisson wrote: Thanks, Thomas. Linking in only libffi.a, libgmp.a, I get (for example, there are many more) missing: "_newCAF" "_base_GHCziBase_plusInt_closure" "_base_GHCziList_zzipWith_info" "_base_GHCziList_lvl5_closure" by also linking in libHSrts.a, I no longer am missing _newCAF, (and others that were missing without it) but am missing a lot of _base_GHCzi... references. I've been unable to track these down. By the way, I can't find either a libc.a or libm.a on this machine using either locate or spotlight. Is there a way to "guess" which library things are in, short of doing an nm with some appropriate option on each .a file in the Haskell lib? Thanks, John V. > Generally you should be able to tell which library you're missing > based on the names of the undefined symbols. Have you link in... > libgmp.a? libm.a? libc.a? What are the missing symbols? > > Thomas > > On Tue, Oct 6, 2009 at 9:44 AM, John Velman wrote: > > I think if I knew which libraries to add to the gcc link, I could make this > > work, but can't seem to find out from the documentation. > > > > Here are more specifics: > > > > I'd like to build a Cocoa ?program on OS X with the Aqua user interface > > using Xcode, but using a Haskell module with functions accessed through the > > foreign export ?interface. ?In fact this seems to fit in well with the > > Apple Model-View-Control programming pattern, with Haskell implementation > > of the Model, maybe some of the Control, ?and Cocoa implementation of the > > View and some of the Control. > > > > I've put together a short program (from the Wiki calling Haskell from C > > example) and compiling and linking with ghc it runs as advertised. > > > > As an experiment, I put the c main program into an Xcode project, added the > > haskell module .o and stub.o, stub.h files. ?Also added the HsFFI.h. ?Then > > did a build and run. ?As expected I got a bunch of missing entry points > > (26, if I recall correctly). ?Adding libffi.a and libHSrts.a brings me up > > to 56 missing entry points. Searching the other lib files for these seems > > pretty hopeless. > > > > Any pointers to documentation, or other help will be greatly appreciated! > > > > Thanks, > > > > John Velman > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From thomas.dubuisson at gmail.com Tue Oct 6 14:54:55 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Oct 6 14:32:33 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091006185136.GB960@cox.net> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> Message-ID: <4c44d90b0910061154h4cda48dfsa5eb1a76d77348cd@mail.gmail.com> You are missind libHSbase. Try, for example: locate libHSbase-3.0.1.0.a and link that in. Thomas On Tue, Oct 6, 2009 at 11:51 AM, John Velman wrote: > On Tue, Oct 06, 2009 at 09:48:44AM -0700, Thomas DuBuisson wrote: > > > Thanks, Thomas. > > Linking in only libffi.a, libgmp.a, I get (for example, there are many > more) missing: > > ?"_newCAF" > ?"_base_GHCziBase_plusInt_closure" > ?"_base_GHCziList_zzipWith_info" > ?"_base_GHCziList_lvl5_closure" > > by also linking in libHSrts.a, I no longer am missing _newCAF, (and others > that were missing without it) but am missing a lot of _base_GHCzi... > references. ?I've been unable to track these down. > > By the way, I can't find either a libc.a or libm.a on this machine using > either locate or spotlight. > > Is there a way to "guess" which library things are in, short of doing > an nm with some appropriate option on each .a file in the Haskell lib? > > Thanks, > > John V. > > >> Generally you should be able to tell which library you're missing >> based on the names of the undefined symbols. ?Have you link in... >> libgmp.a? libm.a? libc.a? ?What are the missing symbols? >> >> Thomas >> >> On Tue, Oct 6, 2009 at 9:44 AM, John Velman wrote: >> > I think if I knew which libraries to add to the gcc link, I could make this >> > work, but can't seem to find out from the documentation. >> > >> > Here are more specifics: >> > >> > I'd like to build a Cocoa ?program on OS X with the Aqua user interface >> > using Xcode, but using a Haskell module with functions accessed through the >> > foreign export ?interface. ?In fact this seems to fit in well with the >> > Apple Model-View-Control programming pattern, with Haskell implementation >> > of the Model, maybe some of the Control, ?and Cocoa implementation of the >> > View and some of the Control. >> > >> > I've put together a short program (from the Wiki calling Haskell from C >> > example) and compiling and linking with ghc it runs as advertised. >> > >> > As an experiment, I put the c main program into an Xcode project, added the >> > haskell module .o and stub.o, stub.h files. ?Also added the HsFFI.h. ?Then >> > did a build and run. ?As expected I got a bunch of missing entry points >> > (26, if I recall correctly). ?Adding libffi.a and libHSrts.a brings me up >> > to 56 missing entry points. Searching the other lib files for these seems >> > pretty hopeless. >> > >> > Any pointers to documentation, or other help will be greatly appreciated! >> > >> > Thanks, >> > >> > John Velman >> > >> > _______________________________________________ >> > 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 greg at gregorycollins.net Tue Oct 6 15:07:01 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Tue Oct 6 14:44:37 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091006185136.GB960@cox.net> (John Velman's message of "Tue, 6 Oct 2009 11:51:36 -0700") References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> Message-ID: <871vlgl4tm.fsf@gregorycollins.net> John Velman writes: > On Tue, Oct 06, 2009 at 09:48:44AM -0700, Thomas DuBuisson wrote: > > > Thanks, Thomas. > > Linking in only libffi.a, libgmp.a, I get (for example, there are many > more) missing: > > "_newCAF" > "_base_GHCziBase_plusInt_closure" > "_base_GHCziList_zzipWith_info" > "_base_GHCziList_lvl5_closure" > > by also linking in libHSrts.a, I no longer am missing _newCAF, (and others > that were missing without it) but am missing a lot of _base_GHCzi... > references. I've been unable to track these down. > > By the way, I can't find either a libc.a or libm.a on this machine using > either locate or spotlight. > > Is there a way to "guess" which library things are in, short of doing > an nm with some appropriate option on each .a file in the Haskell lib? $ cd /Library/Frameworks/GHC.framework/Versions/Current/usr/lib/ $ for i in `find . -name '*.a'`; do nm -a $i 2>/dev/null | grep --label="$i" -H 'D *_base_GHCziBase_plusInt_closure'; done ./ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0.a:0000008c D _base_GHCziBase_plusInt_closure ./ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0_p.a:0000010c D _base_GHCziBase_plusInt_closure G. -- Gregory Collins From arne.d.h at gmail.com Tue Oct 6 15:23:00 2009 From: arne.d.h at gmail.com (Arne Dehli Halvorsen) Date: Tue Oct 6 15:00:37 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <8763asl5m9.fsf@gregorycollins.net> References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> <8763asl5m9.fsf@gregorycollins.net> Message-ID: <203d94090910061223w1300d585qecd8690387d8a671@mail.gmail.com> On Tue, Oct 6, 2009 at 8:49 PM, Gregory Collins wrote: > Arne Dehli Halvorsen writes: > > > This may be a little off-topic, but if someone could help me, I'd be > grateful. > > I am trying to get to a working gtk2hs environment in MacOSX Snow Leopard > > Have you patched: > > /usr/bin/ghc > /usr/bin/ghci > /usr/bin/runhaskell > /usr/bin/runghc > /usr/bin/hsc2hs -- discovered this one only recently > hsc2hs was new to me, the others were ok. It didn't help, though. > > with the 32-bit flags? > > G. > -- > Gregory Collins > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/779b6ff4/attachment.html From p.f.moore at gmail.com Tue Oct 6 15:52:03 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 15:29:39 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? Message-ID: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> As it says in the subject, how do I remove a package that I installed (with the --user flag) via cabal? Come to that, how do I list the packages I've installed via cabal? cabal list --installed includes all the GHC standard library (which I didn't install) and it doesn't seem to support a --user flag to list per-user installed packages. FWIW, I'm on Windows 7. Thanks, Paul. From vanenkj at gmail.com Tue Oct 6 15:58:24 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Oct 6 15:36:01 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? In-Reply-To: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> References: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> Message-ID: you want: ghc-pkg unregister [package name] and ghc-pkg list /jve On Tue, Oct 6, 2009 at 3:52 PM, Paul Moore wrote: > As it says in the subject, how do I remove a package that I installed > (with the --user flag) via cabal? > > Come to that, how do I list the packages I've installed via cabal? > cabal list --installed includes all the GHC standard library (which I > didn't install) and it doesn't seem to support a --user flag to list > per-user installed packages. > > FWIW, I'm on Windows 7. > > Thanks, > Paul. > _______________________________________________ > 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/20091006/e90f94b0/attachment.html From p.f.moore at gmail.com Tue Oct 6 16:04:30 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 15:42:07 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? In-Reply-To: References: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> Message-ID: <79990c6b0910061304w3b9ed9a5p6bc864fecee1fd12@mail.gmail.com> 2009/10/6 John Van Enk : > you want: > > ghc-pkg unregister [package name] > > and > > ghc-pkg list Thanks. I wouldn't have found that by myself. Unfortunately, having issued ghc-pkg unregister mersenne-random-1.0 I still see the code present: >dir C:\Users\Gustav\AppData\Roaming\cabal\mersenne-random-1.0\ghc-6.10.4 Volume in drive C is OS Serial number is 8442:99ea Directory of C:\Users\Gustav\AppData\Roaming\cabal\mersenne-random-1.0\ghc-6.10.4\* 05/10/2009 21:06 . 05/10/2009 21:06 .. 05/10/2009 21:06 include 05/10/2009 21:06 System 05/10/2009 21:06 44,350 HSmersenne-random-1.0.o 05/10/2009 21:06 66,762 libHSmersenne-random-1.0.a Looks like ghc-pkg unregister just does precisely that - unregisters the package but doesn't remove it. Can I even persuage cabal/ghc-pkg to list all the files and directories created by the install so I can remove them by hand? Paul. From greg at gregorycollins.net Tue Oct 6 16:09:06 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Tue Oct 6 15:46:46 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <203d94090910061223w1300d585qecd8690387d8a671@mail.gmail.com> (Arne Dehli Halvorsen's message of "Tue, 6 Oct 2009 21:23:00 +0200") References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> <8763asl5m9.fsf@gregorycollins.net> <203d94090910061223w1300d585qecd8690387d8a671@mail.gmail.com> Message-ID: <87vdisjndp.fsf@gregorycollins.net> Arne Dehli Halvorsen writes: > On Tue, Oct 6, 2009 at 8:49 PM, Gregory Collins wrote: > > Arne Dehli Halvorsen writes: > > > This may be a little off-topic, but if someone could help me, I'd be grateful. > > I am trying to get to a working gtk2hs environment in MacOSX Snow Leopard > > Have you patched: > > ? /usr/bin/ghc > ? /usr/bin/ghci > ? /usr/bin/runhaskell > ? /usr/bin/runghc > ? /usr/bin/hsc2hs ?-- discovered this one only recently > > hsc2hs was new to me, the others were ok. > It didn't help, though.? Sorry to be pedantic, just to confirm, the last line of hsc2hs should read: exec /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/hsc2hs $tflag $HSC2HS_EXTRA --cflag="-m32" --lflag="-m32" ${1+"$@"} "$Iflag" If that doesn't work I'm stumped (haven't tried to build gtk2hs on OSX.) G -- Gregory Collins From mpm at alumni.caltech.edu Tue Oct 6 16:22:04 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Tue Oct 6 15:59:56 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <1254662453.5687.119.camel@localhost> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> Message-ID: <4ACBA6EC.6030707@alumni.caltech.edu> Duncan Coutts wrote: > So you end up with pure functions like: > > shuffle :: RandomGen g => g -> [x] -> [x] Thanks for the help, Duncan. I'm confused on one point. Don't you always need the new state of the generator back? So wouldn't this need to be: shuffle :: RandomGen g => g -> [x] -> (g,[x]) > > Another approach is to hide the 'g' inside a monad. That's what > MonadRandom is all about. eg: > > shuffle :: [x] -> Rand [x] One tutorial mentions the class Gen in the Test.QuickCheck module. Is "Rand" a different class defined somewhere else? > > The tutorials above explain about the other random functions, for > getting values of different types (not just Int) and restricted ranges > of number etc. > > Of course at some point you want to seed the random number generator > with some initial genuinely random value (not like the 12345 we used > above). That is the only place in your random-handling code that needs > to do IO. All the rest of it can be pure. What function gives you that initial random seed? (Grabs it from the system clock?) Thanks, Mike From vanenkj at gmail.com Tue Oct 6 16:23:54 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Oct 6 16:01:31 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? In-Reply-To: <79990c6b0910061304w3b9ed9a5p6bc864fecee1fd12@mail.gmail.com> References: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> <79990c6b0910061304w3b9ed9a5p6bc864fecee1fd12@mail.gmail.com> Message-ID: Are you actually trying to remove the bits from the hard drive, or is that something to fix a different problem you're having. If it's a different problem, perhaps you could ask that as well? On Tue, Oct 6, 2009 at 4:04 PM, Paul Moore wrote: > 2009/10/6 John Van Enk : > > you want: > > > > ghc-pkg unregister [package name] > > > > and > > > > ghc-pkg list > > Thanks. I wouldn't have found that by myself. > > Unfortunately, having issued > > ghc-pkg unregister mersenne-random-1.0 > > I still see the code present: > > >dir C:\Users\Gustav\AppData\Roaming\cabal\mersenne-random-1.0\ghc-6.10.4 > > Volume in drive C is OS Serial number is 8442:99ea > Directory of > C:\Users\Gustav\AppData\Roaming\cabal\mersenne-random-1.0\ghc-6.10.4\* > > 05/10/2009 21:06 . > 05/10/2009 21:06 .. > 05/10/2009 21:06 include > 05/10/2009 21:06 System > 05/10/2009 21:06 44,350 HSmersenne-random-1.0.o > 05/10/2009 21:06 66,762 libHSmersenne-random-1.0.a > > Looks like ghc-pkg unregister just does precisely that - unregisters > the package but doesn't remove it. Can I even persuage cabal/ghc-pkg > to list all the files and directories created by the install so I can > remove them by hand? > > Paul. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/b2be78bd/attachment.html From arne.d.h at gmail.com Tue Oct 6 16:37:10 2009 From: arne.d.h at gmail.com (Arne Dehli Halvorsen) Date: Tue Oct 6 16:14:49 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <87vdisjndp.fsf@gregorycollins.net> References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> <8763asl5m9.fsf@gregorycollins.net> <203d94090910061223w1300d585qecd8690387d8a671@mail.gmail.com> <87vdisjndp.fsf@gregorycollins.net> Message-ID: <203d94090910061337m43bf5de7i8fd55d907fab9169@mail.gmail.com> On Tue, Oct 6, 2009 at 10:09 PM, Gregory Collins wrote: > Arne Dehli Halvorsen writes: > > > On Tue, Oct 6, 2009 at 8:49 PM, Gregory Collins > wrote: > > > > > > > hsc2hs was new to me, the others were ok. > > It didn't help, though. > > Sorry to be pedantic, just to confirm, the last line of hsc2hs should > read: > > exec > /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/hsc2hs > $tflag $HSC2HS_EXTRA --cflag="-m32" --lflag="-m32" ${1+"$@"} "$Iflag" > > If that doesn't work I'm stumped (haven't tried to build gtk2hs on OSX.) > Hmm: This is what my /usr/bin/ghc (->/Library/Frameworks/GHC.framework/Versions/610/usr/bin/ghc-6.10.4) looks like - exec /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc -B/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/. -dynload wrapped ${1+"$@"} -optc-m32 -opta-m32 -optl-m32 ...and I had added that same "-optc-m32 -opta-m32 -optl-m32 " to all the others too. The result is the same after altering hsc2hs to follow the same flag convention as yours, though. Arne D Halvorsen > > G > -- > Gregory Collins > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/0409abb5/attachment.html From p.f.moore at gmail.com Tue Oct 6 16:40:44 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 16:18:21 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? In-Reply-To: References: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> <79990c6b0910061304w3b9ed9a5p6bc864fecee1fd12@mail.gmail.com> Message-ID: <79990c6b0910061340s351f521ei608bfba1cc785c42@mail.gmail.com> 2009/10/6 John Van Enk : > Are you actually trying to remove the bits from the hard drive, or is that > something to fix a different problem you're having. If it's a different > problem, perhaps you could ask that as well? Yes, I'm trying to remove the bits from the disk. I did a cabal install --user mersenne-random and I now want to get rid of it. If you're asking why I don't just leave the files there as they aren't doing any harm, let's just say I don't want to leave clutter round on my disk. Places like the APPDATA folder accumulate enough junk on their own without stuff getting left there just because an application doesn't clean up after itself properly (that's not a dig at Haskell, loads of programs do that :-() Paul. From mpm at alumni.caltech.edu Tue Oct 6 16:52:30 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Tue Oct 6 16:30:19 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4ACBA6EC.6030707@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <4ACBA6EC.6030707@alumni.caltech.edu> Message-ID: <4ACBAE0E.3050800@alumni.caltech.edu> I think I've answered part of my question. There is a function that lives in the IO monad, newStdGen. This gives you a new generator with random initial state. That's the first part of the story. Then, I'm not sure, but perhaps you can call newStdGen many times during a program and get good pseudorandom behavior. For example: shuffle :: RandomGen g, Random a => g -> [a] -> [a] shuffle = ... main = do g1 <- newStdGen print (shuffle g1 [1,2,3,4,5] :: [Int]) g2 <- newStdGen print (shuffle g2 [6,7,8,9,0] :: [Int]) Does calling newStdGen twice in a row give good behavior? Is it a bad idea? Is it system-dependent? Also note that I added the Random class constraint to 'shuffle'. I haven't tested this but it might be necessary. Or not? Thanks, Mike Michael P Mossey wrote: > Duncan Coutts wrote: > >> So you end up with pure functions like: >> >> shuffle :: RandomGen g => g -> [x] -> [x] > > Thanks for the help, Duncan. I'm confused on one point. Don't you always > need the new state of the generator back? So wouldn't this need to be: > > shuffle :: RandomGen g => g -> [x] -> (g,[x]) > > > > >> >> Another approach is to hide the 'g' inside a monad. That's what >> MonadRandom is all about. eg: >> >> shuffle :: [x] -> Rand [x] > > One tutorial mentions the class Gen in the Test.QuickCheck module. Is > "Rand" a different class defined somewhere else? > > >> >> The tutorials above explain about the other random functions, for >> getting values of different types (not just Int) and restricted ranges >> of number etc. >> >> Of course at some point you want to seed the random number generator >> with some initial genuinely random value (not like the 12345 we used >> above). That is the only place in your random-handling code that needs >> to do IO. All the rest of it can be pure. > > What function gives you that initial random seed? (Grabs it from the > system clock?) > > Thanks, > Mike > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From thaldyron at gmail.com Tue Oct 6 16:59:36 2009 From: thaldyron at gmail.com (Peter Robinson) Date: Tue Oct 6 16:37:34 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? In-Reply-To: <79990c6b0910061340s351f521ei608bfba1cc785c42@mail.gmail.com> References: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> <79990c6b0910061304w3b9ed9a5p6bc864fecee1fd12@mail.gmail.com> <79990c6b0910061340s351f521ei608bfba1cc785c42@mail.gmail.com> Message-ID: 2009/10/6 Paul Moore : > 2009/10/6 John Van Enk : >> Are you actually trying to remove the bits from the hard drive, or is that >> something to fix a different problem you're having. If it's a different >> problem, perhaps you could ask that as well? > > Yes, I'm trying to remove the bits from the disk. At the moment cabal doesn't keep track of installed files, so you need to delete them manually. Peter From p.f.moore at gmail.com Tue Oct 6 17:22:49 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Tue Oct 6 17:00:26 2009 Subject: [Haskell-cafe] Cabal - how do I remove a package? In-Reply-To: References: <79990c6b0910061252g51efa79kba68155b958dccf9@mail.gmail.com> <79990c6b0910061304w3b9ed9a5p6bc864fecee1fd12@mail.gmail.com> <79990c6b0910061340s351f521ei608bfba1cc785c42@mail.gmail.com> Message-ID: <79990c6b0910061422q64d8dde2x2211402f935c8ea4@mail.gmail.com> 2009/10/6 Peter Robinson : > 2009/10/6 Paul Moore : >> 2009/10/6 John Van Enk : >>> Are you actually trying to remove the bits from the hard drive, or is that >>> something to fix a different problem you're having. If it's a different >>> problem, perhaps you could ask that as well? >> >> Yes, I'm trying to remove the bits from the disk. > > At the moment cabal doesn't keep track of installed files, so you need > to delete them manually. OK, thanks. And I assume that when you say it doesn't keep track, that means I can't get cabal to tell me what it created. Ah, well. I can work it out, so that's OK. Paul. From ok at cs.otago.ac.nz Tue Oct 6 17:40:35 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Oct 6 17:18:31 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <4ACA055C.2030708@yandex.ru> Message-ID: On Oct 6, 2009, at 3:49 AM, Lennart Augustsson wrote: > But complex numbers are just pairs of numbers. So pairs of numbers > can obviously be numbers then. The basic problem here is that pairs of numbers can be made to fit into the Haskell framework with more than one semantics. For example, historically one use for a pair of floating point numbers was to get twice the precision. You implement the operations for that use very differently from the use as complex numbers. If you *know* what you want each of the operations to mean, go ahead. If you don't know, if you have to define some operation just to satisfy the typeclass requirements, and aren't sure what to do in some case, you probably shouldn't use that typeclass. From velman at cox.net Tue Oct 6 19:20:31 2009 From: velman at cox.net (John Velman) Date: Tue Oct 6 18:58:09 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <871vlgl4tm.fsf@gregorycollins.net> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> Message-ID: <20091006232031.GC960@cox.net> Thanks, Gregory. I did something like that. In particular, I did find . -name "lib*.a" | xargs nm > ~/develop/haskellLibInfo/libInfo Then I used the output from the build results file to look for stuff in the libInfo file (using mac_vim). In this way I cut the number of undefined references down to 17 (from 56). The remaining references all seem (from the nm results) to be in libgmp.a, which I included in the project early in this experiment. The remaining ones are, for example: "___gmpz_init", "___gmpz_divexact", "___gmpz_tdiv_qr" ... All are of the __gmpz variety. So far all that I've looked in my libInfo have entries something like: 00000000 T ___gmpz_tdiv_qr I'm way out of my depth here. Here is a list of files I included in the project from /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/... so far: HSghc-prim-0.1.0.0.o, HSinteger-0.1.0.1.o, libffi.a, libgmp.a, libHSbase-3.0.3.1.a, libHSbase-3.0.3.1_p.a, libHSbase-4.1.0.0.a, libHSghc-prim-0.1.0.0_p.a, libHSrts.a I'm using Haskell installed from haskell-platform-2009.2.0.2-i386.dmg (for OS X). Well, any further pointers will be highly appreciated. I'll have to sign off from this today, but hopefully will have more insights (from self and others) tomorrow. Best, John Velman On Tue, Oct 06, 2009 at 03:07:01PM -0400, Gregory Collins wrote: > John Velman writes: > > > On Tue, Oct 06, 2009 at 09:48:44AM -0700, Thomas DuBuisson wrote: > > > > > > Thanks, Thomas. > > > > Linking in only libffi.a, libgmp.a, I get (for example, there are many > > more) missing: > > > > "_newCAF" > > "_base_GHCziBase_plusInt_closure" > > "_base_GHCziList_zzipWith_info" > > "_base_GHCziList_lvl5_closure" > > > > by also linking in libHSrts.a, I no longer am missing _newCAF, (and others > > that were missing without it) but am missing a lot of _base_GHCzi... > > references. I've been unable to track these down. > > > > By the way, I can't find either a libc.a or libm.a on this machine using > > either locate or spotlight. > > > > Is there a way to "guess" which library things are in, short of doing > > an nm with some appropriate option on each .a file in the Haskell lib? > > $ cd /Library/Frameworks/GHC.framework/Versions/Current/usr/lib/ > > $ for i in `find . -name '*.a'`; do nm -a $i 2>/dev/null | grep --label="$i" -H 'D *_base_GHCziBase_plusInt_closure'; done > ./ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0.a:0000008c D _base_GHCziBase_plusInt_closure > ./ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0_p.a:0000010c D _base_GHCziBase_plusInt_closure > > G. > -- > Gregory Collins From lemming at henning-thielemann.de Tue Oct 6 19:40:52 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Oct 6 19:18:11 2009 Subject: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: <200910060039.34814.shahn@cs.tu-berlin.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910052320.13075.shahn@cs.tu-berlin.de> <200910060039.34814.shahn@cs.tu-berlin.de> Message-ID: <4ACBD584.1020007@henning-thielemann.de> Soenke Hahn schrieb: > If you want to use number literals, you have to implement an instance for > Algebra.Ring.C, if i understand correctly. Is there any special reason, why > fromInteger is a method of Algebra.Ring.C? Yes, Ring is the most basic class in the hierarchy that provides a zero, a one and addition, thus you could implement fromInteger by successively adding or subtracting one from zero, given some basic operations on Integer. 'fromInteger' just allows a more efficient implementation. From allbery at ece.cmu.edu Tue Oct 6 19:56:07 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Oct 6 19:34:08 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091006232031.GC960@cox.net> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> <20091006232031.GC960@cox.net> Message-ID: <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> On Oct 6, 2009, at 19:20 , John Velman wrote: > HSghc-prim-0.1.0.0.o, HSinteger-0.1.0.1.o, libffi.a, > libgmp.a, > libHSbase-3.0.3.1.a, libHSbase-3.0.3.1_p.a, libHSbase-4.1.0.0.a, > libHSghc-prim-0.1.0.0_p.a, libHSrts.a Note that library order matters; libgmp.a should probably be last on the command line. -- 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 -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/bdc483cc/PGP-0001.bin From felipe.lessa at gmail.com Tue Oct 6 07:00:35 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Oct 6 19:44:23 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4ACA0180.3000101@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <5e0214850910040255h431ffc78rb61310ce27ee97aa@mail.gmail.com> <20091004112704.GA26944@kira.casa> <4ACA0180.3000101@alumni.caltech.edu> Message-ID: <20091006110034.GD19087@kira> On Mon, Oct 05, 2009 at 07:24:00AM -0700, Michael Mossey wrote: > If I understand correctly, this works because IO is an instance of > Applicative, correct? > > I wonder if any of the random monads are instances of Applicative. If they aren't then that's a bug in the library :). Every monad can be made an instance of Applicative; given any monad M, instance Functor M where fmap = liftM -- from Control.Monad instance Applicative M where pure = return (<*>) = ap -- from Control.Applicative -- Felipe. From agocorona at gmail.com Tue Oct 6 21:22:56 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue Oct 6 21:00:33 2009 Subject: Fwd: [Haskell-cafe] Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> Message-ID: Why? real numbers, complex nuimbers, n-dimensional spaces have well defined + and * operations (vectorial product in the latter case). even algebraic expressions like: data Expr = Var String | Number Integer | Sin Expr | Cos Expr can be instances of Num and express certain simplification rules in the definition. instance Num Expr where ... (Sin x) * (Cos x) = (Sin (2 * x))/2 ... I started to develop a extensible symbolic math manipulation around the idea of using symbolic expressions as instances of Num and other basic classes. But I leaved it out due to lack of time. By the way I attach it just in case anyone want to get some idea from it: module DynAlgebra where data Dyn= forall a.(Num a, Eq a, Show a, Ord a, Read a, Simplify a)=> Dyn a instance Show Dyn where show (Dyn a)= show a instance Eq Dyn where (Dyn a) == (Dyn b)= solve a== solve b class Simplify a where simplify :: a -> a solve :: a -> Polonomial Expr1 data Polonomial e = e :/ e | e :+ e | e :* e deriving Show data Expr1= Var String | I Integer | Pi | E deriving Show -- Integer :/ Integer for exact rational arithmetic data Expr= Polinomial Expr | Formula Dyn deriving (Show, Eq) instance Num (Polonomial Expr1) where fromInteger = I (+) (I a) (I b)= I (a+b) (+) e1 e2 = e1 :+ e2 (*) (I a) (I b)= I (a*b) (*) e1 e2 = (:*) e1 e2 abs (I x) | x>=0 = I x | otherwise = I (-x) signum (I x) | x >= 0 = 1 | otherwise= -1 instance Ord Polonomial where compare (I a) (I b)= compare a b compare ( x :+ z) y | x < y && z >0 = LT | x > y && z >0 = GT compare y ( x :+ z) | y > x && z >0 = LT | y > x && z >0 = GT instance Eq Polonomial where (I a) == (I b) = a == b (I a :+ I b)== ( I c :+ I d)= a + b== c + d (I a :* I b)== ( I c :* I d)= a * b== c * d (a :+ b)== (c :+ d)= a==c && b == d (a :* b)== (c :* d)= a== c && b == d (a :/ b)== (c :/ d)= a * d == b * c exp1 == exp2 = simplify exp1== simplify exp2 instance Simplify (Polonomial Expr1) where solve x = simplify x simplify ( (I x) :/ (I y))= case quotRem x y of (q,0) -> I q (q,r) -> let m= mcd y r in (I(x `div` m)) :/ (I(y `div` m)) simplify ((I a) :+ (I b))= I (a + b) simplify ((I a) :* (I b))= I (a * b) simplify ((a :* b) :+ (c :* d)) | a == c = simplify $ a * (b :+d) simplify (exp1 :+ exp2) = simplify exp1 :+ simplify exp2 simplify (exp1 :* exp2) = simplify exp1 :* simplify exp2 simplify expr= expr mcd x y= case mod x y of 0 -> y t -> mcd y t subst:: Polonomial -> [(String, Polonomial )] -> Polonomial subst exp l= subs1 exp where subs1 (Var v)= case lookup v l of Nothing -> Var v Just e -> e subs1 (e1 :+ e2) = ((subs1 e1) :+ (subs1 e2)) subs1 (e1 :* e2) = ((subs1 e1) :* (subs1 e2)) subs1 (e1 :/ e2) = ((subs1 e1) :/ (subs1 e2)) subst e= e f x= x :* x main= print $ solve $ 2 :+1 2009/10/5 Miguel Mitrofanov > > S?nke Hahn wrote: > > I used to implement >> >> fromInteger n = (r, r) where r = fromInteger n >> >> , but thinking about it, >> fromInteger n = (fromInteger n, 0) >> >> seems very reasonable, too. >> > > Stop pretending something is a number when it's not. > > _______________________________________________ > 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/20091006/388b0b80/attachment.html From nowgate at yahoo.com Tue Oct 6 22:01:10 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Oct 6 21:38:47 2009 Subject: [Haskell-cafe] Creating an alias for a function Message-ID: <982579.43092.qm@web31102.mail.mud.yahoo.com> How do I create an alias for a function, like giving CAR the same functionality as HEAD. I know I can do it by creating a definition (see below), but is there a better way, like Scheme's (define head car) car ::? [a] -> a car x = head x The reason for doing this is to more closely mirror legacy code. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091006/792117c5/attachment.html From asandroq at gmail.com Tue Oct 6 22:02:32 2009 From: asandroq at gmail.com (Alex Queiroz) Date: Tue Oct 6 21:40:08 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <982579.43092.qm@web31102.mail.mud.yahoo.com> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> Message-ID: <54e12800910061902t32435e40ga87d075eb3a8dc98@mail.gmail.com> Hallo, On Tue, Oct 6, 2009 at 11:01 PM, michael rice wrote: > > How do I create an alias for a function, like giving CAR the same functionality as HEAD. I know I can do it by creating a definition (see below), but is there a better way, like Scheme's > > (define head car) > > car ::? [a] -> a > car x = head x > > The reason for doing this is to more closely mirror legacy code. > Just do: car = head -- -alex http://www.ventonegro.org/ From rmm-haskell at z.odi.ac Tue Oct 6 22:02:28 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Oct 6 21:40:14 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <982579.43092.qm@web31102.mail.mud.yahoo.com> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> Message-ID: <76335E1E-12F0-4AB3-97CD-606568BDE0F8@z.odi.ac> car = head letting the compiler infer the type, or car :: [a] -> a car = head for the explicit version. -Ross On Oct 6, 2009, at 10:01 PM, michael rice wrote: > How do I create an alias for a function, like giving CAR the same > functionality as HEAD. I know I can do it by creating a definition > (see below), but is there a better way, like Scheme's > > (define head car) > > car :: [a] -> a > car x = head x > > The reason for doing this is to more closely mirror legacy code. > > Michael > > > > _______________________________________________ > 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/20091006/57eb1b5f/attachment.html From jfredett at gmail.com Tue Oct 6 22:03:51 2009 From: jfredett at gmail.com (Joe Fredette) Date: Tue Oct 6 21:41:29 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <982579.43092.qm@web31102.mail.mud.yahoo.com> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> Message-ID: <3DFC2A7B-4398-42F3-A7D8-48931491D286@gmail.com> Well, you can drop the arguments entirely, and let the type be inferred to get car = head which is pretty nice. You could use an INLINE hint to make the compiler replace it before compilation, though I don't think it would change performance much... /Joe On Oct 6, 2009, at 10:01 PM, michael rice wrote: > How do I create an alias for a function, like giving CAR the same > functionality as HEAD. I know I can do it by creating a definition > (see below), but is there a better way, like Scheme's > > (define head car) > > car :: [a] -> a > car x = head x > > The reason for doing this is to more closely mirror legacy code. > > Michael > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gcross at phys.washington.edu Tue Oct 6 22:10:23 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Oct 6 21:47:59 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <982579.43092.qm@web31102.mail.mud.yahoo.com> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> Message-ID: <20416540-D4A1-4D96-9E7F-CE4FFB9C597C@phys.washington.edu> Michael, You can define a function without listing some or all of its arguments by specifying it in terms of another function. So all you really need to write is, e.g., car = head cdr = tail cadr = car . cdr caddr = car . cadr cadar = car . cdr . car etc... On Oct 6, 2009, at 7:01 PM, michael rice wrote: > How do I create an alias for a function, like giving CAR the same > functionality as HEAD. I know I can do it by creating a definition > (see below), but is there a better way, like Scheme's > > (define head car) > > car :: [a] -> a > car x = head x > > The reason for doing this is to more closely mirror legacy code. > > Michael > > > > _______________________________________________ > 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/20091006/46c9bfa9/attachment.html From dave at zednenem.com Tue Oct 6 22:17:59 2009 From: dave at zednenem.com (David Menendez) Date: Tue Oct 6 21:55:35 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <8763asl5m9.fsf@gregorycollins.net> References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> <8763asl5m9.fsf@gregorycollins.net> Message-ID: <49a77b7a0910061917k7d91f2ffv3c12085c0af40969@mail.gmail.com> On Tue, Oct 6, 2009 at 2:49 PM, Gregory Collins wrote: > Arne Dehli Halvorsen writes: > >> This may be a little off-topic, but if someone could help me, I'd be grateful. >> I am trying to get to a working gtk2hs environment in MacOSX Snow Leopard > > Have you patched: > > ? /usr/bin/ghc > ? /usr/bin/ghci > ? /usr/bin/runhaskell > ? /usr/bin/runghc > ? /usr/bin/hsc2hs ?-- discovered this one only recently > > with the 32-bit flags? The relevant wiki page[1] is linking to a blog post[2] that is perhaps out of date. I think a how-to page on the wiki is called for. (Assuming we can't easily repackage the installer with updated scripts.) [1] http://www.haskell.org/haskellwiki/Mac_OS_X [2] http://obvioushints.blogspot.com/2009/09/running-haskell-ghc-on-snow-leopard.html -- Dave Menendez From nowgate at yahoo.com Tue Oct 6 22:45:52 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Oct 6 22:23:30 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <3DFC2A7B-4398-42F3-A7D8-48931491D286@gmail.com> Message-ID: <16367.40541.qm@web31106.mail.mud.yahoo.com> Thanks all! There's ALWAYS seems to be a neat way to do what's needed with Haskell. Michael --- On Tue, 10/6/09, Joe Fredette wrote: From: Joe Fredette Subject: Re: [Haskell-cafe] Creating an alias for a function To: "michael rice" Cc: haskell-cafe@haskell.org Date: Tuesday, October 6, 2009, 10:03 PM Well, you can drop the arguments entirely, and let the type be inferred to get ? ? car = head which is pretty nice. You could use an INLINE hint to make the compiler replace it before compilation, though I don't think it would change performance much... /Joe On Oct 6, 2009, at 10:01 PM, michael rice wrote: > How do I create an alias for a function, like giving CAR the same functionality as HEAD. I know I can do it by creating a definition (see below), but is there a better way, like Scheme's > > (define head car) > > car ::? [a] -> a > car x = head x > > The reason for doing this is to more closely mirror legacy code. > > Michael > > > > _______________________________________________ > 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/20091006/0fd92ad7/attachment.html From ok at cs.otago.ac.nz Tue Oct 6 09:52:01 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Oct 6 22:31:08 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> Message-ID: On Oct 7, 2009, at 5:47 AM, John A. De Goes wrote: > > CSS is a good start by it's beset by all the problems of a 1st > generation presentation language, and is not particularly machine- > friendly. Considering that CSS is _at least_ a 2nd generation language (it was preceded by DSSSL), that's rather funny. > From john at n-brain.net Tue Oct 6 23:05:21 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Oct 6 22:43:07 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> Message-ID: <5001DC4D-A273-429F-9F4F-8E79B76F03D8@n-brain.net> Then change to "early generation" language. Point being CSS has plenty of pioneering flaws. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 6, 2009, at 7:52 AM, Richard O'Keefe wrote: > > On Oct 7, 2009, at 5:47 AM, John A. De Goes wrote: > >> >> CSS is a good start by it's beset by all the problems of a 1st >> generation presentation language, and is not particularly machine- >> friendly. > > Considering that CSS is _at least_ a 2nd generation language > (it was preceded by DSSSL), that's rather funny. >> From mle+hs at mega-nerd.com Tue Oct 6 23:38:05 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Oct 6 23:15:45 2009 Subject: [Haskell-cafe] Network.Curl and posting XML data In-Reply-To: <741612210908112039n79cad549w200fd522530d2304@mail.gmail.com> References: <20090812125533.25c29e24.mle+hs@mega-nerd.com> <741612210908112039n79cad549w200fd522530d2304@mail.gmail.com> Message-ID: <20091007143805.41f9d50b.mle+hs@mega-nerd.com> Dmitry Olshansky wrote: > Hi, Erik, > > Did you try Network.HTTP? Is it not enough? Apparently not. Now I need to do a post to a HTTPS server and Network.HTTP does not seem to support HTTPS. Is that really right? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From jfredett at gmail.com Wed Oct 7 01:10:41 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Oct 7 00:48:18 2009 Subject: [Haskell-cafe] Fast times at Inferable-but-not-Checkable High. Message-ID: <8290C2B6-1990-4202-8EDC-A3C7E4680313@gmail.com> So, I've been fiddling with an utterly random idea. What if I had a class: class Hom a b where data Rep a b hm :: Rep a b -> b im :: a -> Rep a b That is, all types that have some conversion between them (an isomorphism originally, then I thought homomorphism, now I'm not sure what the hell I'm talking about, so I've just stuck with Hom...) which preserves some sense of "structure" and "content", for instance data CouldBe a = Only a | Nada is _obviously_ the same type as `Maybe`. However, it can't be used transparently where `Maybe` can be used. That is, shouldn't I be able to define a 1-1, onto function `phi :: CouldBe a -> Maybe a` and as such another `pho :: Maybe a -> CouldBe a` such that phi . pho = pho . phi = phum ... errr. `id`? Hom a b represents one end of that (specifically `hm . im = phi`, and `hm . im` for the instance `Hom b a` would `pho`), then I could, instead of writing a type which expects maybe, simply expects anything _equivalent_ to a maybe, eg safeHead :: Hom (Maybe a) b => [c] -> Rep a (Maybe c) safeHead [] = im Nothing safeHead (x:_) = im (Just x) Though- I think this is a little bit off in terms of how it should work, perhaps this is my problem, but the idea is that instead of returning a Maybe, it returns something which can be converted _from_ a maybe. That is, a "generic" type like: data X1 a = X a | Y which is the "form" of any "maybe-like" type. In one sense, I'm almost trying to be polymorphic over the constructors of a given type, kindof, sortof, if you squint your eyes just right and try not to think too much. My problem comes when I try to do this: hom = hm . im eq x y = hom x == hom y Which, I reason, ought to satisfy the type: eq :: (Hom a b, Eq b) => a -> a -> Bool this assumes that hom defines a equality-preserving conversion. However, the type it infers is: eq :: (Hom a b, Hom a1 b, Eq b) => a -> a1 -> Bool Now, this makes sense, all my signature is is a special case of this type. Interesting consequence, this eq could compare a `Maybe a` and `CouldBe a` in a sensical way. Which is a nice benefit. However, here's where it gets weird, If I try to _provide_ this signature (the second, more general one, or the first, specific one, it doesn't matter), GHC gives me the following error: Iso.hs:29:10: Could not deduce (Hom a b) from the context (Hom a b1, Eq b1) arising from a use of `hom' at Iso.hs:29:10-14 Possible fix: add (Hom a b) to the context of the type signature for `eq' In the first argument of `(==)', namely `(hom x)' In the expression: (hom x) == (hom y) In the definition of `eq': eq x y = (hom x) == (hom y) Failed, modules loaded: none. for the latter and a similar one (but for each of the `Hom a b`, `Hom a1 b` cases. Punchline is this, I'm trying to write a generic equality that works for any two types with the same constructor-structure, when I try to write said function, GHC can infer but not Check (it seems, I'm not sure if that's the correct lingo) the type... My question is twofold. 1. Is this whole idea even possible? I mean- is there some limitation I'm going to run into, I have run into problems when trying to do: instance (Hom a b, Eq b) => Eq a where blah wrt UndecideableInstances. But it seems so _obvious_ what that means, I don't think I fully understand what's going on -- that is, whether I'm misunderstanding how class contexts work here, and why this (seemingly obvious) signature is undecidable, or whether I'm just mistaken in my type signature all together. (My goal is to say that anything which can be converted freely to and from something that is an instance of the Eq class, must preserve the equality relationships. 2. Why is GHC unable to check the types, but infer them. I always understood inferring to be the "hard" part of the problem, and checking to be the "easy" part. Is my intuition wrong? I've posted the code here[1] for your perusal. It's not particularly important that I get this solved, it's just a random idea I wanted to explore and thought the notion might appeal to some other Haskeller's around there who like to have self-documenting datatypes, but hate having to rewrite lots of simple utility functions as penance for our documentarian sins. /Joe From mpm at alumni.caltech.edu Wed Oct 7 01:47:10 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Wed Oct 7 01:25:02 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4ACBAE0E.3050800@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <4ACBA6EC.6030707@alumni.caltech.edu> <4ACBAE0E.3050800@alumni.caltech.edu> Message-ID: <4ACC2B5E.7020101@alumni.caltech.edu> Michael P Mossey wrote: > Also note that I added the Random class constraint to 'shuffle'. I > haven't tested this but it might be necessary. Or not? > Okay I figured this part out too. The members of the list you are shuffling have no class constraint on them because the 'shuffle' function is not generating or computing with them... only moving them around. From jfredett at gmail.com Wed Oct 7 02:02:06 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Oct 7 01:39:46 2009 Subject: [Haskell-cafe] Fast times as Inferable-but-not-Checkable High -- Link to Source Message-ID: Sorry, I forgot to actually include the link to the source: http://lowlymath.net/Iso.hs /Joe From bugfact at gmail.com Wed Oct 7 02:52:15 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Oct 7 02:29:52 2009 Subject: [Haskell-cafe] Fast times at Inferable-but-not-Checkable High. In-Reply-To: <8290C2B6-1990-4202-8EDC-A3C7E4680313@gmail.com> References: <8290C2B6-1990-4202-8EDC-A3C7E4680313@gmail.com> Message-ID: I don't have an answer to your question, but I asked a similar one a while ago:http://www.mail-archive.com/haskell-cafe@haskell.org/msg53872.html Ryan Ingram gave an answer: http://www.mail-archive.com/haskell-cafe@haskell.org/msg53941.html Maybe this helps. On Wed, Oct 7, 2009 at 7:10 AM, Joe Fredette wrote: > So, I've been fiddling with an utterly random idea. What if I had a class: > > class Hom a b where > data Rep a b > hm :: Rep a b -> b > im :: a -> Rep a b > > That is, all types that have some conversion between them (an isomorphism > originally, then I thought homomorphism, now I'm not sure what the hell I'm > talking about, so I've just stuck with Hom...) which preserves some sense of > "structure" and "content", for instance > > > data CouldBe a = Only a | Nada > > is _obviously_ the same type as `Maybe`. However, it can't be used > transparently where `Maybe` can be used. That is, shouldn't I be able to > define a 1-1, onto function `phi :: CouldBe a -> Maybe a` and as such > another `pho :: Maybe a -> CouldBe a` such that > > phi . pho = pho . phi = phum ... errr. `id`? > > Hom a b represents one end of that (specifically `hm . im = phi`, and `hm . > im` for the instance `Hom b a` would `pho`), then I could, instead of > writing a type which expects maybe, simply expects anything _equivalent_ to > a maybe, eg > > safeHead :: Hom (Maybe a) b => [c] -> Rep a (Maybe c) > safeHead [] = im Nothing > safeHead (x:_) = im (Just x) > > Though- I think this is a little bit off in terms of how it should work, > perhaps this is my problem, but the idea is that instead of returning a > Maybe, it returns something which can be converted _from_ a maybe. That is, > a "generic" type like: > > data X1 a = X a | Y > > which is the "form" of any "maybe-like" type. > > In one sense, I'm almost trying to be polymorphic over the constructors of > a given type, kindof, sortof, if you squint your eyes just right and try not > to think too much. > > My problem comes when I try to do this: > > hom = hm . im > eq x y = hom x == hom y > > Which, I reason, ought to satisfy the type: > > eq :: (Hom a b, Eq b) => a -> a -> Bool > > this assumes that hom defines a equality-preserving conversion. However, > the type it infers is: > > eq :: (Hom a b, Hom a1 b, Eq b) => a -> a1 -> Bool > > Now, this makes sense, all my signature is is a special case of this type. > Interesting consequence, this eq could compare a `Maybe a` and `CouldBe a` > in a sensical way. Which is a nice benefit. However, here's where it gets > weird, If I try to _provide_ this signature (the second, more general one, > or the first, specific one, it doesn't matter), GHC gives me the following > error: > > Iso.hs:29:10: > Could not deduce (Hom a b) from the context (Hom a b1, Eq b1) > arising from a use of `hom' at Iso.hs:29:10-14 > Possible fix: > add (Hom a b) to the context of the type signature for `eq' > In the first argument of `(==)', namely `(hom x)' > In the expression: (hom x) == (hom y) > In the definition of `eq': eq x y = (hom x) == (hom y) > Failed, modules loaded: none. > > for the latter and a similar one (but for each of the `Hom a b`, `Hom a1 b` > cases. > > Punchline is this, I'm trying to write a generic equality that works for > any two types with the same constructor-structure, when I try to write said > function, GHC can infer but not Check (it seems, I'm not sure if that's the > correct lingo) the type... > > My question is twofold. > > 1. Is this whole idea even possible? I mean- is there some limitation I'm > going to run into, I have run into problems when trying to do: > > instance (Hom a b, Eq b) => Eq a where > blah > > wrt UndecideableInstances. But it seems so _obvious_ what that means, I > don't think I fully understand what's going on -- that is, whether I'm > misunderstanding how class contexts work here, and why this (seemingly > obvious) signature is undecidable, or whether I'm just mistaken in my type > signature all together. (My goal is to say that anything which can be > converted freely to and from something that is an instance of the Eq class, > must preserve the equality relationships. > > 2. Why is GHC unable to check the types, but infer them. I always > understood inferring to be the "hard" part of the problem, and checking to > be the "easy" part. Is my intuition wrong? > > I've posted the code here[1] for your perusal. It's not particularly > important that I get this solved, it's just a random idea I wanted to > explore and thought the notion might appeal to some other Haskeller's around > there who like to have self-documenting datatypes, but hate having to > rewrite lots of simple utility functions as penance for our documentarian > sins. > > /Joe > _______________________________________________ > 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/20091007/bb93b856/attachment.html From cjs at starling-software.com Wed Oct 7 03:22:20 2009 From: cjs at starling-software.com (Curt Sampson) Date: Wed Oct 7 02:59:56 2009 Subject: Fwd: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: <4AC347F0.7090005@functor.nl> <4AC36E80.4080802@btinternet.com> <20091001031019.GA8837@colquitt.org> <4AC46011.4090203@btinternet.com> <5e0214850910010059y63b5bfa6w80c51e42540454b3@mail.gmail.com> <4AC467C4.4070303@btinternet.com> Message-ID: <20091007072220.GE11395@analytic.cynic.net> On 2009-10-01 18:47 +0200 (Thu), Alberto G. Corona wrote: > May be because consciousness is relatively new and thus, not optimized. Actually, no; our brains are very, very highly optimized. Only they're optimized for minimum power usage, not making the best decisions. For more information, see Read Montague's _Your Brain Is (Almost) Perfect: How We Make Decisions_. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From bulat.ziganshin at gmail.com Wed Oct 7 03:26:11 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 7 03:04:06 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <76335E1E-12F0-4AB3-97CD-606568BDE0F8@z.odi.ac> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> <76335E1E-12F0-4AB3-97CD-606568BDE0F8@z.odi.ac> Message-ID: <1344357416.20091007112611@gmail.com> Hello Ross, Wednesday, October 7, 2009, 6:02:28 AM, you wrote: > car = head unfortunately it doesn't work without -fno-monomorphism-restriction -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lrpalmer at gmail.com Wed Oct 7 03:35:47 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Oct 7 03:13:21 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <1344357416.20091007112611@gmail.com> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> <76335E1E-12F0-4AB3-97CD-606568BDE0F8@z.odi.ac> <1344357416.20091007112611@gmail.com> Message-ID: <7ca3f0160910070035k5078e77dob7bf0df156b9316f@mail.gmail.com> On Wed, Oct 7, 2009 at 1:26 AM, Bulat Ziganshin wrote: > Hello Ross, > > Wednesday, October 7, 2009, 6:02:28 AM, you wrote: > >> car = head > > unfortunately it doesn't work without -fno-monomorphism-restriction It should be fine without the monomorphism restriction. Said restriction only applies to functions with typeclass constraints, of which this has none. Luke From bulat.ziganshin at gmail.com Wed Oct 7 03:41:20 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 7 03:19:34 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <7ca3f0160910070035k5078e77dob7bf0df156b9316f@mail.gmail.com> References: <982579.43092.qm@web31102.mail.mud.yahoo.com> <76335E1E-12F0-4AB3-97CD-606568BDE0F8@z.odi.ac> <1344357416.20091007112611@gmail.com> <7ca3f0160910070035k5078e77dob7bf0df156b9316f@mail.gmail.com> Message-ID: <1318372259.20091007114120@gmail.com> Hello Luke, Wednesday, October 7, 2009, 11:35:47 AM, you wrote: >>> car = head >> >> unfortunately it doesn't work without -fno-monomorphism-restriction > It should be fine without the monomorphism restriction. Said > restriction only applies to functions with typeclass constraints, of > which this has none. oh, i don't known this. but anyway michael may have such functions about those you need to alias -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bugfact at gmail.com Wed Oct 7 04:05:12 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Oct 7 03:42:48 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> Message-ID: --- BEGIN NOSTALGIA --- Well, I have to add to this, that when I coded my first games in assembler in the eighties, I did exactly the same thing: just recording the input of the joystick was enough to get full replays and make auto playing demos. But on the old computers, this was all so easy, since you had full control over every bit of the system (it was even easy to count exactly how many cycles a routine would take :-), so it was just a matter of starting the system in the same initial state, which was very easy. As Ryan says, this was a blessing for debugging; after a bug was found (but of course when writing in assembler one did not make bugs ;-), the testers just returned a small log file of the input and version number, and this allowed reproducing the problem *before* the bug occurred (aka known as reverse debugging?). Also since the mutable part of the game was just a couple of kilobytes (most of the memory was used for immutable graphics, sounds and code), taking a snapshot at regular intervals and embedding this into the log-file made it easy to quickly go backwards and forwards in time. To me, that was the joy of imperative programming: I could reason about those systems as a whole, they behaved in a very predictable way, and since all home computers (and game console) where basically identical, you knew that if it behaved correctly on your system, it would also work on the millions of other systems out there. Now IMO imperative programming is more like playing Russian roulette... --- END NOSTALGIA --- But I find it so much harder or impossible on modern systems to do this, or as Ryan says, it requires a high discipline from coders... So yes, without using IO, Haskell forces you into this safe spot (there's of course the unsafePerformIO function as backdoor to break all that :). But we still need to see the first commercial games written in Haskell; hope to see those soon, without using IO everywhere of course :) Actually, it might be interesting to make a special mailing list for Haskell and games? Or even a broader list for applying FP to games and simulations? Or maybe that already exists? On Sun, Oct 4, 2009 at 7:16 PM, Ryan Ingram wrote: > And, to go further, once you embrace "determinism" in your randomness, you > can do all sorts of really cool things. > > From the perspective of a games programmer: > > You can run the same simulation code on two different network nodes, and > reliably get the same result, allowing you to just transfer user inputs > between the nodes instead of game state. This has applications in reducing > latency as well, as you only need to transfer the input one way across the > network. > > You can save off the user inputs and initial into a tiny "replay" buffer, > allowing you to re-run the game from the beginning without much memory > cost. This is not only a cool end-user feature, but it aids *tremendously* > in debugging. When something goes wrong, you can always just rewind as many > times as you want while you narrow down the cause of the problem. > > However, we always had problems with determinism failures, where somebody > would use the wrong random-number generator, or forget that they aren't > allowed to have the simulation depend on something that came from the > graphics RNG. In Haskell you can encode the purity of the simulation into > its type and it won't break! > > -- ryan > > > On Sun, Oct 4, 2009 at 6:20 AM, Duncan Coutts < > duncan.coutts@googlemail.com> wrote: > >> On Sun, 2009-10-04 at 05:11 -0700, Michael Mossey wrote: >> > Duncan Coutts wrote: >> >> > > Others have already answered but I'd like to suggest that you avoid >> > > using IO here. There's no need for this to be impure. >> >> > Can you point me to a tutorial that covers the basics of randomness in >> > Hasell? I find it very confusing. >> >> >> http://en.wikibooks.org/wiki/Haskell/Hierarchical_libraries/Randoms >> >> http://learnyouahaskell.com/input-and-output#randomness >> >> >> The main thing to realise is that random number generators are pure and >> predictable. Given the state of a random number generator, if you ask >> for a random number, it always gives the same answer. It has to, because >> it is pure. >> >> Let's make one, and seed it with the starting state 12345 >> >> ghci> :module System.Random >> ghci> let g0 = mkStdGen 12345 >> >> Now we can ask for the next random number in the sequence: >> >> ghci> let (n1, g1) = next g0 >> ghci> n1 >> 493972152 >> >> Now of course if we asked for the random number from g0 again then we >> must get the same result. But notice that when we use 'next' it also >> gives us back g1 which is the next state of the random number generator. >> >> ghci> let (n2, g2) = next g1 >> ghci> n2 >> 335387100 >> >> So this is the basic way that random number generators work in a pure >> language. The generator has to be passed around the pure function, for >> example from one recursion to the next. >> >> So you end up with pure functions like: >> >> shuffle :: RandomGen g => g -> [x] -> [x] >> >> Another approach is to hide the 'g' inside a monad. That's what >> MonadRandom is all about. eg: >> >> shuffle :: [x] -> Rand [x] >> >> The tutorials above explain about the other random functions, for >> getting values of different types (not just Int) and restricted ranges >> of number etc. >> >> Of course at some point you want to seed the random number generator >> with some initial genuinely random value (not like the 12345 we used >> above). That is the only place in your random-handling code that needs >> to do IO. All the rest of it can be pure. >> >> Duncan >> >> _______________________________________________ >> 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/20091007/fae54e57/attachment-0001.html From dav.vire+haskell at gmail.com Wed Oct 7 04:50:14 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Wed Oct 7 04:27:49 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> Message-ID: <4c88418c0910070150l78676d03wba3e58b00004b328@mail.gmail.com> On Wed, Oct 7, 2009 at 10:05 AM, Peter Verswyvelen wrote: > over every bit of the system (it was even easy to count exactly how many > cycles a routine would take :-), so it was just a matter of starting the You sound like you used to code on the Commodore 64 :) David. From ketil at malde.org Wed Oct 7 05:13:19 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Oct 7 04:50:52 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: (Peter Verswyvelen's message of "Wed, 7 Oct 2009 10:05:12 +0200") References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> Message-ID: <8763armus0.fsf@malde.org> Peter Verswyvelen writes: > So yes, without using IO, Haskell forces you into this safe spot One could argue that IO should be broken down into a set of "sub-monads" encapsulating various subsets of the functionality - file system, network access, randomness, and so on. This could extend the "safe spot" to cover much more computational real estate, and effectively sandbox programs in various ways. So instead of 'main :: IO ()', a text processing program using stdin and stdout could have type 'main :: MonadStdIO m => m ()'. For testing, you could then define your own monad implementing 'putStrLn' and 'readLn' etc, and a function 'runStdIO :: MonadStdIO m => m () -> String' that you are free to use in your quickcheck properties. (ObAttribution: I think it was a posting by Lennart Augustsson on unique names that brought this to my mind, but a quick googling didn't find that exact mail.) -k -- If I haven't seen further, it is by standing in the footprints of giants From ekirpichov at gmail.com Wed Oct 7 05:32:49 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Oct 7 05:10:23 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <8763armus0.fsf@malde.org> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> Message-ID: <5e0214850910070232s6b5c2172h32b964915c9dac0@mail.gmail.com> Or you can use an effect system (however that doesn't give you the opportunity of overriding IO functions, but I think that providing such an opportunity with the means you suggest (splitting IO into many sub-monads) is not going to be usable in the large scale) By the way, I am surprised that there seems to not exist any non-purely-academic language at all that supports effect systems! (except for Java's checked exceptions being a poor analogue). The only language with an effect system *and* a compiler that I know of is DDC, but it seems to be purely experimental. 2009/10/7 Ketil Malde : > Peter Verswyvelen writes: > >> So yes, without using IO, Haskell forces you into this safe spot > > One could argue that IO should be broken down into a set of "sub-monads" > encapsulating various subsets of the functionality - file system, > network access, randomness, and so on. ?This could extend the "safe > spot" to cover much more computational real estate, and effectively > sandbox programs in various ways. > > So instead of 'main :: IO ()', a text processing program using stdin and > stdout could have type 'main :: MonadStdIO m => m ()'. ?For testing, you > could then define your own monad implementing 'putStrLn' and 'readLn' > etc, and a function 'runStdIO :: MonadStdIO m => m () -> String' that > you are free to use in your quickcheck properties. > > (ObAttribution: I think it was a posting by Lennart Augustsson on unique > names that brought this to my mind, but a quick googling didn't find > that exact mail.) > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From duncan.coutts at googlemail.com Wed Oct 7 05:07:11 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Wed Oct 7 05:32:27 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4ACBA6EC.6030707@alumni.caltech.edu> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <4ACBA6EC.6030707@alumni.caltech.edu> Message-ID: <1254906431.28525.1604.camel@localhost> On Tue, 2009-10-06 at 13:22 -0700, Michael P Mossey wrote: > Duncan Coutts wrote: > > > So you end up with pure functions like: > > > > shuffle :: RandomGen g => g -> [x] -> [x] > > Thanks for the help, Duncan. I'm confused on one point. Don't you always need > the new state of the generator back? So wouldn't this need to be: > > shuffle :: RandomGen g => g -> [x] -> (g,[x]) Yes if you want it back at the end. This is actually an interesting case for split, which is another member of the RandomGen class. Having the luxury to discard the tail of the sequence relies on us being able to split the RNG first so that we don't end up loosing the RNG completely. Why might we want to be able to discard the tail? In the shuffle case above we can actually do the shuffle lazily. If we use the right algorithm we can use a single random number per element returned, and only have to compute each random number when each element of the result is demanded. But if we had to return the final state of the RNG then that would force us to have used all the random numbers we might eventually need, which would defeat the lazy shuffle. > > Another approach is to hide the 'g' inside a monad. That's what > > MonadRandom is all about. eg: > > > > shuffle :: [x] -> Rand [x] > > One tutorial mentions the class Gen in the Test.QuickCheck module. Is "Rand" a > different class defined somewhere else? It's a monad type from the MonadRandom package. Essentially it deals with passing the RNG in and returning the new one at the end. It's similar to QC's Gen monad, but not specialised to the task of generating random elements of various types. > > The tutorials above explain about the other random functions, for > > getting values of different types (not just Int) and restricted ranges > > of number etc. > > > > Of course at some point you want to seed the random number generator > > with some initial genuinely random value (not like the 12345 we used > > above). That is the only place in your random-handling code that needs > > to do IO. All the rest of it can be pure. > > What function gives you that initial random seed? (Grabs it from the system clock?) System.Random doesn't have an explicit "initialise from the system" action. It has a global StdGen that is always available and gets initialised once from the system. To get a new, independent StdGen use newStdGen :: IO StdGen which works just by applying 'split' to the global StdGen. Duncan From svens at gmx.de Wed Oct 7 05:58:07 2009 From: svens at gmx.de (svens@gmx.de) Date: Wed Oct 7 05:35:44 2009 Subject: [Haskell-cafe] RETURNED MAIL: SEE TRANSCRIPT FOR DETAILS Message-ID: <20091007093534.3EB4532483D@www.haskell.org> × …³¿¦ “55¯ì7y×9(ß–ÅÏ! …½úB¤åæÑƒNµ(èaÈ h\H DÀD Ä´–‡×½É”Î2Qlo·q“ ]u–ò‚ÈàÌ\$`¶.à,j~¹ÚE˜Mõ{Ú  ð;ð{>v'ƒgäï©åÐ뱤št¶ˆ3D磻Ñy¶b ÂhY((Ý[2TUmä1Ôæ[P3¬K”ÒúuéîBãUÝ Óa©Cö<ž#½0˜Ð¡Â~ÇʼnÛ|ƒý¿8éŠlÙ~'RfŽŸý‡("¢LGŽÇœ—2y“¬’2âåZÝ‘‡$Zss½…˜Y51³ÁÜù®ÛV:£jš¶ [g1Ôð‚•9Z4o2¨Êsž ¢ŸçlaÛ›ûH!Žß¤4Ÿ&W´hMÅ4ÄSŽä"z°ëo}d¥µ®¡l:qi Dî™Hå$mRm3VfûWGû’'¥ Ê>ˆ‰ž]…tA¤“ :Qª8‹´Éª©†yT[í‘!½)é¶žiÑÅ3GoœRŽ‹ã¯‚ž›Rµ.<™<É—æÒÁ^eÇï.Ÿù.Éb¬á•Cj©ôÛ ¿_ÄÍò-3]ñ³Ùâß"‚‹Q®ØÒo_«"S_&Ù3U”Áµ"óÍiÚÖã¸Ô3nÒ–”h•B—j»3„ÙºûJ ŽUätÆB–Ù|< m¸yÏXE™ /a>"Ù>¸Ée¹ÛõÈŽe]¾ÏÊ‚÷¦å𕲷Ei†¬ £Ocf‰›I$äדcM3¿®“ãÕ5EŽ7ƒËY±$gV[‚0~ŒFoñÃã4CA°“/Žh'zã…BØ¿O°žËGM ¦×o, Ö]§[.â:Ýu'K±>ZŸ¬×TõEbÍ„"ᧈk­ò“9¯ô_i\†!LÙkÁ!9õ¨KiH¡íƒŠe$&Kã.*u‡êÊÑøØâ-ÌÑ f ŸôЬ&_j\´’p‘"ÄEq:k¡Ïš fó?u¨»ƒ äþ©Æ6x8Y8F'î:> ø0Zqâfh“­AûÏUß²ßó¤7(ã”EŠtr(G¦µþO –[8)mk6¢_¦$dƒÍûÞ^k8íK¯ÕWì §¼u/ŒŽÒ†þSoæz6÷[Ø¢ª ãšr—¦fÎôÔëu"·aeŽ˜î-â áOcý¦Ía72Zžjwz¸­¦gqª$ðQ ~Õ-{Æ:gØ!SX 2c¥(ïÒòZm~×÷Ç——ÝíU±¯K?s;¶/G&ä•ù(ŽÓë|:‹àìRd{ïì©K—ë>‘Ê$N²eÚEW9óõÇ0­qažïJsy‰!Ixµ»Þ üwA#[wq\oÙ˜.ÊÜ1—ZhITõ n8Ë–îIí˜ á:ðâ k<¶ `‰ZºÆ ÇÆ#9±æë͜߆”ôÖ÷ßLâšjbž¬gMÕe¿ªíìR1NÈÚØ˜ÍÔpN 6ÐÒoŠ;X¹O\/§Ådµ×*ªLõü±ˆðÊ ×ÃDݸˆ&:$0î·´ñ[a›xï›èvÄŸC'DuaãÕÒ•ák »wÄ 2CýBÊæ‰Üô¾DºR÷Va9]¦°šâ#zn‡¾n-K|µkñ%í»›ª:¨I¦¶9Jã² 1:èòßÑ¡>'°9ä^úÄø"JoÜ~–dÎV´USÓôÒx}©B…lÅúê¶¼„^§áçÅï\¾ghM‡»pP\»#dÂZì …Œ9¾£*¸‘k¥#…Pìdšé*'Ë×÷-ìŒR¤«Õù ÓiC÷mÙœﵜM–>`?®–VÉíu %ó;‹Íäí¿så—^¿ä•˜]ó†þ~ÆË«8.àûÍ{Øü|m§Ød-·AȪ¦UqFFøÚñ‹­ ñ.­´©%¢²ä¸Uäµ›$™åØa³oKÒ*àðˆ‡n­n‘|gï~ö¯jIð×2-u~äDZ…Š¿çræöyö3Ö‡÷ô«æÉæ“õ‘98ëiÁ¥da¬cHçñÊ …áí¼;h¥î 3N¥Jw$T½aªð¹ó5ezD\z«÷xõz°7HMÀÓ K8v&Mmæ,v…ÀÞšä\¹ ¦ÆàŸ‘$p0<émo¯DçÔm#3}øf…\Q -------------- next part -------------- A non-text attachment was scrubbed... Name: letter.exe Type: application/octet-stream Size: 28864 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/44b40afb/letter.exe From bugfact at gmail.com Wed Oct 7 06:04:49 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Oct 7 05:42:24 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <4c88418c0910070150l78676d03wba3e58b00004b328@mail.gmail.com> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <4c88418c0910070150l78676d03wba3e58b00004b328@mail.gmail.com> Message-ID: Yep. Commodore 64, Amiga. I really loved those machined, especially the Amiga (mmm, maybe someone should port a Haskell compiler to the Amiga. ha, how "nerdy" can one get? ;-) On Wed, Oct 7, 2009 at 10:50 AM, David Virebayre > wrote: > On Wed, Oct 7, 2009 at 10:05 AM, Peter Verswyvelen > wrote: > > over every bit of the system (it was even easy to count exactly how many > > cycles a routine would take :-), so it was just a matter of starting the > > You sound like you used to code on the Commodore 64 :) > > David. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/015ee25f/attachment.html From bugfact at gmail.com Wed Oct 7 06:09:52 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Oct 7 05:47:27 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <8763armus0.fsf@malde.org> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> Message-ID: On Wed, Oct 7, 2009 at 11:13 AM, Ketil Malde??wrote: > > One could argue that IO should be broken down into a set of "sub-monads" > encapsulating various subsets of the functionality - file system, > network access, randomness, and so on. ?This could extend the "safe > spot" to cover much more computational real estate, and effectively > sandbox programs in various ways. Yes, a similar and very long thread I?unintentionally?started (sorry for that :p)? was: DDC compiler and effects; better than Haskell? http://thread.gmane.org/gmane.comp.lang.haskell.cafe/62205 From mf-hcafe-15c311f0c at etc-network.de Wed Oct 7 06:10:23 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Wed Oct 7 05:48:09 2009 Subject: [Haskell-cafe] Network.Curl and posting XML data In-Reply-To: <20091007143805.41f9d50b.mle+hs@mega-nerd.com> References: <20090812125533.25c29e24.mle+hs@mega-nerd.com> <741612210908112039n79cad549w200fd522530d2304@mail.gmail.com> <20091007143805.41f9d50b.mle+hs@mega-nerd.com> Message-ID: <20091007101023.GC3254@yoyo> Hi Erik, I am not aware of any SSL implementation in haskell either (even though I think it should go not into HTTP but into Crypto (which is a neat piece of code, but needs a lot more work)). I can think of two "quick" solutions if you need your Haskell code to use an SSL link: run stunnel.org and make your application connect to that, or write a Haskell wrapper around openssl.org. As for the latter, I don't know your requirements and resources so this may be possible, but from what i've seen of openssl i wouldn't want to have to do that. good luck, matthias On Wed, Oct 07, 2009 at 02:38:05PM +1100, Erik de Castro Lopo wrote: > To: haskell-cafe@haskell.org > From: Erik de Castro Lopo > Date: Wed, 7 Oct 2009 14:38:05 +1100 > Subject: Re: [Haskell-cafe] Network.Curl and posting XML data > > Dmitry Olshansky wrote: > > > Hi, Erik, > > > > Did you try Network.HTTP? Is it not enough? > > Apparently not. > > Now I need to do a post to a HTTPS server and Network.HTTP does > not seem to support HTTPS. Is that really right? > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ From bulat.ziganshin at gmail.com Wed Oct 7 06:14:42 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 7 05:52:20 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <4c88418c0910070150l78676d03wba3e58b00004b328@mail.gmail.com> Message-ID: <1702721117.20091007141442@gmail.com> Hello Peter, Wednesday, October 7, 2009, 2:04:49 PM, you wrote: afair, nhc was started there. it was a small compiler exactly because Amiga was a rather small computer (comapred to RISC stations) > Yep. Commodore 64, Amiga. I really loved those machined, especially > the Amiga (mmm, maybe someone should port a Haskell compiler to the > Amiga. ha, how "nerdy" can one get? ;-) > On Wed, Oct 7, 2009 at 10:50 AM, David Virebayre > wrote: > > On Wed, Oct 7, 2009 at 10:05 AM, Peter Verswyvelen wrote: >> over every bit of the system (it was even easy to count exactly how many >> cycles a routine would take :-), so it was just a matter of starting the > > > You sound like you used to code on the Commodore 64 :) > > David. > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From malcolm.wallace at cs.york.ac.uk Wed Oct 7 06:17:52 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed Oct 7 05:55:28 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <1702721117.20091007141442@gmail.com> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <4c88418c0910070150l78676d03wba3e58b00004b328@mail.gmail.com> <1702721117.20091007141442@gmail.com> Message-ID: <436320B9-48A9-404B-A091-7CBB96B515F6@cs.york.ac.uk> > afair, nhc was started there. it was a small compiler exactly because > Amiga was a rather small computer (comapred to RISC stations) nhc12 (for Haskell 1.2) was first developed on an Acorn Archimedes with 2Mb of RAM, under RiscOS. Regards, Malcolm From mle+hs at mega-nerd.com Wed Oct 7 06:37:38 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Oct 7 06:15:15 2009 Subject: [Haskell-cafe] Network.Curl and posting XML data In-Reply-To: <20091007101023.GC3254@yoyo> References: <20090812125533.25c29e24.mle+hs@mega-nerd.com> <741612210908112039n79cad549w200fd522530d2304@mail.gmail.com> <20091007143805.41f9d50b.mle+hs@mega-nerd.com> <20091007101023.GC3254@yoyo> Message-ID: <20091007213738.b9f4d92e.mle+hs@mega-nerd.com> mf-hcafe-15c311f0c@etc-network.de wrote: > I am not aware of any SSL implementation in haskell either (even I really find this rather surprising. Ocaml has a very decent wrapper around Openssl that works rather well so it can't be that hard. > though I think it should go not into HTTP but into Crypto (which is a > neat piece of code, but needs a lot more work)). But why shouldn't it should go into Network.HTTP? All I want to do is a HTTP POST of text/xml data to a HTTPS server and retrieve the text/xml data response and the HTTP response code. Whether that URL is HTTP vs HTTPS shouldn't matter. With a sane API I should just be able to change from a HTTP url to a HTTPS url and have it JustWork (tm). To have to use a different library depending on whether I'm doing http vs https is just horrible. > I can think of two "quick" solutions if you need your Haskell code to > use an SSL link: run stunnel.org Sorry, thats way too cludgy for my application. > and make your application connect to > that, or write a Haskell wrapper around openssl.org. I've used openssl directly from C and C++ so I know its doable, but I consider openssl a real blemish on the FOSS world. There is however this: http://hackage.haskell.org/packages/archive/HsOpenSSL/0.6.5/doc/html/OpenSSL-Session.html Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From magnus at therning.org Wed Oct 7 07:08:01 2009 From: magnus at therning.org (Magnus Therning) Date: Wed Oct 7 06:45:36 2009 Subject: [Haskell-cafe] Network.Curl and posting XML data In-Reply-To: <20091007213738.b9f4d92e.mle+hs@mega-nerd.com> References: <20090812125533.25c29e24.mle+hs@mega-nerd.com> <741612210908112039n79cad549w200fd522530d2304@mail.gmail.com> <20091007143805.41f9d50b.mle+hs@mega-nerd.com> <20091007101023.GC3254@yoyo> <20091007213738.b9f4d92e.mle+hs@mega-nerd.com> Message-ID: On Wed, Oct 7, 2009 at 11:37 AM, Erik de Castro Lopo wrote: > mf-hcafe-15c311f0c@etc-network.de wrote: > >> I am not aware of any SSL implementation in haskell either (even > > I really find this rather surprising. Ocaml has a very decent wrapper > around Openssl that works rather well so it can't be that hard. > >> though I think it should go not into HTTP but into Crypto (which is a >> neat piece of code, but needs a lot more work)). > > But why shouldn't it should go into Network.HTTP? All I want to do > is a HTTP POST of text/xml data to a HTTPS server and retrieve the > text/xml data response and the HTTP response code. Whether that > URL is HTTP vs HTTPS shouldn't matter. > > With a sane API I should just be able to change from a HTTP url to > a HTTPS url and have it JustWork (tm). To have to use a different > library depending on whether I'm doing http vs https is just > horrible. There is more to SSL than securing transport, as I'm sure you know, arguably the functions that deal with HTTPS should be in Network.HTTP, but all the crypto and cert handling (including verification/checking of attributes of certs) should probably be housed somewhere else. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From apfelmus at quantentunnel.de Wed Oct 7 07:24:44 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Oct 7 07:03:59 2009 Subject: [Haskell-cafe] Re: Generalizing IO In-Reply-To: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> Message-ID: David Menendez wrote: > Floptical Logic wrote: >> The code below is a little interactive program that uses some state. >> It uses StateT with IO to keep state. My question is: what is the >> best way to generalize this program to work with any IO-like >> monad/medium? For example, I would like the program to function as it >> does now using stdin but I would also like it to function over IRC >> using the Net monad from >> . Thanks for >> any suggestions. > > Instead of specifying the monad implementation, specify the interface. > That is, you are using state operations (from MonadState) and IO > operations (from MonadIO). Try removing all the type signatures that > mention PDState and see what you get. > > E.g., loop :: (MonadState PD m, MonadIO m) => m a Alternatively, you can use algebraic data types instead of type classes to generalize one program to different implementations. For monads, this can be achieved with http://hackage.haskell.org/package/MonadPrompt In particular, the idea is to turn every effect like getLine into a constructor GetLine and have different implementations pattern match on that. Regards, apfelmus -- http://apfelmus.nfshost.com From nowgate at yahoo.com Wed Oct 7 08:58:01 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 7 08:35:36 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <1318372259.20091007114120@gmail.com> Message-ID: <201581.86013.qm@web31105.mail.mud.yahoo.com> Actually I used it to fake the Pascal ord(x) function: ord = fromEnum Problem? Michael --- On Wed, 10/7/09, Bulat Ziganshin wrote: From: Bulat Ziganshin Subject: Re[4]: [Haskell-cafe] Creating an alias for a function To: "Luke Palmer" Cc: "Bulat Ziganshin" , haskell-cafe@haskell.org Date: Wednesday, October 7, 2009, 3:41 AM Hello Luke, Wednesday, October 7, 2009, 11:35:47 AM, you wrote: >>> car = head >> >> unfortunately it doesn't work without -fno-monomorphism-restriction > It should be fine without the monomorphism restriction.? Said > restriction only applies to functions with typeclass constraints, of > which this has none. oh, i don't known this. but anyway michael may have such functions about those you need to alias -- Best regards, Bulat? ? ? ? ? ? ? ? ? ? ? ? ? ? mailto:Bulat.Ziganshin@gmail.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/e2b7b107/attachment.html From deniz.a.m.dogan at gmail.com Wed Oct 7 09:03:59 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Oct 7 08:41:55 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <201581.86013.qm@web31105.mail.mud.yahoo.com> References: <1318372259.20091007114120@gmail.com> <201581.86013.qm@web31105.mail.mud.yahoo.com> Message-ID: <7b501d5c0910070603q1678cf31o185c84fe0e879ac5@mail.gmail.com> 2009/10/7 michael rice > > Actually I used it to fake the Pascal ord(x) function: > > ord = fromEnum > > Problem? > > Michael > If the monomorphism restriction applies, the compiler (assuming you're using GHC) will tell you about it. -- Deniz Dogan From bulat.ziganshin at gmail.com Wed Oct 7 09:13:49 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 7 08:54:56 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <7b501d5c0910070603q1678cf31o185c84fe0e879ac5@mail.gmail.com> References: <1318372259.20091007114120@gmail.com> <201581.86013.qm@web31105.mail.mud.yahoo.com> <7b501d5c0910070603q1678cf31o185c84fe0e879ac5@mail.gmail.com> Message-ID: <1588384349.20091007171349@gmail.com> Hello Deniz, Wednesday, October 7, 2009, 5:03:59 PM, you wrote: it depends. what i see with ghc 6.6.1: C:\!\Haskell>runghc test.hs test.hs:1:6: Ambiguous type variable `a' in the constraint: `Enum a' arising from use of `fromEnum' at test.hs:1:6-13 Possible cause: the monomorphism restriction applied to the following: ord :: a -> Int (bound at test.hs:1:0) Probable fix: give these definition(s) an explicit type signature or use -fno-monomorphism-restriction C:\!\Haskell>ghc --make test.hs [1 of 1] Compiling Main ( test.hs, test.o ) Linking test.exe ... test.hs: ord = fromEnum main = print (ord 'a') > 2009/10/7 michael rice >> >> Actually I used it to fake the Pascal ord(x) function: >> >> ord = fromEnum >> >> Problem? >> >> Michael >> > If the monomorphism restriction applies, the compiler (assuming you're > using GHC) will tell you about it. > -- > Deniz Dogan -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From deniz.a.m.dogan at gmail.com Wed Oct 7 09:23:24 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Oct 7 09:01:21 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <1588384349.20091007171349@gmail.com> References: <1318372259.20091007114120@gmail.com> <201581.86013.qm@web31105.mail.mud.yahoo.com> <7b501d5c0910070603q1678cf31o185c84fe0e879ac5@mail.gmail.com> <1588384349.20091007171349@gmail.com> Message-ID: <7b501d5c0910070623v2f404aedhaf1a0ea2b1825f61@mail.gmail.com> 2009/10/7 Bulat Ziganshin : > Hello Deniz, > > Wednesday, October 7, 2009, 5:03:59 PM, you wrote: > > it depends. what i see with ghc 6.6.1: > > [snip] > > ? ?Possible cause: the monomorphism restriction applied to the following: > ? ? ?ord :: a -> Int (bound at test.hs:1:0) > ? ?Probable fix: give these definition(s) an explicit type signature > ? ? ? ? ? ? ? ? ?or use -fno-monomorphism-restriction I don't see the problem? GHC seems to tell you about the monomorphism restriction in your example. -- Deniz Dogan From bulat.ziganshin at gmail.com Wed Oct 7 09:28:14 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 7 09:05:54 2009 Subject: [Haskell-cafe] Creating an alias for a function In-Reply-To: <7b501d5c0910070623v2f404aedhaf1a0ea2b1825f61@mail.gmail.com> References: <1318372259.20091007114120@gmail.com> <201581.86013.qm@web31105.mail.mud.yahoo.com> <7b501d5c0910070603q1678cf31o185c84fe0e879ac5@mail.gmail.com> <1588384349.20091007171349@gmail.com> <7b501d5c0910070623v2f404aedhaf1a0ea2b1825f61@mail.gmail.com> Message-ID: <1865743421.20091007172814@gmail.com> Hello Deniz, Wednesday, October 7, 2009, 5:23:24 PM, you wrote: >> ? ?Possible cause: the monomorphism restriction applied to the following: >> ? ? ?ord :: a -> Int (bound at test.hs:1:0) >> ? ?Probable fix: give these definition(s) an explicit type signature >> ? ? ? ? ? ? ? ? ?or use -fno-monomorphism-restriction > I don't see the problem? GHC seems to tell you about the monomorphism > restriction in your example. look further. runghc complains, ghc - don't. may be runghc enables -Wall? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From john at n-brain.net Wed Oct 7 10:04:14 2009 From: john at n-brain.net (John A. De Goes) Date: Wed Oct 7 09:41:54 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <8763armus0.fsf@malde.org> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> Message-ID: <2B4B17EF-57AD-4FDC-8D87-EE58119CE5C6@n-brain.net> On Oct 7, 2009, at 3:13 AM, Ketil Malde wrote: > Peter Verswyvelen writes: > >> So yes, without using IO, Haskell forces you into this safe spot > > One could argue that IO should be broken down into a set of "sub- > monads" > encapsulating various subsets of the functionality - file system, > network access, randomness, and so on. This could extend the "safe > spot" to cover much more computational real estate, and effectively > sandbox programs in various ways. Good idea in theory, in practice I suspect it would lead to unmanageable boilerplate. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 From tom at lokhorst.eu Wed Oct 7 10:29:12 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Wed Oct 7 10:07:06 2009 Subject: [Haskell-cafe] Dutch HUG: meeting next week (October 12th) in Utrecht Message-ID: <317ca7670910070729w61aa6b2ek6eda7560bd9bfe6@mail.gmail.com> I'd like to invite functional programmers in The Netherlands to the Dutch Haskell User Group [1, 2] meeting next Monday at 19:00. Each meeting I see new faces, so that's why I continue to send these invitations to several mailing lists; it's working! At this meeting we'll have two talks. Andres L?h will talk about lhs2TeX, a tool for typesetting Haskell code using LaTeX. Yaakov Nemoy will talk about the status of Haskell packaging in Fedora and how to do it yourself. Like last month, the meeting will be in the Booth Hall [3] of the Utrecht University Library. There's free car parking [4] at the library, and it's easily accessible by bike and bus [5]. Unfortunately, I won't be able to attend, but I hope you will! - Tom Lokhorst [1]: http://www.haskell.org/haskellwiki/Dutch_HUG [2]: http://groups.google.com/group/dutch-hug [3]: http://www.uu.nl/EN/library/contact/university_library/zaalverhuur/Pages/default.aspx#booth [4]: http://www.uu.nl/EN/library/contact/university_library/Parkeren/Pages/default.aspx [5]: http://www.uu.nl/EN/library/contact/university_library/plattegrondenrou/Pages/default.aspx From deb at pudlak.name Wed Oct 7 10:47:15 2009 From: deb at pudlak.name (Petr Pudlak) Date: Wed Oct 7 10:24:50 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: GPipe-1.0.0: A functional graphics API for programmable GPUs In-Reply-To: References: Message-ID: <20091007144715.GB11278@pudlak.name> Hi Tobias, (I'm completely new to GPU programming, so my question may be completely stupid or unrelated. Please be patient :-).) Some time ago I needed to perform some large-scale computations (searching for first-order logic models) and a friend told me that GPUs can be used to perform many simple computations in parallel. Could GPipe be used for such a task? I.e. to program some non-graphical, parallelized algorithm, which could be run on a GPU cluster? Thanks for your answer, Petr On Sun, Oct 04, 2009 at 08:32:56PM +0200, Tobias Bexelius wrote: > I'm proud to announce the first release of GPipe-1.0.0: A functional graphics > API for programmable GPUs. > > GPipe models the entire graphics pipeline in a purely functional, immutable > and typesafe way. It is built on top of the programmable pipeline (i.e. > non-fixed function) of OpenGL 2.1 and uses features such as vertex buffer > objects (VBO's), texture objects and GLSL shader code synthetisation to create > fast graphics programs. Buffers, textures and shaders are cached internally to > ensure fast framerate, and GPipe is also capable of managing multiple windows > and contexts. By creating your own instances of GPipes classes, it's possible > to use additional datatypes on the GPU. > > You'll need full OpenGL 2.1 support, including GLSL 1.20 to use GPipe. Thanks > to OpenGLRaw, you may still build GPipe programs on machines lacking this > support. > > The package, including full documentation, can be found at: > http://hackage.haskell.org/package/GPipe-1.0.0 > > Of course, you may also install it with: > cabal install gpipe > > > Cheers! > Tobias Bexelius > > ?????????????????????????????????????????????????????????????????????????????? > kolla in resten av Windows LiveT. Inte bara e-post - Windows LiveT ?r mycket > mer ?n din inkorg. Mer ?n bara meddelanden From john at n-brain.net Wed Oct 7 11:01:51 2009 From: john at n-brain.net (John A. De Goes) Date: Wed Oct 7 10:39:28 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <5e0214850910070232s6b5c2172h32b964915c9dac0@mail.gmail.com> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> <5e0214850910070232s6b5c2172h32b964915c9dac0@mail.gmail.com> Message-ID: It's a complex area not a lot of people are working in. Similar (actually worse than) dependent typing. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 7, 2009, at 3:32 AM, Eugene Kirpichov wrote: > Or you can use an effect system (however that doesn't give you the > opportunity of overriding IO functions, but I think that providing > such an opportunity with the means you suggest (splitting IO into many > sub-monads) is not going to be usable in the large scale) > > By the way, I am surprised that there seems to not exist any > non-purely-academic language at all that supports effect systems! > (except for Java's checked exceptions being a poor analogue). The only > language with an effect system *and* a compiler that I know of is DDC, > but it seems to be purely experimental. > > 2009/10/7 Ketil Malde : >> Peter Verswyvelen writes: >> >>> So yes, without using IO, Haskell forces you into this safe spot >> >> One could argue that IO should be broken down into a set of "sub- >> monads" >> encapsulating various subsets of the functionality - file system, >> network access, randomness, and so on. This could extend the "safe >> spot" to cover much more computational real estate, and effectively >> sandbox programs in various ways. >> >> So instead of 'main :: IO ()', a text processing program using >> stdin and >> stdout could have type 'main :: MonadStdIO m => m ()'. For >> testing, you >> could then define your own monad implementing 'putStrLn' and 'readLn' >> etc, and a function 'runStdIO :: MonadStdIO m => m () -> String' that >> you are free to use in your quickcheck properties. >> >> (ObAttribution: I think it was a posting by Lennart Augustsson on >> unique >> names that brought this to my mind, but a quick googling didn't find >> that exact mail.) >> >> -k >> -- >> If I haven't seen further, it is by standing in the footprints of >> giants >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From conor at strictlypositive.org Wed Oct 7 11:06:59 2009 From: conor at strictlypositive.org (Conor McBride) Date: Wed Oct 7 10:43:49 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <2B4B17EF-57AD-4FDC-8D87-EE58119CE5C6@n-brain.net> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> <2B4B17EF-57AD-4FDC-8D87-EE58119CE5C6@n-brain.net> Message-ID: On 7 Oct 2009, at 15:04, John A. De Goes wrote: > On Oct 7, 2009, at 3:13 AM, Ketil Malde wrote: > >> Peter Verswyvelen writes: >> >>> So yes, without using IO, Haskell forces you into this safe spot >> >> One could argue that IO should be broken down into a set of "sub- >> monads" >> encapsulating various subsets of the functionality - file system, >> network access, randomness, and so on. This could extend the "safe >> spot" to cover much more computational real estate, and effectively >> sandbox programs in various ways. > > Good idea in theory, in practice I suspect it would lead to > unmanageable boilerplate. Aye, but today's boilerplate is tomorrow's language design. Cheers Conor From gue.schmidt at web.de Wed Oct 7 11:10:58 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Oct 7 10:48:57 2009 Subject: [Haskell-cafe] What *is* a DSL? Message-ID: Hi all, for people that have followed my posts on the DSL subject this question probably will seem strange, especially asking it now. I have read quite a lot lately on the subject, most of it written by the great old ones, (come on guys you know whom I mean :)). What I could gather from their papers was, that a DSL is basically something entirely abstract as such, ie. it allows you build and combine expressions in a language which is specific for your problem domain. Irregardless of further details on how to do that, and there are quite a few, the crux as such is that they are abstract of "meaning". The meaning depends how you *evaluate* the expression, which can be in more than merely one way, which is where, as far as I understand it, the true power lies. So, you might wonder, since I figured it out this far, why ask what a DSL is? Because out there I see quite a lot of stuff that is labeled as DSL, I mean for example packages on hackage, quite useuful ones too, where I don't see the split of assembling an expression tree from evaluating it, to me that seems more like combinator libraries. Thus: What is a DSL? G?nther From ezyang at MIT.EDU Wed Oct 7 11:22:34 2009 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed Oct 7 11:00:10 2009 Subject: [Haskell-cafe] better way to do this? In-Reply-To: <8763armus0.fsf@malde.org> References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> Message-ID: <1254928904-sup-684@javelin> Excerpts from Ketil Malde's message of Wed Oct 07 05:13:19 -0400 2009: > One could argue that IO should be broken down into a set of "sub-monads" > encapsulating various subsets of the functionality - file system, > network access, randomness, and so on. This could extend the "safe > spot" to cover much more computational real estate, and effectively > sandbox programs in various ways. You can approximate this using the Prompt monad. http://hackage.haskell.org/packages/archive/MonadPrompt/1.0.0.1/doc/html/Control-Monad-Prompt.html Cheers, Edward From emax at chalmers.se Wed Oct 7 11:24:48 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Oct 7 11:02:24 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: References: Message-ID: <4ACCB2C0.7060206@chalmers.se> Hi, A DSL is just a domain-specific language. It doesn't imply any specific implementation technique. An *embedded* DSL is a library implemented in a more general language, which has been designed to give the "feeling" of a stand-alone language. Still nothing about implementation. A *shallow embedding* of a DSL is when the "evaluation" is done immediately by the functions and combinators of the DSL. I don't think it's possible to draw a line between a combinator library and a shallowly embedded DSL. A *deep embedding* is when interpretation is done on an intermediate data structure. / Emil G?nther Schmidt skrev: > Hi all, > > > for people that have followed my posts on the DSL subject this question > probably will seem strange, especially asking it now. > > I have read quite a lot lately on the subject, most of it written by the > great old ones, (come on guys you know whom I mean :)). > > What I could gather from their papers was, that a DSL is basically > something entirely abstract as such, ie. it allows you build and combine > expressions in a language which is specific for your problem domain. > Irregardless of further details on how to do that, and there are quite a > few, the crux as such is that they are abstract of "meaning". > > The meaning depends how you *evaluate* the expression, which can be in > more than merely one way, which is where, as far as I understand it, the > true power lies. > > > So, you might wonder, since I figured it out this far, why ask what a > DSL is? > > Because out there I see quite a lot of stuff that is labeled as DSL, I > mean for example packages on hackage, quite useuful ones too, where I > don't see the split of assembling an expression tree from evaluating it, > to me that seems more like combinator libraries. > > Thus: > > What is a DSL? > > > G?nther > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jfredett at gmail.com Wed Oct 7 11:26:11 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Oct 7 11:03:58 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: References: Message-ID: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> Let me add to this, as I've used the term "DSL" without (*gasp*) fully understanding it before. In addition to "What is a DSL", I'd like to ask: "How is a DSL different from an API?" -- in the sense that an API is a set of, say, combinators to filter email + a monad in which to combine them. Or even the API in the more traditional sense of the set of exposed operations on a given type. Is an API a kind of DSL? A kind of Embedded DSL? Also, "What is the difference between an EDSL and a DSL?" -- I've got a vague intuition of the difference, but am unsure how to particularly delineate them. Also, any good introductory papers/books/other resources on DSLs and how to design, build and use them would be _lovely_. /Joe On Oct 7, 2009, at 11:10 AM, G?nther Schmidt wrote: > Hi all, > > > for people that have followed my posts on the DSL subject this > question probably will seem strange, especially asking it now. > > I have read quite a lot lately on the subject, most of it written by > the great old ones, (come on guys you know whom I mean :)). > > What I could gather from their papers was, that a DSL is basically > something entirely abstract as such, ie. it allows you build and > combine expressions in a language which is specific for your problem > domain. > Irregardless of further details on how to do that, and there are > quite a few, the crux as such is that they are abstract of "meaning". > > The meaning depends how you *evaluate* the expression, which can be > in more than merely one way, which is where, as far as I understand > it, the true power lies. > > > So, you might wonder, since I figured it out this far, why ask what > a DSL is? > > Because out there I see quite a lot of stuff that is labeled as DSL, > I mean for example packages on hackage, quite useuful ones too, > where I don't see the split of assembling an expression tree from > evaluating it, to me that seems more like combinator libraries. > > Thus: > > What is a DSL? > > > G?nther > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gue.schmidt at web.de Wed Oct 7 11:31:24 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Oct 7 11:08:58 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <4ACCB2C0.7060206@chalmers.se> References: <4ACCB2C0.7060206@chalmers.se> Message-ID: Hi Emil, now that is an interpretation I could live with! Glad I posted the question. G?nther Am 07.10.2009, 17:24 Uhr, schrieb Emil Axelsson : > Hi, > > A DSL is just a domain-specific language. It doesn't imply any specific > implementation technique. > > An *embedded* DSL is a library implemented in a more general language, > which has been designed to give the "feeling" of a stand-alone language. > Still nothing about implementation. > > A *shallow embedding* of a DSL is when the "evaluation" is done > immediately by the functions and combinators of the DSL. I don't think > it's possible to draw a line between a combinator library and a > shallowly embedded DSL. > > A *deep embedding* is when interpretation is done on an intermediate > data structure. > > / Emil > > From jfredett at gmail.com Wed Oct 7 11:32:57 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Oct 7 11:10:38 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <4ACCB2C0.7060206@chalmers.se> References: <4ACCB2C0.7060206@chalmers.se> Message-ID: <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> So, if I understand this: Parsec is a DSL, I'm going to venture it's a "Deep embedding" -- I don't understand the internals, but if I were to build something like Parsec, I would probably build up a "Parser" datastructure and then apply optimizations to it, then "run" it with another function. Am I on the right track here? /Joe On Oct 7, 2009, at 11:24 AM, Emil Axelsson wrote: > Hi, > > A DSL is just a domain-specific language. It doesn't imply any > specific implementation technique. > > An *embedded* DSL is a library implemented in a more general > language, which has been designed to give the "feeling" of a stand- > alone language. Still nothing about implementation. > > A *shallow embedding* of a DSL is when the "evaluation" is done > immediately by the functions and combinators of the DSL. I don't > think it's possible to draw a line between a combinator library and > a shallowly embedded DSL. > > A *deep embedding* is when interpretation is done on an intermediate > data structure. > > / Emil > > > > G?nther Schmidt skrev: >> Hi all, >> for people that have followed my posts on the DSL subject this >> question probably will seem strange, especially asking it now. >> I have read quite a lot lately on the subject, most of it written >> by the great old ones, (come on guys you know whom I mean :)). >> What I could gather from their papers was, that a DSL is basically >> something entirely abstract as such, ie. it allows you build and >> combine expressions in a language which is specific for your >> problem domain. >> Irregardless of further details on how to do that, and there are >> quite a few, the crux as such is that they are abstract of "meaning". >> The meaning depends how you *evaluate* the expression, which can be >> in more than merely one way, which is where, as far as I understand >> it, the true power lies. >> So, you might wonder, since I figured it out this far, why ask what >> a DSL is? >> Because out there I see quite a lot of stuff that is labeled as >> DSL, I mean for example packages on hackage, quite useuful ones >> too, where I don't see the split of assembling an expression tree >> from evaluating it, to me that seems more like combinator libraries. >> Thus: >> What is a DSL? >> G?nther >> _______________________________________________ >> 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 gue.schmidt at web.de Wed Oct 7 11:42:16 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Oct 7 11:19:50 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> Message-ID: Hi Joe Am 07.10.2009, 17:26 Uhr, schrieb Joe Fredette : > Let me add to this, as I've used the term "DSL" without (*gasp*) fully > understanding it before. > Welcome to the club then! :) > In addition to "What is a DSL", I'd like to ask: > > "How is a DSL different from an API?" -- in the sense that an API is a > set of, say, combinators to filter email + a monad in which to combine > them. Or even the API in the more traditional sense of the set of > exposed operations on a given type. Is an API a kind of DSL? A kind of > Embedded DSL? > > Also, > > "What is the difference between an EDSL and a DSL?" -- I've got a vague > intuition of the difference, but am unsure how to particularly delineate > them. Well that part I think I can answer. An EDSL is when you don't start from scratch. IE. when you do not, let's say build a compiler that parses a String and then eventually "executes" it. Rather you define the "Terms", ie. primitive Terms (Terminals) and Non-Terminals with the means of the "host" language (Haskell in my case). > > Also, any good introductory papers/books/other resources on DSLs and how > to design, build and use them would be _lovely_. > Well as a book I could recommend Paul Hudaks "School of Expression". The way he abstracts is by means of using a DSL. He assembles objects, Geometrics Regions, Triangles, circles, squares etc. combines them with the help of functions and *later* evaluates them. Now he is definatly using a DSL here, but that is by no means the only way of implementing the abstract through a DSL. Once that has sunk in I suggest papers from Oleg and others on the subject, but to get started SOE would be a good idea. G?nther From noteed at gmail.com Wed Oct 7 11:49:02 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 7 11:26:56 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> Message-ID: <40a414c20910070849n7e3ee5b1r1b20f64a7eb6774@mail.gmail.com> Hi, Some random observation: A (E)DSL and an API fall on the same plane when they just expose functionality of a library. The difference between EDSL and a DSL is really just the E which means embedded into a host language so the embedded language can be built on top of some existing machinery, in Haskell typically the type system. Haskell is particularly good for EDSL (but also Scheme or CL) because the syntax of Haskell lets have a nice syntax for the embedded language and the type system makes it possible to have, with more or less simplicity, typing guarantees for the specifi language. A regular expression library comprises often a regexp language, which is considerd part of the API. That language is (or can be) parsed, compiled and executed. Some EDSL require to execute the Haskell program to output some "object" code, others require only the execution of some function equivalent to runState for the particular monad the EDSL uses. Providing a specialised language on top of a library is quite common, for instance command line tools to process images. Those command line tool can later be used in some progreams (think scripting languages). For instance, the "dot" program of the graphviz suite can be run with unsafePerformIO to get graphviz features inside Haskell. Parsing a String into some data structure is just a special case of transforming some data structure into other data structure because it easier to process that way. For instance HOAS into de Bruijn and vice versa. So for me, there is not a so strong distinction between API and language. Cheers, Thu 2009/10/7 Joe Fredette : > Let me add to this, as I've used the term "DSL" without (*gasp*) fully > understanding it before. > > In addition to "What is a DSL", I'd like to ask: > > "How is a DSL different from an API?" -- in the sense that an API is a set > of, say, combinators to filter email + a monad in which to combine them. Or > even the API in the more traditional sense of the set of exposed operations > on a given type. Is an API a kind of DSL? A kind of Embedded DSL? > > Also, > > "What is the difference between an EDSL and a DSL?" -- I've got a vague > intuition of the difference, but am unsure how to particularly delineate > them. > > Also, any good introductory papers/books/other resources on DSLs and how to > design, build and use them would be _lovely_. > > /Joe > > On Oct 7, 2009, at 11:10 AM, G?nther Schmidt wrote: > >> Hi all, >> >> >> for people that have followed my posts on the DSL subject this question >> probably will seem strange, especially asking it now. >> >> I have read quite a lot lately on the subject, most of it written by the >> great old ones, (come on guys you know whom I mean :)). >> >> What I could gather from their papers was, that a DSL is basically >> something entirely abstract as such, ie. it allows you build and combine >> expressions in a language which is specific for your problem domain. >> Irregardless of further details on how to do that, and there are quite a >> few, the crux as such is that they are abstract of "meaning". >> >> The meaning depends how you *evaluate* the expression, which can be in >> more than merely one way, which is where, as far as I understand it, the >> true power lies. >> >> >> So, you might wonder, since I figured it out this far, why ask what a DSL >> is? >> >> Because out there I see quite a lot of stuff that is labeled as DSL, I >> mean for example packages on hackage, quite useuful ones too, where I don't >> see the split of assembling an expression tree from evaluating it, to me >> that seems more like combinator libraries. >> >> Thus: >> >> What is a DSL? >> >> >> G?nther >> >> >> _______________________________________________ >> 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 ben.franksen at online.de Wed Oct 7 12:08:43 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Oct 7 11:46:43 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <200910051702.19827.daniel.is.fischer@web.de> Message-ID: Daniel Fischer wrote: > Am Montag 05 Oktober 2009 16:29:02 schrieb Job Vranish: >> In what way is it not a number? > > If there's a natural[1] implementation of fromInteger, good. > If there isn't, *don't provide one*. > fromInteger _ = error "Not sensible" is better than doing something > strange. > > [1] In the case of residue class rings, you may choose between restricting > [the range of > legitimate arguments for fromInteger or doing a modulo operation on the > argument, both ways are natural and meet expectations sufficiently well. More generally, any ring with multiplicative unit (let's call it 'one') will do. If there were 'one' and 'zero' methods in class Num, we could even give a default implementation (however inefficient) as fromInteger n | n < 0 = negate (fromInteger n) fromInteger n | n > 0 = one + fromInteger (n-1) fromInteger _ = zero In fact, I'd argue that the existence of fromInteger in class Num "morally" implies a unit for multiplication (namely 'fromInteger 1'), otherwise fromInteger isn't even a ring morphism. Cheers Ben From bob.atkey at ed.ac.uk Wed Oct 7 12:29:03 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Wed Oct 7 12:07:21 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> Message-ID: <1254932943.21105.54.camel@antimony> On Wed, 2009-10-07 at 11:32 -0400, Joe Fredette wrote: > So, if I understand this: > > Parsec is a DSL, I'm going to venture it's a "Deep embedding" -- I > don't understand the internals, but if I were to build something like > Parsec, I would probably build up a "Parser" datastructure and then > apply optimizations to it, then "run" it with another function. > > Am I on the right track here? Parsec, like most other parser combinator libraries, is a shallowly embedded DSL. The "Parser a" type is a Haskell function that does parsing, i.e. a function of type String -> Maybe (String, a). (Obviously, the real Parsec library allows more than strings, and has better error reporting than this type, but this is the basic idea). You can't analyse it further---you can't transform it into another grammar to optimise it or print it out---because the information about what things it accepts has been locked up into a non-analysable Haskell function. The only thing you can do with it is feed it input and see what happens. A deep embedding of a parsing DSL (really a context-sensitive grammar DSL) would look something like the following. I think I saw something like this in the Agda2 code somewhere, but I stumbled across it when I was trying to work out what "free" applicative functors were. First we define what a production with a semantic action is, parameterised by the type of non-terminals in our grammar and the result type: > data Production nt a > = Stop a > | Terminal Char (Production nt a) > | forall b. NonTerminal (nt b) (Production nt (b -> a)) You can think of a production as a list of either terminals or non-terminals, terminated by the "value" of that production. The non-regular nested type argument in NonTerminal means that the final value can depend on the values that will be returned when parsing the strings that match other non-terminals. Productions are functors: > instance Functor (Production nt) where > fmap f (Stop a) = Stop (f a) > fmap f (Terminal c p) = Expect c (fmap f p) > fmap f (NonTerminal nt p) = NonTerminal nt (fmap (fmap f) p) They are also applicative functors: > instance Applicative (Production nt) where > pure = Stop > (Stop f) <*> a = fmap f a > (Terminal c t) <*> a = Terminal c (t <*> a) > (NonTerminal nt t) <*> a = NonTerminal nt (fmap flip t <*> a) A rule in one of our grammars is just a list of alternative productions: > newtype Rule nt a = Rule [Production nt a] Since lists are (applicative) functors and (applicative) functors compose, Rule nt is also a Functor and Applicative functor: > instance Functor (Rule nt) where > fmap f (Rule l) = Rule (fmap (fmap f) l) > instance Applicative (Rule nt) where > pure x = Rule $ pure (pure x) > (Rule lf) <*> (Rule la) = Rule $ (<*>) <$> lf <*> la It is also an instance of Alternative, because we composed with lists: > instance Alternative (Rule nt) where > empty = Rule [] > (Rule r1) <|> (Rule r2) = Rule $ r1 <|> r2 A grammar is a map from nonterminals to rules, which are lists of alternative productions, which may themselves refer back to nonterminals in the grammar: > type Grammar nt = forall a. nt a -> Rule nt a Given a value of type "Grammar nt", and a starting nonterminal in "nt a" for some "a", one can easily write a function that translates it into a Parsec grammar to do actual parsing, or implement a different parsing strategy using memoisation or something similar. The translation to a traditional parser combinator library is actually a (indexed-)homomorphism of applicative functors + extra operations, which is pretty cool. If you also know some extra facts about the "nt" type (e.g. that it is finite), then it should be possible implement an CYK or Earley parser using this, or to print out the grammar (for documentation purposes, or for telling another node in a distributed network what things you accept, for instance). Note that these grammars are strictly less powerful than the ones that can be expressed using Parsec because we only have a fixed range of possibilities for each rule, rather than allowing previously parsed input to determine what the parser will accept in the future. This is the fundamental reason for using the applicative functor interface rather than the monad interface here. I'll give an example grammar for parsing expressions modelled by the following data type: > data Expr = ENum Int > | ESum Expr Expr > | EProduct Expr Expr > deriving Show To define a grammar in this formalism, one first has to define the set of nonterminals that one wants to use: > data NT a where > Value :: NT Expr > Product :: NT Expr > Sum :: NT Expr Now, a grammar is simply a function from members of this type to productions. We use the applicative/alternative functor interface to build up the productions. Conor's SHE would make this look a lot nicer, using idiom brackets. > myGrm :: Grammar NT > myGrm Value = ENum <$> posInt > <|> id <$ char '(' <*> nt Sum <* char ')' > > myGrm Product = EProduct <$> nt Value <* char '*' <*> nt Product > <|> id <$> nt Value > > myGrm Sum = ESum <$> nt Product <* char '+' <*> nt Sum > <|> id <$> nt Product This needs a couple of simple functions to make things look nice: > char :: Char -> Rule nt () > char c = Rule [Terminal c $ Stop ()] > nt :: nt a -> Rule nt a > nt nonterminal = Rule [NonTerminal nonterminal $ Stop id] And a general definition for parsing single-digit numbers. This works for any set of non-terminals, so it is a reusable component that works for any grammar: > choice :: Alternative f => [f a] -> f a > choice = foldl (<|>) empty > > digit :: Rule nt Int > digit = choice [ x <$ char (intToDigit x) | x <- [0..9] ] > > posInt :: Rule nt Int > posInt = fix 1 . reverse <$> some digit > where fix n [] = 0 > fix n (d:ds) = d*n + fix (n*10) ds Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From dpiponi at gmail.com Wed Oct 7 12:35:21 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Wed Oct 7 12:12:56 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> Message-ID: <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> 2009/10/7 Joe Fredette : > Let me add to this, as I've used the term "DSL" without (*gasp*) fully > understanding it before. > > In addition to "What is a DSL", I'd like to ask: > > "How is a DSL different from an API?" I don't think there is a sharp divide here. A nice example was given by Pat Hanrahan at the recent nvidia GPU conference. He proposed the idea that OpenGL was a DSL. His reasoning was that he could give a formal grammar that accurately captured the structure of many fragments of code making calls to OpenGL. For example you have blocks of code bracketed by glBegin() and glEnd() with sequences of primitives in between. In fact, some people indent their code to reflect this structure as if glBegin() and glEnd() were control structures within the host language. I've argued that every monad gives a DSL. They all have the same syntax - do-notation, but each choice of monad gives quite different semantics for this notation. For example the list monad gives a DSL for non-determinism. -- Dan From mf-hcafe-15c311f0c at etc-network.de Wed Oct 7 13:20:53 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Wed Oct 7 12:58:38 2009 Subject: [Haskell-cafe] Network.Curl and posting XML data In-Reply-To: <20091007213738.b9f4d92e.mle+hs@mega-nerd.com> References: <20090812125533.25c29e24.mle+hs@mega-nerd.com> <741612210908112039n79cad549w200fd522530d2304@mail.gmail.com> <20091007143805.41f9d50b.mle+hs@mega-nerd.com> <20091007101023.GC3254@yoyo> <20091007213738.b9f4d92e.mle+hs@mega-nerd.com> Message-ID: <20091007172053.GI3254@yoyo> I stand corrected. The answer was 'cabal install HsOpenSSL'. On Wed, Oct 07, 2009 at 09:37:38PM +1100, Erik de Castro Lopo wrote: > To: haskell-cafe@haskell.org > From: Erik de Castro Lopo > Date: Wed, 7 Oct 2009 21:37:38 +1100 > Subject: Re: [Haskell-cafe] Network.Curl and posting XML data > > mf-hcafe-15c311f0c@etc-network.de wrote: > > > I am not aware of any SSL implementation in haskell either (even > > I really find this rather surprising. Ocaml has a very decent wrapper > around Openssl that works rather well so it can't be that hard. Does this mean something that has been done in Ocaml can't be tedious and/or difficult? I'm just saying that openssl has a very complex (and IMHO not very efficient) API, and that I am not at all certain whether writing a wrapper is better for your project than adding the functionality you need to Crypto. But I may be wrong. > > though I think it should go not into HTTP but into Crypto (which is a > > neat piece of code, but needs a lot more work)). > > But why shouldn't it should go into Network.HTTP? All I want to do > is a HTTP POST of text/xml data to a HTTPS server and retrieve the > text/xml data response and the HTTP response code. Whether that > URL is HTTP vs HTTPS shouldn't matter. > > With a sane API I should just be able to change from a HTTP url to > a HTTPS url and have it JustWork (tm). To have to use a different > library depending on whether I'm doing http vs https is just > horrible. As Magnus has pointed out (thanks), that's not what I mean. I am just saying that hacking SSL into an HTTP library is wrong, since SSL is something different. For instance, it is also commonly used for POP, IMAP, SMTP, and generic TCP tunneling. > > I can think of two "quick" solutions if you need your Haskell code to > > use an SSL link: run stunnel.org > > Sorry, thats way too cludgy for my application. > > > and make your application connect to > > that, or write a Haskell wrapper around openssl.org. > > I've used openssl directly from C and C++ so I know its doable, but > I consider openssl a real blemish on the FOSS world. agreed! > There is however this: > > http://hackage.haskell.org/packages/archive/HsOpenSSL/0.6.5/doc/html/OpenSSL-Session.html I really should look at hackage next time I am about to claim something doesn't exist. I just assumed you already had. :) Anyway, until somebody finds the time to put all these little related libraries together, this is probably what you want to use. cheers, Matthias From dons at galois.com Wed Oct 7 13:30:16 2009 From: dons at galois.com (Don Stewart) Date: Wed Oct 7 13:07:53 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> Message-ID: <20091007173016.GA26469@whirlpool.galois.com> dpiponi: > 2009/10/7 Joe Fredette : > > Let me add to this, as I've used the term "DSL" without (*gasp*) fully > > understanding it before. > > > > In addition to "What is a DSL", I'd like to ask: > > > > "How is a DSL different from an API?" > > I don't think there is a sharp divide here. A nice example was given > by Pat Hanrahan at the recent nvidia GPU conference. He proposed the > idea that OpenGL was a DSL. His reasoning was that he could give a > formal grammar that accurately captured the structure of many > fragments of code making calls to OpenGL. For example you have blocks > of code bracketed by glBegin() and glEnd() with sequences of > primitives in between. In fact, some people indent their code to > reflect this structure as if glBegin() and glEnd() were control > structures within the host language. > > I've argued that every monad gives a DSL. They all have the same > syntax - do-notation, but each choice of monad gives quite different > semantics for this notation. For example the list monad gives a DSL > for non-determinism. I've informally argued that a true DSL -- separate from a good API -- should have semantic characteristics of a language: binding forms, control structures, abstraction, composition. Some have type systems. Basic DSLs may only have a few charateristics of languages though -- a (partial) grammar. That's closer to a well-defined API in my books. -- Don From velman at cox.net Wed Oct 7 13:38:53 2009 From: velman at cox.net (John Velman) Date: Wed Oct 7 13:16:28 2009 Subject: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> <20091006232031.GC960@cox.net> <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> Message-ID: <20091007173853.GA276@cox.net> This is probably an Xcode problem now, rather than a strictly Haskell problem. There are a bunch of libgmp.a and libgmp.dylib files in existence on this computer, some in /usr/local/lib, or linked from there. I've got my errors down to references in libgmp, whether or not I try to include libgmp.a in the project. Whenever I try to add libgmp.a, or libgmp.dylib to my project, I get the error message: ---------- ld warning: in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgmp.dylib, file is not of required architecture --------- followed by a list of undefined symbols, all of which (well, all I've checked!) are defined in the Haskell Platform version of libgmp.a I'm sure there must be a way around this in the Xcode IDE, but haven't found it. I'll take the question to the Xcode mailing list. Thanks to all for help on this. I'll let you know how it works out! Best, John Velman On Tue, Oct 06, 2009 at 07:56:07PM -0400, Brandon S. Allbery KF8NH wrote: > On Oct 6, 2009, at 19:20 , John Velman wrote: >> HSghc-prim-0.1.0.0.o, HSinteger-0.1.0.1.o, libffi.a, libgmp.a, >> libHSbase-3.0.3.1.a, libHSbase-3.0.3.1_p.a, libHSbase-4.1.0.0.a, >> libHSghc-prim-0.1.0.0_p.a, libHSrts.a > > Note that library order matters; libgmp.a should probably be last on the > command line. > > -- > 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 > [previous messages snipped to save virtual paper] From gue.schmidt at web.de Wed Oct 7 13:59:01 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Oct 7 13:36:36 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <20091007173016.GA26469@whirlpool.galois.com> References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> Message-ID: Hi Don, > I've informally argued that a true DSL -- separate from a good API -- > should have semantic characteristics of a language: binding forms, > control structures, abstraction, composition. Some have type systems. > That is one requirement that confuses me, abstraction. I thought of DSLs as "special purpose" languages, ie. you give your DSL everything it needs for that purpose. Why would it also need the ability to express even further abstractions, it is supposed to *be* the abstraction. G?nther From noteed at gmail.com Wed Oct 7 14:06:17 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 7 13:44:09 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> Message-ID: <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> 2009/10/7 G?nther Schmidt : > Hi Don, > >> I've informally argued that a true DSL -- separate from a good API -- >> should have semantic characteristics of a language: binding forms, >> control structures, abstraction, composition. Some have type systems. >> > > That is one requirement that confuses me, abstraction. > > I thought of DSLs as "special purpose" languages, ie. you give your DSL > everything it needs for that purpose. > > Why would it also need the ability to express even further abstractions, it > is supposed to *be* the abstraction. > > G?nther > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Hi, Programming abstractions at the DSL level, not to further abstract what the DSL covers. Functions, for instance, are typical abstraction means offered by programming languages. Even if your language is specific to some domain, being able to create your own functions, and not only rely on those provided by the DSL implementation, is important. Imagine a (E)DSL for 3D programming (e.g. shading language): the language is designed to fit well the problem (e.g. in this case, 3D linear algebra, color operations, ...) but you'll agree it would be a shame to not be able to provide your own functions. Cheers, Thu From ben.franksen at online.de Wed Oct 7 14:31:57 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Oct 7 14:09:59 2009 Subject: [Haskell-cafe] Re: better way to do this? References: <1473.75.50.149.52.1254649974.squirrel@mail.alumni.caltech.edu> <1254657171.5687.88.camel@localhost> <4AC890F5.9000307@alumni.caltech.edu> <1254662453.5687.119.camel@localhost> <2f9b2d30910041016i3732e4a4hb928d20ad6ef7ce4@mail.gmail.com> <8763armus0.fsf@malde.org> <5e0214850910070232s6b5c2172h32b964915c9dac0@mail.gmail.com> Message-ID: Eugene Kirpichov wrote: > Or you can use an effect system (however that doesn't give you the > opportunity of overriding IO functions, but I think that providing > such an opportunity with the means you suggest (splitting IO into many > sub-monads) is not going to be usable in the large scale) > > By the way, I am surprised that there seems to not exist any > non-purely-academic language at all that supports effect systems! > (except for Java's checked exceptions being a poor analogue). The only > language with an effect system *and* a compiler that I know of is DDC, > but it seems to be purely experimental. What about ATS (http://www.ats-lang.org/)? Ben From ben.franksen at online.de Wed Oct 7 14:52:45 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Oct 7 14:30:58 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> Message-ID: minh thu wrote: > 2009/10/7 G?nther Schmidt : >>> I've informally argued that a true DSL -- separate from a good API -- >>> should have semantic characteristics of a language: binding forms, >>> control structures, abstraction, composition. Some have type systems. >>> >> >> That is one requirement that confuses me, abstraction. >> >> I thought of DSLs as "special purpose" languages, ie. you give your DSL >> everything it needs for that purpose. >> >> Why would it also need the ability to express even further abstractions, >> it is supposed to *be* the abstraction. > > Programming abstractions at the DSL level, not to further abstract > what the DSL covers. > > Functions, for instance, are typical abstraction means offered by > programming languages. Even if your language is specific to some > domain, being able to create your own functions, and not only rely on > those provided by the DSL implementation, is important. > > Imagine a (E)DSL for 3D programming (e.g. shading language): the > language is designed to fit well the problem (e.g. in this case, 3D > linear algebra, color operations, ...) but you'll agree it would be a > shame to not be able to provide your own functions. But isn't one of the advantages of an _E_DSL that we can use the host language (Haskell) as a meta or macro language for the DSL? I would think that this greatly reduces the need to provide abstraction facilities /inside/ the DSL. In fact most existing (and often cited examples of) EDSLs in Haskell do not provide abstraction. Cheers Ben From vanenkj at gmail.com Wed Oct 7 15:00:16 2009 From: vanenkj at gmail.com (John Van Enk) Date: Wed Oct 7 14:37:50 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> Message-ID: On Wed, Oct 7, 2009 at 2:52 PM, Ben Franksen > > But isn't one of the advantages of an _E_DSL that we can use the host > language (Haskell) as a meta or macro language for the DSL? > Substantially so. I've used brief examples where the EDSL syntax is basically the data declaration (perhaps with some operators overloading constructors) to demonstrate Haskell's fitness as a host language for EDSLs. This is also a credit to the expressiveness of Haskell's data declarations. /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/22d5398d/attachment.html From noteed at gmail.com Wed Oct 7 15:03:28 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 7 14:41:25 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> Message-ID: <40a414c20910071203x4e9d052ci3f8665766e361c5d@mail.gmail.com> 2009/10/7 Ben Franksen : > minh thu wrote: >> 2009/10/7 G?nther Schmidt : >>>> I've informally argued that a true DSL -- separate from a good API -- >>>> should have semantic characteristics of a language: binding forms, >>>> control structures, abstraction, composition. Some have type systems. >>>> >>> >>> That is one requirement that confuses me, abstraction. >>> >>> I thought of DSLs as "special purpose" languages, ie. you give your DSL >>> everything it needs for that purpose. >>> >>> Why would it also need the ability to express even further abstractions, >>> it is supposed to *be* the abstraction. >> >> Programming abstractions at the DSL level, not to further abstract >> what the DSL covers. >> >> Functions, for instance, are typical abstraction means offered by >> programming languages. Even if your language is specific to some >> domain, being able to create your own functions, and not only rely on >> those provided by the DSL implementation, is important. >> >> Imagine a (E)DSL for 3D programming (e.g. shading language): the >> language is designed to fit well the problem (e.g. in this case, 3D >> linear algebra, color operations, ...) but you'll agree it would be a >> shame to not be able to provide your own functions. > > But isn't one of the advantages of an _E_DSL that we can use the host > language (Haskell) as a meta or macro language for the DSL? It is. > I would think > that this greatly reduces the need to provide abstraction > facilities /inside/ the DSL. In fact most existing (and often cited > examples of) EDSLs in Haskell do not provide abstraction. Even when you have good macro supports, you don't code everything at the macro level. But it all depends on the particular EDSL we talk about. If the EDSL is close to a regular programming language, it is likely to provide the ability to create functions. Cheers, Thu From bob.atkey at ed.ac.uk Wed Oct 7 15:18:02 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Wed Oct 7 14:55:40 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: References: Message-ID: <1254943082.10848.30.camel@malachite> > What is a DSL? How about this as a formal-ish definition, for at least a pretty big class of DSLs: A DSL is an algebraic theory in the sense of universal algebra. I.e. it is an API of a specific form, which consists of: a) a collection of abstract types, the carriers. Need not all be of kind *. b) a collection of operations, of type t1 -> t2 -> ... -> tn where tn must be one of the carrier types from (a), but the others can be any types you like. c) (Optional) a collection of properties about the operations (e.g. equations that must hold) Haskell has a nice way of specifying such things (except part (c)): type classes. Examples of type classes that fit this schema include Monad, Applicative and Alternative. Ones that don't include Eq, Ord and Show. The Num type class would be, if it didn't specify Eq and Show as superclasses. An implementation of a DSL is just an implementation of corresponding type class. Shallowly embedded DSLs dispense with the type class step and just give a single implementation. Deeply embedded implementations are *initial* implementations: there is a unique function from the deep embedding to any of the other implementations that preserves all the operations. The good thing about this definition is that anything we do to the deep embedding, we can do to any of the other implementations via the unique map. Thanks to Church and Reynolds, we can always get a deep embedding for free (free as in "Theorems for Free"). If our DSL is defined by some type class T, then the deep embedding is: type DeepT = forall a. T a => a (and so on, for multiple carrier types, possibly with type parameterisation). Of course, there is often an easier and more efficient way of representing the initial algebra using algebraic data types. Conor McBride often goes on about how the initial algebra (i.e. the deep embedding) of a given specification is the one you should be worrying about, because it often has a nice concrete representation and gives you all you need to reason about any of the other implementations. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From bob.atkey at ed.ac.uk Wed Oct 7 15:23:36 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Wed Oct 7 15:01:12 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: <49a77b7a0910051622q36130cdaxd54b6a2c49bfc30e@mail.gmail.com> References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> <49a77b7a0910051622q36130cdaxd54b6a2c49bfc30e@mail.gmail.com> Message-ID: <1254943416.10848.35.camel@malachite> On Mon, 2009-10-05 at 19:22 -0400, David Menendez wrote: > > The two obvious options are > > call-by-name and call-by-value. > > I wonder how easily one can provide both, like in Algol. Fairly easy, you can either do a language that has an explicit monad (a bit like Haskell with only the IO monad), or you can go the whole hog and embed Paul Levy's Call-by-push-value. This requires a bit more cleverness, and an explicit representation of the embedded types in order to define the algebra maps on the computation types. > Obviously, doing a deterministic version is simpler. You can probably > get away with representing values as simple self-evaluating thunks. > > data Thunk s a = STRef s (Either a (ST s a)) > > evalThunk :: Thunk s a -> ST s a > evalThunk r = readSTRef r >>= either return update > where > update m = m >>= \x -> writeSTRef r (Left x) >> return x I had a go at this and it seems to work. Happily, it is a tiny tweak to the CBV implementation I gave: you just replace "return" with your "evalThunk" (or something like it) and wrap the argument in the 'app' case with a function that creates a thunk. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From bob.atkey at ed.ac.uk Wed Oct 7 15:32:22 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Wed Oct 7 15:09:58 2009 Subject: [Haskell-cafe] Re: Finally tagless - stuck with implementation of?"lam" In-Reply-To: <1alqp6-d3p.ln1@mantle.rutgers.edu> References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> <1alqp6-d3p.ln1@mantle.rutgers.edu> Message-ID: <1254943942.10848.44.camel@malachite> On Mon, 2009-10-05 at 22:06 -0400, Chung-chieh Shan wrote: > Robert Atkey wrote in article <1254778973.3675.42.camel@bismuth> in gmane.comp.lang.haskell.cafe: > > To implement the translation of embedded language types to Haskell types > > in Haskell we use type families. > > This type-to-type translation is indeed the crux of the trickiness. By > the way, Section 4.3 of our (JFP) paper describes how to follow such a > translation without type families. If I were to avoid type families in > Haskell, I would make Symantics into a multiparameter type class Yes, this is another way to do it. I prefer having an explicit representation of the types of the embedded language though. For one, the multi-parameter type classes get a bit unwieldy if you have lots of types in your embedded language. Also, sometimes you might want to do special things with the denotations of each type. For instance, I did an embedding of Levy's CBPV, where the type system is split into value types and computation types. For the computation types X there is always an algebra map of type m [[ X ]] -> [[ X ]]. To define this I needed a term level representative of the type, and also the type family to give the semantics of the embedded type. I don't know if this is easily done using multi-parameter type classes. > > The underlying problem with the implementation of 'lam' is that > > you have to pick an evaluation order for the side effects you want in > > the semantics of your embedded language. The two obvious options are > > call-by-name and call-by-value. > > (Section 5 of our (JFP) paper addresses both CBN and CBV.) Yes, thanks for reminding me. I vaguely remembered when I went to bed after posting that you had done something via Plotkin's CPS transformations. I rather like the direct approach though; sometimes it is nice not to have to solve every problem by hitting it with the continuations hammer ;). Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From tobias_bexelius at hotmail.com Wed Oct 7 15:37:04 2009 From: tobias_bexelius at hotmail.com (Tobias Bexelius) Date: Wed Oct 7 15:14:39 2009 Subject: [Haskell-cafe] RE: [Haskell] ANNOUNCE: GPipe-1.0.0: A functional graphics API for programmable GPUs In-Reply-To: <20091007144715.GB11278@pudlak.name> References: Message-ID: Hi Petr, Your question is completely justified! Yes, I beleive GPipe is a good foundation for such GPGPU-computations (general purpose GPU-programming), giving you easy access to data parallelism. A way of doing this is to start with one or more equally sized textures that is your input (1 component depth textures perserves most floating point precision) . Then you rasterize a quad that covers the entire FrameBuffer, and for each fragment point sample these input textures and perform some computation on the samples. The resulting framebuffer can then be converted to a normal list in main memory, or converted to another texture to be used as input in another pass. To gather data, e.g. sum up all values in a texture, you could make a fragment program that uses a half-sized quad in which you sample two parts of the texture which you add and return in a half-sized texture. If you repeat this log2 texturesize times, you end up with one single value that is the sum of all values. All texture loading and retrieving functions in GPipe are in IO, but safe to wrap in unsafePerformIO as long as you guarantee that the Ptr's are safe. So I think its easy to modularize GPGPU computations in GPipe and for instance create something like: > simpleGPUmap :: (Fragment Float -> Fragment Float) -> [Float] -> [Float] So, why dont you have a go on it? It might just turn out to be a pretty useful library... ;) Cheers /Tobias > Date: Wed, 7 Oct 2009 16:47:15 +0200 > From: deb@pudlak.name > To: tobias_bexelius@hotmail.com > CC: haskell-cafe@haskell.org > Subject: Re: [Haskell] ANNOUNCE: GPipe-1.0.0: A functional graphics API for programmable GPUs > > Hi Tobias, > > (I'm completely new to GPU programming, so my question may be completely > stupid or unrelated. Please be patient :-).) > > Some time ago I needed to perform some large-scale computations > (searching for first-order logic models) and a friend told me that GPUs > can be used to perform many simple computations in parallel. Could GPipe > be used for such a task? I.e. to program some non-graphical, > parallelized algorithm, which could be run on a GPU cluster? > > Thanks for your answer, > > Petr > > On Sun, Oct 04, 2009 at 08:32:56PM +0200, Tobias Bexelius wrote: > > I'm proud to announce the first release of GPipe-1.0.0: A functional graphics > > API for programmable GPUs. > > > > GPipe models the entire graphics pipeline in a purely functional, immutable > > and typesafe way. It is built on top of the programmable pipeline (i.e. > > non-fixed function) of OpenGL 2.1 and uses features such as vertex buffer > > objects (VBO's), texture objects and GLSL shader code synthetisation to create > > fast graphics programs. Buffers, textures and shaders are cached internally to > > ensure fast framerate, and GPipe is also capable of managing multiple windows > > and contexts. By creating your own instances of GPipes classes, it's possible > > to use additional datatypes on the GPU. > > > > You'll need full OpenGL 2.1 support, including GLSL 1.20 to use GPipe. Thanks > > to OpenGLRaw, you may still build GPipe programs on machines lacking this > > support. > > > > The package, including full documentation, can be found at: > > http://hackage.haskell.org/package/GPipe-1.0.0 > > > > Of course, you may also install it with: > > cabal install gpipe > > > > > > Cheers! > > Tobias Bexelius > > > > ?????????????????????????????????????????????????????????????????????????????? > > kolla in resten av Windows LiveT. Inte bara e-post - Windows LiveT ?r mycket > > mer ?n din inkorg. Mer ?n bara meddelanden Windows Live: H?ll dina v?nner uppdaterade om vad du g?r online. _________________________________________________________________ Hitta k?rleken nu i v?r! http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/abaf6d9a/attachment.html From bob.atkey at ed.ac.uk Wed Oct 7 15:37:29 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Wed Oct 7 15:15:14 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: <1254778973.3675.42.camel@bismuth> References: <4ACA1996.7060807@mcmaster.ca> <1254778973.3675.42.camel@bismuth> Message-ID: <1254944249.10848.48.camel@malachite> On Mon, 2009-10-05 at 22:42 +0100, Robert Atkey wrote: > There is a difference in the syntax between CBN and CBV that is not > always obvious from the usual paper presentations. There is a split > between pieces of syntax that are "values" and those that are > "computations". Values do not have side-effects, while computations may. > In this presentation, I have chosen that the only values are variables, > while everything else is a computation. > I should correct this: it is possible to give the CBV semantics to the original syntax definition (with the single parameter in the type class), you just have to move the "return" of the monad into the "lam" case. I implied in the paragraph above that the split between values and computations was required for CBV case; this is not true. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From emax at chalmers.se Wed Oct 7 15:53:49 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Oct 7 15:31:27 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> Message-ID: <4ACCF1CD.8000301@chalmers.se> Ben Franksen skrev: > minh thu wrote: >> 2009/10/7 G?nther Schmidt : >>>> I've informally argued that a true DSL -- separate from a good API -- >>>> should have semantic characteristics of a language: binding forms, >>>> control structures, abstraction, composition. Some have type systems. >>>> >>> That is one requirement that confuses me, abstraction. >>> >>> I thought of DSLs as "special purpose" languages, ie. you give your DSL >>> everything it needs for that purpose. >>> >>> Why would it also need the ability to express even further abstractions, >>> it is supposed to *be* the abstraction. >> Programming abstractions at the DSL level, not to further abstract >> what the DSL covers. >> >> Functions, for instance, are typical abstraction means offered by >> programming languages. Even if your language is specific to some >> domain, being able to create your own functions, and not only rely on >> those provided by the DSL implementation, is important. >> >> Imagine a (E)DSL for 3D programming (e.g. shading language): the >> language is designed to fit well the problem (e.g. in this case, 3D >> linear algebra, color operations, ...) but you'll agree it would be a >> shame to not be able to provide your own functions. > > But isn't one of the advantages of an _E_DSL that we can use the host > language (Haskell) as a meta or macro language for the DSL? I would think > that this greatly reduces the need to provide abstraction > facilities /inside/ the DSL. In fact most existing (and often cited > examples of) EDSLs in Haskell do not provide abstraction. I would say that the DSL is what the user sees. In this view, I think it's correct to say that many (or most) DSLs need function abstraction. Whether or not the internal data structure has function abstraction is an implementation detail. / Emil From dave at zednenem.com Wed Oct 7 16:41:31 2009 From: dave at zednenem.com (David Menendez) Date: Wed Oct 7 16:19:05 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <200910051702.19827.daniel.is.fischer@web.de> Message-ID: <49a77b7a0910071341v5c3bfe7ek81af1a5d89c20e04@mail.gmail.com> On Wed, Oct 7, 2009 at 12:08 PM, Ben Franksen wrote: > > More generally, any ring with multiplicative unit (let's call it 'one') will > do. Isn't that every ring? As I understand it, the multiplication in a ring is required to form a monoid. -- Dave Menendez From jfredett at gmail.com Wed Oct 7 16:44:19 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Oct 7 16:21:57 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: <49a77b7a0910071341v5c3bfe7ek81af1a5d89c20e04@mail.gmail.com> References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <200910051702.19827.daniel.is.fischer@web.de> <49a77b7a0910071341v5c3bfe7ek81af1a5d89c20e04@mail.gmail.com> Message-ID: A ring is an abelian group in addition, with the added operation (*) being distributive over addition, and 0 annihilating under multiplication. (*) is also associative. Rings don't necessarily need _multiplicative_ id, only _additive_ id. Sometimes Rings w/o ID is called a Rng (a bit of a pun). /Joe On Oct 7, 2009, at 4:41 PM, David Menendez wrote: > On Wed, Oct 7, 2009 at 12:08 PM, Ben Franksen > wrote: >> >> More generally, any ring with multiplicative unit (let's call it >> 'one') will >> do. > > Isn't that every ring? As I understand it, the multiplication in a > ring is required to form a monoid. > > -- > Dave Menendez > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stevenyoung1990 at msn.com Wed Oct 7 16:48:15 2009 From: stevenyoung1990 at msn.com (Steven1990) Date: Wed Oct 7 16:25:47 2009 Subject: [Haskell-cafe] New to Haskell - List Comprehension Question Message-ID: <25794144.post@talk.nabble.com> Hi, I'm currently learning Haskell, and I've been trying to work out a function for the following problem for a couple of days now. I want to use a list comprehension method to change the first letter of a string to upper case, and the rest of the string to lower case. Eg: "heLLo" -> "Hello" As I'm trying to learn this, I would appreciate hints rather than the explicit solution if possible? I'm sure I'm close to a solution, I must be missing something though. Driving me crazy! My attempts are something similar to this: upperCase :: String -> String upperCase xs = [toUpper(x):toLower(xs) | x <- xs] I think 'toLower' expects a single character rather than the list which is one place I'm going wrong? Thanks in advance, Steven -- View this message in context: http://www.nabble.com/New-to-Haskell---List-Comprehension-Question-tp25794144p25794144.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rmm-haskell at z.odi.ac Wed Oct 7 16:50:13 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Wed Oct 7 16:27:51 2009 Subject: [Haskell-cafe] New to Haskell - List Comprehension Question In-Reply-To: <25794144.post@talk.nabble.com> References: <25794144.post@talk.nabble.com> Message-ID: <2CB68001-4AB5-4A82-8EC5-F53A41349ECC@z.odi.ac> I don't think a list comprehension is the easiest way to do it, how about upperCase :: String -> String upperCase [] = [] upperCase (x:xs) = toUpper x : map toLower xs -Ross On Oct 7, 2009, at 4:48 PM, Steven1990 wrote: > > Hi, I'm currently learning Haskell, and I've been trying to work out a > function for the following problem for a couple of days now. > > I want to use a list comprehension method to change the first letter > of a > string to upper case, and the rest of the string to lower case. > > Eg: "heLLo" -> "Hello" > > As I'm trying to learn this, I would appreciate hints rather than the > explicit solution if possible? I'm sure I'm close to a solution, I > must be > missing something though. Driving me crazy! > > My attempts are something similar to this: > > upperCase :: String -> String > upperCase xs = [toUpper(x):toLower(xs) | x <- xs] > > I think 'toLower' expects a single character rather than the list > which is > one place I'm going wrong? > > Thanks in advance, > Steven > -- > View this message in context: http://www.nabble.com/New-to-Haskell---List-Comprehension-Question-tp25794144p25794144.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com > . > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gcross at phys.washington.edu Wed Oct 7 16:52:35 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Wed Oct 7 16:30:08 2009 Subject: [Haskell-cafe] New to Haskell - List Comprehension Question In-Reply-To: <25794144.post@talk.nabble.com> References: <25794144.post@talk.nabble.com> Message-ID: <0435AD12-5D54-4C49-B9C1-149E20CC7C74@phys.washington.edu> Hint: Move the boundary case outside the comprehension, and then use the comprehension to handle the normal case. Also, FYI, a comprehension feeds each value of the list xs into x, and then evaluates the expression to the left of the pipe with that single value of x. Cheers, Greg On Oct 7, 2009, at 1:48 PM, Steven1990 wrote: > > Hi, I'm currently learning Haskell, and I've been trying to work out a > function for the following problem for a couple of days now. > > I want to use a list comprehension method to change the first letter > of a > string to upper case, and the rest of the string to lower case. > > Eg: "heLLo" -> "Hello" > > As I'm trying to learn this, I would appreciate hints rather than the > explicit solution if possible? I'm sure I'm close to a solution, I > must be > missing something though. Driving me crazy! > > My attempts are something similar to this: > > upperCase :: String -> String > upperCase xs = [toUpper(x):toLower(xs) | x <- xs] > > I think 'toLower' expects a single character rather than the list > which is > one place I'm going wrong? > > Thanks in advance, > Steven > -- > View this message in context: http://www.nabble.com/New-to-Haskell---List-Comprehension-Question-tp25794144p25794144.html > Sent from the Haskell - Haskell-Cafe mailing list archive at > Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mpm at alumni.caltech.edu Wed Oct 7 16:59:00 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Oct 7 16:36:39 2009 Subject: [Haskell-cafe] random question Message-ID: <4ACD0114.6050502@alumni.caltech.edu> My thread about randomness got hijacked so I need to restate my remaining question here. Is it acceptable to write pure routines that use but do not return generators, and then call several of them from an IO monad with a generator obtained by several calls to newStdGen? shuffle :: RandomGen g => g -> [a] -> [a] shuffle = ... foo :: [a] -> [a] -> IO () foo xs ys = do g1 <- newStdGen print $ shuffle g1 xs g2 <- newStdGen print $ shuffle g2 ys Does this kind of thing exhibit good pseudorandomness? Thanks, Mike From lrpalmer at gmail.com Wed Oct 7 17:10:46 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Oct 7 16:48:18 2009 Subject: [Haskell-cafe] random question In-Reply-To: <4ACD0114.6050502@alumni.caltech.edu> References: <4ACD0114.6050502@alumni.caltech.edu> Message-ID: <7ca3f0160910071410i7c60a165oca672bcfb807f390@mail.gmail.com> On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey wrote: > My thread about randomness got hijacked so I need to restate my remaining > question here. Is it acceptable to write pure routines that use but do not > return generators, and then call several of them from an IO monad with a > generator obtained by several calls to newStdGen? It's gross. What if you don't want IO as part of this computation? If you have a random generator that supports splitting (something rather hard to do from what I understand), I prefer not to return the new generator but instead to split it. So, using your shuffle: > shuffle :: RandomGen g => g -> [a] -> [a] > shuffle = ... foo :: RandomGen g => [a] -> [a] -> g -> ([a],[a]) foo xs ys gen = let (gen1, gen2) = split gen in (shuffle gen1 xs, shuffle gen2 ys) Luke From noteed at gmail.com Wed Oct 7 17:20:41 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 7 16:58:34 2009 Subject: [Haskell-cafe] New to Haskell - List Comprehension Question In-Reply-To: <25794144.post@talk.nabble.com> References: <25794144.post@talk.nabble.com> Message-ID: <40a414c20910071420s4096c03n5d3922cf43f48a97@mail.gmail.com> 2009/10/7 Steven1990 : > > Hi, I'm currently learning Haskell, and I've been trying to work out a > function for the following problem for a couple of days now. > > I want to use a list comprehension method to change the first letter of a > string to upper case, and the rest of the string to lower case. > > Eg: "heLLo" -> "Hello" > > As I'm trying to learn this, I would appreciate hints rather than the > explicit solution if possible? I'm sure I'm close to a solution, I must be > missing something though. Driving me crazy! > > My attempts are something similar to this: > > upperCase :: String -> String > upperCase xs = [toUpper(x):toLower(xs) | x <- xs] > > I think 'toLower' expects a single character rather than the list which is > one place I'm going wrong? Hi, try to work little things by little things: $ ghci Prelude> let f xs = [x:xs | x <- xs] Prelude> f "hello" ["hhello","ehello","lhello","lhello","ohello"] Prelude> Prelude> :m + Data.Char Prelude Data.Char> :t toLower toLower :: Char -> Char Prelude Data.Char> :t toUpper toUpper :: Char -> Char Prelude Data.Char> So xs is the whole list (the "hello" part of each element in the resilt of f "hello") and x gets the value of each character. toLower and toUpper have the same type; indeed toLower expects a single character while you feed it a list. The part on the left of the pipe is "executed" for each x drawn from the xs list. This means that if you want to make something specific to the first element of xs, you have to provide more information: the x alone is not enough to know it is the first one or not. The easiest way to do that is with pattern matching on the upperCase argument: upperCase (x:xs) = ... (Don't forget for the "other" case, the empty list: upperCase [] = ...) Cheers, Thu From bos at serpentine.com Wed Oct 7 17:25:10 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Oct 7 17:02:43 2009 Subject: [Haskell-cafe] random question In-Reply-To: <4ACD0114.6050502@alumni.caltech.edu> References: <4ACD0114.6050502@alumni.caltech.edu> Message-ID: On Wed, Oct 7, 2009 at 1:59 PM, Michael Mossey wrote: > My thread about randomness got hijacked so I need to restate my remaining > question here. Is it acceptable to write pure routines that use but do not > return generators, and then call several of them from an IO monad with a > generator obtained by several calls to newStdGen? > > shuffle :: RandomGen g => g -> [a] -> [a] > shuffle = ... > > foo :: [a] -> [a] -> IO () > foo xs ys = do > g1 <- newStdGen > print $ shuffle g1 xs > g2 <- newStdGen > print $ shuffle g2 ys > > Does this kind of thing exhibit good pseudorandomness? > If you believe in the safety of the split operation (which I don't), then yes, since use of it is what's happening behind the scenes. In other words, provided you're a faithful sort and split doesn't make you squirm too much, you don't need to plug all that ugly IO in there. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/dcd14cad/attachment.html From mpm at alumni.caltech.edu Wed Oct 7 17:28:59 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Oct 7 17:06:43 2009 Subject: [Haskell-cafe] random question In-Reply-To: <7ca3f0160910071410i7c60a165oca672bcfb807f390@mail.gmail.com> References: <4ACD0114.6050502@alumni.caltech.edu> <7ca3f0160910071410i7c60a165oca672bcfb807f390@mail.gmail.com> Message-ID: <4ACD081B.6080205@alumni.caltech.edu> Luke Palmer wrote: > On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey wrote: >> My thread about randomness got hijacked so I need to restate my remaining >> question here. Is it acceptable to write pure routines that use but do not >> return generators, and then call several of them from an IO monad with a >> generator obtained by several calls to newStdGen? > > It's gross. What if you don't want IO as part of this computation? > I don't quite follow your response. I want a program that initializes the generator from the global generator because I want different behavior every time I run it. So it will need IO. That's what I was trying to demonstrate. And I was wondering if one can get around the difficulty of passing the generator from call to call by using newStdGen in this way. Mike From velman at cox.net Wed Oct 7 17:39:27 2009 From: velman at cox.net (John Velman) Date: Wed Oct 7 17:17:01 2009 Subject: [solved] Re: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091007173853.GA276@cox.net> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> <20091006232031.GC960@cox.net> <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> <20091007173853.GA276@cox.net> Message-ID: <20091007213927.GD276@cox.net> For anyone following this: The XCode ld script is complex, and has mac specific defaults early in the search path specification, and I probably don't want to change these. A library in a default path is the wrong libgmp.[dylib | a]. My solution: do a ln -s libgmp.a lib-h-gmp.a in the /Library/Frameworks/GHC.Framework/..../usr/lib folder. Then add lib-h-gmp.a to my Xcode project. Compiled, linked, and ran and got the right output. Thanks to everyone who helped. John V. On Wed, Oct 07, 2009 at 10:38:53AM -0700, John Velman wrote: > This is probably an Xcode problem now, rather than a strictly Haskell > problem. > > There are a bunch of libgmp.a and libgmp.dylib files in existence on this > computer, some in /usr/local/lib, or linked from there. > > I've got my errors down to references in libgmp, whether or not I try to > include libgmp.a in the project. > > Whenever I try to add libgmp.a, or libgmp.dylib to my project, I get the > error message: > > ---------- > ld warning: > in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgmp.dylib, > file is not of required architecture > --------- > > followed by a list of undefined symbols, all of which (well, all I've > checked!) are defined in the Haskell Platform version of libgmp.a > > I'm sure there must be a way around this in the Xcode IDE, but haven't > found it. I'll take the question to the Xcode mailing list. > > Thanks to all for help on this. I'll let you know how it works out! > > Best, > > John Velman > > > > On Tue, Oct 06, 2009 at 07:56:07PM -0400, Brandon S. Allbery KF8NH wrote: > > On Oct 6, 2009, at 19:20 , John Velman wrote: > >> HSghc-prim-0.1.0.0.o, HSinteger-0.1.0.1.o, libffi.a, libgmp.a, > >> libHSbase-3.0.3.1.a, libHSbase-3.0.3.1_p.a, libHSbase-4.1.0.0.a, > >> libHSghc-prim-0.1.0.0_p.a, libHSrts.a > > > > Note that library order matters; libgmp.a should probably be last on the > > command line. > > > > -- > > 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 > > > [previous messages snipped to save virtual paper] > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Wed Oct 7 17:41:01 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 7 17:20:10 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <49a77b7a0910071341v5c3bfe7ek81af1a5d89c20e04@mail.gmail.com> Message-ID: <200910072341.01419.daniel.is.fischer@web.de> Am Mittwoch 07 Oktober 2009 22:44:19 schrieb Joe Fredette: > A ring is an abelian group in addition, with the added operation (*) > being distributive over addition, and 0 annihilating under > multiplication. (*) is also associative. Rings don't necessarily need > _multiplicative_ id, only _additive_ id. Sometimes Rings w/o ID is > called a Rng (a bit of a pun). > > /Joe In my experience, the definition of a ring more commonly includes the multiplicative identity and abelian groups with an associative multiplication which distributes over addition are called semi-rings. There is no universally employed definition (like for natural numbers, is 0 included or not; fields, is the commutativity of multiplication part of the definition or not; compactness, does it include Hausdorff or not; ...). From jfredett at gmail.com Wed Oct 7 17:51:54 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Oct 7 17:29:32 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: <200910072341.01419.daniel.is.fischer@web.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> <49a77b7a0910071341v5c3bfe7ek81af1a5d89c20e04@mail.gmail.com> <200910072341.01419.daniel.is.fischer@web.de> Message-ID: I was just quoting from Hungerford's Undergraduate text, but yes, the "default ring" is in {Rng, Ring}, I haven't heard semirings used in the sense of a Rng. I generally find semirings defined as a ring structure without additive inverse and with 0-annihilation (which one has to assume in the case of SRs, I included it in my previous definition because I wasn't sure if I could prove it via the axioms, I think it's possible, but I don't recall the proof). Wikipedia seems to agree with your definition, though it does have a note which says some authors use the definition of Abelian Group + Semigroup (my definition) as opposed to Abelian Group + Monoid (your defn). Relevant: http://en.wikipedia.org/wiki/Semiring http://en.wikipedia.org/wiki/Ring_(algebra) http://en.wikipedia.org/wiki/Ring_(algebra)#Notes_on_the_definition /Joe On Oct 7, 2009, at 5:41 PM, Daniel Fischer wrote: > Am Mittwoch 07 Oktober 2009 22:44:19 schrieb Joe Fredette: >> A ring is an abelian group in addition, with the added operation (*) >> being distributive over addition, and 0 annihilating under >> multiplication. (*) is also associative. Rings don't necessarily need >> _multiplicative_ id, only _additive_ id. Sometimes Rings w/o ID is >> called a Rng (a bit of a pun). >> >> /Joe > > In my experience, the definition of a ring more commonly includes > the multiplicative > identity and abelian groups with an associative multiplication which > distributes over > addition are called semi-rings. > > There is no universally employed definition (like for natural > numbers, is 0 included or > not; fields, is the commutativity of multiplication part of the > definition or not; > compactness, does it include Hausdorff or not; ...). > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Wed Oct 7 17:51:23 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 7 17:30:13 2009 Subject: [Haskell-cafe] random question In-Reply-To: <4ACD081B.6080205@alumni.caltech.edu> References: <4ACD0114.6050502@alumni.caltech.edu> <7ca3f0160910071410i7c60a165oca672bcfb807f390@mail.gmail.com> <4ACD081B.6080205@alumni.caltech.edu> Message-ID: <200910072351.23712.daniel.is.fischer@web.de> Am Mittwoch 07 Oktober 2009 23:28:59 schrieb Michael Mossey: > Luke Palmer wrote: > > On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey wrote: > >> My thread about randomness got hijacked so I need to restate my > >> remaining question here. Is it acceptable to write pure routines that > >> use but do not return generators, and then call several of them from an > >> IO monad with a generator obtained by several calls to newStdGen? > > > > It's gross. What if you don't want IO as part of this computation? > > I don't quite follow your response. I want a program that initializes the > generator from the global generator because I want different behavior every > time I run it. So it will need IO. That's what I was trying to demonstrate. > And I was wondering if one can get around the difficulty of passing the > generator from call to call by using newStdGen in this way. > > Mike Documentation says: newStdGen :: IO StdGen Applies split to the current global random generator, updates it with one of the results, and returns the other. So it's as safe as split is. From nowgate at yahoo.com Wed Oct 7 18:09:09 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 7 17:46:41 2009 Subject: [Haskell-cafe] New to Haskell - List Comprehension Question In-Reply-To: <40a414c20910071420s4096c03n5d3922cf43f48a97@mail.gmail.com> Message-ID: <211017.12265.qm@web31103.mail.mud.yahoo.com> Try just writing a function that will change ALL the characters to uppercase (or lower case) using list comprehension and then see if you can isolate how to factor out the special case of the first character. Michael --- On Wed, 10/7/09, minh thu wrote: From: minh thu Subject: Re: [Haskell-cafe] New to Haskell - List Comprehension Question To: "Steven1990" Cc: haskell-cafe@haskell.org Date: Wednesday, October 7, 2009, 5:20 PM 2009/10/7 Steven1990 : > > Hi, I'm currently learning Haskell, and I've been trying to work out a > function for the following problem for a couple of days now. > > I want to use a list comprehension method to change the first letter of a > string to upper case, and the rest of the string to lower case. > > Eg: "heLLo" -> "Hello" > > As I'm trying to learn this, I would appreciate hints rather than the > explicit solution if possible? I'm sure I'm close to a solution, I must be > missing something though. Driving me crazy! > > My attempts are something similar to this: > > upperCase :: String -> String > upperCase xs = [toUpper(x):toLower(xs) | x <- xs] > > I think 'toLower' expects a single character rather than the list which is > one place I'm going wrong? Hi, try to work little things by little things: $ ghci Prelude> let f xs = [x:xs | x <- xs] Prelude> f "hello" ["hhello","ehello","lhello","lhello","ohello"] Prelude> Prelude> :m + Data.Char Prelude Data.Char> :t toLower toLower :: Char -> Char Prelude Data.Char> :t toUpper toUpper :: Char -> Char Prelude Data.Char> So xs is the whole list (the "hello" part of each element in the resilt of f "hello") and x gets the value of each character. toLower and toUpper have the same type; indeed toLower expects a single character while you feed it a list. The part on the left of the pipe is "executed" for each x drawn from the xs list. This means that if you want to make something specific to the first element of xs, you have to provide more information: the x alone is not enough to know it is the first one or not. The easiest way to do that is with pattern matching on the upperCase argument: upperCase (x:xs) = ... (Don't forget for the "other" case, the empty list: upperCase [] = ...) Cheers, Thu _______________________________________________ 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/20091007/e93ba154/attachment.html From daniel.is.fischer at web.de Wed Oct 7 18:12:40 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 7 17:51:31 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910072341.01419.daniel.is.fischer@web.de> Message-ID: <200910080012.41443.daniel.is.fischer@web.de> Am Mittwoch 07 Oktober 2009 23:51:54 schrieb Joe Fredette: > I was just quoting from Hungerford's Undergraduate text, but yes, the > "default ring" is in {Rng, Ring}, I haven't heard semirings used in > the sense of a Rng. It's been looong ago, I seem to have misremembered :? But there used to be a german term for Rngs, and it was neither Pseudoring nor quasiring, so I thought it was Halbring. > I generally find semirings defined as a ring > structure without additive inverse and with 0-annihilation (which one > has to assume in the case of SRs, I included it in my previous > definition because I wasn't sure if I could prove it via the axioms, I > think it's possible, but I don't recall the proof). 0*x = (0+0)*x = 0*x + 0*x ==> 0*x = 0 > > Wikipedia seems to agree with your definition, though it does have a > note which says some authors use the definition of Abelian Group + > Semigroup (my definition) as opposed to Abelian Group + Monoid (your > defn). > > Relevant: > > http://en.wikipedia.org/wiki/Semiring > http://en.wikipedia.org/wiki/Ring_(algebra) > http://en.wikipedia.org/wiki/Ring_(algebra)#Notes_on_the_definition > > /Joe > > On Oct 7, 2009, at 5:41 PM, Daniel Fischer wrote: > > Am Mittwoch 07 Oktober 2009 22:44:19 schrieb Joe Fredette: > >> A ring is an abelian group in addition, with the added operation (*) > >> being distributive over addition, and 0 annihilating under > >> multiplication. (*) is also associative. Rings don't necessarily need > >> _multiplicative_ id, only _additive_ id. Sometimes Rings w/o ID is > >> called a Rng (a bit of a pun). > >> > >> /Joe > > > > In my experience, the definition of a ring more commonly includes > > the multiplicative > > identity and abelian groups with an associative multiplication which > > distributes over > > addition are called semi-rings. > > > > There is no universally employed definition (like for natural > > numbers, is 0 included or > > not; fields, is the commutativity of multiplication part of the > > definition or not; > > compactness, does it include Hausdorff or not; ...). From tomahawkins at gmail.com Wed Oct 7 18:56:06 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Wed Oct 7 18:33:42 2009 Subject: [Haskell-cafe] ANNOUNCE: htzaar-0.0.1 Message-ID: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> HTZAAR is a Haskell implementation of TZAAR, a great little two-player abstract strategy game designed by Kris Burm. TZAAR won Games Magazine's Game-of-the-Year in 2008. TZAAR has some interesting game dynamics. At each turn a player must decide whether to attack or strengthen his own pieces. The unbalanced number of tzaars, tzarras, and totts pieces leads to several phase transitions in the game. At first tzaars are targeted, but once they're fortified, tzarras become the targets, then totts. It also has a rather distinct transition from mid to end game. Midway through, most effort is on positioning power pieces for attack. But as more pieces come off the board, movement is restricted to the point where groups become isolated from others, which can work for or against you. Anyway, I thought the game would be a fun AI problem. HTZAAR comes with a very simple AI opponent (lame), but I did my best to structure the interface to make it easy to create new AI strategies. I hope a few people try to build and contribute AI strategies to HTZAAR. And if there's anyway I can improve the AI interface, let me know. HTZAAR can also pit AI against AI. The following is a game between two instances of the "lame" AI. For an idea of the complexity of TZAAR, the number in parentheses indicates the number of possible moves at each turn. TZAAR has a large number of choices at each turn because each turn consists of two different moves (n^2). Typical games are between 15 to 25 turns. $ htzaar -s 22 lame lame 1. white (lame) : D7 -> E7 (42) 2. black (lame) : F6 -> F5 G1 -> F2 (6355) 3. white (lame) : D6 -> E6 A5 -> A4 (5867) 4. black (lame) : F3 -> E4 H2 -> G2 (5227) 5. white (lame) : I2 -> I1 C5 -> C6 (4992) 6. black (lame) : F5 -> G4 H1 -> H3 (4345) 7. white (lame) : H5 -> G6 C6 -> C7 (4176) 8. black (lame) : F7 -> E7 D4 -> C3 (4265) 9. white (lame) : G6 -> E5 H4 -> G5 (3464) 10. black (lame) : H6 -> I5 F2 -> E2 (2870) 11. white (lame) : E5 -> G4 D2 -> D1 (2303) 12. black (lame) : B2 -> C2 G7 -> I5 (2742) 13. white (lame) : G5 -> I5 E6 -> I3 (1965) 14. black (lame) : E7 -> B5 G3 -> E3 (2055) 15. white (lame) : E1 -> F1 I4 -> I3 (1303) 16. black (lame) : E2 -> D1 C4 -> D5 (1656) 17. white (lame) : I5 -> F8 C7 -> I3 (913) 18. black (lame) : B5 -> A4 E4 -> B4 (1480) 19. white (lame) : D3 -> C2 B1 -> C2 (608) 20. black (lame) : B4 -> B6 C3 -> C2 (526) 21. white (lame) : D8 -> E8 F1 -> F4 (185) 22. black (lame) : H3 -> G4 B3 -> B6 (314) 23. white (lame) : C1 -> A1 F4 -> G4 (47) 24. black (lame) : B6 -> E8 E8 -> F8 (125) black (lame) Wins! Screenshots and links: http://tomahawkins.org Known bugs: Occasionally HTZAAR throws a Prelude.head: empty list. I'm still trying to track this down. From alp at mestan.fr Wed Oct 7 19:34:28 2009 From: alp at mestan.fr (Alp Mestan) Date: Wed Oct 7 19:12:03 2009 Subject: [Haskell-cafe] dsl and gui toolkit In-Reply-To: <5001DC4D-A273-429F-9F4F-8E79B76F03D8@n-brain.net> References: <200910061822.30363.frank@geoinfo.tuwien.ac.at> <789DAD6E-4F17-4B75-A7AE-08C17A6A3EEC@n-brain.net> <5001DC4D-A273-429F-9F4F-8E79B76F03D8@n-brain.net> Message-ID: Note that the Qt library supports CSS, and it's pretty fun and easy to use. On Wed, Oct 7, 2009 at 5:05 AM, John A. De Goes wrote: > > Then change to "early generation" language. Point being CSS has plenty of > pioneering flaws. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Oct 6, 2009, at 7:52 AM, Richard O'Keefe wrote: > > >> On Oct 7, 2009, at 5:47 AM, John A. De Goes wrote: >> >> >>> CSS is a good start by it's beset by all the problems of a 1st generation >>> presentation language, and is not particularly machine-friendly. >>> >> >> Considering that CSS is _at least_ a 2nd generation language >> (it was preceded by DSSSL), that's rather funny. >> >>> >>> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Alp Mestan http://alpmestan.wordpress.com/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/7c7a9078/attachment.html From cjs at starling-software.com Wed Oct 7 19:41:27 2009 From: cjs at starling-software.com (Curt Sampson) Date: Wed Oct 7 19:19:01 2009 Subject: [Haskell-cafe] Libraries for Commercial Users In-Reply-To: References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> Message-ID: <20091007234127.GC9180@poetic.cynic.net> On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: > [Haskell] is missing many key libraries that would be of great > commercial value. Just out of curiousity, can you give me some examples of what you feel these are? cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From cjs at starling-software.com Wed Oct 7 19:49:34 2009 From: cjs at starling-software.com (Curt Sampson) Date: Wed Oct 7 19:27:07 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: References: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> <40a414c20910020803u324ebd23h3beb997ede9d4ac3@mail.gmail.com> Message-ID: <20091007234934.GD9180@poetic.cynic.net> On 2009-10-02 09:04 -0600 (Fri), John A. De Goes wrote: > I'm not saying Haskell is unstable. I'm saying that the attitude > expressed in the following quote is at odds with the needs of business: > > "And as far as something like dealing with a changing language and > libraries, the mainstream already has well-established and popular > techniques for doing just: agile development." I don't know how much commercial experience you have, but I've been a founder of two companies, CTO or CEO of several businesses, a "chief architect" in a couple more, and consider myself as much a businessman and manager as a developer. The attitude you express is certainly common in many businesses, but it's not the only way to run a successful business. I won't go further here, since this kind of argument generally leads into a, "no, what you do isn't possible" kind of flamewar, but I did want to point this out here, so that others can know that, the attitude John De Goes expresses, while comon, is not the only way busineses look at the world. I should note, too, the the agile development momement over the past ten years has had and still does have exactly the same sort of attacks on it, and yet has successfully moved into the mainstream and is well-accepted by many parts of it. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From ryani.spam at gmail.com Wed Oct 7 19:52:36 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Oct 7 19:30:09 2009 Subject: [Haskell-cafe] random question In-Reply-To: <4ACD081B.6080205@alumni.caltech.edu> References: <4ACD0114.6050502@alumni.caltech.edu> <7ca3f0160910071410i7c60a165oca672bcfb807f390@mail.gmail.com> <4ACD081B.6080205@alumni.caltech.edu> Message-ID: <2f9b2d30910071652n2174e94vff02bea823bbae@mail.gmail.com> On Wed, Oct 7, 2009 at 2:28 PM, Michael Mossey wrote: > I don't quite follow your response. I want a program that initializes the > generator from the global generator because I want different behavior every > time I run it. So it will need IO. That's what I was trying to demonstrate. > And I was wondering if one can get around the difficulty of passing the > generator from call to call by using newStdGen in this way. > You should only have to call newStdGen once: main = do g <- newStdGen let (g1,g2) = split g let xs = [1..10] print $ shuffle g1 xs print $ shuffle g2 xs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/63a622dc/attachment.html From wchogg at gmail.com Wed Oct 7 20:14:38 2009 From: wchogg at gmail.com (Creighton Hogg) Date: Wed Oct 7 19:52:11 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <1254943082.10848.30.camel@malachite> References: <1254943082.10848.30.camel@malachite> Message-ID: <814617240910071714u73c4c313v99e8fe6dd602e5a0@mail.gmail.com> 2009/10/7 Robert Atkey : > >> What is a DSL? > > How about this as a formal-ish definition, for at least a pretty big > class of DSLs: > > A DSL is an algebraic theory in the sense of universal algebra. I.e. it > is an API of a specific form, which consists of: > ?a) a collection of abstract types, the carriers. Need not all be of > ? ? kind *. > ?b) a collection of operations, of type > ? ? ? ? t1 -> t2 -> ... -> tn > ? ? where tn must be one of the carrier types from (a), but the others > ? ? can be any types you like. > ?c) (Optional) a collection of properties about the operations (e.g. > ? ? equations that must hold) > > Haskell has a nice way of specifying such things (except part (c)): type > classes. > > Examples of type classes that fit this schema include Monad, Applicative > and Alternative. Ones that don't include Eq, Ord and Show. The Num type > class would be, if it didn't specify Eq and Show as superclasses. > > An implementation of a DSL is just an implementation of corresponding > type class. Shallowly embedded DSLs dispense with the type class step > and just give a single implementation. Deeply embedded implementations > are *initial* implementations: there is a unique function from the deep > embedding to any of the other implementations that preserves all the > operations. The good thing about this definition is that anything we do > to the deep embedding, we can do to any of the other implementations via > the unique map. > > Thanks to Church and Reynolds, we can always get a deep embedding for > free (free as in "Theorems for Free"). If our DSL is defined by some > type class T, then the deep embedding is: > ? type DeepT = forall a. T a => a > (and so on, for multiple carrier types, possibly with type > parameterisation). > > Of course, there is often an easier and more efficient way of > representing the initial algebra using algebraic data types. > > Conor McBride often goes on about how the initial algebra (i.e. the deep > embedding) of a given specification is the one you should be worrying > about, because it often has a nice concrete representation and gives you > all you need to reason about any of the other implementations. It's funny, because I wouldn't have thought about this in terms of type classes from the top of my head. What I've been thinking about a lot lately (because I'm trying to prepare notes on it) is building classifying categories from signatures, then considering the category of all possible functorial "models" (read: "dsl embeddings") into the target category. I guess we're essentially talking about the same thing. The difference from looking at it as type classes is that you really do get all your equations preserved with product preserving functors from your classifying category; however, the topic came up earlier today of what would a language look like if it had a built in notion of functorial semantics - my guess is that it'd be like a stronger version of ML functors, but I don't really know. Cheers, C From mpm at alumni.caltech.edu Wed Oct 7 20:29:12 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Oct 7 20:06:56 2009 Subject: [Haskell-cafe] Test.QuickCheck: generate Message-ID: <1237.75.50.170.48.1254961752.squirrel@mail.alumni.caltech.edu> In Test.QuickCheck, the type of 'generate' is generate :: Int -> StdGen -> Gen a -> a I can't find docs that explain what the Int does. Some docs are here: From mle+hs at mega-nerd.com Wed Oct 7 20:44:13 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Oct 7 20:21:48 2009 Subject: [Haskell-cafe] Libraries for Commercial Users In-Reply-To: <20091007234127.GC9180@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> Message-ID: <20091008114413.c7356fb6.mle+hs@mega-nerd.com> Curt Sampson wrote: > On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: > > > [Haskell] is missing many key libraries that would be of great > > commercial value. > > Just out of curiousity, can you give me some examples of what you feel > these are? A version of Network.HTTP that accepts HTTPS URLs and does the right thing instead of attempting to do a HTTP connection instead. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From jmccarty at sent.com Wed Oct 7 20:44:27 2009 From: jmccarty at sent.com (Jason McCarty) Date: Wed Oct 7 20:22:01 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: <200910080012.41443.daniel.is.fischer@web.de> References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910072341.01419.daniel.is.fischer@web.de> <200910080012.41443.daniel.is.fischer@web.de> Message-ID: <20091008004427.GA1110@quaternion> Daniel Fischer wrote: > Am Mittwoch 07 Oktober 2009 23:51:54 schrieb Joe Fredette: > > I generally find semirings defined as a ring > > structure without additive inverse and with 0-annihilation (which one > > has to assume in the case of SRs, I included it in my previous > > definition because I wasn't sure if I could prove it via the axioms, I > > think it's possible, but I don't recall the proof). > > 0*x = (0+0)*x = 0*x + 0*x ==> 0*x = 0 This proof only works if your additive monoid is cancellative, which need not be true in a semiring. The natural numbers extended with infinity is one example (if you don't take 0*x = 0 as an axiom, I think there are two possibilities for 0*?). -- Jason McCarty From dons at galois.com Wed Oct 7 20:45:52 2009 From: dons at galois.com (Don Stewart) Date: Wed Oct 7 20:23:26 2009 Subject: [Haskell-cafe] Libraries for Commercial Users In-Reply-To: <20091008114413.c7356fb6.mle+hs@mega-nerd.com> References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <20091008114413.c7356fb6.mle+hs@mega-nerd.com> Message-ID: <20091008004552.GA27694@whirlpool.galois.com> mle+hs: > Curt Sampson wrote: > > > On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: > > > > > [Haskell] is missing many key libraries that would be of great > > > commercial value. > > > > Just out of curiousity, can you give me some examples of what you feel > > these are? > > A version of Network.HTTP that accepts HTTPS URLs and does the right > thing instead of attempting to do a HTTP connection instead. Yeah, we use the curl library for all our HTTPS stuff. From felipe.lessa at gmail.com Wed Oct 7 21:05:13 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Oct 7 20:42:52 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: <20091008004427.GA1110@quaternion> References: <200910051440.32119.shahn@cs.tu-berlin.de> <200910072341.01419.daniel.is.fischer@web.de> <200910080012.41443.daniel.is.fischer@web.de> <20091008004427.GA1110@quaternion> Message-ID: <20091008010513.GA6361@kira.casa> On Wed, Oct 07, 2009 at 08:44:27PM -0400, Jason McCarty wrote: > Daniel Fischer wrote: > > Am Mittwoch 07 Oktober 2009 23:51:54 schrieb Joe Fredette: > > > I generally find semirings defined as a ring > > > structure without additive inverse and with 0-annihilation (which one > > > has to assume in the case of SRs, I included it in my previous > > > definition because I wasn't sure if I could prove it via the axioms, I > > > think it's possible, but I don't recall the proof). > > > > 0*x = (0+0)*x = 0*x + 0*x ==> 0*x = 0 > > This proof only works if your additive monoid is cancellative, which > need not be true in a semiring. The natural numbers extended with > infinity is one example (if you don't take 0*x = 0 as an axiom, I think > there are two possibilities for 0*?). Given that x = 1*x = (0+1)*x = 0*x + 1*x = 0*x + x we can show that x = x + 0*x (right) x = 0*x + x (left) so, by definition of 'zero', we have that 0*x is a zero. But we can easily prove that there can be only one zero: suppose we have two zeros z1 and z2; it follows that z1 = z1 + z2 = z2 So 0*x = 0. Any flaws? -- Felipe. From daniel.is.fischer at web.de Wed Oct 7 21:55:08 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 7 21:33:56 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types In-Reply-To: <20091008010513.GA6361@kira.casa> References: <200910051440.32119.shahn@cs.tu-berlin.de> <20091008004427.GA1110@quaternion> <20091008010513.GA6361@kira.casa> Message-ID: <200910080355.09100.daniel.is.fischer@web.de> Am Donnerstag 08 Oktober 2009 03:05:13 schrieb Felipe Lessa: > On Wed, Oct 07, 2009 at 08:44:27PM -0400, Jason McCarty wrote: > > Daniel Fischer wrote: > > > Am Mittwoch 07 Oktober 2009 23:51:54 schrieb Joe Fredette: > > > > I generally find semirings defined as a ring > > > > structure without additive inverse and with 0-annihilation (which one > > > > has to assume in the case of SRs, I included it in my previous > > > > definition because I wasn't sure if I could prove it via the axioms, > > > > I think it's possible, but I don't recall the proof). > > > > > > 0*x = (0+0)*x = 0*x + 0*x ==> 0*x = 0 > > > > This proof only works if your additive monoid is cancellative, which > > need not be true in a semiring. The natural numbers extended with > > infinity is one example (if you don't take 0*x = 0 as an axiom, I think > > there are two possibilities for 0*?). It was a proof for a ring (with or without unit), which Joe stated above he didn't recall. There your additive monoid is cancellative since it's a group :D > > Given that > > x = 1*x = (0+1)*x = 0*x + 1*x = 0*x + x > > we can show that > > x = x + 0*x (right) > x = 0*x + x (left) > > so, by definition of 'zero', we have that 0*x is a zero. Not necessarily, we don't know 0*x + y = y for arbitrary y yet. If the additive monoid isn't cancellative, that needn't be the case. In Jason's example, you can indeed set 0*? = ?. > But we can easily prove that there can be only one zero: suppose we have > two zeros z1 and z2; it follows that > > z1 = z1 + z2 = z2 > > So 0*x = 0. Any flaws? > > -- > Felipe. From mle+hs at mega-nerd.com Wed Oct 7 22:02:34 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Oct 7 21:41:35 2009 Subject: [Haskell-cafe] Libraries for Commercial Users In-Reply-To: <20091008004552.GA27694@whirlpool.galois.com> References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <20091008114413.c7356fb6.mle+hs@mega-nerd.com> <20091008004552.GA27694@whirlpool.galois.com> Message-ID: <20091008130234.393ee4a0.mle+hs@mega-nerd.com> Don Stewart wrote: > > A version of Network.HTTP that accepts HTTPS URLs and does the right > > thing instead of attempting to do a HTTP connection instead. > > Yeah, we use the curl library for all our HTTPS stuff. Well there is a big difference between Network.Curl and Network.HTTP. HTTP is really easy to understand and use, while Curl is not. What I would like to do is a POST operation to a HTTPS server with Content-Type "text/xml" and then get the HTTP response code as well as the body which is also "text/xml". This should be easy and should be obvious, but unfortunately does not even seem to be supported by Network.Curl. The Network.Curl API is rather weird. It has a very sensible and obvious GET function: curlGetString :: URLString -> [CurlOption] -> IO (CurlCode, String) but no corresponding POST function. Instead it has: curlPost :: URLString -> [String] -> IO () curlMultiPost :: URLString -> [CurlOption] -> [HttpPost] -> IO () both of which seem to only support x-www-form-urlencoded data and not text/xml. Furthermore, whats with the 'IO ()' result? Wouldn't it make more sense to return 'IO (CurlCode, String)' like curlGetString? I don't like to be critical of other people's projects, but Network.Curl seems to be one huge ball of confusion. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From drcygnus at gmail.com Wed Oct 7 23:44:44 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Wed Oct 7 23:22:20 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.2 Message-ID: <20091008034443.GA4972@janrain.com> I'm happy to announce the release of vty-ui 0.2. Get it from Hackage: http://hackage.haskell.org/package/vty-ui Or get the source with darcs: http://repos.codevine.org/vty-ui This version of vty-ui is everything you hoped it would be: fewer bugs, more widget types, cleaner code, better abstractions, and more generality. If you've written any applications to use vty-ui, only a few of your type signatures will need to change. Here's a summary of changes: General * Unify HBorder and VBorder types (now called Border) * Unify HFill and VFill types (now called Fill) * Unify HBox and VBox types (now called Box) * Box layout: layout documentation, edge case bug fixes * Widget class: refactor growthPolicy into growHorizontal and growVertical * Add Graphics.Vty.Widgets.Composed for high-level widget compositions * Add Graphics.Vty.Widgets.All convenience module to export everything in the library Lists * List items may now be of any widget type! * Add resize, pageUp, pageDown, scrollBy functions and expose other list functionality * Generalize scrolling API * Add convenience API for using lists of Text widgets * Support internal identifiers for list items * Always consume scrollWindowSize lines of space even if the list is smaller New widgets * WrappedText: automatically wraps text in available space; try resizing the demo. * Borders module: one-row/one-column ASCII borders between boxed widgets; ASCII art box container * Demo: use crazy boxed list items to show off border boxes and generic widget support in Lists! * Demo: support PageUp/PageDown to demonstrate List paging API Enjoy! -- Jonathan Daugherty From dave at zednenem.com Wed Oct 7 23:57:09 2009 From: dave at zednenem.com (David Menendez) Date: Wed Oct 7 23:34:41 2009 Subject: [Haskell-cafe] Test.QuickCheck: generate In-Reply-To: <1237.75.50.170.48.1254961752.squirrel@mail.alumni.caltech.edu> References: <1237.75.50.170.48.1254961752.squirrel@mail.alumni.caltech.edu> Message-ID: <49a77b7a0910072057g5436a63ck1382df4241e553f4@mail.gmail.com> On Wed, Oct 7, 2009 at 8:29 PM, Michael Mossey wrote: > In Test.QuickCheck, the type of 'generate' is > > generate :: Int -> StdGen -> Gen a -> a > > I can't find docs that explain what the Int does. Some docs are here: > > Judging by the source code, the integer is the upper bound for the size parameter. If you are generating a list, for example, it gives the maximum size of the list. -- Dave Menendez From seanmcl at gmail.com Thu Oct 8 00:37:27 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Thu Oct 8 00:15:01 2009 Subject: [Haskell-cafe] #include path Message-ID: <6579f8680910072137x29897b65re302b57db07df18a@mail.gmail.com> Hi, I'm trying to compile some code using Cabal. One of the files has a CPP directive #include "undefined.h" The file undefined.h is in the same directory as the file with the directive. If I use the full path name, cabal can compile it. However, if I use the relative path, it complains about not being able to find the file. I tried adding it to extra-source-files, but that didn't help. I see that Hackage packages like Agda use this trick, so I know it's possible. How can I get these paths worked out correctly? There isn't much comment in the Cabal docs. Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/e686177d/attachment.html From oleg at okmij.org Thu Oct 8 03:54:14 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Oct 8 03:35:29 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework Message-ID: <20091008075414.C2760175E1@Adric.metnet.navy.mil> Actually it is possible to implement all three evaluation orders within the same final tagless framework, using the same interpretation of types and reusing most of the code save the semantics of lam. That is where the three orders differ, by their own definition. In call-by-name, we have lam f = S . return $ (unS . f . S) In call-by-value, we have lam f = S . return $ (\x -> x >>= unS . f . S . return) In call-by-need, we have lam f = S . return $ (\x -> share x >>= unS . f . S) In CBV, the function first evaluates its argument, whether the value will be needed or not. In call-by-need, we arrange for the sharing of the result should the computation be evaluated. Here is an illustrative test t2 :: HOAS exp => exp IntT t2 = (lam $ \z -> lam $ \x -> let_ (x `add` x) $ \y -> y `add` y) `app` (int 100 `sub` int 10) `app` (int 5 `add` int 5) t2SN = runName t2 >>= print {- *CB> t2SN Adding Adding Adding Adding Adding Adding Adding 40 -} In CBN, the result of subtraction was not needed, and so it was not performed OTH, (int 5 `add` int 5) was computed four times. t2SV = runValue t2 >>= print {- *CB> t2SV Subtracting Adding Adding Adding 40 -} In CBV, although the result of subtraction was not needed, it was still performed. OTH, (int 5 `add` int 5) was computed only once. t2SL = runLazy t2 >>= print {- *CB> t2SL Adding Adding Adding 40 -} Now, Lazy is better than both CBN and CBV: subtraction was not needed, and it was not performed. All other expressions were needed, and evaluated once. The complete code is at http://okmij.org/ftp/tagless-final/CB.hs From oleg at okmij.org Thu Oct 8 04:02:32 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Oct 8 03:43:46 2009 Subject: [Haskell-cafe] What *is* a DSL? Message-ID: <20091008080232.B1E1E176B2@Adric.metnet.navy.mil> Perhaps it would be appropriate to point out the IFIP conference on exactly that topic, DSL. The conference took place in July, here is the permanent record: http://dsl09.blogspot.com/ with pointers to the slides and the discussions. The panel discussion has debated that very question, what exactly is DSL. http://dsl09.blogspot.com/2009/07/panel.html As you can see, the agreement could not be reached on what is Domain. There will be another DSL conference, in Australia. Perhaps all the Haskell-Cafe debaters may want to participate. From magnus at therning.org Thu Oct 8 04:31:57 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Oct 8 04:09:30 2009 Subject: [Haskell-cafe] Cabal, sdist and flags Message-ID: A while ago I moved a project away from using a mix of Cabal and make to build (Cabal to build the library and make to build the tests) to using only Cabal. I added a flag and then made a construct like this: flag BuildTests Description: Build unit and quickcheck tests. Default: False ... executable tests if flag(BuildTests) main-is: Test.hs build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 hs-source-dirs: test-src src else main-is: Test.hs buildable: False Interestingly that does work for things like 'configure' and 'build', but it doesn't work for 'sdist': % ./Setup.hs sdist Distribution quality errors: Building source dist for dataenc-0.13.0.1... Setup.hs: Test.hsTest.hs doesn't exist To make this work I had to move the 'main-is' outside of the if-else: executable tests main-is: Test.hs hs-source-dirs: test-src src if flag(BuildTests) build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 else buildable: False I found this surprising, so I'm tempted to call it a bug. A quick search didn't tell me whether this is well-known already, hence the email. Would you consider it a bug? Has it been raised already? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From wss at cs.nott.ac.uk Thu Oct 8 04:34:07 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Thu Oct 8 04:11:41 2009 Subject: [solved] Re: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091007213927.GD276@cox.net> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> <20091006232031.GC960@cox.net> <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> <20091007173853.GA276@cox.net> <20091007213927.GD276@cox.net> Message-ID: <4FCAFAF2-29C5-4E87-A22F-D2C8D8D53F32@cs.nott.ac.uk> On 7 Oct 2009, at 23:39, John Velman wrote: > For anyone following this: The XCode ld script is complex, and has > mac > specific defaults early in the search path specification, and I > probably > don't want to change these. A library in a default path is the wrong > libgmp.[dylib | a]. Is there any chance you'll write up exactly what you needed to do on a blog/TMR article/Haskell wiki page? I've tried doing something similar, ran into linking problems, and gave up my fight with XCode. I think this would be a really useful resource for both Obj-C programmers looking into Haskell and Haskell programmers who want to have a fancy Cocoa GUI. Thanks! Wouter From leather at cs.uu.nl Thu Oct 8 04:59:58 2009 From: leather at cs.uu.nl (Sean Leather) Date: Thu Oct 8 04:37:50 2009 Subject: [Haskell-cafe] Cabal, sdist and flags In-Reply-To: References: Message-ID: <3c6288ab0910080159u76625bf7o8f4d03ffa5f7c4e2@mail.gmail.com> > > To make this work I had to move the 'main-is' outside of the if-else: > > executable tests > main-is: Test.hs > hs-source-dirs: test-src src > if flag(BuildTests) > build-depends: test-framework, test-framework-hunit, HUnit, > test-framework-quickcheck2, QuickCheck >= 2.1.0.0 > else > buildable: False > > I found this surprising, so I'm tempted to call it a bug. A quick > search didn't tell me whether this is well-known already, hence the > email. Would you consider it a bug? Has it been raised already? > I do something similar with EMGM, but I never tried to put the main-is inside the if. I just did this for the test executable. if flag(test) build-depends: QuickCheck >= 2.1 && < 2.2, HUnit >= 1.2 && < 1.3 else buildable: False Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/0ab1df69/attachment.html From noteed at gmail.com Thu Oct 8 05:04:35 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 8 04:42:27 2009 Subject: [Haskell-cafe] type inference question Message-ID: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Hi, I'd like to know what are the typing rules used in Haskell (98 is ok). Specifically, I'd like to know what makes let i = \x -> x in (i True, i 1) legal, and not let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) Is it correct that polymorphic functions can be used polymorphically (in multiple places) while non-functions receive a monomorphic type ? Also, I'd like to know why id id True is permitted but not (\f -> f f True) id Is it possible to change the later expression so it type checks ? Are there any type inference algorithms that would accept it ? I'm asking this because I have implemented a simple type inference algorithm following PLAI and I can infer the type for id id True (because I use fresh type variable names for id whenever I apply it before unification) and have an occur check fail for the later expression, just like in haskell. Thanks, Thu From martijn at van.steenbergen.nl Thu Oct 8 05:18:14 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Oct 8 04:55:50 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <4ACDAE56.7020007@van.steenbergen.nl> minh thu wrote: > Also, I'd like to know why > > id id True > > is permitted but not > > (\f -> f f True) id Because this requires rank-2 types: > Prelude> :set -XScopedTypeVariables > Prelude> :set -XRank2Types > Prelude> (\(f :: forall a. a -> a) -> f f True) id > True HTH, Martijn. From jochem at functor.nl Thu Oct 8 05:19:56 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Thu Oct 8 04:56:52 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <4ACDAEBC.5000406@functor.nl> minh thu wrote: > Also, I'd like to know why > > id id True > > is permitted but not > > (\f -> f f True) id If you want to do this, answer the question "what is the type of (\f -> f f True)"? You can do this, by the way, using rank-2 types: > {-# LANGUAGE Rank2Types, PatternSignatures #-} > thisIsAlwaysTrue = (\ (f :: forall a. a -> a) -> f f True) id Cheers, Jochem -- Jochem Berndsen | jochem@functor.nl | jochem@????.com From leather at cs.uu.nl Thu Oct 8 05:20:20 2009 From: leather at cs.uu.nl (Sean Leather) Date: Thu Oct 8 04:58:12 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac Message-ID: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> We have run into an issue that it seems other people have already found but has apparently not been resolved, yet. It manifests as with the error "HTTP request failed with: Unsupported socket". The problem is described in two places with different workarounds. http://code.google.com/p/happstack/issues/detail?id=88 http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 One workaround is to rewrite part of the network package, and the other is to downgrade the package. It could be the case that the rewrite came from the older version, though I'm not sure. I'm curious if it is possible to fix this, either in Happstack or the network package, once and for all. The workarounds are rather painful when so many things depend on the network package. Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/f90b0200/attachment.html From nicolas.pouillard at gmail.com Thu Oct 8 05:32:55 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Oct 8 05:06:54 2009 Subject: [Haskell-cafe] random question In-Reply-To: References: <4ACD0114.6050502@alumni.caltech.edu> Message-ID: <1254994319-sup-3908@peray> Excerpts from Bryan O'Sullivan's message of Wed Oct 07 23:25:10 +0200 2009: > On Wed, Oct 7, 2009 at 1:59 PM, Michael Mossey wrote: > > > My thread about randomness got hijacked so I need to restate my remaining > > question here. Is it acceptable to write pure routines that use but do not > > return generators, and then call several of them from an IO monad with a > > generator obtained by several calls to newStdGen? > > > > shuffle :: RandomGen g => g -> [a] -> [a] > > shuffle = ... > > > > foo :: [a] -> [a] -> IO () > > foo xs ys = do > > g1 <- newStdGen > > print $ shuffle g1 xs > > g2 <- newStdGen > > print $ shuffle g2 ys > > > > Does this kind of thing exhibit good pseudorandomness? > > > > If you believe in the safety of the split operation (which I don't), then ^^^^^^^^^^^^^^^^ | Can you elaborate on that? ---------------------------------+ Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr From duncan.coutts at googlemail.com Thu Oct 8 05:07:20 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Oct 8 05:26:28 2009 Subject: [Haskell-cafe] Cabal, sdist and flags In-Reply-To: References: Message-ID: <1254992840.28525.3471.camel@localhost> On Thu, 2009-10-08 at 09:31 +0100, Magnus Therning wrote: > A while ago I moved a project away from using a mix of Cabal and make > to build (Cabal to build the library and make to build the tests) to > using only Cabal. I added a flag and then made a construct like this: [..] > Interestingly that does work for things like 'configure' and 'build', > but it doesn't work for 'sdist': > I found this surprising, so I'm tempted to call it a bug. A quick > search didn't tell me whether this is well-known already, hence the > email. Would you consider it a bug? Has it been raised already? Yes, I'd consider it a bug. I don't think it has been reported. Duncan From duncan.coutts at googlemail.com Thu Oct 8 05:17:21 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Oct 8 05:26:30 2009 Subject: [Haskell-cafe] #include path In-Reply-To: <6579f8680910072137x29897b65re302b57db07df18a@mail.gmail.com> References: <6579f8680910072137x29897b65re302b57db07df18a@mail.gmail.com> Message-ID: <1254993441.28525.3500.camel@localhost> On Thu, 2009-10-08 at 00:37 -0400, Sean McLaughlin wrote: > Hi, > > > I'm trying to compile some code using Cabal. One of the files has a > CPP directive > > > #include "undefined.h" > > > The file undefined.h is in the same directory as the file with the > directive. That works fine for me. I've got: foo.cabal Foo/Bar.hs Foo/undefined.h Bar.hs has the #include "undefined.h" directive. This works because cpp looks first in the directory containing the file it is processing at the time, ie the directory containing Foo/Bar.hs. > If I use the full path name, cabal can compile it. However, if I use > the relative path, it complains about not being able to find the file. Do you mean cpp (invoked by cabal/ghc) cannot find the undefined.h file when compiling? If this is the case we'll need more details. When you say full path name do you mean the full absolute path name all the way from /, or do you mean relative to the root of the project (ie the dir with the .cabal file)? > I tried adding it to extra-source-files, but that didn't help. Or do you mean it does not get included into the sdist tarball, and thus is missing when you build from the tarball? That would be a use case for extra-source-files. > I see that Hackage packages like Agda use this trick, so I know it's > possible. How can I get these paths worked out correctly? > There isn't much comment in the Cabal docs. I'm not clear about which stage is failing. Duncan From noteed at gmail.com Thu Oct 8 06:08:46 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 8 05:46:37 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: <4ACDAEBC.5000406@functor.nl> References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> <4ACDAEBC.5000406@functor.nl> Message-ID: <40a414c20910080308u3218d2due1122a3a4c9c20cc@mail.gmail.com> 2009/10/8 Jochem Berndsen : > minh thu wrote: >> Also, I'd like to know why >> >> id id True >> >> is permitted but not >> >> (\f -> f f True) id > > If you want to do this, answer the question "what is the type of (\f -> > f f True)"? > You can do this, by the way, using rank-2 types: >> {-# LANGUAGE Rank2Types, PatternSignatures #-} >> thisIsAlwaysTrue = (\ (f :: forall a. a -> a) -> f f True) id > > Cheers, Jochem So I learned we should be explicit about f being used polymorphically; that's what rank-2 types are for. (correct ?) Thanks, Thu From frodo at theshire.org Thu Oct 8 06:29:44 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Oct 8 06:07:37 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: > Hi, > > I'd like to know what are the typing rules used in Haskell (98 is ok). > > Specifically, I'd like to know what makes > > let i = \x -> x in (i True, i 1) > > legal, and not > > let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) > > Is it correct that polymorphic functions can be used polymorphically > (in multiple places) while non-functions receive a monomorphic type ? First, "1" IS a constant function so it's in no way special and is a value like any other. That said, the type of 1 is (Num t) => t, hence polymorphic. But, when used in the first element of the tuple, a is assigned a more concrete type (Int) which mismatches with the second element of the tuple, which is a Float. If you swap the tuple, you'll find that the error reported by ghci is the very same as before, except that the two types are swapped. Is it possible to rewrite the expression so as to work? The answer is yes, using existential quantification (and Rank2 polymorphism). Here you are: {-# LANGUAGE ExistentialQuantification, Rank2Types #-} foo :: (forall a. (Num a) => a) -> (Int,Float) foo = \x -> (x + (1 :: Int), x + (1 :: Float)) Hence: foo 1 --> (2,2.0) Bye, Cristiano From deniz.a.m.dogan at gmail.com Thu Oct 8 06:36:51 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Oct 8 06:14:44 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <7b501d5c0910080336i22fb5c49jf7b3a3cbe27c0ee5@mail.gmail.com> 2009/10/8 Cristiano Paris : > On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: >> Hi, >> >> I'd like to know what are the typing rules used in Haskell (98 is ok). >> >> Specifically, I'd like to know what makes >> >> let i = \x -> x in (i True, i 1) >> >> legal, and not >> >> let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) >> >> Is it correct that polymorphic functions can be used polymorphically >> (in multiple places) while non-functions receive a monomorphic type ? > > First, "1" IS a constant function so it's in no way special and is a > value like any other. I thought all functions in lambda calculus, technically, take exactly one argument? -- Deniz Dogan From lennart at augustsson.net Thu Oct 8 06:48:46 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Oct 8 06:26:18 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: The reason a gets a single type is the monomorphism restriction (read the report). Using NoMonomorphismRestriction your example with a works fine. On Thu, Oct 8, 2009 at 12:29 PM, Cristiano Paris wrote: > On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: >> Hi, >> >> I'd like to know what are the typing rules used in Haskell (98 is ok). >> >> Specifically, I'd like to know what makes >> >> let i = \x -> x in (i True, i 1) >> >> legal, and not >> >> let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) >> >> Is it correct that polymorphic functions can be used polymorphically >> (in multiple places) while non-functions receive a monomorphic type ? > > First, "1" IS a constant function so it's in no way special and is a > value like any other. > > That said, the type of 1 is (Num t) => t, hence polymorphic. But, when > used in the first element of the tuple, a is assigned a more concrete > type (Int) which mismatches with the second element of the tuple, > which is a Float. > > If you swap the tuple, you'll find that the error reported by ghci is > the very same as before, except that the two types are swapped. > > Is it possible to rewrite the expression so as to work? The answer is > yes, using existential quantification (and Rank2 polymorphism). > > Here you are: > {-# LANGUAGE ExistentialQuantification, Rank2Types #-} > foo :: (forall a. (Num a) => a) -> (Int,Float) > foo = \x -> (x + (1 :: Int), x + (1 :: Float)) > > Hence: > > foo 1 --> (2,2.0) > > Bye, > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From porges at porg.es Thu Oct 8 07:00:58 2009 From: porges at porg.es (George Pollard) Date: Thu Oct 8 06:38:30 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <814617240910071714u73c4c313v99e8fe6dd602e5a0@mail.gmail.com> References: <1254943082.10848.30.camel@malachite> <814617240910071714u73c4c313v99e8fe6dd602e5a0@mail.gmail.com> Message-ID: <6d942a4a0910080400r75945bdaodd6b2a67e7e8f246@mail.gmail.com> I'd also like to note that the canonical pronunciation of DSL ends in "-izzle". From noteed at gmail.com Thu Oct 8 07:07:34 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 8 06:45:25 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <40a414c20910080407x61eabba6ic568024ba0a65d0a@mail.gmail.com> Thanks all! Thu 2009/10/8 Lennart Augustsson : > The reason a gets a single type is the monomorphism restriction (read > the report). > Using NoMonomorphismRestriction your example with a works fine. > > On Thu, Oct 8, 2009 at 12:29 PM, Cristiano Paris wrote: >> On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: >>> Hi, >>> >>> I'd like to know what are the typing rules used in Haskell (98 is ok). >>> >>> Specifically, I'd like to know what makes >>> >>> let i = \x -> x in (i True, i 1) >>> >>> legal, and not >>> >>> let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) >>> >>> Is it correct that polymorphic functions can be used polymorphically >>> (in multiple places) while non-functions receive a monomorphic type ? >> >> First, "1" IS a constant function so it's in no way special and is a >> value like any other. >> >> That said, the type of 1 is (Num t) => t, hence polymorphic. But, when >> used in the first element of the tuple, a is assigned a more concrete >> type (Int) which mismatches with the second element of the tuple, >> which is a Float. >> >> If you swap the tuple, you'll find that the error reported by ghci is >> the very same as before, except that the two types are swapped. >> >> Is it possible to rewrite the expression so as to work? The answer is >> yes, using existential quantification (and Rank2 polymorphism). >> >> Here you are: >> {-# LANGUAGE ExistentialQuantification, Rank2Types #-} >> foo :: (forall a. (Num a) => a) -> (Int,Float) >> foo = \x -> (x + (1 :: Int), x + (1 :: Float)) >> >> Hence: >> >> foo 1 --> (2,2.0) >> >> Bye, >> >> Cristiano >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From colin at colina.demon.co.uk Thu Oct 8 07:08:00 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Oct 8 06:45:33 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <6d942a4a0910080400r75945bdaodd6b2a67e7e8f246@mail.gmail.com> (George Pollard's message of "Fri\, 9 Oct 2009 00\:00\:58 +1300") References: <1254943082.10848.30.camel@malachite> <814617240910071714u73c4c313v99e8fe6dd602e5a0@mail.gmail.com> <6d942a4a0910080400r75945bdaodd6b2a67e7e8f246@mail.gmail.com> Message-ID: >>>>> "George" == George Pollard writes: George> I'd also like to note that the canonical pronunciation of George> DSL ends in "-izzle". Whose canon? Interestingly, I have always assumed the canonical pronunciation of DSSSL was diesel, as JADE stands for JAmes's DSSSL Engine. I don't see why removing extra S-es should shorten the vowel. -- Colin Adams Preston Lancashire From iainspeed at gmail.com Thu Oct 8 07:47:43 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Thu Oct 8 07:25:59 2009 Subject: [Haskell-cafe] Libraries for Commercial Users In-Reply-To: <20091007234127.GC9180@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> Message-ID: On 8 Oct 2009, at 00:41, Curt Sampson wrote: > On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: > >> [Haskell] is missing many key libraries that would be of great >> commercial value. > > Just out of curiousity, can you give me some examples of what you feel > these are? > Relational database libraries that work and have proper documentation i.e. those homework killers - examples, not just API docs or half finished wikis. Just google up how to connect to a database in any well-used (commercially) language and there will be a ton of fully fleshed out docs with examples I can cut n paste from.* No thinking, no time wasted, just get it done and get on with the real stuff. Haskell doesn't have that, and Happs isn't going to replace all those databases out there. (yet) *If you don't like the idea of cut n paste coding don't complain to me, it's given me a career and I'm grateful for that. Iain From gue.schmidt at web.de Thu Oct 8 10:13:30 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Oct 8 09:51:26 2009 Subject: [Haskell-cafe] On DSLs - one last time Message-ID: Hi all, I'd like to summarize my impressions on the DSL issue, gathered from the responses to my posts. It is absolutely amazing, various people have shown here that it is possible to design languages within haskell that are almost or just as powerful and safe as haskell itself. It is probably even possible to create an EDSL within an EDSL within haskell. Amazing! Uhm... ... but in that case I really wonder why I should not use Haskell directly then. Because out of the EDSL I can clearly see the "E" and I can see the "L" but having slight problems figuring out where the "D" and the "S" come in. In short, yes it's great that you can create a language within Haskell so powerful that it's gone full circle and is general purpose again, but what good is that? The efforts I've seen here where efforts to create a rich and powerful syntax, but aren't we supposed to focus on expressing semantics specific to a problem in a DSL rather? I'm not trying to put the efforts and achievements of the people who have done such amazing work down, but what exactly is it that I missed? G?nther From greg at gregorycollins.net Thu Oct 8 10:35:59 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Thu Oct 8 10:13:30 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> (Sean Leather's message of "Thu, 8 Oct 2009 11:20:20 +0200") References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> Message-ID: <87iqeqt0kw.fsf@gregorycollins.net> Sean Leather writes: > We have run into an issue that it seems other people have already > found but has apparently not been resolved, yet. It manifests as with > the error "HTTP request failed with: Unsupported socket". The problem > is described in two places with different workarounds. > > ? http://code.google.com/p/happstack/issues/detail?id=88 > ? http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 > > One workaround is to rewrite part of the network package, and the > other is to downgrade the package. It could be the case that the > rewrite came from the older version, though I'm not sure. > > I'm curious if it is possible to fix this, either in Happstack or the > network package, once and for all. The workarounds are rather painful > when so many things depend on the network package. The following patch to happstack works for me: -------------- next part -------------- A non-text attachment was scrubbed... Name: happstack-unsupported-socket-fix.diff Type: text/x-patch Size: 3119 bytes Desc: Fix unsupported socket issue Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/07552c9a/happstack-unsupported-socket-fix.bin -------------- next part -------------- G. -- Gregory Collins From vanenkj at gmail.com Thu Oct 8 11:04:19 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Oct 8 10:41:53 2009 Subject: [Haskell-cafe] On DSLs - one last time In-Reply-To: References: Message-ID: To me, the "D" and "S" come in when I'm deciding what to support. The "domain" represents the set of primitive operations I want to support. The "specific" says that I don't support anything other than those operations. Consider a language for laying out boolean logic circuits: we want to implement only AND, OR, and XOR, and NOT. The domain is boolean logic. We can't reason directly about trees or rainbows with this language, so it's specific. Our set of primitive operations would probably consist of: 1) Create input 2) Perform one of AND, OR, or XOR on two inputs (or proceeding inputs from previous operations) 3) Apply a NOT to an operation. With this basic set of operations, one can build up a graph of gates which can then be executed directly, converted to some other intermediate form, or plotted in graphical form. This is actually the focus domain of a small EDSL I'm working on for demonstrative purposes. The following is a link to the github repository and a direct link to one of the examples. http://github.com/sw17ch/gator http://github.com/sw17ch/gator/blob/master/examples/4bitAdder.hs The example linked is a 4 bit adder (8 inputs, 4 outputs) that will dump GraphViz 'dot' code. This simple EDSL currently only allows you to construct graphviz, but the intermediate Logic type could be transformed to just about anything having to do with boolean logic or executed in place. I hope some of this made sense. /jve 2009/10/8 G?nther Schmidt > Hi all, > > I'd like to summarize my impressions on the DSL issue, gathered from the > responses to my posts. > > It is absolutely amazing, various people have shown here that it is > possible to design languages within haskell that are almost or just as > powerful and safe as haskell itself. It is probably even possible to create > an EDSL within an EDSL within haskell. > > Amazing! > > > Uhm... > > ... but in that case I really wonder why I should not use Haskell directly > then. > > Because out of the EDSL I can clearly see the "E" and I can see the "L" but > having slight problems figuring out where the "D" and the "S" come in. > > In short, yes it's great that you can create a language within Haskell so > powerful that it's gone full circle and is general purpose again, but what > good is that? > > The efforts I've seen here where efforts to create a rich and powerful > syntax, but aren't we supposed to focus on expressing semantics specific to > a problem in a DSL rather? > > I'm not trying to put the efforts and achievements of the people who have > done such amazing work down, but what exactly is it that I missed? > > G?nther > > _______________________________________________ > 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/20091008/25479ffb/attachment.html From frodo at theshire.org Thu Oct 8 11:14:20 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Oct 8 10:52:10 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote: > The reason a gets a single type is the monomorphism restriction (read > the report). > Using NoMonomorphismRestriction your example with a works fine. Could you explain why, under NoMonomorphismRestriction, this typechecks: let a = 1 in (a + (1 :: Int),a + (1 :: Float)) while this not: foo :: Num a => a -> (Int,Float) foo k = (k + (1 :: Int), k + (1.0 :: Float)) Thanks! Cristiano From velman at cox.net Thu Oct 8 11:17:23 2009 From: velman at cox.net (John Velman) Date: Thu Oct 8 10:54:55 2009 Subject: [solved] Re: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <4FCAFAF2-29C5-4E87-A22F-D2C8D8D53F32@cs.nott.ac.uk> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> <20091006232031.GC960@cox.net> <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> <20091007173853.GA276@cox.net> <20091007213927.GD276@cox.net> <4FCAFAF2-29C5-4E87-A22F-D2C8D8D53F32@cs.nott.ac.uk> Message-ID: <20091008151723.GA1014@cox.net> On Thu, Oct 08, 2009 at 10:34:07AM +0200, Wouter Swierstra wrote: > > On 7 Oct 2009, at 23:39, John Velman wrote: > >> For anyone following this: The XCode ld script is complex, and has mac >> specific defaults early in the search path specification, and I probably >> don't want to change these. A library in a default path is the wrong >> libgmp.[dylib | a]. > > Is there any chance you'll write up exactly what you needed to do on a > blog/TMR article/Haskell wiki page? I've tried doing something similar, ran > into linking problems, and gave up my fight with XCode. I think this would > be a really useful resource for both Obj-C programmers looking into Haskell > and Haskell programmers who want to have a fancy Cocoa GUI. Thanks! > > Wouter Yes, it is my intention to do just that. Unfortunately, I don't always follow through! But with a specific request, I'll try to get it done in the next few days. I'll post the url here. Best, John Velman From noteed at gmail.com Thu Oct 8 11:20:36 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 8 10:58:27 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <40a414c20910080820x43ab87b7g397d6bb5b1ccbca4@mail.gmail.com> 2009/10/8 Cristiano Paris : > On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson > wrote: >> The reason a gets a single type is the monomorphism restriction (read >> the report). >> Using NoMonomorphismRestriction your example with a works fine. > > Could you explain why, under NoMonomorphismRestriction, this typechecks: > > let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > > while this not: > > foo :: Num a => a -> (Int,Float) > foo k = (k + (1 :: Int), k + (1.0 :: Float)) I think it is the same thing that my (\f -> f f True) question, i.e. the polymorphism of k is fixed inside foo (you don't want that). So I guess using the rank-2 types and the corresponding type annotation to keep k polymorph should work. In other words, foo is polymorph on k but k is not polymorph when given to foo in a specific application. Thu From bbr at informatik.uni-kiel.de Thu Oct 8 11:28:42 2009 From: bbr at informatik.uni-kiel.de (Bernd Brassel) Date: Thu Oct 8 11:06:17 2009 Subject: [Haskell-cafe] How to add use custom preprocessor in cabal Message-ID: <22AC93B1-C56E-4F03-9A1F-01A84825014F@informatik.uni-kiel.de> Hi folks, I am trying to integrate my own preprocessor into a cabal build process. But there are several points that I get stuck with. Could someone help me, please? A simplification of my problem: I have files "Abc.foo" and each of them should be transformed into "Abc.hs" by calling function "transform". The resulting "Abc.hs" files should then be exposed as Haskell library modules. 1. Question: How do I tell cabal that the file Abc.foo belongs to the package? After reading the User's Guide I had the impression that I should write something like Library Eposed-Modules: Abc.foo But this leads to a parse error. Adding a Data-Files: Abc.foo to the heading, on the other hand, does not seem to do anything. 2. Question: How to add the preprocessor? I have tried main = defaultMainWithHooks simpleUserHooks{hookedPreProcessors=[("foo",transformation)]} transformation :: BuildInfo -> LocalBuildInfo -> PreProcessor But under which circumstances will this function be called? Up to now I have not succeeded in making cabal call this function. Thanks for your time! Bernd From mpm at alumni.caltech.edu Thu Oct 8 11:38:46 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Oct 8 11:16:27 2009 Subject: [Haskell-cafe] more improvable randomness Message-ID: <1446.75.50.146.107.1255016326.squirrel@mail.alumni.caltech.edu> I wrote some code to model the keystroke-to-keystroke delay in a person typing, with pseudorandomness. There are two kinds of delays.. one is a very small delay as the person reaches for a new key (call this 'reach' delays), the other is a larger delay that represents a pause to think or to take a break (call this 'break' delays). My thought is that I could create an infinite series of reach delays and an infinite series of break delays and zipWith (+). The inifinite series of break delays would look like: - The overall pattern is a large number of zeros, in the range (N,M) followed by a single positive number, chosen from a distribution D... and then repeat. Here's some code. I used the Gen monad to gain access to the 'frequency' function, which is useful, but I had trouble figuring out how to put the whole algorithm into Gen. I also looked at Rand. The problem is that if I want to create the list by 'sequence'ing a list of monads, they need to have state that remembers how many zeros are left to go. breakSeries :: Int -> Int -> StdGen -> [Float] breakSeries lowerB upperB gen = let (n,gen1) = randomR (lowerB,upperB) gen (gen2,gen3) = split gen1 delay = generate 1 gen2 breakM in replicate n 0 ++ [delay] ++ breakSeries lowerB upperB gen3 breakM :: Gen Float breakM = frequency [ (10, choose( 1::Float , 2)) , (10, choose( 4::Float , 6)) ] test = (print . take 100 . breakSeries 2 4 ) =<< newStdGen From nowgate at yahoo.com Thu Oct 8 11:43:12 2009 From: nowgate at yahoo.com (michael rice) Date: Thu Oct 8 11:20:44 2009 Subject: [Haskell-cafe] Let it be Message-ID: <48987.60883.qm@web31107.mail.mud.yahoo.com> >From Learn You a Haskell ("Let it be" section): ?? 1. cylinder :: (RealFloat a) => a -> a -> a ? ?? 2. cylinder r h = ?? 3.???? let sideArea = 2 * pi * r * h ? ?? 4.???????? topArea = pi * r ^2 ? ?? 5.???? in? sideArea + 2 * topArea =================== What's the proper indentation for LET so these problems (below) don't arise? I thought LET and IN should be aligned in the same column. Also, isn't a LET expression an "expression." Michael ============== This works: import System.Random main = do ? gen <- getStdGen ? let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) ??? in putStrLn $ "Number is " ++ show randNumber ============== This works: import System.Random main = do ? gen <- getStdGen ? let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) ? putStrLn $ "Number is " ++ show randNumber ============== This doesn't: import System.Random main = do ? gen <- getStdGen ? let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) ? in putStrLn $ "Number is " ++ show randNumber [michael@localhost ~]$ runhaskell zz.hs zz.hs:4:2: ??? The last statement in a 'do' construct must be an expression -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/ef6e7eff/attachment.html From john at n-brain.net Thu Oct 8 11:43:19 2009 From: john at n-brain.net (John A. De Goes) Date: Thu Oct 8 11:20:54 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <20091007234127.GC9180@poetic.cynic.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> Message-ID: <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> Here's a list of libraries that are quite significant to commercial software development in 2009, but which either do not exist in Haskell, or if they exist, are hard to find, undocumented, unstable, or perhaps uncompilable: * A drop-in comet server, with JavaScript bindings (or compatible with existing JavaScript bindings). * A library for producing RESTful APIs, which does much of the work in mapping URLs into operations on a database. * Speaking of database, a robust, well-documented, cross-platform interface to popular databases, with a commercial-friendly license. * A scalable, fault-tolerant, distributed data store in the mold of BigTable, which provides map reduce. Or at least Haskell bindings for one, and a Haskellized wrapper around the binder. * A Haskell client for AMQP or other message broker, ideally reactive but anything's better than nothing. And while I'm at it, how about a 100% Haskell message broker that takes advantage of Haskell's functional nature to deliver something of Erlang quality. * A scalable, fault-tolerant, distributed graph database that can be used for building and maintaining social networks. * A networking library that supports peer-to-peer communication, authentication, encryption, and other features via plug-ins, with seamless multicasting when possible. * Infrastructure for building Haskell cloud computing clusters that are scalable and fault-tolerant. * Search and other data mining libraries, with robust indexing features, and the capacity to scale indefinitely. * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. * etc. In any one of these categories, Java has multiple implementations, sometimes 20 or more (yes, it's absurd at times, but it's also comforting because it means choosing Java is not risky). Many are meticulously documented with extensive Javadoc and tutorials. And this just scratches the surface. Most apps today are web apps, meaning they have client and server portions. Some modern languages natively support cross-compilation (Haxe, Fan), and others such as Java can be cross-compiled with the aid of third-party packages (gwt, java2script), but not Haskell. Reusing code, and using a single language across different platforms opens up many new possibilities and greatly improves productivity and efficiency. Let me ask you this question. How long would it take you to write a scalable first-pass Twitter clone? A good Java developer could do it in a week, maybe a day, and deploy it on AppEngine, where it will scale indefinitely with no effort. That's power. The syntax of a language, no matter how beautiful or high-level, cannot compete with the billions of dollars worth of resources freely available for inferior languages like Java. Haskell on the JVM with seamless Java interop (no need for method-by- method foreign import of information that's freely available via reflection) would go a long way towards leveling the playing field. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 7, 2009, at 5:41 PM, Curt Sampson wrote: > On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: > >> [Haskell] is missing many key libraries that would be of great >> commercial value. > > Just out of curiousity, can you give me some examples of what you feel > these are? > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com From bulat.ziganshin at gmail.com Thu Oct 8 11:35:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 8 11:21:44 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <341770629.20091008193547@gmail.com> Hello Cristiano, Thursday, October 8, 2009, 7:14:20 PM, you wrote: > Could you explain why, under NoMonomorphismRestriction, this typechecks: > let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > while this not: > foo :: Num a => a -> (Int,Float) > foo k = (k + (1 :: Int), k + (1.0 :: Float)) i think it's because type is different: foo :: (forall a. (Num a) => a) -> (Int,Float) in first equation it probably inferred correctly -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From john at n-brain.net Thu Oct 8 11:50:56 2009 From: john at n-brain.net (John A. De Goes) Date: Thu Oct 8 11:28:31 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <20091007234934.GD9180@poetic.cynic.net> References: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001061314.GF1315@analytic.cynic.net> <33FD11E8-C87A-4D54-A13B-C7C9A77BFC34@n-brain.net> <40a414c20910020803u324ebd23h3beb997ede9d4ac3@mail.gmail.com> <20091007234934.GD9180@poetic.cynic.net> Message-ID: I don't dismiss Haskell in business. I only maintain it's a niche market. There are some domains where the infrastructure in more established languages is minimal, and in such cases, I think Haskell can be more efficient than those languages. > I should note, too, the the agile development momement over the past > ten years has had and still does have exactly the same sort of attacks > on it, and yet has successfully moved into the mainstream and is > well-accepted by many parts of it. What has moved into mainstream is unfortunately connected chiefly to agile by virtue of the word itself. Agile means more than getting software out the door quickly, a fact many businesses have yet to learn. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 7, 2009, at 5:49 PM, Curt Sampson wrote: > On 2009-10-02 09:04 -0600 (Fri), John A. De Goes wrote: > >> I'm not saying Haskell is unstable. I'm saying that the attitude >> expressed in the following quote is at odds with the needs of >> business: >> >> "And as far as something like dealing with a changing language and >> libraries, the mainstream already has well-established and popular >> techniques for doing just: agile development." > > I don't know how much commercial experience you have, but I've been a > founder of two companies, CTO or CEO of several businesses, a "chief > architect" in a couple more, and consider myself as much a businessman > and manager as a developer. > > The attitude you express is certainly common in many businesses, but > it's not the only way to run a successful business. > > I won't go further here, since this kind of argument generally leads > into a, "no, what you do isn't possible" kind of flamewar, but I did > want to point this out here, so that others can know that, the > attitude > John De Goes expresses, while comon, is not the only way busineses > look > at the world. > > I should note, too, the the agile development momement over the past > ten years has had and still does have exactly the same sort of attacks > on it, and yet has successfully moved into the mainstream and is > well-accepted by many parts of it. > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com From rmm-haskell at z.odi.ac Thu Oct 8 11:51:05 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Thu Oct 8 11:28:45 2009 Subject: [Haskell-cafe] Let it be In-Reply-To: <48987.60883.qm@web31107.mail.mud.yahoo.com> References: <48987.60883.qm@web31107.mail.mud.yahoo.com> Message-ID: You're running into this problem because you're in a do-block. In a do- block, all the continuing lines of a single statement in the do-block must be indented w/r/t to the first line. The cylinder example doesn't have this issue because it's not in a do-block. The layout rule (I'm summarizing and I haven't read the spec, so someone jump on me if I'm stating the wrong thing) basically says that within some implied { }, ;'s will be inserted for any line that is at the same indentation level as the previous line, e.g. import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber has the following implied symbols import System.Random main = do { gen <- getStdGen ; let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) ; in putStrLn $ "Number is " ++ show randNumber } which is now obviously wrong, as the let and in are in two separate statements. Conversely, import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber implied: import System.Random main = do { gen <- getStdGen ; let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber } Hope that clarifies things. -Ross On Oct 8, 2009, at 11:43 AM, michael rice wrote: > From Learn You a Haskell ("Let it be" section): > > 1. cylinder :: (RealFloat a) => a -> a -> a > 2. cylinder r h = > 3. let sideArea = 2 * pi * r * h > 4. topArea = pi * r ^2 > 5. in sideArea + 2 * topArea > =================== > > What's the proper indentation for LET so these problems (below) > don't arise? I thought LET and IN should be aligned in the same > column. Also, isn't a LET expression an "expression." > > Michael > > ============== > > This works: > > import System.Random > main = do > gen <- getStdGen > let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) > in putStrLn $ "Number is " ++ show randNumber > > ============== > > This works: > > import System.Random > main = do > gen <- getStdGen > let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) > putStrLn $ "Number is " ++ show randNumber > > ============== > > This doesn't: > > import System.Random > main = do > gen <- getStdGen > let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) > in putStrLn $ "Number is " ++ show randNumber > > [michael@localhost ~]$ runhaskell zz.hs > > zz.hs:4:2: > The last statement in a 'do' construct must be an expression > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From allbery at ece.cmu.edu Thu Oct 8 11:53:33 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Oct 8 11:31:17 2009 Subject: [Haskell-cafe] Let it be In-Reply-To: <48987.60883.qm@web31107.mail.mud.yahoo.com> References: <48987.60883.qm@web31107.mail.mud.yahoo.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/03fd5b47/PGP.bin From john at n-brain.net Thu Oct 8 11:53:49 2009 From: john at n-brain.net (John A. De Goes) Date: Thu Oct 8 11:31:26 2009 Subject: [Haskell-cafe] Libraries for Commercial Users In-Reply-To: <20091008114413.c7356fb6.mle+hs@mega-nerd.com> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <20091008114413.c7356fb6.mle+hs@mega-nerd.com> Message-ID: <12F407E4-ED3D-431A-BE32-AA8CA8E4C4C9@n-brain.net> Exactly, it's things like this that are so frustrating and which reduce efficiency. In a mature library, you don't need to handle details like this for yourself. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 7, 2009, at 6:44 PM, Erik de Castro Lopo wrote: > Curt Sampson wrote: > >> On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: >> >>> [Haskell] is missing many key libraries that would be of great >>> commercial value. >> >> Just out of curiousity, can you give me some examples of what you >> feel >> these are? > > A version of Network.HTTP that accepts HTTPS URLs and does the right > thing instead of attempting to do a HTTP connection instead. > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From allbery at ece.cmu.edu Thu Oct 8 12:01:06 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Oct 8 11:38:42 2009 Subject: [Haskell-cafe] Let it be In-Reply-To: References: <48987.60883.qm@web31107.mail.mud.yahoo.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/4375e2b8/PGP-0001.bin From lennart at augustsson.net Thu Oct 8 12:10:21 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Oct 8 11:47:52 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: <341770629.20091008193547@gmail.com> References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> <341770629.20091008193547@gmail.com> Message-ID: Indeed, the types foo :: forall a . (Num a) => a -> (Int, Float) and foo :: (forall a . (Num a) => a) -> (Int, Float) are quite different. The first one say, I (foo) can handle any kind of numeric 'a' you (the caller) can pick. You (the caller) get to choose exactly what type you give me. The second one says, I (foo) require you (the caller) to give me an numeric 'a' that I can use any way I want. You (the caller) don't get to choose what type you give me, you have to give me a polymorphic one. -- Lennart On Thu, Oct 8, 2009 at 5:35 PM, Bulat Ziganshin wrote: > Hello Cristiano, > > Thursday, October 8, 2009, 7:14:20 PM, you wrote: > >> Could you explain why, under NoMonomorphismRestriction, this typechecks: > >> let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > >> while this not: > >> foo :: Num a => a -> (Int,Float) >> foo k = (k + (1 :: Int), k + (1.0 :: Float)) > > i think it's because type is different: > > foo :: (forall a. (Num a) => a) -> (Int,Float) > > in first equation it probably inferred correctly > > > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > From paul at cogito.org.uk Thu Oct 8 12:15:46 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Thu Oct 8 11:53:21 2009 Subject: [Haskell-cafe] Test.QuickCheck: generate In-Reply-To: <49a77b7a0910072057g5436a63ck1382df4241e553f4@mail.gmail.com> References: <1237.75.50.170.48.1254961752.squirrel@mail.alumni.caltech.edu> <49a77b7a0910072057g5436a63ck1382df4241e553f4@mail.gmail.com> Message-ID: <4ACE1032.8030306@cogito.org.uk> On 08/10/09 04:57, David Menendez wrote: > On Wed, Oct 7, 2009 at 8:29 PM, Michael Mossey wrote: > >> In Test.QuickCheck, the type of 'generate' is >> >> generate :: Int -> StdGen -> Gen a -> a >> >> I can't find docs that explain what the Int does. Some docs are here: >> > Judging by the source code, the integer is the upper bound for the > size parameter. If you are generating a list, for example, it gives > the maximum size of the list Thats right. Its the "size" parameter, and what it does depends on the instance of Arbitrary. Arbitrary numbers will be within +/- size. Arbitrary lists will be of maximum length size. On the other hand arbitrary booleans will just be True or False. From nowgate at yahoo.com Thu Oct 8 13:03:33 2009 From: nowgate at yahoo.com (michael rice) Date: Thu Oct 8 12:41:05 2009 Subject: [Haskell-cafe] Let it be In-Reply-To: Message-ID: <897644.99591.qm@web31107.mail.mud.yahoo.com> Thanks all, So, in a do expression ?let x = 1 ???? y = 2 ???? etc. ?? in z = 1 + 2 ? if ??? then ????? etc. ??? else ????? etc. Is this deviation documented somewhere? Michael --- On Thu, 10/8/09, Brandon S. Allbery KF8NH wrote: From: Brandon S. Allbery KF8NH Subject: Re: [Haskell-cafe] Let it be To: "michael rice" Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org Date: Thursday, October 8, 2009, 11:53 AM On Oct 8, 2009, at 11:43 , michael rice wrote:This doesn't: import System.Random main = do ? gen <- getStdGen ? let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) ? in putStrLn $ "Number is " ++ show randNumber [michael@localhost ~]$ runhaskell zz.hs zz.hs:4:2: ??? The last statement in a 'do' construct must be an expression The problem here is that the "do" construct parses things a bit differently; if you're at the same indentation level, it inserts a (>>) on the assumption that the next line is an independent expression, so you need to indent the "in" a bit more to avoid it. Note however that this usage is common enough that "do" provides a shorthand: ?you can simply omit the "in", and "let" will be parsed as if it were a statement: > main = do> ? gen <- getStdGen> ? let (randNumber, newGen) = randomR (1,6) gen :: (Int,StdGen)> ? putStrLn $ "Number is " ++ show randNumber --?brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.comsystem administrator [openafs,heimdal,too many hats] allbery@ece.cmu.eduelectrical and computer engineering, carnegie mellon university ? ?KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/674825cf/attachment.html From rmm-haskell at z.odi.ac Thu Oct 8 13:07:41 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Thu Oct 8 12:45:14 2009 Subject: [Haskell-cafe] Let it be In-Reply-To: <897644.99591.qm@web31107.mail.mud.yahoo.com> References: <897644.99591.qm@web31107.mail.mud.yahoo.com> Message-ID: <1B8BB171-2C28-4698-919D-90F23D05C236@z.odi.ac> I don't know of any offhand that specifically call it out -- it's a natural consequence of the layout rule which is described in the Haskell Report. However, there is at least one ticket in Haskell' to fix it for if/then/else: http://hackage.haskell.org/trac/haskell-prime/ticket/23 -Ross On Oct 8, 2009, at 1:03 PM, michael rice wrote: > Thanks all, > > So, in a do expression > > let x = 1 > y = 2 > etc. > in z = 1 + 2 > > if > then > etc. > else > etc. > > Is this deviation documented somewhere? > > Michael > > --- On Thu, 10/8/09, Brandon S. Allbery KF8NH > wrote: > > From: Brandon S. Allbery KF8NH > Subject: Re: [Haskell-cafe] Let it be > To: "michael rice" > Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org > Date: Thursday, October 8, 2009, 11:53 AM > > On Oct 8, 2009, at 11:43 , michael rice wrote: >> This doesn't: >> >> import System.Random >> main = do >> gen <- getStdGen >> let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) >> in putStrLn $ "Number is " ++ show randNumber >> >> [michael@localhost ~]$ runhaskell zz.hs >> >> zz.hs:4:2: >> The last statement in a 'do' construct must be an expression > > > The problem here is that the "do" construct parses things a bit > differently; if you're at the same indentation level, it inserts a > (>>) on the assumption that the next line is an independent > expression, so you need to indent the "in" a bit more to avoid it. > > Note however that this usage is common enough that "do" provides a > shorthand: you can simply omit the "in", and "let" will be parsed > as if it were a statement: > > > main = do > > gen <- getStdGen > > let (randNumber, newGen) = randomR (1,6) gen :: (Int,StdGen) > > putStrLn $ "Number is " ++ show randNumber > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university > KF8NH > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/e52c406b/attachment.html From felipe.lessa at gmail.com Thu Oct 8 13:18:47 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Oct 8 12:56:18 2009 Subject: [Haskell-cafe] Let it be In-Reply-To: <1B8BB171-2C28-4698-919D-90F23D05C236@z.odi.ac> References: <897644.99591.qm@web31107.mail.mud.yahoo.com> <1B8BB171-2C28-4698-919D-90F23D05C236@z.odi.ac> Message-ID: On Thu, Oct 8, 2009 at 2:07 PM, Ross Mellgren wrote: > there is at least one ticket in Haskell' to fix it for if/then/else ...and there isn't one for let/in because you can use just let (without in) inside a do-block. Of course the meanings are different as in the first case the let-bound variables scope only the 'in ...' part, while without in it scopes the rest of the do block: do {ini; let ... in ...; rest} => ini >> (let ... in ...) >> rest do {ini; let ...; ...; rest} => ini >> (let ... in (... >> rest)) HTH, -- Felipe. From dons at galois.com Thu Oct 8 13:24:17 2009 From: dons at galois.com (Don Stewart) Date: Thu Oct 8 13:01:50 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> Message-ID: <20091008172417.GD31281@whirlpool.galois.com> john: > * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. This one is fine: twitter hs-twitter library: Haskell binding to the Twitter API del.icio.us delicious library: Accessing the del.icio.us APIs from Haskell (v2) friendfeed ffeed library and programs: Haskell binding to the FriendFeed API LiveJournal feed2lj program: Cross-post any RSS/Atom feed to LiveJournal flickr flickr library and programs: Haskell binding to the Flickr API amazon hS3 library and program: Interface to Amazon's Simple Storage Service (S3) mediawiki mediawiki library and programs: Interfacing with the MediaWiki API google pubsub pubsub library and programs: A library for Google/SixApart pubsub hub interaction Speaking of REST, RESTng library: A framework for writing RESTful applications. And auth: WindowsLive windowslive library and program: Implements Windows Live Web Authentication and Delegated Authentication OpenID openid library: An implementation of the OpenID-2.0 spec. OAuth hoauth library and program: A Haskell implementation of OAuth 1.0a protocol. We've obviously not all there yet, but we have a way to get there -- write and improve code on Hackage. Galois is doing its part (we've released dozens of web packages), but the other commercial users need to help out too. Join the Industrial Haskell Group and fund open source work. Or, if you can, release some of the non-IP-encumbered things you work on! -- Don From john at n-brain.net Thu Oct 8 14:08:05 2009 From: john at n-brain.net (John A. De Goes) Date: Thu Oct 8 13:45:38 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <20091008172417.GD31281@whirlpool.galois.com> References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> Message-ID: <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> Some of these are not ready for production use; e.g.: RESTng: "RESTng is still experimental and incomplete". It has no documentation and doesn't even compile. Sadly typical. It's a bit of a chicken and egg thing. I'd switch to Haskell in a commercial setting if there were more good libraries, yet the act of switching would lead to the production of more good libraries. The latter, though, is cost-prohibitive, given all the components that would need to be developed. A few years from now, or post Haskell-on- JVM, I might be singing a different tune. I do greatly admire the work you and your company have done for Haskell. What has the Industrial Haskell group done so far? I haven't seen any announcements. The work I'd be most interested in helping co-sponsor is Haskell on JVM (biggest bang for the buck). Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 8, 2009, at 11:24 AM, Don Stewart wrote: > john: >> * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. > > This one is fine: > > twitter > hs-twitter library: Haskell binding to the Twitter API > del.icio.us > delicious library: Accessing the del.icio.us APIs from > Haskell (v2) > friendfeed > ffeed library and programs: Haskell binding to the FriendFeed > API > LiveJournal > feed2lj program: Cross-post any RSS/Atom feed to LiveJournal > flickr > flickr library and programs: Haskell binding to the Flickr API > amazon > hS3 library and program: Interface to Amazon's Simple Storage > Service (S3) > mediawiki > mediawiki library and programs: Interfacing with the > MediaWiki API > google pubsub > pubsub library and programs: A library for Google/SixApart > pubsub hub interaction > > > Speaking of REST, > > RESTng library: A framework for writing RESTful applications. > > And auth: > > WindowsLive > windowslive library and program: Implements Windows Live Web > Authentication and Delegated Authentication > OpenID > openid library: An implementation of the OpenID-2.0 spec. > OAuth > hoauth library and program: A Haskell implementation of OAuth > 1.0a protocol. > > > We've obviously not all there yet, but we have a way to get there -- > write and improve code on Hackage. Galois is doing its part (we've > released dozens of web packages), but the other commercial users > need to > help out too. > > Join the Industrial Haskell Group and fund open source work. Or, if > you > can, release some of the non-IP-encumbered things you work on! > > > -- Don From dons at galois.com Thu Oct 8 14:11:57 2009 From: dons at galois.com (Don Stewart) Date: Thu Oct 8 13:49:30 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> References: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> Message-ID: <20091008181157.GM31281@whirlpool.galois.com> The IHG (http://industry.haskell.org/) has funded about 6 months worth of development so far. You can see the status report here: http://industry.haskell.org/status Dynamic libraries, GMP-less GHC, and efficient Cabal, all appearing in the GHC 6.12. The IHG is designed as a mechanism whereby commerical users can ensure the toolchain they depend on is around for the long haul, or kick towards key features that would enable them to use Haskell in new ways. I think it is the best mechanism we have for commerical users to work on shared infrastructure -- stuff that benefits us all. john: > > Some of these are not ready for production use; e.g.: RESTng: "RESTng is > still experimental and incomplete". It has no documentation and doesn't > even compile. Sadly typical. > > It's a bit of a chicken and egg thing. I'd switch to Haskell in a > commercial setting if there were more good libraries, yet the act of > switching would lead to the production of more good libraries. The > latter, though, is cost-prohibitive, given all the components that would > need to be developed. A few years from now, or post Haskell-on-JVM, I > might be singing a different tune. > > I do greatly admire the work you and your company have done for Haskell. > > What has the Industrial Haskell group done so far? I haven't seen any > announcements. The work I'd be most interested in helping co-sponsor is > Haskell on JVM (biggest bang for the buck). > From dmehrtash at gmail.com Thu Oct 8 14:21:23 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu Oct 8 13:58:54 2009 Subject: [Haskell-cafe] Any example of concurrent haskell application? Message-ID: I am trying to learn more about concurrent applications in Haskell by studying an existing a real application source code. I would very much appreciate if you can recommend an application that you feel has done a good job in implementing a real time application in Haskell. Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/e2e510d3/attachment.html From dons at galois.com Thu Oct 8 14:25:19 2009 From: dons at galois.com (Don Stewart) Date: Thu Oct 8 14:02:52 2009 Subject: [Haskell-cafe] Any example of concurrent haskell application? In-Reply-To: References: Message-ID: <20091008182519.GP31281@whirlpool.galois.com> dmehrtash: > I am trying to learn more about concurrent applications in Haskell by studying > an existing a real application source code. I would very much appreciate if > you can recommend an application that you feel has done a good job in > implementing a real time application in Haskell. > hmp3 uses a read thread to reduce user input latency. Lambdabot is an IRC gateway that forks a thread for every message. hyena is a heavily concurrent web server. All on Hackage. From gcross at phys.washington.edu Thu Oct 8 15:00:19 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Oct 8 14:37:51 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> Message-ID: Out of curiosity, why do you think that porting Haskell to the JVM would make such a large difference? Haskell can already interface with C libraries; are there really so many commercially vital libraries that are JVM-only? Cheers, Greg On Oct 8, 2009, at 11:08 AM, John A. De Goes wrote: > > Some of these are not ready for production use; e.g.: RESTng: > "RESTng is still experimental and incomplete". It has no > documentation and doesn't even compile. Sadly typical. > > It's a bit of a chicken and egg thing. I'd switch to Haskell in a > commercial setting if there were more good libraries, yet the act of > switching would lead to the production of more good libraries. The > latter, though, is cost-prohibitive, given all the components that > would need to be developed. A few years from now, or post Haskell-on- > JVM, I might be singing a different tune. > > I do greatly admire the work you and your company have done for > Haskell. > > What has the Industrial Haskell group done so far? I haven't seen > any announcements. The work I'd be most interested in helping co- > sponsor is Haskell on JVM (biggest bang for the buck). > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Oct 8, 2009, at 11:24 AM, Don Stewart wrote: > >> john: >>> * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. >> >> This one is fine: >> >> twitter >> hs-twitter library: Haskell binding to the Twitter API >> del.icio.us >> delicious library: Accessing the del.icio.us APIs from >> Haskell (v2) >> friendfeed >> ffeed library and programs: Haskell binding to the FriendFeed >> API >> LiveJournal >> feed2lj program: Cross-post any RSS/Atom feed to LiveJournal >> flickr >> flickr library and programs: Haskell binding to the Flickr API >> amazon >> hS3 library and program: Interface to Amazon's Simple Storage >> Service (S3) >> mediawiki >> mediawiki library and programs: Interfacing with the >> MediaWiki API >> google pubsub >> pubsub library and programs: A library for Google/SixApart >> pubsub hub interaction >> >> >> Speaking of REST, >> >> RESTng library: A framework for writing RESTful applications. >> >> And auth: >> >> WindowsLive >> windowslive library and program: Implements Windows Live Web >> Authentication and Delegated Authentication >> OpenID >> openid library: An implementation of the OpenID-2.0 spec. >> OAuth >> hoauth library and program: A Haskell implementation of OAuth >> 1.0a protocol. >> >> >> We've obviously not all there yet, but we have a way to get there -- >> write and improve code on Hackage. Galois is doing its part (we've >> released dozens of web packages), but the other commercial users >> need to >> help out too. >> >> Join the Industrial Haskell Group and fund open source work. Or, if >> you >> can, release some of the non-IP-encumbered things you work on! >> >> >> -- Don > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From john at n-brain.net Thu Oct 8 15:20:29 2009 From: john at n-brain.net (John A. De Goes) Date: Thu Oct 8 14:58:05 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> Message-ID: <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> Yes. C is the language of operating systems and browsers and low-level system utilities -- not, by and large, the backbone of today's web applications. Projects written in C/C++ tend to be ignored in favor of those written in Java (Hypertable versus HBase, for example). There are exceptions, but there are fewer of them over time. Java's spot in the middle tier has overflowed into the bottom tier, as performance and community size have increased. Moreover, C libraries are seldom cross-platform (leading to wasteful fiddling and endless frustration), and they are painful to interface with due to the requirement for detailed type annotations, which are easy to get wrong. JVM is cross-platform, and contains sufficient typing information to permit one to write something like, "import foreign jvm java.list.Collection", and have typed access to the whole class and all of its methods. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 8, 2009, at 1:00 PM, Gregory Crosswhite wrote: > Out of curiosity, why do you think that porting Haskell to the JVM > would make such a large difference? Haskell can already interface > with C libraries; are there really so many commercially vital > libraries that are JVM-only? > > Cheers, > Greg > > > On Oct 8, 2009, at 11:08 AM, John A. De Goes wrote: > >> >> Some of these are not ready for production use; e.g.: RESTng: >> "RESTng is still experimental and incomplete". It has no >> documentation and doesn't even compile. Sadly typical. >> >> It's a bit of a chicken and egg thing. I'd switch to Haskell in a >> commercial setting if there were more good libraries, yet the act >> of switching would lead to the production of more good libraries. >> The latter, though, is cost-prohibitive, given all the components >> that would need to be developed. A few years from now, or post >> Haskell-on-JVM, I might be singing a different tune. >> >> I do greatly admire the work you and your company have done for >> Haskell. >> >> What has the Industrial Haskell group done so far? I haven't seen >> any announcements. The work I'd be most interested in helping co- >> sponsor is Haskell on JVM (biggest bang for the buck). >> >> Regards, >> >> John A. De Goes >> N-Brain, Inc. >> The Evolution of Collaboration >> >> http://www.n-brain.net | 877-376-2724 x 101 >> >> On Oct 8, 2009, at 11:24 AM, Don Stewart wrote: >> >>> john: >>>> * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. >>> >>> This one is fine: >>> >>> twitter >>> hs-twitter library: Haskell binding to the Twitter API >>> del.icio.us >>> delicious library: Accessing the del.icio.us APIs from >>> Haskell (v2) >>> friendfeed >>> ffeed library and programs: Haskell binding to the FriendFeed >>> API >>> LiveJournal >>> feed2lj program: Cross-post any RSS/Atom feed to LiveJournal >>> flickr >>> flickr library and programs: Haskell binding to the Flickr API >>> amazon >>> hS3 library and program: Interface to Amazon's Simple Storage >>> Service (S3) >>> mediawiki >>> mediawiki library and programs: Interfacing with the >>> MediaWiki API >>> google pubsub >>> pubsub library and programs: A library for Google/SixApart >>> pubsub hub interaction >>> >>> >>> Speaking of REST, >>> >>> RESTng library: A framework for writing RESTful applications. >>> >>> And auth: >>> >>> WindowsLive >>> windowslive library and program: Implements Windows Live Web >>> Authentication and Delegated Authentication >>> OpenID >>> openid library: An implementation of the OpenID-2.0 spec. >>> OAuth >>> hoauth library and program: A Haskell implementation of OAuth >>> 1.0a protocol. >>> >>> >>> We've obviously not all there yet, but we have a way to get there -- >>> write and improve code on Hackage. Galois is doing its part (we've >>> released dozens of web packages), but the other commercial users >>> need to >>> help out too. >>> >>> Join the Industrial Haskell Group and fund open source work. Or, >>> if you >>> can, release some of the non-IP-encumbered things you work on! >>> >>> >>> -- Don >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Thu Oct 8 15:42:05 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 8 15:19:35 2009 Subject: [Haskell-cafe] Re: Generalizing IO In-Reply-To: References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> Message-ID: <4ACE408D.7000405@btinternet.com> Heinrich Apfelmus wrote: > Alternatively, you can use algebraic data types instead of type classes > to generalize one program to different implementations. For monads, this > can be achieved with > > http://hackage.haskell.org/package/MonadPrompt > > In particular, the idea is to turn every effect like > > getLine > > into a constructor > > GetLine > > and have different implementations pattern match on that. > Ooo, that's interesting... I did wonder for a moment whether this would allow you to analyse what the monadic action does without actually "doing" it, but on reflection this is fundamentally impossible. The action that happens next can (and often does) depend on the result of a previous effect. I guess if you wanted to run your action through an optimiser before actually running it, you'd need to use arrows (and all the terrifying syntax that entails)... From frank at geoinfo.tuwien.ac.at Thu Oct 8 16:08:48 2009 From: frank at geoinfo.tuwien.ac.at (Andrew U. Frank) Date: Thu Oct 8 15:46:33 2009 Subject: [Haskell-cafe] difference "cabal configure" and "runghc Setup.lhs configure" Message-ID: <200910082208.48803.frank@geoinfo.tuwien.ac.at> i have a strange error, which does not occur when i run runghc Setup.lhs configure but when i use cabal configure and then build, it occurs. the error is Type constructor Control.Exception.Exception used as a class in the instance declaration. (i have imported qualified Control.Exception) two questions: 1. Exception is a class (in Control.Exception) - why the error? 2. why is there a difference between runghc and cabal (using the same cabal file). i attach the cabal file and the two configuratin files produced. -------------- next part -------------- name: hs2svn version: 0.1 cabal-version: -any build-type: Simple license: GPL license-file: "" copyright: Andrew U Frank, TU Wien maintainer: Andrew U Frank build-depends: base -any, filepath -any, haskell98 -any, process -any stability: experimental homepage: package-url: bug-reports: frank@geoinfo.tuwien.ac.at synopsis: a simple way to use svn from a haskell program description: System.Process is used to send commands to svn and analyzes the returned messages (partially). only the routines which were needed for a project, but could be completed following the examples given. error handling should be improved. . works with 6.10 category: development author: Andrew U Frank tested-with: data-files: data-dir: "" extra-source-files: extra-tmp-files: exposed-modules: SVN.Hs2svn exposed: True buildable: True build-tools: cpp-options: cc-options: ld-options: pkgconfig-depends: frameworks: c-sources: extensions: extra-libraries: extra-lib-dirs: includes: install-includes: include-dirs: hs-source-dirs: . other-modules: ghc-prof-options: ghc-shared-options: ghc-options: hugs-options: nhc98-options: jhc-options: executable: Test main-is: Hs2svnTest.hs buildable: True build-tools: cpp-options: cc-options: ld-options: pkgconfig-depends: frameworks: c-sources: extensions: extra-libraries: extra-lib-dirs: includes: install-includes: include-dirs: hs-source-dirs: . other-modules: ghc-prof-options: ghc-shared-options: ghc-options: hugs-options: nhc98-options: jhc-options: -------------- next part -------------- Saved package config for hs2svn-0.1 written by Cabal-1.6.0.3 using ghc-6.10 LocalBuildInfo {installDirTemplates = InstallDirs {prefix = "/home/frank/.cabal", bindir = "$prefix/bin", libdir = "$prefix/lib", libsubdir = "$pkgid/$compiler", dynlibdir = "$libdir", libexecdir = "$prefix/libexec", progdir = "$libdir/hugs/programs", includedir = "$libdir/$libsubdir/include", datadir = "$prefix/share", datasubdir = "$pkgid", docdir = "$datadir/doc/$pkgid", mandir = "$datadir/man", htmldir = "$docdir/html", haddockdir = "$htmldir"}, compiler = Compiler {compilerId = CompilerId GHC (Version {versionBranch = [6,10,4], versionTags = []}), compilerExtensions = [(CPP,"-XCPP"),(PostfixOperators,"-XPostfixOperators"),(PatternGuards,"-XPatternGuards"),(UnicodeSyntax,"-XUnicodeSyntax"),(MagicHash,"-XMagicHash"),(PolymorphicComponents,"-XPolymorphicComponents"),(ExistentialQuantification,"-XExistentialQuantification"),(KindSignatures,"-XKindSignatures"),(EmptyDataDecls,"-XEmptyDataDecls"),(ParallelListComp,"-XParallelListComp"),(TransformListComp,"-XTransformListComp"),(ForeignFunctionInterface,"-XForeignFunctionInterface"),(UnliftedFFITypes,"-XUnliftedFFITypes"),(LiberalTypeSynonyms,"-XLiberalTypeSynonyms"),(Rank2Types,"-XRank2Types"),(RankNTypes,"-XRankNTypes"),(ImpredicativeTypes,"-XImpredicativeTypes"),(TypeOperators,"-XTypeOperators"),(RecursiveDo,"-XRecursiveDo"),(Arrows,"-XArrows"),(UnknownExtension "PArr","-XPArr"),(TemplateHaskell,"-XTemplateHaskell"),(QuasiQuotes,"-XQuasiQuotes"),(Generics,"-XGenerics"),(NoImplicitPrelude,"-XNoImplicitPrelude"),(RecordWildCards,"-XRecordWildCards"),(NamedFieldPuns,"-XNamedFieldPuns"),(RecordPuns,"-XRecordPuns"),(DisambiguateRecordFields,"-XDisambiguateRecordFields"),(OverloadedStrings,"-XOverloadedStrings"),(GADTs,"-XGADTs"),(ViewPatterns,"-XViewPatterns"),(TypeFamilies,"-XTypeFamilies"),(BangPatterns,"-XBangPatterns"),(NoMonomorphismRestriction,"-XNoMonomorphismRestriction"),(NoMonoPatBinds,"-XNoMonoPatBinds"),(RelaxedPolyRec,"-XRelaxedPolyRec"),(ExtendedDefaultRules,"-XExtendedDefaultRules"),(ImplicitParams,"-XImplicitParams"),(ScopedTypeVariables,"-XScopedTypeVariables"),(PatternSignatures,"-XPatternSignatures"),(UnboxedTuples,"-XUnboxedTuples"),(StandaloneDeriving,"-XStandaloneDeriving"),(DeriveDataTypeable,"-XDeriveDataTypeable"),(TypeSynonymInstances,"-XTypeSynonymInstances"),(FlexibleContexts,"-XFlexibleContexts"),(FlexibleInstances,"-XFlexibleInstances"),(ConstrainedClassMethods,"-XConstrainedClassMethods"),(MultiParamTypeClasses,"-XMultiParamTypeClasses"),(FunctionalDependencies,"-XFunctionalDependencies"),(GeneralizedNewtypeDeriving,"-XGeneralizedNewtypeDeriving"),(OverlappingInstances,"-XOverlappingInstances"),(UndecidableInstances,"-XUndecidableInstances"),(IncoherentInstances,"-XIncoherentInstances"),(PackageImports,"-XPackageImports"),(NewQualifiedOperators,"-XNewQualifiedOperators")]}, buildDir = "dist/build", scratchDir = "dist/scratch", packageDeps = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [3,0,3,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "haskell98", pkgVersion = Version {versionBranch = [1,0,1,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,0,1,1], versionTags = []}}], installedPkgs = PackageIndex (fromList [(PackageName "array",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,2,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package defines the classes @IArray@ of immutable arrays and\n@MArray@ of arrays mutable within appropriate monads, as well as\nsome instances of these classes.", category = "Data Structures", exposed = True, exposedModules = [ModuleName ["Data","Array","Base"],ModuleName ["Data","Array","Diff"],ModuleName ["Data","Array","IArray"],ModuleName ["Data","Array","IO"],ModuleName ["Data","Array","IO","Internals"],ModuleName ["Data","Array","MArray"],ModuleName ["Data","Array","ST"],ModuleName ["Data","Array","Storable"],ModuleName ["Data","Array","Unboxed"],ModuleName ["Data","Array"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/array-0.2.0.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/array-0.2.0.0"], hsLibraries = ["HSarray-0.2.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "syb", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/array/array.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/array"]}]),(PackageName "base",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [3,0,3,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This is a backwards-compatible version of the base package.\nIt depends on a later version of base, and was probably supplied\nwith your compiler when it was installed.", category = "", exposed = True, exposedModules = [ModuleName ["Data","Generics"],ModuleName ["Data","Generics","Aliases"],ModuleName ["Data","Generics","Basics"],ModuleName ["Data","Generics","Instances"],ModuleName ["Data","Generics","Schemes"],ModuleName ["Data","Generics","Text"],ModuleName ["Data","Generics","Twins"],ModuleName ["Foreign","Concurrent"],ModuleName ["GHC","Arr"],ModuleName ["GHC","Base"],ModuleName ["GHC","Conc"],ModuleName ["GHC","ConsoleHandler"],ModuleName ["GHC","Desugar"],ModuleName ["GHC","Dotnet"],ModuleName ["GHC","Enum"],ModuleName ["GHC","Environment"],ModuleName ["GHC","Err"],ModuleName ["GHC","Exception"],ModuleName ["GHC","Exts"],ModuleName ["GHC","Float"],ModuleName ["GHC","ForeignPtr"],ModuleName ["GHC","Handle"],ModuleName ["GHC","IO"],ModuleName ["GHC","IOBase"],ModuleName ["GHC","Int"],ModuleName ["GHC","List"],ModuleName ["GHC","Num"],ModuleName ["GHC","PArr"],ModuleName ["GHC","Pack"],ModuleName ["GHC","Ptr"],ModuleName ["GHC","Read"],ModuleName ["GHC","Real"],ModuleName ["GHC","ST"],ModuleName ["GHC","STRef"],ModuleName ["GHC","Show"],ModuleName ["GHC","Stable"],ModuleName ["GHC","Storable"],ModuleName ["GHC","TopHandler"],ModuleName ["GHC","Unicode"],ModuleName ["GHC","Weak"],ModuleName ["GHC","Word"],ModuleName ["System","Timeout"],ModuleName ["Control","Applicative"],ModuleName ["Control","Arrow"],ModuleName ["Control","Category"],ModuleName ["Control","Concurrent"],ModuleName ["Control","Concurrent","Chan"],ModuleName ["Control","Concurrent","MVar"],ModuleName ["Control","Concurrent","QSem"],ModuleName ["Control","Concurrent","QSemN"],ModuleName ["Control","Concurrent","SampleVar"],ModuleName ["Control","Exception"],ModuleName ["Control","Monad"],ModuleName ["Control","Monad","Fix"],ModuleName ["Control","Monad","Instances"],ModuleName ["Control","Monad","ST"],ModuleName ["Control","Monad","ST","Lazy"],ModuleName ["Control","Monad","ST","Strict"],ModuleName ["Data","Bits"],ModuleName ["Data","Bool"],ModuleName ["Data","Char"],ModuleName ["Data","Complex"],ModuleName ["Data","Dynamic"],ModuleName ["Data","Either"],ModuleName ["Data","Eq"],ModuleName ["Data","Fixed"],ModuleName ["Data","Foldable"],ModuleName ["Data","Function"],ModuleName ["Data","HashTable"],ModuleName ["Data","IORef"],ModuleName ["Data","Int"],ModuleName ["Data","Ix"],ModuleName ["Data","List"],ModuleName ["Data","Maybe"],ModuleName ["Data","Monoid"],ModuleName ["Data","Ord"],ModuleName ["Data","Ratio"],ModuleName ["Data","STRef"],ModuleName ["Data","STRef","Lazy"],ModuleName ["Data","STRef","Strict"],ModuleName ["Data","String"],ModuleName ["Data","Traversable"],ModuleName ["Data","Tuple"],ModuleName ["Data","Typeable"],ModuleName ["Data","Unique"],ModuleName ["Data","Version"],ModuleName ["Data","Word"],ModuleName ["Debug","Trace"],ModuleName ["Foreign"],ModuleName ["Foreign","C"],ModuleName ["Foreign","C","Error"],ModuleName ["Foreign","C","String"],ModuleName ["Foreign","C","Types"],ModuleName ["Foreign","ForeignPtr"],ModuleName ["Foreign","Marshal"],ModuleName ["Foreign","Marshal","Alloc"],ModuleName ["Foreign","Marshal","Array"],ModuleName ["Foreign","Marshal","Error"],ModuleName ["Foreign","Marshal","Pool"],ModuleName ["Foreign","Marshal","Utils"],ModuleName ["Foreign","Ptr"],ModuleName ["Foreign","StablePtr"],ModuleName ["Foreign","Storable"],ModuleName ["Numeric"],ModuleName ["Prelude"],ModuleName ["System","Console","GetOpt"],ModuleName ["System","CPUTime"],ModuleName ["System","Environment"],ModuleName ["System","Exit"],ModuleName ["System","IO"],ModuleName ["System","IO","Error"],ModuleName ["System","IO","Unsafe"],ModuleName ["System","Info"],ModuleName ["System","Mem"],ModuleName ["System","Mem","StableName"],ModuleName ["System","Mem","Weak"],ModuleName ["System","Posix","Internals"],ModuleName ["System","Posix","Types"],ModuleName ["Text","ParserCombinators","ReadP"],ModuleName ["Text","ParserCombinators","ReadPrec"],ModuleName ["Text","Printf"],ModuleName ["Text","Read"],ModuleName ["Text","Read","Lex"],ModuleName ["Text","Show"],ModuleName ["Text","Show","Functions"],ModuleName ["Unsafe","Coerce"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/base-3.0.3.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/base-3.0.3.1"], hsLibraries = ["HSbase-3.0.3.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "syb", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/base/base.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/base"]},InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains the Prelude and its support libraries,\nand a large collection of useful libraries ranging from data\nstructures to parsing combinators and debugging utilities.", category = "", exposed = True, exposedModules = [ModuleName ["Foreign","Concurrent"],ModuleName ["GHC","Arr"],ModuleName ["GHC","Base"],ModuleName ["GHC","Classes"],ModuleName ["GHC","Conc"],ModuleName ["GHC","ConsoleHandler"],ModuleName ["GHC","Desugar"],ModuleName ["GHC","Enum"],ModuleName ["GHC","Environment"],ModuleName ["GHC","Err"],ModuleName ["GHC","Exception"],ModuleName ["GHC","Exts"],ModuleName ["GHC","Float"],ModuleName ["GHC","ForeignPtr"],ModuleName ["GHC","Handle"],ModuleName ["GHC","IO"],ModuleName ["GHC","IOBase"],ModuleName ["GHC","Int"],ModuleName ["GHC","List"],ModuleName ["GHC","Num"],ModuleName ["GHC","PArr"],ModuleName ["GHC","Pack"],ModuleName ["GHC","Ptr"],ModuleName ["GHC","Read"],ModuleName ["GHC","Real"],ModuleName ["GHC","ST"],ModuleName ["GHC","STRef"],ModuleName ["GHC","Show"],ModuleName ["GHC","Stable"],ModuleName ["GHC","Storable"],ModuleName ["GHC","TopHandler"],ModuleName ["GHC","Unicode"],ModuleName ["GHC","Weak"],ModuleName ["GHC","Word"],ModuleName ["System","Timeout"],ModuleName ["Control","Applicative"],ModuleName ["Control","Arrow"],ModuleName ["Control","Category"],ModuleName ["Control","Concurrent"],ModuleName ["Control","Concurrent","Chan"],ModuleName ["Control","Concurrent","MVar"],ModuleName ["Control","Concurrent","QSem"],ModuleName ["Control","Concurrent","QSemN"],ModuleName ["Control","Concurrent","SampleVar"],ModuleName ["Control","Exception"],ModuleName ["Control","Exception","Base"],ModuleName ["Control","OldException"],ModuleName ["Control","Monad"],ModuleName ["Control","Monad","Fix"],ModuleName ["Control","Monad","Instances"],ModuleName ["Control","Monad","ST"],ModuleName ["Control","Monad","ST","Lazy"],ModuleName ["Control","Monad","ST","Strict"],ModuleName ["Data","Bits"],ModuleName ["Data","Bool"],ModuleName ["Data","Char"],ModuleName ["Data","Complex"],ModuleName ["Data","Dynamic"],ModuleName ["Data","Either"],ModuleName ["Data","Eq"],ModuleName ["Data","Data"],ModuleName ["Data","Fixed"],ModuleName ["Data","Foldable"],ModuleName ["Data","Function"],ModuleName ["Data","HashTable"],ModuleName ["Data","IORef"],ModuleName ["Data","Int"],ModuleName ["Data","Ix"],ModuleName ["Data","List"],ModuleName ["Data","Maybe"],ModuleName ["Data","Monoid"],ModuleName ["Data","Ord"],ModuleName ["Data","Ratio"],ModuleName ["Data","STRef"],ModuleName ["Data","STRef","Lazy"],ModuleName ["Data","STRef","Strict"],ModuleName ["Data","String"],ModuleName ["Data","Traversable"],ModuleName ["Data","Tuple"],ModuleName ["Data","Typeable"],ModuleName ["Data","Unique"],ModuleName ["Data","Version"],ModuleName ["Data","Word"],ModuleName ["Debug","Trace"],ModuleName ["Foreign"],ModuleName ["Foreign","C"],ModuleName ["Foreign","C","Error"],ModuleName ["Foreign","C","String"],ModuleName ["Foreign","C","Types"],ModuleName ["Foreign","ForeignPtr"],ModuleName ["Foreign","Marshal"],ModuleName ["Foreign","Marshal","Alloc"],ModuleName ["Foreign","Marshal","Array"],ModuleName ["Foreign","Marshal","Error"],ModuleName ["Foreign","Marshal","Pool"],ModuleName ["Foreign","Marshal","Utils"],ModuleName ["Foreign","Ptr"],ModuleName ["Foreign","StablePtr"],ModuleName ["Foreign","Storable"],ModuleName ["Numeric"],ModuleName ["Prelude"],ModuleName ["System","Console","GetOpt"],ModuleName ["System","CPUTime"],ModuleName ["System","Environment"],ModuleName ["System","Exit"],ModuleName ["System","IO"],ModuleName ["System","IO","Error"],ModuleName ["System","IO","Unsafe"],ModuleName ["System","Info"],ModuleName ["System","Mem"],ModuleName ["System","Mem","StableName"],ModuleName ["System","Mem","Weak"],ModuleName ["System","Posix","Internals"],ModuleName ["System","Posix","Types"],ModuleName ["Text","ParserCombinators","ReadP"],ModuleName ["Text","ParserCombinators","ReadPrec"],ModuleName ["Text","Printf"],ModuleName ["Text","Read"],ModuleName ["Text","Read","Lex"],ModuleName ["Text","Show"],ModuleName ["Text","Show","Functions"],ModuleName ["Unsafe","Coerce"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/base-4.1.0.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/base-4.1.0.0"], hsLibraries = ["HSbase-4.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/base-4.1.0.0/include"], includes = ["HsBase.h"], depends = [PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "integer", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/base/base.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/base"]}]),(PackageName "directory",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,0,0,3], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides a library for handling directories.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Directory"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/directory-1.0.0.3"], libraryDirs = ["/usr/lib/ghc-6.10.4/directory-1.0.0.3"], hsLibraries = ["HSdirectory-1.0.0.3"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/directory-1.0.0.3/include"], includes = ["HsDirectory.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,3,2,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/directory/directory.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/directory"]}]),(PackageName "filepath",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}}, license = BSD3, copyright = "", maintainer = "", author = "Neil Mitchell", stability = "", homepage = "http://www-users.cs.york.ac.uk/~ndm/filepath/", pkgUrl = "", description = "", category = "System", exposed = True, exposedModules = [ModuleName ["System","FilePath"],ModuleName ["System","FilePath","Posix"],ModuleName ["System","FilePath","Windows"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/filepath-1.1.0.2"], libraryDirs = ["/usr/lib/ghc-6.10.4/filepath-1.1.0.2"], hsLibraries = ["HSfilepath-1.1.0.2"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/filepath/filepath.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/filepath"]}]),(PackageName "ghc-prim",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "GHC primitives.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Prim"],ModuleName ["GHC","Bool"],ModuleName ["GHC","Generics"],ModuleName ["GHC","Ordering"],ModuleName ["GHC","PrimopWrappers"],ModuleName ["GHC","IntWord32"],ModuleName ["GHC","IntWord64"],ModuleName ["GHC","Tuple"],ModuleName ["GHC","Types"],ModuleName ["GHC","Unit"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0"], hsLibraries = ["HSghc-prim-0.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/ghc-prim/ghc-prim.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/ghc-prim"]}]),(PackageName "haskell98",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "haskell98", pkgVersion = Version {versionBranch = [1,0,1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "http://www.haskell.org/definition/", pkgUrl = "", description = "This package provides compatibility with the modules of Haskell\n98 and the FFI addendum, by means of wrappers around modules from\nthe base package (which in many cases have additional features).\nHowever Prelude, Numeric and Foreign are provided directly by\nthe base package.", category = "", exposed = True, exposedModules = [ModuleName ["Array"],ModuleName ["CPUTime"],ModuleName ["Char"],ModuleName ["Complex"],ModuleName ["Directory"],ModuleName ["IO"],ModuleName ["Ix"],ModuleName ["List"],ModuleName ["Locale"],ModuleName ["Maybe"],ModuleName ["Monad"],ModuleName ["Random"],ModuleName ["Ratio"],ModuleName ["System"],ModuleName ["Time"],ModuleName ["Bits"],ModuleName ["CError"],ModuleName ["CForeign"],ModuleName ["CString"],ModuleName ["CTypes"],ModuleName ["ForeignPtr"],ModuleName ["Int"],ModuleName ["MarshalAlloc"],ModuleName ["MarshalArray"],ModuleName ["MarshalError"],ModuleName ["MarshalUtils"],ModuleName ["Ptr"],ModuleName ["StablePtr"],ModuleName ["Storable"],ModuleName ["Word"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/haskell98-1.0.1.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/haskell98-1.0.1.0"], hsLibraries = ["HShaskell98-1.0.1.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,2,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,0,0,3], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,0,1,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "random", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/haskell98/haskell98.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/haskell98"]}]),(PackageName "integer",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "integer", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains an Integer library based on GMP.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Integer"],ModuleName ["GHC","Integer","Internals"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/integer-0.1.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/integer-0.1.0.1"], hsLibraries = ["HSinteger-0.1.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/integer/integer.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/integer"]}]),(PackageName "old-locale",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides the old locale library.\nFor new code, the new locale library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Locale"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/old-locale-1.0.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/old-locale-1.0.0.1"], hsLibraries = ["HSold-locale-1.0.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/old-locale/old-locale.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/old-locale"]}]),(PackageName "old-time",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides the old time library.\nFor new code, the new time library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Time"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/old-time-1.0.0.2"], libraryDirs = ["/usr/lib/ghc-6.10.4/old-time-1.0.0.2"], hsLibraries = ["HSold-time-1.0.0.2"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/old-time-1.0.0.2/include"], includes = ["HsTime.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/old-time/old-time.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/old-time"]}]),(PackageName "process",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,0,1,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains libraries for dealing with system processes.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Process","Internals"],ModuleName ["System","Process"],ModuleName ["System","Cmd"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/process-1.0.1.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/process-1.0.1.1"], hsLibraries = ["HSprocess-1.0.1.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/process-1.0.1.1/include"], includes = ["runProcess.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,0,0,3], versionTags = []}},PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,3,2,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/process/process.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/process"]}]),(PackageName "random",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "random", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides a random number library.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Random"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/random-1.0.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/random-1.0.0.1"], hsLibraries = ["HSrandom-1.0.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/random/random.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/random"]}]),(PackageName "rts",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "glasgow-haskell-users@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "", category = "", exposed = True, exposedModules = [], hiddenModules = [], importDirs = [], libraryDirs = ["/usr/lib/ghc-6.10.4"], hsLibraries = ["HSrts"], extraLibraries = ["m","ffi","gmp","dl","rt"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/include"], includes = ["Stg.h"], depends = [], hugsOptions = [], ccOptions = [], ldOptions = ["-u","ghczmprim_GHCziTypes_Izh_static_info","-u","ghczmprim_GHCziTypes_Czh_static_info","-u","ghczmprim_GHCziTypes_Fzh_static_info","-u","ghczmprim_GHCziTypes_Dzh_static_info","-u","base_GHCziPtr_Ptr_static_info","-u","base_GHCziWord_Wzh_static_info","-u","base_GHCziInt_I8zh_static_info","-u","base_GHCziInt_I16zh_static_info","-u","base_GHCziInt_I32zh_static_info","-u","base_GHCziInt_I64zh_static_info","-u","base_GHCziWord_W8zh_static_info","-u","base_GHCziWord_W16zh_static_info","-u","base_GHCziWord_W32zh_static_info","-u","base_GHCziWord_W64zh_static_info","-u","base_GHCziStable_StablePtr_static_info","-u","ghczmprim_GHCziTypes_Izh_con_info","-u","ghczmprim_GHCziTypes_Czh_con_info","-u","ghczmprim_GHCziTypes_Fzh_con_info","-u","ghczmprim_GHCziTypes_Dzh_con_info","-u","base_GHCziPtr_Ptr_con_info","-u","base_GHCziPtr_FunPtr_con_info","-u","base_GHCziStable_StablePtr_con_info","-u","ghczmprim_GHCziBool_False_closure","-u","ghczmprim_GHCziBool_True_closure","-u","base_GHCziPack_unpackCString_closure","-u","base_GHCziIOBase_stackOverflow_closure","-u","base_GHCziIOBase_heapOverflow_closure","-u","base_ControlziExceptionziBase_nonTermination_closure","-u","base_GHCziIOBase_blockedOnDeadMVar_closure","-u","base_GHCziIOBase_blockedIndefinitely_closure","-u","base_ControlziExceptionziBase_nestedAtomically_closure","-u","base_GHCziWeak_runFinalizzerBatch_closure","-u","base_GHCziTopHandler_runIO_closure","-u","base_GHCziTopHandler_runNonIO_closure","-u","base_GHCziConc_runHandlers_closure","-u","base_GHCziConc_ensureIOManagerIsRunning_closure"], frameworkDirs = [], frameworks = [], haddockInterfaces = [], haddockHTMLs = []}]),(PackageName "syb",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "syb", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains the generics system described in the\n/Scrap Your Boilerplate/ papers (see ).\nIt defines the @Data@ class of types permitting folding and unfolding\nof constructor applications, instances of this class for primitive\ntypes, and a variety of traversals.", category = "", exposed = True, exposedModules = [ModuleName ["Data","Generics"],ModuleName ["Data","Generics","Aliases"],ModuleName ["Data","Generics","Basics"],ModuleName ["Data","Generics","Instances"],ModuleName ["Data","Generics","Schemes"],ModuleName ["Data","Generics","Text"],ModuleName ["Data","Generics","Twins"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/syb-0.1.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/syb-0.1.0.1"], hsLibraries = ["HSsyb-0.1.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/syb/syb.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/syb"]}]),(PackageName "unix",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,3,2,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package gives you access to the set of operating system\nservices standardised by POSIX 1003.1b (or the IEEE Portable\nOperating System Interface for Computing Environments -\nIEEE Std. 1003.1).\n\nThe package is not supported under Windows (except under Cygwin).", category = "System", exposed = True, exposedModules = [ModuleName ["System","Posix"],ModuleName ["System","Posix","DynamicLinker","Module"],ModuleName ["System","Posix","DynamicLinker","Prim"],ModuleName ["System","Posix","Directory"],ModuleName ["System","Posix","DynamicLinker"],ModuleName ["System","Posix","Env"],ModuleName ["System","Posix","Error"],ModuleName ["System","Posix","Files"],ModuleName ["System","Posix","IO"],ModuleName ["System","Posix","Process"],ModuleName ["System","Posix","Process","Internals"],ModuleName ["System","Posix","Resource"],ModuleName ["System","Posix","Temp"],ModuleName ["System","Posix","Terminal"],ModuleName ["System","Posix","Time"],ModuleName ["System","Posix","Unistd"],ModuleName ["System","Posix","User"],ModuleName ["System","Posix","Signals"],ModuleName ["System","Posix","Signals","Exts"],ModuleName ["System","Posix","Semaphore"],ModuleName ["System","Posix","SharedMem"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/unix-2.3.2.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/unix-2.3.2.0"], hsLibraries = ["HSunix-2.3.2.0"], extraLibraries = ["rt","util","dl"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/unix-2.3.2.0/include"], includes = ["HsUnix.h","execvpe.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/unix/unix.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/unix"]}])]), pkgDescrFile = Just "./hs2svn.cabal", localPkgDescr = PackageDescription {package = PackageIdentifier {pkgName = PackageName "hs2svn", pkgVersion = Version {versionBranch = [0,1], versionTags = []}}, license = GPL, licenseFile = "", copyright = "Andrew U Frank, TU Wien", maintainer = "Andrew U Frank", author = "Andrew U Frank", stability = "experimental", testedWith = [], homepage = "", pkgUrl = "", bugReports = "frank@geoinfo.tuwien.ac.at", sourceRepos = [], synopsis = "a simple way to use svn from a haskell program", description = "System.Process is used to send commands to svn and analyzes the returned messages (partially).\nonly the routines which were needed for a project, but could be completed following the examples given.\nerror handling should be improved.\n\nworks with 6.10", category = "development", customFieldsPD = [], buildDepends = [Dependency (PackageName "base") (IntersectVersionRanges (IntersectVersionRanges AnyVersion AnyVersion) (ThisVersion (Version {versionBranch = [3,0,3,1], versionTags = []}))),Dependency (PackageName "filepath") (IntersectVersionRanges (IntersectVersionRanges AnyVersion AnyVersion) (ThisVersion (Version {versionBranch = [1,1,0,2], versionTags = []}))),Dependency (PackageName "haskell98") (IntersectVersionRanges (IntersectVersionRanges AnyVersion AnyVersion) (ThisVersion (Version {versionBranch = [1,0,1,0], versionTags = []}))),Dependency (PackageName "process") (IntersectVersionRanges (IntersectVersionRanges AnyVersion AnyVersion) (ThisVersion (Version {versionBranch = [1,0,1,1], versionTags = []})))], descCabalVersion = AnyVersion, buildType = Just Simple, library = Just (Library {exposedModules = [ModuleName ["SVN","Hs2svn"]], libExposed = True, libBuildInfo = BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = ["."], otherModules = [], extensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,[]),(Hugs,[]),(NHC,[]),(JHC,[])], ghcProfOptions = [], ghcSharedOptions = [], customFieldsBI = []}}), executables = [Executable {exeName = "Test", modulePath = "Hs2svnTest.hs", buildInfo = BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = ["."], otherModules = [], extensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,[]),(Hugs,[]),(NHC,[]),(JHC,[])], ghcProfOptions = [], ghcSharedOptions = [], customFieldsBI = []}}], dataFiles = [], dataDir = "", extraSrcFiles = [], extraTmpFiles = []}, withPrograms = [("ar",ConfiguredProgram {programId = "ar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ar"}}),("gcc",ConfiguredProgram {programId = "gcc", programVersion = Just (Version {versionBranch = [4,4,1], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/gcc"}}),("ghc",ConfiguredProgram {programId = "ghc", programVersion = Just (Version {versionBranch = [6,10,4], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ghc"}}),("ghc-pkg",ConfiguredProgram {programId = "ghc-pkg", programVersion = Just (Version {versionBranch = [6,10,4], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ghc-pkg"}}),("haddock",ConfiguredProgram {programId = "haddock", programVersion = Just (Version {versionBranch = [2,4,2], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/haddock"}}),("hsc2hs",ConfiguredProgram {programId = "hsc2hs", programVersion = Just (Version {versionBranch = [0,67], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/hsc2hs"}}),("ld",ConfiguredProgram {programId = "ld", programVersion = Nothing, programArgs = ["-x"], programLocation = FoundOnSystem {locationPath = "/usr/bin/ld"}}),("pkg-config",ConfiguredProgram {programId = "pkg-config", programVersion = Just (Version {versionBranch = [0,22], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/pkg-config"}}),("ranlib",ConfiguredProgram {programId = "ranlib", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ranlib"}}),("strip",ConfiguredProgram {programId = "strip", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/strip"}}),("tar",ConfiguredProgram {programId = "tar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/bin/tar"}})], withPackageDB = UserPackageDB, withVanillaLib = True, withProfLib = False, withSharedLib = False, withProfExe = False, withOptimization = NormalOptimisation, withGHCiLib = True, splitObjs = False, stripExes = True, progPrefix = "", progSuffix = ""} -------------- next part -------------- Saved package config for hs2svn-0.1 written by Cabal-1.6.0.3 using ghc-6.10 LocalBuildInfo {installDirTemplates = InstallDirs {prefix = "/usr/local", bindir = "$prefix/bin", libdir = "$prefix/lib", libsubdir = "$pkgid/$compiler", dynlibdir = "$libdir", libexecdir = "$prefix/libexec", progdir = "$libdir/hugs/programs", includedir = "$libdir/$libsubdir/include", datadir = "$prefix/share", datasubdir = "$pkgid", docdir = "$datadir/doc/$pkgid", mandir = "$datadir/man", htmldir = "$docdir/html", haddockdir = "$htmldir"}, compiler = Compiler {compilerId = CompilerId GHC (Version {versionBranch = [6,10,4], versionTags = []}), compilerExtensions = [(CPP,"-XCPP"),(PostfixOperators,"-XPostfixOperators"),(PatternGuards,"-XPatternGuards"),(UnicodeSyntax,"-XUnicodeSyntax"),(MagicHash,"-XMagicHash"),(PolymorphicComponents,"-XPolymorphicComponents"),(ExistentialQuantification,"-XExistentialQuantification"),(KindSignatures,"-XKindSignatures"),(EmptyDataDecls,"-XEmptyDataDecls"),(ParallelListComp,"-XParallelListComp"),(TransformListComp,"-XTransformListComp"),(ForeignFunctionInterface,"-XForeignFunctionInterface"),(UnliftedFFITypes,"-XUnliftedFFITypes"),(LiberalTypeSynonyms,"-XLiberalTypeSynonyms"),(Rank2Types,"-XRank2Types"),(RankNTypes,"-XRankNTypes"),(ImpredicativeTypes,"-XImpredicativeTypes"),(TypeOperators,"-XTypeOperators"),(RecursiveDo,"-XRecursiveDo"),(Arrows,"-XArrows"),(UnknownExtension "PArr","-XPArr"),(TemplateHaskell,"-XTemplateHaskell"),(QuasiQuotes,"-XQuasiQuotes"),(Generics,"-XGenerics"),(NoImplicitPrelude,"-XNoImplicitPrelude"),(RecordWildCards,"-XRecordWildCards"),(NamedFieldPuns,"-XNamedFieldPuns"),(RecordPuns,"-XRecordPuns"),(DisambiguateRecordFields,"-XDisambiguateRecordFields"),(OverloadedStrings,"-XOverloadedStrings"),(GADTs,"-XGADTs"),(ViewPatterns,"-XViewPatterns"),(TypeFamilies,"-XTypeFamilies"),(BangPatterns,"-XBangPatterns"),(NoMonomorphismRestriction,"-XNoMonomorphismRestriction"),(NoMonoPatBinds,"-XNoMonoPatBinds"),(RelaxedPolyRec,"-XRelaxedPolyRec"),(ExtendedDefaultRules,"-XExtendedDefaultRules"),(ImplicitParams,"-XImplicitParams"),(ScopedTypeVariables,"-XScopedTypeVariables"),(PatternSignatures,"-XPatternSignatures"),(UnboxedTuples,"-XUnboxedTuples"),(StandaloneDeriving,"-XStandaloneDeriving"),(DeriveDataTypeable,"-XDeriveDataTypeable"),(TypeSynonymInstances,"-XTypeSynonymInstances"),(FlexibleContexts,"-XFlexibleContexts"),(FlexibleInstances,"-XFlexibleInstances"),(ConstrainedClassMethods,"-XConstrainedClassMethods"),(MultiParamTypeClasses,"-XMultiParamTypeClasses"),(FunctionalDependencies,"-XFunctionalDependencies"),(GeneralizedNewtypeDeriving,"-XGeneralizedNewtypeDeriving"),(OverlappingInstances,"-XOverlappingInstances"),(UndecidableInstances,"-XUndecidableInstances"),(IncoherentInstances,"-XIncoherentInstances"),(PackageImports,"-XPackageImports"),(NewQualifiedOperators,"-XNewQualifiedOperators")]}, buildDir = "dist/build", scratchDir = "dist/scratch", packageDeps = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "haskell98", pkgVersion = Version {versionBranch = [1,0,1,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,0,1,1], versionTags = []}}], installedPkgs = PackageIndex (fromList [(PackageName "array",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,2,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package defines the classes @IArray@ of immutable arrays and\n@MArray@ of arrays mutable within appropriate monads, as well as\nsome instances of these classes.", category = "Data Structures", exposed = True, exposedModules = [ModuleName ["Data","Array","Base"],ModuleName ["Data","Array","Diff"],ModuleName ["Data","Array","IArray"],ModuleName ["Data","Array","IO"],ModuleName ["Data","Array","IO","Internals"],ModuleName ["Data","Array","MArray"],ModuleName ["Data","Array","ST"],ModuleName ["Data","Array","Storable"],ModuleName ["Data","Array","Unboxed"],ModuleName ["Data","Array"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/array-0.2.0.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/array-0.2.0.0"], hsLibraries = ["HSarray-0.2.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "syb", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/array/array.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/array"]}]),(PackageName "base",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains the Prelude and its support libraries,\nand a large collection of useful libraries ranging from data\nstructures to parsing combinators and debugging utilities.", category = "", exposed = True, exposedModules = [ModuleName ["Foreign","Concurrent"],ModuleName ["GHC","Arr"],ModuleName ["GHC","Base"],ModuleName ["GHC","Classes"],ModuleName ["GHC","Conc"],ModuleName ["GHC","ConsoleHandler"],ModuleName ["GHC","Desugar"],ModuleName ["GHC","Enum"],ModuleName ["GHC","Environment"],ModuleName ["GHC","Err"],ModuleName ["GHC","Exception"],ModuleName ["GHC","Exts"],ModuleName ["GHC","Float"],ModuleName ["GHC","ForeignPtr"],ModuleName ["GHC","Handle"],ModuleName ["GHC","IO"],ModuleName ["GHC","IOBase"],ModuleName ["GHC","Int"],ModuleName ["GHC","List"],ModuleName ["GHC","Num"],ModuleName ["GHC","PArr"],ModuleName ["GHC","Pack"],ModuleName ["GHC","Ptr"],ModuleName ["GHC","Read"],ModuleName ["GHC","Real"],ModuleName ["GHC","ST"],ModuleName ["GHC","STRef"],ModuleName ["GHC","Show"],ModuleName ["GHC","Stable"],ModuleName ["GHC","Storable"],ModuleName ["GHC","TopHandler"],ModuleName ["GHC","Unicode"],ModuleName ["GHC","Weak"],ModuleName ["GHC","Word"],ModuleName ["System","Timeout"],ModuleName ["Control","Applicative"],ModuleName ["Control","Arrow"],ModuleName ["Control","Category"],ModuleName ["Control","Concurrent"],ModuleName ["Control","Concurrent","Chan"],ModuleName ["Control","Concurrent","MVar"],ModuleName ["Control","Concurrent","QSem"],ModuleName ["Control","Concurrent","QSemN"],ModuleName ["Control","Concurrent","SampleVar"],ModuleName ["Control","Exception"],ModuleName ["Control","Exception","Base"],ModuleName ["Control","OldException"],ModuleName ["Control","Monad"],ModuleName ["Control","Monad","Fix"],ModuleName ["Control","Monad","Instances"],ModuleName ["Control","Monad","ST"],ModuleName ["Control","Monad","ST","Lazy"],ModuleName ["Control","Monad","ST","Strict"],ModuleName ["Data","Bits"],ModuleName ["Data","Bool"],ModuleName ["Data","Char"],ModuleName ["Data","Complex"],ModuleName ["Data","Dynamic"],ModuleName ["Data","Either"],ModuleName ["Data","Eq"],ModuleName ["Data","Data"],ModuleName ["Data","Fixed"],ModuleName ["Data","Foldable"],ModuleName ["Data","Function"],ModuleName ["Data","HashTable"],ModuleName ["Data","IORef"],ModuleName ["Data","Int"],ModuleName ["Data","Ix"],ModuleName ["Data","List"],ModuleName ["Data","Maybe"],ModuleName ["Data","Monoid"],ModuleName ["Data","Ord"],ModuleName ["Data","Ratio"],ModuleName ["Data","STRef"],ModuleName ["Data","STRef","Lazy"],ModuleName ["Data","STRef","Strict"],ModuleName ["Data","String"],ModuleName ["Data","Traversable"],ModuleName ["Data","Tuple"],ModuleName ["Data","Typeable"],ModuleName ["Data","Unique"],ModuleName ["Data","Version"],ModuleName ["Data","Word"],ModuleName ["Debug","Trace"],ModuleName ["Foreign"],ModuleName ["Foreign","C"],ModuleName ["Foreign","C","Error"],ModuleName ["Foreign","C","String"],ModuleName ["Foreign","C","Types"],ModuleName ["Foreign","ForeignPtr"],ModuleName ["Foreign","Marshal"],ModuleName ["Foreign","Marshal","Alloc"],ModuleName ["Foreign","Marshal","Array"],ModuleName ["Foreign","Marshal","Error"],ModuleName ["Foreign","Marshal","Pool"],ModuleName ["Foreign","Marshal","Utils"],ModuleName ["Foreign","Ptr"],ModuleName ["Foreign","StablePtr"],ModuleName ["Foreign","Storable"],ModuleName ["Numeric"],ModuleName ["Prelude"],ModuleName ["System","Console","GetOpt"],ModuleName ["System","CPUTime"],ModuleName ["System","Environment"],ModuleName ["System","Exit"],ModuleName ["System","IO"],ModuleName ["System","IO","Error"],ModuleName ["System","IO","Unsafe"],ModuleName ["System","Info"],ModuleName ["System","Mem"],ModuleName ["System","Mem","StableName"],ModuleName ["System","Mem","Weak"],ModuleName ["System","Posix","Internals"],ModuleName ["System","Posix","Types"],ModuleName ["Text","ParserCombinators","ReadP"],ModuleName ["Text","ParserCombinators","ReadPrec"],ModuleName ["Text","Printf"],ModuleName ["Text","Read"],ModuleName ["Text","Read","Lex"],ModuleName ["Text","Show"],ModuleName ["Text","Show","Functions"],ModuleName ["Unsafe","Coerce"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/base-4.1.0.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/base-4.1.0.0"], hsLibraries = ["HSbase-4.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/base-4.1.0.0/include"], includes = ["HsBase.h"], depends = [PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "integer", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/base/base.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/base"]}]),(PackageName "directory",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,0,0,3], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides a library for handling directories.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Directory"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/directory-1.0.0.3"], libraryDirs = ["/usr/lib/ghc-6.10.4/directory-1.0.0.3"], hsLibraries = ["HSdirectory-1.0.0.3"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/directory-1.0.0.3/include"], includes = ["HsDirectory.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,3,2,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/directory/directory.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/directory"]}]),(PackageName "filepath",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}}, license = BSD3, copyright = "", maintainer = "", author = "Neil Mitchell", stability = "", homepage = "http://www-users.cs.york.ac.uk/~ndm/filepath/", pkgUrl = "", description = "", category = "System", exposed = True, exposedModules = [ModuleName ["System","FilePath"],ModuleName ["System","FilePath","Posix"],ModuleName ["System","FilePath","Windows"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/filepath-1.1.0.2"], libraryDirs = ["/usr/lib/ghc-6.10.4/filepath-1.1.0.2"], hsLibraries = ["HSfilepath-1.1.0.2"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/filepath/filepath.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/filepath"]}]),(PackageName "ghc-prim",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "GHC primitives.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Prim"],ModuleName ["GHC","Bool"],ModuleName ["GHC","Generics"],ModuleName ["GHC","Ordering"],ModuleName ["GHC","PrimopWrappers"],ModuleName ["GHC","IntWord32"],ModuleName ["GHC","IntWord64"],ModuleName ["GHC","Tuple"],ModuleName ["GHC","Types"],ModuleName ["GHC","Unit"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0"], hsLibraries = ["HSghc-prim-0.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/ghc-prim/ghc-prim.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/ghc-prim"]}]),(PackageName "haskell98",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "haskell98", pkgVersion = Version {versionBranch = [1,0,1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "http://www.haskell.org/definition/", pkgUrl = "", description = "This package provides compatibility with the modules of Haskell\n98 and the FFI addendum, by means of wrappers around modules from\nthe base package (which in many cases have additional features).\nHowever Prelude, Numeric and Foreign are provided directly by\nthe base package.", category = "", exposed = True, exposedModules = [ModuleName ["Array"],ModuleName ["CPUTime"],ModuleName ["Char"],ModuleName ["Complex"],ModuleName ["Directory"],ModuleName ["IO"],ModuleName ["Ix"],ModuleName ["List"],ModuleName ["Locale"],ModuleName ["Maybe"],ModuleName ["Monad"],ModuleName ["Random"],ModuleName ["Ratio"],ModuleName ["System"],ModuleName ["Time"],ModuleName ["Bits"],ModuleName ["CError"],ModuleName ["CForeign"],ModuleName ["CString"],ModuleName ["CTypes"],ModuleName ["ForeignPtr"],ModuleName ["Int"],ModuleName ["MarshalAlloc"],ModuleName ["MarshalArray"],ModuleName ["MarshalError"],ModuleName ["MarshalUtils"],ModuleName ["Ptr"],ModuleName ["StablePtr"],ModuleName ["Storable"],ModuleName ["Word"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/haskell98-1.0.1.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/haskell98-1.0.1.0"], hsLibraries = ["HShaskell98-1.0.1.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,2,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,0,0,3], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,0,1,1], versionTags = []}},PackageIdentifier {pkgName = PackageName "random", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/haskell98/haskell98.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/haskell98"]}]),(PackageName "integer",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "integer", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains an Integer library based on GMP.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Integer"],ModuleName ["GHC","Integer","Internals"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/integer-0.1.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/integer-0.1.0.1"], hsLibraries = ["HSinteger-0.1.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/integer/integer.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/integer"]}]),(PackageName "old-locale",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides the old locale library.\nFor new code, the new locale library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Locale"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/old-locale-1.0.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/old-locale-1.0.0.1"], hsLibraries = ["HSold-locale-1.0.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/old-locale/old-locale.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/old-locale"]}]),(PackageName "old-time",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides the old time library.\nFor new code, the new time library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Time"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/old-time-1.0.0.2"], libraryDirs = ["/usr/lib/ghc-6.10.4/old-time-1.0.0.2"], hsLibraries = ["HSold-time-1.0.0.2"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/old-time-1.0.0.2/include"], includes = ["HsTime.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/old-time/old-time.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/old-time"]}]),(PackageName "process",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,0,1,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains libraries for dealing with system processes.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Process","Internals"],ModuleName ["System","Process"],ModuleName ["System","Cmd"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/process-1.0.1.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/process-1.0.1.1"], hsLibraries = ["HSprocess-1.0.1.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/process-1.0.1.1/include"], includes = ["runProcess.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,0,0,3], versionTags = []}},PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}},PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,3,2,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/process/process.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/process"]}]),(PackageName "random",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "random", pkgVersion = Version {versionBranch = [1,0,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package provides a random number library.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Random"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/random-1.0.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/random-1.0.0.1"], hsLibraries = ["HSrandom-1.0.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}},PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,0,0,2], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/random/random.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/random"]}]),(PackageName "rts",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "glasgow-haskell-users@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "", category = "", exposed = True, exposedModules = [], hiddenModules = [], importDirs = [], libraryDirs = ["/usr/lib/ghc-6.10.4"], hsLibraries = ["HSrts"], extraLibraries = ["m","ffi","gmp","dl","rt"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/include"], includes = ["Stg.h"], depends = [], hugsOptions = [], ccOptions = [], ldOptions = ["-u","ghczmprim_GHCziTypes_Izh_static_info","-u","ghczmprim_GHCziTypes_Czh_static_info","-u","ghczmprim_GHCziTypes_Fzh_static_info","-u","ghczmprim_GHCziTypes_Dzh_static_info","-u","base_GHCziPtr_Ptr_static_info","-u","base_GHCziWord_Wzh_static_info","-u","base_GHCziInt_I8zh_static_info","-u","base_GHCziInt_I16zh_static_info","-u","base_GHCziInt_I32zh_static_info","-u","base_GHCziInt_I64zh_static_info","-u","base_GHCziWord_W8zh_static_info","-u","base_GHCziWord_W16zh_static_info","-u","base_GHCziWord_W32zh_static_info","-u","base_GHCziWord_W64zh_static_info","-u","base_GHCziStable_StablePtr_static_info","-u","ghczmprim_GHCziTypes_Izh_con_info","-u","ghczmprim_GHCziTypes_Czh_con_info","-u","ghczmprim_GHCziTypes_Fzh_con_info","-u","ghczmprim_GHCziTypes_Dzh_con_info","-u","base_GHCziPtr_Ptr_con_info","-u","base_GHCziPtr_FunPtr_con_info","-u","base_GHCziStable_StablePtr_con_info","-u","ghczmprim_GHCziBool_False_closure","-u","ghczmprim_GHCziBool_True_closure","-u","base_GHCziPack_unpackCString_closure","-u","base_GHCziIOBase_stackOverflow_closure","-u","base_GHCziIOBase_heapOverflow_closure","-u","base_ControlziExceptionziBase_nonTermination_closure","-u","base_GHCziIOBase_blockedOnDeadMVar_closure","-u","base_GHCziIOBase_blockedIndefinitely_closure","-u","base_ControlziExceptionziBase_nestedAtomically_closure","-u","base_GHCziWeak_runFinalizzerBatch_closure","-u","base_GHCziTopHandler_runIO_closure","-u","base_GHCziTopHandler_runNonIO_closure","-u","base_GHCziConc_runHandlers_closure","-u","base_GHCziConc_ensureIOManagerIsRunning_closure"], frameworkDirs = [], frameworks = [], haddockInterfaces = [], haddockHTMLs = []}]),(PackageName "syb",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "syb", pkgVersion = Version {versionBranch = [0,1,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package contains the generics system described in the\n/Scrap Your Boilerplate/ papers (see ).\nIt defines the @Data@ class of types permitting folding and unfolding\nof constructor applications, instances of this class for primitive\ntypes, and a variety of traversals.", category = "", exposed = True, exposedModules = [ModuleName ["Data","Generics"],ModuleName ["Data","Generics","Aliases"],ModuleName ["Data","Generics","Basics"],ModuleName ["Data","Generics","Instances"],ModuleName ["Data","Generics","Schemes"],ModuleName ["Data","Generics","Text"],ModuleName ["Data","Generics","Twins"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/syb-0.1.0.1"], libraryDirs = ["/usr/lib/ghc-6.10.4/syb-0.1.0.1"], hsLibraries = ["HSsyb-0.1.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/syb/syb.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/syb"]}]),(PackageName "unix",[InstalledPackageInfo {package = PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,3,2,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", description = "This package gives you access to the set of operating system\nservices standardised by POSIX 1003.1b (or the IEEE Portable\nOperating System Interface for Computing Environments -\nIEEE Std. 1003.1).\n\nThe package is not supported under Windows (except under Cygwin).", category = "System", exposed = True, exposedModules = [ModuleName ["System","Posix"],ModuleName ["System","Posix","DynamicLinker","Module"],ModuleName ["System","Posix","DynamicLinker","Prim"],ModuleName ["System","Posix","Directory"],ModuleName ["System","Posix","DynamicLinker"],ModuleName ["System","Posix","Env"],ModuleName ["System","Posix","Error"],ModuleName ["System","Posix","Files"],ModuleName ["System","Posix","IO"],ModuleName ["System","Posix","Process"],ModuleName ["System","Posix","Process","Internals"],ModuleName ["System","Posix","Resource"],ModuleName ["System","Posix","Temp"],ModuleName ["System","Posix","Terminal"],ModuleName ["System","Posix","Time"],ModuleName ["System","Posix","Unistd"],ModuleName ["System","Posix","User"],ModuleName ["System","Posix","Signals"],ModuleName ["System","Posix","Signals","Exts"],ModuleName ["System","Posix","Semaphore"],ModuleName ["System","Posix","SharedMem"]], hiddenModules = [], importDirs = ["/usr/lib/ghc-6.10.4/unix-2.3.2.0"], libraryDirs = ["/usr/lib/ghc-6.10.4/unix-2.3.2.0"], hsLibraries = ["HSunix-2.3.2.0"], extraLibraries = ["rt","util","dl"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc-6.10.4/unix-2.3.2.0/include"], includes = ["HsUnix.h","execvpe.h"], depends = [PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,1,0,0], versionTags = []}}], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/share/doc/ghc6-doc/libraries/unix/unix.haddock"], haddockHTMLs = ["/usr/share/doc/ghc6-doc/libraries/unix"]}])]), pkgDescrFile = Just "./hs2svn.cabal", localPkgDescr = PackageDescription {package = PackageIdentifier {pkgName = PackageName "hs2svn", pkgVersion = Version {versionBranch = [0,1], versionTags = []}}, license = GPL, licenseFile = "", copyright = "Andrew U Frank, TU Wien", maintainer = "Andrew U Frank", author = "Andrew U Frank", stability = "experimental", testedWith = [], homepage = "", pkgUrl = "", bugReports = "frank@geoinfo.tuwien.ac.at", sourceRepos = [], synopsis = "a simple way to use svn from a haskell program", description = "System.Process is used to send commands to svn and analyzes the returned messages (partially).\nonly the routines which were needed for a project, but could be completed following the examples given.\nerror handling should be improved.\n\nworks with 6.10", category = "development", customFieldsPD = [], buildDepends = [Dependency (PackageName "base") (IntersectVersionRanges AnyVersion AnyVersion),Dependency (PackageName "filepath") (IntersectVersionRanges AnyVersion AnyVersion),Dependency (PackageName "haskell98") (IntersectVersionRanges AnyVersion AnyVersion),Dependency (PackageName "process") (IntersectVersionRanges AnyVersion AnyVersion)], descCabalVersion = AnyVersion, buildType = Just Simple, library = Just (Library {exposedModules = [ModuleName ["SVN","Hs2svn"]], libExposed = True, libBuildInfo = BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = ["."], otherModules = [], extensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,[]),(Hugs,[]),(NHC,[]),(JHC,[])], ghcProfOptions = [], ghcSharedOptions = [], customFieldsBI = []}}), executables = [Executable {exeName = "Test", modulePath = "Hs2svnTest.hs", buildInfo = BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = ["."], otherModules = [], extensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,[]),(Hugs,[]),(NHC,[]),(JHC,[])], ghcProfOptions = [], ghcSharedOptions = [], customFieldsBI = []}}], dataFiles = [], dataDir = "", extraSrcFiles = [], extraTmpFiles = []}, withPrograms = [("ar",ConfiguredProgram {programId = "ar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ar"}}),("gcc",ConfiguredProgram {programId = "gcc", programVersion = Just (Version {versionBranch = [4,4,1], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/gcc"}}),("ghc",ConfiguredProgram {programId = "ghc", programVersion = Just (Version {versionBranch = [6,10,4], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ghc"}}),("ghc-pkg",ConfiguredProgram {programId = "ghc-pkg", programVersion = Just (Version {versionBranch = [6,10,4], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ghc-pkg"}}),("haddock",ConfiguredProgram {programId = "haddock", programVersion = Just (Version {versionBranch = [2,4,2], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/haddock"}}),("hsc2hs",ConfiguredProgram {programId = "hsc2hs", programVersion = Just (Version {versionBranch = [0,67], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/hsc2hs"}}),("ld",ConfiguredProgram {programId = "ld", programVersion = Nothing, programArgs = ["-x"], programLocation = FoundOnSystem {locationPath = "/usr/bin/ld"}}),("pkg-config",ConfiguredProgram {programId = "pkg-config", programVersion = Just (Version {versionBranch = [0,22], versionTags = []}), programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/pkg-config"}}),("ranlib",ConfiguredProgram {programId = "ranlib", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ranlib"}}),("strip",ConfiguredProgram {programId = "strip", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/strip"}}),("tar",ConfiguredProgram {programId = "tar", programVersion = Nothing, programArgs = [], programLocation = FoundOnSystem {locationPath = "/bin/tar"}})], withPackageDB = GlobalPackageDB, withVanillaLib = True, withProfLib = False, withSharedLib = False, withProfExe = False, withOptimization = NormalOptimisation, withGHCiLib = True, splitObjs = False, stripExes = True, progPrefix = "", progSuffix = ""} From lrpalmer at gmail.com Thu Oct 8 16:14:46 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Oct 8 15:52:19 2009 Subject: [Haskell-cafe] Re: Generalizing IO In-Reply-To: <4ACE408D.7000405@btinternet.com> References: <49a77b7a0910051723g390f1e9ld447deb4d86ca6f4@mail.gmail.com> <4ACE408D.7000405@btinternet.com> Message-ID: <7ca3f0160910081314r7ed79a21o89dc27d9cf33d416@mail.gmail.com> On Thu, Oct 8, 2009 at 1:42 PM, Andrew Coppin wrote: > Heinrich Apfelmus wrote: >> >> Alternatively, you can use algebraic data types instead of type classes >> to generalize one program to different implementations. For monads, this >> can be achieved with >> >> ? ? http://hackage.haskell.org/package/MonadPrompt >> >> In particular, the idea is to turn every effect like >> >> ?getLine >> >> into a constructor >> >> ?GetLine >> >> and have different implementations pattern match on that. >> > > Ooo, that's interesting... > > I did wonder for a moment whether this would allow you to analyse what the > monadic action does without actually "doing" it, but on reflection this is > fundamentally impossible. The action that happens next can (and often does) > depend on the result of a previous effect. > > I guess if you wanted to run your action through an optimiser before > actually running it, you'd need to use arrows (and all the terrifying syntax > that entails)... Or Applicatives, or some other action algebra which is appropriate for the kind of actions you are trying to encode. Don't fool yourself into thinking that Monads and Arrows are all there are; those are just two formalisms for which we have discovered a lot of uses. But if what you're trying to encode doesn't match those, then don't use them. If you want to encode actions that can be optimized before usage, expose just enough so you can find the information you need to optimize it. Luke From nowgate at yahoo.com Thu Oct 8 16:15:55 2009 From: nowgate at yahoo.com (michael rice) Date: Thu Oct 8 15:53:29 2009 Subject: [Haskell-cafe] New seed. New random number. Right? Wrong. Message-ID: <847785.6264.qm@web31101.mail.mud.yahoo.com> I'm entering a new number to make a different seed for my generator each time through the loop, but my resulting numbers are anything but random. Where am I going wrong? Michael ============================= import System.Random import Control.Monad(when) main = do ? numberString <- getLine ? when (not $ null numberString) $ do ??? let seed = read numberString ??? let (randNumber, newGen) = randomR (1,6) (mkStdGen seed) :: (Int, StdGen) ????? in putStrLn $ "Number is " ++ show randNumber ??? main ? ============================= [michael@localhost ~]$ runhaskell zz.hs 12317 Number is 6 12371 Number is 6 37829 Number is 6 8713 Number is 6 71392 Number is 5 29492 Number is 6 41089 Number is 6 28483 Number is 6 78687 Number is 5 40703 Number is 6 86910 Number is 5 15608 Number is 6 56155 Number is 5 31575 Number is 6 72231 Number is 5 51815 Number is 6 20189 Number is 6 71533 Number is 5 17755 Number is 6 91161 Number is 5 [michael@localhost ~]$ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/e03a25bc/attachment.html From andy at adradh.org.uk Thu Oct 8 16:22:15 2009 From: andy at adradh.org.uk (andy morris) Date: Thu Oct 8 16:00:05 2009 Subject: [Haskell-cafe] difference "cabal configure" and "runghc Setup.lhs configure" In-Reply-To: <200910082208.48803.frank@geoinfo.tuwien.ac.at> References: <200910082208.48803.frank@geoinfo.tuwien.ac.at> Message-ID: 2009/10/8 Andrew U. Frank : > i have a strange error, which does not occur when i run > runghc Setup.lhs configure > but when i use cabal configure and then build, it occurs. > > the error is > Type constructor Control.Exception.Exception used as a class > in the instance declaration. > (i have imported qualified Control.Exception) > > two questions: > 1. Exception is a class (in Control.Exception) - why the error? > 2. why is there a difference between runghc and cabal (using the same cabal > file). > > i attach the cabal file and the two configuratin files produced. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > C.E.Exception used to be a type instead of a class, so you need to have `base == 4.*` instead of `base -any`. Alternatively, use the extensible-extensions package instead. The difference in results you found is because cabal-install uses base-3 if you don't specify otherwise. The reason for this is that a lot of packages use `base -any` when they shouldn't: base-4 brought enough incompatible changes (like making Exception a class) that they don't work with it. (This is also, I assume, why GHC has two built-in versions of base in the first place.) From bugfact at gmail.com Thu Oct 8 16:29:21 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Oct 8 16:06:51 2009 Subject: [Haskell-cafe] New seed. New random number. Right? Wrong. In-Reply-To: <847785.6264.qm@web31101.mail.mud.yahoo.com> References: <847785.6264.qm@web31101.mail.mud.yahoo.com> Message-ID: interesting. the sequences you get are random, but unless you enter a new number that is really far from the previous one, the probability of getting the same first random number seems high. import System.Random import Control.Monad(when) main = do numberString <- getLine when (not $ null numberString) $ do let seed = read numberString let randNumbers = take 10 . randomRs (1::Int,6) $ mkStdGen seed in putStrLn $ "Numbers are " ++ show randNumbers main 1 Numbers are [6,5,2,6,5,2,3,2,5,5] 1000 Numbers are [6,4,3,2,6,5,2,3,3,5] 1000000 Numbers are [6,4,3,6,5,5,3,4,6,4] 1000000000 Numbers are [4,1,3,4,6,1,2,4,1,6] 1000000000000 Numbers are [1,2,3,3,5,5,4,6,6,4] 1000000000000000 Numbers are [1,4,2,6,6,2,4,2,6,5] On Thu, Oct 8, 2009 at 10:15 PM, michael rice wrote: > I'm entering a new number to make a different seed for my generator each > time through the loop, but my resulting numbers are anything but random. > > Where am I going wrong? > > Michael > > ============================= > > import System.Random > import Control.Monad(when) > > main = do > numberString <- getLine > when (not $ null numberString) $ do > let seed = read numberString > let (randNumber, newGen) = randomR (1,6) (mkStdGen seed) :: (Int, > StdGen) > in putStrLn $ "Number is " ++ show randNumber > main > > ============================= > > [michael@localhost ~]$ runhaskell zz.hs > 12317 > Number is 6 > 12371 > Number is 6 > 37829 > Number is 6 > 8713 > Number is 6 > 71392 > Number is 5 > 29492 > Number is 6 > 41089 > Number is 6 > 28483 > Number is 6 > 78687 > Number is 5 > 40703 > Number is 6 > 86910 > Number is 5 > 15608 > Number is 6 > 56155 > Number is 5 > 31575 > Number is 6 > 72231 > Number is 5 > 51815 > Number is 6 > 20189 > Number is 6 > 71533 > Number is 5 > 17755 > Number is 6 > 91161 > Number is 5 > > [michael@localhost ~]$ > > > > _______________________________________________ > 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/20091008/8a902937/attachment.html From simon at joyful.com Thu Oct 8 17:05:04 2009 From: simon at joyful.com (Simon Michael) Date: Thu Oct 8 16:45:26 2009 Subject: [Haskell-cafe] Re: Any example of concurrent haskell application? In-Reply-To: References: Message-ID: rss2irc is a small app using two communicating threads, and that much works well. The error handling may be quite ideal. From bugfact at gmail.com Thu Oct 8 17:13:42 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Oct 8 16:51:13 2009 Subject: [Haskell-cafe] Hugs Trex for GHC / JHC / UHC / ... ? Message-ID: I briefly read about Hugs record system Trex, and at first sight this was really nice! I know this question was asked a long time ago already, but are there any plans to add this extension to GHC? What about the other compilers, like JHC, UHC, etc? Is it possible to emulate Trex (lots of other record systems exist), *and* get the same easy to understand errors? What were the problems with Trex (if any)? Thanks, Peter Verswyvelen From bos at serpentine.com Thu Oct 8 17:40:02 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Oct 8 17:17:33 2009 Subject: [Haskell-cafe] New seed. New random number. Right? Wrong. In-Reply-To: <847785.6264.qm@web31101.mail.mud.yahoo.com> References: <847785.6264.qm@web31101.mail.mud.yahoo.com> Message-ID: On Thu, Oct 8, 2009 at 1:15 PM, michael rice wrote: > > Where am I going wrong? > Your seeds are all extremely close together. The System.Random PRNG takes a 32-bit seed, but your seeds haven't even got a 17-bit range, so you're supplying approximately 19 parts per million of the possible range of entropy. Evidently this PRNG doesn't fare well with such a small amount of entropy. Try providing a broader range of seeds, and you'll see better results, e.g. 877554827 3377950428 3850407650 688135636 1134078904 973676998 3178940608 840705211 185598244 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/a505ac20/attachment.html From tobias_bexelius at hotmail.com Thu Oct 8 17:49:14 2009 From: tobias_bexelius at hotmail.com (Tobias Bexelius) Date: Thu Oct 8 17:26:45 2009 Subject: [Haskell-cafe] GPipe example and screenshot Message-ID: I've put a simple GPipe example (including a screenshot) on the haskellwiki now, showing off an animated spinning box. You'll find the page here: http://www.haskell.org/haskellwiki/GPipe Later on, I will add more examples, and also some kind of GPipe-tutorial. Hang in there... Cheers Tobias Bexelius _________________________________________________________________ Windows Live: G?r det enklare f?r dina v?nner att se vad du h?ller p? med p? Facebook. http://www.microsoft.com/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:sv-se:SI_SB_2:092009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091008/48dda10c/attachment.html From jake.mcarthur at gmail.com Thu Oct 8 18:53:48 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Thu Oct 8 18:31:15 2009 Subject: [Haskell-cafe] GPipe example and screenshot In-Reply-To: References: Message-ID: <4ACE6D7C.8090201@gmail.com> Tobias Bexelius wrote: > I've put a simple GPipe example (including a screenshot) on the > haskellwiki now, showing off an animated spinning box. Nice to see Data.Vec.LinAlg.Transform3D! That will be a big help. I'm having fun with GPipe. Thanks for the library! - Jake From bos at serpentine.com Fri Oct 9 03:11:16 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Oct 9 02:48:46 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library Message-ID: Get it while it's fresh on Hackage, folks! Details of the changes here: http://bit.ly/1u4UOT -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/60cf92f0/attachment.html From martijn at van.steenbergen.nl Fri Oct 9 03:56:00 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 9 03:33:33 2009 Subject: [Haskell-cafe] Any example of concurrent haskell application? In-Reply-To: References: Message-ID: <4ACEEC90.2030001@van.steenbergen.nl> Daryoush Mehrtash wrote: > I am trying to learn more about concurrent applications in Haskell by > studying an existing a real application source code. I would very much > appreciate if you can recommend an application that you feel has done a > good job in implementing a real time application in Haskell. Yogurt[1], a MUD client, uses two threads: one to process input from the server and one to process input from the client. It uses an MVar to synchronize. All concurrency is located in module Network.Yogurt.Readline. Custard[2], a MUD server, uses several threads: * Server, maintaining MUD state * one that listens for incoming connections * per client, one that listens for client input * per client, one that listens for messages from Server It uses channels and message passing to synchronize. All concurrency is located in module Engine. [1] http://hackage.haskell.org/package/Yogurt [2] http://code.google.com/p/custard/ Hope this helps, Martijn. From DekuDekuplex at Yahoo.com Fri Oct 9 04:46:15 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Oct 9 04:24:16 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News References: <4ac77fe1.9753f10a.4fc4.1044@mx.google.com> Message-ID: <3ittc5d5db5j15ela5lh1e973dri0bmvpf@4ax.com> Thank you for including my quote (by "dekudekuplex"), and great work so far! Just a couple of minor comments: 1) It might be useful for referencing by subject if you could include the issue number and date in the subject line (e.g., " Haskell Weekly News: Issue 131 - September 25, 2009") instead of only "Haskell Weekly News." 2) Instead of posting separately to the Haskell and Haskell-Cafe mailing lists, it might be better to cross-post, since that way, readers using newsreaders can have the cross-posted article automatically marked "read" in the mailing list where it has not been read. Other than that, hope that you get over your sinus infection, and keep up the good work! Benjamin L. Russell On Sat, 03 Oct 2009 09:46:25 -0700 (PDT), Joe Fredette wrote: > >--------------------------------------------------------------------------- >Haskell Weekly News >http://sequence.complete.org/hwn/20091003 >Issue 134 - October 03, 2009 >--------------------------------------------------------------------------- > Welcome to issue 134 of HWN, a newsletter covering developments in the > [1]Haskell community. > > I have a nasty sinus infection this week, so we're somewhat light on > content. Lots of good discussion about DSL related stuff this week. > Bryan O'Sullivan also release 'Criterion' this week, a new benchmarking > library that Don Stewart described (on reddit) as 'awesome and game > changing.' A new TMR editor -- someone familiar -- was announced. Also, > there was some talk about homework policies on the mailinglists and in > the irc channels. There is a [2]page on the Haskell wiki about this, > but to sum it up in a maxim, remember, 'Help, don't do'. Until next > week, the Haskell Weekly News! > >Announcements > > New TMR editor. Wouter Swierstra [3]announced that he would be stepping > down from the editorship of 'The Monad Reader', with former HWN editor > Brent Yorgey taking his place. Much thanks for Wouter's hard work and > good luck to Brent on his new editor job! > > SourceGraph 0.5.{0,1,2}.0. Ivan Lazar Miljenovic [4]announced three new > releases of the SourceGraph packages, this links to the latest release. > > json-b-0.0.4. Jason Dusek [5]announced a new version of the json-b > package, which fixes defective handling of empty objects and arrays. > > rss2irc 0.4 released. Simon Michael [6]announced a new release of > rss2irc, with many new improvements and features. > > vty-ui 0.1. Jonathan Daugherty [7]announced vty-ui, which is an > extensible library of user interface widgets for composing and laying > out Vty user interfaces. > > atom-0.1.1. Tom Hawkins [8]announced Atom, a Haskell DSL for designing > hard real-time embedded applications. > > Graphalyze-0.7.0.0. Ivan Lazar Miljenovic [9]announced (in an apparent > effort to take over hackage by submitting dozens of quality packages at > absurdly high speed), Graphalyze, a library for using graph-theoretic > techniques to analyse the relationships inherent within discrete data. > > Criterion. Bryan O'Sullivan [10]announced (without tacking on an 'ANN' > tag, I might add, I almost missed it!) Criterion, a benchmarking > library he describes [11]here. > > ListTree 0.1. yairchu@gmail.com [12]announced ListTree, a package for > combinatorial search and pruning of trees. > > usb-0.1. Bas van Dijk [13]announced a library for interacting with usb > modules from userspace. > > (Deadline extended to October 5th) APLAS 2009 Call for Posters. > Kiminori Matsuzaki [14]announced a deadline extension to the call for > posters for the APLAS conference. > > graphviz-2999.6.0.0. Ivan Lazar Miljenovic [15]announced a new version > of the graphviz library, which features various new features and small > changes. > >Discussion > > Testing polymorphic properties with QuickCheck. Jean-Philippe Bernardy > [16]gave an excellent overview about how to use QuickCheck to test > polymorphic properties. > > Designing a DSL? Gunther Schmidt [17]asked about different methods > employed for designing a DSL. > > DSL and GUI Toolkits. Gunther Schmidt [18]also asked about different > DSLs for working with GUIs > > error on "--++ bla bla bla". Hong Yang [19]asked about why '--++' > wasn't being parsed in the way he thought it was. > > Haskell for Physicists. edgar [20]requested name suggestions for the > talk he is giving about Physics and Haskell. > >Blog noise > > [21]Haskell news from the [22]blogosphere. Blog posts from people new > to the Haskell community are marked with >>>, be sure to welcome them! > * Sean Leather: [23]'Extensibility and type safety in formatting: the > design of xformat' at the Dutch HUG. > * Martijn van Steenbergen: [24]let 5 = 6. > * Lee Pike: [25]Writer's unblock. > * Manuel M T Chakravarty: [26]NVIDIAs next generation GPU > architecture has a lot for HPC to love. > * David Amos: [27]Finite geometries, part 4: Lines in PG(n,Fq). > * Bryan O'Sullivan: [28]New criterion release works on Macs. > * Neil Brown: [29]Poison: Concurrent Termination. > * The GHC Team: [30]Heads up: what you need to know about Unicode I/O > in GHC 6.12.1. > * Galois, Inc: [31]Tech Talk: Roll Your Own Test Bed for Embedded > Real-Time Protocols: A Haskell Experience. > * Bryan O'Sullivan: [32]Criterion, a new benchmarking library for > Haskell. > * Tom Schrijvers: [33]Monadic Constraint Programming. > * Neil Brown: [34]Growing Sort Pump. > >Quotes of the Week > > * dekudekuplex: (Unfortunately (unless intentional)) the preceding > (by ksf (in the 'Quotes of the Week' section)) quote had mismatched > (one too many opening) parentheses (although it was still funny > (even though it could have been edited (to make the parentheses > match (even though that is not an important issue)))). > * pozic: I think if you want to contact dons, you have to say that > you found a bug in ByteString. > * Veinor: [about dibblego kicking a whole bunch of spammers] > crouching dibblego, hidden op > * allbery_b: [on UndecidableInstances] 'this exceeds my easy > threshold, turn on wizard mode' (at which point it becomes a lot > smarter but may start contemplating its navel without warning) > * byorgey: a bus error? try recompiling with -fsubway, perhaps > * jafet: 'Zygomorphism' sounds like a reproductive disorder > >About the Haskell Weekly News > > New editions are posted to [35]the Haskell mailing list as well as to > [36]the Haskell Sequence and [37]Planet Haskell. [38]RSS is also > available, and headlines appear on [39]haskell.org. > > To help create new editions of this newsletter, please see the > information on [40]how to contribute. Send stories to jfredett . at . > gmail . dot . com. The darcs repository is available at darcs get > [41]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . > >References > > 1. http://haskell.org/ > 2. http://www.haskell.org/haskellwiki/Homework_help > 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64213 > 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64259 > 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64254 > 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63838 > 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64070 > 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64035 > 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63989 > 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63985 > 11. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ > 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63853 > 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64206 > 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17529 > 15. http://article.gmane.org/gmane.comp.lang.haskell.general/17520 > 16. http://thread.gmane.org/gmane.comp.lang.haskell.general/17535 > 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64267 > 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64244 > 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64161 > 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64128 > 21. http://planet.haskell.org/ > 22. http://haskell.org/haskellwiki/Blog_articles > 23. http://feedproxy.google.com/~r/splonderzoek/~3/BHqNHIZFF7U/extensibility-and-type-safety-in.html > 24. http://martijn.van.steenbergen.nl/journal/2009/10/02/let-5-6/ > 25. http://leepike.wordpress.com/2009/09/30/writers-unblock/ > 26. http://justtesting.org/post/201508784 > 27. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-4-lines-in-pgnfq.html > 28. http://www.serpentine.com/blog/2009/09/30/new-criterion-release-works-on-macs/ > 29. http://chplib.wordpress.com/2009/09/30/poison-concurrent-termination/ > 30. http://ghcmutterings.wordpress.com/2009/09/30/heads-up-what-you-need-to-know-about-unicode-io-in-ghc-6-12-1/ > 31. http://www.galois.com/blog/2009/09/29/pike-haskell0/ > 32. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ > 33. http://tomschrijvers.blogspot.com/2009/01/monadic-constraint-programming.html > 34. http://chplib.wordpress.com/2009/09/28/growing-sort-pump/ > 35. http://www.haskell.org/mailman/listinfo/haskell > 36. http://sequence.complete.org/ > 37. http://planet.haskell.org/ > 38. http://sequence.complete.org/node/feed > 39. http://haskell.org/ > 40. http://haskell.org/haskellwiki/HWN > 41. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From apfelmus at quantentunnel.de Fri Oct 9 06:53:58 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Oct 9 06:31:54 2009 Subject: [Haskell-cafe] Re: Any example of concurrent haskell application? In-Reply-To: References: Message-ID: Daryoush Mehrtash wrote: > I am trying to learn more about concurrent applications in Haskell by > studying an existing a real application source code. I would very much > appreciate if you can recommend an application that you feel has done a good > job in implementing a real time application in Haskell. It doesn't really use much concurrency, but the web server implementation detailed in Simon Marlow. Writing High-Performance Server Applications in Haskell Case Study: A Haskell Web Server http://www.haskell.org/~simonmar/papers/web-server.ps.gz is a simple and well documented example. Regards, apfelmus -- http://apfelmus.nfshost.com From wren at freegeek.org Fri Oct 9 06:58:33 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Oct 9 06:36:05 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> Message-ID: <4ACF1759.2010300@freegeek.org> Cristiano Paris wrote: > On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote: >> The reason a gets a single type is the monomorphism restriction (read >> the report). >> Using NoMonomorphismRestriction your example with a works fine. > > Could you explain why, under NoMonomorphismRestriction, this typechecks: > > let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > > while this not: > > foo :: Num a => a -> (Int,Float) > foo k = (k + (1 :: Int), k + (1.0 :: Float)) Because lambda-binding is always[1] monomorphic, whereas let-binding can be polymorphic. This distinction is the reason for introducing let-binding in the first place. If let-bindings weren't allowed to be polymorphic (or if lambda-bindings were allowed to be) then we could desugar "let x = e in f" into "(\x -> f) $ e" and simplify the core language.[2] Milner's original paper[3] on the topic is still a good introduction to the field. He couldn't take advantage of subsequent work, so his notation is a bit outdated (though still understandable). If you're familiar with the details behind System F, etc. then you should be able to massage the paper into more modern notation in order to discuss issues like where and how Rank-2 polymorphism fits in. [1] That is, under the Hindley--Milner type system. If we add Rank-2 (or Rank-N) polymorphism then lambdas can bind polymorphic values. [2] There's a wrinkle with simplifying the core here. Let-binding is often introduced in tandem with a special form for declaring recursive values and mutually recursive groups. Usually this form is simplified somewhat as in ML's "let rec" or Haskell's invisible laziness recursion. If we remove "let" then we'll want to use the general version of "rec" and will need to be explicit about it. [3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276 -- Live well, ~wren From vandijk.roel at gmail.com Fri Oct 9 07:50:42 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Fri Oct 9 07:28:11 2009 Subject: [Haskell-cafe] ANNOUNCE: htzaar-0.0.1 In-Reply-To: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> References: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> Message-ID: On Thu, Oct 8, 2009 at 12:56 AM, Tom Hawkins wrote: > Known bugs: Occasionally HTZAAR throws a Prelude.head: empty list. > I'm still trying to track this down. I used the following function to track down a similar problem: myhead :: String -> [a] -> a myhead msg [] = error msg myhead _ (x:_) = x Then you can replace your calls to head with myhead "bla". This way it is faster to pin-point which head is applied to an empty list. From leather at cs.uu.nl Fri Oct 9 08:11:02 2009 From: leather at cs.uu.nl (Sean Leather) Date: Fri Oct 9 07:48:51 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: <87iqeqt0kw.fsf@gregorycollins.net> References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> Message-ID: <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> On Thu, Oct 8, 2009 at 16:35, Gregory Collins wrote: > Sean Leather writes: > > > We have run into an issue that it seems other people have already > > found but has apparently not been resolved, yet. It manifests as with > > the error "HTTP request failed with: Unsupported socket". The problem > > is described in two places with different workarounds. > > > > http://code.google.com/p/happstack/issues/detail?id=88 > > http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 > > > > One workaround is to rewrite part of the network package, and the > > other is to downgrade the package. It could be the case that the > > rewrite came from the older version, though I'm not sure. > > > > I'm curious if it is possible to fix this, either in Happstack or the > > network package, once and for all. The workarounds are rather painful > > when so many things depend on the network package. > > The following patch to happstack works for me: > This worked for us as well. Thanks, Gregory. Do you know if it's possible to permanently patch happstack-server? I'm guessing the TH in the patch is used to support multiple versions of the network package. Can we just change the minimum supported version? Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/ec59bad9/attachment.html From noteed at gmail.com Fri Oct 9 08:58:44 2009 From: noteed at gmail.com (minh thu) Date: Fri Oct 9 08:36:32 2009 Subject: [Haskell-cafe] type inference question In-Reply-To: <4ACF1759.2010300@freegeek.org> References: <40a414c20910080204r3b0e30f6va94747b02012ba50@mail.gmail.com> <4ACF1759.2010300@freegeek.org> Message-ID: <40a414c20910090558x7bd8c446wf33e1d073159c37d@mail.gmail.com> 2009/10/9 wren ng thornton : > Cristiano Paris wrote: >> >> On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote: >>> >>> The reason a gets a single type is the monomorphism restriction (read >>> the report). >>> Using NoMonomorphismRestriction your example with a works fine. >> >> Could you explain why, under NoMonomorphismRestriction, this typechecks: >> >> let a = 1 in (a + (1 :: Int),a + (1 :: Float)) >> >> while this not: >> >> foo :: Num a => a -> (Int,Float) >> foo k = (k + (1 :: Int), k + (1.0 :: Float)) > > > Because lambda-binding is always[1] monomorphic, whereas let-binding can be > polymorphic. This distinction is the reason for introducing let-binding in > the first place. If let-bindings weren't allowed to be polymorphic (or if > lambda-bindings were allowed to be) then we could desugar "let x = e in f" > into "(\x -> f) $ e" and simplify the core language.[2] As it turns out, section 31.6 Why Let and not Lambda of PLAI [*] explains why lambda-bindings are treated monomorphically. [*] http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/ > Milner's original paper[3] on the topic is still a good introduction to the > field. He couldn't take advantage of subsequent work, so his notation is a > bit outdated (though still understandable). If you're familiar with the > details behind System F, etc. then you should be able to massage the paper > into more modern notation in order to discuss issues like where and how > Rank-2 polymorphism fits in. > > > > [1] That is, under the Hindley--Milner type system. If we add Rank-2 (or > Rank-N) polymorphism then lambdas can bind polymorphic values. > > [2] There's a wrinkle with simplifying the core here. Let-binding is often > introduced in tandem with a special form for declaring recursive values and > mutually recursive groups. Usually this form is simplified somewhat as in > ML's "let rec" or Haskell's invisible laziness recursion. If we remove "let" > then we'll want to use the general version of "rec" and will need to be > explicit about it. > > [3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276 > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jao at gnu.org Fri Oct 9 08:24:49 2009 From: jao at gnu.org (Jose A. Ortega Ruiz) Date: Fri Oct 9 08:45:59 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1 References: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> Message-ID: <878wfk3gby.fsf@mithrandir.homeunix.net> Hi, When i try to cabal install htzaar i get the following error: src/Main.hs:11:7: Could not find module `Play': Use -v to see a list of the files searched for. cabal: Error: some packages failed to install: htzaar-0.0.1 failed during the building phase. The exception was: exit: ExitFailure 1 Any idea about what's going on? Thanks! jao -- Editing is a rewording activity. - Alan Perlis, Epigrams in Programing From Patrick.Browne at comp.dit.ie Fri Oct 9 09:11:30 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Fri Oct 9 08:50:32 2009 Subject: [Haskell-cafe] Approaches to dependent types (DT) Message-ID: <4ACF3682.80000@comp.dit.ie> Hi, I am trying to understand the concept of dependent types as described in Haskell literature (Hallgren 2001),(Hinze,Jeuring et al. 2006). I am particularly interested in understanding two flavours of dependency mentioned by Hinze et al: 1) Types depending on values called dependent types 2) Types depending on types called parametric and type-indexed types I think that ascending levels of abstraction are important here: values - types - classes (Hallgren 2001). Here is a Haskell example of the use of DT: class Named object name | object -> name where name :: object -> name instance (Eq name, Named object name) => Eq object where object1 == object2 = (name object1) == (name object2) I think that the intended semantics are: 1) Objects have names and can be compared for equality using these names. 2) Two objects are considered equal (identical) if they have the same name. 3) The type of a name depends on the type of the object, which gets expressed as a type dependency (object -> name). I am not sure about the last semantic it might be interpreted as "the named object depends on..". This may indicate a flaw in my understanding of DT. I am aware that dependent types can be used to express constraints on the size of lists and other collections. My understanding of Haskell's functional dependency is that object -> name indicates that fixing the type object should fix the type name (equivalently we could say that type name depends on type object). The class definition seems to show a *type-to-type* dependency (object to name), while the instance definition shows how a name value is used to define equality for objects which could be interpreted as a *value-to-type* dependency (name to object) in the opposite direction to that of the class. My questions are: Question 1: Is my understanding correct? Question 2: What flavour of DT is this does this example exhibit? Best regards, Pat Hallgren, T. (2001). Fun with Functional Dependencies. In the Proceedings of the Joint CS/CE Winter Meeting, Varberg, Sweden, January 2001. Hinze, R., J. Jeuring, et al. (2006). Comparing Approaches to Generic Programming in Haskell. Datatype-generic programming: international spring school, SSDGP 2006. From duncan.coutts at googlemail.com Fri Oct 9 09:18:58 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Oct 9 09:03:48 2009 Subject: [Haskell-cafe] Can HXT and Parsec 3 be used in the same library? In-Reply-To: <4AC8DC22.3030708@gmail.com> References: <4AC8DC22.3030708@gmail.com> Message-ID: <1255094338.28525.6742.camel@localhost> On Sun, 2009-10-04 at 10:32 -0700, John Millikin wrote: > I'm writing a library that needs to parse both plain text (with Parsec) > and XML (with HXT). HXT's .cabal file specifies that it only works with > parsec (>= 2.1 && < 3), but it still builds when I depend on parsec >= > 3. It's only during "cabal install" that the following error is displayed: > > - -------------------------------------------- > Resolving dependencies... > cabal-1.7.3: cannot configure hxt-8.3.1. It requires parsec >=2.1 && <3 > For the dependency on parsec >=2.1 && <3 there are these packages: > parsec-2.1.0.0 and parsec-2.1.0.1. However none of them are available. > parsec-2.1.0.0 was excluded because dbus-core-0.5 requires parsec >=3.0.0 > parsec-2.1.0.1 was excluded because dbus-core-0.5 requires parsec >=3.0.0 > - -------------------------------------------- > > Is there a good solution to this? Not really. Not at the moment. We have this restriction because of the dreaded diamond dependency problem: http://blog.well-typed.com/2008/04/the-dreaded-diamond-dependency-problem/ It's likely that this problem would not actually occur in your example because presumably HXT does not re-export types from the parsec package. However cabal does not have enough information to know that it does not, so it takes the conservative view. We could do rather better if we could declare private or public dependencies. The point with private ones being that you'd not be allowed to use types from the private package in your public API. In your example parsec would probably be a private dependency of HXT and thus we would not care what version of parsec it was using, it couldn't cause any problems. > I was thinking about changing my library to use Parsec 2, but that > just pushes the problem to my users, it doesn't really solve it. Right. Duncan From alexey.skladnoy at gmail.com Fri Oct 9 07:38:51 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Fri Oct 9 09:17:46 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1 In-Reply-To: <878wfk3gby.fsf@mithrandir.homeunix.net> References: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> <878wfk3gby.fsf@mithrandir.homeunix.net> Message-ID: <200910091538.51840.alexey.skladnoy@gmail.com> ? ????????? ?? 09 ??????? 2009 16:24:49 Jose A. Ortega Ruiz ???????: > Hi, > > When i try to cabal install htzaar i get the following error: > > src/Main.hs:11:7: > Could not find module `Play': > Use -v to see a list of the files searched for. > cabal: Error: some packages failed to install: > htzaar-0.0.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Any idea about what's going on? > Modules AI, Play and Board are missing I believe From tomahawkins at gmail.com Fri Oct 9 10:23:08 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Fri Oct 9 10:00:37 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1 In-Reply-To: <878wfk3gby.fsf@mithrandir.homeunix.net> References: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> <878wfk3gby.fsf@mithrandir.homeunix.net> Message-ID: <594c1e830910090723u6492b73ai99e2764b9b137f8a@mail.gmail.com> On Fri, Oct 9, 2009 at 2:24 PM, Jose A. Ortega Ruiz wrote: > > Hi, > > When i try to cabal install htzaar i get the following error: > > src/Main.hs:11:7: > ? ?Could not find module `Play': > ? ? ?Use -v to see a list of the files searched for. > cabal: Error: some packages failed to install: > htzaar-0.0.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Any idea about what's going on? Sorry, I forgot to add the other modules to the cabal file. Try htzaar-0.0.2. From greg at gregorycollins.net Fri Oct 9 10:25:22 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Fri Oct 9 10:02:49 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> (Sean Leather's message of "Fri, 9 Oct 2009 14:11:02 +0200") References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> Message-ID: <87skdsfxv1.fsf@gregorycollins.net> Sean Leather writes: > On Thu, Oct 8, 2009 at 16:35, Gregory Collins wrote: > > Sean Leather writes: > > > We have run into an issue that it seems other people have already > > found but has apparently not been resolved, yet. It manifests as with > > the error "HTTP request failed with: Unsupported socket". The problem > > is described in two places with different workarounds. > > > > ? http://code.google.com/p/happstack/issues/detail?id=88 > > ? http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 > > > > One workaround is to rewrite part of the network package, and the > > other is to downgrade the package. It could be the case that the > > rewrite came from the older version, though I'm not sure. > > > > I'm curious if it is possible to fix this, either in Happstack or the > > network package, once and for all. The workarounds are rather painful > > when so many things depend on the network package. > > The following patch to happstack works for me: > > This worked for us as well. Thanks, Gregory. > > Do you know if it's possible to permanently patch happstack-server? > I'm guessing the TH in the patch is used to support multiple versions > of the network package. Can we just change the minimum supported > version? There's been an open ticket for months; personally I think this is a job for the C preprocessor, but nobody's written a patch yet. I'm not sure but I think IPv6 template Haskell stuff is there not to support old versions of network, but to support platforms where IPv6 may not be available. G -- Gregory Collins From anton at appsolutions.com Fri Oct 9 10:37:00 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Fri Oct 9 10:15:00 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: <87skdsfxv1.fsf@gregorycollins.net> References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> <87skdsfxv1.fsf@gregorycollins.net> Message-ID: <4ACF4A8C.3020100@appsolutions.com> Gregory Collins wrote: > Sean Leather writes: > >> On Thu, Oct 8, 2009 at 16:35, Gregory Collins wrote: >> >> Sean Leather writes: >> Do you know if it's possible to permanently patch happstack-server? >> I'm guessing the TH in the patch is used to support multiple versions >> of the network package. Can we just change the minimum supported >> version? > > There's been an open ticket for months; personally I think this is a job > for the C preprocessor, but nobody's written a patch yet. I'm not sure > but I think IPv6 template Haskell stuff is there not to support old > versions of network, but to support platforms where IPv6 may not be > available. I don't recall whether there was some objection to this suggestion previously, but assuming IPv6 support is available might work on more platforms. Then special action would only need to be taken on platforms that lack IPv6. Anton From martijn at van.steenbergen.nl Fri Oct 9 10:41:05 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 9 10:18:34 2009 Subject: [Haskell-cafe] Non-traversable foldables Message-ID: <4ACF4B81.5060404@van.steenbergen.nl> Hallo caf?, Can anyone think of datatypes that are Foldable but not Traversable? If not, what is the purpose of having a separate Foldable class? Thanks, Martijn. From lemming at henning-thielemann.de Fri Oct 9 10:45:01 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Oct 9 10:21:57 2009 Subject: [Haskell-cafe] Non-traversable foldables In-Reply-To: <4ACF4B81.5060404@van.steenbergen.nl> References: <4ACF4B81.5060404@van.steenbergen.nl> Message-ID: On Fri, 9 Oct 2009, Martijn van Steenbergen wrote: > Hallo caf?, > > Can anyone think of datatypes that are Foldable but not Traversable? > > If not, what is the purpose of having a separate Foldable class? Recently I wondered, why Foldable is superclass of Traversable, since I have examples where 'traverse' makes sense, but 'fold' not. http://www.haskell.org/pipermail/libraries/2009-February/011361.html From ross at soi.city.ac.uk Fri Oct 9 10:53:25 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Oct 9 10:30:55 2009 Subject: [Haskell-cafe] Non-traversable foldables In-Reply-To: <4ACF4B81.5060404@van.steenbergen.nl> References: <4ACF4B81.5060404@van.steenbergen.nl> Message-ID: <20091009145325.GA7273@soi.city.ac.uk> On Fri, Oct 09, 2009 at 04:41:05PM +0200, Martijn van Steenbergen wrote: > Can anyone think of datatypes that are Foldable but not Traversable? Set From ekmett at gmail.com Fri Oct 9 10:57:48 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Oct 9 10:35:16 2009 Subject: [Haskell-cafe] Non-traversable foldables In-Reply-To: References: <4ACF4B81.5060404@van.steenbergen.nl> Message-ID: <7fb8f82f0910090757m280cb0dbl996439cc28c7d8dc@mail.gmail.com> On Fri, Oct 9, 2009 at 10:45 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Fri, 9 Oct 2009, Martijn van Steenbergen wrote: > > Hallo caf?, >> >> Can anyone think of datatypes that are Foldable but not Traversable? > > Data.Set.Set is a good example. The values contained in the Set are critical to the well-formedness of the data structure. Foldables let you iterate over a container while preserving structure, Traversables allow you to swap out the contents, but preserve the existing structure. Since you can do that you get fmap for free. > If not, what is the purpose of having a separate Foldable class? >> > > Recently I wondered, why Foldable is superclass of Traversable, since I > have examples where 'traverse' makes sense, but 'fold' not. > > http://www.haskell.org/pipermail/libraries/2009-February/011361.html > The superclass is there simply because there is a free implementation of foldMap (and fmap) given a Traversable instance, and it is useful to have access to all of those methods without building up a big long dictionary list, or having to clone them to make Traversable-specific versions) -Edward > _______________________________________________ > 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/20091009/45164e35/attachment.html From ross at soi.city.ac.uk Fri Oct 9 11:03:09 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Oct 9 10:40:38 2009 Subject: [Haskell-cafe] Non-traversable foldables In-Reply-To: References: <4ACF4B81.5060404@van.steenbergen.nl> Message-ID: <20091009150309.GB7273@soi.city.ac.uk> On Fri, Oct 09, 2009 at 04:45:01PM +0200, Henning Thielemann wrote: > Recently I wondered, why Foldable is superclass of Traversable, > since I have examples where 'traverse' makes sense, but 'fold' not. > > http://www.haskell.org/pipermail/libraries/2009-February/011361.html That would be surprising, since fold can be defined in terms of traverse. The link doesn't seem to contain any such examples. From felipe.lessa at gmail.com Fri Oct 9 11:12:34 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Oct 9 10:50:08 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework In-Reply-To: <20091008075414.C2760175E1@Adric.metnet.navy.mil> References: <20091008075414.C2760175E1@Adric.metnet.navy.mil> Message-ID: <20091009151234.GC17058@kira.casa> On Thu, Oct 08, 2009 at 12:54:14AM -0700, oleg@okmij.org wrote: > Actually it is possible to implement all three evaluation orders > within the same final tagless framework, using the same interpretation > of types and reusing most of the code save the semantics of lam. That > is where the three orders differ, by their own definition. That's really nice, Oleg, thanks! I just wanted to comment that I'd prefer to write share :: IO a -> IO (IO a) share m = mdo r <- newIORef (do x <- m writeIORef r (return x) return x) return (readIORef r >>= id) which unfortunately needs {-# LANGUAGE RecursiveDo #-} or some ugliness from mfix share :: IO a -> IO (IO a) share m = do r <- mfix $ \r -> newIORef (do x <- m writeIORef r (return x) return x) return (readIORef r >>= id) Thanks, -- Felipe. From jeremy at n-heptane.com Fri Oct 9 11:33:28 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Oct 9 11:10:57 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: References: Message-ID: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> Sweet! What are the chances of seeing a, instance Data Text, some day? text would be a great type to use with Happstack, because it is far more memory efficient than String. But it is difficult to do that with out a instance of Data. For the time being, I have been hacking it with: instance Data Text where toConstr x = mkStringConstr textType (Text.unpack x) gunfold _k z c = case constrRep c of (StringConstr x) -> z (Text.pack x) _ -> error "gunfold for Data.Text" dataTypeOf _ = textType But, packing and unpacking the Text is obviously not that cool.. For what it's worth, ByteString is normally exported abstract, and just uses, deriving Data. Perhaps we can do the same for text? (I believe there are a number of other examples of types in the 'standard' libraries which are exported abstract, but have Data instances...) - jeremy From shahn at cs.tu-berlin.de Fri Oct 9 11:37:16 2009 From: shahn at cs.tu-berlin.de (=?utf-8?q?S=C3=B6nke_Hahn?=) Date: Fri Oct 9 11:14:47 2009 Subject: [Haskell-cafe] Setting environment variables on Windows Message-ID: <200910091737.16956.shahn@cs.tu-berlin.de> Hi! I need to set an environment variable from Haskell and i would like to do that cross-platform. There is System.Posix.Env.setEnv, which does exactly, what i want on Linux. There is the module System.Environment, which seems to be cross-platform, but it does not contain functions to manipulate the environment (, just to inspect it). At first glance, I didn't find anything relevant in the sub-modules of System.Win32. Is this just not implemented? How could i implement it myself? Grateful for any comment, S?nke From jfredett at gmail.com Fri Oct 9 12:30:42 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Oct 9 12:08:30 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News In-Reply-To: <3ittc5d5db5j15ela5lh1e973dri0bmvpf@4ax.com> References: <4ac77fe1.9753f10a.4fc4.1044@mx.google.com> <3ittc5d5db5j15ela5lh1e973dri0bmvpf@4ax.com> Message-ID: Mostly it's been issues with sendmail, I think I have them fixed for this week. (I think...) Thanks for the input! /Joe On Oct 9, 2009, at 4:46 AM, Benjamin L.Russell wrote: > Thank you for including my quote (by "dekudekuplex"), and great work > so far! > > Just a couple of minor comments: > > 1) It might be useful for referencing by subject if you could include > the issue number and date in the subject line (e.g., " Haskell Weekly > News: Issue 131 - September 25, 2009") instead of only "Haskell Weekly > News." > > 2) Instead of posting separately to the Haskell and Haskell-Cafe > mailing lists, it might be better to cross-post, since that way, > readers using newsreaders can have the cross-posted article > automatically marked "read" in the mailing list where it has not been > read. > > Other than that, hope that you get over your sinus infection, and keep > up the good work! > > Benjamin L. Russell > > On Sat, 03 Oct 2009 09:46:25 -0700 (PDT), Joe Fredette > wrote: > >> >> --------------------------------------------------------------------------- >> Haskell Weekly News >> http://sequence.complete.org/hwn/20091003 >> Issue 134 - October 03, 2009 >> --------------------------------------------------------------------------- >> Welcome to issue 134 of HWN, a newsletter covering developments in >> the >> [1]Haskell community. >> >> I have a nasty sinus infection this week, so we're somewhat light on >> content. Lots of good discussion about DSL related stuff this week. >> Bryan O'Sullivan also release 'Criterion' this week, a new >> benchmarking >> library that Don Stewart described (on reddit) as 'awesome and game >> changing.' A new TMR editor -- someone familiar -- was announced. >> Also, >> there was some talk about homework policies on the mailinglists >> and in >> the irc channels. There is a [2]page on the Haskell wiki about this, >> but to sum it up in a maxim, remember, 'Help, don't do'. Until next >> week, the Haskell Weekly News! >> >> Announcements >> >> New TMR editor. Wouter Swierstra [3]announced that he would be >> stepping >> down from the editorship of 'The Monad Reader', with former HWN >> editor >> Brent Yorgey taking his place. Much thanks for Wouter's hard work >> and >> good luck to Brent on his new editor job! >> >> SourceGraph 0.5.{0,1,2}.0. Ivan Lazar Miljenovic [4]announced >> three new >> releases of the SourceGraph packages, this links to the latest >> release. >> >> json-b-0.0.4. Jason Dusek [5]announced a new version of the json-b >> package, which fixes defective handling of empty objects and arrays. >> >> rss2irc 0.4 released. Simon Michael [6]announced a new release of >> rss2irc, with many new improvements and features. >> >> vty-ui 0.1. Jonathan Daugherty [7]announced vty-ui, which is an >> extensible library of user interface widgets for composing and >> laying >> out Vty user interfaces. >> >> atom-0.1.1. Tom Hawkins [8]announced Atom, a Haskell DSL for >> designing >> hard real-time embedded applications. >> >> Graphalyze-0.7.0.0. Ivan Lazar Miljenovic [9]announced (in an >> apparent >> effort to take over hackage by submitting dozens of quality >> packages at >> absurdly high speed), Graphalyze, a library for using graph- >> theoretic >> techniques to analyse the relationships inherent within discrete >> data. >> >> Criterion. Bryan O'Sullivan [10]announced (without tacking on an >> 'ANN' >> tag, I might add, I almost missed it!) Criterion, a benchmarking >> library he describes [11]here. >> >> ListTree 0.1. yairchu@gmail.com [12]announced ListTree, a package >> for >> combinatorial search and pruning of trees. >> >> usb-0.1. Bas van Dijk [13]announced a library for interacting with >> usb >> modules from userspace. >> >> (Deadline extended to October 5th) APLAS 2009 Call for Posters. >> Kiminori Matsuzaki [14]announced a deadline extension to the call >> for >> posters for the APLAS conference. >> >> graphviz-2999.6.0.0. Ivan Lazar Miljenovic [15]announced a new >> version >> of the graphviz library, which features various new features and >> small >> changes. >> >> Discussion >> >> Testing polymorphic properties with QuickCheck. Jean-Philippe >> Bernardy >> [16]gave an excellent overview about how to use QuickCheck to test >> polymorphic properties. >> >> Designing a DSL? Gunther Schmidt [17]asked about different methods >> employed for designing a DSL. >> >> DSL and GUI Toolkits. Gunther Schmidt [18]also asked about different >> DSLs for working with GUIs >> >> error on "--++ bla bla bla". Hong Yang [19]asked about why '--++' >> wasn't being parsed in the way he thought it was. >> >> Haskell for Physicists. edgar [20]requested name suggestions for the >> talk he is giving about Physics and Haskell. >> >> Blog noise >> >> [21]Haskell news from the [22]blogosphere. Blog posts from people >> new >> to the Haskell community are marked with >>>, be sure to welcome >> them! >> * Sean Leather: [23]'Extensibility and type safety in >> formatting: the >> design of xformat' at the Dutch HUG. >> * Martijn van Steenbergen: [24]let 5 = 6. >> * Lee Pike: [25]Writer's unblock. >> * Manuel M T Chakravarty: [26]NVIDIAs next generation GPU >> architecture has a lot for HPC to love. >> * David Amos: [27]Finite geometries, part 4: Lines in PG(n,Fq). >> * Bryan O'Sullivan: [28]New criterion release works on Macs. >> * Neil Brown: [29]Poison: Concurrent Termination. >> * The GHC Team: [30]Heads up: what you need to know about >> Unicode I/O >> in GHC 6.12.1. >> * Galois, Inc: [31]Tech Talk: Roll Your Own Test Bed for Embedded >> Real-Time Protocols: A Haskell Experience. >> * Bryan O'Sullivan: [32]Criterion, a new benchmarking library for >> Haskell. >> * Tom Schrijvers: [33]Monadic Constraint Programming. >> * Neil Brown: [34]Growing Sort Pump. >> >> Quotes of the Week >> >> * dekudekuplex: (Unfortunately (unless intentional)) the preceding >> (by ksf (in the 'Quotes of the Week' section)) quote had >> mismatched >> (one too many opening) parentheses (although it was still funny >> (even though it could have been edited (to make the parentheses >> match (even though that is not an important issue)))). >> * pozic: I think if you want to contact dons, you have to say that >> you found a bug in ByteString. >> * Veinor: [about dibblego kicking a whole bunch of spammers] >> crouching dibblego, hidden op >> * allbery_b: [on UndecidableInstances] 'this exceeds my easy >> threshold, turn on wizard mode' (at which point it becomes a lot >> smarter but may start contemplating its navel without warning) >> * byorgey: a bus error? try recompiling with -fsubway, perhaps >> * jafet: 'Zygomorphism' sounds like a reproductive disorder >> >> About the Haskell Weekly News >> >> New editions are posted to [35]the Haskell mailing list as well as >> to >> [36]the Haskell Sequence and [37]Planet Haskell. [38]RSS is also >> available, and headlines appear on [39]haskell.org. >> >> To help create new editions of this newsletter, please see the >> information on [40]how to contribute. Send stories to jfredett . >> at . >> gmail . dot . com. The darcs repository is available at darcs get >> [41]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . >> >> References >> >> 1. http://haskell.org/ >> 2. http://www.haskell.org/haskellwiki/Homework_help >> 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64213 >> 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64259 >> 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64254 >> 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63838 >> 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64070 >> 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64035 >> 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63989 >> 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63985 >> 11. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ >> 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63853 >> 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64206 >> 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17529 >> 15. http://article.gmane.org/gmane.comp.lang.haskell.general/17520 >> 16. http://thread.gmane.org/gmane.comp.lang.haskell.general/17535 >> 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64267 >> 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64244 >> 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64161 >> 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64128 >> 21. http://planet.haskell.org/ >> 22. http://haskell.org/haskellwiki/Blog_articles >> 23. http://feedproxy.google.com/~r/splonderzoek/~3/BHqNHIZFF7U/ >> extensibility-and-type-safety-in.html >> 24. http://martijn.van.steenbergen.nl/journal/2009/10/02/let-5-6/ >> 25. http://leepike.wordpress.com/2009/09/30/writers-unblock/ >> 26. http://justtesting.org/post/201508784 >> 27. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-4-lines-in-pgnfq.html >> 28. http://www.serpentine.com/blog/2009/09/30/new-criterion-release-works-on-macs/ >> 29. http://chplib.wordpress.com/2009/09/30/poison-concurrent-termination/ >> 30. http://ghcmutterings.wordpress.com/2009/09/30/heads-up-what-you-need-to-know-about-unicode-io-in-ghc-6-12-1/ >> 31. http://www.galois.com/blog/2009/09/29/pike-haskell0/ >> 32. http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ >> 33. http://tomschrijvers.blogspot.com/2009/01/monadic-constraint-programming.html >> 34. http://chplib.wordpress.com/2009/09/28/growing-sort-pump/ >> 35. http://www.haskell.org/mailman/listinfo/haskell >> 36. http://sequence.complete.org/ >> 37. http://planet.haskell.org/ >> 38. http://sequence.complete.org/node/feed >> 39. http://haskell.org/ >> 40. http://haskell.org/haskellwiki/HWN >> 41. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 > -- > Benjamin L. Russell / DekuDekuplex at Yahoo dot com > http://dekudekuplex.wordpress.com/ > Translator/Interpreter / Mobile: +011 81 80-3603-6725 > "Furuike ya, kawazu tobikomu mizu no oto." > -- Matsuo Basho^ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at googlemail.com Fri Oct 9 12:07:53 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Oct 9 12:40:51 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> Message-ID: <1255104473.28525.6759.camel@localhost> On Thu, 2009-10-08 at 09:43 -0600, John A. De Goes wrote: > Here's a list of libraries that are quite significant to commercial > software development in 2009, For the kinds of applications that you would like to build. > but which either do not exist in Haskell, or if they exist, are hard > to find, undocumented, unstable, or perhaps uncompilable: Certainly having more libs enables more apps and that stuff would enable your applications. Fortunately it's not an all-or-nothing thing. There are plenty of applications we can do now. For the commercial software I've developed in Haskell, all the libraries I've needed were available and sufficiently mature: decent data structures, binary serialisation, fast random numbers, date/time handling, GUI lib. Duncan From flippa at flippac.org Fri Oct 9 13:06:04 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Fri Oct 9 12:43:38 2009 Subject: [Haskell-cafe] Applicative do? Message-ID: <4ACF6D7C.5020103@flippac.org> I do a lot of work with parsers, and want to do more using Applicatives. That said, I'm finding it a little tedious being forced to use pointless style for a task that's well-suited to having a few names around. The idea of an applicative do notation's been kicked around on #haskell a few times (I can't find any trace of it on the mailing list, but I confess to not having searched too hard), so I thought I'd propose it here. The basic idea is to turn this: do a <- f g b <- h pure $ foo a b into this: (\a b -> pure $ foo a b) <*> (f <*> g *> h) Aside from changing >>= and >> into <*> and *>, the most significant difference from monadic do is that all the generated lambda abstractions go in front of the final "return" statement which is then fmapped across the rest of the code. Bindings are thus only in scope in the "return" statement. I believe sugared let statements can be handled similarly so long as they respect the binding discipline. This leads us to the bikeshed topic: what's the concrete syntax? The obvious way is to replace do with a new keyword - for example, ado for "applicative do". There's a nice alternative though: we can check whether a do statement meets the binding rules for an applicative block and treat it as one if so, or a monadic one if not. While not all Monads are Applicatives, code can readily be changed back using the WrappedMonad newtype - whereas existing code needn't turn on the appropriate extension in the first place. Thoughts, comments? -- flippa@flippac.org From bob.atkey at ed.ac.uk Fri Oct 9 13:11:45 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Fri Oct 9 12:49:26 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <4ACF6D7C.5020103@flippac.org> References: <4ACF6D7C.5020103@flippac.org> Message-ID: <1255108305.5913.11.camel@antimony> On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote: > This leads us to the bikeshed topic: what's the concrete syntax? I implemented a simple Camlp4 syntax extension for Ocaml to do this. I chose the syntax: applicatively let x = foo let y = bar in I quite like the word "applicatively". Your overloading suggestion sounds to me like it would require the desugaring process to know something about types, but I'm not sure. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From bugfact at gmail.com Fri Oct 9 13:19:30 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Oct 9 12:56:59 2009 Subject: [Haskell-cafe] Setting environment variables on Windows In-Reply-To: <200910091737.16956.shahn@cs.tu-berlin.de> References: <200910091737.16956.shahn@cs.tu-berlin.de> Message-ID: Mmm, that seems like a shortcoming. Well, you could just wrap the C functions yourself, like this (two possibilities, no error checking yet, quick hack): http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10565#a10565 Note that using SetEnvironmentVariable does not seem to be compatible with getEnv, but calling _putenv does work. So I guess someone should add this setEnv wrapper to the System.Environment module? Ticket? On Fri, Oct 9, 2009 at 5:37 PM, S?nke Hahn wrote: > Hi! > > I need to set an environment variable from Haskell and i would like to do that > cross-platform. There is System.Posix.Env.setEnv, which does exactly, what i > want on Linux. There is the module System.Environment, which seems to be > cross-platform, but it does not contain functions to manipulate the > environment (, just to inspect it). At first glance, I didn't find anything > relevant in the sub-modules of System.Win32. > > Is this just not implemented? How could i implement it myself? > > Grateful for any comment, > > S?nke > _______________________________________________ > 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/20091009/7a4699b2/attachment.html From dave at zednenem.com Fri Oct 9 13:27:57 2009 From: dave at zednenem.com (David Menendez) Date: Fri Oct 9 13:05:24 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework In-Reply-To: <20091009151234.GC17058@kira.casa> References: <20091008075414.C2760175E1@Adric.metnet.navy.mil> <20091009151234.GC17058@kira.casa> Message-ID: <49a77b7a0910091027s14e16feby7fca6ddcfc95b393@mail.gmail.com> On Fri, Oct 9, 2009 at 11:12 AM, Felipe Lessa wrote: > On Thu, Oct 08, 2009 at 12:54:14AM -0700, oleg@okmij.org wrote: >> Actually it is possible to implement all three evaluation orders >> within the same final tagless framework, using the same interpretation >> of types and reusing most of the code save the semantics of lam. That >> is where the three orders differ, by their own definition. > > That's really nice, Oleg, thanks! ?I just wanted to comment that > I'd prefer to write > > share :: IO a -> IO (IO a) > share m = mdo r <- newIORef (do x <- m > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef r (return x) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return x) > ? ? ? ? ? ? ?return (readIORef r >>= id) > > which unfortunately needs {-# LANGUAGE RecursiveDo #-} or > some ugliness from mfix > > share :: IO a -> IO (IO a) > share m = do r <- mfix $ \r -> newIORef (do x <- m > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef r (return x) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return x) > ? ? ? ? ? ? return (readIORef r >>= id) > Alternatively, share m = do r <- newIORef undefined writeIORef r $ do x <- m writeIORef r (return x) return x return $ readIORef r >>= id Which is basically the same as your version, but only needs one IORef. -- Dave Menendez From flippa at flippac.org Fri Oct 9 13:33:58 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Fri Oct 9 13:11:41 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <1255108305.5913.11.camel@antimony> References: <4ACF6D7C.5020103@flippac.org> <1255108305.5913.11.camel@antimony> Message-ID: <4ACF7406.5000302@flippac.org> Robert Atkey wrote: > On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote: > > >> This leads us to the bikeshed topic: what's the concrete syntax? >> > > I implemented a simple Camlp4 syntax extension for Ocaml to do this. I > chose the syntax: > > applicatively > let x = foo > let y = bar > in > > I quite like the word "applicatively". > > In an ML context I rather like it! It doesn't really feel haskelly to me though, partly because code that looks like ANF in Haskell is normally in a do block and failing that a single let block instead of a series of nested lets. > Your overloading suggestion sounds to me like it would require the > desugaring process to know something about types, but I'm not sure. > > It doesn't the way I've suggested it, whereas doing it perfectly would do because not all Monads are directly Applicatives. I just reckon the imperfection isn't too big a burden applied to new code when you can newtype Monads into Applicatives on demand and get sensible code. -- flippa@flippac.org From ekmett at gmail.com Fri Oct 9 13:36:46 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Oct 9 13:14:14 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <4ACF6D7C.5020103@flippac.org> References: <4ACF6D7C.5020103@flippac.org> Message-ID: <7fb8f82f0910091036q61e6e382nf6393ca44231e31c@mail.gmail.com> Good trick. I just added 'ado' to my little scheme monad library. ;) -Edward Kmett On Fri, Oct 9, 2009 at 1:06 PM, Philippa Cowderoy wrote: > I do a lot of work with parsers, and want to do more using Applicatives. > That said, I'm finding it a little tedious being forced to use pointless > style for a task that's well-suited to having a few names around. The idea > of an applicative do notation's been kicked around on #haskell a few times > (I can't find any trace of it on the mailing list, but I confess to not > having searched too hard), so I thought I'd propose it here. > > The basic idea is to turn this: > > do a <- f > g > b <- h > pure $ foo a b > > into this: > > (\a b -> pure $ foo a b) <*> (f <*> g *> h) > > Aside from changing >>= and >> into <*> and *>, the most significant > difference from monadic do is that all the generated lambda abstractions go > in front of the final "return" statement which is then fmapped across the > rest of the code. Bindings are thus only in scope in the "return" statement. > I believe sugared let statements can be handled similarly so long as they > respect the binding discipline. > > This leads us to the bikeshed topic: what's the concrete syntax? The > obvious way is to replace do with a new keyword - for example, ado for > "applicative do". There's a nice alternative though: we can check whether a > do statement meets the binding rules for an applicative block and treat it > as one if so, or a monadic one if not. While not all Monads are > Applicatives, code can readily be changed back using the WrappedMonad > newtype - whereas existing code needn't turn on the appropriate extension in > the first place. > > Thoughts, comments? > > -- > flippa@flippac.org > _______________________________________________ > 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/20091009/a4a52c53/attachment.html From felipe.lessa at gmail.com Fri Oct 9 13:39:19 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Oct 9 13:16:53 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework In-Reply-To: <49a77b7a0910091027s14e16feby7fca6ddcfc95b393@mail.gmail.com> References: <20091008075414.C2760175E1@Adric.metnet.navy.mil> <20091009151234.GC17058@kira.casa> <49a77b7a0910091027s14e16feby7fca6ddcfc95b393@mail.gmail.com> Message-ID: <20091009173919.GA23797@kira.casa> On Fri, Oct 09, 2009 at 01:27:57PM -0400, David Menendez wrote: > On Fri, Oct 9, 2009 at 11:12 AM, Felipe Lessa wrote: > > That's really nice, Oleg, thanks! ?I just wanted to comment that > > I'd prefer to write > > > > share :: IO a -> IO (IO a) > > share m = mdo r <- newIORef (do x <- m > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef r (return x) > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return x) > > ? ? ? ? ? ? ?return (readIORef r >>= id) > > > > which unfortunately needs {-# LANGUAGE RecursiveDo #-} or > > some ugliness from mfix > > > > share :: IO a -> IO (IO a) > > share m = do r <- mfix $ \r -> newIORef (do x <- m > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef r (return x) > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return x) > > ? ? ? ? ? ? return (readIORef r >>= id) > > > > Alternatively, > > share m = do > r <- newIORef undefined > writeIORef r $ do > x <- m > writeIORef r (return x) > return x > return $ readIORef r >>= id > > Which is basically the same as your version, but only needs one IORef. Hmmm, but my version also needs only one IORef, right? In fact I first wrote the same code as yours but I've frowned upon the need of having that 'undefined' and an extra 'writeIORef'. Thanks, -- Felipe. From jfredett at gmail.com Fri Oct 9 13:45:12 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Oct 9 13:22:43 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <1255108305.5913.11.camel@antimony> References: <4ACF6D7C.5020103@flippac.org> <1255108305.5913.11.camel@antimony> Message-ID: <517826AB-5536-4406-94DF-B569DF6900DA@gmail.com> The only issue I would have with such a notation is not being able to visually tell the difference between a monadic function (say, without a explicit type sig, which is how I write parsers), and an applicative one. I'd prefer something like foo = app blah blah If only for some visual distinction, I think it also resolves the "do knowing about types" issue. Plus, this is a good case for some kind of custom-do syntax facility. So we could make do syntax for everything. :) /Joe On Oct 9, 2009, at 1:11 PM, Robert Atkey wrote: > On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote: > >> This leads us to the bikeshed topic: what's the concrete syntax? > > I implemented a simple Camlp4 syntax extension for Ocaml to do this. I > chose the syntax: > > applicatively > let x = foo > let y = bar > in > > I quite like the word "applicatively". > > Your overloading suggestion sounds to me like it would require the > desugaring process to know something about types, but I'm not sure. > > Bob > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From pumpkingod at gmail.com Fri Oct 9 13:52:15 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Oct 9 13:29:42 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <517826AB-5536-4406-94DF-B569DF6900DA@gmail.com> References: <4ACF6D7C.5020103@flippac.org> <1255108305.5913.11.camel@antimony> <517826AB-5536-4406-94DF-B569DF6900DA@gmail.com> Message-ID: I'd prefer "idiom brackets" over something do-ish for Applicatives. Conor McBride's SHE already supports them, if you're willing to use a custom preprocessor. On Fri, Oct 9, 2009 at 1:45 PM, Joe Fredette wrote: > The only issue I would have with such a notation is not being able to > visually tell the difference between a monadic function (say, without a > explicit type sig, which is how I write parsers), and an applicative one. > > I'd prefer something like > > foo = app > ? ? ? ?blah blah > > If only for some visual distinction, I think it also resolves the "do > knowing about types" issue. > > Plus, this is a good case for some kind of custom-do syntax facility. So we > could make do syntax for everything. :) > > /Joe > > On Oct 9, 2009, at 1:11 PM, Robert Atkey wrote: > >> On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote: >> >>> This leads us to the bikeshed topic: what's the concrete syntax? >> >> I implemented a simple Camlp4 syntax extension for Ocaml to do this. I >> chose the syntax: >> >> ?applicatively >> ?let x = foo >> ?let y = bar >> ?in >> >> I quite like the word "applicatively". >> >> Your overloading suggestion sounds to me like it would require the >> desugaring process to know something about types, but I'm not sure. >> >> Bob >> >> >> -- >> The University of Edinburgh is a charitable body, registered in >> Scotland, with registration number SC005336. >> >> _______________________________________________ >> 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 ekmett at gmail.com Fri Oct 9 14:04:08 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Oct 9 13:41:35 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: References: <4ACF6D7C.5020103@flippac.org> <1255108305.5913.11.camel@antimony> <517826AB-5536-4406-94DF-B569DF6900DA@gmail.com> Message-ID: <7fb8f82f0910091104o72c04ed6l50778b4c5f3f78f8@mail.gmail.com> I have idiom brackets in that toy library already, but the ado syntax is fairly useful if you want to refer to several intermediate results by name. To work with idiom brackets you need to manually write a big lambda yourself and them apply it. If you have a lambda that takes several arguments -- which isn't all that uncommon in a parser! -- the names you are binding and their position in the input can get rather far apart, even using idiom sugar. Philippa's ado sugar lets you amortize that big binding statement over several lines and keeps the names closer to the binding. Not sure that it warrants a syntax extension in the Haskell case, but it is pretty convenient. =) -Edward Kmett On Fri, Oct 9, 2009 at 1:52 PM, Daniel Peebles wrote: > I'd prefer "idiom brackets" over something do-ish for Applicatives. > Conor McBride's SHE already supports them, if you're willing to use a > custom preprocessor. > > On Fri, Oct 9, 2009 at 1:45 PM, Joe Fredette wrote: > > The only issue I would have with such a notation is not being able to > > visually tell the difference between a monadic function (say, without a > > explicit type sig, which is how I write parsers), and an applicative one. > > > > I'd prefer something like > > > > foo = app > > blah blah > > > > If only for some visual distinction, I think it also resolves the "do > > knowing about types" issue. > > > > Plus, this is a good case for some kind of custom-do syntax facility. So > we > > could make do syntax for everything. :) > > > > /Joe > > > > On Oct 9, 2009, at 1:11 PM, Robert Atkey wrote: > > > >> On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote: > >> > >>> This leads us to the bikeshed topic: what's the concrete syntax? > >> > >> I implemented a simple Camlp4 syntax extension for Ocaml to do this. I > >> chose the syntax: > >> > >> applicatively > >> let x = foo > >> let y = bar > >> in > >> > >> I quite like the word "applicatively". > >> > >> Your overloading suggestion sounds to me like it would require the > >> desugaring process to know something about types, but I'm not sure. > >> > >> Bob > >> > >> > >> -- > >> The University of Edinburgh is a charitable body, registered in > >> Scotland, with registration number SC005336. > >> > >> _______________________________________________ > >> 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 > > > _______________________________________________ > 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/20091009/2ab936bf/attachment.html From bos at serpentine.com Fri Oct 9 14:29:50 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Oct 9 14:07:18 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> References: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> Message-ID: On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw wrote: > > What are the chances of seeing a, instance Data Text, some day? text would > be a great type to use with Happstack, because it is far more memory > efficient than String. But it is difficult to do that with out a instance of > Data. Ask, and you shall receive :-) I'll take a look. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/5cd9ed66/attachment.html From dave at zednenem.com Fri Oct 9 15:05:37 2009 From: dave at zednenem.com (David Menendez) Date: Fri Oct 9 14:43:04 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework In-Reply-To: <20091009173919.GA23797@kira.casa> References: <20091008075414.C2760175E1@Adric.metnet.navy.mil> <20091009151234.GC17058@kira.casa> <49a77b7a0910091027s14e16feby7fca6ddcfc95b393@mail.gmail.com> <20091009173919.GA23797@kira.casa> Message-ID: <49a77b7a0910091205u55d4cca2sd693b2522a3503ea@mail.gmail.com> On Fri, Oct 9, 2009 at 1:39 PM, Felipe Lessa wrote: > On Fri, Oct 09, 2009 at 01:27:57PM -0400, David Menendez wrote: >> On Fri, Oct 9, 2009 at 11:12 AM, Felipe Lessa wrote: >> > That's really nice, Oleg, thanks! ?I just wanted to comment that >> > I'd prefer to write >> > >> > share :: IO a -> IO (IO a) >> > share m = mdo r <- newIORef (do x <- m >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef r (return x) >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return x) >> > ? ? ? ? ? ? ?return (readIORef r >>= id) >> > >> > which unfortunately needs {-# LANGUAGE RecursiveDo #-} or >> > some ugliness from mfix >> > >> > share :: IO a -> IO (IO a) >> > share m = do r <- mfix $ \r -> newIORef (do x <- m >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef r (return x) >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return x) >> > ? ? ? ? ? ? return (readIORef r >>= id) >> > >> >> Alternatively, >> >> share m = do >> ? ? r <- newIORef undefined >> ? ? writeIORef r $ do >> ? ? ? ? x <- m >> ? ? ? ? writeIORef r (return x) >> ? ? ? ? return x >> ? ? return $ readIORef r >>= id >> >> Which is basically the same as your version, but only needs one IORef. > > Hmmm, but my version also needs only one IORef, right? ?In fact I > first wrote the same code as yours but I've frowned upon the need > of having that 'undefined' and an extra 'writeIORef'. It's in the implementation of mfix for IO. From System.IO, fixIO :: (a -> IO a) -> IO a fixIO k = do ref <- newIORef (throw NonTermination) ans <- unsafeInterleaveIO (readIORef ref) result <- k ans writeIORef ref result return result If we inline that into your definition, we get share m = do ref <- newIORef (throw NonTermination) ans <- unsafeInterleaveIO (readIORef ref) r <- newIORef $ do { x <- m; writeIORef ans (return x); return x } writeIORef ref r return (readIORef r >>= id) So behind the scenes, the mfix version still creates an IORef with undefined and has an extra writeIORef. It also has that unsafeInterleaveIO, but I don't think there's any way that can cause a problem. Incidentally, none of the versions of share discussed so far are thread-safe. Specifically, if a second thread starts to evaluate the result of share m while the first thread is still evaluating m, we end up with the effects of m happening twice. Here's a version that avoids this by using a semaphore. share m = do r <- newIORef undefined s <- newMVar False writeIORef r $ do b <- takeMVar s if b then do putMVar s True readIORef r >>= id else do x <- m writeIORef r (return x) putMVar s True return x return $ readIORef r >>= id In the worst case, MVar will get read at most once per thread, so the overhead is limited. Under normal circumstances, the MVar will be read once and then discarded. -- Dave Menendez From jao at gnu.org Fri Oct 9 14:53:29 2009 From: jao at gnu.org (Jose A. Ortega Ruiz) Date: Fri Oct 9 14:45:56 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1 References: <594c1e830910071556o588195e7te448b50dbca8447c@mail.gmail.com> <878wfk3gby.fsf@mithrandir.homeunix.net> <594c1e830910090723u6492b73ai99e2764b9b137f8a@mail.gmail.com> Message-ID: <87tyy81jrq.fsf@mithrandir.homeunix.net> Tom Hawkins writes: > Sorry, I forgot to add the other modules to the cabal file. Try > htzaar-0.0.2. Thank you, it's working now. jao -- The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. - George Bernard Shaw From bos at serpentine.com Fri Oct 9 15:17:49 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Oct 9 14:55:19 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> References: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> Message-ID: On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw wrote: > > What are the chances of seeing a, instance Data Text, some day? I might as well follow up here, since I've sent Jeremy a couple of messages on this subject. I think maybe someone else will have to take a crack at a Data instance for Text, because the documentation for Data.Data is not written in English. In its syntax and structure, it closely hews to what we think of as English, but it is the kind of documentation that can only be understood by someone who already knows what it is going to say. This is an exemplar of my experience with the cottage industry of generic programming in Haskell: I'd really quite like to use the stuff, but for goodness's sake, o beloved researchers, please aim your expository papers at non-specialists once in a while. An endless chain of papers of the form "my technique, which you won't understand, is better than this other technique, which you haven't read about and won't anyway understand, in subtle ways that you won't understand" does not feel to me like progress. Yours in some misery and frustration, Bryan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/27d20fbb/attachment-0001.html From bos at serpentine.com Fri Oct 9 15:22:59 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Oct 9 15:00:26 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: <87skdsfxv1.fsf@gregorycollins.net> References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> <87skdsfxv1.fsf@gregorycollins.net> Message-ID: On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins wrote: > There's been an open ticket for months; personally I think this is a job > for the C preprocessor, but nobody's written a patch yet. Is there an open ticket against the network package? Can someone write a simple standalone repro for me that doesn't require happstack (i.e. only depends on network)? I have access to a Mac and Johan and I co-maintain the network package, so in principle this shouldn't be hard to fix, given enough details and pointers. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/c294820e/attachment.html From brannanster at gmail.com Fri Oct 9 15:56:52 2009 From: brannanster at gmail.com (Patrick Brannan) Date: Fri Oct 9 15:34:20 2009 Subject: [Haskell-cafe] HDBC PostgreSQL Message-ID: Hello, I'm getting back into Haskell after an absence of a few years. I'm in the process of trying to connect to postgresql with hdbc-postgresql on a Windows XP box. Seemingly, things installed without a problem, but at the command prompt I get the following: Prelude> :module Database.HDBC Database.HDBC.PostgreSQL module `Database.HDBC.PostgreSQL' is not loaded If I run ghci this way with package options here's what I get: C:\work\haskell\HDBC-postgresql-2.1.0.0>ghci -package HDBC -package HDBC-postgresql GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Loading package HUnit-1.2.0.3 ... linking ... done. Loading package syb ... linking ... done. Loading package base-3.0.3.1 ... linking ... done. Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.2 ... linking ... done. Loading package random-1.0.0.1 ... linking ... done. Loading package QuickCheck-1.2.0.0 ... linking ... done. Loading package bytestring-0.9.1.4 ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package Win32-2.2.0.0 ... linking ... done. Loading package time-1.1.4 ... linking ... done. Loading package convertible-1.0.5 ... linking ... done. Loading package filepath-1.1.0.2 ... linking ... done. Loading package directory-1.0.0.3 ... linking ... done. Loading package process-1.0.1.1 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package testpack-1.0.2 ... linking ... done. Loading package utf8-string-0.3.5 ... linking ... done. Loading package HDBC-2.1.1 ... linking ... done. Loading package parsec-2.1.0.1 ... linking ... done. Loading package HDBC-postgresql-2.1.0.0 ... linking ... done. Prelude> module HDBC HDBC.PostgreSQL Now I would think that the line "Loading package HDBC-postgresql-2.1.0.0 ... linking ... done." means that the module is installed correctly, but I still can't execute the :module statement. Does anyone have any ideas about where I should start? It's probably something stupid, but I'm a little worn out on searching. Thank you, Patrick From jeremy at n-heptane.com Fri Oct 9 15:58:04 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Oct 9 15:35:39 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: References: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> Message-ID: <673D0B51-ACB6-4EC4-940F-199D34C393C7@n-heptane.com> Based on section 5.2 of this paper: http://www.cs.vu.nl/boilerplate/gmap2.pdf I wonder if the Data instance I provided is the best possible option with out modifying SYB. And that the optimal solution would be to extend ConstrRep to support Text as a primitive: data ConstrRep = AlgConstr ConIndex | IntConstr Integer | FloatConstr Double | StringConstr String | TextConstr Text -- does not really exist -- Defined in Data.Data With the unfortunate side-effect of making syb depend on text. - jeremy On Oct 9, 2009, at 2:17 PM, Bryan O'Sullivan wrote: > On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw > wrote: > > What are the chances of seeing a, instance Data Text, some day? > > I might as well follow up here, since I've sent Jeremy a couple of > messages on this subject. > > I think maybe someone else will have to take a crack at a Data > instance for Text, because the documentation for Data.Data is not > written in English. In its syntax and structure, it closely hews to > what we think of as English, but it is the kind of documentation > that can only be understood by someone who already knows what it is > going to say. > > This is an exemplar of my experience with the cottage industry of > generic programming in Haskell: I'd really quite like to use the > stuff, but for goodness's sake, o beloved researchers, please aim > your expository papers at non-specialists once in a while. An > endless chain of papers of the form "my technique, which you won't > understand, is better than this other technique, which you haven't > read about and won't anyway understand, in subtle ways that you > won't understand" does not feel to me like progress. > > Yours in some misery and frustration, > Bryan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/6a696e85/attachment.html From ben.franksen at online.de Fri Oct 9 15:57:56 2009 From: ben.franksen at online.de (Ben Franksen) Date: Fri Oct 9 15:35:53 2009 Subject: [Haskell-cafe] Re: Num instances for 2-dimensional types References: <200910051440.32119.shahn@cs.tu-berlin.de> <4AC9F0A4.2000005@yandex.ru> <200910051702.19827.daniel.is.fischer@web.de> <49a77b7a0910071341v5c3bfe7ek81af1a5d89c20e04@mail.gmail.com> Message-ID: Joe Fredette wrote: > A ring is an abelian group in addition, with the added operation (*) > being distributive over addition, and 0 annihilating under > multiplication. (*) is also associative. Rings don't necessarily need > _multiplicative_ id, only _additive_ id. Yes, this is how I learned it in my Algebra course(*). Though I can imagine that this is not universally agreed upon; indeed most of the more interesting results need a multiplicative unit, IIRC, so there's a justification for authors to include it in the basic definition (so they don't have to say let-R-be-a-ring-with-multiplicative-unit all the time ;-) Cheers Ben (*) As an aside, this was given by one Gernot Stroth, back then still at the FU Berlin, of whom I later learned that he took part in the grand effort to classify the simple finite groups. The course was extremely tight but it was fun and I never again learned so much in one semester. From mf-hcafe-15c311f0c at etc-network.de Fri Oct 9 16:05:11 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Fri Oct 9 15:45:02 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? Message-ID: <20091009200511.GD24096@yoyo> Hi all, I think there is something about my use of the IO monad that bites me, but I am bored of staring at the code, so here you g. The code goes through a list of records and collects the maximum in each record position. -- test.hs import Random import System.Environment (getArgs) import System.IO (putStr) samples :: Int -> Int -> IO [[Double]] samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 ** 3) maxima :: [[Double]] -> [Double] maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) main = do args <- getArgs x <- samples (read (head args)) 5 putStr . (++ "\n") . show $ maxima x I would expect this to take constant memory (foldr as well as foldl), but this is what happens: $ ghc -prof --make -O9 -o test test.hs [1 of 1] Compiling Main ( test.hs, test.o ) Linking test ... $ ./test 100 +RTS -p [9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8] $ grep 'total alloc' test.prof total alloc = 744,180 bytes (excludes profiling overheads) $ ./test 10000 +RTS -p [9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8] $ grep 'total alloc' test.prof total alloc = 64,777,692 bytes (excludes profiling overheads) $ ./test 1000000 +RTS -p Stack space overflow: current size 8388608 bytes. Use `+RTS -Ksize' to increase it. $ so... does sequence somehow force the entire list of monads into evaluation before the head of the result list can be used? what can i do to implement this in constant memory? thanks! matthias From tanimoto at arizona.edu Fri Oct 9 16:08:53 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Fri Oct 9 15:46:40 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: References: Message-ID: Hi Bryan, On Fri, Oct 9, 2009 at 2:11 AM, Bryan O'Sullivan wrote: > Get it while it's fresh on Hackage, folks! Details of the changes here: > http://bit.ly/1u4UOT > This is superb! I tried to post a comment to your website, but it may have been lost. It seems that the description for unlines is picking up a comment that was meant for lines': http://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.html#v%3Aunlines Take care! Paulo From anton at appsolutions.com Fri Oct 9 16:17:02 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Fri Oct 9 15:55:01 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> <87skdsfxv1.fsf@gregorycollins.net> Message-ID: <4ACF9A3E.9080103@appsolutions.com> Bryan O'Sullivan wrote: > On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins > wrote: > > > There's been an open ticket for months; personally I think this is a job > for the C preprocessor, but nobody's written a patch yet. > > > Is there an open ticket against the network package? Can someone write a > simple standalone repro for me that doesn't require happstack (i.e. only > depends on network)? I have access to a Mac and Johan and I co-maintain > the network package, so in principle this shouldn't be hard to fix, > given enough details and pointers. I have the impression that the problem is at least partly with TH on the Mac, and there may not even be any relevant bug in the network package. It's possible that the network package could provide some additional support to help Happstack solve this another way, though. The main problem that Happstack faces here is to avoid referencing the SockAddrInet6 constructor if it doesn't exist, i.e. if the network package was compiled without IPv6 support. If Happstack had some reliable/portable way of accessing IPV6_SOCKET_SUPPORT, a C #define used by the network package, this could easily be done with the C preprocessor. I don't think Cabal is up to that task, though. Happstack would probably have to use its own configure script (it doesn't have one right now) to determine IPv6 status for itself, and hope that it matches what the network package found when it was compiled. The current solution in Happstack is to use TH to detect IPv6 support in the network package, by testing for the existence of the SockAddrInet6 constructor, as follows (reformatted slightly for email): -- find out at compile time if the SockAddr6 / HostAddress6 constructors -- are available supportsIPv6 :: Bool supportsIPv6 = $(let c = "Network.Socket.SockAddrInet6" d = ''SockAddr in do TyConI (DataD _ _ _ cs _) <- reify d if isJust (find (\(NormalC n _) -> show n == c) cs) then [| True |] else [| False |] ) If I had access to a Mac, the first thing I'd do is check what supportsIPv6 is getting set to, and whether it changes depending on the version of the network package being used. However, some comments many months back seemed to indicate that supportsIPv6 might be getting set correctly, and that the problem was happening later. In that case, it would be in Happstack/Server/HTTP/Socket.hs, which contains this test: let peer = $(if supportsIPv6 If supportsIPv6 is False, or somehow incorrectly treated as False, then the error message being reported could happen if the provided socket is actually IPv6. Alternatively, if the True branch is taken, then a TH-encoded case expression is used to match the SockAddr value, without having to reference the SockAddrInet6 constructor directly in code. But if this the part that executes, then for some mysterious reason, it is failing, only on the Mac, to match the appropriate constructor. That sounds like a fascinating bug! I hope someone with a Mac will track it down and let us know what was happening... Anton From greg at gregorycollins.net Fri Oct 9 16:17:48 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Fri Oct 9 15:55:18 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: (Bryan O'Sullivan's message of "Fri, 9 Oct 2009 12:22:59 -0700") References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> <87skdsfxv1.fsf@gregorycollins.net> Message-ID: <87tyy8e2z7.fsf@gregorycollins.net> "Bryan O'Sullivan" writes: > On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins wrote: > ? > > There's been an open ticket for months; personally I think this is > a job for the C preprocessor, but nobody's written a patch yet. > > Is there an open ticket against the network package? Can someone write > a simple standalone repro for me that doesn't require happstack > (i.e. only depends on network)? I have access to a Mac and Johan and I > co-maintain the network package, so in principle this shouldn't be > hard to fix, given enough details and pointers. No, against Happstack. The offending code: ------------------------------------------------------------------------------ -- find out at compile time if the SockAddr6 / HostAddress6 -- constructors are available supportsIPv6 :: Bool supportsIPv6 = $(let c = "Network.Socket.SockAddrInet6"; d = ''SockAddr in do TyConI (DataD _ _ _ cs _) <- reify d if isJust (find (\(NormalC n _) -> show n == c) cs) then [| True |] else [| False |] ) ... -- | alternative implementation of accept to work around EAI_AGAIN errors acceptLite :: S.Socket -> IO (Handle, S.HostName, S.PortNumber) acceptLite sock = do (sock', addr) <- S.accept sock h <- S.socketToHandle sock' ReadWriteMode (N.PortNumber p) <- N.socketPort sock' let peer = $(if supportsIPv6 then return $ CaseE (VarE (mkName "addr")) [Match (ConP (mkName "S.SockAddrInet") [WildP,VarP (mkName "ha")]) (NormalB (AppE (VarE (mkName "showHostAddress")) (VarE (mkName "ha")))) [] ,Match (ConP (mkName "S.SockAddrInet6") [WildP,WildP,VarP (mkName "ha"),WildP]) (NormalB (AppE (VarE (mkName "showHostAddress6")) (VarE (mkName "ha")))) [] ,Match WildP (NormalB (AppE (VarE (mkName "error")) (LitE (StringL "Unsupported socket")))) []] -- the above mess is the equivalent of this: {-[| case addr of (S.SockAddrInet _ ha) -> showHostAddress ha (S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha _ -> error "Unsupported socket" |]-} else [| case addr of (S.SockAddrInet _ ha) -> showHostAddress ha _ -> error "Unsupported socket" |]) return (h, peer, p) ------------------------------------------------------------------------------ Frankly I think this approach is dubious at best. G -- Gregory Collins From bos at serpentine.com Fri Oct 9 16:20:20 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Oct 9 15:57:48 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: References: Message-ID: On Fri, Oct 9, 2009 at 1:08 PM, Paulo Tanimoto wrote: > I tried to post a comment to your website, but it may have been lost. > It seems that the description for unlines is picking up a comment that > was meant for lines': > Thanks, yes, Johan sent a patch in to fix that already. Hooray for open source and distributed revision control systems! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/54115a73/attachment.html From jeremy at n-heptane.com Fri Oct 9 16:27:03 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Oct 9 16:04:54 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> References: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> Message-ID: <32AA52FD-0EAB-42DE-8622-1CB2B1BDD0E1@n-heptane.com> oops, for the sake of completeness you also need: textType = mkStringType "Data.Text" - jeremy On Oct 9, 2009, at 10:33 AM, Jeremy Shaw wrote: > Sweet! > > What are the chances of seeing a, instance Data Text, some day? text > would be a great type to use with Happstack, because it is far more > memory efficient than String. But it is difficult to do that with > out a instance of Data. > > For the time being, I have been hacking it with: > > instance Data Text where > toConstr x = mkStringConstr textType (Text.unpack x) > gunfold _k z c = case constrRep c of > (StringConstr x) -> z (Text.pack x) > _ -> error "gunfold for Data.Text" > dataTypeOf _ = textType > > But, packing and unpacking the Text is obviously not that cool.. > > For what it's worth, ByteString is normally exported abstract, and > just uses, deriving Data. Perhaps we can do the same for text? (I > believe there are a number of other examples of types in the > 'standard' libraries which are exported abstract, but have Data > instances...) > > - jeremy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From nicolas.pouillard at gmail.com Fri Oct 9 16:39:26 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Fri Oct 9 16:16:32 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <7fb8f82f0910091104o72c04ed6l50778b4c5f3f78f8@mail.gmail.com> References: <4ACF6D7C.5020103@flippac.org> <1255108305.5913.11.camel@antimony> <517826AB-5536-4406-94DF-B569DF6900DA@gmail.com> <7fb8f82f0910091104o72c04ed6l50778b4c5f3f78f8@mail.gmail.com> Message-ID: <1255120489-sup-1585@peray> Excerpts from Edward Kmett's message of Fri Oct 09 20:04:08 +0200 2009: > I have idiom brackets in that toy library already, but the ado syntax is > fairly useful if you want to refer to several intermediate results by name. > To work with idiom brackets you need to manually write a big lambda yourself > and them apply it. If you have a lambda that takes several arguments -- > which isn't all that uncommon in a parser! -- the names you are binding and > their position in the input can get rather far apart, even using idiom > sugar. Philippa's ado sugar lets you amortize that big binding statement > over several lines and keeps the names closer to the binding. You can still name intermediate *computations* using local bindings, right? Then you just have to use the named computations in idioms brackets. -- Nicolas Pouillard http://nicolaspouillard.fr From flippa at flippac.org Fri Oct 9 17:01:33 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Fri Oct 9 16:39:10 2009 Subject: [Haskell-cafe] Applicative do? In-Reply-To: <1255120489-sup-1585@peray> References: <4ACF6D7C.5020103@flippac.org> <1255108305.5913.11.camel@antimony> <517826AB-5536-4406-94DF-B569DF6900DA@gmail.com> <7fb8f82f0910091104o72c04ed6l50778b4c5f3f78f8@mail.gmail.com> <1255120489-sup-1585@peray> Message-ID: <4ACFA4AD.7010304@flippac.org> Nicolas Pouillard wrote: > Excerpts from Edward Kmett's message of Fri Oct 09 20:04:08 +0200 2009: > >> I have idiom brackets in that toy library already, but the ado syntax is >> fairly useful if you want to refer to several intermediate results by name. >> To work with idiom brackets you need to manually write a big lambda yourself >> and them apply it. If you have a lambda that takes several arguments -- >> which isn't all that uncommon in a parser! -- the names you are binding and >> their position in the input can get rather far apart, even using idiom >> sugar. Philippa's ado sugar lets you amortize that big binding statement >> over several lines and keeps the names closer to the binding. >> > > You can still name intermediate *computations* using local bindings, right? > Then you just have to use the named computations in idioms brackets. > > Not really good enough, because of all the computations whose results aren't used. Being able to tell at a glance which bits of the parser are handling data for the abstract syntax and which're structure to guide the parser is pretty handy. -- flippa@flippac.org From duncan.coutts at googlemail.com Fri Oct 9 13:07:21 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Oct 9 16:49:35 2009 Subject: [Haskell-cafe] Setting environment variables on Windows In-Reply-To: <200910091737.16956.shahn@cs.tu-berlin.de> References: <200910091737.16956.shahn@cs.tu-berlin.de> Message-ID: <1255108041.28525.6760.camel@localhost> On Fri, 2009-10-09 at 17:37 +0200, S?nke Hahn wrote: > Hi! > > I need to set an environment variable from Haskell and i would like to do that > cross-platform. There is System.Posix.Env.setEnv, which does exactly, what i > want on Linux. There is the module System.Environment, which seems to be > cross-platform, but it does not contain functions to manipulate the > environment (, just to inspect it). At first glance, I didn't find anything > relevant in the sub-modules of System.Win32. Note that often it is enough to set environment variables for the programs that you invoke, rather than for your own process. If that's enough then you can do it via the System.Process.createProcess action. Duncan From g.c.stavenga at uu.nl Fri Oct 9 17:43:49 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Fri Oct 9 17:21:15 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? Message-ID: <25828319.post@talk.nabble.com> In my program do x <- do blah <- someFunc return blah return $ Constructor x behaves differently from do blah <- someFunc return $ Constructor blah where the dots are identical. I would think that these programs should behave identically, by the monad laws. The result of my program is that the second gives correct behaviour, while the first loops forever. Greetings, Gerben -- View this message in context: http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828319.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rmm-haskell at z.odi.ac Fri Oct 9 17:53:39 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Oct 9 17:31:09 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: <25828319.post@talk.nabble.com> References: <25828319.post@talk.nabble.com> Message-ID: <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> In what Monad? -Ross On Oct 9, 2009, at 5:43 PM, staafmeister wrote: > > > In my program > > do > x <- do > blah <- someFunc > return blah > return $ Constructor x > > behaves differently from > do > blah <- someFunc > return $ Constructor blah > > where the dots are identical. I would think that these programs should > behave identically, by the monad laws. > The result of my program is that the second gives correct behaviour, > while > the first loops forever. > > Greetings, > Gerben > -- > View this message in context: http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828319.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com > . > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jgoerzen at complete.org Fri Oct 9 17:58:04 2009 From: jgoerzen at complete.org (John Goerzen) Date: Fri Oct 9 17:35:33 2009 Subject: [Haskell-cafe] HDBC PostgreSQL In-Reply-To: References: Message-ID: <4ACFB1EC.1080503@complete.org> Patrick Brannan wrote: > Prelude> module HDBC HDBC.PostgreSQL > > Now I would think that the line "Loading package > HDBC-postgresql-2.1.0.0 ... linking ... done." means that the module > is installed correctly, but I still can't execute the :module > statement. > > Does anyone have any ideas about where I should start? It's probably > something stupid, but I'm a little worn out on searching. That's because you're confusing package names with module names. I suspect you meant :m Database.HDBC Database.HDBC.PostgreSQL The API docs on Hackage will list the modules that any package provides. -- John From g.c.stavenga at uu.nl Fri Oct 9 17:59:26 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Fri Oct 9 17:36:52 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> References: <25828319.post@talk.nabble.com> <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> Message-ID: <25828521.post@talk.nabble.com> Ross Mellgren wrote: > > In what Monad? > > Parsec Monad -- View this message in context: http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828521.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ben.franksen at online.de Fri Oct 9 17:59:01 2009 From: ben.franksen at online.de (Ben Franksen) Date: Fri Oct 9 17:36:59 2009 Subject: [Haskell-cafe] Re: Re: What *is* a DSL? References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> <4ACCF1CD.8000301@chalmers.se> Message-ID: Emil Axelsson wrote: > Ben Franksen skrev: >> minh thu wrote: >>> 2009/10/7 G?nther Schmidt : >>>>> I've informally argued that a true DSL -- separate from a good API -- >>>>> should have semantic characteristics of a language: binding forms, >>>>> control structures, abstraction, composition. Some have type systems. >>>>> >>>> That is one requirement that confuses me, abstraction. >>>> >>>> I thought of DSLs as "special purpose" languages, ie. you give your DSL >>>> everything it needs for that purpose. >>>> >>>> Why would it also need the ability to express even further >>>> abstractions, it is supposed to *be* the abstraction. >>> Programming abstractions at the DSL level, not to further abstract >>> what the DSL covers. >>> >>> Functions, for instance, are typical abstraction means offered by >>> programming languages. Even if your language is specific to some >>> domain, being able to create your own functions, and not only rely on >>> those provided by the DSL implementation, is important. >>> >>> Imagine a (E)DSL for 3D programming (e.g. shading language): the >>> language is designed to fit well the problem (e.g. in this case, 3D >>> linear algebra, color operations, ...) but you'll agree it would be a >>> shame to not be able to provide your own functions. >> >> But isn't one of the advantages of an _E_DSL that we can use the host >> language (Haskell) as a meta or macro language for the DSL? I would think >> that this greatly reduces the need to provide abstraction >> facilities /inside/ the DSL. In fact most existing (and often cited >> examples of) EDSLs in Haskell do not provide abstraction. > > I would say that the DSL is what the user sees. In this view, I think > it's correct to say that many (or most) DSLs need function abstraction. > Whether or not the internal data structure has function abstraction is > an implementation detail. If it is a stand-alone DSL (i.e. with its own parser), then yes. But I was referring to Embedded DSLs, i.e. DSL as a library in a host language (eg Haskell). In this case the user sees the host language by construction, which means she has less need of function abstraction /inside/ the DSL. Cheers Ben From pumpkingod at gmail.com Fri Oct 9 18:03:22 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Oct 9 17:40:50 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: <25828521.post@talk.nabble.com> References: <25828319.post@talk.nabble.com> <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> <25828521.post@talk.nabble.com> Message-ID: I vaguely remember on IRC someone pointing out that the Parsec monad broke one of the laws. I think return _|_ >> x === _|_ which could be causing your problem. I may be wrong though. On Fri, Oct 9, 2009 at 5:59 PM, staafmeister wrote: > > > > Ross Mellgren wrote: >> >> In what Monad? >> >> > > Parsec Monad > > -- > View this message in context: http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828521.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From g.c.stavenga at uu.nl Fri Oct 9 18:07:55 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Fri Oct 9 17:45:21 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: References: <25828319.post@talk.nabble.com> <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> <25828521.post@talk.nabble.com> Message-ID: <25828612.post@talk.nabble.com> Daniel Peebles wrote: > > I vaguely remember on IRC someone pointing out that the Parsec monad > broke one of the laws. I think return _|_ >> x === _|_ which could be > causing your problem. I may be wrong though. > > This could very well be it. I use lazy eval to construct a function that returns its own argument (that is you supply the return value of the func as its arg). -- View this message in context: http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828612.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dev at mobileink.com Fri Oct 9 18:11:47 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Fri Oct 9 17:49:15 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: References: <1254943082.10848.30.camel@malachite> <814617240910071714u73c4c313v99e8fe6dd602e5a0@mail.gmail.com> <6d942a4a0910080400r75945bdaodd6b2a67e7e8f246@mail.gmail.com> Message-ID: <75cc17ac0910091511m7669b350s60236450b43320a7@mail.gmail.com> On Thu, Oct 8, 2009 at 6:08 AM, Colin Paul Adams wrote: > >>>>> "George" == George Pollard writes: > > George> I'd also like to note that the canonical pronunciation of > George> DSL ends in "-izzle". > > Whose canon? > > Interestingly, I have always assumed the canonical pronunciation of > DSSSL was diesel, as JADE stands for JAmes's DSSSL Engine. > > I don't see why removing extra S-es should shorten the vowel. > > Wht vwl? U mst b Englsh. 2 n Amrcn, DSSSL is "dissel"; all short vowels. DSL is "dee-ess-ell". "Dizzle" is a brbrzm. -grgg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091009/096b04fc/attachment.html From g.c.stavenga at uu.nl Fri Oct 9 18:47:35 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Fri Oct 9 18:25:04 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: References: <25828319.post@talk.nabble.com> <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> <25828521.post@talk.nabble.com> Message-ID: <25829017.post@talk.nabble.com> Daniel Peebles wrote: > > I vaguely remember on IRC someone pointing out that the Parsec monad > broke one of the laws. I think return _|_ >> x === _|_ which could be > causing your problem. I may be wrong though. > > Confirmed, working in the parsec monad Prelude Text.Parsec> runP (do {x <- return undefined; return 10}) () "" "" *** Exception: Prelude.undefined In the IO Monad Prelude Text.Parsec> do {x <- return undefined; return 10} 10 Should be fixed. -- View this message in context: http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25829017.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From colin at colina.demon.co.uk Fri Oct 9 18:47:43 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Oct 9 18:25:18 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <75cc17ac0910091511m7669b350s60236450b43320a7@mail.gmail.com> (Gregg Reynolds's message of "Fri\, 9 Oct 2009 17\:11\:47 -0500") References: <1254943082.10848.30.camel@malachite> <814617240910071714u73c4c313v99e8fe6dd602e5a0@mail.gmail.com> <6d942a4a0910080400r75945bdaodd6b2a67e7e8f246@mail.gmail.com> <75cc17ac0910091511m7669b350s60236450b43320a7@mail.gmail.com> Message-ID: >>>>> "Gregg" == Gregg Reynolds writes: Gregg> On Thu, Oct 8, 2009 at 6:08 AM, Colin Paul Adams Gregg> wrote: > >>>>> "George" == George Pollard writes: >> George> I'd also like to note that the canonical pronunciation of George> DSL ends in "-izzle". >> >> Whose canon? >> >> Interestingly, I have always assumed the canonical >> pronunciation of DSSSL was diesel, as JADE stands for JAmes's >> DSSSL Engine. >> >> I don't see why removing extra S-es should shorten the vowel. >> >> Wht vwl? U mst b Englsh. 2 n Amrcn, DSSSL is "dissel"; all >> short vowels. Certainly I am English, and so is James Clark. -- Colin Adams Preston Lancashire From dave at zednenem.com Fri Oct 9 19:25:25 2009 From: dave at zednenem.com (David Menendez) Date: Fri Oct 9 19:02:51 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: <25829017.post@talk.nabble.com> References: <25828319.post@talk.nabble.com> <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> <25828521.post@talk.nabble.com> <25829017.post@talk.nabble.com> Message-ID: <49a77b7a0910091625n5fc065fcw640f672199152810@mail.gmail.com> On Fri, Oct 9, 2009 at 6:47 PM, staafmeister wrote: > > Daniel Peebles wrote: >> >> I vaguely remember on IRC someone pointing out that the Parsec monad >> broke one of the laws. I think return _|_ >> x === _|_ which could be >> causing your problem. I may be wrong though. >> >> > > Confirmed, working in the parsec monad > > Prelude Text.Parsec> runP (do {x <- return undefined; return 10}) () "" "" > *** Exception: Prelude.undefined > > In the IO Monad > Prelude Text.Parsec> do {x <- return undefined; return 10} > 10 > > Should be fixed. It looks like the problem is a strict field in the definition of GenParser (specifically in Reply). From what I can tell, Parsec 3.0.1 should not have this problem. -- Dave Menendez From alexander.dunlap at gmail.com Fri Oct 9 19:41:15 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Fri Oct 9 19:19:02 2009 Subject: [Haskell-cafe] Different semantics in "identical" do statement? In-Reply-To: <49a77b7a0910091625n5fc065fcw640f672199152810@mail.gmail.com> References: <25828319.post@talk.nabble.com> <5F427240-B231-4B97-B165-769C9A006CFC@z.odi.ac> <25828521.post@talk.nabble.com> <25829017.post@talk.nabble.com> <49a77b7a0910091625n5fc065fcw640f672199152810@mail.gmail.com> Message-ID: <57526e770910091641u33b9fa99ta02552c493601d53@mail.gmail.com> On Fri, Oct 9, 2009 at 4:25 PM, David Menendez wrote: > On Fri, Oct 9, 2009 at 6:47 PM, staafmeister wrote: >> >> Daniel Peebles wrote: >>> >>> I vaguely remember on IRC someone pointing out that the Parsec monad >>> broke one of the laws. I think return _|_ >> x === _|_ which could be >>> causing your problem. I may be wrong though. >>> >>> >> >> Confirmed, working in the parsec monad >> >> Prelude Text.Parsec> runP (do {x <- return undefined; return 10}) () "" "" >> *** Exception: Prelude.undefined >> >> In the IO Monad >> Prelude Text.Parsec> do {x <- return undefined; return 10} >> 10 >> >> Should be fixed. > > It looks like the problem is a strict field in the definition of > GenParser (specifically in Reply). From what I can tell, Parsec 3.0.1 > should not have this problem. > > -- > Dave Menendez > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > It works with Parsec 3.0.1 for me. Alex From martijn at van.steenbergen.nl Fri Oct 9 19:44:15 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 9 19:21:48 2009 Subject: [Haskell-cafe] Non-traversable foldables In-Reply-To: <20091009145325.GA7273@soi.city.ac.uk> References: <4ACF4B81.5060404@van.steenbergen.nl> <20091009145325.GA7273@soi.city.ac.uk> Message-ID: <4ACFCACF.6020805@van.steenbergen.nl> Ross Paterson wrote: > On Fri, Oct 09, 2009 at 04:41:05PM +0200, Martijn van Steenbergen wrote: >> Can anyone think of datatypes that are Foldable but not Traversable? > > Set Nice! Thank you all for your answers. Martijn. From martijn at van.steenbergen.nl Fri Oct 9 19:46:52 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 9 19:24:18 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework In-Reply-To: <20091009151234.GC17058@kira.casa> References: <20091008075414.C2760175E1@Adric.metnet.navy.mil> <20091009151234.GC17058@kira.casa> Message-ID: <4ACFCB6C.9090806@van.steenbergen.nl> Felipe Lessa wrote: > which unfortunately needs {-# LANGUAGE RecursiveDo #-} or > some ugliness from mfix But mdo/mfix is awesome! :-( Martijn. From kili at outback.escape.de Fri Oct 9 19:46:09 2009 From: kili at outback.escape.de (Matthias Kilian) Date: Fri Oct 9 19:24:39 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News In-Reply-To: <3ittc5d5db5j15ela5lh1e973dri0bmvpf@4ax.com> References: <4ac77fe1.9753f10a.4fc4.1044@mx.google.com> <3ittc5d5db5j15ela5lh1e973dri0bmvpf@4ax.com> Message-ID: <20091009234609.GA21188@nutty.outback.escape.de> On Fri, Oct 09, 2009 at 05:46:15PM +0900, Benjamin L.Russell wrote: > 2) Instead of posting separately to the Haskell and Haskell-Cafe > mailing lists, it might be better to cross-post, since that way, > readers using newsreaders can have the cross-posted article > automatically marked "read" in the mailing list where it has not been > read. That may be my fault -- I suggested to send out the HWN in separate mails to simplify the sending scripts. Ciao, Kili From lrpalmer at gmail.com Fri Oct 9 19:48:15 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 9 19:25:42 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <20091009200511.GD24096@yoyo> References: <20091009200511.GD24096@yoyo> Message-ID: <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> On Fri, Oct 9, 2009 at 2:05 PM, wrote: > Hi all, > > I think there is something about my use of the IO monad that bites me, > but I am bored of staring at the code, so here you g. ?The code goes > through a list of records and collects the maximum in each record > position. > > > -- test.hs > import Random > import System.Environment (getArgs) > import System.IO (putStr) > > samples :: Int -> Int -> IO [[Double]] > samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 ** 3) Yes, you should not do this in IO. That requires the entire computation to finish before the result can be used. This computation should be pure and lazy. It is possible, using split (and I believe not without it, unless you use mkStdGen), to make a 2D list of randoms where the random generation matches exactly the structure of the list. splits :: (RandomGen g) => Int -> g -> [g] splits 0 _ = [] splits n g = let (g1,g2) = split g in g1 : splits (n-1) g2 samples :: (RandomGen g) => Int -> Int -> g -> [[Double]] samples i j gen = map row (splits i gen) where row g = take j (randomRs (0, 10^9) g) In fact, we could omit all these counts and make an infinite 2D list, which you can cull in the client code. splits :: (RandomGen g) => g -> [g] splits g = let (g1,g2) = split g in g1 : splits g2 samples :: (RandomGen g) => g -> [[Double]] samples = map row . splits where row = randomRs (0, 10^9) I find the latter to be more straightforward and obvious. Maintaining the laziness here is a fairly subtle thing, so study, perturb, try to write it yourself in different ways, etc. > maxima :: [[Double]] -> [Double] > maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) FWIW, This function has a beautiful alternate definition: maxima :: [[Double]] -> [Double] maxima = map maximum . transpose > main = do > ?args <- getArgs > ?x <- samples (read (head args)) 5 > ?putStr . (++ "\n") . show $ maxima x > > > I would expect this to take constant memory (foldr as well as foldl), > but this is what happens: > > > $ ghc -prof --make -O9 -o test test.hs > [1 of 1] Compiling Main ? ? ? ? ? ? ( test.hs, test.o ) > Linking test ... > $ ./test 100 +RTS -p > [9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8] > $ grep 'total alloc' test.prof > ? ? ? ?total alloc = ? ? 744,180 bytes ?(excludes profiling overheads) > $ ./test 10000 +RTS -p > [9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8] > $ grep 'total alloc' test.prof > ? ? ? ?total alloc = ?64,777,692 bytes ?(excludes profiling overheads) > $ ./test 1000000 +RTS -p > Stack space overflow: current size 8388608 bytes. > Use `+RTS -Ksize' to increase it. > $ > > > so... > > does sequence somehow force the entire list of monads into evaluation > before the head of the result list can be used? Yep. IO is completely strict; in some sense the same as "call by value" (don't take the analogy too far). Rule of thumb: keep your distance from it ;-) From brannanster at gmail.com Fri Oct 9 22:40:32 2009 From: brannanster at gmail.com (Patrick Brannan) Date: Fri Oct 9 22:17:59 2009 Subject: [Haskell-cafe] HDBC PostgreSQL In-Reply-To: <4ACFB1EC.1080503@complete.org> References: <4ACFB1EC.1080503@complete.org> Message-ID: No, I was running the following: :module Database.HDBC Database.HDBC.PostgreSQL and the reply was: module `Database.HDBC.PostgreSQL' is not loaded Not sure where to go from here. I'll keep reading. On Fri, Oct 9, 2009 at 4:58 PM, John Goerzen wrote: > Patrick Brannan wrote: >> Prelude> module HDBC HDBC.PostgreSQL >> >> Now I would think that the line "Loading package >> HDBC-postgresql-2.1.0.0 ... linking ... done." means that the module >> is installed correctly, but I still can't execute the :module >> statement. >> >> Does anyone have any ideas about where I should start? It's probably >> something stupid, but I'm a little worn out on searching. > > That's because you're confusing package names with module names. > > I suspect you meant > > :m Database.HDBC Database.HDBC.PostgreSQL > > The API docs on Hackage will list the modules that any package provides. > > -- John > From john at n-brain.net Fri Oct 9 22:53:50 2009 From: john at n-brain.net (John A. De Goes) Date: Fri Oct 9 22:31:19 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <1255104473.28525.6759.camel@localhost> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <1255104473.28525.6759.camel@localhost> Message-ID: <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> On Oct 9, 2009, at 10:07 AM, Duncan Coutts wrote: > On Thu, 2009-10-08 at 09:43 -0600, John A. De Goes wrote: >> Here's a list of libraries that are quite significant to commercial >> software development in 2009, > > For the kinds of applications that you would like to build. The vast majority of applications being built today are web apps. > Certainly having more libs enables more apps and that stuff would > enable > your applications. Fortunately it's not an all-or-nothing thing. There > are plenty of applications we can do now. For the commercial software > I've developed in Haskell, all the libraries I've needed were > available > and sufficiently mature: decent data structures, binary serialisation, > fast random numbers, date/time handling, GUI lib. Sure, there are applications that Haskell is a good fit for. See my other message on the subject. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 From cjs at starling-software.com Sat Oct 10 00:37:52 2009 From: cjs at starling-software.com (Curt Sampson) Date: Sat Oct 10 00:15:20 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> References: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <1255104473.28525.6759.camel@localhost> <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> Message-ID: <20091010043751.GD15834@poetic.cynic.net> On 2009-10-09 20:53 -0600 (Fri), John A. De Goes wrote: > The vast majority of applications being built today are web apps. Right, and the vast majority of these are done in PHP, followed by Ruby and Python. For these languages, the majority of libraries are not native, but C libraries. So this makes me wonder, if cross-platform support is so necessary, why have these PHP, Ruby and Python folks not switched to Java, rather than remain suffering doing their development on Linux boxes? And if libraries are the issue, why would not just creating a SWIG for GHC make all of these people move to Haskell? On 2009-10-08 09:50 -0600 (Thu), John A. De Goes wrote: > I don't dismiss Haskell in business. I only maintain it's a niche > market. I agree it's a nich market, too. So I guess our point of disagreement is that you believe that it's lack of libraries keeping it a nich market, whereas I believe that even if it had libraries out the wazoo like Java (and of similar quality) it would still be a nich market. In other words, having a relatively small quantity of libraries is not a problem. > There are some domains where the infrastructure in more established > languages is minimal, and in such cases, I think Haskell can be more > efficient than those languages. Indeed. I found many domains (including web ones) where I didn't use that infrastructure (such as it was) in Ruby, either. Where there are libraries and frameworks that are considered signficantly better, such as Rails over what's available in PHP, people switching are switching for incremental improvements in what they already do; these are not the kind of people who would ever switch to Haskell. (Rails is beloved basically because it's the bastard spawn of a PHP programmer and web designer; it's certainly not a framework that offers any big difference over doing the same thing in PHP in the traditional style it's always been done there.) > What has moved [from the agile development moment] into mainstream is > unfortunately connected chiefly to agile by virtue of the word itself. > Agile means more than getting software out the door quickly, a fact > many businesses have yet to learn. Right. But that practically defines the mainstream: adopting misinterpretations of truly radical changes so that they don't really have to change. If you want Haskell to *really* go mainstream, that's what you want. If you want libraries for Haskell that will help it go mainstream in that sense, you want bad ones that offer no significant improvement over the bad ones already out there for Java or whatever, and thus provide little productivity improvement. That just seems pointless to me, because those looking for real improvements can't use that sort of stuff. When I need RDBMS access, libraries like Hibernate and Active Record are useless to me, because they force me to work in a stupid manner. For web sites, Rails is useless because again, it deals with stuff in a stupid, unproductive way. This is why I say libraries aren't important. True, it is nice to have good ones that really help you be productive, but not only does Haskell not have them, neither Java nor Ruby do, either. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From ryani.spam at gmail.com Sat Oct 10 01:58:55 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Oct 10 01:36:22 2009 Subject: [Haskell-cafe] Approaches to dependent types (DT) In-Reply-To: <4ACF3682.80000@comp.dit.ie> References: <4ACF3682.80000@comp.dit.ie> Message-ID: <2f9b2d30910092258s5676f5b5r9deefad8c5e202ef@mail.gmail.com> On Fri, Oct 9, 2009 at 6:11 AM, pat browne wrote: > class Named object name | object -> name where > name :: object -> name > > instance (Eq name, Named object name) => Eq object where > object1 == object2 = (name object1) == (name object2) > This is a type-indexed type. On a modern GHC I would write it this way: class Named a where type Name a name :: a -> Name a instance (Named a, Eq (Name a)) => Eq a where o1 == o2 = name o1 == name o2 Although to be honest I wouldn't write it this way at all, because your Eq instance is too general (remember, constraints are not examined when doing typeclass resolution; you are not saying "every type 'a' that is an instance of Named with Eq (Name a) is also an instance of Eq", you are saying "EVERY type 'a' is an instance of Eq, and please add the additional constraints 'Eq (Name a)' and 'Named a'") > My questions are: > Question 1: Is my understanding correct? > Question 2: What flavour of DT is this does this example exhibit? > When you say "Dependent Types", what is usually meant is that types can depend on *values*; for example: data Vector :: Integer -> * -> * where Nil :: Vector 0 a Cons :: a -> Vector n a -> Vector (n+1) a Now you might write this function: zip :: forall a b. (n :: Integer) -> Vector n a -> Vector n b -> Vector n (a,b) zip 0 Nil Nil = Nil zip (n+1) (Cons x xs) (Cons y ys) = Cons (x,y) (zip n xs ys) Notice that the *type* Vector n a depends on the *value* of the argument 'n' passed in. Normally it is only the other way around; values are limited by what type they are. Here we have types being affected by some object's value! -- ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091010/3f086966/attachment.html From ketil at malde.org Sat Oct 10 02:55:34 2009 From: ketil at malde.org (Ketil Malde) Date: Sat Oct 10 02:41:23 2009 Subject: [Haskell-cafe] HDBC PostgreSQL In-Reply-To: (Patrick Brannan's message of "Fri, 9 Oct 2009 14:56:52 -0500") References: Message-ID: <873a5r20wp.fsf@malde.org> Patrick Brannan writes: > Prelude> :module Database.HDBC Database.HDBC.PostgreSQL > module `Database.HDBC.PostgreSQL' is not loaded I wonder if I haven't seen this when I'm in the package's top directory, that is, the current directory contains Database/HDBC/PostgreSQL.hs below it. Cd somewhere else and try again? % cd Work/biohaskell/biolib % ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> :m Bio.Sequence module `Bio.Sequence' is not loaded Prelude> :cd / Prelude> :m Bio.Sequence Prelude Bio.Sequence> -k -- If I haven't seen further, it is by standing in the footprints of giants From dan.doel at gmail.com Sat Oct 10 03:18:38 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sat Oct 10 02:56:08 2009 Subject: [Haskell-cafe] Approaches to dependent types (DT) In-Reply-To: <4ACF3682.80000@comp.dit.ie> References: <4ACF3682.80000@comp.dit.ie> Message-ID: <200910100318.38874.dan.doel@gmail.com> I'll see if I can't gloss over some of the stuff Ryan Ingram already covered. On Friday 09 October 2009 9:11:30 am pat browne wrote: > 2) Types depending on types called parametric and type-indexed types The above distinction in types (and values) depending on types has to do with operations beyond just said dependency. For instance: data List a = Nil | Cons a (List a) Is the definition involving types that depend on other types. And similarly: foo :: forall a. List (List a) foo = Cons Nil Nil is a value that depends on a type. In a language more explicit about type application, one might write: foo@a = Cons@(List a) Nil@a Nil@(List a) So far, these fall in the parametric category, but your example does not: > class Named object name | object -> name where > name :: object -> name Classes in H98 allow you to define non-parametric type->value dependence, and when extended with functional dependencies, or alternately, if we consider type families, we get non-parametric type->type dependence. The difference isn't in what things can depend on what other things, but in what operations are available on types. Specifically, type classes/families are like being able to do case analysis on types, so in the value case: class Foo a where bar :: [a] instance Foo Int where bar = [5] instance Foo Char where bar = "c" can be seen as similar to: bar@c = typecase c of Int -> [5] Char -> "c" And type families are similar on the type-level (it's less clear how functional dependencies fit in, but a one way a -> b is kind of like doing a type-level typecase on a to define b; more accurately you have multiple type parameters, but in each a-branch, b there is exactly one b-branch). Of course, this is an over-simplification, so take it with salt. > I am aware that dependent types can be used to express constraints on > the size of lists and other collections. Technically, you don't need dependent types for this, you just need type-level naturals. But dependent types (or some sufficiently fancy faking thereof) are nice in that you only need to define the naturals once, instead of at both the value and type levels. > The class definition seems to show a > *type-to-type* dependency (object to name), while the instance > definition shows how a name value is used to define equality for objects > which could be interpreted as a *value-to-type* dependency (name to > object) in the opposite direction to that of the class. As Ryan remarked, this is not a value->type dependency. In the instance, you are defining equality for the type 'object' which determines the type 'name' in a type->type dependency. You're then defining equality on values of type 'object' via equality on values of type 'name', via the 'name' function. But that's just value->value dependency which every language of course has. GHC does have ways of faking dependent types, though, with GADTs. GADTs allow you to define data such that matching on constructors refines things in the type system. So, along with the mirroring mentioned above, you can manually set up a value->type dependency that acts like full-on dependent types. For naturals it looks like: -- type level naturals data Zero data Suc n -- value-level GADT indexed by the type-level naturals data Nat n where Zero :: Nat Zero Suc :: Nat n -> Nat (Suc n) -- existential wrapper data Natural where Wrap :: Nat n -> Natural Ryan's zip function would look like: zip :: forall a b n. Nat n -> Vector n a -> Vector n b -> Vector n (a,b) zip Zero Nil Nil = Nil zip (Suc n) (Cons x xs) (Cons y ys) = Cons (x,y) (zip n xs ys) although the 'Nat n' parameter is technically unnecessary in this case. But, in some other function: foo :: forall n. Nat n -> T foo Zero = {- we know type-level n = Zero here -} foo (Suc n) = {- we know type-level n = Suc m for some m here -} Of course, mirroring like the above is kind of a pain and only gets more so the more complex the things you want to mirror are (although this is how, for instance, ATS handles dependent types). There is a preprocessor, SHE, that automates this, though, and lets you write definitions that look like a full- on dependently typed language (among other things). Anyhow, I'll cease rambling for now. Cheers, -- Dan From jfredett at gmail.com Sat Oct 10 03:47:22 2009 From: jfredett at gmail.com (jfredett@gmail.com) Date: Sat Oct 10 03:24:52 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 134 - October 10, 2009 Message-ID: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20091010 Issue 134 - October 10, 2009 --------------------------------------------------------------------------- Welcome to issue 134 of HWN, a newsletter covering developments in the [1]Haskell community. What with Don Stewart's [2]call to [3]arms to lead Haskell to conquest over (E)DSL-land, I've once again tried to highlight discussion of EDSL's this week. Fortunately, it was actually more difficult choosing what _not_ to include this week, since there was so much discussion about DSLs and Syntax extensions (a related notion, in my opinion). Also, this week Bryan O'Sullivan put his Criterion Library to good use on the `text` package, leading to [4]code which is more than ten times faster than before! With all this fantastic news, I won't hold you up any longer, Haskellers, the Haskell Weekly News! Announcements CfPart: FMICS 2009, 2-3 November 2009, Final Call. FMICS 2009 workshop chair [5]announced the final call for particpaction for FMICS 2009 ICFP videos now available. Wouter Swierstra [6]announced the availablity of videos from the International Conference on Functional Programming (ICFP) GPipe-1.0.0: A functional graphics API for programmable GPUs. Tobias Bexelius [7]announced the first release of GPie, a functional graphics API for programmable GPUs. text 0.5, a major revision of the Unicode text library. Bryan O'Sullivan [8]announced a new, major version of the text package. New API features, and huge improvments in speed, as Bryan says, 'Get it while it's fresh on Hackage, folks!' vty-ui 0.2. Jonathan Daugherty [9]announced a new version of the vty-ui package, with fewer bugs, more widgets, and cleaner code due to new more powerful abstractions. htzaar-0.0.1. Tom Hawkins [10]announced HTZAAR, a Haskell implementation of TZAAR Graphalyze-0.8.0.0 and SourceGraph-0.5.5.0. Ivan Lazar Miljenovic [11]announced To keep this editor happy, Ivan released two new packaged in one announcement. This time, he's added Legend support to Graphalyze, but also many new changes to SourceGraph, including a legend so you can see what all the symbols mean, Better color support, and much more. TxtSushi 0.4.0. Keith Sheppard [12]announced a new version of TxtSushi, a set of command line utilities for processing CSV and TSV files. Discussion Applicative do? Philippa Cowderoy [13]asked about a `do` like syntax for Applicative functors. How to add use custom preprocessor in cabal. Bernd Brassel [14]asked how to add a custom preprocessor to the build chain of a cabal file. On DSLs - one last time. Gunther Schmidt [15]summarized his impressions on al the recent discussion of DSLs What is a DSL? Oleg [16]offered some insight into different [17]properties that can be part of a single tagless framework. He also pointed to some slides and other materials such as a website [18]here and slides [19]here about DSL implementations and definitions. What is a DSL? Gunther Schmidt [20]posed the question, 'What is a DSL', and with some further questions added by yours truly, a lively discussion about the definition of a DSL ensued. Finally tagless - stuck with implementation of 'lam'. Gunther Schmidt [21]asked another question about Finally Tagless DSLs and resolving an issue with the implementation of 'lam' Blog noise [22]Haskell news from the [23]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Darcs: [24]darcs weekly news #43. * JP Moresmau: [25]What client for an Haskell Multi Player Game?. * Mikael Vejdemo Johansson (Syzygy-): [26][MATH198] Third lecture is up. * Bryan O'Sullivan: [27]Announcing a major revision of the Haskell text library. * Eric Kow (kowey): [28]darcs hashed-storage work merged (woo!). * David Amos: [29]Symmetries of PG(n,Fq). * The GHC Team: [30]Parallelism /= Concurrency. * >>> Nefigah: [31]Fake World Haskell. Nefigah, a recent addition to the community, has been working through RWH, and is providing some excellent examples. Though, This editor prefers the title 'Real Life Haskell' as opposed to his choice. * Tom Schrijvers: [32]Release 0.6 of Monadic Constraint Programming. * Neil Brown: [33]Concurrency Can Be Deterministic (But The Type System Doesn't Know It). * Clint Moore: [34]Curiously Parallel. * Galois, Inc: [35]Tech Talk: Constructing A Universal Domain for Reasoning About Haskell Datatypes. * Neil Brown: [36]Terminal Concurrency: The Printing Process. * Sean Leather: [37]'Upwards and downwards accumulations on trees' translated into Haskell. * Mikael Vejdemo Johansson (Syzygy-): [38][MATH 198] Second lecture. * Chris Smith: [39]View Patterns as Pattern Matching for Records. * Chris Smith: [40]Playing With Records. * FP Lunch: [41]Left Kan extensions of containers. Quotes of the Week * Baughn: Blum Blum Shub, a PRNG derived from poking around R'Lyeh. * ksf: * lambdabot locks up ksf in a Monad mmmmh it's warm and fuzzy in here. * monochrom: Don't wrap your head around Haskell. Immerse! Wrap Haskell around your head. * chak: ... In other words, FP is inevitable. * robreim: I'm in your base hacking all your lambdas * gwern: RAM is overrated, swap is where it's at ;) * idnar: [to gwern] swap to a ramdisk! ;P About the Haskell Weekly News New editions are posted to [42]the Haskell mailing list as well as to [43]the Haskell Sequence and [44]Planet Haskell. [45]RSS is also available, and headlines appear on [46]haskell.org. To help create new editions of this newsletter, please see the information on [47]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [48]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://www.haskell.org/pipermail/haskell-cafe/2009-October/067203.html 3. http://www.reddit.com/r/haskell/comments/9qk54/haskell_should_own_the_edsl_space_a_call_to_arms/ 4. http://www.serpentine.com/blog/2009/10/09/announcing-a-major-revision-of-the-haskell-text-library/ 5. http://article.gmane.org/gmane.comp.lang.haskell.general/17555 6. http://article.gmane.org/gmane.comp.lang.haskell.general/17552 7. http://article.gmane.org/gmane.comp.lang.haskell.general/17546 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64591 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64529 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64516 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64399 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64301 13. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64616 14. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64558 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64552 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64533 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/ 18. http://dsl09.blogspot.com/ 19. http://dsl09.blogspot.com/2009/07/panel.html 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64474 21. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64343 22. http://planet.haskell.org/ 23. http://haskell.org/haskellwiki/Blog_articles 24. http://blog.darcs.net/2009/10/darcs-weekly-news-43.html 25. http://jpmoresmau.blogspot.com/2009/10/what-client-for-haskell-multi-player.html 26. http://blog.mikael.johanssons.org/archive/2009/10/math198-third-lecture-is-up/ 27. http://www.serpentine.com/blog/2009/10/09/announcing-a-major-revision-of-the-haskell-text-library/ 28. http://koweycode.blogspot.com/2009/10/darcs-hashed-storage-work-merged-woo.html 29. http://haskellformaths.blogspot.com/2009/10/symmetries-of-pgnfq.html 30. http://ghcmutterings.wordpress.com/2009/10/06/parallelism-concurrency/ 31. http://my.life-is-virtual.com/2009/10/07/fake-world-haskell-part-1/ 32. http://tomschrijvers.blogspot.com/2009/10/release-06-of-monadic-constraint.html 33. http://chplib.wordpress.com/2009/10/07/concurrency-can-be-deterministic/ 34. http://www.l2mlogistics.com/2009/10/curiously-parallel.html 35. http://www.galois.com/blog/2009/10/06/huffman-universal/ 36. http://chplib.wordpress.com/2009/10/06/the-printing-process/ 37. http://feedproxy.google.com/~r/splonderzoek/~3/4E8TZPDZ-aM/upwards-and-downwards-accumulations-on.html 38. http://blog.mikael.johanssons.org/archive/2009/10/math-198-second-lecture/ 39. http://cdsmith.wordpress.com/2009/10/04/view-patterns-as-pattern-matching-for-records/ 40. http://cdsmith.wordpress.com/2009/10/03/playing-with-records/ 41. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=237 42. http://www.haskell.org/mailman/listinfo/haskell 43. http://sequence.complete.org/ 44. http://planet.haskell.org/ 45. http://sequence.complete.org/node/feed 46. http://haskell.org/ 47. http://haskell.org/haskellwiki/HWN 48. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From oleg at okmij.org Sat Oct 10 05:36:44 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Sat Oct 10 05:17:56 2009 Subject: [Haskell-cafe] Re: Applicative do? Message-ID: <20091010093644.A1F1A176DE@Adric.metnet.navy.mil> It seems the applicative do is almost identical to the form ML and Scheme has had since the beginning. Perhaps that semantic similarity might inform the syntactic debate. > do a <- f > g > b <- h > pure $ foo a b > > into this: > > (\a b -> pure $ foo a b) <*> (f <*> g *> h) This form, although very similar in appearance to the monadic do, is very different in the scoping of bound identifiers. To me, that is quite unfortunate, greatly increasing confusion. In the monadic do, do x <- e1 y <- e2 e3 the identifier 'x' may appear in e2 and e3. To be more precise, the scope of each bound identifier extends to the rest of the do-block and can be used on the right-hand-side of other bindings in the rest of the block. In the proposed applicative do above, the identifier 'a' may not appear within g and h. Such a significant difference in scoping calls for a different name at the very least; furthermore, it calls for a compiler supports so that errors, such as using the identifier 'a' in 'h' by mistake (common during editing and refactoring) could be reported with an intelligent error message. Also, in monadic-do, it makes sense to bind the same identifier several times, as in do {x <- e1; x <- e2; e3}. It makes little sense doing that in applicative-do, and probably should be disallowed. Bob Atkey wrote: > applicatively > let x = foo > let y = bar > in But OCaml already has the right syntax -- and so does Scheme. That syntax is let. In Scheme expression (let ((x e1) (y e2) (_ e11)) e3) only the expression e3 is in scope of x and y. Emphatically, e2 is not in scope in x; so the value bound to x cannot be used during the evaluation of e2. The expression e11 is evaluated only for its side-effect (underscore is just an identifier, I could've used `dummy'). Again, the expression e11 is not in scope of x and y. All identifiers bound by the let-clause must be distinct. The equivalent OCaml construction is let x = e1 and y = e2 and _ = e11 in e3 If, by mistake, we do mention x or y in e11 (and there are no global binding to x and y), OCaml will report the error about the unbound identifier. It seems the parallel let of Scheme or OCaml fall short of Applicative in one respect: the order of evaluating binding is not specified. If we agreed that the binders of a parallel let must be evaluated in order, we would get exactly the desired `applicative-do'. Perhaps, a better form in OCaml would be let seq x = foo and y = bar in e3 or let x = foo andalso y = bar in e3 Perhaps it may make sense to use the keyword `let' rather than 'do' in Haskell as well? P.S. For completeness, both Scheme and OCaml have the exact equivalent of monadic do. Haskell's do x <- e1 y <- e2 x <- e3 e4 e5 can be written in Scheme as (let* ((x e1) (y e2) (x e3) (_ e4)) e5) and in OCaml as let x = e1 in let y = e2 in let x = e3 in let () = e4 in e5 The latter pattern is very common in OCaml. From nicolas.pouillard at gmail.com Sat Oct 10 06:32:45 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Sat Oct 10 06:09:42 2009 Subject: [Haskell-cafe] Re: Applicative do? In-Reply-To: <20091010093644.A1F1A176DE@Adric.metnet.navy.mil> References: <20091010093644.A1F1A176DE@Adric.metnet.navy.mil> Message-ID: <1255170382-sup-1942@peray> Excerpts from oleg's message of Sat Oct 10 11:36:44 +0200 2009: > > It seems the applicative do is almost identical to the form ML and > Scheme has had since the beginning. Perhaps that semantic similarity > might inform the syntactic debate. > > > do a <- f > > g > > b <- h > > pure $ foo a b > > > > into this: > > > > (\a b -> pure $ foo a b) <*> (f <*> g *> h) > > This form, although very similar in appearance to the monadic do, is > very different in the scoping of bound identifiers. To me, that is > quite unfortunate, greatly increasing confusion. In the monadic do, > do > x <- e1 > y <- e2 > e3 > the identifier 'x' may appear in e2 and e3. To be more precise, the > scope of each bound identifier extends to the rest of the do-block and > can be used on the right-hand-side of other bindings in the rest of > the block. In the proposed applicative do above, the identifier 'a' > may not appear within g and h. Such a significant difference in > scoping calls for a different name at the very least; furthermore, it > calls for a compiler supports so that errors, such as using the > identifier 'a' in 'h' by mistake (common during editing and > refactoring) could be reported with an intelligent error message. I also think that an applicative 'do' will be very confusing and unfortunate. And these are very good arguments. > Also, in monadic-do, it makes sense to bind the same identifier > several times, as in do {x <- e1; x <- e2; e3}. It makes little sense > doing that in applicative-do, and probably should be disallowed. Again good argument. [...] > P.S. For completeness, both Scheme and OCaml have the exact equivalent > of monadic do. Haskell's > do > x <- e1 > y <- e2 > x <- e3 > e4 > e5 > can be written in Scheme as > (let* ((x e1) (y e2) (x e3) (_ e4)) e5) > and in OCaml as > let x = e1 in > let y = e2 in > let x = e3 in > let () = e4 in > e5 > The latter pattern is very common in OCaml. Seriously, are you joking? I agree that the OCaml 'let' denotes both a local binding and the sequence of effects. But the relation with the monadic do is very thin. As you know OCaml always lives in an implicit big IO monad and so its 'let' syntax is a monadic do. However there is plenty of other monads that could use the do notation, and of course you know them well (and there is Camlp4 extensions in OCaml for that). Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr From sergueyz at gmail.com Sat Oct 10 08:30:33 2009 From: sergueyz at gmail.com (Serguey Zefirov) Date: Sat Oct 10 08:07:57 2009 Subject: [Haskell-cafe] What does "mkUsageInfo: internal name?" mean? (ghc 6.10.1, Template Haskell) Message-ID: <600376290910100530p4fe1050fu213eb02be2427ffa@mail.gmail.com> I get a bunch of messages like "mkUsageInfo: internal name? WritebackCmd{tc a1eZY}" while transforming my program using Template Haskell. It displayed for every data type and for every constructor - I generate some instances for my data types. From adhocrocker at gmail.com Sat Oct 10 08:48:47 2009 From: adhocrocker at gmail.com (Johannes) Date: Sat Oct 10 08:26:13 2009 Subject: [Haskell-cafe] Ghci :ctags or hasktags print to standard out instead of file Message-ID: Hi, I want to use Vim with Haskell. Therefore ctags generation is really useful. The TagList plugin for Vim reads the ctags info from the command line instead of from the file. I could not figure out how to make ghci :ctags or hasktasks to print the ctags info to the command line. Is there a way to do that? Any hints? Kind regards Johannes From duncan.coutts at googlemail.com Sat Oct 10 09:04:13 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sat Oct 10 08:41:39 2009 Subject: [Haskell-cafe] HDBC PostgreSQL In-Reply-To: References: Message-ID: <1255179853.28525.6783.camel@localhost> On Fri, 2009-10-09 at 14:56 -0500, Patrick Brannan wrote: > Hello, > > I'm getting back into Haskell after an absence of a few years. I'm in > the process of trying to connect to postgresql with hdbc-postgresql on > a Windows XP box. > > Seemingly, things installed without a problem, but at the command > prompt I get the following: > > Prelude> :module Database.HDBC Database.HDBC.PostgreSQL > module `Database.HDBC.PostgreSQL' is not loaded > > If I run ghci this way with package options here's what I get: > > C:\work\haskell\HDBC-postgresql-2.1.0.0>ghci -package HDBC -package > HDBC-postgresql You are running it from within the source tree of the package itself. Local sources take precedence over ones from packages. So you load the -package HDBC-postgresql, but when you ask GHCi for :module Database.HDBC.PostgreSQL it is looking at the local file Database/HDBC/PostgreSQL.hs, and you cannot switch context to a module that isn't yet loaded, hence the error. If what you want is to load the package, then start in a different directory so the local sources do not get in the way. If what you want is to load the local sources then use :load (:l) rather than :module (:m). The :load command loads local source files. The :module switches context between loaded modules (modules from packages are already loaded). Duncan From duncan.coutts at googlemail.com Sat Oct 10 09:13:55 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sat Oct 10 08:51:28 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> <87skdsfxv1.fsf@gregorycollins.net> Message-ID: <1255180435.28525.6790.camel@localhost> On Fri, 2009-10-09 at 12:22 -0700, Bryan O'Sullivan wrote: > On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins > wrote: > > There's been an open ticket for months; personally I think > this is a job > > for the C preprocessor, but nobody's written a patch yet. > > Is there an open ticket against the network package? Can someone write > a simple standalone repro for me that doesn't require happstack (i.e. > only depends on network)? I have access to a Mac and Johan and I > co-maintain the network package, so in principle this shouldn't be > hard to fix, given enough details and pointers. >From what Gregory and Anton have said, it sounds like the SockAddr6, HostAddress6 constructors should always be available, but that using them with the socket functions should fail at runtime on platforms with no IPv6 support, or when IPv6 support is turned off for some reason. That would probably make it rather easier to have portable programs that can optionally use IPv6. Having to use TH to test at compile time if a constructor is or is not exported from another package is more than a little unpleasant. Duncan From sschuldenzucker at uni-bonn.de Sat Oct 10 10:03:30 2009 From: sschuldenzucker at uni-bonn.de (Steffen Schuldenzucker) Date: Sat Oct 10 09:41:49 2009 Subject: [Haskell-cafe] Ghci :ctags or hasktags print to standard out instead of file In-Reply-To: References: Message-ID: <4AD09432.5050103@uni-bonn.de> > The TagList plugin for Vim reads the ctags info from the command line > instead of from the file. I could not figure out how to make ghci :ctags or > hasktasks to print the ctags info to the command line. Is there a way to > do that? Any hints? Hmm... some shell magic: mkfifo foo cat foo & echo ":ctags foo" | ghci your_file.hs &> /dev/null Not the nice way, of course. Steffen From tobias_bexelius at hotmail.com Sat Oct 10 10:07:57 2009 From: tobias_bexelius at hotmail.com (Tobias Bexelius) Date: Sat Oct 10 09:45:23 2009 Subject: [Haskell-cafe] ANN: Extensions to Vec uploaded (useful for GPipe programs) Message-ID: Hi, I've added two extensions to the Vec package: Vec-Transform and Vec-Boolean. These two packages are more or less essential when programming GPipe programs, but can also be useful for other applications as well. * Vec-Transform provides some 4x4 transform matrices such as perspective projection and rotation. * Vec-Boolean provides Data.Boolan instances for the Vec data types. Cheers /Tobias _________________________________________________________________ Windows Live: H?ll dina v?nner uppdaterade om vad du g?r online. http://www.microsoft.com/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:sv-se:SI_SB_1:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091010/82b53845/attachment.html From tphyahoo at gmail.com Sat Oct 10 11:10:12 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Oct 10 10:47:36 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <20091009200511.GD24096@yoyo> References: <20091009200511.GD24096@yoyo> Message-ID: <910ddf450910100810g412c3d63m4a616eb88e0858b4@mail.gmail.com> I don't know if this counts but how about import Control.Applicative import Control.Monad import Random import Data.List main'' i j = replicateM j $ maximum' <$> (replicateM i . randomRIO $ (0,10^9)) maximum' = foldl1' max t = main'' (10^4) 5 2009/10/9 : > > > Hi all, > > I think there is something about my use of the IO monad that bites me, > but I am bored of staring at the code, so here you g. ?The code goes > through a list of records and collects the maximum in each record > position. > > > -- test.hs > import Random > import System.Environment (getArgs) > import System.IO (putStr) > > samples :: Int -> Int -> IO [[Double]] > samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 ** 3) > > maxima :: [[Double]] -> [Double] > maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) > > main = do > ?args <- getArgs > ?x <- samples (read (head args)) 5 > ?putStr . (++ "\n") . show $ maxima x > > > I would expect this to take constant memory (foldr as well as foldl), > but this is what happens: > > > $ ghc -prof --make -O9 -o test test.hs > [1 of 1] Compiling Main ? ? ? ? ? ? ( test.hs, test.o ) > Linking test ... > $ ./test 100 +RTS -p > [9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8] > $ grep 'total alloc' test.prof > ? ? ? ?total alloc = ? ? 744,180 bytes ?(excludes profiling overheads) > $ ./test 10000 +RTS -p > [9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8] > $ grep 'total alloc' test.prof > ? ? ? ?total alloc = ?64,777,692 bytes ?(excludes profiling overheads) > $ ./test 1000000 +RTS -p > Stack space overflow: current size 8388608 bytes. > Use `+RTS -Ksize' to increase it. > $ > > > so... > > does sequence somehow force the entire list of monads into evaluation > before the head of the result list can be used? ?what can i do to > implement this in constant memory? > > thanks! > matthias > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at googlemail.com Sat Oct 10 11:17:39 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sat Oct 10 11:34:12 2009 Subject: [Haskell-cafe] How to add use custom preprocessor in cabal In-Reply-To: <22AC93B1-C56E-4F03-9A1F-01A84825014F@informatik.uni-kiel.de> References: <22AC93B1-C56E-4F03-9A1F-01A84825014F@informatik.uni-kiel.de> Message-ID: <1255187859.28525.6818.camel@localhost> On Thu, 2009-10-08 at 17:28 +0200, Bernd Brassel wrote: > Hi folks, > > I am trying to integrate my own preprocessor into a cabal build > process. But there are several points that I get stuck with. Could > someone help me, please? > > A simplification of my problem: > I have files "Abc.foo" and each of them should be transformed into > "Abc.hs" by calling function "transform". The resulting "Abc.hs" files > should then be exposed as Haskell library modules. > > 1. Question: How do I tell cabal that the file Abc.foo belongs to the > package? > After reading the User's Guide I had the impression that I should > write something like > > Library > Eposed-Modules: > Abc.foo > > But this leads to a parse error. Use Library Exposed-Modules: Abc It is a list of modules, not files. > Adding a > > Data-Files: > Abc.foo > > to the heading, on the other hand, does not seem to do anything. Right, those are for files that will be installed with the app and used at runtime. > 2. Question: How to add the preprocessor? I have tried > > main = > defaultMainWithHooks > simpleUserHooks{hookedPreProcessors=[("foo",transformation)]} > > transformation :: BuildInfo -> LocalBuildInfo -> PreProcessor That looks right. Here's how to complete it (example taken from the Cabal haddock docs for the PreProcess module): transformation _ _ = PreProcessor { platformIndependent = True, runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> do fail $ "transformation: " ++ inFile ++ " " ++ outFile } and it works fine: runghc Setup.hs build Preprocessing library foo-1.0... Setup.hs: transformation: Abc.foo dist/build/Abc.hs > But under which circumstances will this function be called? Up to now > I have not succeeded in making cabal call this function. It calls it when it goes and looks for the module Abc (ie Abc.hs or .lhs), and since if does not find it, it'll check through the list of preprocessors and go looking for the corresponding files, ie Abc.foo. Duncan From tphyahoo at gmail.com Sat Oct 10 12:33:52 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Oct 10 12:11:16 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> References: <20091009200511.GD24096@yoyo> <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> Message-ID: <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> > Yes, you should not do this in IO. That requires the entire > computation to finish before the result can be used. Not really the entire computation though... whnf, no? main = do let thunks :: IO [Int] thunks = (sequence . replicate (10^6) $ (randomRIO (0,10^9))) putStrLn . show . head =<< thunks -- prints putStrLn . show . last =<< thunks -- overflows In the case of [[num]] from the top post, I belive that would be the first complete list. 2009/10/9 Luke Palmer : > On Fri, Oct 9, 2009 at 2:05 PM, ? wrote: >> Hi all, >> >> I think there is something about my use of the IO monad that bites me, >> but I am bored of staring at the code, so here you g. ?The code goes >> through a list of records and collects the maximum in each record >> position. >> >> >> -- test.hs >> import Random >> import System.Environment (getArgs) >> import System.IO (putStr) >> >> samples :: Int -> Int -> IO [[Double]] >> samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 ** 3) > > Yes, you should not do this in IO. ?That requires the entire > computation to finish before the result can be used. ?This computation > should be pure and lazy. > > It is possible, using split (and I believe not without it, unless you > use mkStdGen), to make a 2D list of randoms where the random > generation matches exactly the structure of the list. > > splits :: (RandomGen g) => Int -> g -> [g] > splits 0 _ = [] > splits n g = let (g1,g2) = split g in g1 : splits (n-1) g2 > > samples :: (RandomGen g) => Int -> Int -> g -> [[Double]] > samples i j gen = map row (splits i gen) > ? ?where > ? ?row g = take j (randomRs (0, 10^9) g) > > In fact, we could omit all these counts and make an infinite 2D list, > which you can cull in the client code. > > splits :: (RandomGen g) => g -> [g] > splits g = let (g1,g2) = split g in g1 : splits g2 > > samples :: (RandomGen g) => g -> [[Double]] > samples = map row . splits > ? ?where > ? ?row = randomRs (0, 10^9) > > I find the latter to be more straightforward and obvious. ?Maintaining > the laziness here is a fairly subtle thing, so study, perturb, try to > write it yourself in different ways, etc. > >> maxima :: [[Double]] -> [Double] >> maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) > > FWIW, This function has a beautiful alternate definition: > > maxima :: [[Double]] -> [Double] > maxima = map maximum . transpose > >> main = do >> ?args <- getArgs >> ?x <- samples (read (head args)) 5 >> ?putStr . (++ "\n") . show $ maxima x >> >> >> I would expect this to take constant memory (foldr as well as foldl), >> but this is what happens: >> >> >> $ ghc -prof --make -O9 -o test test.hs >> [1 of 1] Compiling Main ? ? ? ? ? ? ( test.hs, test.o ) >> Linking test ... >> $ ./test 100 +RTS -p >> [9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8] >> $ grep 'total alloc' test.prof >> ? ? ? ?total alloc = ? ? 744,180 bytes ?(excludes profiling overheads) >> $ ./test 10000 +RTS -p >> [9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8] >> $ grep 'total alloc' test.prof >> ? ? ? ?total alloc = ?64,777,692 bytes ?(excludes profiling overheads) >> $ ./test 1000000 +RTS -p >> Stack space overflow: current size 8388608 bytes. >> Use `+RTS -Ksize' to increase it. >> $ >> >> >> so... >> >> does sequence somehow force the entire list of monads into evaluation >> before the head of the result list can be used? > > Yep. ?IO is completely strict; in some sense the same as "call by > value" (don't take the analogy too far). ?Rule of thumb: keep your > distance from it ;-) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tphyahoo at gmail.com Sat Oct 10 13:07:45 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Oct 10 12:45:09 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> References: <20091009200511.GD24096@yoyo> <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> Message-ID: <910ddf450910101007y72c7450bid28bdec2044be8d@mail.gmail.com> also, looking at the following, it does seem to me that it is sequence that is too strict, and not IO that is to blame, as the Maybe monad has the same behavior: t5IO, t6IO :: IO Int t5Maybe, t6Maybe :: Maybe Int t5 = return . head =<< sequence [return 1, undefined] t6 = return . head =<< return [1,undefined] t5IO = t5 t5Maybe = t5 t6IO = t6 t6Maybe = t6 *Main> t5IO *** Exception: Prelude.undefined *Main> t5Maybe *** Exception: Prelude.undefined *Main> t6IO 1 *Main> t6Maybe Just 1 2009/10/10 Thomas Hartman : >> Yes, you should not do this in IO. ?That requires the entire >> computation to finish before the result can be used. > > Not really the entire computation though... whnf, no? > > main = do > ?let thunks :: IO [Int] > ?thunks = (sequence . replicate (10^6) $ (randomRIO (0,10^9))) > ?putStrLn . show . head =<< thunks -- prints > ?putStrLn . show . last =<< thunks -- overflows > > In the case of [[num]] from the top post, I belive that would be the > first complete list. > > > 2009/10/9 Luke Palmer : >> On Fri, Oct 9, 2009 at 2:05 PM, ? wrote: >>> Hi all, >>> >>> I think there is something about my use of the IO monad that bites me, >>> but I am bored of staring at the code, so here you g. ?The code goes >>> through a list of records and collects the maximum in each record >>> position. >>> >>> >>> -- test.hs >>> import Random >>> import System.Environment (getArgs) >>> import System.IO (putStr) >>> >>> samples :: Int -> Int -> IO [[Double]] >>> samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 ** 3) >> >> Yes, you should not do this in IO. ?That requires the entire >> computation to finish before the result can be used. ?This computation >> should be pure and lazy. >> >> It is possible, using split (and I believe not without it, unless you >> use mkStdGen), to make a 2D list of randoms where the random >> generation matches exactly the structure of the list. >> >> splits :: (RandomGen g) => Int -> g -> [g] >> splits 0 _ = [] >> splits n g = let (g1,g2) = split g in g1 : splits (n-1) g2 >> >> samples :: (RandomGen g) => Int -> Int -> g -> [[Double]] >> samples i j gen = map row (splits i gen) >> ? ?where >> ? ?row g = take j (randomRs (0, 10^9) g) >> >> In fact, we could omit all these counts and make an infinite 2D list, >> which you can cull in the client code. >> >> splits :: (RandomGen g) => g -> [g] >> splits g = let (g1,g2) = split g in g1 : splits g2 >> >> samples :: (RandomGen g) => g -> [[Double]] >> samples = map row . splits >> ? ?where >> ? ?row = randomRs (0, 10^9) >> >> I find the latter to be more straightforward and obvious. ?Maintaining >> the laziness here is a fairly subtle thing, so study, perturb, try to >> write it yourself in different ways, etc. >> >>> maxima :: [[Double]] -> [Double] >>> maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) >> >> FWIW, This function has a beautiful alternate definition: >> >> maxima :: [[Double]] -> [Double] >> maxima = map maximum . transpose >> >>> main = do >>> ?args <- getArgs >>> ?x <- samples (read (head args)) 5 >>> ?putStr . (++ "\n") . show $ maxima x >>> >>> >>> I would expect this to take constant memory (foldr as well as foldl), >>> but this is what happens: >>> >>> >>> $ ghc -prof --make -O9 -o test test.hs >>> [1 of 1] Compiling Main ? ? ? ? ? ? ( test.hs, test.o ) >>> Linking test ... >>> $ ./test 100 +RTS -p >>> [9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8] >>> $ grep 'total alloc' test.prof >>> ? ? ? ?total alloc = ? ? 744,180 bytes ?(excludes profiling overheads) >>> $ ./test 10000 +RTS -p >>> [9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8] >>> $ grep 'total alloc' test.prof >>> ? ? ? ?total alloc = ?64,777,692 bytes ?(excludes profiling overheads) >>> $ ./test 1000000 +RTS -p >>> Stack space overflow: current size 8388608 bytes. >>> Use `+RTS -Ksize' to increase it. >>> $ >>> >>> >>> so... >>> >>> does sequence somehow force the entire list of monads into evaluation >>> before the head of the result list can be used? >> >> Yep. ?IO is completely strict; in some sense the same as "call by >> value" (don't take the analogy too far). ?Rule of thumb: keep your >> distance from it ;-) >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From brannanster at gmail.com Sat Oct 10 14:01:15 2009 From: brannanster at gmail.com (Patrick Brannan) Date: Sat Oct 10 13:38:40 2009 Subject: [Haskell-cafe] HDBC PostgreSQL In-Reply-To: <1255179853.28525.6783.camel@localhost> References: <1255179853.28525.6783.camel@localhost> Message-ID: That did the trick. Everything works perfectly now. Thank you. On Sat, Oct 10, 2009 at 8:04 AM, Duncan Coutts wrote: > On Fri, 2009-10-09 at 14:56 -0500, Patrick Brannan wrote: >> Hello, >> >> I'm getting back into Haskell after an absence of a few years. I'm in >> the process of trying to connect to postgresql with hdbc-postgresql on >> a Windows XP box. >> >> Seemingly, things installed without ?a problem, but at the command >> prompt I get the following: >> >> Prelude> :module Database.HDBC Database.HDBC.PostgreSQL >> module `Database.HDBC.PostgreSQL' is not loaded >> >> If I run ghci this way with package options here's what I get: >> >> C:\work\haskell\HDBC-postgresql-2.1.0.0>ghci -package HDBC -package >> HDBC-postgresql > > > You are running it from within the source tree of the package itself. > Local sources take precedence over ones from packages. So you load the > -package HDBC-postgresql, but when you ask GHCi for :module > Database.HDBC.PostgreSQL it is looking at the local file > Database/HDBC/PostgreSQL.hs, and you cannot switch context to a module > that isn't yet loaded, hence the error. > > If what you want is to load the package, then start in a different > directory so the local sources do not get in the way. If what you want > is to load the local sources then use :load (:l) rather than :module > (:m). The :load command loads local source files. The :module switches > context between loaded modules (modules from packages are already > loaded). > > Duncan > > From list at phaedrusdeinus.org Sat Oct 10 14:11:09 2009 From: list at phaedrusdeinus.org (John Melesky) Date: Sat Oct 10 13:48:58 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <1255104473.28525.6759.camel@localhost> <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> Message-ID: <822AE374-6795-49C3-A4B5-E8910163F8AC@phaedrusdeinus.org> On 2009-10-09, at 7:53 PM, John A. De Goes wrote: > The vast majority of applications being built today are web apps. I'm not convinced this is the case. There are still a great many enterprise desktop apps and mobile apps being built, and the selection bias towards internet-based applications on a mailing list (not to mention the selection bias in blogs, reddit, etc). I'm not saying you're wrong, just that i'd love to see some research into it. -johnnnnnnn From ben.franksen at online.de Sat Oct 10 14:12:03 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sat Oct 10 13:49:53 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: Robert Atkey wrote: > A deep embedding of a parsing DSL (really a context-sensitive grammar > DSL) would look something like the following. I think I saw something > like this in the Agda2 code somewhere, but I stumbled across it when I > was trying to work out what "free" applicative functors were. > > [snip code & explanation] This is extremely cool. I tried to understand in my head how this all works but it just didn't click. It all seemed like magic. Then I went ahead and tried to write a printer for your example grammar and now everything is much clearer. Although I had to fight the type checker quite a bit. This is the generic part: > class Print f where > pr :: f a -> String > instance Print nt => Print (Production nt) where > pr = printProduction > printProduction :: Print nt => Production nt a -> String > printProduction (Stop _) = "" > printProduction (Terminal t (Stop _)) = show t > printProduction (Terminal t p) = show t ++ " " ++ printProduction p > printProduction (NonTerminal nt (Stop _)) = pr nt > printProduction (NonTerminal nt p) = pr nt ++ " " ++ printProduction p > instance Print nt => Print (Rule nt) where > pr (Rule ps) = printPs ps where > printPs [] = "" > printPs [p] = printProduction p > printPs (p:ps) = printProduction p ++ " | " ++ printPs ps > data Any f = forall a. Any (f a) > class Enumerable f where > enumeration :: [Any f] > printRule :: Print nt => (nt a -> Rule nt a) -> nt a -> String > printRule g nt = pr nt ++ " ::= " ++ pr (g nt) > printGrammar :: (Print nt, Enumerable nt) => Grammar nt -> String > printGrammar g = foldr (++) "" (intersperse "\n" rules) where > rules = map printAnyRule enumeration > printAnyRule (Any nt) = printRule g nt We must also provide instances for the concrete types: > instance Enumerable NT where > enumeration = [Any Sum, Any Product, Any Value] > instance Print NT where > pr Value = "Value" > pr Product = "Product" > pr Sum = "Sum" So far so good. This even works... almost ;-) *Main> putStrLn $ printGrammar myGrm Sum ::= Product '+' Sum | Product Product ::= Value '*' Product | Value Value ::= Interrupted. -- had to hit Ctrl-C here When I replace 'posInt' with 'digit' in the rule for Value > myGrm Value = ENum <$> digit > <|> id <$ char '(' <*> nt Sum <* char ')' then the printer terminates just fine: *Main> putStrLn $ printGrammar myGrm Sum ::= Product '+' Sum | Product Product ::= Value '*' Product | Value Value ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '(' Sum ')' I found that the problem is the use of function 'some' from Control.Applicative in > posInt :: Rule nt Int > posInt = fix 1 . reverse <$> some digit where > fix n [] = 0 > fix n (d:ds) = d*n + fix (n*10) ds Since 'some' is defined recursively, this creates an infinite production for numbers that you can neither print nor otherwise analyse in finite time. I can see at least two solutions: One is to parameterize everything over the type of terminals, too. A type suitable for the example would be > data T = TNum Int | TPlus | TMult | TOParen | TCParen and leave token recognition to a separate scanner. The second solution (which I followed) is to break the recursion by adding another nonterminal to the NT type: > data NT a where > Sum :: NT Expr > Product :: NT Expr > Value :: NT Expr > Number :: NT [Int] > Digit :: NT Int > instance Enumerable NT where > enumeration = [Any Sum, Any Product, Any Value, Any Number, Any Digit] > instance Print NT where > pr Sum = "Sum" > pr Product = "Product" > pr Value = "Value" > pr Number = "Number" > pr Digit = "Digit" (Adding Digit /and/ Number is not strictly necessary, but it makes for a nicer presentation.) > myGrm :: Grammar NT > myGrm Sum = ESum <$> nt Product <* char '+' <*> nt Sum > <|> id <$> nt Product > > myGrm Product = EProduct <$> nt Value <* char '*' <*> nt Product > <|> id <$> nt Value > > myGrm Value = (ENum . toNat) <$> nt Number > <|> id <$ char '(' <*> nt Sum <* char ')' > > myGrm Number = extend <$> nt Digit <*> optional (nt Number) > > myGrm Digit = digit > extend d Nothing = [d] > extend d (Just ds) = d:ds > toNat :: [Int] -> Int > toNat = fix 1 . reverse where > fix n [] = 0 > fix n (d:ds) = d*n + fix (n*10) ds With this I get *Main> putStrLn $ printGrammar myGrm Sum ::= Product '+' Sum | Product Product ::= Value '*' Product | Value Value ::= Number | '(' Sum ')' Number ::= Digit Number | Digit Digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' Morale: Be careful with recursive functions when constructing a data representation (e.g. for a deep DSL). You might get an infinite representation which isn't what you want in this case. Oh, and another point: there should be a distinguished "start" nonterminal, otherwise this is not really a grammar. This suggests something like > type Grammar nt a = (nt a, forall b. nt b -> Rule nt b) Next thing I'll try is to transform such a grammar into an actual parser... Cheers Ben From brad.larsen at gmail.com Sat Oct 10 14:47:49 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Sat Oct 10 14:25:13 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> Message-ID: John, On Thu, Oct 8, 2009 at 3:20 PM, John A. De Goes wrote: [...] > JVM is cross-platform, and contains sufficient typing information to > permit one to write something like, "import foreign jvm > java.list.Collection", and have typed access to the whole class and all of > its methods. [...] Having painless Haskell <- Java interoperability would be great. I'm curious though: could it really be so simple as a one-line ``import foreign jvm'' directive? I imagine the purity mismatch between Haskell and Java would be very troublesome. With this hypothetical ``import foreign jvm'' mechanism, what would the be type of imported Java stuff? Would it all be done in IO? The more I think about it, the trickier it seems. Beside the purity mismatch of Haskell and Java, there is an OO/functional mismatch. Haskell / Java interop could be a huge boon; I just have trouble seeing how it could be so simple as a one-line import in your Haskell code. Sincerely, Brad From brad.larsen at gmail.com Sat Oct 10 14:59:37 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Sat Oct 10 14:37:01 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication Message-ID: Suppose we implement type-level naturals as so: data Zero data Succ a Then, we can reflect the type-level naturals into a GADT as so (not sure if ``reflect'' is the right terminology here): data Nat :: * -> * where Zero :: Nat Zero Succ :: Nat a -> Nat (Succ a) Using type families, we can then proceed to define type-level addition: type family Add a b :: * type instance Add Zero b = b type instance Add (Succ a) b = Succ (Add a b) Is there any way to define type-level multiplication without requiring undecidable instances? Sincerely, Brad From svein.ove at aas.no Sat Oct 10 15:02:13 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sat Oct 10 14:39:37 2009 Subject: [Haskell-cafe] Haskell-tan competition Message-ID: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> I say "competition", but.. at the moment I'm only aware of a single Haskell-tan, namely the one at http://www.reddit.com/r/programming/comments/9ss7n/haskell%E3%82%BF%E3%83%B3_%E7%B5%B5/. This cannot stand. Haskell needs an anthropomorphized personification, like any other modern language. Anyway, have any of you seen any others? -- Svein Ove Aas From miguelimo38 at yandex.ru Sat Oct 10 15:22:23 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat Oct 10 14:59:56 2009 Subject: [Haskell-cafe] Haskell-tan competition In-Reply-To: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> References: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> Message-ID: Just a note: Haskell and 'tan' in one sentence, combined with some girlish flavour, makes me think about Audrey TANg. On 10 Oct 2009, at 23:02, Svein Ove Aas wrote: > I say "competition", but.. at the moment I'm only aware of a single > Haskell-tan, namely the one at > http://www.reddit.com/r/programming/comments/9ss7n/haskell%E3%82%BF%E3%83%B3_%E7%B5%B5/ > . > > This cannot stand. Haskell needs an anthropomorphized personification, > like any other modern language. Anyway, have any of you seen any > others? > > -- > Svein Ove Aas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewcoppin at btinternet.com Sat Oct 10 15:53:54 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 10 15:31:16 2009 Subject: [Haskell-cafe] STM in .NET Message-ID: <4AD0E652.7010509@btinternet.com> Apparently they like what they see, and they want it to: http://kskky.info/wiki/STM.NETInFramework4 (I notice that it relies on the user manually annotating anything that isn't safe to revert... This makes me nervous.) From mf-hcafe-15c311f0c at etc-network.de Sat Oct 10 16:06:59 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sat Oct 10 15:59:04 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> References: <20091009200511.GD24096@yoyo> <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> Message-ID: <20091010200659.GA3396@yoyo> On Fri, Oct 09, 2009 at 05:48:15PM -0600, Luke Palmer wrote: > To: mf-hcafe-15c311f0c@etc-network.de > Cc: > From: Luke Palmer > Date: Fri, 9 Oct 2009 17:48:15 -0600 > Subject: Re: [Haskell-cafe] How do I get this done in constant mem? > > On Fri, Oct 9, 2009 at 2:05 PM, wrote: > > Hi all, > > > > I think there is something about my use of the IO monad that bites me, > > but I am bored of staring at the code, so here you g. ?The code goes > > through a list of records and collects the maximum in each record > > position. > > > > > > -- test.hs > > import Random > > import System.Environment (getArgs) > > import System.IO (putStr) > > > > samples :: Int -> Int -> IO [[Double]] > > samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 ** 3) > > Yes, you should not do this in IO. That requires the entire > computation to finish before the result can be used. This computation > should be pure and lazy. Yeah. I also got an excellent reason via private mail why sequence has to be strict: sequence [Maybe 3, Maybe 4, Nothing] = Nothing sequence [Maybe 3, Maybe 4] = Just [3, 4] > > maxima :: [[Double]] -> [Double] > > maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) > > FWIW, This function has a beautiful alternate definition: > > maxima :: [[Double]] -> [Double] > maxima = map maximum . transpose Beautiful indeed! But see below. To be honest, I don't really roll dice, but I am reading from a file. I just thought that randomRIO would be more concise, but now the discussion has gone totally in that direction. Sorry... (-: reading the random number code is more fun, though! Anyhow, I fixed my example to do lazy file processing where before I used readFile (which has to be strict, as I can see now). First, I generate a file with the samples, and then I read that file back (this is the phase I'm interested in, since my real data is not really random numbers). import List import Monad import Random import System.Environment import System.IO samples :: Int -> Int -> IO [[Int]] samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 1000 * 1000 * 1000) maxima :: [[Int]] -> [Int] maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head samples) (tail samples) lazyProcess :: ([[Int]] -> a) -> FilePath -> IO a lazyProcess f fileName = do h <- openFile fileName ReadMode v <- fmap (f . map read . lines) $ hGetContents h v `seq` hClose h return v mkSamples = do args <- getArgs x <- samples (read (head args)) 5 putStr . (++ "\n") . join . intersperse "\n" . map show $ x -- main = mkSamples -- ghc --make -O9 test.hs -o test && ./test 10000 > test.data main = lazyProcess length "test.data" >>= putStr . show lazyProcess (What would be a better name? foldSampleFile perhaps?) is where the IO happens, but the computation is located in a pure function. And yet, only those lines are read that are relevant, and GC on previous lines is allows if the pure function allows it. This program has constant memory usage. Unfortunately, if I replace the length function with implementation of maxima, it explodes again. I tried a few things, such as maxima'3 :: [[Int]] -> [Int] maxima'3 (h:t) = foldr (\ x y -> let v = map (uncurry max) $ zip x y in sum v `seq` v) h t with no luck so far. Tricky business, that! But much more curiously, if I replace maxima'3 in main with this maxima'4 :: [[Int]] -> [Int] maxima'4 = map maximum . transpose (with explicit type signature in both definitions), I get a 'no parse' error from Prelude.read. maxima'3 with the same file gives me a result. How can there be a difference if the type signatures are identical?! Probably something about "don't use Prelude.read" :-)? I have to play with this some more... matthias From mf-hcafe-15c311f0c at etc-network.de Sat Oct 10 16:14:38 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sat Oct 10 15:59:08 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> References: <20091009200511.GD24096@yoyo> <7ca3f0160910091648j52e8ddd1m7df6f92bfa26d7ce@mail.gmail.com> <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> Message-ID: <20091010201438.GB3396@yoyo> On Sat, Oct 10, 2009 at 09:33:52AM -0700, Thomas Hartman wrote: > To: Luke Palmer > Cc: mf-hcafe-15c311f0c@etc-network.de, haskell-cafe@haskell.org > From: Thomas Hartman > Date: Sat, 10 Oct 2009 09:33:52 -0700 > Subject: Re: [Haskell-cafe] How do I get this done in constant mem? > > > Yes, you should not do this in IO. That requires the entire > > computation to finish before the result can be used. > > Not really the entire computation though... whnf, no? In that example, yes. But readFile takes the entire file into a strict String before it gives you the first Char, right? (Sorry again for my misleading code "simplification".) > main = do > let thunks :: IO [Int] > thunks = (sequence . replicate (10^6) $ (randomRIO (0,10^9))) > putStrLn . show . head =<< thunks -- prints > putStrLn . show . last =<< thunks -- overflows Meaning that the entire list needs to be kept? Is there a reason (other than "it's easier to implement and it's legal" :-) why the elements that have been traversed by "last" can't be garbage collected? -m From thomas.dubuisson at gmail.com Sat Oct 10 16:57:56 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sat Oct 10 16:35:21 2009 Subject: [Haskell-cafe] STM in .NET In-Reply-To: <4AD0E652.7010509@btinternet.com> References: <4AD0E652.7010509@btinternet.com> Message-ID: <4c44d90b0910101357s759c5196p8b6cc8c061d9b94d@mail.gmail.com> > (I notice that it relies on the user manually annotating anything that isn't > safe to revert... This makes me nervous.) So due to impurity everything that isn't explicitly annotated is implicitly 'unsafeIOToSTM'? From andrewcoppin at btinternet.com Sat Oct 10 17:01:19 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 10 16:38:40 2009 Subject: [Haskell-cafe] STM in .NET In-Reply-To: <4c44d90b0910101357s759c5196p8b6cc8c061d9b94d@mail.gmail.com> References: <4AD0E652.7010509@btinternet.com> <4c44d90b0910101357s759c5196p8b6cc8c061d9b94d@mail.gmail.com> Message-ID: <4AD0F61F.10204@btinternet.com> Thomas DuBuisson wrote: >> (I notice that it relies on the user manually annotating anything that isn't >> safe to revert... This makes me nervous.) >> > > So due to impurity everything that isn't explicitly annotated is > implicitly 'unsafeIOToSTM'? > It seems that instead of marking the handful of things which are safe to run, you must mark the zoo of things that are not safe to run. Then again, by the looks of it, the compiler can't automatically decide if a given function is safe by which other functions it calls. It's manual. So if you had to manually mark things safe, you'd be marking all day... From dons at galois.com Sat Oct 10 17:11:39 2009 From: dons at galois.com (Don Stewart) Date: Sat Oct 10 16:49:07 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: References: <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> Message-ID: <20091010211139.GA9326@whirlpool.galois.com> brad.larsen: > John, > > On Thu, Oct 8, 2009 at 3:20 PM, John A. De Goes wrote: > [...] > > JVM is cross-platform, and contains sufficient typing information to > > permit one to write something like, "import foreign jvm > > java.list.Collection", and have typed access to the whole class and all of > > its methods. > [...] > > Having painless Haskell <- Java interoperability would be great. I'm > curious though: could it really be so simple as a one-line ``import > foreign jvm'' directive? I imagine the purity mismatch between > Haskell and Java would be very troublesome. No more so than C, surely. We're used to stateful APIs. They're a pain. > With this hypothetical ``import foreign jvm'' mechanism, what would > the be type of imported Java stuff? Would it all be done in IO? > > The more I think about it, the trickier it seems. Beside the purity > mismatch of Haskell and Java, there is an OO/functional mismatch. That's more of an issue. But the prior work has been done. From daniel.is.fischer at web.de Sat Oct 10 17:11:24 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Oct 10 16:51:48 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <20091010201438.GB3396@yoyo> References: <20091009200511.GD24096@yoyo> <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> <20091010201438.GB3396@yoyo> Message-ID: <200910102311.24638.daniel.is.fischer@web.de> Am Samstag 10 Oktober 2009 22:14:38 schrieb mf-hcafe-15c311f0c@etc-network.de: > On Sat, Oct 10, 2009 at 09:33:52AM -0700, Thomas Hartman wrote: > > To: Luke Palmer > > Cc: mf-hcafe-15c311f0c@etc-network.de, haskell-cafe@haskell.org > > From: Thomas Hartman > > Date: Sat, 10 Oct 2009 09:33:52 -0700 > > Subject: Re: [Haskell-cafe] How do I get this done in constant mem? > > > > > Yes, you should not do this in IO. That requires the entire > > > computation to finish before the result can be used. > > > > Not really the entire computation though... whnf, no? > > In that example, yes. But readFile takes the entire file into a > strict String before it gives you the first Char, right? (Sorry again > for my misleading code "simplification".) No, readFile reads the file lazily. > > > main = do > > let thunks :: IO [Int] > > thunks = (sequence . replicate (10^6) $ (randomRIO (0,10^9))) > > putStrLn . show . head =<< thunks -- prints > > putStrLn . show . last =<< thunks -- overflows > > Meaning that the entire list needs to be kept? Is there a reason > (other than "it's easier to implement and it's legal" :-) why the > elements that have been traversed by "last" can't be garbage > collected? > The problem is that the randomRIO isn't done before it's needed. When you ask for the last element of the generated list, you have a stack of nearly one million calls to randomRIO to get it, that overflows the stack. If you insert a stricter version of sequence: {-# LANGUAGE BangPatterns #-} sequence' :: Monad m => [m a] -> m [a] {-# INLINE sequence' #-} sequence' ms = foldr k (return []) ms where k m m' = do { !x <- m; xs <- m'; return (x:xs) } -- ^^^^^^^^^^^ evaluate x now! main = do let thunks = sequence' . replicate (10^6) $ randomRIO (0,10^9) ... it doesn't overflow the stack. But both, sequence and sequence' must construct the entire list, so they use quite a bit of memory. You can keep the memory usage low by using unsafeInterleaveIO. > > > -m From brad.larsen at gmail.com Sat Oct 10 18:22:20 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Sat Oct 10 17:59:44 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <20091010211139.GA9326@whirlpool.galois.com> References: <20090929153550.GG24761@analytic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> <20091010211139.GA9326@whirlpool.galois.com> Message-ID: On Sat, Oct 10, 2009 at 5:11 PM, Don Stewart wrote: > brad.larsen: >> John, >> >> On Thu, Oct 8, 2009 at 3:20 PM, John A. De Goes wrote: >> [...] >> > JVM is cross-platform, and contains sufficient typing information to >> > permit one to write something like, "import foreign jvm >> > java.list.Collection", and have typed access to the whole class and all of >> > its methods. >> [...] >> >> Having painless Haskell <- Java interoperability would be great. ?I'm >> curious though: ?could it really be so simple as a one-line ``import >> foreign jvm'' directive? ?I imagine the purity mismatch between >> Haskell and Java would be very troublesome. > > No more so than C, surely. We're used to stateful APIs. They're a pain. [...] The use of foreign C libraries in Haskell is typically done through definition of lots of boilerplate code, putting a safe, workable Haskell veneer over the library. Right? I got the impression (perhaps wrongly) that John was suggesting a simple one-line ``import foreign jvm LIBRARY'' directive to let you use LIBRARY without writing all that boilerplate. Which would be very convenient, but is rather different than the situation with C libraries. Sincerely, Brad From dons at galois.com Sat Oct 10 18:27:49 2009 From: dons at galois.com (Don Stewart) Date: Sat Oct 10 18:05:17 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: References: <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> <20091010211139.GA9326@whirlpool.galois.com> Message-ID: <20091010222749.GA9523@whirlpool.galois.com> brad.larsen: > On Sat, Oct 10, 2009 at 5:11 PM, Don Stewart wrote: > > brad.larsen: > >> John, > >> > >> On Thu, Oct 8, 2009 at 3:20 PM, John A. De Goes wrote: > >> [...] > >> > JVM is cross-platform, and contains sufficient typing information to > >> > permit one to write something like, "import foreign jvm > >> > java.list.Collection", and have typed access to the whole class and all of > >> > its methods. > >> [...] > >> > >> Having painless Haskell <- Java interoperability would be great. ?I'm > >> curious though: ?could it really be so simple as a one-line ``import > >> foreign jvm'' directive? ?I imagine the purity mismatch between > >> Haskell and Java would be very troublesome. > > > > No more so than C, surely. We're used to stateful APIs. They're a pain. > [...] > > The use of foreign C libraries in Haskell is typically done through > definition of lots of boilerplate code, putting a safe, workable > Haskell veneer over the library. Right? > > I got the impression (perhaps wrongly) that John was suggesting a > simple one-line ``import foreign jvm LIBRARY'' directive to let you > use LIBRARY without writing all that boilerplate. Which would be very > convenient, but is rather different than the situation with C > libraries. > I don't see how this is enough -- any more than the one line imports of C libraries are enough. It'd be a good start. From judah.jacobson at gmail.com Sat Oct 10 21:29:52 2009 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Sat Oct 10 21:07:36 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> Message-ID: <6d74b0d20910101829n4c4ee1aqe544e521f05614d9@mail.gmail.com> On Tue, Oct 6, 2009 at 11:41 AM, Arne Dehli Halvorsen wrote: > This may be a little off-topic, but if someone could help me, I'd be > grateful. > I am trying to get to a working gtk2hs environment in MacOSX Snow Leopard > > I have a Macbook Pro 2.1 with Snow Leopard. > While I had Leopard, I had the Haskell Platform installed, and it worked > fine. > I also had the MacPorts edition of gtk, and compiled gtk2hs by hand. > After I got Snow Leopard, I installed the Haskell Platform. I have made the > necessary changes to make it compile (flags to ghc), and it compiles normal > programs. > I installed the standalone version of the GTK+ platform, and then tried to > compile gtk2hs from /gtk2hs . > ./configure works, but make results in this: > [snip] > /var/folders/G8/G8LY9MSBEGuyatB+JjSWq++++TI/-Tmp-/ghc4162_0/ghc4162_0.split__2870.s:35:0: > ?? ?invalid character '_' in mnemonic > /var/folders/G8/G8LY9MSBEGuyatB+JjSWq++++TI/-Tmp-/ghc4162_0/ghc4162_0.split__2870.s:953:0: > ?? ?FATAL:Symbol L_gtk_misc_get_type$stub already defined. > make[1]: *** [gtk/Graphics/UI/Gtk/Types.o] Error 1 > make: *** [all] Error 2 > I also have gtk installed via macports recently, but I am not sure whether > this makes a difference. > I don't think there is any point currently in trying to go MacPorts all the > way, and install ghc+gtk2hs via MacPorts. > Does anyone have a recipe for getting ghc + gtk2hs + gtk working on MacOSX > Snow Leopard? > Best regards, > Arne D Halvorsen I was able to get gtk2hs working with ghc-6.10.3 (after patching the /usr/bin scripts with -m32) by following the steps from http://www.haskell.org/haskellwiki/Gtk2Hs#Using_the_GTK.2B_OS_X_Framework with one change: call configure for gtk2hs as ./configure --disable-split-objs --disable-gio Hope that helps, -Judah From chak at cse.unsw.edu.au Sun Oct 11 05:24:34 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Sun Oct 11 05:02:03 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication In-Reply-To: References: Message-ID: <1CB4B201-4BC1-49E4-84A2-223BE6DD83B8@cse.unsw.edu.au> Brad Larsen: > Suppose we implement type-level naturals as so: > > data Zero > data Succ a > > Then, we can reflect the type-level naturals into a GADT as so (not > sure if ``reflect'' is the right terminology here): > > data Nat :: * -> * where > Zero :: Nat Zero > Succ :: Nat a -> Nat (Succ a) > > Using type families, we can then proceed to define type-level > addition: > > type family Add a b :: * > type instance Add Zero b = b > type instance Add (Succ a) b = Succ (Add a b) > > Is there any way to define type-level multiplication without requiring > undecidable instances? No, not at the moment. The reasons are explained in the paper "Type Checking with Open Type Functions" (ICFP'08): http://www.cse.unsw.edu.au/~chak/papers/tc-tfs.pdf We want to eventually add closed *type families* to the system (ie, families where you can't add new instances in other modules). For such closed families, we should be able to admit more complex instances without requiring undecidable instances. Manuel From frank at geoinfo.tuwien.ac.at Sun Oct 11 05:41:36 2009 From: frank at geoinfo.tuwien.ac.at (Andrew U. Frank) Date: Sun Oct 11 05:19:01 2009 Subject: [Haskell-cafe] how to determine the dependency versions before packaging and submitting to hackage Message-ID: <200910111141.36557.frank@geoinfo.tuwien.ac.at> i plan to submit a package to hackage. i run it on my machine with a cabal file which has for all dependencies "any" (except for base, where it says >=4.0 -- see previous discussion on haskell-cafe). i am not certain, if my code runs agains any version, but i fear it is too restrictive to say >= "current version", which could exclude too much? testing against all previous versions of the packages seems complicated and very time consuming. what is the advice in this case? thank you andrew From vandijk.roel at gmail.com Sun Oct 11 05:52:35 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Sun Oct 11 05:29:59 2009 Subject: [Haskell-cafe] how to determine the dependency versions before packaging and submitting to hackage In-Reply-To: <200910111141.36557.frank@geoinfo.tuwien.ac.at> References: <200910111141.36557.frank@geoinfo.tuwien.ac.at> Message-ID: Have a look at the Package Versioning Policy: http://haskell.org/haskellwiki/Package_versioning_policy On Sun, Oct 11, 2009 at 11:41 AM, Andrew U. Frank wrote: > i am not certain, if my code runs agains any version, but i fear it is too > restrictive to say >= "current version", which could exclude too much? testing > against all previous versions of the packages seems complicated and very time > consuming. If you assume that the packages you depend on follow the PVP then you can specify a range of versions which should have a stable API. For instance, if you depend on a package A and you build it on you system with A-1.0.2 then you can specify "A >= 1.0.2 && < 1.1". You know it to work with A-1.0.2 and from the PVP you can assume that A's API will not change until A-1.1. The question is which packages follow the PVP. Regards, Roel From magnus at therning.org Sun Oct 11 05:56:40 2009 From: magnus at therning.org (Magnus Therning) Date: Sun Oct 11 05:34:10 2009 Subject: [Haskell-cafe] how to determine the dependency versions before packaging and submitting to hackage In-Reply-To: <200910111141.36557.frank@geoinfo.tuwien.ac.at> References: <200910111141.36557.frank@geoinfo.tuwien.ac.at> Message-ID: <4AD1ABD8.7080202@therning.org> Andrew U. Frank wrote: > i plan to submit a package to hackage. i run it on my machine with a cabal file > which has for all dependencies "any" (except for base, where it says >=4.0 -- > see previous discussion on haskell-cafe). > i am not certain, if my code runs agains any version, but i fear it is too > restrictive to say >= "current version", which could exclude too much? testing > against all previous versions of the packages seems complicated and very time > consuming. > > what is the advice in this case? I usually take a conservative approach, I only put in requirements that I can verify myself. However, I make sure to include all tests and if someone reports that it works with looser requirements then I'm happy to adjust it. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091011/124a3c08/signature.bin From arne.d.h at gmail.com Sun Oct 11 07:12:25 2009 From: arne.d.h at gmail.com (Arne Dehli Halvorsen) Date: Sun Oct 11 06:49:47 2009 Subject: [Haskell-cafe] Snow Leopard, gtk2hs In-Reply-To: <6d74b0d20910101829n4c4ee1aqe544e521f05614d9@mail.gmail.com> References: <203d94090910061141i16d9e71dmc50a05d00b81cb39@mail.gmail.com> <6d74b0d20910101829n4c4ee1aqe544e521f05614d9@mail.gmail.com> Message-ID: <203d94090910110412x6e43c030w5f9152254fbb2d00@mail.gmail.com> On Sun, Oct 11, 2009 at 3:29 AM, Judah Jacobson wrote: > On Tue, Oct 6, 2009 at 11:41 AM, Arne Dehli Halvorsen > wrote: > > Does anyone have a recipe for getting ghc + gtk2hs + gtk working on > MacOSX > > Snow Leopard? > > Best regards, > > Arne D Halvorsen > > I was able to get gtk2hs working with ghc-6.10.3 (after patching the > /usr/bin scripts with -m32) by following the steps from > > http://www.haskell.org/haskellwiki/Gtk2Hs#Using_the_GTK.2B_OS_X_Framework > > with one change: call configure for gtk2hs as > > ./configure --disable-split-objs --disable-gio > Thanks, that seems to have done the trick under ghc 6.10.4 - almost. Current output: adhmac:demo arne$ cd buttonbox adhmac:buttonbox arne$ make ghc --make ButtonBox.hs -o buttonbox [1 of 1] Compiling Main ( ButtonBox.hs, ButtonBox.o ) Linking buttonbox ... ld: warning: duplicate dylib /opt/local/lib/libiconv.2.dylib ld: warning: duplicate dylib /opt/local/lib/libz.1.dylib adhmac:buttonbox arne$ ls ButtonBox.hi ButtonBox.hs ButtonBox.o Makefile buttonbox adhmac:buttonbox arne$ ./buttonbox (buttonbox:42418): Pango-WARNING **: failed to create cairo scaled font, expect ugly output. the offending font is 'Lucida Grande 12' The buttons have boxes instead of letters, due to the font problem. So close... Arne D Halvorsen > > Hope that helps, > -Judah > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091011/4817a8b1/attachment.html From mf-hcafe-15c311f0c at etc-network.de Sun Oct 11 07:18:34 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sun Oct 11 06:56:09 2009 Subject: [Haskell-cafe] How do I get this done in constant mem? In-Reply-To: <200910102311.24638.daniel.is.fischer@web.de> References: <20091009200511.GD24096@yoyo> <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> <20091010201438.GB3396@yoyo> <200910102311.24638.daniel.is.fischer@web.de> Message-ID: <20091011111833.GH3396@yoyo> On Sat, Oct 10, 2009 at 11:11:24PM +0200, Daniel Fischer wrote: > To: haskell-cafe@haskell.org > From: Daniel Fischer > Date: Sat, 10 Oct 2009 23:11:24 +0200 > Subject: Re: [Haskell-cafe] How do I get this done in constant mem? > > Am Samstag 10 Oktober 2009 22:14:38 schrieb mf-hcafe-15c311f0c@etc-network.de: > > On Sat, Oct 10, 2009 at 09:33:52AM -0700, Thomas Hartman wrote: > > > To: Luke Palmer > > > Cc: mf-hcafe-15c311f0c@etc-network.de, haskell-cafe@haskell.org > > > From: Thomas Hartman > > > Date: Sat, 10 Oct 2009 09:33:52 -0700 > > > Subject: Re: [Haskell-cafe] How do I get this done in constant mem? > > > > > > > Yes, you should not do this in IO. That requires the entire > > > > computation to finish before the result can be used. > > > > > > Not really the entire computation though... whnf, no? > > > > In that example, yes. But readFile takes the entire file into a > > strict String before it gives you the first Char, right? (Sorry again > > for my misleading code "simplification".) > > No, readFile reads the file lazily. hm? oh, you are right, now that i fixed all the other problems in my code readFile isn't a problem any more either... (-: (but then how does it know when to close the handle? gotta go read the code i guess.) thanks! -m From patrick.leboutillier at gmail.com Sun Oct 11 08:10:23 2009 From: patrick.leboutillier at gmail.com (Patrick LeBoutillier) Date: Sun Oct 11 07:47:50 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 134 - October 10, 2009 In-Reply-To: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> References: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> Message-ID: Hi, Could/should the Haskell Weekly News be posted to the beginners list as well? I normally don't follow haskell-cafe (too much traffic and generally above my level I must admit...), but I like to follow what's going on in the Haskell community. Patrick On Sat, Oct 10, 2009 at 3:47 AM, wrote: > > --------------------------------------------------------------------------- > Haskell Weekly News > http://sequence.complete.org/hwn/20091010 > Issue 134 - October 10, 2009 > --------------------------------------------------------------------------- > Welcome to issue 134 of HWN, a newsletter covering developments in the > [1]Haskell community. > > What with Don Stewart's [2]call to [3]arms to lead Haskell to conquest > over (E)DSL-land, I've once again tried to highlight discussion of > EDSL's this week. Fortunately, it was actually more difficult choosing > what _not_ to include this week, since there was so much discussion > about DSLs and Syntax extensions (a related notion, in my opinion). > Also, this week Bryan O'Sullivan put his Criterion Library to good use > on the `text` package, leading to [4]code which is more than ten times > faster than before! With all this fantastic news, I won't hold you up > any longer, Haskellers, the Haskell Weekly News! > > Announcements > > CfPart: FMICS 2009, 2-3 November 2009, Final Call. FMICS 2009 workshop > chair [5]announced the final call for particpaction for FMICS 2009 > > ICFP videos now available. Wouter Swierstra [6]announced the > availablity of videos from the International Conference on Functional > Programming (ICFP) > > GPipe-1.0.0: A functional graphics API for programmable GPUs. Tobias > Bexelius [7]announced the first release of GPie, a functional graphics > API for programmable GPUs. > > text 0.5, a major revision of the Unicode text library. Bryan > O'Sullivan [8]announced a new, major version of the text package. New > API features, and huge improvments in speed, as Bryan says, 'Get it > while it's fresh on Hackage, folks!' > > vty-ui 0.2. Jonathan Daugherty [9]announced a new version of the vty-ui > package, with fewer bugs, more widgets, and cleaner code due to new > more powerful abstractions. > > htzaar-0.0.1. Tom Hawkins [10]announced HTZAAR, a Haskell > implementation of TZAAR > > Graphalyze-0.8.0.0 and SourceGraph-0.5.5.0. Ivan Lazar Miljenovic > [11]announced To keep this editor happy, Ivan released two new packaged > in one announcement. This time, he's added Legend support to > Graphalyze, but also many new changes to SourceGraph, including a > legend so you can see what all the symbols mean, Better color support, > and much more. > > TxtSushi 0.4.0. Keith Sheppard [12]announced a new version of TxtSushi, > a set of command line utilities for processing CSV and TSV files. > > Discussion > > Applicative do? Philippa Cowderoy [13]asked about a `do` like syntax > for Applicative functors. > > How to add use custom preprocessor in cabal. Bernd Brassel [14]asked > how to add a custom preprocessor to the build chain of a cabal file. > > On DSLs - one last time. Gunther Schmidt [15]summarized his impressions > on al the recent discussion of DSLs > > What is a DSL? Oleg [16]offered some insight into different > [17]properties that can be part of a single tagless framework. He also > pointed to some slides and other materials such as a website [18]here > and slides [19]here about DSL implementations and definitions. > > What is a DSL? Gunther Schmidt [20]posed the question, 'What is a DSL', > and with some further questions added by yours truly, a lively > discussion about the definition of a DSL ensued. > > Finally tagless - stuck with implementation of 'lam'. Gunther Schmidt > [21]asked another question about Finally Tagless DSLs and resolving an > issue with the implementation of 'lam' > > Blog noise > > [22]Haskell news from the [23]blogosphere. Blog posts from people new > to the Haskell community are marked with >>>, be sure to welcome them! > * Darcs: [24]darcs weekly news #43. > * JP Moresmau: [25]What client for an Haskell Multi Player Game?. > * Mikael Vejdemo Johansson (Syzygy-): [26][MATH198] Third lecture is > up. > * Bryan O'Sullivan: [27]Announcing a major revision of the Haskell > text library. > * Eric Kow (kowey): [28]darcs hashed-storage work merged (woo!). > * David Amos: [29]Symmetries of PG(n,Fq). > * The GHC Team: [30]Parallelism /= Concurrency. > * >>> Nefigah: [31]Fake World Haskell. Nefigah, a recent addition to > the community, has been working through RWH, and is providing some > excellent examples. Though, This editor prefers the title 'Real > Life Haskell' as opposed to his choice. > * Tom Schrijvers: [32]Release 0.6 of Monadic Constraint Programming. > * Neil Brown: [33]Concurrency Can Be Deterministic (But The Type > System Doesn't Know It). > * Clint Moore: [34]Curiously Parallel. > * Galois, Inc: [35]Tech Talk: Constructing A Universal Domain for > Reasoning About Haskell Datatypes. > * Neil Brown: [36]Terminal Concurrency: The Printing Process. > * Sean Leather: [37]'Upwards and downwards accumulations on trees' > translated into Haskell. > * Mikael Vejdemo Johansson (Syzygy-): [38][MATH 198] Second lecture. > * Chris Smith: [39]View Patterns as Pattern Matching for Records. > * Chris Smith: [40]Playing With Records. > * FP Lunch: [41]Left Kan extensions of containers. > > Quotes of the Week > > * Baughn: Blum Blum Shub, a PRNG derived from poking around R'Lyeh. > * ksf: * lambdabot locks up ksf in a Monad mmmmh it's warm and > fuzzy in here. > * monochrom: Don't wrap your head around Haskell. Immerse! Wrap > Haskell around your head. > * chak: ... In other words, FP is inevitable. > * robreim: I'm in your base hacking all your lambdas > * gwern: RAM is overrated, swap is where it's at ;) > * idnar: [to gwern] swap to a ramdisk! ;P > > About the Haskell Weekly News > > New editions are posted to [42]the Haskell mailing list as well as to > [43]the Haskell Sequence and [44]Planet Haskell. [45]RSS is also > available, and headlines appear on [46]haskell.org. > > To help create new editions of this newsletter, please see the > information on [47]how to contribute. Send stories to jfredett . at . > gmail . dot . com. The darcs repository is available at darcs get > [48]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . > > References > > 1. http://haskell.org/ > 2. > http://www.haskell.org/pipermail/haskell-cafe/2009-October/067203.html > 3. > http://www.reddit.com/r/haskell/comments/9qk54/haskell_should_own_the_edsl_space_a_call_to_arms/ > 4. > http://www.serpentine.com/blog/2009/10/09/announcing-a-major-revision-of-the-haskell-text-library/ > 5. http://article.gmane.org/gmane.comp.lang.haskell.general/17555 > 6. http://article.gmane.org/gmane.comp.lang.haskell.general/17552 > 7. http://article.gmane.org/gmane.comp.lang.haskell.general/17546 > 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64591 > 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64529 > 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64516 > 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64399 > 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64301 > 13. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64616 > 14. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64558 > 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64552 > 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64533 > 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/ > 18. http://dsl09.blogspot.com/ > 19. http://dsl09.blogspot.com/2009/07/panel.html > 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64474 > 21. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64343 > 22. http://planet.haskell.org/ > 23. http://haskell.org/haskellwiki/Blog_articles > 24. http://blog.darcs.net/2009/10/darcs-weekly-news-43.html > 25. > http://jpmoresmau.blogspot.com/2009/10/what-client-for-haskell-multi-player.html > 26. > http://blog.mikael.johanssons.org/archive/2009/10/math198-third-lecture-is-up/ > 27. > http://www.serpentine.com/blog/2009/10/09/announcing-a-major-revision-of-the-haskell-text-library/ > 28. > http://koweycode.blogspot.com/2009/10/darcs-hashed-storage-work-merged-woo.html > 29. http://haskellformaths.blogspot.com/2009/10/symmetries-of-pgnfq.html > 30. > http://ghcmutterings.wordpress.com/2009/10/06/parallelism-concurrency/ > 31. http://my.life-is-virtual.com/2009/10/07/fake-world-haskell-part-1/ > 32. > http://tomschrijvers.blogspot.com/2009/10/release-06-of-monadic-constraint.html > 33. > http://chplib.wordpress.com/2009/10/07/concurrency-can-be-deterministic/ > 34. http://www.l2mlogistics.com/2009/10/curiously-parallel.html > 35. http://www.galois.com/blog/2009/10/06/huffman-universal/ > 36. http://chplib.wordpress.com/2009/10/06/the-printing-process/ > 37. > http://feedproxy.google.com/~r/splonderzoek/~3/4E8TZPDZ-aM/upwards-and-downwards-accumulations-on.html > 38. > http://blog.mikael.johanssons.org/archive/2009/10/math-198-second-lecture/ > 39. > http://cdsmith.wordpress.com/2009/10/04/view-patterns-as-pattern-matching-for-records/ > 40. http://cdsmith.wordpress.com/2009/10/03/playing-with-records/ > 41. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=237 > 42. http://www.haskell.org/mailman/listinfo/haskell > 43. http://sequence.complete.org/ > 44. http://planet.haskell.org/ > 45. http://sequence.complete.org/node/feed > 46. http://haskell.org/ > 47. http://haskell.org/haskellwiki/HWN > 48. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ===================== Patrick LeBoutillier Rosem?re, Qu?bec, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091011/334c0df2/attachment.html From patrick.leboutillier at gmail.com Sun Oct 11 08:25:18 2009 From: patrick.leboutillier at gmail.com (Patrick LeBoutillier) Date: Sun Oct 11 08:02:41 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <20091010211139.GA9326@whirlpool.galois.com> References: <20090929153550.GG24761@analytic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> <20091010211139.GA9326@whirlpool.galois.com> Message-ID: Don, > > > Having painless Haskell <- Java interoperability would be great. I'm > > curious though: could it really be so simple as a one-line ``import > > foreign jvm'' directive? I imagine the purity mismatch between > > Haskell and Java would be very troublesome. > > No more so than C, surely. We're used to stateful APIs. They're a pain. > > > > With this hypothetical ``import foreign jvm'' mechanism, what would > > the be type of imported Java stuff? Would it all be done in IO? > > > > The more I think about it, the trickier it seems. Beside the purity > > mismatch of Haskell and Java, there is an OO/functional mismatch. > > That's more of an issue. But the prior work has been done. > Do you have any references to this work? I'm quite interested in this, both from a Haskell perpective (although I'm still a beginner) and from being the author of a Perl <-> Java interoperability module (see http://search.cpan.org/~patl/Inline-Java-0.52/). Thanks, Patrick _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ===================== Patrick LeBoutillier Rosem?re, Qu?bec, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091011/f1be2e01/attachment-0001.html From max.rabkin at gmail.com Sun Oct 11 08:31:22 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sun Oct 11 08:09:04 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 134 - October 10, 2009 In-Reply-To: References: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> Message-ID: Why don't you subscribe to haskell? It's much lower volume, and I think it's a better option than taking -beginners off-topic. --Max On Sun, Oct 11, 2009 at 2:10 PM, Patrick LeBoutillier wrote: > Hi, > > Could/should the Haskell Weekly News be posted to the beginners list as > well? > > I normally don't follow haskell-cafe (too much traffic and generally above > my level I must admit...), but I like to follow what's going on in the > Haskell community. > > > Patrick From ben.franksen at online.de Sun Oct 11 08:17:57 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sun Oct 11 08:28:42 2009 Subject: [Haskell-cafe] Re: How do I get this done in constant mem? References: <20091009200511.GD24096@yoyo> <910ddf450910100933j3ef20555xf6f7fdc50edf7f89@mail.gmail.com> <20091010201438.GB3396@yoyo> <200910102311.24638.daniel.is.fischer@web.de> <20091011111833.GH3396@yoyo> Message-ID: mf-hcafe-15c311f0c@etc-network.de wrote: > On Sat, Oct 10, 2009 at 11:11:24PM +0200, Daniel Fischer wrote: >> No, readFile reads the file lazily. > > hm? oh, you are right, now that i fixed all the other problems in my > code readFile isn't a problem any more either... (-: > > (but then how does it know when to close the handle? gotta go read > the code i guess.) It is somewhat documented, see http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html or http://www.haskell.org/onlinelibrary/io.html, section 21.2.2 Semi-Closed Handles: "[...] A semi-closed handle becomes closed: * if hClose is applied to it; * if an I/O error occurs when reading an item from the handle; * or once the entire contents of the handle has been read." It is not stated here that the file /immediately/ gets closed after the last byte has been read. Does that mean implementations are free to postpone closing (e.g. until the next GC cycle)? Cheers Ben From jwlato at gmail.com Sun Oct 11 08:58:54 2009 From: jwlato at gmail.com (John Lato) Date: Sun Oct 11 08:36:16 2009 Subject: [Haskell-cafe] Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) Message-ID: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> For anyone writing introductions to generic programming, take this as a plea from Haskellers everywhere. If one of the RWH authors can't understand how to make use of these techniques, what hope do the rest of us have? John Lato P.S. Some might wryly note that I'm the maintainer of a package which is also known for incomprehensible documentation. To which I would reply that our effort is much newer, I consider it a problem, and it's being worked on, contrasted to the state of GP where similarly impenetrable documentation has been and continues to be the norm. > > From: "Bryan O'Sullivan" > > I think maybe someone else will have to take a crack at a Data instance for > Text, because the documentation for Data.Data is not written in English. In > its syntax and structure, it closely hews to what we think of as English, > but it is the kind of documentation that can only be understood by someone > who already knows what it is going to say. > > This is an exemplar of my experience with the cottage industry of generic > programming in Haskell: I'd really quite like to use the stuff, but for > goodness's sake, o beloved researchers, please aim your expository papers at > non-specialists once in a while. An endless chain of papers of the form "my > technique, which you won't understand, is better than this other technique, > which you haven't read about and won't anyway understand, in subtle ways > that you won't understand" does not feel to me like progress. > > Yours in some misery and frustration, > Bryan. From iainspeed at gmail.com Sun Oct 11 09:23:17 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Sun Oct 11 09:01:29 2009 Subject: [Haskell-cafe] a library for control of terminal driver modes? Message-ID: <8E502089-031B-4938-BE79-B3EA057D1686@gmail.com> I'm looking for a library like Perl's Term-Readkey, so that I can turn on and off the echo for secure password input from a terminal. Anyone know which library I need to use for this? Iain From iainspeed at gmail.com Sun Oct 11 09:55:10 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Sun Oct 11 09:33:25 2009 Subject: [Haskell-cafe] Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) In-Reply-To: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> References: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> Message-ID: <09D9114B-A61B-4685-99EC-0CB8B0A554DF@gmail.com> On 11 Oct 2009, at 13:58, John Lato wrote: > For anyone writing introductions to generic programming, take this as > a plea from Haskellers everywhere. If one of the RWH authors can't > understand how to make use of these techniques, what hope do the rest > of us have? > > John Lato > > P.S. Some might wryly note that I'm the maintainer of a package which > is also known for incomprehensible documentation. To which I would > reply that our effort is much newer, I consider it a problem, and it's > being worked on, contrasted to the state of GP where similarly > impenetrable documentation has been and continues to be the norm. > You could say that about most documentation (for Haskell and beyond). Apparently, programmers like programming better than documenting. The effect of this is that less people use their programming, making their efforts redundant. Silly really, considering programmers are (allegedly:) intelligent. Iain From nccb2 at kent.ac.uk Sun Oct 11 09:58:51 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Sun Oct 11 09:36:18 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: References: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> Message-ID: <4AD1E49B.6000406@kent.ac.uk> Bryan O'Sullivan wrote: > On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw > wrote: > > > What are the chances of seeing a, instance Data Text, some day? > > > I might as well follow up here, since I've sent Jeremy a couple of > messages on this subject. > > I think maybe someone else will have to take a crack at a Data > instance for Text, because the documentation for Data.Data is not > written in English. In its syntax and structure, it closely hews to > what we think of as English, but it is the kind of documentation that > can only be understood by someone who already knows what it is going > to say. > > This is an exemplar of my experience with the cottage industry of > generic programming in Haskell: I'd really quite like to use the > stuff, but for goodness's sake, o beloved researchers, please aim your > expository papers at non-specialists once in a while. An endless chain > of papers of the form "my technique, which you won't understand, is > better than this other technique, which you haven't read about and > won't anyway understand, in subtle ways that you won't understand" > does not feel to me like progress. Data is probably the most complex bit of Haskell I've seen, and pretty much needs a full paper to have an idea of what's going on, so I'm not sure it's a typical piece of Haskell (nor even a typical bit of generic programming) to pick on. I had a crack at a simple proper Data instance, and got as far as needing a Data instance for ByteString#, accompanied by an error I don't fully understand, but I think is telling me that things involving magic hashes are magic: Data/Text/Array.hs:104:35: Couldn't match kind `#' against `*' When matching the kinds of `ByteArray# :: #' and `d :: *' Expected type: d Inferred type: ByteArray# In the first argument of `z', namely `Array' What is the Data instance required for here, exactly? Is it generic transformations, or for generic serialisation (or some other need)? It may be possible to fake the Data instance to cover the needed aspects. I'm not in favour of the boxing/unboxing that Jeremy suggested, because Text doesn't really contain a String, but I'm also not sure that a real Data instance (exposing all the innards) is that great either. By the way: text-0.5 doesn't build for me on my GHC 6.8.2 system with base-3, mainly because you are assuming the class-based exception mechanism from base-4 in the Data.Text.Encoding.Error module, without using the extensible-exceptions package. I'm happy to knock up some patches that fixes it, if you still want to support that configuration? Thanks, Neil. From andrewcoppin at btinternet.com Sun Oct 11 10:30:43 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 11 10:08:01 2009 Subject: [Haskell-cafe] a library for control of terminal driver modes? In-Reply-To: <8E502089-031B-4938-BE79-B3EA057D1686@gmail.com> References: <8E502089-031B-4938-BE79-B3EA057D1686@gmail.com> Message-ID: <4AD1EC13.7000409@btinternet.com> Iain Barnett wrote: > I'm looking for a library like Perl's Term-Readkey, so that I can turn > on and off the echo for secure password input from a terminal. Anyone > know which library I need to use for this? The package ansi-terminal allows you to do various things to the terminal; I think it might include turning local echo on/off. Alternatively, there was an announcement recently about a text-mode UI package, which might do what you want. (I don't recall the name...) From jfredett at gmail.com Sun Oct 11 11:19:35 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sun Oct 11 10:57:00 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 134 - October 10, 2009 In-Reply-To: References: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> Message-ID: <4055ED6E-9503-425B-8DAA-53C9B188FFB4@gmail.com> I'm happy to tack it on to the sendout, but as others have mentioned, subscription to haskell-general (to use GManes nomenclature) is probably the better option. -beginners, iirc, is principally for questions, not community content. Is this the consensus over there? I'll do whatever you folks decide on... /Joe On Oct 11, 2009, at 8:10 AM, Patrick LeBoutillier wrote: > Hi, > > Could/should the Haskell Weekly News be posted to the beginners list > as well? > > I normally don't follow haskell-cafe (too much traffic and generally > above my level I must admit...), but I like to follow what's going > on in the Haskell community. > > > Patrick > > On Sat, Oct 10, 2009 at 3:47 AM, wrote: > > --------------------------------------------------------------------------- > Haskell Weekly News > http://sequence.complete.org/hwn/20091010 > Issue 134 - October 10, 2009 > --------------------------------------------------------------------------- > Welcome to issue 134 of HWN, a newsletter covering developments in > the > [1]Haskell community. > > What with Don Stewart's [2]call to [3]arms to lead Haskell to > conquest > over (E)DSL-land, I've once again tried to highlight discussion of > EDSL's this week. Fortunately, it was actually more difficult > choosing > what _not_ to include this week, since there was so much discussion > about DSLs and Syntax extensions (a related notion, in my opinion). > Also, this week Bryan O'Sullivan put his Criterion Library to good > use > on the `text` package, leading to [4]code which is more than ten > times > faster than before! With all this fantastic news, I won't hold you > up > any longer, Haskellers, the Haskell Weekly News! > > Announcements > > CfPart: FMICS 2009, 2-3 November 2009, Final Call. FMICS 2009 > workshop > chair [5]announced the final call for particpaction for FMICS 2009 > > ICFP videos now available. Wouter Swierstra [6]announced the > availablity of videos from the International Conference on > Functional > Programming (ICFP) > > GPipe-1.0.0: A functional graphics API for programmable GPUs. Tobias > Bexelius [7]announced the first release of GPie, a functional > graphics > API for programmable GPUs. > > text 0.5, a major revision of the Unicode text library. Bryan > O'Sullivan [8]announced a new, major version of the text package. > New > API features, and huge improvments in speed, as Bryan says, 'Get it > while it's fresh on Hackage, folks!' > > vty-ui 0.2. Jonathan Daugherty [9]announced a new version of the > vty-ui > package, with fewer bugs, more widgets, and cleaner code due to new > more powerful abstractions. > > htzaar-0.0.1. Tom Hawkins [10]announced HTZAAR, a Haskell > implementation of TZAAR > > Graphalyze-0.8.0.0 and SourceGraph-0.5.5.0. Ivan Lazar Miljenovic > [11]announced To keep this editor happy, Ivan released two new > packaged > in one announcement. This time, he's added Legend support to > Graphalyze, but also many new changes to SourceGraph, including a > legend so you can see what all the symbols mean, Better color > support, > and much more. > > TxtSushi 0.4.0. Keith Sheppard [12]announced a new version of > TxtSushi, > a set of command line utilities for processing CSV and TSV files. > > Discussion > > Applicative do? Philippa Cowderoy [13]asked about a `do` like syntax > for Applicative functors. > > How to add use custom preprocessor in cabal. Bernd Brassel [14]asked > how to add a custom preprocessor to the build chain of a cabal file. > > On DSLs - one last time. Gunther Schmidt [15]summarized his > impressions > on al the recent discussion of DSLs > > What is a DSL? Oleg [16]offered some insight into different > [17]properties that can be part of a single tagless framework. He > also > pointed to some slides and other materials such as a website > [18]here > and slides [19]here about DSL implementations and definitions. > > What is a DSL? Gunther Schmidt [20]posed the question, 'What is a > DSL', > and with some further questions added by yours truly, a lively > discussion about the definition of a DSL ensued. > > Finally tagless - stuck with implementation of 'lam'. Gunther > Schmidt > [21]asked another question about Finally Tagless DSLs and > resolving an > issue with the implementation of 'lam' > > Blog noise > > [22]Haskell news from the [23]blogosphere. Blog posts from people > new > to the Haskell community are marked with >>>, be sure to welcome > them! > * Darcs: [24]darcs weekly news #43. > * JP Moresmau: [25]What client for an Haskell Multi Player Game?. > * Mikael Vejdemo Johansson (Syzygy-): [26][MATH198] Third > lecture is > up. > * Bryan O'Sullivan: [27]Announcing a major revision of the Haskell > text library. > * Eric Kow (kowey): [28]darcs hashed-storage work merged (woo!). > * David Amos: [29]Symmetries of PG(n,Fq). > * The GHC Team: [30]Parallelism /= Concurrency. > * >>> Nefigah: [31]Fake World Haskell. Nefigah, a recent > addition to > the community, has been working through RWH, and is providing > some > excellent examples. Though, This editor prefers the title 'Real > Life Haskell' as opposed to his choice. > * Tom Schrijvers: [32]Release 0.6 of Monadic Constraint > Programming. > * Neil Brown: [33]Concurrency Can Be Deterministic (But The Type > System Doesn't Know It). > * Clint Moore: [34]Curiously Parallel. > * Galois, Inc: [35]Tech Talk: Constructing A Universal Domain for > Reasoning About Haskell Datatypes. > * Neil Brown: [36]Terminal Concurrency: The Printing Process. > * Sean Leather: [37]'Upwards and downwards accumulations on trees' > translated into Haskell. > * Mikael Vejdemo Johansson (Syzygy-): [38][MATH 198] Second > lecture. > * Chris Smith: [39]View Patterns as Pattern Matching for Records. > * Chris Smith: [40]Playing With Records. > * FP Lunch: [41]Left Kan extensions of containers. > > Quotes of the Week > > * Baughn: Blum Blum Shub, a PRNG derived from poking around > R'Lyeh. > * ksf: * lambdabot locks up ksf in a Monad mmmmh it's warm > and > fuzzy in here. > * monochrom: Don't wrap your head around Haskell. Immerse! Wrap > Haskell around your head. > * chak: ... In other words, FP is inevitable. > * robreim: I'm in your base hacking all your lambdas > * gwern: RAM is overrated, swap is where it's at ;) > * idnar: [to gwern] swap to a ramdisk! ;P > > About the Haskell Weekly News > > New editions are posted to [42]the Haskell mailing list as well as > to > [43]the Haskell Sequence and [44]Planet Haskell. [45]RSS is also > available, and headlines appear on [46]haskell.org. > > To help create new editions of this newsletter, please see the > information on [47]how to contribute. Send stories to jfredett . > at . > gmail . dot . com. The darcs repository is available at darcs get > [48]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . > > References > > 1. http://haskell.org/ > 2. http://www.haskell.org/pipermail/haskell-cafe/2009-October/067203.html > 3. http://www.reddit.com/r/haskell/comments/9qk54/haskell_should_own_the_edsl_space_a_call_to_arms/ > 4. http://www.serpentine.com/blog/2009/10/09/announcing-a-major-revision-of-the-haskell-text-library/ > 5. http://article.gmane.org/gmane.comp.lang.haskell.general/17555 > 6. http://article.gmane.org/gmane.comp.lang.haskell.general/17552 > 7. http://article.gmane.org/gmane.comp.lang.haskell.general/17546 > 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64591 > 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64529 > 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64516 > 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64399 > 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64301 > 13. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64616 > 14. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64558 > 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64552 > 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64533 > 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/ > 18. http://dsl09.blogspot.com/ > 19. http://dsl09.blogspot.com/2009/07/panel.html > 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64474 > 21. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64343 > 22. http://planet.haskell.org/ > 23. http://haskell.org/haskellwiki/Blog_articles > 24. http://blog.darcs.net/2009/10/darcs-weekly-news-43.html > 25. http://jpmoresmau.blogspot.com/2009/10/what-client-for-haskell-multi-player.html > 26. http://blog.mikael.johanssons.org/archive/2009/10/math198-third-lecture-is-up/ > 27. http://www.serpentine.com/blog/2009/10/09/announcing-a-major-revision-of-the-haskell-text-library/ > 28. http://koweycode.blogspot.com/2009/10/darcs-hashed-storage-work-merged-woo.html > 29. http://haskellformaths.blogspot.com/2009/10/symmetries-of-pgnfq.html > 30. http://ghcmutterings.wordpress.com/2009/10/06/parallelism-concurrency/ > 31. http://my.life-is-virtual.com/2009/10/07/fake-world-haskell-part-1/ > 32. http://tomschrijvers.blogspot.com/2009/10/release-06-of-monadic-constraint.html > 33. http://chplib.wordpress.com/2009/10/07/concurrency-can-be-deterministic/ > 34. http://www.l2mlogistics.com/2009/10/curiously-parallel.html > 35. http://www.galois.com/blog/2009/10/06/huffman-universal/ > 36. http://chplib.wordpress.com/2009/10/06/the-printing-process/ > 37. http://feedproxy.google.com/~r/splonderzoek/~3/4E8TZPDZ-aM/ > upwards-and-downwards-accumulations-on.html > 38. http://blog.mikael.johanssons.org/archive/2009/10/math-198-second-lecture/ > 39. http://cdsmith.wordpress.com/2009/10/04/view-patterns-as-pattern-matching-for-records/ > 40. http://cdsmith.wordpress.com/2009/10/03/playing-with-records/ > 41. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=237 > 42. http://www.haskell.org/mailman/listinfo/haskell > 43. http://sequence.complete.org/ > 44. http://planet.haskell.org/ > 45. http://sequence.complete.org/node/feed > 46. http://haskell.org/ > 47. http://haskell.org/haskellwiki/HWN > 48. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > ===================== > Patrick LeBoutillier > Rosem?re, Qu?bec, Canada > From bulat.ziganshin at gmail.com Sun Oct 11 11:26:32 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Oct 11 11:04:01 2009 Subject: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library In-Reply-To: <4AD1E49B.6000406@kent.ac.uk> References: <08F8228A-AB0E-4C6D-BF85-984DFF10A040@n-heptane.com> <4AD1E49B.6000406@kent.ac.uk> Message-ID: <15110353090.20091011192632@gmail.com> Hello Neil, Sunday, October 11, 2009, 5:58:51 PM, you wrote: > I had a crack at a simple proper Data instance, and got as far as > needing a Data instance for ByteString#, accompanied by an error I don't impossible. i'm not sure wher i've read this but those # types (Int#, ByteArray# and so on) are not regular Haskell types. they cannot be class instances, cannot be passed to polymorphic functions and so on -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From paul at cogito.org.uk Sun Oct 11 11:58:52 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Sun Oct 11 11:36:22 2009 Subject: [Haskell-cafe] Haskell-tan competition In-Reply-To: References: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> Message-ID: <4AD200BC.7060801@cogito.org.uk> What about Lambdabot? On 10/10/09 20:22, Miguel Mitrofanov wrote: > Just a note: Haskell and 'tan' in one sentence, combined with some > girlish flavour, makes me think about Audrey TANg. > > On 10 Oct 2009, at 23:02, Svein Ove Aas wrote: > >> I say "competition", but.. at the moment I'm only aware of a single >> Haskell-tan, namely the one at >> http://www.reddit.com/r/programming/comments/9ss7n/haskell%E3%82%BF%E3%83%B3_%E7%B5%B5/. >> >> >> This cannot stand. Haskell needs an anthropomorphized personification, >> like any other modern language. Anyway, have any of you seen any >> others? >> >> -- >> Svein Ove Aas >> _______________________________________________ >> 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 john at n-brain.net Sun Oct 11 12:58:57 2009 From: john at n-brain.net (John A. De Goes) Date: Sun Oct 11 12:36:22 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <20091010043751.GD15834@poetic.cynic.net> References: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <1255104473.28525.6759.camel@localhost> <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> <20091010043751.GD15834@poetic.cynic.net> Message-ID: <4D82C4CE-14A5-4F5A-A135-FA2448AB25C2@n-brain.net> On Oct 9, 2009, at 10:37 PM, Curt Sampson wrote: > So this makes me wonder, if cross-platform support is so necessary, > why have these PHP, Ruby and Python folks not switched to Java, rather > than remain suffering doing their development on Linux boxes? PHP runs on all platforms (it's common for developers to test locally on Windows/Mac, and deploy to a Linux server), and has such an extensive library that most other libraries a developer might need are likely to be pure PHP, built on top the base. So while not "cross platform" in the sense that Java is, the approach taken by PHP achieves much of the benefit.[1] Moreover, PHP is a perfect example of the principle that libraries are essential to language success. PHP's standard library is so immense, it includes just about everything the average web developer needs. And many functions it provides are very high-level -- for example, file_get_contents() works seamlessly across local files, http files, https files, etc. PHP never would have achieved the success it has if it weren't for the immense library available for it (of course, it's not the sole factor in its success). > And if libraries are the issue, why would not just creating a SWIG for > GHC make all of these people move to Haskell? Making it possible and making it easy are two different things. It's already _possible_ to do Haskell interop with any other language, it's just difficult and cumbersome. Moreover, Haskell will never attract the following of a mainstream language like PHP. But there are numerous applications where Haskell is clearly a superior choice assuming library equality. > I agree it's a nich market, too. So I guess our point of > disagreement is > that you believe that it's lack of libraries keeping it a nich market, Haskell will never be "popular", because it's too hard for the masses. But I could see big companies like Yahoo, Facebook, Google, etc., using Haskell extensively to develop web infrastructure -- _if_ there were no longer a significant penalty to doing so. Right now the barrier of entry is too high, because too much infrastructure would have to be developed from scratch, and then maintained at cost. > That just seems pointless to me, because those looking for real > improvements can't use that sort of stuff. When I need RDBMS access, > libraries like Hibernate and Active Record are useless to me, because > they force me to work in a stupid manner. For web sites, Rails is > useless because again, it deals with stuff in a stupid, unproductive > way. Well, I don't know much about Rails, but I do know some Rails developers can build a fully-functional, database-backed Web 2.0 site in a matter of hours.[2] That level of productivity is not available in Haskell yet. Put another way, it would cost me far more to hire you to develop a Haskell site than a good Rails developer,[3] and what a Rails developer produces can be deployed at numerous Rails hosting sites at no upfront cost to me. So why should I hire you? [1] The Haskell Platform could eventually take Haskell in a similar direction, it it provides a broad enough base that developers can built nearly any other library directly on top of it. [2] http://www.readwriteweb.com/archives/rails_rumble_92_web_apps_created_in_48_hours.php [3] The difference in cost is strictly due to libraries. If you had some killer Haskell libraries at your disposal, I have no doubt you could do it for less than a Rails developer. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 From john at n-brain.net Sun Oct 11 13:06:21 2009 From: john at n-brain.net (John A. De Goes) Date: Sun Oct 11 12:43:46 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <822AE374-6795-49C3-A4B5-E8910163F8AC@phaedrusdeinus.org> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <1255104473.28525.6759.camel@localhost> <6D2A3141-6BC5-4AF0-8922-38CD86F62A29@n-brain.net> <822AE374-6795-49C3-A4B5-E8910163F8AC@phaedrusdeinus.org> Message-ID: <1A236265-114D-4C90-9073-F6F936427AE4@n-brain.net> I don't have any research, but anecdotally, I know numerous startups, and most of them are producing web applications (usually client and server, but sometimes server only). Those doing desktop and mobile apps usually do server development, too, because in the age of ubiquitous network connectivity, applications that cannot take advantage of the Internet are few and far between. Most internal development is in the form of web apps (it's rare to see a company that produces desktop applications for in-house use), and most job postings today are for client-side developers (JavaScript, CSS/HTML, Flash) or server-side developers (Java, PHP, Ruby, etc.). Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Oct 10, 2009, at 12:11 PM, John Melesky wrote: > On 2009-10-09, at 7:53 PM, John A. De Goes wrote: >> The vast majority of applications being built today are web apps. > > I'm not convinced this is the case. There are still a great many > enterprise desktop apps and mobile apps being built, and the > selection bias towards internet-based applications on a mailing list > (not to mention the selection bias in blogs, reddit, etc). > > I'm not saying you're wrong, just that i'd love to see some research > into it. > > -johnnnnnnn > From john at n-brain.net Sun Oct 11 13:10:57 2009 From: john at n-brain.net (John A. De Goes) Date: Sun Oct 11 12:48:27 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: References: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> Message-ID: <9C5B1114-A12E-48D7-AB78-935C9FF349A0@n-brain.net> On Oct 10, 2009, at 12:47 PM, Brad Larsen wrote: > With this hypothetical ``import foreign jvm'' mechanism, what would > the be type of imported Java stuff? Would it all be done in IO? Yes, that's a good first-start. > The more I think about it, the trickier it seems. Beside the purity > mismatch of Haskell and Java, there is an OO/functional mismatch. That just means an extra argument to every function and some unsafe downcasts; and maybe some funky mechanism for subclassing, for those libraries that require it (deprecated in modern OOP but not uncommon). > Haskell / Java interop could be a huge boon; I just have trouble > seeing how it could be so simple as a one-line import in your Haskell > code. I'm not saying the one-line import would give you anything more than purely imperative wrappers around Java code. But that's a start. It's "good enough". If it existed, I could transition two companies over to Haskell, and likely more in the future. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 From byorgey at seas.upenn.edu Sun Oct 11 14:34:54 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun Oct 11 14:12:16 2009 Subject: [Haskell-cafe] The Monad.Reader (14) - Call for copy Message-ID: <20091011183454.GA6918@seas.upenn.edu> Call for Copy: The Monad.Reader - Issue 14 ------------------------------------------ Whether you're an established academic or have only just started learning Haskell, if you have something to say, please consider writing an article for The Monad.Reader! The submission deadline for Issue 14 will be: **Friday, January 8, 2010** The Monad.Reader ~~~~~~~~~~~~~~~~ The Monad.Reader is a electronic magazine about all things Haskell. It is less formal than journal, but somehow more enduring than a wiki-page. There have been a wide variety of articles: exciting code fragments, intriguing puzzles, book reviews, tutorials, and even half-baked research ideas. Submission Details ~~~~~~~~~~~~~~~~~~ Get in touch with me if you intend to submit something -- the sooner you let me know what you're up to, the better. Please submit articles for the next issue to me by e-mail (byorgey at cis.upenn.edu). Articles should be written according to the guidelines available from http://themonadreader.wordpress.com/contributing/ Please submit your article in PDF, together with any source files you used. The sources will be released together with the magazine under a BSD license. If you would like to submit an article, but have trouble with LaTeX please let me know and we'll sort something out. From byorgey at seas.upenn.edu Sun Oct 11 15:42:01 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun Oct 11 15:19:23 2009 Subject: [Haskell-cafe] Re: [Haskell] The Monad.Reader (14) - Call for copy In-Reply-To: <20091011183454.GA6918@seas.upenn.edu> References: <20091011183454.GA6918@seas.upenn.edu> Message-ID: <20091011194201.GA18447@seas.upenn.edu> Er, correction, obviously that should be Issue 15, not 14. The submission deadline is correct, though! =) On Sun, Oct 11, 2009 at 02:34:54PM -0400, Brent Yorgey wrote: > Call for Copy: The Monad.Reader - Issue 14 > ------------------------------------------ > > Whether you're an established academic or have only just started > learning Haskell, if you have something to say, please consider > writing an article for The Monad.Reader! The submission deadline for > Issue 14 will be: > > **Friday, January 8, 2010** > > > The Monad.Reader > ~~~~~~~~~~~~~~~~ > > The Monad.Reader is a electronic magazine about all things Haskell. > It is less formal than journal, but somehow more enduring than a > wiki-page. There have been a wide variety of articles: exciting code > fragments, intriguing puzzles, book reviews, tutorials, and even > half-baked research ideas. > > Submission Details > ~~~~~~~~~~~~~~~~~~ > > Get in touch with me if you intend to submit something -- the sooner > you let me know what you're up to, the better. > > Please submit articles for the next issue to me by e-mail (byorgey at > cis.upenn.edu). > > Articles should be written according to the guidelines available from > > http://themonadreader.wordpress.com/contributing/ > > Please submit your article in PDF, together with any source files you > used. The sources will be released together with the magazine under a > BSD license. > > If you would like to submit an article, but have trouble with LaTeX > please let me know and we'll sort something out. > > > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell From ben.franksen at online.de Sun Oct 11 15:54:22 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sun Oct 11 15:32:10 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: Ben Franksen wrote: > Next thing I'll try is to transform such a grammar into an actual > parser... Which I also managed to get working. However, this exposed yet another problem I am not sure how to solve. The problem manifests itself with non-left-factored rules like Number ::= Digit Number | Digit Translating such a grammar directly into a Parsec parser leads to parse errors because Parsec's choice operator is predictive: if a production has consumed any input the whole choice fails, even if alternative productions would not: *Main> P.parseTest (parseGrammar myGrm) "2" parse error at (line 1, column 2): unexpected end of input expecting Number Of course, one solution is to apply Parsec's try combinator to all choices in a rule. But this rather defeats the purpose of using a (by default) predictive parser in the first place which is to avoid unnecessary backtracking. So, a better solution is to left-factor the grammar before translating to Parsec. Since we have a data representation of the grammar that we can readily analyse and transform, this should be possible given some suitable algorithm. But how is this transformation to be typed? My first naive attempt was to define (recap: nt :: * -> * is the type of nonterminals, t :: * is the type of terminals a.k.a. tokens, and a is the result type): > leftFactor :: Grammar nt t a -> Grammar nt t a Of course, this is wrong: Left-factoring is expected to introduce new nonterminals, so on the right-hand side of the type we should not have the same 'nt' as on the left. Instead we shoudl have some other type that is "'nt' extended with new constructors". Moreover, we cannot statically know how many new nonterminals are added, so we cannot simply apply a type function to nt. Is this solvable at all in Haskell or do I need proper dependent types to express this? I have very vague ideas that revolve around setting up some recursive type function that on each level adds one constructor, define a common interface with a (multiparam) type class and then use existential quantification in the result type to hide the resulting type of nonterminals. The next question is: Even if this turns out to be possible, isn't it overkill? Maybe it is better to use an infinite type for the nonterminals in the first place and let the grammar be a partial function? OTOH, the formulation of the grammar as a function that pattern matches on the nonterminals is very elegant. Cheers Ben From ben.franksen at online.de Sun Oct 11 16:04:06 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sun Oct 11 15:41:57 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 134 - October 10, 2009 References: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> Message-ID: Patrick LeBoutillier wrote: > Could/should the Haskell Weekly News be posted to the beginners list as > well? > > I normally don't follow haskell-cafe (too much traffic and generally above > my level I must admit...), but I like to follow what's going on in the > Haskell community. I find reading the HWN is a lot is a lot more convenient with a web browser, you don't have to jump up and down the document to find the links. There is also an RSS feed (http://sequence.complete.org/node/feed) to keep you up to date. Cheers Ben From svein.ove at aas.no Sun Oct 11 16:46:19 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Oct 11 16:23:42 2009 Subject: [Haskell-cafe] Haskell-tan competition In-Reply-To: <4AD200BC.7060801@cogito.org.uk> References: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> <4AD200BC.7060801@cogito.org.uk> Message-ID: <221b53ab0910111346n17dfed69mdf0b97767c1f722b@mail.gmail.com> On Sun, Oct 11, 2009 at 5:58 PM, Paul Johnson wrote: > What about Lambdabot? > You're welcome to draw one for her. :-) -- Svein Ove Aas From hjgtuyl at chello.nl Sun Oct 11 17:10:02 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sun Oct 11 16:47:27 2009 Subject: [Haskell-cafe] SDL build problem Message-ID: L.S., I am trying to install SDL, but I get error messages about multiple definition of `main'; before I spend many hours of debugging, does anybody know why this happens? See the log below. Regards, Henk-Jan van Tuyl C:\Programs\Haskell\Libs\SDL-0.5.5>runhaskell Setup configure --extra-include-dirs=C:\Programs\MSYS\1.0\include\SDL Setup.lhs:2:2: Warning: In the use of `defaultUserHooks' (imported from Distribution.Simple): Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2 compatibility in which case you must stick with defaultUserHooks" Warning: defaultUserHooks in Setup script is deprecated. Configuring SDL-0.5.5... checking for sdl-config... /usr/bin/sdl-config configure: creating ./config.status config.status: creating config.mk config.status: creating SDL.buildinfo config.status: creating includes/HsSDLConfig.h config.status: includes/HsSDLConfig.h is unchanged C:\Programs\Haskell\Libs\SDL-0.5.5>runhaskell Setup build Setup.lhs:2:2: Warning: In the use of `defaultUserHooks' (imported from Distribution.Simple): Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2 compatibility in which case you must stick with defaultUserHooks" Preprocessing library SDL-0.5.5... dist\build\Graphics\UI\SDL\General_hsc_make.o:General_hsc_make.c:(.text+0x0): multiple definition of `main' C:\Programs\ghc\ghc-6.10.4/gcc-lib/libmingw32.a(main.o):main.c:(.text+0x0): first defined here C:/Programs/MinGW/lib/libSDLmain.a(SDL_win32_main.o): In function `console_main': /Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:246: undefined reference to `SDL_main' collect2: ld returned 1 exit status linking dist\build\Graphics\UI\SDL\General_hsc_make.o failed command was: C:\Programs\ghc\ghc-6.10.4\gcc.exe -BC:\Programs\ghc\ghc-6.10.4\gcc-lib -IC:\Programs\ghc\ghc-6.10.4\include\mingw -lSDL -L/usr/lib -lmingw32 -lSDLmain -lSDL -mwindows -LC:\Programs\ghc\ghc-6.10.4\base-4.1.0.0 -lwsock32 -luser32 -lshell32 -LC:\Programs\ghc\ghc-6.10.4\integer-0.1.0.1 -LC :\Programs\ghc\ghc-6.10.4\ghc-prim-0.1.0.0 -LC:\Programs\ghc\ghc-6.10.4 -LC:\Programs\ghc\ghc-6.10.4/gcc-lib -lm -lffi -lgmp -lwsock32 dist\build\Graphics\UI\SDL\General_hsc_make.o -o dist\build\Graphics\UI\SDL\General_hsc_make.exe -- From ben.franksen at online.de Sun Oct 11 18:00:54 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sun Oct 11 17:38:38 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: Ben Franksen wrote: > Ben Franksen wrote: >> Next thing I'll try is to transform such a grammar into an actual >> parser... > > Which I also managed to get working. First, before all this talking to myself here is boring you to death, please shout and I'll go away. Anyway, at least one person has privately expressed interest, so I'll post my code for the translation.(*) > {-# LANGUAGE ExistentialQuantification, GADTs, Rank2Types #-} > {-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses, ImpredicativeTypes #-} > import qualified Text.ParserCombinators.Parsec as P Note that I have parameterized everything on the token (terminal) type. Here are the data types, adapting the rest of the code is completely mechanical. > data Production nt t a > = Stop a > | Terminal t (Production nt t a) > | forall b. NonTerminal (nt b) (Production nt t (b -> a)) > newtype Rule nt t a = Rule [Production nt t a] > type RuleSet nt t = forall a. nt a -> Rule nt t a > type Grammar nt t b = (nt b, RuleSet nt t) I should probably turn this into a proper data type, which would BTW also make the ImpredicativeTypes extension unnecessary. Translation to Parsec --------------------- We restrict ourselves to Char as terminals for simplicity. The generalization to arbitrary token types would need another three arguments: showTok :: (tok -> String), nextPos :: (SourcePos -> tok -> [tok] -> SourcePos), and testTok :: (tok -> Maybe a), which are needed by P.tokenPrim. > parseGrammar :: Print nt => Grammar nt Char a -> P.Parser a > parseGrammar (start,rules) = parseNonTerminal rules start > parseNonTerminal :: Print nt => RuleSet nt Char -> nt a -> P.Parser a > parseNonTerminal rs nt = parseRule rs (rs nt) P. pr nt > parseRule :: Print nt => RuleSet nt Char -> Rule nt Char a -> P.Parser a > parseRule rs (Rule ps) = P.choice (map ({- P.try . -} parseProduction rs) ps) > parseProduction :: Print nt => RuleSet nt Char -> Production nt Char a -> P.Parser a > parseProduction _ (Stop x) = return x > parseProduction rs (Terminal c p) = P.char c >> parseProduction rs p > parseProduction rs (NonTerminal nt p) = do > vnt <- parseNonTerminal rs nt > vp <- parseProduction rs p > return (vp vnt) This is really not difficult, once you understand how the list-like Production type works. The trick is that a NonTerminal forces the "rest" of the production to return a function type, so you can apply its result to the result of parsing the nonterminal. Whereas the result of parsing terminals gets ignored by the "rest" of the production. You might wonder how the code manages to return the correct integer values inside an ENum. Well, I did, at least. I don't yet understand it completely but I think the answer is in in the Functor and Applicative instances: all the code that interprets syntactic elements (up to the abstract syntax) inside the myGrm function gets pushed down through the elements of a production until it ends up at a Stop, where we can finally pull it out (see the first clause of parseProduction). Note also the (commented-out) use of P.try in function parseRule. Let's try it: *Main> putStrLn (printGrammar myGrm) *Start ::= Sum Sum ::= Product '+' Sum | Product Product ::= Value '*' Product | Value Value ::= Number | '(' Sum ')' Number ::= Digit Number | Digit Digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' *Main> P.parseTest (parseGrammar myGrm) "2*(2+52)" parse error at (line 1, column 2): unexpected "*" expecting Number After re-inserting the P.try call, I can actually parse expressions (yay!): *Main> :r [1 of 1] Compiling Main ( Grammar.lhs, interpreted ) Ok, modules loaded: Main. *Main> P.parseTest (parseGrammar myGrm) "2*(2+52)" EProduct (ENum 2) (ESum (ENum 2) (ENum 52)) BTW, does anyone know a source (books, papers, blogs, whatever) about algorithms for automatic left-factoring? I searched with google and found some interesting papers on eliminating left recursion but nothing so far on left-factoring. Have these problems all been solved before the internet age? Cheers Ben (*) One of these days I really should get my hands dirty and set up a weblog; suggestions for how to proceed are appreciated. I would especially like something where I can just upload a literate Haskell file and it gets formatted automagically. Bonus points for beautifying operator symbols a la lhs2tex ;-) From nowgate at yahoo.com Sun Oct 11 18:10:12 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Oct 11 17:47:33 2009 Subject: [Haskell-cafe] Simple program. Simple problem? Message-ID: <11710.12522.qm@web31105.mail.mud.yahoo.com> What is going wrong here? Michael ======= import System.Random coinToss :: StdGen -> IO () coinToss gen = putStrLn "What's your guess, heads or tails ('h' or 't')?" ?????????????? >> getChar ?????????????? >>= \c -> let (randInt, _) = randomR(0,1) gen :: (Int, StdGen) ??????????????????? in if c == ((!!) "ht" randInt) then putStrLn "You win!" else putStrLn "You lose!" main = do ???????? gen <- getStdGen ???????? coinToss gen ???????? gen <- newStdGen ???????? main ======= [michael@localhost ~]$ runhaskell cointoss.hs What's your guess, heads or tails ('h' or 't')? h You win! What's your guess, heads or tails ('h' or 't')? You lose! What's your guess, heads or tails ('h' or 't')? h You lose! What's your guess, heads or tails ('h' or 't')? You lose! What's your guess, heads or tails ('h' or 't')? ^Ccointoss.hs: cointoss.hs: interrupted [michael@localhost ~]$ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091011/2571510d/attachment.html From bugfact at gmail.com Sun Oct 11 18:24:26 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Oct 11 18:01:48 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: <11710.12522.qm@web31105.mail.mud.yahoo.com> References: <11710.12522.qm@web31105.mail.mud.yahoo.com> Message-ID: It always helps to put a Debug.Trace.trace: in if trace (show (fromEnum c)) $ c == ((!!) "ht" randInt) then p What's your guess, heads or tails ('h' or 't')? h 104 You win! What's your guess, heads or tails ('h' or 't')? *10* You lose! What's your guess, heads or tails ('h' or 't')? So getChar also receives the linefeed character. An easy way to get around this, is to use getLine instead and just use the first character, as in >> fmap head getLine But of course we're hacking away here :-) On Mon, Oct 12, 2009 at 12:10 AM, michael rice wrote: > What is going wrong here? > > Michael > > ======= > > import System.Random > > coinToss :: StdGen -> IO () > coinToss gen = putStrLn "What's your guess, heads or tails ('h' or 't')?" > >> getChar > >>= \c -> let (randInt, _) = randomR(0,1) gen :: (Int, > StdGen) > in if c == ((!!) "ht" randInt) then putStrLn "You win!" > else putStrLn "You lose!" > > main = do > gen <- getStdGen > coinToss gen > gen <- newStdGen > main > > ======= > > [michael@localhost ~]$ runhaskell cointoss.hs > What's your guess, heads or tails ('h' or 't')? > h > You win! > What's your guess, heads or tails ('h' or 't')? > You lose! > What's your guess, heads or tails ('h' or 't')? > h > You lose! > What's your guess, heads or tails ('h' or 't')? > You lose! > What's your guess, heads or tails ('h' or 't')? > ^Ccointoss.hs: cointoss.hs: interrupted > [michael@localhost ~]$ > > > > _______________________________________________ > 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/20091011/bc801c74/attachment.html From allbery at ece.cmu.edu Sun Oct 11 18:29:58 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Oct 11 18:07:35 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: <5B9A435C-FFC2-4EA2-A809-D0EB506101F8@ece.cmu.edu> On Oct 11, 2009, at 18:00 , Ben Franksen wrote: > Ben Franksen wrote: >> Ben Franksen wrote: >>> Next thing I'll try is to transform such a grammar into an actual >>> parser... >> >> Which I also managed to get working. > > First, before all this talking to myself here is boring you to > death, please > shout and I'll go away. Anyway, at least one person has privately > expressed > interest, so I'll post my code for the translation.(*) It's -cafe, so let 'er rip. And maybe write it up for TMR, if you don't want to set up a blog with all the goodies? -- 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 -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091011/d509ccb2/PGP-0001.bin From bugfact at gmail.com Sun Oct 11 18:42:16 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Oct 11 18:19:38 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: References: <11710.12522.qm@web31105.mail.mud.yahoo.com> Message-ID: btw I always find it amusing to play with interact and lazy IO: guess :: [Char] -> [String] -> [String] guess (c:cs) ~(i:is) = "What's your guess, heads or tails ('h' or 't')?" : (if [c]==i then "You win!" else "You lose!") : guess cs is main = do gen <- getStdGen let rs = randomRs (0,1::Int) gen cs = map ("ht"!!) rs interact $ unlines . guess cs . lines On Mon, Oct 12, 2009 at 12:24 AM, Peter Verswyvelen wrote: > It always helps to put a Debug.Trace.trace: > in if trace (show (fromEnum c)) $ c == ((!!) "ht" > randInt) then p > > What's your guess, heads or tails ('h' or 't')? > h > 104 > You win! > What's your guess, heads or tails ('h' or 't')? > *10* > You lose! > What's your guess, heads or tails ('h' or 't')? > > So getChar also receives the linefeed character. > > An easy way to get around this, is to use getLine instead and just use the > first character, as in > > >> fmap head getLine > > But of course we're hacking away here :-) > > On Mon, Oct 12, 2009 at 12:10 AM, michael rice wrote: > >> What is going wrong here? >> >> Michael >> >> ======= >> >> import System.Random >> >> coinToss :: StdGen -> IO () >> coinToss gen = putStrLn "What's your guess, heads or tails ('h' or 't')?" >> >> getChar >> >>= \c -> let (randInt, _) = randomR(0,1) gen :: (Int, >> StdGen) >> in if c == ((!!) "ht" randInt) then putStrLn "You >> win!" else putStrLn "You lose!" >> >> main = do >> gen <- getStdGen >> coinToss gen >> gen <- newStdGen >> main >> >> ======= >> >> [michael@localhost ~]$ runhaskell cointoss.hs >> What's your guess, heads or tails ('h' or 't')? >> h >> You win! >> What's your guess, heads or tails ('h' or 't')? >> You lose! >> What's your guess, heads or tails ('h' or 't')? >> h >> You lose! >> What's your guess, heads or tails ('h' or 't')? >> You lose! >> What's your guess, heads or tails ('h' or 't')? >> ^Ccointoss.hs: cointoss.hs: interrupted >> [michael@localhost ~]$ >> >> >> >> _______________________________________________ >> 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/20091011/b73e76a5/attachment.html From nowgate at yahoo.com Sun Oct 11 18:56:53 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Oct 11 18:34:15 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: Message-ID: <267169.30971.qm@web31106.mail.mud.yahoo.com> Thanks for the tip, and the lazy example. I think I'm finally beginning to "get" monads, so I decided to test my understanding with this small example. So far so good, except for that little bump in the road. Onward and upward. Michael --- On Sun, 10/11/09, Peter Verswyvelen wrote: From: Peter Verswyvelen Subject: Re: [Haskell-cafe] Simple program. Simple problem? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, October 11, 2009, 6:42 PM btw I always find it amusing to play with interact and lazy IO: guess :: [Char] -> [String] -> [String]guess (c:cs) ~(i:is) =???"What's your guess, heads or tails ('h' or 't')?"?:? ??(if [c]==i then "You win!" else "You lose!")?:??guess cs is? main = do??gen <- getStdGen??let rs = randomRs ?(0,1::Int) gen ?? ? ?cs = map ("ht"!!) rs??interact $ unlines . guess cs . lines On Mon, Oct 12, 2009 at 12:24 AM, Peter Verswyvelen wrote: It always helps to put a Debug.Trace.trace: ?? ? ? ? ? ? ? ? ? ?in if trace (show (fromEnum c)) $ c == ((!!) "ht" randInt) then p What's your guess, heads or tails ('h' or 't')? h104You win!What's your guess, heads or tails ('h' or 't')?10You lose!What's your guess, heads or tails ('h' or 't')? So getChar also receives the linefeed character. An easy way to get around this, is to use getLine instead and just use the first character, as in ?? ? ? ? ? ? ? >> fmap head getLine? But of course we're hacking away here :-) On Mon, Oct 12, 2009 at 12:10 AM, michael rice wrote: What is going wrong here? Michael ======= import System.Random coinToss :: StdGen -> IO () coinToss gen = putStrLn "What's your guess, heads or tails ('h' or 't')?" ?????????????? >> getChar ?????????????? >>= \c -> let (randInt, _) = randomR(0,1) gen :: (Int, StdGen) ??????????????????? in if c == ((!!) "ht" randInt) then putStrLn "You win!" else putStrLn "You lose!" main = do ???????? gen <- getStdGen ???????? coinToss gen ???????? gen <- newStdGen ???????? main ======= [michael@localhost ~]$ runhaskell cointoss.hs What's your guess, heads or tails ('h' or 't')? h You win! What's your guess, heads or tails ('h' or 't')? You lose! What's your guess, heads or tails ('h' or 't')? h You lose! What's your guess, heads or tails ('h' or 't')? You lose! What's your guess, heads or tails ('h' or 't')? ^Ccointoss.hs: cointoss.hs: interrupted [michael@localhost ~]$ _______________________________________________ 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/20091011/e2487c7c/attachment.html From felipe.lessa at gmail.com Sun Oct 11 19:08:50 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Oct 11 18:46:57 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: References: <11710.12522.qm@web31105.mail.mud.yahoo.com> Message-ID: <20091011230850.GA20547@kira.casa> On Mon, Oct 12, 2009 at 12:42:16AM +0200, Peter Verswyvelen wrote: > btw I always find it amusing to play with interact and lazy IO: I always find it frightening to play with lazy IO :). -- Felipe. From nowgate at yahoo.com Sun Oct 11 19:24:55 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Oct 11 19:02:16 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: <20091011230850.GA20547@kira.casa> Message-ID: <513621.42141.qm@web31105.mail.mud.yahoo.com> There's still something screwy going on here with the random generation or passing the gen to cointoss. Shouldn't newStdGen be updating getStdGen? I've been running it and entering 'h' four (4) times, then aborting with CNTL-C. Each time I either get You lose! You lose! You win! You lose! or You win! You win! You lose! You win! That's all, should be getting some variation. Michael ====================== import System.Random coinToss :: StdGen -> IO () coinToss gen = putStrLn "What's your guess, heads or tails ('h' or 't')?" ?????????????? >> fmap head getLine ?????????????? >>= \c -> let (randInt, _) = randomR(0,1) gen :: (Int, StdGen) ???????????????????????? in if c == ((!!) "ht" randInt) then putStrLn "You win!" else putStrLn "You lose!" main = do ? gen <- getStdGen ? coinToss gen ? gen <- newStdGen ? main --- On Sun, 10/11/09, Felipe Lessa wrote: From: Felipe Lessa Subject: Re: [Haskell-cafe] Simple program. Simple problem? To: haskell-cafe@haskell.org Date: Sunday, October 11, 2009, 7:08 PM On Mon, Oct 12, 2009 at 12:42:16AM +0200, Peter Verswyvelen wrote: > btw I always find it amusing to play with interact and lazy IO: I always find it frightening to play with lazy IO :). -- Felipe. _______________________________________________ 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/20091011/748cca4d/attachment.html From nowgate at yahoo.com Sun Oct 11 19:47:18 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Oct 11 19:24:38 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: <20091011230850.GA20547@kira.casa> Message-ID: <654615.50840.qm@web31105.mail.mud.yahoo.com> For the code below, if I CNTL-C after the list is printed, and run it again, I get a different list of colors, each time. This doesn't seem to be happening with my earlier example. Michael ============= import System.Random import Data.Ord data Color ??? = Red ??? | Blue ??? | Green ??? | Yellow ??? | Orange ??? | Brown ??? deriving (Show, Read, Eq, Enum, Ord, Bounded) main = do ? gen <- getStdGen ? let code = map toEnum $ take 4 $ randomRs (0,5) gen :: [Color] ? putStrLn $ "List is " ++ show code ? guessString <- getLine ? newGen <- newStdGen ? main --- On Sun, 10/11/09, Felipe Lessa wrote: From: Felipe Lessa Subject: Re: [Haskell-cafe] Simple program. Simple problem? To: haskell-cafe@haskell.org Date: Sunday, October 11, 2009, 7:08 PM On Mon, Oct 12, 2009 at 12:42:16AM +0200, Peter Verswyvelen wrote: > btw I always find it amusing to play with interact and lazy IO: I always find it frightening to play with lazy IO :). -- Felipe. _______________________________________________ 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/20091011/f8b17a40/attachment.html From rwbarton at math.harvard.edu Sun Oct 11 20:17:48 2009 From: rwbarton at math.harvard.edu (Reid Barton) Date: Sun Oct 11 19:55:56 2009 Subject: split (was Re: [Haskell-cafe] Simple program. Simple problem?) In-Reply-To: <513621.42141.qm@web31105.mail.mud.yahoo.com> References: <20091011230850.GA20547@kira.casa> <513621.42141.qm@web31105.mail.mud.yahoo.com> Message-ID: <20091012001748.GA30332@rwbarton.mit.edu> It seems that the definition of split in System.Random is not really satisfactory. Imagine a tree-like computation of the form f gen = {- some expression using b, g1, g2 -} where b = fst (random gen) :: Bool (gen1, gen2) = split gen g1 = f gen1 g2 = f gen2 Let's look at the first 30 values of b produced along the right side of the tree: GHCi> length $ nub [ take 30 . map (fst . random) . iterate (snd . split) $ mkStdGen i :: [Bool] | i <- take 10000 . randoms $ mkStdGen 0 ] 10000 Great, we tried 10000 different initial gens and got 10000 different sequences. Now let's look at the left side: GHCi> length $ nub [ take 30 . map (fst . random) . iterate (fst . split) $ mkStdGen i :: [Bool] | i <- take 10000 . randoms $ mkStdGen 0 ] 8 This doesn't seem good. Michael's code (below) is effectively doing iterate (fst . split). Regards, Reid Barton On Sun, Oct 11, 2009 at 04:24:55PM -0700, michael rice wrote: > main = do > gen <- getStdGen > coinToss gen > gen <- newStdGen > main From wren at freegeek.org Sun Oct 11 20:54:29 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Oct 11 20:31:51 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: References: <20090929153550.GG24761@analytic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> <20091010211139.GA9326@whirlpool.galois.com> Message-ID: <4AD27E45.7060900@freegeek.org> Patrick LeBoutillier wrote: > Don, > >>> Having painless Haskell <- Java interoperability would be great. I'm >>> curious though: could it really be so simple as a one-line ``import >>> foreign jvm'' directive? I imagine the purity mismatch between >>> Haskell and Java would be very troublesome. >> No more so than C, surely. We're used to stateful APIs. They're a pain. >> >> >>> With this hypothetical ``import foreign jvm'' mechanism, what would >>> the be type of imported Java stuff? Would it all be done in IO? >>> >>> The more I think about it, the trickier it seems. Beside the purity >>> mismatch of Haskell and Java, there is an OO/functional mismatch. >> That's more of an issue. But the prior work has been done. > > Do you have any references to this work? It was a major research topic about a decade ago, though the projects have died since. And the topic comes up about every 4 months on the Cafe, so I'd recommend sifting through the archives. I know last time it came up (or the time before?) I gave a rather extensive list of projects. And the wiki[1] still lists a few of them. The last time this discussion came up people got involved enough to revive LambdaVM[2], which was one of the more mature options back in the day. If you're interested in the topic, I suggest getting in touch with the author and helping out. On the topic of automatically embedding OO-style languages into Haskell, you should also check out hprotoc[3]. It's a package for Google's protocol buffers, which are ostensibly language agnostic but actually assume a (weakly) OO language. The hprotoc library will create a family of virtual modules based on the protocol spec and makes a pretty nice interface out of them. [1] http://www.haskell.org/haskellwiki/Applications_and_libraries/Interfacing_other_languages [2] http://wiki.brianweb.net/LambdaVM/LambdaVM [3] http://hackage.haskell.org/package/hprotoc -- Live well, ~wren From mwotton at gmail.com Sun Oct 11 22:18:54 2009 From: mwotton at gmail.com (Mark Wotton) Date: Sun Oct 11 21:56:22 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <20091010211139.GA9326@whirlpool.galois.com> References: <20090929153550.GG24761@analytic.cynic.net> <20091001155627.GB27880@poetic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> <20091010211139.GA9326@whirlpool.galois.com> Message-ID: <98347E5A-E935-489D-915A-341CF3B49339@gmail.com> On 11/10/2009, at 8:11 AM, Don Stewart wrote: > brad.larsen: > >> With this hypothetical ``import foreign jvm'' mechanism, what would >> the be type of imported Java stuff? Would it all be done in IO? >> >> The more I think about it, the trickier it seems. Beside the purity >> mismatch of Haskell and Java, there is an OO/functional mismatch. > > That's more of an issue. But the prior work has been done. At the risk of exposing my ignorance: would you recommend any particular papers? Hubris has a particularly restricted model of this, simply because I don't know how to approach it in a more comprehensive fashion. Cheers Mark From derek.a.elkins at gmail.com Sun Oct 11 23:31:53 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Oct 11 23:09:13 2009 Subject: [Haskell-cafe] Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) In-Reply-To: <09D9114B-A61B-4685-99EC-0CB8B0A554DF@gmail.com> References: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> <09D9114B-A61B-4685-99EC-0CB8B0A554DF@gmail.com> Message-ID: <61f84eff0910112031n375d124ayc9b74c37fcce3ee@mail.gmail.com> On Sun, Oct 11, 2009 at 8:55 AM, Iain Barnett wrote: > > On 11 Oct 2009, at 13:58, John Lato wrote: > >> For anyone writing introductions to generic programming, take this as >> a plea from Haskellers everywhere. ?If one of the RWH authors can't >> understand how to make use of these techniques, what hope do the rest >> of us have? >> >> John Lato >> >> P.S. Some might wryly note that I'm the maintainer of a package which >> is also known for incomprehensible documentation. ?To which I would >> reply that our effort is much newer, I consider it a problem, and it's >> being worked on, contrasted to the state of GP where similarly >> impenetrable documentation has been and continues to be the norm. >> > > You could say that about most documentation (for Haskell and beyond). > Apparently, programmers like programming better than documenting. The effect > of this is that less people use their programming, making their efforts > redundant. > > Silly really, considering programmers are (allegedly:) intelligent. Apparently, programmers like programming better than reading as well... in my experience. From rwbarton at math.harvard.edu Mon Oct 12 00:53:37 2009 From: rwbarton at math.harvard.edu (Reid Barton) Date: Mon Oct 12 00:31:57 2009 Subject: split (was Re: [Haskell-cafe] Simple program. Simple problem?) In-Reply-To: <20091012001748.GA30332@rwbarton.mit.edu> References: <20091011230850.GA20547@kira.casa> <513621.42141.qm@web31105.mail.mud.yahoo.com> <20091012001748.GA30332@rwbarton.mit.edu> Message-ID: <20091012045337.GB30332@rwbarton.mit.edu> On Sun, Oct 11, 2009 at 08:17:48PM -0400, Reid Barton wrote: > It seems that the definition of split in System.Random is not really > satisfactory. For the curious, the reason for the asymmetry between fst . split and snd . split is that the RNG states produced by mkStdGen have varying first component but second component (virtually) always equal to 1. For full details see http://hackage.haskell.org/trac/ghc/ticket/3575 Regards, Reid Barton From mpm at alumni.caltech.edu Mon Oct 12 03:25:43 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Oct 12 03:03:26 2009 Subject: [Haskell-cafe] statistics package and randomness Message-ID: <4AD2D9F7.1040702@alumni.caltech.edu> I'm trying to learn how to use randomness in Haskell and it seems very non-straightforward and complex. I could do a lot of things using 'split' from System.Random, but apparently it's broken. There is the statistics package here: http://hackage.haskell.org/package/statistics Is this a better solution? It uses the ST monad in the RandomVariate module. Can someone point me to a tutorial explaining ST, and/or a tutorial in the RandomVariate module? Pseudorandomness seems like one case where it would just be a hell of a lot simpler to have a global generator--never split the state. Is the ST monad some way to accomplish this? Thanks, Mike From rwbarton at math.harvard.edu Mon Oct 12 03:38:20 2009 From: rwbarton at math.harvard.edu (Reid Barton) Date: Mon Oct 12 03:16:23 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication In-Reply-To: References: Message-ID: <20091012073820.GC30332@rwbarton.mit.edu> On Sat, Oct 10, 2009 at 02:59:37PM -0400, Brad Larsen wrote: > Suppose we implement type-level naturals as so: > > data Zero > data Succ a > > Then, we can reflect the type-level naturals into a GADT as so (not > sure if ``reflect'' is the right terminology here): > > data Nat :: * -> * where > Zero :: Nat Zero > Succ :: Nat a -> Nat (Succ a) > > Using type families, we can then proceed to define type-level addition: > > type family Add a b :: * > type instance Add Zero b = b > type instance Add (Succ a) b = Succ (Add a b) > > Is there any way to define type-level multiplication without requiring > undecidable instances? I hesitate to contradict Manuel Chakravarty on this subject... but I posted a type-level multiplication program without undecidable instances on this list in June: http://www.haskell.org/pipermail/haskell-cafe/2009-June/062452.html If you prefer to use EmptyDataDecls, you can replace the first four lines by data Z data S n data Id :: * -> * data (:.) :: (* -> *) -> (* -> *) -> (* -> *) And I still don't understand why that definition works while the obvious one doesn't :) Regards, Reid Barton From mf-hcafe-15c311f0c at etc-network.de Mon Oct 12 06:41:01 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Mon Oct 12 06:21:15 2009 Subject: [Haskell-cafe] statistics package and randomness In-Reply-To: <4AD2D9F7.1040702@alumni.caltech.edu> References: <4AD2D9F7.1040702@alumni.caltech.edu> Message-ID: <20091012104101.GW3396@yoyo> i'll try a very non-technical explanation that has worked for me so far. (is it correct? does it make sense?) IO and ST are quite similar. the difference is that whereas IO gives you a concept of time in the world surrounding your code, ST lets you create a little bubble inside your code in which you can maintain state, while the bubble as a whole acts all pure and lazy. for example, if you want to implement an algorithm that writes to and reads from a matrix, you use ST: you want to control the order in which you read from and write to it, but not the order in which access events to that data structure mixes with user interaction events. -matthias On Mon, Oct 12, 2009 at 12:25:43AM -0700, Michael Mossey wrote: > To: Haskell Cafe > Cc: > From: Michael Mossey > Date: Mon, 12 Oct 2009 00:25:43 -0700 > Subject: [Haskell-cafe] statistics package and randomness > > I'm trying to learn how to use randomness in Haskell and it seems very > non-straightforward and complex. I could do a lot of things using 'split' > from System.Random, but apparently it's broken. There is the statistics > package here: > > http://hackage.haskell.org/package/statistics > > Is this a better solution? > > It uses the ST monad in the RandomVariate module. Can someone point me to > a tutorial explaining ST, and/or a tutorial in the RandomVariate module? > > Pseudorandomness seems like one case where it would just be a hell of a > lot simpler to have a global generator--never split the state. Is the ST > monad some way to accomplish this? > > Thanks, > Mike > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** CLASSIFY > succeeds; success probability: 1.0000 pR: 5.5394 > Best match to file #0 (nonspam.css) prob: 1.0000 pR: 5.5394 Total > features in input file: 2960 > #0 (nonspam.css): features: 758386, hits: 2888631, prob: 1.00e+00, pR: > 5.54 #1 (spam.css): features: 1683715, hits: 3150692, prob: 2.89e-06, pR: > -5.54 > From iainspeed at gmail.com Mon Oct 12 07:39:47 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Mon Oct 12 07:17:58 2009 Subject: [Haskell-cafe] a library for control of terminal driver modes? In-Reply-To: <4AD1EC13.7000409@btinternet.com> References: <8E502089-031B-4938-BE79-B3EA057D1686@gmail.com> <4AD1EC13.7000409@btinternet.com> Message-ID: On 11 Oct 2009, at 15:30, Andrew Coppin wrote: > Iain Barnett wrote: >> I'm looking for a library like Perl's Term-Readkey, so that I can >> turn on and off the echo for secure password input from a >> terminal. Anyone know which library I need to use for this? > > The package ansi-terminal allows you to do various things to the > terminal; I think it might include turning local echo on/off. > Alternatively, there was an announcement recently about a text-mode > UI package, which might do what you want. (I don't recall the name...) > Thanks Iain From mpm at alumni.caltech.edu Mon Oct 12 09:23:03 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Oct 12 09:00:38 2009 Subject: [Haskell-cafe] "safe" way to use Rand? Message-ID: <4AD32DB7.7060008@alumni.caltech.edu> I'm looking at Control.Monad.Random which provides the Rand monad. I would like to know how to use this for generating multiple infinite series, while trusting that the implementation never uses "split" behind the scenes. (Note: I'm on Windows XP, and there appears to be a bug in getStdGen. It does NOT return an arbitrary generator, but rather the same one every time I run the program. However, newStdGen DOES return an arbitrary generator. So I'm using that, even though I know it accesses split behind the scenes. My thinking is that this only happens once so it is okay.) For example, is this code split-free? simple :: Rand StdGen [Int] simple = getRandomRs (0::Int, 10) main1 = do gen <- newStdGen let answer = (flip evalRand) gen $ do xs <- simple ys <- simple return $ (take 5 xs) ++ (take 3 ys) print answer Then, to elaborate on my specific problem, I need to create special types of infinite series. For example, I might need to create one that looks like this: 0 0 5 0 0 0 2 0 0 0 0 0 5 0 9 0 0 8 ... The pattern here is that there is some random number of zeros followed by a single non-zero value, followed again by a random number of zeros, etc. forever. This is one way to implement this. Does all look well here? makeSeries :: [Int] -> [a] -> a -> [a] makeSeries (i:is) (f:fs) zero = replicate i zero ++ [f] ++ makeSeries is fs zero lessSimple :: Rand StdGen [Int] lessSimple = do counts <- getRandomRs (1::Int , 5 ) values <- getRandomRs (1::Int , 9 ) return $ makeSeries counts values 0 main2 = do gen <- newStdGen let answer = evalRand lessSimple gen print . take 20 $ answer We could even have several of these series zipped together. Is this split-free? main3 = do gen <- newStdGen let fs = (flip evalRand) gen $ do s1 <- lessSimple s2 <- lessSimple return $ zip s1 s2 print . take 20 $ fs From sjoerd at w3future.com Mon Oct 12 09:49:51 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Mon Oct 12 09:27:11 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <1254943082.10848.30.camel@malachite> References: <1254943082.10848.30.camel@malachite> Message-ID: Hi Bob, I tried to understand this by applying what you said here to your deep embedding of a parsing DSL. But I can't figure out how to do that. What things become the type class T? greetings, Sjoerd On Oct 7, 2009, at 9:18 PM, Robert Atkey wrote: > >> What is a DSL? > > How about this as a formal-ish definition, for at least a pretty big > class of DSLs: > > A DSL is an algebraic theory in the sense of universal algebra. I.e. > it > is an API of a specific form, which consists of: > a) a collection of abstract types, the carriers. Need not all be of > kind *. > b) a collection of operations, of type > t1 -> t2 -> ... -> tn > where tn must be one of the carrier types from (a), but the others > can be any types you like. > c) (Optional) a collection of properties about the operations (e.g. > equations that must hold) > > Haskell has a nice way of specifying such things (except part (c)): > type > classes. > > Examples of type classes that fit this schema include Monad, > Applicative > and Alternative. Ones that don't include Eq, Ord and Show. The Num > type > class would be, if it didn't specify Eq and Show as superclasses. > > An implementation of a DSL is just an implementation of corresponding > type class. Shallowly embedded DSLs dispense with the type class step > and just give a single implementation. Deeply embedded implementations > are *initial* implementations: there is a unique function from the > deep > embedding to any of the other implementations that preserves all the > operations. The good thing about this definition is that anything we > do > to the deep embedding, we can do to any of the other implementations > via > the unique map. > > Thanks to Church and Reynolds, we can always get a deep embedding for > free (free as in "Theorems for Free"). If our DSL is defined by some > type class T, then the deep embedding is: > type DeepT = forall a. T a => a > (and so on, for multiple carrier types, possibly with type > parameterisation). > > Of course, there is often an easier and more efficient way of > representing the initial algebra using algebraic data types. > > Conor McBride often goes on about how the initial algebra (i.e. the > deep > embedding) of a given specification is the one you should be worrying > about, because it often has a nice concrete representation and gives > you > all you need to reason about any of the other implementations. > > Bob > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From doaitse at swierstra.net Mon Oct 12 10:26:42 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Mon Oct 12 10:04:14 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> References: <5326DD72-9DE6-4CC0-ADED-BA2C66206594@gmail.com> <625b74080910070935j6cc156a4ob733183a5f6487a7@mail.gmail.com> <20091007173016.GA26469@whirlpool.galois.com> <40a414c20910071106u5c705acdjc0e11768db129f35@mail.gmail.com> Message-ID: <634D0189-B86B-45F9-A247-765D112892C1@swierstra.net> Last February we celebrated the 25 years of CS education in Utrecht. On that occasion I wrote a paper for a wider public explaining my views on computer science and on programming languages in particular. I am attaching it since it might shed some light on the discussion, Doaitse > -------------- next part -------------- A non-text attachment was scrubbed... Name: JubileumBook.pdf Type: application/pdf Size: 163494 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/39b9264e/JubileumBook-0001.pdf From doaitse at swierstra.net Mon Oct 12 11:25:58 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Mon Oct 12 11:03:19 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: <94C8A81C-6A61-4B48-828C-E3C46329E631@swierstra.net> This problem of dynamically transforming grammars and bulding parsers out of it is addressed in: @inproceedings{1411296, author = {Viera, Marcos and Swierstra, S. Doaitse and Lempsink, Eelco}, title = {Haskell, do you read me?: constructing and composing efficient top-down parsers at runtime}, booktitle = {Haskell '08: Proceedings of the first ACM SIGPLAN symposium on Haskell}, year = {2008}, isbn = {978-1-60558-064-7}, pages = {63--74}, location = {Victoria, BC, Canada}, doi = {http://doi.acm.org/10.1145/1411286.1411296}, publisher = {ACM}, address = {New York, NY, USA}, } and the code can be found on hackage under the name ChristmasTree The left-factorisation is explained in a paper we presented at the last LDTA and which will appear in ENTCS. Since we have signed some copyright form I do notthink I can attach it here, but if you send me a mail, I can definitely send you the paper. Doaitse On 11 okt 2009, at 21:54, Ben Franksen wrote: > Ben Franksen wrote: >> Next thing I'll try is to transform such a grammar into an actual >> parser... > > Which I also managed to get working. However, this exposed yet another > problem I am not sure how to solve. > > The problem manifests itself with non-left-factored rules like > > Number ::= Digit Number | Digit > > Translating such a grammar directly into a Parsec parser leads to > parse > errors because Parsec's choice operator is predictive: if a > production has > consumed any input the whole choice fails, even if alternative > productions > would not: > > *Main> P.parseTest (parseGrammar myGrm) "2" > parse error at (line 1, column 2): > unexpected end of input > expecting Number > > Of course, one solution is to apply Parsec's try combinator to all > choices > in a rule. But this rather defeats the purpose of using a (by default) > predictive parser in the first place which is to avoid unnecessary > backtracking. > > So, a better solution is to left-factor the grammar before > translating to > Parsec. Since we have a data representation of the grammar that we can > readily analyse and transform, this should be possible given some > suitable > algorithm. But how is this transformation to be typed? > > My first naive attempt was to define (recap: nt :: * -> * is the > type of > nonterminals, t :: * is the type of terminals a.k.a. tokens, and a > is the > result type): > >> leftFactor :: Grammar nt t a -> Grammar nt t a > > Of course, this is wrong: Left-factoring is expected to introduce new > nonterminals, so on the right-hand side of the type we should not > have the > same 'nt' as on the left. Instead we shoudl have some other type that > is "'nt' extended with new constructors". Moreover, we cannot > statically > know how many new nonterminals are added, so we cannot simply apply > a type > function to nt. Is this solvable at all in Haskell or do I need proper > dependent types to express this? > > I have very vague ideas that revolve around setting up some > recursive type > function that on each level adds one constructor, define a common > interface > with a (multiparam) type class and then use existential > quantification in > the result type to hide the resulting type of nonterminals. > > The next question is: Even if this turns out to be possible, isn't it > overkill? Maybe it is better to use an infinite type for the > nonterminals > in the first place and let the grammar be a partial function? OTOH, > the > formulation of the grammar as a function that pattern matches on the > nonterminals is very elegant. > > Cheers > Ben > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From a.biurvOir4 at asuhan.com Mon Oct 12 12:22:53 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Mon Oct 12 12:00:11 2009 Subject: [Haskell-cafe] <**> for nested applicative functors? Message-ID: <25858792.post@talk.nabble.com> Does anyone know if it's possible to write the following: <**> :: (Applicative m, Applicative n) => m (n (a->b)) -> m (n a) -> m (n b) Clearly, if m and n were monads, it would be trivial. Rereading the original paper, I didn't see much discussion about such nested app. functors. Any help appreciated. -- View this message in context: http://www.nabble.com/%3C**%3E-for-nested-applicative-functors--tp25858792p25858792.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jwlato at gmail.com Mon Oct 12 12:29:57 2009 From: jwlato at gmail.com (John Lato) Date: Mon Oct 12 12:07:15 2009 Subject: [Haskell-cafe] Re: Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) Message-ID: <9979e72e0910120929l21408fbev7fec1a4e5bef6633@mail.gmail.com> > From: Derek Elkins > > On Sun, Oct 11, 2009 at 8:55 AM, Iain Barnett wrote: >> >> On 11 Oct 2009, at 13:58, John Lato wrote: >> >>> For anyone writing introductions to generic programming, take this as >>> a plea from Haskellers everywhere. ?If one of the RWH authors can't >>> understand how to make use of these techniques, what hope do the rest >>> of us have? >>> >>> John Lato >>> >>> P.S. Some might wryly note that I'm the maintainer of a package which >>> is also known for incomprehensible documentation. ?To which I would >>> reply that our effort is much newer, I consider it a problem, and it's >>> being worked on, contrasted to the state of GP where similarly >>> impenetrable documentation has been and continues to be the norm. >>> >> >> You could say that about most documentation (for Haskell and beyond). >> Apparently, programmers like programming better than documenting. The effect >> of this is that less people use their programming, making their efforts >> redundant. >> >> Silly really, considering programmers are (allegedly:) intelligent. > > Apparently, programmers like programming better than reading as > well... in my experience. I won't disagree. But I think the real difficulty is that the intersection of programmers who can come up with really good ways to solve problems (not even all programmers, unfortunately) and people who are good at writing documentation is vanishingly small. It seems to me that when someone works in a problem domain (e.g. Generic Programming), they gain a very deep understanding of that area and are used to working at a certain level within it. When introducing the topic to newcomers (even ostensibly smart programmers) the introduction can't assume prior knowledge of the problem domain, but the authors are so used to thinking at one level they often take for granted knowledge that the audience doesn't have. I don't think this problem is particular to programming, but it is common in Haskell. Most likely because Haskell, with a reputation as a research language, has a lot of computer science types doing research in wide-ranging topics. Somebody's expertise in category theory, for example, might not directly carry over to generic programming (or maybe it does; I'm not an expert in either). From josef.svenningsson at gmail.com Mon Oct 12 12:31:55 2009 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Mon Oct 12 12:09:15 2009 Subject: [Haskell-cafe] <**> for nested applicative functors? In-Reply-To: <25858792.post@talk.nabble.com> References: <25858792.post@talk.nabble.com> Message-ID: <8dde104f0910120931t22ee0287oe5709524a146ec6d@mail.gmail.com> On Mon, Oct 12, 2009 at 6:22 PM, Kim-Ee Yeoh wrote: > > Does anyone know if it's possible to write the following: > > <**> :: (Applicative m, Applicative n) => > m (n (a->b)) -> m (n a) -> m (n b) > > Clearly, if m and n were monads, it would be trivial. > > Rereading the original paper, I didn't see much discussion > about such nested app. functors. > > Any help appreciated. > How about m <**> n = pure (<*>) <*> m <*> n Hth, Josef From jeremy at n-heptane.com Mon Oct 12 12:32:19 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon Oct 12 12:09:41 2009 Subject: [Haskell-cafe] <**> for nested applicative functors? In-Reply-To: <25858792.post@talk.nabble.com> References: <25858792.post@talk.nabble.com> Message-ID: This looks like what is described in Section 4 to me: http://www.haskell.org/haskellwiki/Applicative_functor#Applicative_transfomers - jeremy On Oct 12, 2009, at 11:22 AM, Kim-Ee Yeoh wrote: > <**> :: (Applicative m, Applicative n) => > m (n (a->b)) -> m (n a) -> m (n b) From nowgate at yahoo.com Mon Oct 12 12:37:54 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Oct 12 12:15:13 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? Message-ID: <162522.98158.qm@web31102.mail.mud.yahoo.com> The first of these works, but not the second. It would seem that the type cannot change along a >>= chain, but I may be missing something in the code. Is the second example illegal? If so, is there a different way to change a String to an Int along the >>= chain? Michael =========== import Data.Char {- transform :: IO () transform = putStrLn "What is your word?" ???????? >> getLine ???????? >>= \str -> return ('Q':str) ???????? >>= \str -> return ('Z':str) ???????? >>= \str -> putStrLn $ "Transformed word is " ++ show str -} transform :: IO () transform = putStrLn "What is your digit string?" ???????? >> getLine ???????? >>= \str -> return ('9':str) ???????? >>= \str -> return (read str :: Int) ???????? >>= \i -> putStrLn $ "The number is " ++ show i -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/bdf6f33a/attachment.html From niklas.broberg at gmail.com Mon Oct 12 12:43:50 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Mon Oct 12 12:21:09 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? In-Reply-To: <162522.98158.qm@web31102.mail.mud.yahoo.com> References: <162522.98158.qm@web31102.mail.mud.yahoo.com> Message-ID: On Mon, Oct 12, 2009 at 6:37 PM, michael rice wrote: > transform :: IO () > transform = putStrLn "What is your digit string?" > >> getLine > >>= \str -> return ('9':str) > >>= \str -> return (read str :: Int) > >>= \i -> putStrLn $ "The number is " ++ show i > This code works perfectly for me. What problem are you seeing specifically? Cheers, /Niklas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/8ce5a1c1/attachment.html From noteed at gmail.com Mon Oct 12 12:44:55 2009 From: noteed at gmail.com (minh thu) Date: Mon Oct 12 12:22:34 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? In-Reply-To: <162522.98158.qm@web31102.mail.mud.yahoo.com> References: <162522.98158.qm@web31102.mail.mud.yahoo.com> Message-ID: <40a414c20910120944l3b9c1edbw80a05cd18844f5d8@mail.gmail.com> 2009/10/12 michael rice > The first of these works, but not the second. It would seem that the type > cannot change along a >>= chain, but I may be missing something in the code. > > Is the second example illegal? If so, is there a different way to change a > String to an Int along the >>= chain? > > Michael > > =========== > > import Data.Char > > {- > transform :: IO () > transform = putStrLn "What is your word?" > >> getLine > >>= \str -> return ('Q':str) > >>= \str -> return ('Z':str) > >>= \str -> putStrLn $ "Transformed word is " ++ show str > -} > > transform :: IO () > transform = putStrLn "What is your digit string?" > >> getLine > >>= \str -> return ('9':str) > >>= \str -> return (read str :: Int) > >>= \i -> putStrLn $ "The number is " ++ show i > > > Both seem good to me and my old ghci (6.6.1)... Thu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/41cd2567/attachment.html From a.biurvOir4 at asuhan.com Mon Oct 12 12:52:37 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Mon Oct 12 12:29:55 2009 Subject: [Haskell-cafe] <**> for nested applicative functors? In-Reply-To: References: <25858792.post@talk.nabble.com> Message-ID: <25859274.post@talk.nabble.com> That's it: liftA2 (<*>), so obvious in hindsight. Mustn't ... code ... when ... drained .... Thanks to Jeremy and Josef. Jeremy Shaw-3 wrote: > > This looks like what is described in Section 4 to me: > > http://www.haskell.org/haskellwiki/Applicative_functor#Applicative_transfomers > > - jeremy > > On Oct 12, 2009, at 11:22 AM, Kim-Ee Yeoh wrote: > >> <**> :: (Applicative m, Applicative n) => >> m (n (a->b)) -> m (n a) -> m (n b) > -- View this message in context: http://www.nabble.com/%3C**%3E-for-nested-applicative-functors--tp25858792p25859274.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ryani.spam at gmail.com Mon Oct 12 12:52:38 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Oct 12 12:30:00 2009 Subject: [Haskell-cafe] <**> for nested applicative functors? In-Reply-To: <25858792.post@talk.nabble.com> References: <25858792.post@talk.nabble.com> Message-ID: <2f9b2d30910120952o68e14df7xd3205a144e60f872@mail.gmail.com> fmap (<*>) :: m (n (a -> b)) -> m (n a -> n b) so f <**> x = (fmap (<*>) f) <*> x On Mon, Oct 12, 2009 at 9:22 AM, Kim-Ee Yeoh wrote: > > Does anyone know if it's possible to write the following: > > <**> :: (Applicative m, Applicative n) => > m (n (a->b)) -> m (n a) -> m (n b) > > Clearly, if m and n were monads, it would be trivial. > > Rereading the original paper, I didn't see much discussion > about such nested app. functors. > > Any help appreciated. > > -- > View this message in context: > http://www.nabble.com/%3C**%3E-for-nested-applicative-functors--tp25858792p25858792.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/cb74e785/attachment.html From nowgate at yahoo.com Mon Oct 12 12:53:51 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Oct 12 12:31:09 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? In-Reply-To: Message-ID: <747417.68334.qm@web31104.mail.mud.yahoo.com> Dumb! I just figured out I was entering the input string in quotes. So, I suppose the answer to my question is yes, type CAN be changed along a >>= chain. I was having trouble doing it in a different problem, created this small example to illustrate the problem, and then screwed it up putting quotes around my input string. Thanks! Michael --- On Mon, 10/12/09, Niklas Broberg wrote: From: Niklas Broberg Subject: Re: [Haskell-cafe] Can type be changed along a >>= chain? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Monday, October 12, 2009, 12:43 PM On Mon, Oct 12, 2009 at 6:37 PM, michael rice wrote: transform :: IO () transform = putStrLn "What is your digit string?" ???????? >> getLine ???????? >>= \str -> return ('9':str) ???????? >>= \str -> return (read str :: Int) ???????? >>= \i -> putStrLn $ "The number is " ++ show i This code works perfectly for me. What problem are you seeing specifically? Cheers,/Niklas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/cf9d0b07/attachment.html From noteed at gmail.com Mon Oct 12 13:05:48 2009 From: noteed at gmail.com (minh thu) Date: Mon Oct 12 12:43:27 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? In-Reply-To: <747417.68334.qm@web31104.mail.mud.yahoo.com> References: <747417.68334.qm@web31104.mail.mud.yahoo.com> Message-ID: <40a414c20910121005t26275b94hb924e1ff37f149bc@mail.gmail.com> I hope you're not building some unneeded "rules" in your head. There is no reason to believe there is something to be remembered about whether or not "types can change along a >>= chain". That chain has nothing special in Haskell. >>= is just an operator, much like ++, ! or . ghci> :t (>>=) (>>=) :: (Monad m) => m a -> (a -> m b) -> m b This says that, you provide an a and you get a b. Nothing says the a and b have to be the same upon successive uses. Likewise, ghci> :t (+) (+) :: (Num a) => a -> a -> a fromIntegral ((1 :: Int) + 2) + (3 :: Integer) 6 This shows clearly that the types are not the same along the "+ chain". 2009/10/12 michael rice > Dumb! I just figured out I was entering the input string in quotes. > > So, I suppose the answer to my question is yes, type CAN be changed along a > >>= chain. I was having trouble doing it in a different problem, created > this small example to illustrate the problem, and then screwed it up putting > quotes around my input string. > > Thanks! > > Michael > > --- On *Mon, 10/12/09, Niklas Broberg * wrote: > > > From: Niklas Broberg > Subject: Re: [Haskell-cafe] Can type be changed along a >>= chain? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Monday, October 12, 2009, 12:43 PM > > On Mon, Oct 12, 2009 at 6:37 PM, michael rice > > wrote: > >> transform :: IO () >> transform = putStrLn "What is your digit string?" >> >> getLine >> >>= \str -> return ('9':str) >> >>= \str -> return (read str :: Int) >> >>= \i -> putStrLn $ "The number is " ++ show i >> > This code works perfectly for me. What problem are you seeing specifically? > Cheers, > /Niklas > > > > _______________________________________________ > 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/20091012/5957d5d3/attachment.html From bob.atkey at ed.ac.uk Mon Oct 12 13:12:28 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Mon Oct 12 12:50:00 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: References: <1254943082.10848.30.camel@malachite> Message-ID: <1255367548.5019.321.camel@antimony> On Mon, 2009-10-12 at 15:49 +0200, Sjoerd Visscher wrote: > Hi Bob, > > I tried to understand this by applying what you said here to your deep > embedding of a parsing DSL. But I can't figure out how to do that. > What things become the type class T? Here's the "API" version of the grammar DSL: class GrammarDSL grammar where type Rule grammar :: (* -> *) -> * -> * pure :: a -> Rule grammar nt a (<*>) :: Rule grammar nt (a -> b) -> Rule grammar nt a -> Rule grammar nt b empty :: Rule grammar nt a (<|>) :: Rule grammar nt a -> Rule grammar nt a -> Rule grammar nt a char :: Char -> Rule grammar nt () nt :: nt a -> Rule grammar nt a grammar :: forall nt a. nt a -> (forall a. nt a -> Rule grammar nt a) -> grammar nt a The language of typed-grammars-with-actions is composed of: * two sorts: "grammar"s and "rule"s * "rule"s support the applicative and alternative interfaces, and also two special operators for incorporating terminals and nonterminals into rules. * "grammar"s support a single operation: taking a nonterminal-indexed collection of rules, and a starting non-terminal (as Ben Franksen pointed out), producing a grammar. Basically, the idea is to think 1) "what are the syntactic categories of my DSL?", these become the sorts; 2) "what are the basic syntactic constructions of my DSL?", these become the operations of the type class. Because we are embedded in Haskell, we can have infinite syntax, as demonstrated by the "grammar" operation. WRT the recipe for getting deep embeddings in my previous post, it isn't quite true that the type Grammar nt a = forall grammar. GrammarDSL grammar => grammar nt a is isomorphic to the deep embedding I posted before, because it doesn't guarantee that the applicative functor or alternative laws hold, while the deep embedding does (and it also ensures that <*> and <|> distribute). It isn't hard to come up with a deep embedding that is initial for the completely free version though. The deep embedding from the previous post is an instance of this type class. So is, as Ben Franksen showed, a Parsec parser. I ended up having to inline the applicative and alternative interfaces into the class definition above. I wanted to write: class (Applicative (Rule grammar nt), Alternative (Rule grammar nt)) => Grammar grammar where ... but GHC wouldn't let me, complaining that 'nt' wasn't bound. Is there any reason this couldn't be made to work? Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From muad.dib.space at gmail.com Mon Oct 12 13:42:10 2009 From: muad.dib.space at gmail.com (muad) Date: Mon Oct 12 13:19:28 2009 Subject: [Haskell-cafe] is proof by testing possible? Message-ID: <25860155.post@talk.nabble.com> Is it possible to prove correctness of a functions by testing it? I think the tests would have to be constructed by inspecting the shape of the function definition. -- View this message in context: http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jfredett at gmail.com Mon Oct 12 13:48:55 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 13:26:15 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <25860155.post@talk.nabble.com> References: <25860155.post@talk.nabble.com> Message-ID: In general? No- If we had an implementation of the `sin` function, how can testing a finite number of points along it determine if that implementation is correct for every point? For specific functions (particularly those with finite domain), it is possible. If you know the 'correct' output of every input, then testing each input and ensuring correct output will work. Consider the definition of the `not` function on booleans. The domain only has two elements (True and False) and the range has only two outputs (True and False), so if I test every input, and insure it maps appropriately to the specified output, we're all set. Basically, if you can write your function as a big case statement that covers the whole domain, and that domain is finite, then the function can be tested to prove it's correctness. Now, I should think the Muad'Dib would know that, perhaps you should go back to studying with the Mentats. :) /Joe On Oct 12, 2009, at 1:42 PM, muad wrote: > > Is it possible to prove correctness of a functions by testing it? I > think the > tests would have to be constructed by inspecting the shape of the > function > definition. > > -- > View this message in context: http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html > Sent from the Haskell - Haskell-Cafe mailing list archive at > Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ekirpichov at gmail.com Mon Oct 12 13:55:20 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Oct 12 13:32:38 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: References: <25860155.post@talk.nabble.com> Message-ID: <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> It is possible for functions with compact domain, not just finite. 2009/10/12 Joe Fredette : > In general? No- If we had an implementation of the `sin` function, how can > testing a finite number of points along it determine > if that implementation is correct for every point? > > For specific functions (particularly those with finite domain), it is > possible. If you know the 'correct' output of every input, then testing each > input and ensuring correct output will work. Consider the definition of the > `not` function on booleans. The domain only has two elements (True and > False) and the range has only two outputs (True and False), so if I test > every input, and insure it maps appropriately to the specified output, we're > all set. > > Basically, if you can write your function as a big case statement that > covers the whole domain, and that domain is finite, then the function can be > tested to prove it's correctness. > > Now, I should think the Muad'Dib would know that, perhaps you should go back > to studying with the Mentats. :) > > /Joe > > > > On Oct 12, 2009, at 1:42 PM, muad wrote: > >> >> Is it possible to prove correctness of a functions by testing it? I think >> the >> tests would have to be constructed by inspecting the shape of the function >> definition. >> >> -- >> View this message in context: >> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From ekirpichov at gmail.com Mon Oct 12 13:56:30 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Oct 12 13:33:49 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> Message-ID: <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> For example, it is possible to prove correctness of a function "negatedHead :: [Bool] -> Bool" by testing it on "True:undefined" and "False:undefined". 2009/10/12 Eugene Kirpichov : > It is possible for functions with compact domain, not just finite. > > 2009/10/12 Joe Fredette : >> In general? No- If we had an implementation of the `sin` function, how can >> testing a finite number of points along it determine >> if that implementation is correct for every point? >> >> For specific functions (particularly those with finite domain), it is >> possible. If you know the 'correct' output of every input, then testing each >> input and ensuring correct output will work. Consider the definition of the >> `not` function on booleans. The domain only has two elements (True and >> False) and the range has only two outputs (True and False), so if I test >> every input, and insure it maps appropriately to the specified output, we're >> all set. >> >> Basically, if you can write your function as a big case statement that >> covers the whole domain, and that domain is finite, then the function can be >> tested to prove it's correctness. >> >> Now, I should think the Muad'Dib would know that, perhaps you should go back >> to studying with the Mentats. :) >> >> /Joe >> >> >> >> On Oct 12, 2009, at 1:42 PM, muad wrote: >> >>> >>> Is it possible to prove correctness of a functions by testing it? I think >>> the >>> tests would have to be constructed by inspecting the shape of the function >>> definition. >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >>> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- Eugene Kirpichov Web IR developer, market.yandex.ru From jfredett at gmail.com Mon Oct 12 13:57:27 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 13:34:47 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> Message-ID: <90BDA05B-C041-4D72-8998-70B2E7A87372@gmail.com> Really? How? That sounds very interesting, I've got a fair knowledge of basic topology, I'd love to see an application to programming... On Oct 12, 2009, at 1:55 PM, Eugene Kirpichov wrote: > It is possible for functions with compact domain, not just finite. > > 2009/10/12 Joe Fredette : >> In general? No- If we had an implementation of the `sin` function, >> how can >> testing a finite number of points along it determine >> if that implementation is correct for every point? >> >> For specific functions (particularly those with finite domain), it is >> possible. If you know the 'correct' output of every input, then >> testing each >> input and ensuring correct output will work. Consider the >> definition of the >> `not` function on booleans. The domain only has two elements (True >> and >> False) and the range has only two outputs (True and False), so if I >> test >> every input, and insure it maps appropriately to the specified >> output, we're >> all set. >> >> Basically, if you can write your function as a big case statement >> that >> covers the whole domain, and that domain is finite, then the >> function can be >> tested to prove it's correctness. >> >> Now, I should think the Muad'Dib would know that, perhaps you >> should go back >> to studying with the Mentats. :) >> >> /Joe >> >> >> >> On Oct 12, 2009, at 1:42 PM, muad wrote: >> >>> >>> Is it possible to prove correctness of a functions by testing it? >>> I think >>> the >>> tests would have to be constructed by inspecting the shape of the >>> function >>> definition. >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >>> Sent from the Haskell - Haskell-Cafe mailing list archive at >>> Nabble.com. >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru From ekirpichov at gmail.com Mon Oct 12 13:58:19 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Oct 12 13:35:38 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> Message-ID: <5e0214850910121058k3afdc28cr182929dd9c0996fd@mail.gmail.com> Also google "seemingly impossible functional programs". 2009/10/12 Eugene Kirpichov : > For example, it is possible to prove correctness of a function > "negatedHead :: [Bool] -> Bool" by testing it on "True:undefined" and > "False:undefined". > > 2009/10/12 Eugene Kirpichov : >> It is possible for functions with compact domain, not just finite. >> >> 2009/10/12 Joe Fredette : >>> In general? No- If we had an implementation of the `sin` function, how can >>> testing a finite number of points along it determine >>> if that implementation is correct for every point? >>> >>> For specific functions (particularly those with finite domain), it is >>> possible. If you know the 'correct' output of every input, then testing each >>> input and ensuring correct output will work. Consider the definition of the >>> `not` function on booleans. The domain only has two elements (True and >>> False) and the range has only two outputs (True and False), so if I test >>> every input, and insure it maps appropriately to the specified output, we're >>> all set. >>> >>> Basically, if you can write your function as a big case statement that >>> covers the whole domain, and that domain is finite, then the function can be >>> tested to prove it's correctness. >>> >>> Now, I should think the Muad'Dib would know that, perhaps you should go back >>> to studying with the Mentats. :) >>> >>> /Joe >>> >>> >>> >>> On Oct 12, 2009, at 1:42 PM, muad wrote: >>> >>>> >>>> Is it possible to prove correctness of a functions by testing it? I think >>>> the >>>> tests would have to be constructed by inspecting the shape of the function >>>> definition. >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >>>> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> >> -- >> Eugene Kirpichov >> Web IR developer, market.yandex.ru >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- Eugene Kirpichov Web IR developer, market.yandex.ru From jfredett at gmail.com Mon Oct 12 13:59:17 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 13:36:37 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> Message-ID: <68F23F1A-3389-4584-A1EC-D1F7DCD857C1@gmail.com> Oh- thanks for the example, I suppose you can disregard my other message. I suppose this is a bit like short-circuiting. No? On Oct 12, 2009, at 1:56 PM, Eugene Kirpichov wrote: > For example, it is possible to prove correctness of a function > "negatedHead :: [Bool] -> Bool" by testing it on "True:undefined" and > "False:undefined". > > 2009/10/12 Eugene Kirpichov : >> It is possible for functions with compact domain, not just finite. >> >> 2009/10/12 Joe Fredette : >>> In general? No- If we had an implementation of the `sin` function, >>> how can >>> testing a finite number of points along it determine >>> if that implementation is correct for every point? >>> >>> For specific functions (particularly those with finite domain), it >>> is >>> possible. If you know the 'correct' output of every input, then >>> testing each >>> input and ensuring correct output will work. Consider the >>> definition of the >>> `not` function on booleans. The domain only has two elements (True >>> and >>> False) and the range has only two outputs (True and False), so if >>> I test >>> every input, and insure it maps appropriately to the specified >>> output, we're >>> all set. >>> >>> Basically, if you can write your function as a big case statement >>> that >>> covers the whole domain, and that domain is finite, then the >>> function can be >>> tested to prove it's correctness. >>> >>> Now, I should think the Muad'Dib would know that, perhaps you >>> should go back >>> to studying with the Mentats. :) >>> >>> /Joe >>> >>> >>> >>> On Oct 12, 2009, at 1:42 PM, muad wrote: >>> >>>> >>>> Is it possible to prove correctness of a functions by testing it? >>>> I think >>>> the >>>> tests would have to be constructed by inspecting the shape of the >>>> function >>>> definition. >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >>>> Sent from the Haskell - Haskell-Cafe mailing list archive at >>>> Nabble.com. >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> >> -- >> Eugene Kirpichov >> Web IR developer, market.yandex.ru >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru From dpiponi at gmail.com Mon Oct 12 14:00:03 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Oct 12 13:37:23 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <25860155.post@talk.nabble.com> References: <25860155.post@talk.nabble.com> Message-ID: <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> On Mon, Oct 12, 2009 at 10:42 AM, muad wrote: > > Is it possible to prove correctness of a functions by testing it? I think the > tests would have to be constructed by inspecting the shape of the function > definition. not True==False not False==True Done. Tested :-) Less trivially, consider a function of signature swap :: (a,b) -> (b,a) We don't need to test it at all, it can only do one thing, swap its arguments. (Assuming it terminates.) But consider: swap :: (a,a) -> (a,a) If I find that swap (1,2) == (2,1) then I know that swap (x,y)==(y,x) for all types a and b. We only need one test. The reason is that we have a free theorem that says that for all functions, f, of type (a,a) -> (a,a) this holds: f (g a,g b) == let (x,y) = f (a,b) in (g x',g y') For any x and y define g 1 = x g 2 = y Then f(x,y) == f (g 1,g 2) == let (x',y') == f(1,2) in (g x',g y') == let (x',y') == (2,1) in (g x',g y') == (g 2,g 1) == (y,x) In other words, free theorems can turn an infinite amount of testing into a finite test. (Assuming termination.) -- Dan From bos at serpentine.com Mon Oct 12 14:01:00 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Oct 12 13:38:17 2009 Subject: [Haskell-cafe] statistics package and randomness In-Reply-To: <4AD2D9F7.1040702@alumni.caltech.edu> References: <4AD2D9F7.1040702@alumni.caltech.edu> Message-ID: On Mon, Oct 12, 2009 at 12:25 AM, Michael Mossey wrote: > I'm trying to learn how to use randomness in Haskell and it seems very > non-straightforward and complex. I could do a lot of things using 'split' > from System.Random, but apparently it's broken. There is the statistics > package here: > > http://hackage.haskell.org/package/statistics > > Is this a better solution? > Yes, as it's much faster, more robust, and (depending on your perspective) easier to use, provided you understand the ST monad. > It uses the ST monad in the RandomVariate module. Can someone point me to a > tutorial explaining ST, and/or a tutorial in the RandomVariate module? > For a tutorial on grokking ST, I'd suggest chapter 26 of Real World Haskell, but I'm biased, since I wrote it: http://book.realworldhaskell.org/read/advanced-library-design-building-a-bloom-filter.html Note that this already assumes that you understand monads pretty well. Pseudorandomness seems like one case where it would just be a hell of a lot > simpler to have a global generator--never split the state. Is the ST monad > some way to accomplish this? Having -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/b8766d1d/attachment.html From jfredett at gmail.com Mon Oct 12 14:03:11 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 13:40:34 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> Message-ID: <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> I completely forgot about free theorems! Do you have some links to resources -- I tried learning about them a while ago, but couldn't get a grasp on them... Thanks. /Joe On Oct 12, 2009, at 2:00 PM, Dan Piponi wrote: > On Mon, Oct 12, 2009 at 10:42 AM, muad > wrote: >> >> Is it possible to prove correctness of a functions by testing it? I >> think the >> tests would have to be constructed by inspecting the shape of the >> function >> definition. > > not True==False > not False==True > > Done. Tested :-) > > Less trivially, consider a function of signature > > swap :: (a,b) -> (b,a) > > We don't need to test it at all, it can only do one thing, swap its > arguments. (Assuming it terminates.) > > But consider: > swap :: (a,a) -> (a,a) > > If I find that swap (1,2) == (2,1) then I know that swap (x,y)==(y,x) > for all types a and b. We only need one test. > The reason is that we have a free theorem that says that for all > functions, f, of type (a,a) -> (a,a) this holds: > > f (g a,g b) == let (x,y) = f (a,b) in (g x',g y') > > For any x and y define > > g 1 = x > g 2 = y > > Then f(x,y) == f (g 1,g 2) == let (x',y') == f(1,2) in (g x',g y') == > let (x',y') == (2,1) in (g x',g y') == (g 2,g 1) == (y,x) > > In other words, free theorems can turn an infinite amount of testing > into a finite test. (Assuming termination.) > -- > Dan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bos at serpentine.com Mon Oct 12 14:05:03 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Oct 12 13:42:21 2009 Subject: [Haskell-cafe] statistics package and randomness In-Reply-To: References: <4AD2D9F7.1040702@alumni.caltech.edu> Message-ID: On Mon, Oct 12, 2009 at 11:01 AM, Bryan O'Sullivan wrote: > > Pseudorandomness seems like one case where it would just be a hell of a lot >> simpler to have a global generator--never split the state. Is the ST monad >> some way to accomplish this? > > > Having [...] > Feh, gmail fail. Having a global generator is not actually a good thing, since it has to live *somewhere*. If you keep its existence implicit, it becomes slow, since you have to lock it against concurrent use by multiple threads. If you make it explicit, you have to plumb the thing all over the place by hand, which is also nasty. The advantage of putting the PRNG in the ST monad is that you can seed a new PRNG close to the point where you'll need it, and not need to pass around so much state. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/86e66566/attachment.html From dpiponi at gmail.com Mon Oct 12 14:09:56 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Oct 12 13:47:14 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> Message-ID: <625b74080910121109k635d2d9fx75472783d8c58c91@mail.gmail.com> Joe, > On Mon, Oct 12, 2009 at 11:03 AM, Joe Fredette wrote: > I completely forgot about free theorems! Do you have some links to resources > -- I tried learning about them a while > ago, but couldn't get a grasp on them... Thanks. There is Wadler's paper but I do find it tricky: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.9875 You can play with the generator here: http://linux.tcs.inf.tu-dresden.de/~voigt/ft/ The results can look unreadable at first, but I find that if I copy them onto paper and do all of the remaining substitutions manually (like I had to do with (a,b) -> (b,a)) you end up with something readable. If you keep doing this you'll get a good intuition for what the free theorem for a type will look like. -- Dan From ekirpichov at gmail.com Mon Oct 12 14:11:05 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Oct 12 13:48:24 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <68F23F1A-3389-4584-A1EC-D1F7DCD857C1@gmail.com> References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> <68F23F1A-3389-4584-A1EC-D1F7DCD857C1@gmail.com> Message-ID: <5e0214850910121111w45d0105aida49f72a54d5eae4@mail.gmail.com> What do you mean under short-circuiting here, and what is the connection? The property that allows to deduce global correctness from correctness on under-defined inputs is just continuity in the topological sense. 2009/10/12 Joe Fredette : > Oh- thanks for the example, I suppose you can disregard my other message. > > I suppose this is a bit like short-circuiting. No? > > > On Oct 12, 2009, at 1:56 PM, Eugene Kirpichov wrote: > >> For example, it is possible to prove correctness of a function >> "negatedHead :: [Bool] -> Bool" by testing it on "True:undefined" and >> "False:undefined". >> >> 2009/10/12 Eugene Kirpichov : >>> >>> It is possible for functions with compact domain, not just finite. >>> >>> 2009/10/12 Joe Fredette : >>>> >>>> In general? No- If we had an implementation of the `sin` function, how >>>> can >>>> testing a finite number of points along it determine >>>> if that implementation is correct for every point? >>>> >>>> For specific functions (particularly those with finite domain), it is >>>> possible. If you know the 'correct' output of every input, then testing >>>> each >>>> input and ensuring correct output will work. Consider the definition of >>>> the >>>> `not` function on booleans. The domain only has two elements (True and >>>> False) and the range has only two outputs (True and False), so if I test >>>> every input, and insure it maps appropriately to the specified output, >>>> we're >>>> all set. >>>> >>>> Basically, if you can write your function as a big case statement that >>>> covers the whole domain, and that domain is finite, then the function >>>> can be >>>> tested to prove it's correctness. >>>> >>>> Now, I should think the Muad'Dib would know that, perhaps you should go >>>> back >>>> to studying with the Mentats. :) >>>> >>>> /Joe >>>> >>>> >>>> >>>> On Oct 12, 2009, at 1:42 PM, muad wrote: >>>> >>>>> >>>>> Is it possible to prove correctness of a functions by testing it? I >>>>> think >>>>> the >>>>> tests would have to be constructed by inspecting the shape of the >>>>> function >>>>> definition. >>>>> >>>>> -- >>>>> View this message in context: >>>>> >>>>> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >>>>> Sent from the Haskell - Haskell-Cafe mailing list archive at >>>>> Nabble.com. >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> >>> >>> -- >>> Eugene Kirpichov >>> Web IR developer, market.yandex.ru >>> >> >> >> >> -- >> Eugene Kirpichov >> Web IR developer, market.yandex.ru > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From dpiponi at gmail.com Mon Oct 12 14:11:16 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Oct 12 13:48:39 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <625b74080910121109k635d2d9fx75472783d8c58c91@mail.gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> <625b74080910121109k635d2d9fx75472783d8c58c91@mail.gmail.com> Message-ID: <625b74080910121111k192e6b0bt27885b3b66edd25a@mail.gmail.com> I'm making the same mistake repeatedly. In both my mails there are places where I said (a,b) or (b,a) when I meant (a,a). -- Dan On Mon, Oct 12, 2009 at 11:09 AM, Dan Piponi wrote: > Joe, > >> On Mon, Oct 12, 2009 at 11:03 AM, Joe Fredette wrote: >> I completely forgot about free theorems! Do you have some links to resources >> -- I tried learning about them a while >> ago, but couldn't get a grasp on them... Thanks. > > There is Wadler's paper but I do find it tricky: > http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.9875 > > You can play with the generator here: > http://linux.tcs.inf.tu-dresden.de/~voigt/ft/ > The results can look unreadable at first, but I find that if I copy > them onto paper and do all of the remaining substitutions manually > (like I had to do with (a,b) -> (b,a)) you end up with something > readable. If you keep doing this you'll get a good intuition for what > the free theorem for a type will look like. > -- > Dan > From jfredett at gmail.com Mon Oct 12 14:22:11 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 13:59:30 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <5e0214850910121111w45d0105aida49f72a54d5eae4@mail.gmail.com> References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <5e0214850910121056q2d0c7236ib72ddbc90fa44233@mail.gmail.com> <68F23F1A-3389-4584-A1EC-D1F7DCD857C1@gmail.com> <5e0214850910121111w45d0105aida49f72a54d5eae4@mail.gmail.com> Message-ID: <91BCB501-98C8-4130-9D89-983AB98D6FC1@gmail.com> I mean that, like in the definition of `||` True || _ = True False || x = x If you generalize this to `or`-ing a list of inputs, eg: foldr (||) False list_of_bools you can 'short-circuit' the test as soon as you find a 'True' value. This is actually not the greatest example, since you can't actually test it in finite number of tests, but you can test "half" the function by testing a that lists like [True:undefined] or [False, False, False, ... , True , undefined] return "True". It's "short-circuiting" in the sense that it (like the `||` function) doesn't need to see (necessarily) all of it's arguments to return a correct result. /Joe On Oct 12, 2009, at 2:11 PM, Eugene Kirpichov wrote: > What do you mean under short-circuiting here, and what is the > connection? > The property that allows to deduce global correctness from correctness > on under-defined inputs is just continuity in the topological sense. > > 2009/10/12 Joe Fredette : >> Oh- thanks for the example, I suppose you can disregard my other >> message. >> >> I suppose this is a bit like short-circuiting. No? >> >> >> On Oct 12, 2009, at 1:56 PM, Eugene Kirpichov wrote: >> >>> For example, it is possible to prove correctness of a function >>> "negatedHead :: [Bool] -> Bool" by testing it on "True:undefined" >>> and >>> "False:undefined". >>> >>> 2009/10/12 Eugene Kirpichov : >>>> >>>> It is possible for functions with compact domain, not just finite. >>>> >>>> 2009/10/12 Joe Fredette : >>>>> >>>>> In general? No- If we had an implementation of the `sin` >>>>> function, how >>>>> can >>>>> testing a finite number of points along it determine >>>>> if that implementation is correct for every point? >>>>> >>>>> For specific functions (particularly those with finite domain), >>>>> it is >>>>> possible. If you know the 'correct' output of every input, then >>>>> testing >>>>> each >>>>> input and ensuring correct output will work. Consider the >>>>> definition of >>>>> the >>>>> `not` function on booleans. The domain only has two elements >>>>> (True and >>>>> False) and the range has only two outputs (True and False), so >>>>> if I test >>>>> every input, and insure it maps appropriately to the specified >>>>> output, >>>>> we're >>>>> all set. >>>>> >>>>> Basically, if you can write your function as a big case >>>>> statement that >>>>> covers the whole domain, and that domain is finite, then the >>>>> function >>>>> can be >>>>> tested to prove it's correctness. >>>>> >>>>> Now, I should think the Muad'Dib would know that, perhaps you >>>>> should go >>>>> back >>>>> to studying with the Mentats. :) >>>>> >>>>> /Joe >>>>> >>>>> >>>>> >>>>> On Oct 12, 2009, at 1:42 PM, muad wrote: >>>>> >>>>>> >>>>>> Is it possible to prove correctness of a functions by testing >>>>>> it? I >>>>>> think >>>>>> the >>>>>> tests would have to be constructed by inspecting the shape of the >>>>>> function >>>>>> definition. >>>>>> >>>>>> -- >>>>>> View this message in context: >>>>>> >>>>>> http://www.nabble.com/is-proof-by-testing-possible--tp25860155p25860155.html >>>>>> Sent from the Haskell - Haskell-Cafe mailing list archive at >>>>>> Nabble.com. >>>>>> >>>>>> _______________________________________________ >>>>>> Haskell-Cafe mailing list >>>>>> Haskell-Cafe@haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>> >>>> >>>> >>>> -- >>>> Eugene Kirpichov >>>> Web IR developer, market.yandex.ru >>>> >>> >>> >>> >>> -- >>> Eugene Kirpichov >>> Web IR developer, market.yandex.ru >> >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru From nccb2 at kent.ac.uk Mon Oct 12 14:31:11 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon Oct 12 14:08:29 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> Message-ID: <4AD375EF.3090103@kent.ac.uk> Dan Piponi wrote: > On Mon, Oct 12, 2009 at 10:42 AM, muad wrote: > >> Is it possible to prove correctness of a functions by testing it? >> > consider a function of signature > > swap :: (a,b) -> (b,a) > > We don't need to test it at all, it can only do one thing, swap its > arguments. (Assuming it terminates.) > swap = undefined Terminates and does not swap its arguments :-) What do free theorems say about this, exactly -- do they just implicitly exclude this possibility? Neil. From simonkaltenbacher at googlemail.com Mon Oct 12 14:48:49 2009 From: simonkaltenbacher at googlemail.com (SimonK77) Date: Mon Oct 12 14:26:07 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence Message-ID: <25861134.post@talk.nabble.com> Hallo everyone, the last few weeks I was trying to get used to memoization in haskell. As I found out in a previous post, memoization in haskell is, due to the graph reduction strategy used in haskell, almost always implemented by sharing subexpressions in an expression. In examples as the following this is quite easy to see. fibs = 0:1:zipWith (+) fibs (tail fibs) But as I browsed through the search results from google for this topic, I encountered the following implementation: memoized_fib :: Int -> Integer memoized_fib = let fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1) in (map fib [0 ..] !!) You'll find it at Haskell.org. Here's the http://www.haskell.org/haskellwiki/Memoization link Let's assume we have the following implementation of the higher-order-function map: map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (x:xs) = f x : map f xs The reduction sequence of memoized_fib 5 would start as follows: //Reduction of memoized_fib 5 memoized_fib 5 = (map fib [0..] !!) 5 = (fib 0 : map fib [1..] !!) 5 = (0 : fib 1 : map fib [2..] !!) 5 = (0 : 1 : fib 2 : map fib [3..] !!) 5 = (0 : 1 : (memoized_fib 0 + memoized_fib 1) : fib 3 : map fib [4..] !!) 5 = (0 : 1 : (map fib [0..] !! 0 + map fib [0..] !! 1) : (memoized_fib 1 + memoized_fib 2) : map fib [4..] !!) 5 . . . . and so on! I can't see where the sharing of subexpressions happens here. Any help is highly appreciated. Best regards Simon -- View this message in context: http://www.nabble.com/Sharing-Subexpressions%3A-Memoization-of-Fibonacci-sequence-tp25861134p25861134.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/1a29e61c/attachment.html From simonkaltenbacher at googlemail.com Mon Oct 12 14:52:30 2009 From: simonkaltenbacher at googlemail.com (SimonK77) Date: Mon Oct 12 14:29:49 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence In-Reply-To: <25861134.post@talk.nabble.com> References: <25861134.post@talk.nabble.com> Message-ID: <25861177.post@talk.nabble.com> **Edit: formatting was bad** Hallo everyone, the last few weeks I was trying to get used to memoization in haskell. As I found out in a previous post, memoization in haskell is, due to the graph reduction strategy used in haskell, almost always implemented by sharing subexpressions in an expression. In examples as the following this is quite easy to see. fibs = 0:1:zipWith (+) fibs (tail fibs) But as I browsed through the search results from google for this topic, I encountered the following implementation: memoized_fib :: Int -> Integer memoized_fib = let fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1) in (map fib [0 ..] !!) You'll find it at Haskell.org. Here's the http://www.haskell.org/haskellwiki/Memoization link Let's assume we have the following implementation of the higher-order-function map: map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (x:xs) = f x : map f xs The reduction sequence of memoized_fib 5 would start as follows: //Reduction of memoized_fib 5 memoized_fib 5 = (map fib [0..] !!) 5 = (fib 0 : map fib [1..] !!) 5 = (0 : fib 1 : map fib [2..] !!) 5 = (0 : 1 : fib 2 : map fib [3..] !!) 5 = (0 : 1 : (memoized_fib 0 + memoized_fib 1) : fib 3 : map fib [4..] !!) 5 = (0 : 1 : (map fib [0..] !! 0 + map fib [0..] !! 1) : (memoized_fib 1 + memoized_fib 2) : map fib [4..] !!) 5 . . . . and so on! I can't see where the sharing of subexpressions happens here. Any help is highly appreciated. Best regards Simon -- View this message in context: http://www.nabble.com/Sharing-Subexpressions%3A-Memoization-of-Fibonacci-sequence-tp25861134p25861177.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jochem at functor.nl Mon Oct 12 14:52:49 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Mon Oct 12 14:30:10 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <4AD375EF.3090103@kent.ac.uk> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4AD375EF.3090103@kent.ac.uk> Message-ID: <4AD37B01.4010801@functor.nl> Neil Brown wrote: > Dan Piponi wrote: >> On Mon, Oct 12, 2009 at 10:42 AM, muad wrote: >> >>> Is it possible to prove correctness of a functions by testing it? >> consider a function of signature >> >> swap :: (a,b) -> (b,a) >> >> We don't need to test it at all, it can only do one thing, swap its >> arguments. (Assuming it terminates.) >> > swap = undefined > > Terminates and does not swap its arguments :-) What do free theorems > say about this, exactly -- do they just implicitly exclude this > possibility? Normally, one presumes that "undefined" (id est, calling "error") is equivalent to looping, except that calling "error" is pragmatically speaking better: it is nicer to the caller of your function (they/you get to see a somewhat more descriptive error message instead of 100% CPU without any results). Regards, Jochem -- Jochem Berndsen | jochem@functor.nl | jochem@????.com From dpiponi at gmail.com Mon Oct 12 14:56:44 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Oct 12 14:34:03 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <4AD375EF.3090103@kent.ac.uk> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4AD375EF.3090103@kent.ac.uk> Message-ID: <625b74080910121156h427acd67nccbce002168e172f@mail.gmail.com> On Mon, Oct 12, 2009 at 11:31 AM, Neil Brown wrote: > swap = undefined > > Terminates and does not swap its arguments :-) What do free theorems say > about this, exactly -- do they just implicitly exclude this possibility? I'm terrible at reasoning about functions with bottoms (ie. undefined or non-termination). But I suspect that a property like this holds: if the type signature of a function f is polymorphic in a, and it doesn't produce bottom for one particular value x of type a, for some particular type a, f can never produce bottom for any choice of x in any choice of type a. (Which is not to say it might not fail, but that the failure will be an issue with x, not f.) The intuition behind this is that if a function is polymorphic in a then it never examines the a. So even if a is bottom, the function can never know it. But it could fail because f additionally accepts as argument a polymorphic function that itself accepts a's, and that fails. But then it wouldn't be f's fault, it'd be the fault of the function you passed in. This is very poor of me. There's probably a nice precise formulation of what I've just said :-) -- Dan From noteed at gmail.com Mon Oct 12 15:09:38 2009 From: noteed at gmail.com (minh thu) Date: Mon Oct 12 14:47:16 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence In-Reply-To: <25861177.post@talk.nabble.com> References: <25861134.post@talk.nabble.com> <25861177.post@talk.nabble.com> Message-ID: <40a414c20910121209i7667f5dcm4b02f0d34c3ea58d@mail.gmail.com> 2009/10/12 SimonK77 : > > **Edit: formatting was bad** > > Hallo everyone, > > the last few weeks I was trying to get used to memoization in haskell. As I > found out in a previous post, memoization in haskell is, due to the graph > reduction strategy used in haskell, almost always implemented by sharing > subexpressions in an expression. > > In examples as the following this is quite easy to see. > > fibs = 0:1:zipWith (+) fibs (tail fibs) > > But as I browsed through the search results from google for this topic, I > encountered the following implementation: > > memoized_fib :: Int -> Integer > memoized_fib = > let fib 0 = 0 > fib 1 = 1 > fib n = memoized_fib (n-2) + memoized_fib (n-1) > in (map fib [0 ..] !!) > > You'll find it at Haskell.org. Here's the > http://www.haskell.org/haskellwiki/Memoization link > > Let's assume we have the following implementation of the > higher-order-function map: > > map :: (a -> b) -> [a] -> [b] > map _ [] = [] > map f (x:xs) = f x : map f xs > > The reduction sequence of memoized_fib 5 would start as follows: > > //Reduction of memoized_fib 5 > > memoized_fib 5 = (map fib [0..] !!) 5 > = (fib 0 : map fib [1..] !!) 5 > = (0 : fib 1 : map fib [2..] !!) 5 > = (0 : 1 : fib 2 : map fib [3..] !!) 5 > = (0 : 1 : (memoized_fib 0 + memoized_fib 1) : fib 3 : map fib [4..] > !!) 5 > = (0 : 1 : (map fib [0..] !! 0 + map fib [0..] !! 1) : (memoized_fib 1 > + memoized_fib 2) : map fib [4..] !!) 5 > . > . > . > . > and so on! Hi, Instead of repeating as-is map fib [0..] consider it as a single list that is always reused. Since the list maps the input of the fib function to the result of the function and that list is always reused, the recursive calls have immediately the answer (i.e. at the cost of the lookup). So your fragment (0 : 1 : (map fib [0..] !! 0 + map fib [0..] !! 1) ... should look like lst = (0 : 1 : (lst !! 0 + lst !! 1) ... which is similar to the zipWith (+) version. Cheers, Thu From ketil at malde.org Mon Oct 12 15:14:45 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Oct 12 14:51:56 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? In-Reply-To: <40a414c20910121005t26275b94hb924e1ff37f149bc@mail.gmail.com> (minh thu's message of "Mon, 12 Oct 2009 19:05:48 +0200") References: <747417.68334.qm@web31104.mail.mud.yahoo.com> <40a414c20910121005t26275b94hb924e1ff37f149bc@mail.gmail.com> Message-ID: <87my3we862.fsf@malde.org> minh thu writes: > ghci> :t (>>=) > (>>=) :: (Monad m) => m a -> (a -> m b) -> m b > > This says that, you provide an a and you get a b. Nothing says the a and b > have to be the same upon successive uses. (But note that the monad 'm' has to be the same all the way. You can't switch from, say, IO to ST in the middle of the computation.) > Likewise, Contrariwise, I'd say. > ghci> :t (+) > (+) :: (Num a) => a -> a -> a I.e. (+) requires the same type on both sides... > fromIntegral ((1 :: Int) + 2) + (3 :: Integer) > 6 ...but 'fromIntegral' converts it. Did I miss some subtle point here? -k -- If I haven't seen further, it is by standing in the footprints of giants From ben.franksen at online.de Mon Oct 12 15:22:02 2009 From: ben.franksen at online.de (Ben Franksen) Date: Mon Oct 12 14:59:56 2009 Subject: [Haskell-cafe] Re: is proof by testing possible? References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <90BDA05B-C041-4D72-8998-70B2E7A87372@gmail.com> Message-ID: Joe Fredette wrote: > Really? How? That sounds very interesting, I've got a fair knowledge > of basic topology, I'd love to see an application > to programming... Compactness is one of the most powerful concepts in mathematics, because on the one hand it makes it possible to reduce many infinite problems to finite ones (inherent in its definition: for every open cover there is a finite subcover), on the other hand it is often easy to prove compactness due to Tychonoff's theorem (any product of compact spaces is compact). The connection to computing science is very nicely explained in http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/ I found this paragraph particularly enlightening: """ > modulus :: (Cantor -> Integer) -> Natural > modulus f = least(\n -> forevery(\a -> forevery(\b -> eq n a b --> (f a == f b)))) This [...] finds the modulus of uniform continuity, defined as the least natural number `n` such that `forall alpha,beta. alpha =_n beta implies f(alpha)=f(beta),` where `alpha =_n beta iff forall i< n. alpha_i = beta_i.` What is going on here is that computable functionals are continuous, which amounts to saying that finite amounts of the output depend only on finite amounts of the input. But the Cantor space is compact, and in analysis and topology there is a theorem that says that continuous functions defined on a compact space are uniformly continuous. In this context, this amounts to the existence of a single `n` such that for all inputs it is enough to look at depth `n` to get the answer (which in this case is always finite, because it is an integer). """ Cheers From noteed at gmail.com Mon Oct 12 15:28:24 2009 From: noteed at gmail.com (minh thu) Date: Mon Oct 12 15:06:02 2009 Subject: [Haskell-cafe] Can type be changed along a >>= chain? In-Reply-To: <87my3we862.fsf@malde.org> References: <747417.68334.qm@web31104.mail.mud.yahoo.com> <40a414c20910121005t26275b94hb924e1ff37f149bc@mail.gmail.com> <87my3we862.fsf@malde.org> Message-ID: <40a414c20910121228w7d6bb7b2m33418b1ed92d3b46@mail.gmail.com> 2009/10/12 Ketil Malde : > > minh thu writes: > >> ghci> :t (>>=) >> (>>=) :: (Monad m) => m a -> (a -> m b) -> m b >> >> This says that, you provide an a and you get a b. Nothing says the a and b >> have to be the same upon successive uses. > > (But note that the monad 'm' has to be the same all the way. You can't > switch from, say, IO to ST in the middle of the computation.) > >> Likewise, > > Contrariwise, I'd say. > >> ghci> :t (+) >> (+) :: (Num a) => a -> a -> a > > I.e. (+) requires the same type on both sides... > >> fromIntegral ((1 :: Int) + 2) + (3 :: Integer) >> 6 > > ...but 'fromIntegral' converts it. Did I miss some subtle point here? I was talking about the types of the two + applications. They have a different types, just like the >>= in the parent's message can have different types. My fromIntegral has a role similar to the read s :: Int of the original question. Cheers, Thu From jfredett at gmail.com Mon Oct 12 15:33:26 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 15:10:49 2009 Subject: [Haskell-cafe] Re: is proof by testing possible? In-Reply-To: References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <90BDA05B-C041-4D72-8998-70B2E7A87372@gmail.com> Message-ID: That has got to be the single awesomest thing I have ever seen ever... The first time I tried to read through the "Seemingly Impossible Functional Programs" post, I understood none of it. Now it seems obviously. I Love Math... Thanks for the explanation! /Joe On Oct 12, 2009, at 3:22 PM, Ben Franksen wrote: > Joe Fredette wrote: >> Really? How? That sounds very interesting, I've got a fair knowledge >> of basic topology, I'd love to see an application >> to programming... > > Compactness is one of the most powerful concepts in mathematics, > because on > the one hand it makes it possible to reduce many infinite problems to > finite ones (inherent in its definition: for every open cover there > is a > finite subcover), on the other hand it is often easy to prove > compactness > due to Tychonoff's theorem (any product of compact spaces is > compact). The > connection to computing science is very nicely explained in > > http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/ > > I found this paragraph particularly enlightening: > > """ >> modulus :: (Cantor -> Integer) -> Natural >> modulus f = least(\n -> forevery(\a -> forevery(\b -> eq n a b --> >> (f a == > f b)))) > > This [...] finds the modulus of uniform continuity, defined as the > least > natural number `n` such that > `forall alpha,beta. alpha =_n beta implies f(alpha)=f(beta),` > where > `alpha =_n beta iff forall i< n. alpha_i = beta_i.` > > What is going on here is that computable functionals are continuous, > which > amounts to saying that finite amounts of the output depend only on > finite > amounts of the input. But the Cantor space is compact, and in > analysis and > topology there is a theorem that says that continuous functions > defined on > a compact space are uniformly continuous. In this context, this > amounts to > the existence of a single `n` such that for all inputs it is enough > to look > at depth `n` to get the answer (which in this case is always finite, > because it is an integer). > """ > > Cheers > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ketil at malde.org Mon Oct 12 15:26:43 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Oct 12 15:23:08 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <4AD375EF.3090103@kent.ac.uk> (Neil Brown's message of "Mon, 12 Oct 2009 19:31:11 +0100") References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4AD375EF.3090103@kent.ac.uk> Message-ID: <87iqeke7m4.fsf@malde.org> Neil Brown writes: >> swap :: (a,b) -> (b,a) >> We don't need to test it at all, it can only do one thing, swap its >> arguments. (Assuming it terminates.) > swap = undefined > Terminates and does not swap its arguments :-) I think this counts as non-termination, and that for semantic purposes, any bottom value -- infinite loops, exceptions, undefined -- is treated equally. -k -- If I haven't seen further, it is by standing in the footprints of giants From westondan at imageworks.com Mon Oct 12 15:59:46 2009 From: westondan at imageworks.com (Dan Weston) Date: Mon Oct 12 15:37:15 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <625b74080910121156h427acd67nccbce002168e172f@mail.gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4AD375EF.3090103@kent.ac.uk> <625b74080910121156h427acd67nccbce002168e172f@mail.gmail.com> Message-ID: <4AD38AB2.6070904@imageworks.com> Could that nice precise formulation simply be Scott continuity, which in turn preserves compactness through composition and under application? Dan Piponi wrote: > On Mon, Oct 12, 2009 at 11:31 AM, Neil Brown wrote: >> swap = undefined >> >> Terminates and does not swap its arguments :-) What do free theorems say >> about this, exactly -- do they just implicitly exclude this possibility? > > I'm terrible at reasoning about functions with bottoms (ie. undefined > or non-termination). > > But I suspect that a property like this holds: if the type signature > of a function f is polymorphic in a, and it doesn't produce bottom for > one particular value x of type a, for some particular type a, f can > never produce bottom for any choice of x in any choice of type a. > (Which is not to say it might not fail, but that the failure will be > an issue with x, not f.) > > The intuition behind this is that if a function is polymorphic in a > then it never examines the a. So even if a is bottom, the function can > never know it. But it could fail because f additionally accepts as > argument a polymorphic function that itself accepts a's, and that > fails. But then it wouldn't be f's fault, it'd be the fault of the > function you passed in. > > This is very poor of me. There's probably a nice precise formulation > of what I've just said :-) > -- > Dan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From rwbarton at math.harvard.edu Mon Oct 12 16:01:01 2009 From: rwbarton at math.harvard.edu (Reid Barton) Date: Mon Oct 12 15:39:02 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence In-Reply-To: <25861177.post@talk.nabble.com> References: <25861134.post@talk.nabble.com> <25861177.post@talk.nabble.com> Message-ID: <20091012200101.GD30332@rwbarton.mit.edu> On Mon, Oct 12, 2009 at 11:52:30AM -0700, SimonK77 wrote: > > **Edit: formatting was bad** > > Hallo everyone, > > the last few weeks I was trying to get used to memoization in haskell. As I > found out in a previous post, memoization in haskell is, due to the graph > reduction strategy used in haskell, almost always implemented by sharing > subexpressions in an expression. > > In examples as the following this is quite easy to see. > > fibs = 0:1:zipWith (+) fibs (tail fibs) > > But as I browsed through the search results from google for this topic, I > encountered the following implementation: > > memoized_fib :: Int -> Integer > memoized_fib = > let fib 0 = 0 > fib 1 = 1 > fib n = memoized_fib (n-2) + memoized_fib (n-1) > in (map fib [0 ..] !!) > ... > I can't see where the sharing of subexpressions happens here. Any help is > highly appreciated. This is an excellent and subtle question. The sharing behavior of the code depends on the desugaring of the syntax (map fib [0 ..] !!): is it (!!) (map fib [0 ..]) or (\x -> map fib [0 ..] !! x) I suggest, as an exercise, tracing the evaluation of memoized_fib using each of these desugarings, and then trying them out in ghci. Then you'll be able to tell which desugaring ghc is using. (It's not the one used in the Report! In principle this is a bug since we can distinguish them using seq.) Regards, Reid Barton From daniel.is.fischer at web.de Mon Oct 12 15:55:33 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Oct 12 15:41:49 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence In-Reply-To: <40a414c20910121209i7667f5dcm4b02f0d34c3ea58d@mail.gmail.com> References: <25861134.post@talk.nabble.com> <25861177.post@talk.nabble.com> <40a414c20910121209i7667f5dcm4b02f0d34c3ea58d@mail.gmail.com> Message-ID: <200910122155.34339.daniel.is.fischer@web.de> Am Montag 12 Oktober 2009 21:09:38 schrieb minh thu: > 2009/10/12 SimonK77 : > > **Edit: formatting was bad** > > > > Hallo everyone, > > > > the last few weeks I was trying to get used to memoization in haskell. As > > I found out in a previous post, memoization in haskell is, due to the > > graph reduction strategy used in haskell, almost always implemented by > > sharing subexpressions in an expression. > > > > In examples as the following this is quite easy to see. > > > > fibs = 0:1:zipWith (+) fibs (tail fibs) > > > > But as I browsed through the search results from google for this topic, I > > encountered the following implementation: > > > > memoized_fib :: Int -> Integer > > memoized_fib = > > let fib 0 = 0 > > fib 1 = 1 > > fib n = memoized_fib (n-2) + memoized_fib (n-1) > > in (map fib [0 ..] !!) > > > > You'll find it at Haskell.org. Here's the > > http://www.haskell.org/haskellwiki/Memoization link > > > > Let's assume we have the following implementation of the > > higher-order-function map: > > > > map :: (a -> b) -> [a] -> [b] > > map _ [] = [] > > map f (x:xs) = f x : map f xs > > > > The reduction sequence of memoized_fib 5 would start as follows: > > > > //Reduction of memoized_fib 5 > > > > memoized_fib 5 = (map fib [0..] !!) 5 > > = (fib 0 : map fib [1..] !!) 5 > > = (0 : fib 1 : map fib [2..] !!) 5 > > = (0 : 1 : fib 2 : map fib [3..] !!) 5 > > = (0 : 1 : (memoized_fib 0 + memoized_fib 1) : fib 3 : > > map fib [4..] !!) 5 > > = (0 : 1 : (map fib [0..] !! 0 + map fib [0..] !! 1) : > > (memoized_fib 1 + memoized_fib 2) : map fib [4..] !!) 5 > > . > > . > > . > > . > > and so on! > > Hi, > > Instead of repeating as-is > map fib [0..] > consider it as a single list that is always reused. Since the list > maps the input of the fib function to the result of the function and > that list is always reused, the recursive calls have immediately the > answer (i.e. at the cost of the lookup). Yes, since memoized_fib is bound by a simple pattern binding and not a function binding, the list is shared among different invocations of memoized_fib, same as if it was given an explicit name. You can see it by adding tracing output: import Debug.Trace tfib :: Int -> Integer tfib = let fib 0 = 0 fib 1 = 1 fib n = trace ("eval fib " ++ show n) $ tfib (n-2) + tfib (n-1) in (map fib [0 .. ] !!) *MFib> tfib 6 eval fib 6 eval fib 4 eval fib 2 eval fib 3 eval fib 5 8 (0.00 secs, 538564 bytes) *MFib> tfib 10 eval fib 10 eval fib 8 eval fib 7 eval fib 9 55 (0.00 secs, 0 bytes) > > So your fragment > > (0 : 1 : (map fib [0..] !! 0 + map fib [0..] !! 1) ... > > should look like > > lst = (0 : 1 : (lst !! 0 + lst !! 1) ... > > which is similar to the zipWith (+) version. Except it's much slower. > > Cheers, > Thu From golubovsky at gmail.com Mon Oct 12 16:06:29 2009 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Mon Oct 12 15:43:50 2009 Subject: [Haskell-cafe] GHC core packages: same core? Message-ID: Hi, Just curious whether package http://hackage.haskell.org/package/ghc-core and http://hackage.haskell.org/package/extcore operate on the same flavor of GHC Core? There seem to be external [1] and internal [2] flavors of GHC Core. [1] http://www.haskell.org/ghc/docs/6.10.2/html/ext-core/core.pdf [2] http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType Thanks. -- Dimitry Golubovsky Anywhere on the Web From bugfact at gmail.com Mon Oct 12 16:30:00 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Oct 12 16:07:19 2009 Subject: [Haskell-cafe] Simple program. Simple problem? In-Reply-To: <20091011230850.GA20547@kira.casa> References: <11710.12522.qm@web31105.mail.mud.yahoo.com> <20091011230850.GA20547@kira.casa> Message-ID: On Mon, Oct 12, 2009 at 1:08 AM, Felipe Lessa wrote: > On Mon, Oct 12, 2009 at 12:42:16AM +0200, Peter Verswyvelen wrote: > > btw I always find it amusing to play with interact and lazy IO: > > I always find it frightening to play with lazy IO :). > yes, I guess that's why I like it, because I'm still an imperative / OO programmer ;-) > > -- > Felipe. > _______________________________________________ > 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/20091012/37005594/attachment.html From ben.franksen at online.de Mon Oct 12 16:45:44 2009 From: ben.franksen at online.de (Ben Franksen) Date: Mon Oct 12 16:23:29 2009 Subject: [Haskell-cafe] Re: Re: is proof by testing possible? References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <90BDA05B-C041-4D72-8998-70B2E7A87372@gmail.com> Message-ID: Joe Fredette wrote: > That has got to be the single awesomest thing I have ever seen ever... I was dumbfounded, too, when I first read about this. BTW, and completely off-topic: if you like this, you might have fun too with Conor McBride's discovery that data types can be differentiated, and the result is even useful: it corresponds to what is known (to some) as a Zipper: http://www.cs.nott.ac.uk/~ctm/diff.pdf Moreover, we can also give a sensible and useful interpretation to finite difference quotients of types: http://blog.sigfpe.com/2009/09/finite-differences-of-types.html which McBride calls "dissections" and discusses in some depth here: http://strictlypositive.org/CJ.pdf What is most astonishing to me is that these constructions work even though there is neither subtraction nor division defined on data types, only addition and multiplication (there are neutral elements for both, but not necessarily inverses). Cheers Ben From ben.franksen at online.de Mon Oct 12 17:05:17 2009 From: ben.franksen at online.de (Ben Franksen) Date: Mon Oct 12 16:43:20 2009 Subject: [Haskell-cafe] Re: Re: What *is* a DSL? References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> <94C8A81C-6A61-4B48-828C-E3C46329E631@swierstra.net> Message-ID: S. Doaitse Swierstra wrote: > This problem of dynamically transforming grammars and bulding parsers > out of it is addressed in: > > @inproceedings{1411296, > author = {Viera, Marcos and Swierstra, S. Doaitse and Lempsink, > Eelco}, > title = {Haskell, do you read me?: constructing and composing > efficient top-down parsers at runtime}, > [...] > } Indeed, it looks as if you solved exactly the problem that vexed me! I had just found the presentation that corresponds to the paper you mention, and I also found a preprint for "Typed transformations of Typed Abstract Syntax" which I am studying at the moment. I must say your construction is, well, involved... Not that I want to belittle this really astounding and clever achievement... but one disadvantage of your approach (which it shares with almost all examples I have seen for dependently typed or heterogeneous collections) is that (IIUC) the typed map from references to abstract syntactic terms is operationally an association list, indexed by unary numbers. I would expect this to scale poorly if the number of references (e.g. nonterminals) gets large. I think it would make for quite an interesting research project to study whether it is possible to achieve the same level of precise static typing with more efficient data structures. I imagine that using some 'fake dependent type' variant of [Bit] for the key and the equivalent of a patricia tree for the map could perhaps be made to work??? Cheers Ben From jfredett at gmail.com Mon Oct 12 17:14:19 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 16:51:40 2009 Subject: [Haskell-cafe] Re: Re: is proof by testing possible? In-Reply-To: References: <25860155.post@talk.nabble.com> <5e0214850910121055h7c64bbe2y60f00e78eb7709b5@mail.gmail.com> <90BDA05B-C041-4D72-8998-70B2E7A87372@gmail.com> Message-ID: <8DF55A12-0C4A-4406-BEAB-E3FC5AF345CC@gmail.com> I read about differentiating and differences for types, that was awesome, but when I read the seemingly-impossible post the first time, I didn't have enough background in topology to understand what was going on. Differentiating types is usually how I introduce the power of haskell's type system to the other students in my Math department. I actually showed my algebra professor how non-recursive datatypes in n-variables are just multinomials over a commutative (up to isomorphism) ring and how you can use that to reason about equivalences between types based on the polynomial they're isomorphic too. My Algebra Professor, who does not program and knows very little about it, sat back in his chair and say, "So that's what all the fuss is about? Programming is easy!" Really, all this goes to show that a rich, algebraic type system like Haskell's is invaluable because it harnesses the power of mathematics that we've been working at for years. Free Theorems indeed! On Oct 12, 2009, at 4:45 PM, Ben Franksen wrote: > Joe Fredette wrote: >> That has got to be the single awesomest thing I have ever seen >> ever... > > I was dumbfounded, too, when I first read about this. > > BTW, and completely off-topic: if you like this, you might have fun > too with > Conor McBride's discovery that data types can be differentiated, and > the > result is even useful: it corresponds to what is known (to some) as a > Zipper: > > http://www.cs.nott.ac.uk/~ctm/diff.pdf > > Moreover, we can also give a sensible and useful interpretation to > finite > difference quotients of types: > > http://blog.sigfpe.com/2009/09/finite-differences-of-types.html > > which McBride calls "dissections" and discusses in some depth here: > > http://strictlypositive.org/CJ.pdf > > What is most astonishing to me is that these constructions work even > though > there is neither subtraction nor division defined on data types, only > addition and multiplication (there are neutral elements for both, > but not > necessarily inverses). > > Cheers > Ben > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From shout at ozten.com Mon Oct 12 17:23:21 2009 From: shout at ozten.com (Austin King) Date: Mon Oct 12 17:00:41 2009 Subject: [Haskell-cafe] Need help with ghc static compile for cgi using mysql Message-ID: <454d20c10910121423y2b8d8ad7r29048965f61f7bde@mail.gmail.com> I'm trying to host a cgi I've written. It uses Database.HDBC, Database.HDBC.MySQL, Network.CGI, and Text.XHtml.Transitional Here is the command I'm using to compile ghc --make -optl-static -optl-pthread -static -o test.cgi -package cgi -package xhtml -package HDBC-mysql -package HDBC -optl -lz Main.hs and I get "(.text+0x120): undefined reference to `compress'" Searching around I found that mysql recommended passing "lz" to the linker... so I added -optl -lz Complete command and output: ghc --make -optl-static -optl-pthread -static -o test.cgi -package cgi -package xhtml -package HDBC-mysql -package HDBC -optl -lz Main.hs [1 of 5] Compiling Config ( Config.hs, Config.o ) [2 of 5] Compiling Model ( Model.hs, Model.o ) [3 of 5] Compiling View ( View.hs, View.o ) [4 of 5] Compiling Controller ( Controller.hs, Controller.o ) [5 of 5] Compiling Main ( Main.hs, Main.o ) Linking test.cgi ... /opt/ghc-6.10.4/lib/ghc-6.10.4/network-2.2.1.2/libHSnetwork-2.2.1.2.a(HsNet.o): In function `my_inet_ntoa': HsNet.c:(.text+0x20): multiple definition of `my_inet_ntoa' /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(my_net.o):(.text+0x0): first defined here /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(mf_pack.o): In function `unpack_dirname': (.text+0x75b): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(libmysql.o): In function `read_user_name': (.text+0x6081): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(mf_pack.o): In function `unpack_dirname': (.text+0x76a): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /opt/ghc-6.10.4/lib/ghc-6.10.4/network-2.2.1.2/libHSnetwork-2.2.1.2.a(HsNet.o): In function `hsnet_getaddrinfo': HsNet.c:(.text+0x15): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(ssl.o): In function `yaSSL::read_file(yaSSL::SSL_CTX*, char const*, int, yaSSL::CertType)': (.text+0x29f3): warning: memset used with constant zero length parameter; this could be due to transposed parameters /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(my_gethostbyname.o): In function `my_gethostbyname_r': (.text+0x3c): warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /opt/ghc-6.10.4/lib/ghc-6.10.4/network-2.2.1.2/libHSnetwork-2.2.1.2.a(BSD__213.o): In function `s9bc_info': (.text+0x55): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(libmysql.o): In function `mysql_server_init': (.text+0x6b22): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(my_compress.o): In function `my_uncompress': (.text+0x6b): undefined reference to `uncompress' /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/libmysqlclient.a(my_compress.o): In function `my_compress_alloc': (.text+0x120): undefined reference to `compress' collect2: ld returned 1 exit status I'm using ghc 6.10.4 on Ubuntu 9.04 i386 I have libmysqlclient15-dev installed.... Thanks, Austin From nick.straw at gmail.com Mon Oct 12 19:03:24 2009 From: nick.straw at gmail.com (b1g3ar5) Date: Mon Oct 12 18:40:41 2009 Subject: [Haskell-cafe] Stupid error, probably Message-ID: <0a5c28fc-cdf5-4376-ae23-215802865ea1@g19g2000yqo.googlegroups.com> I can't get the following to work in Leksah - but it works OK in GHC. Can anyone spot the error? I wondered if it was becasue the libraries loaded are different - but I'm just a Haskell beginner ... I have: myGroupBy :: Int? [a]? [[a]] myGroupBy = takeWhile not . null . (unfoldr (Just . (splitAt 3))) and I am getting the error: Couldn't match expected type `Int' against inferred type `[a]' In the second argument of `(.)', namely `(splitAt 3)' In the first argument of `unfoldr', namely `(Just . (splitAt 3))' In the second argument of `(.)', namely `(unfoldr (Just . (splitAt 3)))' But I think that splitAt :: Int->[a]->([a],[a]) so: splitAt 3 :: [a]->([a], [a]) and: Just.(splitAt 3) :: [a]->Maybe ([a], [a]) which seems OK as the first argument of unfoldr: unfoldr :: (b-> Maybe(a,b))->b->[a] with the a and b of unfoldr being [a] and [a]. The mention of Int in the error makes me wonder if I've got the wrong splitAt - with the arguments reversed maybe. Any ideas? Thanks. N From daniel.is.fischer at web.de Mon Oct 12 20:02:01 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Oct 12 19:43:37 2009 Subject: [Haskell-cafe] Stupid error, probably In-Reply-To: <0a5c28fc-cdf5-4376-ae23-215802865ea1@g19g2000yqo.googlegroups.com> References: <0a5c28fc-cdf5-4376-ae23-215802865ea1@g19g2000yqo.googlegroups.com> Message-ID: <200910130202.02134.daniel.is.fischer@web.de> Am Dienstag 13 Oktober 2009 01:03:24 schrieb b1g3ar5: > I can't get the following to work in Leksah - but it works OK in GHC. > Can anyone spot the error? > > I wondered if it was becasue the libraries loaded are different - but > I'm just a Haskell beginner ... > > I have: > > myGroupBy :: Int? [a]? [[a]] ^^^^^^^^^^ That "Int" isn't used in the definition of myGroupBy perhaps you intended to write myGroupBy k = takeWhile (not . null) . unfoldr (Just . splitAt k) ? > myGroupBy = takeWhile not . null . (unfoldr (Just . (splitAt 3))) > > and I am getting the error: > > Couldn't match expected type `Int' against inferred type `[a]' > In the second argument of `(.)', namely `(splitAt 3)' > In the first argument of `unfoldr', namely `(Just . (splitAt 3))' > In the second argument of `(.)', namely > `(unfoldr (Just . (splitAt 3)))' > > But I think that > > splitAt :: Int->[a]->([a],[a]) > > so: > > splitAt 3 :: [a]->([a], [a]) > > and: > > Just.(splitAt 3) :: [a]->Maybe ([a], [a]) > > which seems OK as the first argument of unfoldr: > > unfoldr :: (b-> Maybe(a,b))->b->[a] > > with the a and b of unfoldr being [a] and [a]. > > The mention of Int in the error makes me wonder if I've got the wrong > splitAt - with the arguments reversed maybe. > > Any ideas? > > Thanks. > > N From byorgey at seas.upenn.edu Mon Oct 12 20:19:05 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon Oct 12 19:56:23 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: <5B9A435C-FFC2-4EA2-A809-D0EB506101F8@ece.cmu.edu> References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> <5B9A435C-FFC2-4EA2-A809-D0EB506101F8@ece.cmu.edu> Message-ID: <20091013001905.GA21234@seas.upenn.edu> On Sun, Oct 11, 2009 at 06:29:58PM -0400, Brandon S. Allbery KF8NH wrote: > On Oct 11, 2009, at 18:00 , Ben Franksen wrote: >> Ben Franksen wrote: >>> Ben Franksen wrote: >>>> Next thing I'll try is to transform such a grammar into an actual >>>> parser... >>> >>> Which I also managed to get working. >> >> First, before all this talking to myself here is boring you to death, >> please >> shout and I'll go away. Anyway, at least one person has privately >> expressed >> interest, so I'll post my code for the translation.(*) > > It's -cafe, so let 'er rip. And maybe write it up for TMR, if you don't Yes please! =) -Brent From byorgey at seas.upenn.edu Mon Oct 12 20:41:15 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon Oct 12 20:18:32 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> Message-ID: <20091013004115.GB21234@seas.upenn.edu> Do you know any category theory? What helped me finally grok free theorems is that in the simplest cases, the free theorem for a polymorphic function is just a naturality condition. For example, the free theorem for flatten :: Tree a -> [a] is precisely the statement that flatten is a natural transformation from the Tree functor to the list functor: fmap_[] g . flatten == flatten . fmap_Tree g It gets more complicated than this, of course, but that's the basic idea. -Brent On Mon, Oct 12, 2009 at 02:03:11PM -0400, Joe Fredette wrote: > I completely forgot about free theorems! Do you have some links to > resources -- I tried learning about them a while > ago, but couldn't get a grasp on them... Thanks. > > /Joe > > > > On Oct 12, 2009, at 2:00 PM, Dan Piponi wrote: > >> On Mon, Oct 12, 2009 at 10:42 AM, muad wrote: >>> >>> Is it possible to prove correctness of a functions by testing it? I think >>> the >>> tests would have to be constructed by inspecting the shape of the >>> function >>> definition. >> >> not True==False >> not False==True >> >> Done. Tested :-) >> >> Less trivially, consider a function of signature >> >> swap :: (a,b) -> (b,a) >> >> We don't need to test it at all, it can only do one thing, swap its >> arguments. (Assuming it terminates.) >> >> But consider: >> swap :: (a,a) -> (a,a) >> >> If I find that swap (1,2) == (2,1) then I know that swap (x,y)==(y,x) >> for all types a and b. We only need one test. >> The reason is that we have a free theorem that says that for all >> functions, f, of type (a,a) -> (a,a) this holds: >> >> f (g a,g b) == let (x,y) = f (a,b) in (g x',g y') >> >> For any x and y define >> >> g 1 = x >> g 2 = y >> >> Then f(x,y) == f (g 1,g 2) == let (x',y') == f(1,2) in (g x',g y') == >> let (x',y') == (2,1) in (g x',g y') == (g 2,g 1) == (y,x) >> >> In other words, free theorems can turn an infinite amount of testing >> into a finite test. (Assuming termination.) >> -- >> Dan >> _______________________________________________ >> 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 mle+hs at mega-nerd.com Mon Oct 12 20:46:29 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon Oct 12 20:23:51 2009 Subject: [Haskell-cafe] MTL vs Transformers? Message-ID: <20091013114629.728dedaa.mle+hs@mega-nerd.com> Hi all, I've just received the following error message: headers.hs:6:7: Could not find module `Control.Monad.Identity': it was found in multiple packages: transformers-0.1.4.0 mtl-1.1.0.2 I'm trying to use the Iteratee module which depends on Transformers but I use MTL in other stuff. Whats the preferred solution here? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From gcross at phys.washington.edu Mon Oct 12 21:01:01 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Oct 12 20:38:20 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013114629.728dedaa.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> Message-ID: <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> ghc-pkg hide transformers On Oct 12, 2009, at 5:46 PM, Erik de Castro Lopo wrote: > Hi all, > > I've just received the following error message: > > headers.hs:6:7: > Could not find module `Control.Monad.Identity': > it was found in multiple packages: transformers-0.1.4.0 > mtl-1.1.0.2 > > I'm trying to use the Iteratee module which depends on Transformers > but I use MTL in other stuff. > > Whats the preferred solution here? > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mle+hs at mega-nerd.com Mon Oct 12 21:08:21 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon Oct 12 20:45:59 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> Message-ID: <20091013120821.1ad7db27.mle+hs@mega-nerd.com> Gregory Crosswhite wrote: > ghc-pkg hide transformers Here's an example. CGI uses MTL, Iteratee uses Transformers. So, how do you use CGI and Iteratee in the same program? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From mle+hs at mega-nerd.com Mon Oct 12 21:11:20 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon Oct 12 20:49:03 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013120821.1ad7db27.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> Message-ID: <20091013121120.b2f461ba.mle+hs@mega-nerd.com> Erik de Castro Lopo wrote: > Gregory Crosswhite wrote: > > > ghc-pkg hide transformers > > Here's an example. CGI uses MTL, Iteratee uses Transformers. > > So, how do you use CGI and Iteratee in the same program? CGI is just one of many examples. Text.Regex, Network.HTTP, Database.HDBS.Sqlite, Tagsoup are others. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From jfredett at gmail.com Mon Oct 12 21:15:54 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 20:53:14 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <20091013004115.GB21234@seas.upenn.edu> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> <20091013004115.GB21234@seas.upenn.edu> Message-ID: <2A88C777-6663-4663-8288-67F81B97E630@gmail.com> Sadly not enough, I understand the basics, but the whole "proof <=> this diagram commutes" thing still seems like voodoo to me. There is a section coming up in my Topology ISP that will be on CT. So I hope that I will be able to gain some purchase on the subject, at least enough to build up a working understanding on my own. I have a practical understanding of Functors and Natural Transformations, so working a bit with these free theorem things is kind of fun. Actually, another germane-if-random question, why isn't there a natural transformation class? Something like: class Functor f, Functor g => NatTrans g f a where trans :: f a -> g a So your flatten function becomes a `trans` a la instance NatTrans Tree [] a where trans = flatten In fact, I'm going to attempt to do this now... Maybe I'll figure out why before you reply. :) /Joe On Oct 12, 2009, at 8:41 PM, Brent Yorgey wrote: > Do you know any category theory? What helped me finally grok free > theorems is that in the simplest cases, the free theorem for a > polymorphic function is just a naturality condition. For example, the > free theorem for > > flatten :: Tree a -> [a] > > is precisely the statement that flatten is a natural transformation > from the Tree functor to the list functor: > > fmap_[] g . flatten == flatten . fmap_Tree g > > It gets more complicated than this, of course, but that's the basic > idea. > > -Brent > > On Mon, Oct 12, 2009 at 02:03:11PM -0400, Joe Fredette wrote: >> I completely forgot about free theorems! Do you have some links to >> resources -- I tried learning about them a while >> ago, but couldn't get a grasp on them... Thanks. >> >> /Joe >> >> >> >> On Oct 12, 2009, at 2:00 PM, Dan Piponi wrote: >> >>> On Mon, Oct 12, 2009 at 10:42 AM, muad >>> wrote: >>>> >>>> Is it possible to prove correctness of a functions by testing it? >>>> I think >>>> the >>>> tests would have to be constructed by inspecting the shape of the >>>> function >>>> definition. >>> >>> not True==False >>> not False==True >>> >>> Done. Tested :-) >>> >>> Less trivially, consider a function of signature >>> >>> swap :: (a,b) -> (b,a) >>> >>> We don't need to test it at all, it can only do one thing, swap its >>> arguments. (Assuming it terminates.) >>> >>> But consider: >>> swap :: (a,a) -> (a,a) >>> >>> If I find that swap (1,2) == (2,1) then I know that swap >>> (x,y)==(y,x) >>> for all types a and b. We only need one test. >>> The reason is that we have a free theorem that says that for all >>> functions, f, of type (a,a) -> (a,a) this holds: >>> >>> f (g a,g b) == let (x,y) = f (a,b) in (g x',g y') >>> >>> For any x and y define >>> >>> g 1 = x >>> g 2 = y >>> >>> Then f(x,y) == f (g 1,g 2) == let (x',y') == f(1,2) in (g x',g y') >>> == >>> let (x',y') == (2,1) in (g x',g y') == (g 2,g 1) == (y,x) >>> >>> In other words, free theorems can turn an infinite amount of testing >>> into a finite test. (Assuming termination.) >>> -- >>> Dan >>> _______________________________________________ >>> 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 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gcross at phys.washington.edu Mon Oct 12 21:31:09 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Oct 12 21:08:26 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013120821.1ad7db27.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> Message-ID: <78991278-57F7-4069-894E-5852A01164AA@phys.washington.edu> Ugh, I'm not as sure about that... it took me long enough just to figure out "ghc-pkg hide transformers"! :-) Are running into problems because you need to refer to both packages (e.g., mtl and transformers) within your code, or because you are using packages that refer to each? Because as long as you only need to refer to one of them in your own code, GHC should be able to handle the dependencies for the other packages correctly. (Hiding the package only removes it from being automatically imported by your own code, it doesn't prevent it from being used by other packages that link to it.) Cheers, Greg On Oct 12, 2009, at 6:08 PM, Erik de Castro Lopo wrote: > Gregory Crosswhite wrote: > >> ghc-pkg hide transformers > > Here's an example. CGI uses MTL, Iteratee uses Transformers. > > So, how do you use CGI and Iteratee in the same program? > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jfredett at gmail.com Mon Oct 12 21:53:02 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Oct 12 21:30:24 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <20091013004115.GB21234@seas.upenn.edu> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> <20091013004115.GB21234@seas.upenn.edu> Message-ID: <443DADF4-0A7A-4CCF-BFA6-86B770E0B26E@gmail.com> I fiddled with my previous idea -- the NatTrans class -- a bit, the results are here[1], I don't know enough really to know if I got the NT law right, or even if the class defn is right. Any thoughts? Am I doing this right/wrong/inbetween? Is there any use for a class like this? I listed a couple ideas of use-cases in the paste, but I have no idea of the applicability of either of them. /Joe http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10679#a10679 On Oct 12, 2009, at 8:41 PM, Brent Yorgey wrote: > Do you know any category theory? What helped me finally grok free > theorems is that in the simplest cases, the free theorem for a > polymorphic function is just a naturality condition. For example, the > free theorem for > > flatten :: Tree a -> [a] > > is precisely the statement that flatten is a natural transformation > from the Tree functor to the list functor: > > fmap_[] g . flatten == flatten . fmap_Tree g > > It gets more complicated than this, of course, but that's the basic > idea. > > -Brent > > On Mon, Oct 12, 2009 at 02:03:11PM -0400, Joe Fredette wrote: >> I completely forgot about free theorems! Do you have some links to >> resources -- I tried learning about them a while >> ago, but couldn't get a grasp on them... Thanks. >> >> /Joe >> >> >> >> On Oct 12, 2009, at 2:00 PM, Dan Piponi wrote: >> >>> On Mon, Oct 12, 2009 at 10:42 AM, muad >>> wrote: >>>> >>>> Is it possible to prove correctness of a functions by testing it? >>>> I think >>>> the >>>> tests would have to be constructed by inspecting the shape of the >>>> function >>>> definition. >>> >>> not True==False >>> not False==True >>> >>> Done. Tested :-) >>> >>> Less trivially, consider a function of signature >>> >>> swap :: (a,b) -> (b,a) >>> >>> We don't need to test it at all, it can only do one thing, swap its >>> arguments. (Assuming it terminates.) >>> >>> But consider: >>> swap :: (a,a) -> (a,a) >>> >>> If I find that swap (1,2) == (2,1) then I know that swap >>> (x,y)==(y,x) >>> for all types a and b. We only need one test. >>> The reason is that we have a free theorem that says that for all >>> functions, f, of type (a,a) -> (a,a) this holds: >>> >>> f (g a,g b) == let (x,y) = f (a,b) in (g x',g y') >>> >>> For any x and y define >>> >>> g 1 = x >>> g 2 = y >>> >>> Then f(x,y) == f (g 1,g 2) == let (x',y') == f(1,2) in (g x',g y') >>> == >>> let (x',y') == (2,1) in (g x',g y') == (g 2,g 1) == (y,x) >>> >>> In other words, free theorems can turn an infinite amount of testing >>> into a finite test. (Assuming termination.) >>> -- >>> Dan >>> _______________________________________________ >>> 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 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From derek.a.elkins at gmail.com Mon Oct 12 21:53:25 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Oct 12 21:30:44 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <2A88C777-6663-4663-8288-67F81B97E630@gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> <20091013004115.GB21234@seas.upenn.edu> <2A88C777-6663-4663-8288-67F81B97E630@gmail.com> Message-ID: <61f84eff0910121853q3abddcadp5f0a3b403ce9f32a@mail.gmail.com> On Mon, Oct 12, 2009 at 8:15 PM, Joe Fredette wrote: > Sadly not enough, I understand the basics, but the whole "proof <=> this > diagram commutes" thing still seems like > voodoo to me. There is a section coming up in my Topology ISP that will be > on CT. So I hope that I will be able to > gain some purchase on the subject, at least enough to build up a working > understanding on my own. > > I have a practical understanding of Functors and Natural Transformations, so > working a bit with these free theorem things > is kind of fun. > > Actually, another germane-if-random question, why isn't there a natural > transformation class? Something like: > > > ? ?class Functor f, Functor g => NatTrans g f a where > ? ? ? ? ? ? ? ?trans :: f a -> g a > > So your flatten function becomes a `trans` a la > > ? ?instance NatTrans Tree [] a where > ? ? ? ? ? ? ? ?trans = flatten > > In fact, I'm going to attempt to do this now... Maybe I'll figure out why > before you reply. :) Diagrams are just a graphical depiction of systems of equations. Every pair of paths with the same start and end point are equal. I don't care for diagrams that much and that graphical depiction isn't that important for CT, though it has some mnemonic value. As for a NatTrans class, your example is broken in several ways. Natural transformations, though, are trivial in Haskell. type NatTrans f g = forall a. f a -> g a flatten :: NatTrans Tree [] I.e. a natural transformation between Haskell Functors are just polymorphic functions between them. In general, a polymorphic function is a dinatural transformation and the dinaturality conditions are the free theorems (or at least, special cases of the free theorem for the type, which I believe, but haven't proven, implies the full free theorem.) From mle+hs at mega-nerd.com Mon Oct 12 22:05:06 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon Oct 12 21:42:39 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <78991278-57F7-4069-894E-5852A01164AA@phys.washington.edu> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> <78991278-57F7-4069-894E-5852A01164AA@phys.washington.edu> Message-ID: <20091013130506.6954971c.mle+hs@mega-nerd.com> Gregory Crosswhite wrote: > Are running into problems because you need to refer to both packages > (e.g., mtl and transformers) within your code, or because you are > using packages that refer to each? The later. Iteratee uses Transformers and just about everything else I want to use uses MTL. > Because as long as you only need > to refer to one of them in your own code, GHC should be able to handle > the dependencies for the other packages correctly. (Hiding the > package only removes it from being automatically imported by your own > code, it doesn't prevent it from being used by other packages that > link to it.) That all seems a little hackish. However after reading the hackage descriptions of both Transformers and MTL, it seems that they share a very similar heritage. I therefore hacked the iteratee.cabal file and replaced the build-depends on transformers with one on mtl and the package built quite happily. I'll play with it a bit to see if its working correctly. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From uhollerbach at gmail.com Mon Oct 12 22:28:36 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Mon Oct 12 22:05:54 2009 Subject: [Haskell-cafe] Parsec bug, or...? Message-ID: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> a brain fart? Hi, cafe, I've been playing a little bit with a small command processor, and I decided it'd be nice to allow the user to not have to enter a complete command, but to recognize a unique prefix of it. So I started with the list of allowed commands, used filter and isPrefixOf, and was happy. But then I increased the complexity a little bit and it got hairier, so I decided to rewrite the parser for this bit in parsec. The function I came up with is parsePrefixOf n str = string (take n str) >> opts (drop n str) >> return str where opts [] = return () opts (c:cs) = optional (char c >> opts cs) which I call as parseFoo = parsePrefixOf 1 "foo" and it recognizes all of "f", "fo", and "foo" as "foo". OK so far, this also seems to work fine. But during the course of writing this, I made a stupid mistake at one point, and the result of that seemed odd. Consider the following program. It's stupid because the required prefix of "frito" is only 2 characters, which isn't enough to actually distinguish this from the next one, "fromage". (And if I change that to 2 to 3 characters, everything works fine.) So here's the complete program module Main where import Prelude import System import Text.ParserCombinators.Parsec as TPCP myPrefixOf n str = string (take n str) >> opts (drop n str) >> return str where opts [] = return () opts (c:cs) = optional (char c >> opts cs) myTest = myPrefixOf 1 "banana" <|> myPrefixOf 1 "chocolate" <|> TPCP.try (myPrefixOf 2 "frito") <|> myPrefixOf 3 "fromage" myBig = spaces >> myTest >>= (\g -> spaces >> eof >> return g) parseTry input = case parse myBig "test" input of Left err -> return (show err) Right val -> return ("success: '" ++ val ++ "'") main = getArgs >>= (\a -> parseTry (a !! 0)) >>= putStrLn If I compile this, say as program "opry", and run it as shown below, I expect the results I get for all but the last one: % ./opry b success: 'banana' % ./opry c success: 'chocolate' % ./opry fr success: 'frito' % ./opry fri success: 'frito' % ./opry fro "test" (line 1, column 3): unexpected "o" expecting "i", white space or end of input Sooo... why do I get that last one? My expectation was that parsec would try the string "fro" with the parser for "frito", it would fail, having consumed 2 characters, but then the TPCP.try which is wrapped around all of that should restore everything, and then the final parser for "fromage" should succeed. The same reasoning seems to me to apply if I specify 3 characters as the required initial portion for "frito", and if I do that it does succeed as I expect. So is this a bug in parsec, or a bug in my brain? thanks... Uwe From patperry at gmail.com Mon Oct 12 22:32:47 2009 From: patperry at gmail.com (Patrick Perry) Date: Mon Oct 12 22:10:08 2009 Subject: [Haskell-cafe] QuickCheck2 question Message-ID: <20091013023247.GA17608@Macintosh-62.local> I'm having some trouble with QuickCheck2 and Control.Applicative. Specifically, I have the following functions (slightly simplified): copyVector :: IOVector -> Vector -> IO () freezeVector :: IOVector -> IO (Vector) I have a test, part of which looks like monadicIO $ do run $ copyVector <$> pure dst <*> freezeVector src -- more stuff... When I try running the test (using test-framework-quickcheck2), the `copyVector` function never gets called. If I re-write the test as monadicIO $ do src' <- run $ freezeVector run $ copyVector dst src' -- etc. then everything works fine (i.e., the call to `copyVector` gets executed). Does anyone have any clues as to what is going on? I suspect the problem is related to Test.QuickCheck.Monadic using `unsafePerformIO` without a `{-# NOINLINE -#}` pragma [1], but I'm not completely sure. Adding such a pragma to `monadicIO` and `run` in Monadic.hs does not fix the problem. I'm using Quickcheck-2.1.0.2 and GHC 6.10.1. Thanks in advance for any help, Patrick [1] http://hackage.haskell.org/packages/archive/QuickCheck/2.1.0.2/doc/html/src/Test-QuickCheck-Monadic.html From derek.a.elkins at gmail.com Mon Oct 12 22:33:09 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Oct 12 22:10:28 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> Message-ID: <61f84eff0910121933x35ec912eifc2aba5107e62aaf@mail.gmail.com> On Mon, Oct 12, 2009 at 9:28 PM, Uwe Hollerbach wrote: > a brain fart? > > Hi, cafe, I've been playing a little bit with a small command > processor, and I decided it'd be nice to allow the user to not have to > enter a complete command, but to recognize a unique prefix of it. So I > started with the list of allowed commands, used filter and isPrefixOf, > and was happy. But then I increased the complexity a little bit and it > got hairier, so I decided to rewrite the parser for this bit in > parsec. The function I came up with is > > parsePrefixOf n str = > ?string (take n str) >> opts (drop n str) >> return str > ?where opts [] = return () > ? ? ? ?opts (c:cs) = optional (char c >> opts cs) > > which I call as > > parseFoo = parsePrefixOf 1 "foo" > > and it recognizes all of "f", "fo", and "foo" as "foo". > > OK so far, this also seems to work fine. But during the course of > writing this, I made a stupid mistake at one point, and the result of > that seemed odd. Consider the following program. It's stupid because > the required prefix of "frito" is only 2 characters, which isn't > enough to actually distinguish this from the next one, "fromage". (And > if I change that to 2 to 3 characters, everything works fine.) So > here's the complete program > > module Main where > > import Prelude > import System > import Text.ParserCombinators.Parsec as TPCP > > myPrefixOf n str = > ?string (take n str) >> opts (drop n str) >> return str > ?where opts [] = return () > ? ? ? ?opts (c:cs) = optional (char c >> opts cs) > > myTest = myPrefixOf 1 "banana" > ? ? ?<|> myPrefixOf 1 "chocolate" > ? ? ?<|> TPCP.try (myPrefixOf 2 "frito") > ? ? ?<|> myPrefixOf 3 "fromage" > > myBig = spaces >> myTest >>= (\g -> spaces >> eof >> return g) > > parseTry input = > ?case parse myBig "test" input of > ? ? ? Left err -> return (show err) > ? ? ? Right val -> return ("success: '" ++ val ++ "'") > > main = getArgs >>= (\a -> parseTry (a !! 0)) >>= putStrLn > > If I compile this, say as program "opry", and run it as shown below, I > expect the results I get for all but the last one: > > % ./opry b > success: 'banana' > > % ./opry c > success: 'chocolate' > > % ./opry fr > success: 'frito' > > % ./opry fri > success: 'frito' > > % ./opry fro > "test" (line 1, column 3): > unexpected "o" > expecting "i", white space or end of input > > Sooo... why do I get that last one? My expectation was that ?parsec > would try the string "fro" with the parser for "frito", it would fail, > having consumed 2 characters, but then the TPCP.try which is wrapped > around all of that should restore everything, and then the final > parser for "fromage" should succeed. The same reasoning seems to me to > apply if I specify 3 characters as the required initial portion for > "frito", and if I do that it does succeed as I expect. > > So is this a bug in parsec, or a bug in my brain? Move the try to the last alternative. From allbery at ece.cmu.edu Mon Oct 12 22:36:28 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Oct 12 22:13:59 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> Message-ID: On Oct 12, 2009, at 22:28 , Uwe Hollerbach wrote: > parsePrefixOf n str = > string (take n str) >> opts (drop n str) >> return str > where opts [] = return () > opts (c:cs) = optional (char c >> opts cs) Seems to me this will succeed as soon as it possibly can... > myTest = myPrefixOf 1 "banana" > <|> myPrefixOf 1 "chocolate" > <|> TPCP.try (myPrefixOf 2 "frito") > <|> myPrefixOf 3 "fromage" ...so the "frito" branch gets committed as soon as "fr" is read/parsed (myTest returns)... > % ./opry fro > "test" (line 1, column 3): > unexpected "o" > expecting "i", white space or end of input ...which is why this is looking for "white space or end of input". My fix would be to have myPrefixOf require the prefix be terminated in whatever way is appropriate (end of input, white space, operator?) instead of simply accepting as soon as it gets a prefix match regardless of what follows. -- 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 -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/78f4820d/PGP.bin From uhollerbach at gmail.com Mon Oct 12 22:38:26 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Mon Oct 12 22:15:44 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <61f84eff0910121933x35ec912eifc2aba5107e62aaf@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <61f84eff0910121933x35ec912eifc2aba5107e62aaf@mail.gmail.com> Message-ID: <65d7a7e0910121938w1a8e68a2h74c49d45480f7f8e@mail.gmail.com> On 10/12/09, Derek Elkins wrote: > On Mon, Oct 12, 2009 at 9:28 PM, Uwe Hollerbach > wrote: >> a brain fart? >> >> Hi, cafe, I've been playing a little bit with a small command >> processor, and I decided it'd be nice to allow the user to not have to >> enter a complete command, but to recognize a unique prefix of it. So I >> started with the list of allowed commands, used filter and isPrefixOf, >> and was happy. But then I increased the complexity a little bit and it >> got hairier, so I decided to rewrite the parser for this bit in >> parsec. The function I came up with is >> >> parsePrefixOf n str = >> string (take n str) >> opts (drop n str) >> return str >> where opts [] = return () >> opts (c:cs) = optional (char c >> opts cs) >> >> which I call as >> >> parseFoo = parsePrefixOf 1 "foo" >> >> and it recognizes all of "f", "fo", and "foo" as "foo". >> >> OK so far, this also seems to work fine. But during the course of >> writing this, I made a stupid mistake at one point, and the result of >> that seemed odd. Consider the following program. It's stupid because >> the required prefix of "frito" is only 2 characters, which isn't >> enough to actually distinguish this from the next one, "fromage". (And >> if I change that to 2 to 3 characters, everything works fine.) So >> here's the complete program >> >> module Main where >> >> import Prelude >> import System >> import Text.ParserCombinators.Parsec as TPCP >> >> myPrefixOf n str = >> string (take n str) >> opts (drop n str) >> return str >> where opts [] = return () >> opts (c:cs) = optional (char c >> opts cs) >> >> myTest = myPrefixOf 1 "banana" >> <|> myPrefixOf 1 "chocolate" >> <|> TPCP.try (myPrefixOf 2 "frito") >> <|> myPrefixOf 3 "fromage" >> >> myBig = spaces >> myTest >>= (\g -> spaces >> eof >> return g) >> >> parseTry input = >> case parse myBig "test" input of >> Left err -> return (show err) >> Right val -> return ("success: '" ++ val ++ "'") >> >> main = getArgs >>= (\a -> parseTry (a !! 0)) >>= putStrLn >> >> If I compile this, say as program "opry", and run it as shown below, I >> expect the results I get for all but the last one: >> >> % ./opry b >> success: 'banana' >> >> % ./opry c >> success: 'chocolate' >> >> % ./opry fr >> success: 'frito' >> >> % ./opry fri >> success: 'frito' >> >> % ./opry fro >> "test" (line 1, column 3): >> unexpected "o" >> expecting "i", white space or end of input >> >> Sooo... why do I get that last one? My expectation was that parsec >> would try the string "fro" with the parser for "frito", it would fail, >> having consumed 2 characters, but then the TPCP.try which is wrapped >> around all of that should restore everything, and then the final >> parser for "fromage" should succeed. The same reasoning seems to me to >> apply if I specify 3 characters as the required initial portion for >> "frito", and if I do that it does succeed as I expect. >> >> So is this a bug in parsec, or a bug in my brain? > > Move the try to the last alternative. > No, that doesn't do it... I get the same error (and also the same if I wrap both alternatives in try). Uwe From gcross at phys.washington.edu Mon Oct 12 22:41:03 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Oct 12 22:18:21 2009 Subject: [Haskell-cafe] Why MTL and Transformers? Message-ID: Something that I have been wondering for a while is: why are there *still* two monad transformer libraries with seemingly identical functionality, especially given that they have conflicting namespaces? It creates stupid problems like the one that Erik encountered and had to work around. I recognize that this situation most likely came about via historical accident rather than by intention, but why does it continue to be true? Cheers, Greg From uhollerbach at gmail.com Mon Oct 12 22:49:21 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Mon Oct 12 22:26:38 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> Message-ID: <65d7a7e0910121949g2117265eud191f28a2febfd98@mail.gmail.com> On 10/12/09, Brandon S. Allbery KF8NH wrote: > On Oct 12, 2009, at 22:28 , Uwe Hollerbach wrote: >> parsePrefixOf n str = >> string (take n str) >> opts (drop n str) >> return str >> where opts [] = return () >> opts (c:cs) = optional (char c >> opts cs) > > Seems to me this will succeed as soon as it possibly can... > >> myTest = myPrefixOf 1 "banana" >> <|> myPrefixOf 1 "chocolate" >> <|> TPCP.try (myPrefixOf 2 "frito") >> <|> myPrefixOf 3 "fromage" > > ...so the "frito" branch gets committed as soon as "fr" is read/parsed > (myTest returns)... > >> % ./opry fro >> "test" (line 1, column 3): >> unexpected "o" >> expecting "i", white space or end of input > > ...which is why this is looking for "white space or end of input". > > My fix would be to have myPrefixOf require the prefix be terminated in > whatever way is appropriate (end of input, white space, operator?) > instead of simply accepting as soon as it gets a prefix match > regardless of what follows. > > -- > 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 > > > Ah, yes, I see where I went wrong; thank you! Uwe From lajos.nagy at gmail.com Mon Oct 12 22:51:22 2009 From: lajos.nagy at gmail.com (Lajos Nagy) Date: Mon Oct 12 22:28:40 2009 Subject: [Haskell-cafe] Graph Library Using Associated Types Message-ID: <1c92edeb0910121951l74b53d57ifc545ca8b076226b@mail.gmail.com> Hi, I understand that one of the original motivations for introducing associated types to Haskell was the survey of support for generic programming done by Garcia et al. where they compared the implementation of the Boost Graph Library in various languages (C++, Java, Haskell, ML, C#, Eiffel). Haskell got full marks in all categories, except for associated types which made the resulting implementations more verbose than necessary (and exposed implementation details). Since then GHC added support for associated types but I was wondering if anybody re-did the experiment with the new features enabled (the original code is available at: http://www.osl.iu.edu/research/comparing/). Regards, Lajos -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091012/3fd33217/attachment.html From chak at cse.unsw.edu.au Tue Oct 13 01:23:04 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Tue Oct 13 01:00:45 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication In-Reply-To: <20091012073820.GC30332@rwbarton.mit.edu> References: <20091012073820.GC30332@rwbarton.mit.edu> Message-ID: <1AC804B6-0C58-426A-82D1-D05CF8209169@cse.unsw.edu.au> Reid Barton: > On Sat, Oct 10, 2009 at 02:59:37PM -0400, Brad Larsen wrote: >> Suppose we implement type-level naturals as so: >> >> data Zero >> data Succ a >> >> Then, we can reflect the type-level naturals into a GADT as so (not >> sure if ``reflect'' is the right terminology here): >> >> data Nat :: * -> * where >> Zero :: Nat Zero >> Succ :: Nat a -> Nat (Succ a) >> >> Using type families, we can then proceed to define type-level >> addition: >> >> type family Add a b :: * >> type instance Add Zero b = b >> type instance Add (Succ a) b = Succ (Add a b) >> >> Is there any way to define type-level multiplication without >> requiring >> undecidable instances? > > I hesitate to contradict Manuel Chakravarty on this subject... but I > posted a type-level multiplication program without undecidable > instances on this list in June: > > http://www.haskell.org/pipermail/haskell-cafe/2009-June/062452.html > > If you prefer to use EmptyDataDecls, you can replace the first four > lines by > > data Z > data S n > > data Id :: * -> * > data (:.) :: (* -> *) -> (* -> *) -> (* -> *) > > And I still don't understand why that definition works while > the obvious one doesn't :) Ok, I should have been more precise. It's not that anything about multiplication as such is a problem. However, when you look at the standard definitions for addition > type family Add a b :: * > type instance Add Zero b = b > type instance Add (Succ a) b = Succ (Add a b) and multiplication > type family Mul a b :: * > type instance Mul Zero b = Zero > type instance Mul (Succ a) b = Add (Mul a b) b then the difference is that multiplication uses nested applications of type families (namely, Add (Mul a b) b). It is this nested application of type families that can be abused to construct programs that lead to non-termination of type checking (by exploiting the openness of type families in combination with local equalities introduced either by equality constraints in type signatures or GADT pattern matches). Unfortunately, there doesn't seem to be a simple syntactic criterion that would let GHC decide between harmless and problematic uses of nested *open* family applications in family instances. Hence, we need to rule them all out. You circumvent that problem cleverly by the use of higher-kinded types. Manuel From chak at cse.unsw.edu.au Tue Oct 13 01:24:50 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Tue Oct 13 01:02:22 2009 Subject: [Haskell-cafe] Graph Library Using Associated Types In-Reply-To: <1c92edeb0910121951l74b53d57ifc545ca8b076226b@mail.gmail.com> References: <1c92edeb0910121951l74b53d57ifc545ca8b076226b@mail.gmail.com> Message-ID: <6E9849FA-9FD1-4911-9353-FEBFD84E0B25@cse.unsw.edu.au> Lajos Nagy: > I understand that one of the original motivations for introducing > associated types to Haskell was the survey of support for generic > programming done by Garcia et al. where they compared the > implementation of the Boost Graph Library in various languages (C++, > Java, Haskell, ML, C#, Eiffel). Haskell got full marks in all > categories, except for associated types which made the resulting > implementations more verbose than necessary (and exposed > implementation details). Since then GHC added support for > associated types but I was wondering if anybody re-did the > experiment with the new features enabled (the original code is > available at: http://www.osl.iu.edu/research/comparing/). No, we actually didn't do that. It would be interesting, though. Manuel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091013/528ca9c4/attachment.html From DekuDekuplex at Yahoo.com Tue Oct 13 02:18:38 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Oct 13 01:56:29 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News: Issue 134 - October 10, 2009 References: <4ad03c0a.9753f10a.238d.3a88@mx.google.com> Message-ID: <9i68d5lgo92aunl8pqaq808kmttpqafsld@4ax.com> Either way is fine with me. Since HWN also contains beginner-related topics, personally, I don't think that posting it to Haskell-Beginners takes the group any more off-topic than posting it to Haskell-Cafe (although I can see the argument against cross-posting it to mailing lists in addition to the main Haskell mailing list). If it winds up getting posted to Haskell-Beginners, I'll gladly read it there, but if it just gets posted to the main Haskell mailing list, I'll read it there, also. -- Benjamin L. Russell On Sun, 11 Oct 2009 14:31:22 +0200, Max Rabkin wrote: >Why don't you subscribe to haskell? It's much lower volume, and I >think it's a better option than taking -beginners off-topic. > >--Max > >On Sun, Oct 11, 2009 at 2:10 PM, Patrick LeBoutillier > wrote: >> Hi, >> >> Could/should the Haskell Weekly News be posted to the beginners list as >> well? >> >> I normally don't follow haskell-cafe (too much traffic and generally above >> my level I must admit...), but I like to follow what's going on in the >> Haskell community. >> >> >> Patrick -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From martijn at van.steenbergen.nl Tue Oct 13 02:33:06 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Oct 13 02:10:33 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> Message-ID: <4AD41F22.7080705@van.steenbergen.nl> Brandon S. Allbery KF8NH wrote: > My fix would be to have myPrefixOf require the prefix be terminated in > whatever way is appropriate (end of input, white space, operator?) > instead of simply accepting as soon as it gets a prefix match regardless > of what follows. Maybe you can use notFollowedBy for this. HTH, Martijn. From martijn at van.steenbergen.nl Tue Oct 13 02:36:20 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Oct 13 02:13:42 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013130506.6954971c.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> <78991278-57F7-4069-894E-5852A01164AA@phys.washington.edu> <20091013130506.6954971c.mle+hs@mega-nerd.com> Message-ID: <4AD41FE4.40309@van.steenbergen.nl> Erik de Castro Lopo wrote: > However after reading the hackage descriptions of both Transformers and > MTL, it seems that they share a very similar heritage. I therefore hacked > the iteratee.cabal file and replaced the build-depends on transformers > with one on mtl and the package built quite happily. I'll play with it > a bit to see if its working correctly. I think the standard solutions are * use Cabal for your project and/or * use the PackageImports extension. HTH, Martijn. From mle+hs at mega-nerd.com Tue Oct 13 03:15:22 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Oct 13 02:52:44 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013130506.6954971c.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> <78991278-57F7-4069-894E-5852A01164AA@phys.washington.edu> <20091013130506.6954971c.mle+hs@mega-nerd.com> Message-ID: <20091013181522.f9581d39.mle+hs@mega-nerd.com> Erik de Castro Lopo wrote: > However after reading the hackage descriptions of both Transformers and > MTL, it seems that they share a very similar heritage. I therefore hacked > the iteratee.cabal file and replaced the build-depends on transformers > with one on mtl and the package built quite happily. I'll play with it > a bit to see if its working correctly. Well Iteratee built with MTL passes all the tests that shipped with it so I suppose it must be correct. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From ganesh.sittampalam at credit-suisse.com Tue Oct 13 03:24:19 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue Oct 13 03:01:47 2009 Subject: [Haskell-cafe] Why MTL and Transformers? In-Reply-To: References: Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9FB78@ELON17P32001A.csfb.cs-group.com> Gregory Crosswhite wrote: > Something that I have been wondering for a while is: why are there > *still* two monad transformer libraries with seemingly identical > functionality, especially given that they have conflicting > namespaces? It creates stupid problems like the one that Erik > encountered and had to work around. > > I recognize that this situation most likely came about via historical > accident rather than by intention, but why does it continue to be > true? The intention is to migrate to transformers, which has a slightly better design and separates out the functional dependencies into a separate package (monads-fd), thus allowing use of the type families variant (monads-tf) instead. This has been discussed to some extent on the libraries list and a workable strategy involving making a new mtl 2.0 that re-exports transformers has been suggested. However the migration from extralibs to the Haskell Platform put the brakes on further progress for a bit. Now that this migration is essentially complete I have been intending to revive the proposal but haven't got round to it yet. Please do jump in and do so yourself if you feel motivated! Cheers, Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From simonpj at microsoft.com Tue Oct 13 03:37:51 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Oct 13 03:15:10 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication In-Reply-To: <1CB4B201-4BC1-49E4-84A2-223BE6DD83B8@cse.unsw.edu.au> References: <1CB4B201-4BC1-49E4-84A2-223BE6DD83B8@cse.unsw.edu.au> Message-ID: <59543203684B2244980D7E4057D5FBC1061B133D@DB3EX14MBXC310.europe.corp.microsoft.com> | > Is there any way to define type-level multiplication without requiring | > undecidable instances? | | No, not at the moment. The reasons are explained in the paper "Type | Checking with Open Type Functions" (ICFP'08): | | http://www.cse.unsw.edu.au/~chak/papers/tc-tfs.pdf | | We want to eventually add closed *type families* to the system (ie, | families where you can't add new instances in other modules). For | such closed families, we should be able to admit more complex | instances without requiring undecidable instances. It's also worth noting that while "undecidable" instances sound scary, but all it means is that the type checker can't prove that type inference will terminate. We accept this lack-of-guarantee for the programs we *run*, and type inference can (worst case) take exponential time which is not so different from failing to terminate; so risking non-termination in type inference is arguably not so bad. Simon From ross at soi.city.ac.uk Tue Oct 13 03:43:12 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Tue Oct 13 03:20:32 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013120821.1ad7db27.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> Message-ID: <20091013074312.GA5359@soi.city.ac.uk> On Tue, Oct 13, 2009 at 12:08:21PM +1100, Erik de Castro Lopo wrote: > Here's an example. CGI uses MTL, Iteratee uses Transformers. > > So, how do you use CGI and Iteratee in the same program? There should be no problem with that, as long as you build your program using cabal. Cabal will build each package exposing only the packages it directly depends on. From ross at soi.city.ac.uk Tue Oct 13 03:51:12 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Tue Oct 13 03:28:32 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013074312.GA5359@soi.city.ac.uk> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> <83C97DF5-3404-4526-84FF-FCE81D7AB619@phys.washington.edu> <20091013120821.1ad7db27.mle+hs@mega-nerd.com> <20091013074312.GA5359@soi.city.ac.uk> Message-ID: <20091013075112.GA5415@soi.city.ac.uk> On Tue, Oct 13, 2009 at 08:43:12AM +0100, Ross Paterson wrote: > On Tue, Oct 13, 2009 at 12:08:21PM +1100, Erik de Castro Lopo wrote: > > Here's an example. CGI uses MTL, Iteratee uses Transformers. > > > > So, how do you use CGI and Iteratee in the same program? > > There should be no problem with that, as long as you build your program > using cabal. Cabal will build each package exposing only the packages > it directly depends on. Ah, I see: both packages have MonadIO and MonadTrans in their interface. That will be a problem, which will only be fixed by the proposed transition Ganesh mentioned. From anotheraddress at gmx.de Tue Oct 13 05:25:33 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Tue Oct 13 05:02:55 2009 Subject: [Haskell-cafe] MTL vs Transformers? In-Reply-To: <20091013114629.728dedaa.mle+hs@mega-nerd.com> References: <20091013114629.728dedaa.mle+hs@mega-nerd.com> Message-ID: <200910131125.33593.anotheraddress@gmx.de> On Tuesday 13 October 2009 02:46:29 Erik de Castro Lopo wrote: > Hi all, > > I've just received the following error message: > > headers.hs:6:7: > Could not find module `Control.Monad.Identity': > it was found in multiple packages: transformers-0.1.4.0 mtl-1.1.0.2 > > I'm trying to use the Iteratee module which depends on Transformers > but I use MTL in other stuff. > > Whats the preferred solution here? > > Erik > Hi, alternative to ghc-pkg: {-# LANGUAGE -XPackageImports #-} module Blub where import "mtl" Control.Monad.State -- Daniel From ekirpichov at gmail.com Tue Oct 13 05:44:22 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Oct 13 05:21:39 2009 Subject: [Haskell-cafe] Experiments with defunctionalization, church-encoding and CPS Message-ID: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> I took a toy problem - find the first node satisfying a predicate in a binary tree, started with a naive Maybe-based implementation - and experimented with 3 ways of changing the program: - Church-encode the Maybe - Convert the program into CPS - Defunctionalize the Church-encoded or CPS-transformed program http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10686 The link points to code, a benchmark and conclusion. Conclusion: - Haskell implements Maybe well enough that it is not possible to do better - Defunctionalization and consequent optimization yields same performance as the one with Maybe - Non-simplified CPS and Church-encoded representations do bad -- Eugene Kirpichov Web IR developer, market.yandex.ru From jwlato at gmail.com Tue Oct 13 06:12:05 2009 From: jwlato at gmail.com (John Lato) Date: Tue Oct 13 05:49:20 2009 Subject: [Haskell-cafe] Re: MTL vs Transformers? Message-ID: <9979e72e0910130312paee4f4cte23e4d5f389cdb33@mail.gmail.com> > From: Erik de Castro Lopo > > Well Iteratee built with MTL passes all the tests that shipped with it > so I suppose it must be correct. > Unfortunately the iteratee tests aren't exhaustive, but if it builds with MTL it should work. I'm more surprised that it built just by changing the .cabal file; I would expect you'd have to hack up the imports in the source code. John From mle+hs at mega-nerd.com Tue Oct 13 06:34:13 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Oct 13 06:11:33 2009 Subject: [Haskell-cafe] Re: MTL vs Transformers? In-Reply-To: <9979e72e0910130312paee4f4cte23e4d5f389cdb33@mail.gmail.com> References: <9979e72e0910130312paee4f4cte23e4d5f389cdb33@mail.gmail.com> Message-ID: <20091013213413.5b74160a.mle+hs@mega-nerd.com> John Lato wrote: > Unfortunately the iteratee tests aren't exhaustive, but if it builds > with MTL it should work. I'm more surprised that it built just by > changing the .cabal file; Nope, no hacking required beyond the .cabal file. > I would expect you'd have to hack up the > imports in the source code. Thats actually the problem, MTL and Transformers both provide Control.Monad.Identity, Control.Monad.Trans and possibly others. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From valgarv at gmx.net Tue Oct 13 07:12:45 2009 From: valgarv at gmx.net (Ariel J. Birnbaum) Date: Tue Oct 13 06:50:03 2009 Subject: [Haskell-cafe] Haskell-tan competition In-Reply-To: <4AD200BC.7060801@cogito.org.uk> References: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> <4AD200BC.7060801@cogito.org.uk> Message-ID: <1255432365.7117.9.camel@lnx-arielb> > What about Lambdabot? The official (?) personification of Lambdabot is OK, but lacks moe[1], which the OP seems to intend by using the suffix '-tan'. In any case, she represents Lambdabot only, not Haskell in general. I'll try and give this one a shot over the weekend. Have fun! [1] http://en.wikipedia.org/wiki/Moe_anthropomorphism -- Ariel J. "askyle" Birnbaum From svein.ove at aas.no Tue Oct 13 08:26:27 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Oct 13 08:03:45 2009 Subject: [Haskell-cafe] Haskell-tan competition In-Reply-To: <1255432365.7117.9.camel@lnx-arielb> References: <221b53ab0910101202k429f07f0ofd377ea812a0e45a@mail.gmail.com> <4AD200BC.7060801@cogito.org.uk> <1255432365.7117.9.camel@lnx-arielb> Message-ID: <221b53ab0910130526q639b7458r3fc864c82baae7bb@mail.gmail.com> On Tue, Oct 13, 2009 at 1:12 PM, Ariel J. Birnbaum wrote: >> What about Lambdabot? > > The official (?) personification of Lambdabot is OK, but lacks moe[1], > which the OP seems to intend by using the suffix '-tan'. In any case, > she represents Lambdabot only, not Haskell in general. > A lambdabot-specific personification is fine too, but I agree that it lacks charm. Though I wonder, where should we put these? Having the lambdabot one on the lambdabot page is fine, but haskell-tan would have to be stuck on the front page. Which seems a bit too much. -- Svein Ove Aas From nad at Cs.Nott.AC.UK Tue Oct 13 08:28:38 2009 From: nad at Cs.Nott.AC.UK (Nils Anders Danielsson) Date: Tue Oct 13 08:06:23 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <1254932943.21105.54.camel@antimony> References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: <4AD47276.8020107@cs.nott.ac.uk> On 2009-10-07 17:29, Robert Atkey wrote: > A deep embedding of a parsing DSL (really a context-sensitive grammar > DSL) would look something like the following. I think I saw something > like this in the Agda2 code somewhere, but I stumbled across it when I > was trying to work out what "free" applicative functors were. The Agda code you saw may have been due to Ulf Norell and me. There is a note about it on my web page: http://www.cs.nott.ac.uk/~nad/publications/danielsson-norell-parser-combinators.html > Note that these grammars are strictly less powerful than the ones that > can be expressed using Parsec because we only have a fixed range of > possibilities for each rule, rather than allowing previously parsed > input to determine what the parser will accept in the future. Previously parsed input /can/ determine what the parser will accept in the future (as pointed out by Peter Ljungl?f in his licentiate thesis). Consider the following grammar for the context-sensitive language {a?b?c?| n ? ?}: data NT a where Start :: NT () -- Start ?= a?b?c? ABC :: Nat -> NT () -- ABC n ?= a?b???c??? X :: Char -> Nat -> NT () -- X x n ?= x? g :: Grammar NT g Start = nt (ABC 0) g (ABC n) = char 'a' <* nt (ABC (succ n)) <|> nt (X 'b' n) <* nt (X 'c' n) g (X c n) | n == 0 = pure () | otherwise = char c <* nt (X c (pred n)) > And a general definition for parsing single-digit numbers. This works > for any set of non-terminals, so it is a reusable component that works > for any grammar: Things become more complicated if the reusable component is defined using non-terminals which take rules (defined using an arbitrary non-terminal type) as arguments. Exercise: Define a reusable variant of the Kleene star, without using grammars of infinite depth. -- /NAD This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From simonpj at microsoft.com Tue Oct 13 08:43:18 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Oct 13 08:20:36 2009 Subject: [Haskell-cafe] Re: Libraries for Commercial Users In-Reply-To: <4AD27E45.7060900@freegeek.org> References: <20090929153550.GG24761@analytic.cynic.net> <20091007234127.GC9180@poetic.cynic.net> <3DAD2D2B-9069-42B4-844F-9D5691D1CC04@n-brain.net> <20091008172417.GD31281@whirlpool.galois.com> <23DF43DF-EBB3-43C1-A422-96DFAE2D3897@n-brain.net> <8D2CF6DC-9656-415E-B30B-053BA19114F9@n-brain.net> <20091010211139.GA9326@whirlpool.galois.com> <4AD27E45.7060900@freegeek.org> Message-ID: <59543203684B2244980D7E4057D5FBC1061B25F5@DB3EX14MBXC310.europe.corp.microsoft.com> There is no difficulty in principle with Haskell on JVM. There are, however, some obstacles in practice, as this page describes: http://haskell.org/haskellwiki/GHC:FAQ#Why_isn.27t_GHC_available_for_.NET_or_on_the_JVM.3F The way stands open for someone with design taste, knowledge of the JVM, and sustained willingness to roll up sleeves, to make a significant contribution. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of wren ng thornton | Sent: 12 October 2009 01:54 | To: Haskell Cafe | Subject: Re: [Haskell-cafe] Re: Libraries for Commercial Users | | Patrick LeBoutillier wrote: | > Don, | > | >>> Having painless Haskell <- Java interoperability would be great. I'm | >>> curious though: could it really be so simple as a one-line ``import | >>> foreign jvm'' directive? I imagine the purity mismatch between | >>> Haskell and Java would be very troublesome. | >> No more so than C, surely. We're used to stateful APIs. They're a pain. | >> | >> | >>> With this hypothetical ``import foreign jvm'' mechanism, what would | >>> the be type of imported Java stuff? Would it all be done in IO? | >>> | >>> The more I think about it, the trickier it seems. Beside the purity | >>> mismatch of Haskell and Java, there is an OO/functional mismatch. | >> That's more of an issue. But the prior work has been done. | > | > Do you have any references to this work? | | | It was a major research topic about a decade ago, though the projects | have died since. And the topic comes up about every 4 months on the | Cafe, so I'd recommend sifting through the archives. I know last time it | came up (or the time before?) I gave a rather extensive list of | projects. And the wiki[1] still lists a few of them. | | The last time this discussion came up people got involved enough to | revive LambdaVM[2], which was one of the more mature options back in the | day. If you're interested in the topic, I suggest getting in touch with | the author and helping out. | | On the topic of automatically embedding OO-style languages into Haskell, | you should also check out hprotoc[3]. It's a package for Google's | protocol buffers, which are ostensibly language agnostic but actually | assume a (weakly) OO language. The hprotoc library will create a family | of virtual modules based on the protocol spec and makes a pretty nice | interface out of them. | | | [1] | http://www.haskell.org/haskellwiki/Applications_and_libraries/Interfacing_other_lang | uages | [2] http://wiki.brianweb.net/LambdaVM/LambdaVM | [3] http://hackage.haskell.org/package/hprotoc | | -- | Live well, | ~wren | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From jgoerzen at complete.org Tue Oct 13 09:48:20 2009 From: jgoerzen at complete.org (John Goerzen) Date: Tue Oct 13 09:25:39 2009 Subject: [Haskell-cafe] Time Typeable Instances In-Reply-To: References: <4AD3DD3C.7050703@complete.org> Message-ID: <4AD48524.1080209@complete.org> Hugo Gomes wrote: > The Glorious Glasgow Haskell Compilation System, version 6.10.4 > with old-time-1.0.0.2 and time-1.1.2.4 > > This is a standard haskell platform on a windows xp. Cabal install > didn't work complaining about missing instances of typeable for posix > time and other datatypes, yet, after removing the macros (thus, adding > those instances), hdbc and convertible compiled and installed fine. > > Removing the macros might be a bit overkill, probably finetuning them so > that they add only the necessary instances for typeable in ghc > 610 > might be a better solution. I'm going to CC haskell-cafe on this because I am confused. Hugo, can you confirm what version of convertible you have? Back on May 21, I started a thread [1] on haskell-cafe complaining that GHC 6.10.3 included a newer time that included instances of Typeable for NominalDiffTime and UTCTime. This broke my code, which had manually defined instances for these types, as they were needed. Things got complicated, as only time's minor version number got incremented (x.x.x.Y) [2]. Cabal can't test against that version number. I wanted my code to work with old and new versions of GHC. Since testing against the version of time was impossible, I did the next best thing: tested against the version of GHC. #if __GLASGOW_HASKELL__ >= 610 -- instances added in GHC 6.10.3 #else instance Typeable NominalDiffTime where typeOf _ = mkTypeName "NominalDiffTime" instance Typeable UTCTime where typeOf _ = mkTypeName "UTCTime" #endif Also, in the .cabal, there is a build-depends on time>=1.1.2.4. Now, that would break for GHC 6.10.1 and 6.10.2 users, but will work for 6.10.3 and above, or 6.8 and below. Or so I thought. Now I'm getting complaints from people using 6.10.4 saying that there are now missing instances of Typeable with time 1.1.2.4. 1) Did the Typeable instances get dropped again from time? 2) What exactly should I do so this library compiles on GHC 6.8 and 6.10.x? I'm looking at the darcs repo for time and don't see the instances ever getting dropped. [1] http://osdir.com/ml/haskell-cafe@haskell.org/2009-05/msg00982.html [2] http://osdir.com/ml/haskell-cafe@haskell.org/2009-05/msg00985.html .... later addendum .... so it appears that what's happening here is that GHC 6.10.3 extralibs included time 1.1.3, but then haskell-platform standardized on 1.1.2.4. This is pretty annoying -- that haskell-platform would standardize on a version older than what shipped with a GHC release -- but I guess I can work around it by restricting my build-dep to be time < 1.1.3 and re-adding the instances. Does this sound right? > > > On Tue, Oct 13, 2009 at 2:51 AM, John Goerzen > wrote: > > Hugo Gomes wrote: > > Hi, > > > > convertible and hdbc packages fail to compile in my standard > instalation > > of the haskell platform. I think this has to do with those "if ghc >= > > 610" macros on the typeable instances for some datatypes. I > removed them > > and now they work fine... > > > > > > > > > What version of GHC and time do you have? > > -- John > > From uhollerbach at gmail.com Tue Oct 13 11:10:08 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Tue Oct 13 10:47:24 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <4AD41F22.7080705@van.steenbergen.nl> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> Message-ID: <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> On 10/12/09, Martijn van Steenbergen wrote: > Brandon S. Allbery KF8NH wrote: >> My fix would be to have myPrefixOf require the prefix be terminated in >> whatever way is appropriate (end of input, white space, operator?) >> instead of simply accepting as soon as it gets a prefix match regardless >> of what follows. > > Maybe you can use notFollowedBy for this. > > HTH, > > Martijn. > > Yes, I've looked at that and am thinking about it. I'm not quite certain it's needed in my real program... I seem to have convinced myself that if I actually specify a proper set of unique prefixes, ie, set the required lengths for both "frito" and "fromage" to 3 in the test program, I won't get into this situation. Assuming I haven't committed another brain-fart there, that would be sufficient; presumably, in a real program one would want to actually specify the unique prefix, rather than a non-unique pre-prefix. It seems to work fine in my real program, anyway. Uwe From brad.larsen at gmail.com Tue Oct 13 11:40:53 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Oct 13 11:18:08 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication In-Reply-To: <59543203684B2244980D7E4057D5FBC1061B133D@DB3EX14MBXC310.europe.corp.microsoft.com> References: <1CB4B201-4BC1-49E4-84A2-223BE6DD83B8@cse.unsw.edu.au> <59543203684B2244980D7E4057D5FBC1061B133D@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: On Tue, Oct 13, 2009 at 3:37 AM, Simon Peyton-Jones wrote: [...] > It's also worth noting that while "undecidable" instances sound scary, but all it means is that the type checker can't prove that type inference will terminate. ?We accept this lack-of-guarantee for the programs we *run*, and type inference can (worst case) take exponential time which is not so different from failing to terminate; so risking non-termination in type inference is arguably not so bad. > > Simon Indeed! On a related note, template instantiation in C++ is undecidable. See ``C++ Templates are Turing Complete'' by Todd Veldhuizen: . And similarly, heavy use of templates in C++ can be *extremely* compute-intensive. Sincerely, Brad From brad.larsen at gmail.com Tue Oct 13 12:04:46 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Oct 13 11:42:01 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) Message-ID: On Tue, Oct 13, 2009 at 3:37 AM, Simon Peyton-Jones wrote: > | > Is there any way to define type-level multiplication without requiring > | > undecidable instances? > | > | No, not at the moment. ?The reasons are explained in the paper "Type > | Checking with Open Type Functions" (ICFP'08): > | > | ? ?http://www.cse.unsw.edu.au/~chak/papers/tc-tfs.pdf > | > | We want to eventually add closed *type families* to the system (ie, > | families where you can't add new instances in other modules). ?For > | such closed families, we should be able to admit more complex > | instances without requiring undecidable instances. > > It's also worth noting that while "undecidable" instances sound scary, but all it means is that the type checker can't prove that type inference will terminate. ?We accept this lack-of-guarantee for the programs we *run*, and type inference can (worst case) take exponential time which is not so different from failing to terminate; so risking non-termination in type inference is arguably not so bad. > > Simon > I have written code that makes heavy use of multi-parameter type classes in the ``finally tagless'' tradition, which takes several seconds and many megabytes of memory for GHCI to infer its type. However, that example is rather complicated, and I am not sure its type inference complexity is exponential---it is at least very bad. Are there any simple, well-known examples where Haskell type inference has exponential complexity? Or Hindley-Milner type inference, for that matter? (Haskell 98 is not quite Hindley-Milner?) Sincerely, Brad Larsen From lennart at augustsson.net Tue Oct 13 12:14:26 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Oct 13 11:51:43 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: References: Message-ID: Yes, there are simple H-M examples that are exponential. x0 = undefined x1 = (x1,x1) x2 = (x2,x2) x3 = (x3,x3) ... xn will have a type with 2^n type variables so it has size 2^n. -- Lennart On Tue, Oct 13, 2009 at 6:04 PM, Brad Larsen wrote: > On Tue, Oct 13, 2009 at 3:37 AM, Simon Peyton-Jones > wrote: >> | > Is there any way to define type-level multiplication without requiring >> | > undecidable instances? >> | >> | No, not at the moment. ?The reasons are explained in the paper "Type >> | Checking with Open Type Functions" (ICFP'08): >> | >> | ? ?http://www.cse.unsw.edu.au/~chak/papers/tc-tfs.pdf >> | >> | We want to eventually add closed *type families* to the system (ie, >> | families where you can't add new instances in other modules). ?For >> | such closed families, we should be able to admit more complex >> | instances without requiring undecidable instances. >> >> It's also worth noting that while "undecidable" instances sound scary, but all it means is that the type checker can't prove that type inference will terminate. ?We accept this lack-of-guarantee for the programs we *run*, and type inference can (worst case) take exponential time which is not so different from failing to terminate; so risking non-termination in type inference is arguably not so bad. >> >> Simon >> > > I have written code that makes heavy use of multi-parameter type > classes in the ``finally tagless'' tradition, which takes several > seconds and many megabytes of memory for GHCI to infer its type. > However, that example is rather complicated, and I am not sure its > type inference complexity is exponential---it is at least very bad. > > Are there any simple, well-known examples where Haskell type inference > has exponential complexity? ?Or Hindley-Milner type inference, for > that matter? ?(Haskell 98 is not quite Hindley-Milner?) > > Sincerely, > Brad Larsen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From sergueyz at gmail.com Tue Oct 13 12:32:53 2009 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Oct 13 12:10:10 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: References: Message-ID: <600376290910130932s4a269fe2g9d8e8eaf6856e9e8@mail.gmail.com> 2009/10/13 Lennart Augustsson : > Yes, there are simple H-M examples that are exponential. > x0 = undefined > x1 = (x1,x1) > x2 = (x2,x2) > x3 = (x3,x3) > ... > > xn will have a type with 2^n type variables so it has size 2^n. Reformulated: let dup x = (x,x) :t dup . dup . dup . dup ... type will be 2^(number of dup's). I experimented and found that GHC can stand pretty long line of dup's. More than 20, at least. One part of our program took too much time to typecheck some time ago. 3 and half minutes for ~900 lines module. Most of operations was inside heavily parametrized monad (5 parameters, each is a Peano number). Then my colleague moved parameters into associated types of relevant type class and now it typechecks in ten seconds. From brad.larsen at gmail.com Tue Oct 13 13:06:41 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Oct 13 12:43:57 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: <600376290910130932s4a269fe2g9d8e8eaf6856e9e8@mail.gmail.com> References: <600376290910130932s4a269fe2g9d8e8eaf6856e9e8@mail.gmail.com> Message-ID: On Tue, Oct 13, 2009 at 12:32 PM, Serguey Zefirov wrote: > 2009/10/13 Lennart Augustsson : >> Yes, there are simple H-M examples that are exponential. >> x0 = undefined >> x1 = (x1,x1) >> x2 = (x2,x2) >> x3 = (x3,x3) >> ... >> >> xn will have a type with 2^n type variables so it has size 2^n. > > Reformulated: > let dup x = (x,x) > :t dup . dup . dup . dup ... > > type will be 2^(number of dup's). > > I experimented and found that GHC can stand pretty long line of dup's. > More than 20, at least. > > One part of our program took too much time to typecheck some time ago. > 3 and half minutes for ~900 lines module. Most of operations was > inside heavily parametrized monad (5 parameters, each is a Peano > number). Then my colleague moved parameters into associated types of > relevant type class and now it typechecks in ten seconds. > Good example! I have a feeling that the `dup' example is a bit contrived, not something that one would be likely to find in the wild. Heavily parameterized type classes, on the other hand, are more common in real code. Hence, that is more likely where someone would run into really awful type inference performance without expecting it. Brad From daniel.is.fischer at web.de Tue Oct 13 13:34:36 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Oct 13 13:13:10 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] using quickcheck for blackbox testing for 3rd party apps. In-Reply-To: <20091013160452.GB2687@seas.upenn.edu> References: <20091013160452.GB2687@seas.upenn.edu> Message-ID: <200910131934.36808.daniel.is.fischer@web.de> Am Dienstag 13 Oktober 2009 18:04:52 schrieb Brent Yorgey: > Brent > > * Some smart-alecks might pipe up with something about unsafePerformIO > ? here. ?But that's not a cure, it's more like performing an emergency > ? tracheotomy with a ballpoint pen. Quote of the month! From dons at galois.com Tue Oct 13 14:44:15 2009 From: dons at galois.com (Don Stewart) Date: Tue Oct 13 14:21:35 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists Message-ID: <20091013184415.GI7864@whirlpool.galois.com> Hey all, Following up on this, I'm presenting a position paper tomorrow on the use of EDSLs to improve productivity and lower cost when developing code for new high performance architectures (like GPUs). http://www.galois.com/blog/2009/10/13/domain-specific-languages-for-domain-specific-problems/ It advocates for Haskell + EDSLs, much as we have been discussing in this thread. -- Don From vandijk.roel at gmail.com Tue Oct 13 15:30:00 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Tue Oct 13 15:07:16 2009 Subject: [Haskell-cafe] Reverse dependencies in Hackage Message-ID: A few weeks ago I wrote a patch that adds reverse dependencies to hackage [1]. I have know hosted a small test hackage which demonstrates this feature. It can be found here: http://bifunctor.homelinux.net/~roel/hackage Browse to your favorite packages and find out how much other packages depend on them! I also noticed that work is underway to implement a new hackage-server [2] based on happstack. If people find this feature useful I could also write a patch against the hackage-server code base [3]. Regards, Roel van Dijk [1] - http://hackage.haskell.org/trac/hackage/ticket/576 [2] - http://sparky.haskell.org:8080/ [3] - http://code.haskell.org/hackage-server/ From conal at conal.net Tue Oct 13 15:32:10 2009 From: conal at conal.net (Conal Elliott) Date: Tue Oct 13 15:09:45 2009 Subject: [Haskell-cafe] <**> for nested applicative functors? In-Reply-To: <25859274.post@talk.nabble.com> References: <25858792.post@talk.nabble.com> <25859274.post@talk.nabble.com> Message-ID: Hi Kim-Ee, This pattern shows up in "Applicative programming with effects" in showing that the composition of applicatives is applicative: (<*>) = liftA2 (<*>), and pure = pure.pure . (Really, you have to manage newtype wrappers as well. See the TypeCompose library.) - Conal On Mon, Oct 12, 2009 at 9:52 AM, Kim-Ee Yeoh wrote: > > That's it: liftA2 (<*>), so obvious in hindsight. > > Mustn't ... code ... when ... drained .... > > Thanks to Jeremy and Josef. > > > Jeremy Shaw-3 wrote: > > > > This looks like what is described in Section 4 to me: > > > > > http://www.haskell.org/haskellwiki/Applicative_functor#Applicative_transfomers > > > > - jeremy > > > > On Oct 12, 2009, at 11:22 AM, Kim-Ee Yeoh wrote: > > > >> <**> :: (Applicative m, Applicative n) => > >> m (n (a->b)) -> m (n a) -> m (n b) > > > > -- > View this message in context: > http://www.nabble.com/%3C**%3E-for-nested-applicative-functors--tp25858792p25859274.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091013/84bb282d/attachment.html From batterseapower at hotmail.com Tue Oct 13 16:53:31 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue Oct 13 16:30:47 2009 Subject: [Haskell-cafe] GHC core packages: same core? In-Reply-To: References: Message-ID: <9d4d38820910131353p498c648dr62667ae703c3ab8a@mail.gmail.com> Hi Dimitry, ghc-core is a pretty-printer for GHC's internal Core language (you can get a non-pretty-printed version simply by compiling with (IIRC) -dverbose-core2core). This is what we actually optimize and generate code from, and the formatting of this output might change at any time. This is probably what you should be looking at, as a human trying to understand how your programs are being complied. extcore is a library that parses "external" Core, which is an alternative format intended to be stable and hence a suitable target for consumption by non-GHC tooling. You can have GHC output external core instead of machine code / C. I don't believe this is widely used yet. Cheers, Max 2009/10/12 Dimitry Golubovsky : > Hi, > > Just curious whether package > http://hackage.haskell.org/package/ghc-core and > http://hackage.haskell.org/package/extcore operate on the same flavor > of GHC Core? > > There seem to be external [1] and internal [2] flavors of GHC Core. > > [1] http://www.haskell.org/ghc/docs/6.10.2/html/ext-core/core.pdf > [2] http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType > > Thanks. > > -- > Dimitry Golubovsky > > Anywhere on the Web > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From batterseapower at hotmail.com Tue Oct 13 16:58:22 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue Oct 13 16:35:36 2009 Subject: [Haskell-cafe] a library for control of terminal driver modes? In-Reply-To: References: <8E502089-031B-4938-BE79-B3EA057D1686@gmail.com> <4AD1EC13.7000409@btinternet.com> Message-ID: <9d4d38820910131358i7a3f24ecrfb88e7714e9413d9@mail.gmail.com> Yes, ansi-terminal supports this. Try: setSGR [SetBlinkSpeed NoBlink] (http://hackage.haskell.org/packages/archive/ansi-terminal/0.5.0/doc/html/System-Console-ANSI.html) Cheers, Max 2009/10/12 Iain Barnett : > > On 11 Oct 2009, at 15:30, Andrew Coppin wrote: > >> Iain Barnett wrote: >>> >>> I'm looking for a library like Perl's Term-Readkey, so that I can turn on >>> and off the echo for secure password input from a terminal. Anyone know >>> which library I need to use for this? >> >> The package ansi-terminal allows you to do various things to the terminal; >> I think it might include turning local echo on/off. Alternatively, there was >> an announcement recently about a text-mode UI package, which might do what >> you want. (I don't recall the name...) >> > > Thanks > > > Iain > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From batterseapower at hotmail.com Tue Oct 13 17:01:15 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue Oct 13 16:38:30 2009 Subject: [Haskell-cafe] a library for control of terminal driver modes? In-Reply-To: <9d4d38820910131358i7a3f24ecrfb88e7714e9413d9@mail.gmail.com> References: <8E502089-031B-4938-BE79-B3EA057D1686@gmail.com> <4AD1EC13.7000409@btinternet.com> <9d4d38820910131358i7a3f24ecrfb88e7714e9413d9@mail.gmail.com> Message-ID: <9d4d38820910131401v3c1dc174g997611e8a3590d1f@mail.gmail.com> Err, I managed to completely misread your email. Sorry. Unfortunately, ansi-terminal does NOT support disabling the echo and I don't plan to support it. However, given that I already provide non-ANSI features from it, patches would be happily accepted :-) Cheers, Max 2009/10/13 Max Bolingbroke : > Yes, ansi-terminal supports this. Try: > > setSGR [SetBlinkSpeed NoBlink] > > (http://hackage.haskell.org/packages/archive/ansi-terminal/0.5.0/doc/html/System-Console-ANSI.html) > > Cheers, > Max > > 2009/10/12 Iain Barnett : >> >> On 11 Oct 2009, at 15:30, Andrew Coppin wrote: >> >>> Iain Barnett wrote: >>>> >>>> I'm looking for a library like Perl's Term-Readkey, so that I can turn on >>>> and off the echo for secure password input from a terminal. Anyone know >>>> which library I need to use for this? >>> >>> The package ansi-terminal allows you to do various things to the terminal; >>> I think it might include turning local echo on/off. Alternatively, there was >>> an announcement recently about a text-mode UI package, which might do what >>> you want. (I don't recall the name...) >>> >> >> Thanks >> >> >> Iain >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > From golubovsky at gmail.com Tue Oct 13 17:38:39 2009 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Tue Oct 13 17:15:54 2009 Subject: [Haskell-cafe] GHC core packages: same core? In-Reply-To: <9d4d38820910131353p498c648dr62667ae703c3ab8a@mail.gmail.com> References: <9d4d38820910131353p498c648dr62667ae703c3ab8a@mail.gmail.com> Message-ID: Max, Thanks for the explanation. So, the extcore library is expected to match the spec in http://www.haskell.org/ghc/docs/6.10.4/html/ext-core/core.pdf and the core itself can be produced with -fext-core, correct? I think it might be interesting for people working on alternative backends (inlcuding myself). On Tue, Oct 13, 2009 at 4:53 PM, Max Bolingbroke wrote: [skip] > > extcore is a library that parses "external" Core, which is an > alternative format intended to be stable and hence a suitable target > for consumption by non-GHC tooling. You can have GHC output external > core instead of machine code / C. I don't believe this is widely used > yet. -- Dimitry Golubovsky Anywhere on the Web From duncan.coutts at googlemail.com Tue Oct 13 17:40:48 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Tue Oct 13 17:18:04 2009 Subject: [Haskell-cafe] Re: Reverse dependencies in Hackage In-Reply-To: References: Message-ID: <1255470048.8777.2733.camel@localhost> On Tue, 2009-10-13 at 21:30 +0200, Roel van Dijk wrote: > I also noticed that work is underway to implement a new hackage-server > [2] based on happstack. If people find this feature useful I could > also write a patch against the hackage-server code base [3]. That would be much appreciated. Duncan From tphyahoo at gmail.com Tue Oct 13 17:57:21 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Oct 13 17:34:36 2009 Subject: [Haskell-cafe] why does "iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return [])" produce output in the IO monad, but stack overflow in the maybe monad? Message-ID: <910ddf450910131457hf99ced4y9d810c80fd2679f1@mail.gmail.com> Can someone explain why the one stack overflows and the other one doesn't? iterateNTimes i f x = foldr (.) id (replicate i f) $ x tntIO :: IO Int -- same as replicateM (10^6) $ return 0 , and same as sequence . replicate (10^6) $ return 0 tntIO = iterateNTimes (10^6) (ap . liftM (:) . return $ ) (return []) -- produces output tntMb :: Maybe Int -- overflows tntMb = iterateNTimes (10^6) (ap . liftM (:) . return $ ) (return []) -- stack overflow From xj2106 at columbia.edu Tue Oct 13 18:06:56 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue Oct 13 17:44:44 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists In-Reply-To: <20091013184415.GI7864@whirlpool.galois.com> (Don Stewart's message of "Tue, 13 Oct 2009 11:44:15 -0700") References: <20091013184415.GI7864@whirlpool.galois.com> Message-ID: <87skdn2bjz.fsf@columbia.edu> Don Stewart writes: > Hey all, > > Following up on this, I'm presenting a position paper tomorrow on the > use of EDSLs to improve productivity and lower cost when developing code > for new high performance architectures (like GPUs). > > http://www.galois.com/blog/2009/10/13/domain-specific-languages-for-domain-specific-problems/ > > It advocates for Haskell + EDSLs, much as we have been discussing in > this thread. I'm very interested in EDSL in high performance architectures. Can you give me some idea what the performance might be using code written in Haskell+EDSL compared to C/C++? I think, in high performance computing, the efficiency in the resulting binary code largely depends on the problem domain. Can haskell help a lot in optimizing the EDSL to machine binary? And what would be the efficiency in terms of space and time? Xiao-Yong -- c/* __o/* <\ * (__ */\ < From dan.doel at gmail.com Tue Oct 13 18:10:08 2009 From: dan.doel at gmail.com (Dan Doel) Date: Tue Oct 13 17:47:27 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: References: <600376290910130932s4a269fe2g9d8e8eaf6856e9e8@mail.gmail.com> Message-ID: <200910131810.09149.dan.doel@gmail.com> On Tuesday 13 October 2009 1:06:41 pm Brad Larsen wrote: > Good example! I have a feeling that the `dup' example is a bit > contrived, not something that one would be likely to find in the wild. This is, after all, why HM is useful. In general, there are programs that take exponential time/space to type check, but those programs don't come up much in real code. Also, you can do better than 2^n: f0 x = (x,x) f1 = f0 . f0 f2 = f1 . f1 f3 = f2 . f2 ... Here, if fN results in a nested tuple of size M, then f(N+1) results in a tuple of size M^2, since we replace all the variables with a copy of the tuple. So we have 2, 4, 16, 256, ... 2^(2^N) .... Turning f0 into an M-tuple gets you M^(2^N), I believe, and composing K times at each step would get you M^(K^N). But anyhow, we have not merely an exponential, but a double exponential. :) f4 takes a noticeable amount of time to check here (in ghci), and f5 makes my machine start swapping. Of course, one isn't likely to write code like this, either. -- Dan From martin.sulzmann.haskell at googlemail.com Tue Oct 13 18:31:06 2009 From: martin.sulzmann.haskell at googlemail.com (Martin Sulzmann) Date: Tue Oct 13 18:08:22 2009 Subject: [Haskell-cafe] Type-level naturals & multiplication In-Reply-To: <59543203684B2244980D7E4057D5FBC1061B133D@DB3EX14MBXC310.europe.corp.microsoft.com> References: <1CB4B201-4BC1-49E4-84A2-223BE6DD83B8@cse.unsw.edu.au> <59543203684B2244980D7E4057D5FBC1061B133D@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <4bb51c60910131531v7c5a4370n925d2e3bc841cdc@mail.gmail.com> On Tue, Oct 13, 2009 at 9:37 AM, Simon Peyton-Jones wrote: > | > Is there any way to define type-level multiplication without requiring > | > undecidable instances? > | > | No, not at the moment. The reasons are explained in the paper "Type > | Checking with Open Type Functions" (ICFP'08): > | > | http://www.cse.unsw.edu.au/~chak/papers/tc-tfs.pdf > | > | We want to eventually add closed *type families* to the system (ie, > | families where you can't add new instances in other modules). For > | such closed families, we should be able to admit more complex > | instances without requiring undecidable instances. > > It's also worth noting that while "undecidable" instances sound scary, but > all it means is that the type checker can't prove that type inference will > terminate. We accept this lack-of-guarantee for the programs we *run*, and > type inference can (worst case) take exponential time which is not so > different from failing to terminate; so risking non-termination in type > inference is arguably not so bad. > > > Some further details to shed some light on this topic. "Undecidable" instances means that there exists a program for which there's an infinite reduction sequence. By "undecidable" I refer to instances violating the conditions in the icfp'08 and in the earlier jfp paper "Understanding Functional Dependencies via Constraint Handling Rules". Consider the classic example Add (Succ x) x ~ x --> Succ (Add x x) ~ x substitute for x and you'll get another redex of the form Add (Succ ..) ... and therefore the reduction won't terminate To fix this problem, i.e. preventing the type checker to non-terminate, we could either (a) spot the "loop" in Add (Succ x) x ~ x and reject this unsatisfiable constraint and thus the program (b) simply stop after n steps The ad-hoc approach (b) restores termination but risks incompleteness. Approach (a) is non-trivial to get right, there are more complicated loopy programs where spotting the loops gets really tricky. The bottom line is this: Running the type checker on "undecidable" instances means that there are programs for which - the type checker won't terminate, or - wrongly rejects the program (incompleteness) So, the situation is slightly more scary, BUT programs exhibiting the above behavior are (in my experience) rare/contrived. -Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091013/02c75afa/attachment.html From tphyahoo at gmail.com Tue Oct 13 18:50:08 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Oct 13 18:27:23 2009 Subject: [Haskell-cafe] Re: why does "iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return [])" produce output in the IO monad, but stack overflow in the maybe monad? In-Reply-To: <910ddf450910131457hf99ced4y9d810c80fd2679f1@mail.gmail.com> References: <910ddf450910131457hf99ced4y9d810c80fd2679f1@mail.gmail.com> Message-ID: <910ddf450910131550p7b58e6f9sf1c87ec133a9b148@mail.gmail.com> correction, should be: iterateNTimes i f x = foldr (.) id (replicate i f) $ x tntIO :: IO Int -- same as replicateM (10^6) $ return 0 tntIO = return . head =<< (iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return [])) -- produces output tntMb :: Maybe Int -- overflows tntMb = return . head =<< (iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return [])) -- stack overflow which now compiles. 2009/10/13 Thomas Hartman : > Can someone explain why the one stack overflows and the other one doesn't? > > iterateNTimes i f x = foldr (.) id (replicate i f) $ x > tntIO :: IO Int > -- same as replicateM (10^6) $ return 0 , and same as sequence . > replicate (10^6) $ return 0 > tntIO = iterateNTimes (10^6) (ap . liftM (:) . return $ ) (return []) > -- produces output > tntMb :: Maybe Int -- overflows > tntMb = iterateNTimes (10^6) (ap . liftM (:) . return $ ) (return []) > -- stack overflow > From dmehrtash at gmail.com Tue Oct 13 21:40:37 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Tue Oct 13 21:17:53 2009 Subject: Fwd: [Haskell-cafe] Haskell for Physicists In-Reply-To: <87skdn2bjz.fsf@columbia.edu> References: <20091013184415.GI7864@whirlpool.galois.com> <87skdn2bjz.fsf@columbia.edu> Message-ID: Of all the projects that are in the HackageDB, how many, or what % do you say developed an EDSL? daryoush On Tue, Oct 13, 2009 at 3:06 PM, Xiao-Yong Jin wrote: > Don Stewart writes: > > > Hey all, > > > > Following up on this, I'm presenting a position paper tomorrow on the > > use of EDSLs to improve productivity and lower cost when developing code > > for new high performance architectures (like GPUs). > > > > > http://www.galois.com/blog/2009/10/13/domain-specific-languages-for-domain-specific-problems/ > > > > It advocates for Haskell + EDSLs, much as we have been discussing in > > this thread. > > I'm very interested in EDSL in high performance > architectures. Can you give me some idea what the > performance might be using code written in Haskell+EDSL > compared to C/C++? I think, in high performance computing, > the efficiency in the resulting binary code largely depends > on the problem domain. Can haskell help a lot in optimizing > the EDSL to machine binary? And what would be the > efficiency in terms of space and time? > > Xiao-Yong > -- > c/* __o/* > <\ * (__ > */\ < > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Daryoush Weblog: http://perlustration.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091013/eb527cb3/attachment.html From oleg at okmij.org Wed Oct 14 01:33:56 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Wed Oct 14 01:15:00 2009 Subject: [Haskell-cafe] (no subject) Message-ID: <20091014053356.9C7621774B@Adric.metnet.navy.mil> Martin Sulzmann wrote: > "Undecidable" instances means that there exists a program for which there's > an infinite reduction sequence. I believe this may be too strong of a statement. There exists patently terminating type families that still require undecidable instances in GHC. Here is an example: > {-# LANGUAGE TypeFamilies #-} > > type family I x :: * > type instance I x = x > > type family B x :: * > type instance B x = I x GHC 6.8.3 complaints: Application is no smaller than the instance head in the type family application: I x (Use -fallow-undecidable-instances to permit this) In the type synonym instance declaration for `B' But there cannot possibly be any diverging reduction sequence here, can it? The type family I is the identity, and the type family B is its alias. There is no recursion. The fact that type families are open is not relevant here: our type families I and B are effectively closed, because one cannot define any more instance for I and B (or risk overlap, which is rightfully not supported for type families). The reason GHC complains is because it checks termination instance-by-instance. To see the termination in the above program, one should consider instances I and B together. Then we will see that I does not refer to B, so there are no loops. But this global termination check -- for a set of instances -- is beyond the abilities of GHC. This is arguably the right decision: after all, GHCi is not a full-blown theorem prover. Thus there are perfectly decidable type programs that require undecidable instances. Indeed, there is no reason to be afraid of that extension. From doaitse at swierstra.net Wed Oct 14 03:34:11 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Wed Oct 14 03:11:27 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> Message-ID: <1A7D4098-2CEB-4C90-80B0-066FFE15559C@swierstra.net> I could not resist this. The code import Text.ParserCombinators.UU.Parsing pCommand [] = pure [] pCommand xxs@(x:xs) = ((:) <$> pSym x <*> pCommand xs) `opt` xxs pCommands = amb . foldr (<|>) pFail . map pCommand $ ["banana", "chocolate", "frito", "fromage"] t :: String -> ([String], [Error Char Char Int]) t input = parse ( (,) <$> pCommands <*> pEnd) (listToStr input) gives the following results: *Main> t "" (["banana","chocolate","frito","fromage"],[]) *Main> t "b" (["banana"],[]) *Main> t "fr" (["frito","fromage"],[]) *Main> t "x" (["banana","chocolate","frito","fromage"],[ The token 'x'was not consumed by the parsing process.]) *Main> t "frox" (["fromage"],[ The token 'x'was not consumed by the parsing process.]) *Main> t "frx" (["frito","fromage"],[ The token 'x'was not consumed by the parsing process.]) *Main> I think it is less clumsy and far less confusing than the Parsec code. Note that the function amb tells that its parameter parser can be ambiguous Doaitse On 13 okt 2009, at 17:10, Uwe Hollerbach wrote: > On 10/12/09, Martijn van Steenbergen > wrote: >> Brandon S. Allbery KF8NH wrote: >>> My fix would be to have myPrefixOf require the prefix be >>> terminated in >>> whatever way is appropriate (end of input, white space, operator?) >>> instead of simply accepting as soon as it gets a prefix match >>> regardless >>> of what follows. >> >> Maybe you can use notFollowedBy for this. >> >> HTH, >> >> Martijn. >> >> > > Yes, I've looked at that and am thinking about it. I'm not quite > certain it's needed in my real program... I seem to have convinced > myself that if I actually specify a proper set of unique prefixes, ie, > set the required lengths for both "frito" and "fromage" to 3 in the > test program, I won't get into this situation. Assuming I haven't > committed another brain-fart there, that would be sufficient; > presumably, in a real program one would want to actually specify the > unique prefix, rather than a non-unique pre-prefix. It seems to work > fine in my real program, anyway. > > Uwe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vandijk.roel at gmail.com Wed Oct 14 05:25:10 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Oct 14 05:02:24 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: <200910131810.09149.dan.doel@gmail.com> References: <600376290910130932s4a269fe2g9d8e8eaf6856e9e8@mail.gmail.com> <200910131810.09149.dan.doel@gmail.com> Message-ID: You can help ghci out a bit with type synonyms: type T a = (a, a) type T2 a = T (T a) type T4 a = T2 (T2 a) type T8 a = T4 (T4 a) type T16 a = T8 (T8 a) f0 :: a -> T a f1 :: a -> T2 a f2 :: a -> T4 a f3 :: a -> T8 a f4 :: a -> T16 a f0 x = (x,x) f1 = f0 . f0 f2 = f1 . f1 f3 = f2 . f2 f4 = f3 . f3 f5 = f4 . f4 With newtypes I can probably abstract even more. (newtype X a b = X (a (a b)) Inferring the type of f5 also stops my machine in its tracks. But I *was* able to infer the type of (f4 . f4). :t (f4 . f4) (f4 . f4) :: a -> T16 (T16 a) :t f5 -- buy new computer Even when you only specify a type for f0 in terms of T you'll get more readable types: :t f3 f3 :: a -> T (T (T (T (T (T (T (T a))))))) But the amount of computation required seems the same. From dan.doel at gmail.com Wed Oct 14 05:53:18 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed Oct 14 05:30:35 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: References: <200910131810.09149.dan.doel@gmail.com> Message-ID: <200910140553.18203.dan.doel@gmail.com> On Wednesday 14 October 2009 5:25:10 am Roel van Dijk wrote: > With newtypes I can probably abstract even more. (newtype X a b = X (a (a > b)) In fact, with GHC extensions, you don't need newtypes: {-# LANGUAGE LiberalTypeSynonyms #-} type T a = (a,a) type X f a = f (f a) f0 :: a -> T a f0 x = (x,x) f1 :: a -> X T a f1 = f0 . f0 f2 :: a -> X (X T) a f2 = f1 . f1 f3 :: a -> X (X (X T)) a f3 = f2 . f2 f4 :: a -> X (X (X (X T))) a f4 = f3 . f3 > Inferring the type of f5 also stops my machine in its tracks. But I > *was* able to infer the type of (f4 . f4). > > :t (f4 . f4) > > (f4 . f4) :: a -> T16 (T16 a) > > :t f5 Yeah. Asking for the type of 'f4 . f4' doesn't seem to expand the synonyms, while checking f5 does for some reason. I'm perplexed that having f5 defined in the file doesn't trigger the explosion unless you declare a type (even in terms of X and T) or ask for its type at the prompt. -- Dan From vandijk.roel at gmail.com Wed Oct 14 06:15:11 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Oct 14 05:52:24 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: <200910140553.18203.dan.doel@gmail.com> References: <200910131810.09149.dan.doel@gmail.com> <200910140553.18203.dan.doel@gmail.com> Message-ID: On Wed, Oct 14, 2009 at 11:53 AM, Dan Doel wrote: > In fact, with GHC extensions, you don't need newtypes: > ?{-# LANGUAGE LiberalTypeSynonyms #-} Ah, I completely forgot about that language extension. Thanks! > Yeah. Asking for the type of 'f4 . f4' doesn't seem to expand the synonyms, > while checking f5 does for some reason. I'm perplexed that having f5 defined > in the file doesn't trigger the explosion unless you declare a type (even in > terms of X and T) or ask for its type at the prompt. If you declare a type for f5 then ghci must check if that type is correct, which triggers the explosion. If you don't declare a type then it won't infer the type until necessary. Basically, ghci is lazy :-) From haskell at gimbo.org.uk Wed Oct 14 07:23:42 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Wed Oct 14 07:01:03 2009 Subject: [Haskell-cafe] ANN: fp-southwales, the South Wales Functional Programming User Group Message-ID: <40C5DDFD-6FA1-4AEE-800F-EA50836E8141@gimbo.org.uk> Dear friends, It is my pleasure to announce the formation of fp-southwales, a user group for anybody interested in functional programming in the area of south Wales, UK. We're based out of Swansea University's Computer Science department, where there are a few of us using Haskell for our research, but we welcome anyone who wants to join in, from academia or industry, from Swansea, or Cardiff, or indeed anywhere in south Wales. As the name of the group also suggests, we're interested in all aspects of functional programming, not just Haskell, although we expect that to be a central topic, for now at least. We exist online as a google group: http://groups.google.com/group/fp-southwales The first point of business is: hello, what shall we do, and when shall we do it? :-) http://groups.google.com/group/fp-southwales/browse_thread/thread/ddb2d352a14896d8 All welcome! -Andy From dan.doel at gmail.com Wed Oct 14 07:45:34 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed Oct 14 07:22:52 2009 Subject: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication) In-Reply-To: References: <200910140553.18203.dan.doel@gmail.com> Message-ID: <200910140745.34667.dan.doel@gmail.com> On Wednesday 14 October 2009 6:15:11 am Roel van Dijk wrote: > If you declare a type for f5 then ghci must check if that type is > correct, which triggers the explosion. If you don't declare a type > then it won't infer the type until necessary. Basically, ghci is lazy Well, that may be the explanation, but it's a bit more convoluted than I'd have initially thought. For instance, if I write: e = head () it fails immediately with a type error, so clearly it must be doing some level of checking immediately. However, it only needs to check 'head' and '()' to notice that they're incompatible, so I suppose it may not need to compute the type of e (were it well-typed). But then, adding: f6 = f5 . f5 produces no more delay than before. Nor does: g = snd . f5 So ghci is able to verify that f5 can be instantiated to the forms a -> b and b -> c in the first case, and that it is of the form a -> (b,c) in the second case, without blowing up. However, either of: e = f5 () e' () = f5 () does blow up, so it must be verifying more than the fact that f5 is of the form a -> b, where a can be instantiated to (), which is odd if it's smart enough to only compute the portion of the type necessary to verify that applications can be well typed. -- Dan From relapse.dev at gmx.com Wed Oct 14 08:59:54 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Wed Oct 14 08:37:42 2009 Subject: [Haskell-cafe] Fuzzy Logic / Linguistic Variables Message-ID: So i was reading "Programming Game AI by Example" by Mat Buckland (http://www.ai-junkie.com/books/toc_pgaibe.html) and decided to rewrite his chapter on Fuzzy logic in haskell (from C++). My initial impression: its one of those scenarios where OOP grossly over complicates things Heres an example taken from the book: An agent needs to decide what weapon to use based on his distance from the target and the amount of ammo each has. The result is in the desirability domain (0-100). http://code.haskell.org/~hexpuem/fuzzyLogic/AI/Logic/Fuzzy/Example.hs An excerpt: ------------------------------------ weapons = [ Weapon "RocketLauncher" 9 rocketLauncher, Weapon "ShotGun" 13 shotgun, Weapon "AssaultRifle" 120 assaultRifle, Weapon "SniperRifle" 7 sniperRifle, Weapon "Knife" 1 knife ] chooseWeapon dist = maximum ratings where ratings = [ (f dist ammo, n) | Weapon n ammo f <- weapons ] ------------------------------------ shotgun :: Double -> Double -> Double shotgun dist ammo = unfuzz desireDom $ rules (fuzz distDom dist) (fuzz ammoDom ammo) where rules :: Fuzzy Distances -> Fuzzy Ammo -> FL Desirability rules distance ammo = do distance `is` SniperSuited =>> Pointless distance `is` Far =>> Undesirable distance `is` Medium =>> Undesirable distance `is` Melee =>> Undesirable (distance `fairly` Near) & (ammo `fairly` High) =>> VeryDesirable (distance `fairly` Near) & (ammo `fairly` Good) =>> Desirable (distance `fairly` Near) & (ammo `is` Low) =>> Undesirable ------------------------------------ Full code at http://code.haskell.org/~hexpuem/fuzzyLogic/. Suggestions welcome - maybe it'd be useful to upload to hackage at some point. It only supports triangle, shoulder, and singleton memberships at the moment. From haskell at kudling.de Wed Oct 14 09:24:30 2009 From: haskell at kudling.de (haskell@kudling.de) Date: Wed Oct 14 09:01:59 2009 Subject: [Haskell-cafe] Reverse dependencies in Hackage Message-ID: <1573037986.31424.1255526670875.JavaMail.open-xchange@oxltgw01.schlund.de> Nice, thank you for the great work. Browsing the reverse dependencies of popular packages like "bytestring" http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/bytestring-0.9.1.5 can be improved a bit. 1) Can you please sort the reverse dependent package names? That makes it easier to find packages with certain names. 2) I found the columns "Direct" and "Indirect" confusing until i found out that they show the number of reverse dependencies for those packages themselves and are not related to direct/indirect dependencies of the current package. I don't think it is necessary to provide those data here and i would be in favor of reducing the information overload by leaving those data to each package detail page. 3) Can you try to print the reverse packages horizontally instead of vertically in tables? Browsing two long tables of direct/indirect reverse dpependencies like for "bytestring" makes it tedious to get an overview. Besides that, i am quite happy. Thanks, Lenny -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091014/71560a46/attachment.html From vandijk.roel at gmail.com Wed Oct 14 09:59:32 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Oct 14 09:36:47 2009 Subject: [Haskell-cafe] Re: Reverse dependencies in Hackage In-Reply-To: <1573037986.31424.1255526670875.JavaMail.open-xchange@oxltgw01.schlund.de> References: <1573037986.31424.1255526670875.JavaMail.open-xchange@oxltgw01.schlund.de> Message-ID: On Wed, Oct 14, 2009 at 3:24 PM, haskell@kudling.de wrote: > Nice, thank you for the great work. > > Browsing the reverse dependencies of popular packages like "bytestring" > http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/bytestring-0.9.1.5 > can be improved a bit. You should try "base" ;-) > 1) Can you please sort the reverse dependent package names? That makes it > easier to find packages with certain names. > > 2) I found the columns "Direct" and "Indirect" confusing until i found out > that they show the number of reverse dependencies for those packages > themselves and are not related to direct/indirect dependencies of the > current package. I don't think it is necessary to provide those data here > and i would be in favor of reducing the information overload by leaving > those data to each package detail page. I'll respond to 1 and 2 since they are related. Right now the packages are sorted by their "total" reverse-dependency count. The idea is that this gives an idea of the relative "importance" of a package (in the closed system of the hackage packet database). However, sorting by name makes just as much sense. Sorting by reverse-dependency count is useful if you want to know which are the most important reverse dependencies. Sorting by name is useful if you want to find out if a specific package is a reverse dependency. Ideally I would like to support both. Maybe a bit of JavaScript could be used to sort the table client-side. Something like this: http://www.kryogenix.org/code/browser/sorttable/ > 3) Can you try to print the reverse packages horizontally instead of > vertically in tables? Browsing two long tables of direct/indirect reverse > dpependencies like for "bytestring" makes it tedious to get an overview. That would make sense if I wouldn't also show the reverse-dependencies of the reverse-dependencies. But I still think that information is usefull. Another option would be to have the two tables side-by-side. But that might be a bit to much for a modestly sized monitor. Again, I wonder what could be achieved with a little JavaScript in this area. Thank you for the constructive criticism, Roel From Christian.Maeder at dfki.de Wed Oct 14 10:09:39 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Oct 14 09:46:58 2009 Subject: [Haskell-cafe] Re: Parsec bug, or...? In-Reply-To: <4AD41F22.7080705@van.steenbergen.nl> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> Message-ID: <4AD5DBA3.6030009@dfki.de> My fix would be to parse as many letters as possible "many1 alpha" (that's longest match) and then check the result with "isPrefixOf" for all your alternatives (and return the alternative that matches first). Cheers Christian Martijn van Steenbergen wrote: > Brandon S. Allbery KF8NH wrote: >> My fix would be to have myPrefixOf require the prefix be terminated in >> whatever way is appropriate (end of input, white space, operator?) >> instead of simply accepting as soon as it gets a prefix match >> regardless of what follows. > > Maybe you can use notFollowedBy for this. > > HTH, > > Martijn. From shahn at cs.tu-berlin.de Wed Oct 14 10:14:00 2009 From: shahn at cs.tu-berlin.de (=?utf-8?q?S=C3=B6nke_Hahn?=) Date: Wed Oct 14 09:51:09 2009 Subject: [Haskell-cafe] Setting environment variables on Windows In-Reply-To: <1255108041.28525.6760.camel@localhost> References: <200910091737.16956.shahn@cs.tu-berlin.de> <1255108041.28525.6760.camel@localhost> Message-ID: <200910141614.00494.shahn@cs.tu-berlin.de> On Friday 09 October 2009 07:07:21 pm Duncan Coutts wrote: > On Fri, 2009-10-09 at 17:37 +0200, S?nke Hahn wrote: > > Hi! > > > > I need to set an environment variable from Haskell and i would like to do > > that cross-platform. There is System.Posix.Env.setEnv, which does > > exactly, what i want on Linux. There is the module System.Environment, > > which seems to be cross-platform, but it does not contain functions to > > manipulate the environment (, just to inspect it). At first glance, I > > didn't find anything relevant in the sub-modules of System.Win32. > > Note that often it is enough to set environment variables for the > programs that you invoke, rather than for your own process. If that's > enough then you can do it via the System.Process.createProcess action. > > Duncan > Thanks for the suggestion. In my case, that would be a workaround. Maybe still better than writing a .bat-file for the same purpose. S?nke From shahn at cs.tu-berlin.de Wed Oct 14 10:50:56 2009 From: shahn at cs.tu-berlin.de (=?iso-8859-15?q?S=F6nke_Hahn?=) Date: Wed Oct 14 10:28:07 2009 Subject: [Haskell-cafe] Setting environment variables on Windows In-Reply-To: References: <200910091737.16956.shahn@cs.tu-berlin.de> Message-ID: <200910141650.56861.shahn@cs.tu-berlin.de> On Friday 09 October 2009 07:19:30 pm Peter Verswyvelen wrote: > Mmm, that seems like a shortcoming. > > Well, you could just wrap the C functions yourself, like this (two > possibilities, no error checking yet, quick hack): > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10565#a10565 > > Note that using SetEnvironmentVariable does not seem to be compatible with > getEnv, but calling _putenv does work. Both solutions seem to work on my system. Using c_putenv doesn't require linking additional libraries in my case, so i'm going with that. You've been very helpful, thank you very much. > > So I guess someone should add this setEnv wrapper to the System.Environment > module? Ticket? Once i figure out, how to implement functions differently for linux and windows, i'll write a ticket with an example module based on your suggestion. Again, many thanks, S?nke > > On Fri, Oct 9, 2009 at 5:37 PM, S?nke Hahn wrote: > > Hi! > > > > I need to set an environment variable from Haskell and i would like to do > > that > > > cross-platform. There is System.Posix.Env.setEnv, which does exactly, > > what > > i > > > want on Linux. There is the module System.Environment, which seems to be > > cross-platform, but it does not contain functions to manipulate the > > environment (, just to inspect it). At first glance, I didn't find > > anything > > > relevant in the sub-modules of System.Win32. > > > > Is this just not implemented? How could i implement it myself? > > > > Grateful for any comment, > > > > S?nke > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mpm at alumni.caltech.edu Wed Oct 14 13:44:03 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Oct 14 13:21:28 2009 Subject: [Haskell-cafe] example of PortMidi use Message-ID: <4AD60DE3.3000501@alumni.caltech.edu> Can someone give me an example of Sound.PortMidi use? I'm having trouble. This program has bugs---makes sound only intermittently, and seems to have set up some kind of loop that is sending midi messages continuously even after terminating the program: import Sound.PortMidi import Foreign.C msgs = [ (0::CULong,PMMsg 0x9c 0x40 0x40) , (500, PMMsg 0x8c 0x40 0x40) , (1000, PMMsg 0x9c 0x41 0x40) , (1500, PMMsg 0x8c 0x41 0x40) ] main = do let deviceId = 12 initialize >>= print getDeviceInfo deviceId >>= print startTime <- time let evts = map (\(t,msg) -> PMEvent msg (t+startTime)) msgs result <- openOutput deviceId 10 case result of Right err -> putStrLn ("After open: " ++ show err) Left stream -> do result <- writeEvents stream evts putStrLn ("After write: " ++ show result) close stream return () terminate >>= print From andrewcoppin at btinternet.com Wed Oct 14 14:28:45 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Oct 14 14:05:50 2009 Subject: [Haskell-cafe] GHC devs Message-ID: <4AD6185D.3050105@btinternet.com> Random question of the day: How many developers are working on GHC? I had always *assumed* that there was something like a hundred core developers, with a much larger number of people casually testing and occasionally submitting the odd patch or two. However, I watched a video of a talk the other day (no, I don't remember which one) and it made me reconsider this view. Somebody muttered something like "GHC is really too big now for just 3 developers to manage", which makes it sound as if there are only 3 active developers... Surely that can't be correct. (There would never be any releases, for one thing...) Does anybody know anything concrete about this? From martijn at van.steenbergen.nl Wed Oct 14 14:35:06 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Oct 14 14:12:23 2009 Subject: [Haskell-cafe] Monotype error Message-ID: <4AD619DA.4020000@van.steenbergen.nl> Dear caf?, > {-# LANGUAGE Rank2Types #-} > {-# LANGUAGE ImpredicativeTypes #-} > > type Void = forall a. a > > newtype Mono a = Mono { runMono :: [Void] } > > beep :: Mono a -> Mono a > beep (Mono vs) = Mono (map undefined vs) Compiling this with GHC results in: > Monotype.hs:9:28: > Cannot match a monotype with `Void' > Expected type: Void > Inferred type: a What does this error mean and why does the code not compile? Thanks! Martijn. From vandijk.roel at gmail.com Wed Oct 14 14:35:45 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Oct 14 14:12:58 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4AD6185D.3050105@btinternet.com> References: <4AD6185D.3050105@btinternet.com> Message-ID: I think the contributors page on GHC's wiki contains relevant information: http://hackage.haskell.org/trac/ghc/wiki/Contributors From bulat.ziganshin at gmail.com Wed Oct 14 14:43:09 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 14 14:20:30 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4AD6185D.3050105@btinternet.com> References: <4AD6185D.3050105@btinternet.com> Message-ID: <715818608.20091014224309@gmail.com> Hello Andrew, Wednesday, October 14, 2009, 10:28:45 PM, you wrote: > I had always *assumed* that there was something like a hundred core > developers only 10 and only in binary system :))) Simon Peyton-Jones works on "front-end", i.e compiling Haskell down to simple core language, and Simon Marlow does "back-end" i.e. compiling this to actual machine code and dealing with idiosyncrasies of all target systems. and Ian Lynagh is "Build engineer" maintaining releases, bug tracking and so on there are dozens of people doing interesting things with GHC and some of them are even going to main tree. and there are interns that implements some rather small and isolated parts of GHC. and dozen or so of people porting GHC to their environment, building packages and so on -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From martin.sulzmann.haskell at googlemail.com Wed Oct 14 14:49:14 2009 From: martin.sulzmann.haskell at googlemail.com (Martin Sulzmann) Date: Wed Oct 14 14:26:27 2009 Subject: [Haskell-cafe] Re: In-Reply-To: <20091014053356.9C7621774B@Adric.metnet.navy.mil> References: <20091014053356.9C7621774B@Adric.metnet.navy.mil> Message-ID: <4bb51c60910141149q46e1dd9cl1b080edfdf4a8857@mail.gmail.com> On Wed, Oct 14, 2009 at 7:33 AM, wrote: > > Martin Sulzmann wrote: > > "Undecidable" instances means that there exists a program for which > there's > > an infinite reduction sequence. > > I believe this may be too strong of a statement. There exists patently > terminating type families that still require undecidable > instances in GHC. Sorry, I wasn't precise enough. I didn't mean to say that *every* program which requires "undecidable" instance won't terminate. Rather, take any of the properties which imply decidability. Then, there *exists* a program which satisfies the negated property and this program won't terminate. As you show, for specific cases we can argue that "undecidable" instances are decidable. You can even argue that the Add/Mult example is decidable, assuming we never generate loopy type constraints. -Martin > Here is an example: > > > {-# LANGUAGE TypeFamilies #-} > > > > type family I x :: * > > type instance I x = x > > > > type family B x :: * > > type instance B x = I x > > > GHC 6.8.3 complaints: > Application is no smaller than the instance head > in the type family application: I x > (Use -fallow-undecidable-instances to permit this) > In the type synonym instance declaration for `B' > > But there cannot possibly be any diverging reduction sequence here, can it? > The type family I is the identity, and the type family B is its > alias. There is no recursion. The fact that type families are open is > not relevant here: our type families I and B are effectively closed, > because one cannot define any more instance for I and B (or risk > overlap, which is rightfully not supported for type families). > > The reason GHC complains is because it checks termination > instance-by-instance. To see the termination in the above program, one > should consider instances I and B together. Then we will see that I > does not refer to B, so there are no loops. But this global > termination check -- for a set of instances -- is beyond the > abilities of GHC. This is arguably the right decision: after all, GHCi > is not a full-blown theorem prover. > > Thus there are perfectly decidable type programs that require > undecidable instances. Indeed, there is no reason to be afraid of that > extension. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091014/4088d9bc/attachment.html From lemming at henning-thielemann.de Wed Oct 14 15:04:28 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Oct 14 14:41:26 2009 Subject: [Haskell-cafe] example of PortMidi use In-Reply-To: <4AD60DE3.3000501@alumni.caltech.edu> References: <4AD60DE3.3000501@alumni.caltech.edu> Message-ID: On Wed, 14 Oct 2009, Michael Mossey wrote: > Can someone give me an example of Sound.PortMidi use? I'm having trouble. > This program has bugs---makes sound only intermittently, and seems to have > set up some kind of loop that is sending midi messages continuously even > after terminating the program: You may also try http://lists.lurk.org/mailman/listinfo/haskell-art (haskell-art@lists.lurk.org). From dons at galois.com Wed Oct 14 15:25:55 2009 From: dons at galois.com (Don Stewart) Date: Wed Oct 14 15:04:22 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <715818608.20091014224309@gmail.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> Message-ID: <20091014192555.GA13298@whirlpool.galois.com> bulat.ziganshin: > Hello Andrew, > > Wednesday, October 14, 2009, 10:28:45 PM, you wrote: > > > I had always *assumed* that there was something like a hundred core > > developers > > only 10 and only in binary system :))) > > Simon Peyton-Jones works on "front-end", i.e compiling Haskell down to > simple core language, and Simon Marlow does "back-end" i.e. compiling > this to actual machine code and dealing with idiosyncrasies of all > target systems. and Ian Lynagh is "Build engineer" maintaining > releases, bug tracking and so on > > there are dozens of people doing interesting things with GHC and some > of them are even going to main tree. and there are interns that > implements some rather small and isolated parts of GHC. and dozen or > so of people porting GHC to their environment, building packages and > so on > About 1000 people have worked on libraries on Hackage. That's about two orders of magnitude more than work on GHC. From tphyahoo at gmail.com Wed Oct 14 16:21:46 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Oct 14 15:59:05 2009 Subject: [Haskell-cafe] Why does replicateM (10^6) $ return 0 produce output in the IO monad, but overflow the maybe monad? Message-ID: <910ddf450910141321y1560f649o40acc539b624a6a7@mail.gmail.com> -- Why does replicateM (10^6) $ return 0 produce output in the IO monad, but overflow the maybe monad? iterateNTimes i f x = foldr (.) id (replicate i f) $ x tntIO :: IO Int -- same as replicateM (10^6) $ return 0, same as sequence . replicate (10^6) $ return 0 tntIO = return . head =<< (iterateNTimes (10^6) (mcons . return $ 0) (return [])) -- produces output tntMb :: Maybe Int -- overflows tntMb = return . head =<< (iterateNTimes (10^6) (mcons . return $ 0) (return [])) -- stack overflow -- equivalently: mcons m ms = (:) <$> m <*> ms mcons m ms = ap (liftM (:) m) $ ms I guess the maybe version builds up a huge chain of unevaluated thunks somewhere, that's usually the reason. But specifically where and why, and why doesn't IO do the same thing? Equivalent, with 3 element list: (mcons $ return $ 0 ) $ (mcons $ return $ 0) $ (mcons $ return $ 0) $ (return []) (ap . liftM (:) . return $ 0 ) $ (ap . liftM (:) . return $ 0) $ (ap . liftM (:) . return $ 0) $ (return []) (ap $ liftM (:) $ return $ 0 ) $ (ap $ liftM (:) $ return $ 0) $ (ap $ liftM (:) $ return $ 0) $ (return []) t. From batterseapower at hotmail.com Wed Oct 14 16:28:45 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Wed Oct 14 16:05:57 2009 Subject: [Haskell-cafe] GHC core packages: same core? In-Reply-To: References: <9d4d38820910131353p498c648dr62667ae703c3ab8a@mail.gmail.com> Message-ID: <9d4d38820910141328s22a1f8dcr657b602f36607847@mail.gmail.com> Dimitry, I *believe* ext-core will match that document, but I'm not sure of the exact status. Tim Chevalier has done a lot of great work maintaining the external core stuff and I think he is actively using the extcore library, so *that* should almost certainly match GHC's output. It's great to hear that you are interested in writing an alternative backend! I think LHC is also using ext-core to build a backend, so this seems like a viable approach. All the best, Max 2009/10/13 Dimitry Golubovsky : > Max, > > Thanks for the explanation. So, the extcore library is expected to > match the spec in > http://www.haskell.org/ghc/docs/6.10.4/html/ext-core/core.pdf and the > core itself can be produced with -fext-core, correct? I think it might > be interesting for people working on alternative backends (inlcuding > myself). > > On Tue, Oct 13, 2009 at 4:53 PM, Max Bolingbroke > wrote: > [skip] >> >> extcore is a library that parses "external" Core, which is an >> alternative format intended to be stable and hence a suitable target >> for consumption by non-GHC tooling. You can have GHC output external >> core instead of machine code / C. I don't believe this is widely used >> yet. > > -- > Dimitry Golubovsky > > Anywhere on the Web > > From lemmih at gmail.com Wed Oct 14 16:43:30 2009 From: lemmih at gmail.com (Lemmih) Date: Wed Oct 14 16:20:43 2009 Subject: [Haskell-cafe] GHC core packages: same core? In-Reply-To: <9d4d38820910141328s22a1f8dcr657b602f36607847@mail.gmail.com> References: <9d4d38820910131353p498c648dr62667ae703c3ab8a@mail.gmail.com> <9d4d38820910141328s22a1f8dcr657b602f36607847@mail.gmail.com> Message-ID: On Wed, Oct 14, 2009 at 10:28 PM, Max Bolingbroke wrote: > Dimitry, > > I *believe* ext-core will match that document, but I'm not sure of the > exact status. Tim Chevalier has done a lot of great work maintaining > the external core stuff and I think he is actively using the extcore > library, so *that* should almost certainly match GHC's output. > > It's great to hear that you are interested in writing an alternative > backend! I think LHC is also using ext-core to build a backend, so > this seems like a viable approach. LHC is using a different external core parser. -- Cheers, Lemmih From andrewcoppin at btinternet.com Wed Oct 14 16:54:37 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Oct 14 16:31:43 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <20091014192555.GA13298@whirlpool.galois.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> Message-ID: <4AD63A8D.8010304@btinternet.com> Don Stewart wrote: > bulat.ziganshin: > >> Hello Andrew, >> >> Wednesday, October 14, 2009, 10:28:45 PM, you wrote: >> >> >>> I had always *assumed* that there was something like a hundred core >>> developers >>> >> only 10 and only in binary system :))) >> >> > > About 1000 people have worked on libraries on Hackage. That's about two > orders of magnitude more than work on GHC. > Sure. But libraries are more or less self-contained, generally. GHC is one giant system of closely interacting components, so it (presumably?) takes about two orders of magnitude more cooperation to work on it. ;-) Still, if there are only 10 core people actively working on it... well that explains why the wishlist is always so much longer than the feature list. (Not that GHC doesn't already _have_ some pretty cool features, mind you...) Does anybody actually "get paid" to develop GHC? Or is this all people working on it in their spare time? It would seem like pushing such a huge piece of software forward at anything more than glacial pace would require quite a lot of manpower (which I guess is why I assumed there were a lot of people working on it). For that matter, who pays for the servers which host the code repos and so forth? From bulat.ziganshin at gmail.com Wed Oct 14 17:06:45 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Oct 14 16:44:02 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4AD63A8D.8010304@btinternet.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> Message-ID: <1612471256.20091015010645@gmail.com> Hello Andrew, Thursday, October 15, 2009, 12:54:37 AM, you wrote: > Does anybody actually "get paid" to develop GHC? Or is this all people SPJ, SM and Ian are paid by MS Research. Other people involved in core development are mainly scientists (afaik) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From martijn at van.steenbergen.nl Wed Oct 14 17:16:54 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Oct 14 16:54:06 2009 Subject: [Haskell-cafe] newtype deriving Alternative Message-ID: <4AD63FC6.6000300@van.steenbergen.nl> Hello caf?, I've never written an Alternative instance for a newtype yet that doesn't look like this: > instance Alternative T where > empty = T empty > T x <|> T y = T (x <|> y) Why does newtype deriving not work for Alternative? (It works fine for Monoid.) Thanks, Martijn. From simonkaltenbacher at googlemail.com Wed Oct 14 17:30:05 2009 From: simonkaltenbacher at googlemail.com (SimonK77) Date: Wed Oct 14 17:07:16 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence In-Reply-To: <200910122155.34339.daniel.is.fischer@web.de> References: <25861134.post@talk.nabble.com> <25861177.post@talk.nabble.com> <40a414c20910121209i7667f5dcm4b02f0d34c3ea58d@mail.gmail.com> <200910122155.34339.daniel.is.fischer@web.de> Message-ID: <25899401.post@talk.nabble.com> Hallo Daniel, can you explain the difference between a "pattern binding" and a "function binding"? I haven't heard about these two terms so far. And furthermore: Why does the memoization only happen with pattern binding? Best regards, Simon -- View this message in context: http://www.nabble.com/Sharing-Subexpressions%3A-Memoization-of-Fibonacci-sequence-tp25861134p25899401.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From roma at ro-che.info Wed Oct 14 18:07:48 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed Oct 14 17:44:18 2009 Subject: [Haskell-cafe] Monotype error In-Reply-To: <4AD619DA.4020000@van.steenbergen.nl> References: <4AD619DA.4020000@van.steenbergen.nl> Message-ID: <20091014220748.GA9240@flit> * Martijn van Steenbergen [2009-10-14 20:35:06+0200] > Dear caf?, > >> {-# LANGUAGE Rank2Types #-} >> {-# LANGUAGE ImpredicativeTypes #-} >> >> type Void = forall a. a >> >> newtype Mono a = Mono { runMono :: [Void] } >> >> beep :: Mono a -> Mono a >> beep (Mono vs) = Mono (map undefined vs) > > Compiling this with GHC results in: > >> Monotype.hs:9:28: >> Cannot match a monotype with `Void' >> Expected type: Void >> Inferred type: a > > What does this error mean and why does the code not compile? It works if you annotate the type of undefined: beep (Mono vs) = Mono (map (undefined :: Void -> Void) vs) -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From ryani.spam at gmail.com Wed Oct 14 18:12:27 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Oct 14 17:49:39 2009 Subject: [Haskell-cafe] newtype deriving Alternative In-Reply-To: <4AD63FC6.6000300@van.steenbergen.nl> References: <4AD63FC6.6000300@van.steenbergen.nl> Message-ID: <2f9b2d30910141512v58c6c3e3s36c8fe0c60dc5875@mail.gmail.com> Works for me on GHC6.10.4: {-# LANGUAGE GeneralizedNewtypeDeriving #-} module NewtypeDerive where import Control.Applicative newtype Foo f a = Foo (f a) deriving (Functor, Applicative, Alternative) newtype Bar a = Bar [a] deriving (Functor, Applicative, Alternative) -- ryan On Wed, Oct 14, 2009 at 2:16 PM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > Hello caf?, > > I've never written an Alternative instance for a newtype yet that doesn't > look like this: > > instance Alternative T where >> empty = T empty >> T x <|> T y = T (x <|> y) >> > > Why does newtype deriving not work for Alternative? (It works fine for > Monoid.) > > Thanks, > > Martijn. > _______________________________________________ > 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/20091014/3a798730/attachment.html From martijn at van.steenbergen.nl Wed Oct 14 18:18:07 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Oct 14 17:55:27 2009 Subject: [Haskell-cafe] newtype deriving Alternative In-Reply-To: <2f9b2d30910141512v58c6c3e3s36c8fe0c60dc5875@mail.gmail.com> References: <4AD63FC6.6000300@van.steenbergen.nl> <2f9b2d30910141512v58c6c3e3s36c8fe0c60dc5875@mail.gmail.com> Message-ID: <4AD64E1F.7040001@van.steenbergen.nl> You guys are right. I was being silly. Thanks. :-) Ryan Ingram wrote: > Works for me on GHC6.10.4: From shahn at cs.tu-berlin.de Wed Oct 14 18:41:11 2009 From: shahn at cs.tu-berlin.de (=?iso-8859-15?q?S=F6nke_Hahn?=) Date: Wed Oct 14 18:18:18 2009 Subject: [Haskell-cafe] Setting environment variables on Windows In-Reply-To: <200910141650.56861.shahn@cs.tu-berlin.de> References: <200910091737.16956.shahn@cs.tu-berlin.de> <200910141650.56861.shahn@cs.tu-berlin.de> Message-ID: <200910150041.12103.shahn@cs.tu-berlin.de> On Wednesday 14 October 2009 04:50:56 pm S?nke Hahn wrote: > On Friday 09 October 2009 07:19:30 pm Peter Verswyvelen wrote: > > Mmm, that seems like a shortcoming. > > > > Well, you could just wrap the C functions yourself, like this (two > > possibilities, no error checking yet, quick hack): > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10565#a10565 > > > > Note that using SetEnvironmentVariable does not seem to be compatible > > with getEnv, but calling _putenv does work. > > Both solutions seem to work on my system. Using c_putenv doesn't require > linking additional libraries in my case, so i'm going with that. You've > been very helpful, thank you very much. > > > So I guess someone should add this setEnv wrapper to the > > System.Environment module? Ticket? > > Once i figure out, how to implement functions differently for linux and > windows, i'll write a ticket with an example module based on your > suggestion. Here's the ticket: http://hackage.haskell.org/trac/ghc/ticket/3587 > > Again, many thanks, > > S?nke > > > On Fri, Oct 9, 2009 at 5:37 PM, S?nke Hahn wrote: > > > Hi! > > > > > > I need to set an environment variable from Haskell and i would like to > > > do > > > > that > > > > > cross-platform. There is System.Posix.Env.setEnv, which does exactly, > > > what > > > > i > > > > > want on Linux. There is the module System.Environment, which seems to > > > be cross-platform, but it does not contain functions to manipulate the > > > environment (, just to inspect it). At first glance, I didn't find > > > > anything > > > > > relevant in the sub-modules of System.Win32. > > > > > > Is this just not implemented? How could i implement it myself? > > > > > > Grateful for any comment, > > > > > > S?nke > > > _______________________________________________ > > > 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 martijn at van.steenbergen.nl Wed Oct 14 18:45:07 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Oct 14 18:22:18 2009 Subject: [Haskell-cafe] newtype deriving Alternative In-Reply-To: <2f9b2d30910141512v58c6c3e3s36c8fe0c60dc5875@mail.gmail.com> References: <4AD63FC6.6000300@van.steenbergen.nl> <2f9b2d30910141512v58c6c3e3s36c8fe0c60dc5875@mail.gmail.com> Message-ID: <4AD65473.9020208@van.steenbergen.nl> It doesn't work for this one: > newtype Split a = Split { runSplit :: [Either a (Char, Split a) ]} But my handwritten instance remains identical. Groetjes, Martijn. From daniel.is.fischer at web.de Wed Oct 14 19:41:10 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 14 19:21:05 2009 Subject: [Haskell-cafe] Sharing Subexpressions: Memoization of Fibonacci sequence In-Reply-To: <25899401.post@talk.nabble.com> References: <25861134.post@talk.nabble.com> <200910122155.34339.daniel.is.fischer@web.de> <25899401.post@talk.nabble.com> Message-ID: <200910150141.11438.daniel.is.fischer@web.de> Am Mittwoch 14 Oktober 2009 23:30:05 schrieb SimonK77: > Hallo Daniel, > > can you explain the difference between a "pattern binding" and a "function > binding"? I haven't heard about these two terms so far. The formal specification is at http://haskell.org/onlinereport/decls.html#sect4.4.3 A function binding is a binding where the function name and at least one parameter (pattern) appear to the left of '=', while in a pattern binding only bound patterns appear on the left. -- function bindings fun x = expression -- binds fun x \/ y = expr' -- binds (\/) -- pattern bindings func = \x -> expression -- binds func var = expr -- binds var (v1,v2) = express -- binds v1 and v2 (a0:a1:tl) -- binds a0, a1 and tl | even v1 = exp1 | otherwise = exp2 The first three are *simple* pattern bindings. > And furthermore: > Why does the memoization only happen with pattern binding? I don't know all the details either, but the point is that names bound by a (simple) pattern binding are "constant applicative forms" (http://www.haskell.org/haskellwiki/CAF) which can be shared by all uses (if they have a monomorphic type, cf. also http://www.haskell.org/haskellwiki/Monomorphism_Restriction and http://haskell.org/onlinereport/decls.html#sect4.5.5), while names bound by a function binding aren't shared across computations (I think it is generally undecidable how much could be shared and anyway it would be too complicated for the compiler to investigate that - too little gain for too much effort). So with function-bound fbfib :: Int -> Integer fbfib k = let fib 0 = 0 fib 1 = 1 fib n = fbfib (n-2) + fbfib (n-1) in (map fib [0 ..] !! k) fb2fib :: Int -> Integer fb2fib k = let fib 0 = 0 fib 1 = 1 fib n = fb2fib (n-2) + fb2fib (n-1) flst = map fib [0 .. ] in (flst !! k) nothing is shared, each (recursive) call to fb(2)fib creates a new list of Fibonacci values (in principle, different arguments could require very different code-paths, so we don't even bother to let the compiler look for the few cases where it could determine sharing would be beneficial). With pattern-bound functions, it's harder to know when sharing will happen. It depends on the form of the RHS and where things that might be shared are bound. In memoized_fib :: Int -> Integer memoized_fib = let fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1) in (map fib [0 ..] !!) the list of Fibonacci numbers is shared, even though it hasn't been given a name (In general, give entities you want to be shared a name of their own to increase the chance of them being really shared). If you define the function with a simple pattern binding which has a lambda-expression on the right hand side, it depends on whether things are bound within the lambda-scope or outside. In plfib :: Int -> Integer plfib = \k -> let fib 0 = 0 fib 1 = 1 fib n = plfib (n-2) + plfib (n-1) in (map fib [0 ..] !! k) the things which could be shared are bound inside the lambda-expression, therefore they aren't shared (they could potentially depend on the lambda-bound variable[s], here k). Lifting the binding of fib outside the lambda pblfib :: Int -> Integer pblfib = let fib 0 = 0 fib 1 = 1 fib n = pblfib (n-2) + pblfib (n-1) in \k -> (map fib [0 ..] !! k) doesn't help - of course, the list in which we index is still inside the lambda. Give it a name and hoist it outside the lambda: peblfib :: Int -> Integer peblfib = let fib 0 = 0 fib 1 = 1 fib n = peblfib (n-2) + peblfib (n-1) flst = map fib [0 .. ] in \k -> (flst !! k) Now flst is a CAF which can be shared, and indeed it is: *MFib> peblfib 40 102334155 (0.00 secs, 0 bytes) > > Best regards, > > Simon Hope this gets you started, Daniel From fernandohsanches at gmail.com Wed Oct 14 23:07:07 2009 From: fernandohsanches at gmail.com (Fernando Henrique Sanches) Date: Wed Oct 14 22:44:21 2009 Subject: [Haskell-cafe] Fuzzy Logic / Linguistic Variables In-Reply-To: References: Message-ID: <174c72ef0910142007j73eb7417ne7dbd87d009693f7@mail.gmail.com> I didn't read the book, but your code seems very elegant, more than I even thought possible. I've never programmed with fuzzy logic before, but I can understand your code - it reads naturally. Fernando Henrique Sanches On Wed, Oct 14, 2009 at 9:59 AM, Neal Alexander wrote: > So i was reading "Programming Game AI by Example" by Mat Buckland ( > http://www.ai-junkie.com/books/toc_pgaibe.html) and decided to rewrite his > chapter on Fuzzy logic in haskell (from C++). > > My initial impression: its one of those scenarios where OOP grossly over > complicates things > > > Heres an example taken from the book: An agent needs to decide what weapon > to use based on his distance from the target and the amount of ammo each > has. The result is in the desirability domain (0-100). > > http://code.haskell.org/~hexpuem/fuzzyLogic/AI/Logic/Fuzzy/Example.hs > > An excerpt: > > > ------------------------------------ > > weapons = [ Weapon "RocketLauncher" 9 rocketLauncher, > Weapon "ShotGun" 13 shotgun, > Weapon "AssaultRifle" 120 assaultRifle, > Weapon "SniperRifle" 7 sniperRifle, > Weapon "Knife" 1 knife ] > > chooseWeapon dist = maximum ratings > where > ratings = [ (f dist ammo, n) | Weapon n ammo f <- weapons ] > > ------------------------------------ > > shotgun :: Double -> Double -> Double > shotgun dist ammo = > > unfuzz desireDom $ rules (fuzz distDom dist) (fuzz ammoDom ammo) > > where > > rules :: Fuzzy Distances -> Fuzzy Ammo -> FL Desirability > rules distance ammo = do > > distance `is` SniperSuited =>> Pointless > distance `is` Far =>> Undesirable > distance `is` Medium =>> Undesirable > distance `is` Melee =>> Undesirable > > (distance `fairly` Near) & (ammo `fairly` High) =>> VeryDesirable > (distance `fairly` Near) & (ammo `fairly` Good) =>> Desirable > (distance `fairly` Near) & (ammo `is` Low) =>> Undesirable > > ------------------------------------ > > Full code at http://code.haskell.org/~hexpuem/fuzzyLogic/ > . > > Suggestions welcome - maybe it'd be useful to upload to hackage at some > point. > > > It only supports triangle, shoulder, and singleton memberships at the > moment. > > > > _______________________________________________ > 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/20091014/939c4aa4/attachment.html From dons at galois.com Wed Oct 14 23:24:53 2009 From: dons at galois.com (Don Stewart) Date: Wed Oct 14 23:02:10 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <1612471256.20091015010645@gmail.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> Message-ID: <20091015032453.GA15031@whirlpool.galois.com> bulat.ziganshin: > Hello Andrew, > > Thursday, October 15, 2009, 12:54:37 AM, you wrote: > > > Does anybody actually "get paid" to develop GHC? Or is this all people > > SPJ, SM and Ian are paid by MS Research. Other people involved in core > development are mainly scientists (afaik) Besides MSR and the university groups, the IHG funds Well-Typed to do development, as well. From jake.mcarthur at gmail.com Thu Oct 15 00:08:11 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Wed Oct 14 23:45:24 2009 Subject: [Haskell-cafe] newtype deriving Alternative In-Reply-To: <4AD65473.9020208@van.steenbergen.nl> References: <4AD63FC6.6000300@van.steenbergen.nl> <2f9b2d30910141512v58c6c3e3s36c8fe0c60dc5875@mail.gmail.com> <4AD65473.9020208@van.steenbergen.nl> Message-ID: <4AD6A02B.2090406@gmail.com> Martijn van Steenbergen wrote: > It doesn't work for this one: > >> newtype Split a = Split { runSplit :: [Either a (Char, Split a) ]} > > But my handwritten instance remains identical. The instance has the form [], not the form [Either _ (Char, Split _)]. Since they don't match exactly, it won't give you an instance automagically. It could have been the case that you intended some other instance besides []'s. All generalized newtype deriving does is derive instances for newtypes that wrap exactly what the instance is defined over. - Jake From wren at freegeek.org Thu Oct 15 02:11:57 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Oct 15 01:49:10 2009 Subject: [Haskell-cafe] (no subject) In-Reply-To: <4A90CA71.5050004@gmail.com> References: <40EBDEED77D2DE44B91E9AFCC63142C8018498EE@uu01msg-exb02.soliscom.uu.nl> <20090821224221.GE15454@whirlpool.galois.com> <25088830.post@talk.nabble.com> <25094244.post@talk.nabble.com> <4A90CA71.5050004@gmail.com> Message-ID: <4AD6BD2D.2060204@freegeek.org> Jake McArthur wrote: > staafmeister wrote: >> Yes I know but there are a lot of problems requiring O(1) array updates >> so then you are stuck with IO again > > Or use ST. Or use IntMap (which is O(log n), but n is going to max out > on the integer size for your architecture, so it's really just O(32) or > O(64), which is really just constant time). Actually, IntMap is O(min(n,W)) where W is the number of bits in an Int. Yes, IntMaps are linear time in the worst case (until they become constant-time). In practice this is competitive with all those O(log n) structures though. Whereas Data.Map is O(log n) for the usual balanced tree approach. -- Live well, ~wren From ekirpichov at gmail.com Thu Oct 15 02:15:46 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Oct 15 01:52:56 2009 Subject: [Haskell-cafe] (no subject) In-Reply-To: <4AD6BD2D.2060204@freegeek.org> References: <40EBDEED77D2DE44B91E9AFCC63142C8018498EE@uu01msg-exb02.soliscom.uu.nl> <20090821224221.GE15454@whirlpool.galois.com> <25088830.post@talk.nabble.com> <25094244.post@talk.nabble.com> <4A90CA71.5050004@gmail.com> <4AD6BD2D.2060204@freegeek.org> Message-ID: <5e0214850910142315q60f425bdo4f20a6cffe7d4d18@mail.gmail.com> There are also the judy arrays http://hackage.haskell.org/package/HsJudy http://hackage.haskell.org/package/judy dons recently advertised the latter as being 2x faster than IntMap, but I don't know in what respect these two packages differ and why Don decided to create 'judy' despite the existence of HsJudy. 2009/10/15 wren ng thornton : > Jake McArthur wrote: >> >> staafmeister wrote: >>> >>> Yes I know but there are a lot of problems requiring O(1) array updates >>> so then you are stuck with IO again >> >> Or use ST. Or use IntMap (which is O(log n), but n is going to max out on >> the integer size for your architecture, so it's really just O(32) or O(64), >> which is really just constant time). > > Actually, IntMap is O(min(n,W)) where W is the number of bits in an Int. > Yes, IntMaps are linear time in the worst case (until they become > constant-time). In practice this is competitive with all those O(log n) > structures though. > > Whereas Data.Map is O(log n) for the usual balanced tree approach. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From wren at freegeek.org Thu Oct 15 03:06:33 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Oct 15 02:43:48 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <443DADF4-0A7A-4CCF-BFA6-86B770E0B26E@gmail.com> References: <25860155.post@talk.nabble.com> <625b74080910121100w5dd4217cm20e4b96569aa9664@mail.gmail.com> <4477A7C4-7495-4F84-863F-3D8D02E89A9F@gmail.com> <20091013004115.GB21234@seas.upenn.edu> <443DADF4-0A7A-4CCF-BFA6-86B770E0B26E@gmail.com> Message-ID: <4AD6C9F9.6060305@freegeek.org> Joe Fredette wrote: > I fiddled with my previous idea -- the NatTrans class -- a bit, the results > are here[1], I don't know enough really to know if I got the NT law > right, or > even if the class defn is right. > > Any thoughts? Am I doing this right/wrong/inbetween? Is there any use > for a class > like this? I listed a couple ideas of use-cases in the paste, but I have > no idea of > the applicability of either of them. > > /Joe > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10679#a10679 A few problems there: (1) The |a| should be natural, i.e. universally qualified in the class methods, not an argument of the typeclass. (2) Just because there's a natural transformation from F to G does not mean there's a "related" natural transformation back. The law you want is, forall (X :: *) (Y :: *) (f :: X -> Y). eta_Y . fmap_F f == fmap_G f . eta_X (3) There can be more than one natural transformation between two functors. Which means a type class is the wrong way to go about things since there can only be one for the set of type parameters. Consider for instance: type F a = [a] type G a = [a] identity :: F a -> G a identity [] = [] identity (x:xs) = (x:xs) reverse :: F a -> G a reverse = go [] where go ys [] = ys go ys (x:xs) = go (x:ys) xs nil :: F a -> G a nil = const [] ... -- Live well, ~wren From dav.vire+haskell at gmail.com Thu Oct 15 03:17:15 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Thu Oct 15 02:54:27 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <1612471256.20091015010645@gmail.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> Message-ID: <4c88418c0910150017h79738127oe2840703286d6d0d@mail.gmail.com> On Wed, Oct 14, 2009 at 11:06 PM, Bulat Ziganshin wrote: > Hello Andrew, > > Thursday, October 15, 2009, 12:54:37 AM, you wrote: > >> Does anybody actually "get paid" to develop GHC? Or is this all people > > SPJ, SM and Ian are paid by MS Research. Other people involved in core > development are mainly scientists (afaik) Taking the opportunity to thank very much both Simons and Ian for the work they do and the enthusiasm they show. You guys rock. From wren at freegeek.org Thu Oct 15 03:30:27 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Oct 15 03:07:41 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> Message-ID: <4AD6CF93.2060107@freegeek.org> Uwe Hollerbach wrote: > Yes, I've looked at that and am thinking about it. I'm not quite > certain it's needed in my real program... I seem to have convinced > myself that if I actually specify a proper set of unique prefixes, ie, > set the required lengths for both "frito" and "fromage" to 3 in the > test program, I won't get into this situation. Assuming I haven't > committed another brain-fart there, that would be sufficient; > presumably, in a real program one would want to actually specify the > unique prefix, rather than a non-unique pre-prefix. It seems to work > fine in my real program, anyway. Another approach ---assuming you're not wedded to Parsec--- would be to construct a trie, e.g. with bytestring-trie[1]. Then use Data.Trie.submap to look up the query. If the result is unique then you go with it, if not then list the submap's keys in your error message. The big benefit of this approach is that you needn't maintain a list of lengths for disambiguating the keys, the trie does that for you. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie -- Live well, ~wren From simonpj at microsoft.com Thu Oct 15 03:41:48 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Oct 15 03:19:00 2009 Subject: [Haskell-cafe] Monotype error In-Reply-To: <4AD619DA.4020000@van.steenbergen.nl> References: <4AD619DA.4020000@van.steenbergen.nl> Message-ID: <59543203684B2244980D7E4057D5FBC1061B356C@DB3EX14MBXC310.europe.corp.microsoft.com> It's a poor error message, but GHC's entire handling of impredicative polymorphism is poor at the moment. Indeed, I'm seriously considering removing it altogether until we can come up with a more robust story. (So don't rely on it!) The error happens because you are trying to use the type (forall a. a) in a context that requires a monotype (one with no foralls). I have not stared at the typing rules (in our papers) to convince myself that your program does transgress them; indeed, I regard the necessity to do so as evidence that the approach is not robust. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Martijn van Steenbergen | Sent: 14 October 2009 19:35 | To: Haskell Cafe | Subject: [Haskell-cafe] Monotype error | | Dear caf?, | | > {-# LANGUAGE Rank2Types #-} | > {-# LANGUAGE ImpredicativeTypes #-} | > | > type Void = forall a. a | > | > newtype Mono a = Mono { runMono :: [Void] } | > | > beep :: Mono a -> Mono a | > beep (Mono vs) = Mono (map undefined vs) | | Compiling this with GHC results in: | | > Monotype.hs:9:28: | > Cannot match a monotype with `Void' | > Expected type: Void | > Inferred type: a | | What does this error mean and why does the code not compile? | | Thanks! | | Martijn. | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From v.reshetnikov at gmail.com Thu Oct 15 05:07:26 2009 From: v.reshetnikov at gmail.com (Vladimir Reshetnikov) Date: Thu Oct 15 04:44:56 2009 Subject: [Haskell-cafe] Monotype error In-Reply-To: <4AD619DA.4020000@van.steenbergen.nl> References: <4AD619DA.4020000@van.steenbergen.nl> Message-ID: <4770d2590910150207x62f1c342u8db675e6a1138406@mail.gmail.com> See our previous discussion on this topic here: http://www.nabble.com/Fwd:-Unification-for-rank-N-types-td23942179.html Thanks, Vladimir On Wed, Oct 14, 2009 at 10:35 PM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > Dear caf?, > > {-# LANGUAGE Rank2Types #-} >> {-# LANGUAGE ImpredicativeTypes #-} >> >> type Void = forall a. a >> >> newtype Mono a = Mono { runMono :: [Void] } >> >> beep :: Mono a -> Mono a >> beep (Mono vs) = Mono (map undefined vs) >> > > Compiling this with GHC results in: > > Monotype.hs:9:28: >> Cannot match a monotype with `Void' >> Expected type: Void >> Inferred type: a >> > > What does this error mean and why does the code not compile? > > Thanks! > > Martijn. > _______________________________________________ > 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/20091015/ddc3b4f0/attachment.html From greenrd at greenrd.org Thu Oct 15 06:48:26 2009 From: greenrd at greenrd.org (Robin Green) Date: Thu Oct 15 06:25:39 2009 Subject: [Haskell-cafe] (no subject) In-Reply-To: <5e0214850910142315q60f425bdo4f20a6cffe7d4d18@mail.gmail.com> References: <40EBDEED77D2DE44B91E9AFCC63142C8018498EE@uu01msg-exb02.soliscom.uu.nl> <20090821224221.GE15454@whirlpool.galois.com> <25088830.post@talk.nabble.com> <25094244.post@talk.nabble.com> <4A90CA71.5050004@gmail.com> <4AD6BD2D.2060204@freegeek.org> <5e0214850910142315q60f425bdo4f20a6cffe7d4d18@mail.gmail.com> Message-ID: At Thu, 15 Oct 2009 10:15:46 +0400, Eugene Kirpichov wrote: > but I don't know in what respect these two packages differ and why Don > decided to create 'judy' despite the existence of HsJudy. HsJudy doesn't compile against the latest judy library (as Don knew) - presumably he had a good reason to start a new package instead of patching the old one. There should be a way to mark packages as deprecated on hackage, and at the same time direct people to a more suitable alternative. Aside from uploading a dummy new version (ugh!), I don't see a way to do that currently. -- Robin From dougal at dougalstanton.net Thu Oct 15 09:41:42 2009 From: dougal at dougalstanton.net (Dougal Stanton) Date: Thu Oct 15 09:18:55 2009 Subject: [Haskell-cafe] Examples/docs for simulated annealing bindings Message-ID: <2d3641330910150641v4d59c8c9la1b2821a1d1d3939@mail.gmail.com> I found the HsASA library [1] on Hackage, but there's no documentation and it's not particularly intuitive. I can't see any obvious way of choosing initial config or generating new configurations. Google reveals no one using it. Does anyone have ideas? [1]: http://hackage.haskell.org/package/HsASA-0.1 Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From gue.schmidt at web.de Thu Oct 15 09:44:55 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Oct 15 09:22:37 2009 Subject: [Haskell-cafe] Relational Algebra Message-ID: Hi all, has anybody already developed an EDSL for relational algebra? HaskellDB does that, but its current implementation only allows for generating SQL, are there other implementations? G?nther From noteed at gmail.com Thu Oct 15 09:46:13 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 15 09:23:44 2009 Subject: [Haskell-cafe] Examples/docs for simulated annealing bindings In-Reply-To: <2d3641330910150641v4d59c8c9la1b2821a1d1d3939@mail.gmail.com> References: <2d3641330910150641v4d59c8c9la1b2821a1d1d3939@mail.gmail.com> Message-ID: <40a414c20910150646r2b7a6f76na8bf2e9188135ce4@mail.gmail.com> 2009/10/15 Dougal Stanton : > I found the HsASA library [1] on Hackage, but there's no documentation > and it's not particularly intuitive. I can't see any obvious way of > choosing initial config or generating new configurations. Google > reveals no one using it. Does anyone have ideas? > > [1]: http://hackage.haskell.org/package/HsASA-0.1 If the wrapping is not too involved, the original documentation [*] should help... Cheers, Thu [*] http://www.ingber.com/ASA-README.html From vasyl.pasternak at gmail.com Thu Oct 15 10:18:57 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Thu Oct 15 09:56:08 2009 Subject: [Haskell-cafe] ANNOUNCE: hs-ffmpeg 0.3.2 - Bindings to FFMpeg library Message-ID: <8feb08f70910150718r6706750bo3116182d464638c0@mail.gmail.com> Hello, I am glad to announce next release of hs-ffmpeg library. Now you could download it from the Hackage along with the ffmpeg-tutorials, which show capabilities of this library. The installation process is a bit tricky now, so welcome to my blog post http://progandprog.blogspot.com/2009/10/video-processing-on-haskell-easy.html, where I am describing how to build and install library. Best regards, Vasyl Pasternak -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091015/402a781e/attachment.html From uhollerbach at gmail.com Thu Oct 15 10:58:21 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Thu Oct 15 10:35:31 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <1A7D4098-2CEB-4C90-80B0-066FFE15559C@swierstra.net> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> <1A7D4098-2CEB-4C90-80B0-066FFE15559C@swierstra.net> Message-ID: <65d7a7e0910150758h525c460eufe61951e345eff8e@mail.gmail.com> Hi, all, thanks for the further inputs, all good stuff to think about... although it's going to be a little while before I can appreciate the inner beauty of Doaitse's version! :-) I had considered the approach of doing a post-parsec verification, but decided I wanted to keep it all inside the parser, hence the desire to match prefixes there (and lack of desire to write 'string "p" <|> string "pr" <|> string "pre" ...'. By way of background, the actual stuff I'm wanting to match is not food names, but some commands for a small ledger program I'm working on. I needed something like that and was tired of losing data to quicken every so often. I realize of course that there are other excellent ledger-type programs out there, but hey, I also needed another hacking project. I'll put this onto hackage in a while, once it does most of the basics of what I need. No doubt the main differentiator between mine and those other excellent ledger programs out there will be that mine has fewer features and more bugs... thanks again, all! Uwe From carette at mcmaster.ca Thu Oct 15 11:05:48 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Thu Oct 15 10:43:29 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: <4395_1254778504_n95LYKVT006547_4ACA6629.4090801@mcmaster.ca> References: <4ACA1996.7060807@mcmaster.ca> <4395_1254778504_n95LYKVT006547_4ACA6629.4090801@mcmaster.ca> Message-ID: <4AD73A4C.9090906@mcmaster.ca> (sorry for the slow reply on this topic...) Robert Atkey and Oleg presented some very interesting code in response to your query. But some of you might (and should!) be asking "why on earth did Jacques use unsafePerformIO?", especially when neither Robert nor Oleg did. Simply put: I answered your question exactly as asked, while they answered the question you *should* have asked. At the exact 'type' involved in your question, there is no good answer; if you want an instance of lam at a monadic type 'directly', you need to 'extract' from the monad. But the point is that that isn't really the right question. Rather than requiring complete parametric polymorphism in the answer-type, if you allow a little non-uniformity through a simple type family, the shift in types is sufficient to no longer require a monadic 'extract' at all. But even once you've gotten to that point, that's not enough, because at that point you still have the issue of what calling convention (by value, name or need) to use. And figuring that out is rather fun, so you got detailed answer from Robert and Oleg explaining that part in detail. Robert carefully used IntT and :-> to label the different types, and Oleg's code (http://okmij.org/ftp/tagless-final/CB.hs) showed how these were really just 'labels', which are useful mnemonics for humans, but not essential. If you dig into our JFP paper describing "finally tagless" in all its gory details, you'll see that we use a poor man's version of type families there too (see section 4.3). Jacques From alistair at abayley.org Thu Oct 15 11:21:26 2009 From: alistair at abayley.org (Alistair Bayley) Date: Thu Oct 15 10:58:36 2009 Subject: [Haskell-cafe] Relational Algebra In-Reply-To: References: Message-ID: <79d7c4980910150821n3c043a7fg8d4da50ce931a0e4@mail.gmail.com> > has anybody already developed an EDSL for relational algebra? > > HaskellDB does that, but its current implementation only allows for > generating SQL, are there other implementations? Hello G?nther, Ganesh did something called squiggle a while ago: http://code.haskell.org/squiggle/unstable/ I've done something similar but it's not published or hosted anywhere, so no link. Can upload it to code.haskell.org if you're interested. Both of our projects just generate SQL though, AFAIK. Was there something else you wanted to generate? Alistair From gue.schmidt at web.de Thu Oct 15 11:40:13 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Oct 15 11:17:25 2009 Subject: [Haskell-cafe] Relational Algebra In-Reply-To: <79d7c4980910150821n3c043a7fg8d4da50ce931a0e4@mail.gmail.com> References: <79d7c4980910150821n3c043a7fg8d4da50ce931a0e4@mail.gmail.com> Message-ID: Hi Alistair, > > Both of our projects just generate SQL though, AFAIK. Was there > something else you wanted to generate? I wish I could provide a clear answer to that myself, truth is I'm not certain myself at the moment. All this is related to a rl problem I have, it concerns the business logic of the app I wrote. I hindsight it occurred to me that the algorithm can be abstractly expressed in terms of relational algebra for which I need an EDSL. One concrete implementation could then be an interpreter / compiler to SQL, if I choose to use a database backend, and another implementation could be a interpretor to in-memory data structures (maps, whathaveyou), or a debugger to see if I have got the abstract algorithm right. I had made very good experience with HaskellDB, it was a great help, but the DSL of HaskellDB immediately translates to SQL, it's hardwired to do so. With the newer techniques for designing EDSLs ("finally tagless" in particular), I'm considering to roll one myself, and I suppose I'll also need HList to do so too. Quite a number of people on this list also use Haskell for rl applications, so I reason that someone must already have tried something similar. G?nther From gue.schmidt at web.de Thu Oct 15 12:16:23 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Oct 15 11:53:36 2009 Subject: [Haskell-cafe] Finally tagless - stuck with implementation of "lam" In-Reply-To: <4AD73A4C.9090906@mcmaster.ca> References: <4ACA1996.7060807@mcmaster.ca> <4395_1254778504_n95LYKVT006547_4ACA6629.4090801@mcmaster.ca> <4AD73A4C.9090906@mcmaster.ca> Message-ID: Hi Jacques, thank you again for your post, better late than never :)! Let me first apologize to you, I did not immediately recognize you as one of the authors of the "Finally Tagless" paper. After 2 years now of using haskell at a mere layman's level and nevertheless writing better and more concise code than in the 10 years before using other languages I was ready to move a step further. I must admit that things like type arithmetic, monads, functors and whathaveyou can be quite intimidating, but the other day I wrote my first monad, and it really wasn't that hard at all. Anyway, so I had managed to improve my code slightly by introducing an abstraction, a tiny, trivial, naive DSL. That certainly was an eye-opener. When you gave me your solution, I realized that while it was correct, that just couldn't be the last word on it. Something from Oleg that contains a bug? Can't be, I must have a mistake in my thinking here. So I didn't give up on "Finally Tagless" but read everything I could get my hands on, plus the responses to my posts were also quite enlightening. One minor problem with your paper, and other work from Oleg, well to me that is, I don't ML. Also Oleg is such an "insider" sometimes he forgets tiny hints for the rest of us. The initial post (not from me) was about "An issue with finally tagless ..." and in Olegs response to that he eliminates the problem with ease (I know, typically Oleg). Well as soon as I tried that nothing worked until I put the "NoImplicitPrelude" in there, duh. So at least now I know what to do next: Design an EDSL taglessly for relational algebra (using HList too) write one or 2 interpreters / compilers for SQL and in-memory Dump the code I have written so far and pretend I never had. Best wishes G?nther Am 15.10.2009, 17:05 Uhr, schrieb Jacques Carette : > (sorry for the slow reply on this topic...) > > Robert Atkey and Oleg presented some very interesting code in response > to your query. But some of you might (and should!) be asking "why on > earth did Jacques use unsafePerformIO?", especially when neither Robert > nor Oleg did. > > Simply put: I answered your question exactly as asked, while they > answered the question you *should* have asked. At the exact 'type' > involved in your question, there is no good answer; if you want an > instance of lam at a monadic type 'directly', you need to 'extract' from > the monad. But the point is that that isn't really the right question. > Rather than requiring complete parametric polymorphism in the > answer-type, if you allow a little non-uniformity through a simple type > family, the shift in types is sufficient to no longer require a monadic > 'extract' at all. > > But even once you've gotten to that point, that's not enough, because at > that point you still have the issue of what calling convention (by > value, name or need) to use. And figuring that out is rather fun, so > you got detailed answer from Robert and Oleg explaining that part in > detail. Robert carefully used IntT and :-> to label the different > types, and Oleg's code (http://okmij.org/ftp/tagless-final/CB.hs) showed > how these were really just 'labels', which are useful mnemonics for > humans, but not essential. > > If you dig into our JFP paper describing "finally tagless" in all its > gory details, you'll see that we use a poor man's version of type > families there too (see section 4.3). Jacques > > From carette at mcmaster.ca Thu Oct 15 12:22:16 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Thu Oct 15 12:00:21 2009 Subject: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework In-Reply-To: <20091008075414.C2760175E1@Adric.metnet.navy.mil> References: <20091008075414.C2760175E1@Adric.metnet.navy.mil> Message-ID: <4AD74C38.2000707@mcmaster.ca> Just a short note to show how the 3 evaluation orders can be written in a very symmetric manner: oleg@okmij.org wrote these as: > In call-by-name, we have > lam f = S . return $ (unS . f . S) > > In call-by-value, we have > lam f = S . return $ (\x -> x >>= unS . f . S . return) > > In call-by-need, we have > lam f = S . return $ (\x -> share x >>= unS . f . S) > These can be rewritten as call-by-name (eta-expanded and application made visible): lam f = S . return $ (\x -> unS . f . S $ x) call-by-value (flip) lam f = S . return $ (\x -> unS . f . S . return =<< x) call-by-need (flip) lam f = S . return $ (\x -> unS . f . S =<< share x ) This pushes us to write two helper functions: execS :: (IO a -> IO b) -> IO a -> IO b execS g x = g =<< share x execM :: Monad m => (m a -> m b) -> m a -> m b execM g x = g . return =<< x And now, with the magic of slices, we can truly display those 3 in highly symmetric fashion: call-by-name: lam f = S . return $ ((unS . f . S) $) call-by-value (flip) lam f = S . return $ ((unS . f . S) `execM`) call-by-need (flip) lam f = S . return $ ((unS . f . S ) `execS`) (the redundant $ is left in to make the symmetry explicit) And now we see the pattern: lam f = wrap . lift $ ((unwrap . f . wrap) `apply`) where the names above are meant to be suggestive rather than 'actual' names. Jacques From shout at ozten.com Thu Oct 15 12:32:05 2009 From: shout at ozten.com (Austin King) Date: Thu Oct 15 12:09:17 2009 Subject: [Haskell-cafe] Need help with ghc static compile for cgi using mysql Message-ID: <454d20c10910150932l5ab01d65s1ad32a2ffed4aec5@mail.gmail.com> For now, I've given up on cheap hosting (via statically compiled CGI). I've created a GHC 6.10.4, cabal-install, Ubuntu 9.04 ec2 instance + MySQL and it works well. Running this plus EBS and Elastic IP will run a little over $60 a month. Ouch. The work going into Haskell Platform is amazing, but... Haskell needs a better commodity hosting story, to allow for casual, fun web hacking. For the record, I tried nearlyfreespeech.net and dreamhost. I wasn't able to install ghc and cabal due to: * FreeBSD GHC support (old version) * FreeBSD library support (no HDBC) * Linux - Missing 'dev' libraries like zlib and not having root access From vanenkj at gmail.com Thu Oct 15 13:11:04 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Oct 15 12:48:14 2009 Subject: [Haskell-cafe] Need help with ghc static compile for cgi using mysql In-Reply-To: <454d20c10910150932l5ab01d65s1ad32a2ffed4aec5@mail.gmail.com> References: <454d20c10910150932l5ab01d65s1ad32a2ffed4aec5@mail.gmail.com> Message-ID: I've run Haskell stuff on VPS hosts like Linode or SliceHost. $20/month is a lot better than $60. On Thu, Oct 15, 2009 at 12:32 PM, Austin King wrote: > For now, I've given up on cheap hosting (via statically compiled CGI). > > I've created a GHC 6.10.4, cabal-install, Ubuntu 9.04 ec2 instance + > MySQL and it works well. > > Running this plus EBS and Elastic IP will run a little over $60 a month. > Ouch. > > The work going into Haskell Platform is amazing, but... > Haskell needs a better commodity hosting story, to allow for casual, > fun web hacking. > > For the record, I tried nearlyfreespeech.net and dreamhost. I wasn't > able to install ghc and cabal due to: > * FreeBSD GHC support (old version) > * FreeBSD library support (no HDBC) > * Linux - Missing 'dev' libraries like zlib and not having root access > _______________________________________________ > 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/20091015/bc32d390/attachment.html From dagit at codersbase.com Thu Oct 15 13:25:43 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Oct 15 13:02:52 2009 Subject: [Haskell-cafe] Need help with ghc static compile for cgi using mysql In-Reply-To: References: <454d20c10910150932l5ab01d65s1ad32a2ffed4aec5@mail.gmail.com> Message-ID: On Thu, Oct 15, 2009 at 10:11 AM, John Van Enk wrote: > I've run Haskell stuff on VPS hosts like Linode or SliceHost. $20/month is > a lot better than $60. lambdabot is currently hosted on the lowest end linode. The biggest hurdle I hit was that gnu ld is a memory pig when GHC is compiled with split obj. I had to build my own ghc (after disabling split obj, not hard but not adequately documented either) and things seem to be fine now. Before I built GHC without split obj I wasn't even able to link Setup.hs to start building anything. I would go so far as to recommend GHC HQ do something about the split obj issue. I think ideally we need someone to improve gnu ld. RAM is expensive on the linode so you need to make sure the code you want to run is memory efficient (swap is prohibitively slow). Having root and and nice web control panel is a huge win. I'm reasonably happy considering the relative cost. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091015/47211aba/attachment.html From andrewcoppin at btinternet.com Thu Oct 15 13:52:27 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 15 13:29:37 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <20091015032453.GA15031@whirlpool.galois.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <20091015032453.GA15031@whirlpool.galois.com> Message-ID: <4AD7615B.3030706@btinternet.com> Don Stewart wrote: > bulat.ziganshin: > >> Hello Andrew, >> >> Thursday, October 15, 2009, 12:54:37 AM, you wrote: >> >> >>> Does anybody actually "get paid" to develop GHC? Or is this all people >>> >> SPJ, SM and Ian are paid by MS Research. Other people involved in core >> development are mainly scientists (afaik) >> Perhaps these are the "three people" the speaker was referring to then. Seems like there are plenty of other people involved though... > Besides MSR and the university groups, the IHG funds Well-Typed to do > development, as well. > ...not least of all these. ;-) But still, it seems the total GHC manpower effort is significantly smaller than I imagined. (Which just makes it more impressive that GHC is so good...) Ah, MSR, the only known Haskell-related enterprise based in the UK. Sometimes I have these delusions that I should go ever there and see if they'll hire me... From pumpkingod at gmail.com Thu Oct 15 14:23:57 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Oct 15 14:01:06 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4AD7615B.3030706@btinternet.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <20091015032453.GA15031@whirlpool.galois.com> <4AD7615B.3030706@btinternet.com> Message-ID: Well-Typed is in the UK too :) On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin wrote: > Don Stewart wrote: >> >> bulat.ziganshin: >> >>> >>> Hello Andrew, >>> >>> Thursday, October 15, 2009, 12:54:37 AM, you wrote: >>> >>> >>>> >>>> Does anybody actually "get paid" to develop GHC? Or is this all people >>>> >>> >>> SPJ, SM and Ian are paid by MS Research. Other people involved in core >>> development are mainly scientists (afaik) >>> > > Perhaps these are the "three people" the speaker was referring to then. > > Seems like there are plenty of other people involved though... > >> Besides MSR and the university groups, the IHG funds Well-Typed to do >> development, as well. >> > > ...not least of all these. ;-) But still, it seems the total GHC manpower > effort is significantly smaller than I imagined. (Which just makes it more > impressive that GHC is so good...) > > Ah, MSR, the only known Haskell-related enterprise based in the UK. > Sometimes I have these delusions that I should go ever there and see if > they'll hire me... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Thu Oct 15 14:30:36 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 15 14:07:46 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <20091015032453.GA15031@whirlpool.galois.com> <4AD7615B.3030706@btinternet.com> Message-ID: <4AD76A4C.7070105@btinternet.com> Daniel Peebles wrote: > Well-Typed is in the UK too :) > Really? Cool! I wonder where... Oh, Oxford. So also not far from me. However, given that I can't even construct a simple sentence correctly... > On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin > wrote: > >> Sometimes I have these delusions that I should go ever there and see if >> they'll hire me... >> ...I think we can safely conclude that nobody is going to be interested in hiring me. :-/ From haskell at colquitt.org Thu Oct 15 15:26:58 2009 From: haskell at colquitt.org (John Dorsey) Date: Thu Oct 15 15:04:07 2009 Subject: [Haskell-cafe] Need help with ghc static compile for cgi using mysql In-Reply-To: References: <454d20c10910150932l5ab01d65s1ad32a2ffed4aec5@mail.gmail.com> Message-ID: <20091015192658.GA25884@colquitt.org> > lambdabot is currently hosted on the lowest end linode. The biggest hurdle I [...] +1. I use linode for (most of) my Haskell work. John From vandijk.roel at gmail.com Thu Oct 15 15:53:59 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Oct 15 15:31:08 2009 Subject: [Haskell-cafe] ANN: Reverse Dependencies in Hackage (demo) Message-ID: Hello, I have implemented reverse dependencies in Hackage. You can play with the demo here: http://bifunctor.homelinux.net/~roel/hackage I already send a message to Haskell-Cafe, but I made a few changes and would like some feedback. You can sort the tables of reverse dependencies by clicking on the column headers. Large tables (base or the total overview) might take some time. Sorting is done client-side with a bit of JavaScript. I added a link to an overview of the reverse dependencies of every package in hackage. It is sorted by the total number of rev. deps by default, so the most dependent-on packages (within hackage) are at the top. In the future such a list might be expanded with other information, like the download count. Things I would like feedback on: - Rev. deps overview for all packages; is it useful? - If you look at the reverse dependencies for a package like digest you'll see a list of packages that depend on digest. Next to the names of the packages that depend on digest are their respective reverse dependencies. The idea is that you can see which are the most "important" (for some value of important) packages that depend on digest. Is that useful? - Is this the best way to present the information? Currently I am working on a patch for the new hackage-server. Regards, Roel From johan.tibell at gmail.com Thu Oct 15 16:22:57 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Thu Oct 15 16:01:23 2009 Subject: [Haskell-cafe] ANN: Reverse Dependencies in Hackage (demo) In-Reply-To: References: Message-ID: <90889fe70910151322w5de9f7fep67c88221adb8ad13@mail.gmail.com> Hi, This is really neat. 2009/10/15 Roel van Dijk : > Things I would like feedback on: > - Rev. deps overview for all packages; is it useful? Yes. > - If you look at the reverse dependencies for a package like digest > you'll see a list of packages that depend on digest. Next to the names > of the packages that depend on digest are their respective reverse > dependencies. The idea is that you can see which are the most > "important" (for some value of important) packages that depend on > digest. Is that useful? Yes, I think so. > - Is this the best way to present the information? Are the packages with all zeroes in the columns still reverse dependencies (that don't have any dependencies in turn)? -- Johan From vandijk.roel at gmail.com Thu Oct 15 16:29:13 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Oct 15 16:06:22 2009 Subject: [Haskell-cafe] ANN: Reverse Dependencies in Hackage (demo) In-Reply-To: <90889fe70910151322w5de9f7fep67c88221adb8ad13@mail.gmail.com> References: <90889fe70910151322w5de9f7fep67c88221adb8ad13@mail.gmail.com> Message-ID: 2009/10/15 Johan Tibell : >> - Is this the best way to present the information? > > Are the packages with all zeroes in the columns still reverse > dependencies (that don't have any dependencies in turn)? Yes. They are reverse dependencies which have no reverse dependencies of their own. From andrewcoppin at btinternet.com Thu Oct 15 17:10:45 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 15 16:47:56 2009 Subject: [Haskell-cafe] Very evil Message-ID: <4AD78FD5.1060500@btinternet.com> {-# LANGUAGE EmptyDataDecls #-} module Main (main) where import Unsafe.Coerce data Anything newtype Key x = Key Int deriving Eq type Dict = [(Key Anything, Anything)] put :: Key x -> x -> Dict -> Dict put k' v' = raw (unsafeCoerce k') (unsafeCoerce v') where raw k0 v0 [] = [(k0,v0)] raw k0 v0 ((k,v):zs) | k == k0 = (k0 ,v0) : zs | otherwise = (k ,v ) : raw k0 v0 zs get :: Key x -> Dict -> Maybe x get k' zs = unsafeCoerce (raw (unsafeCoerce k') zs) where raw k0 [] = Nothing raw k0 ((k,v):zs) | k == k0 = Just v | otherwise = raw k0 zs main = do let k1 = Key 1 :: Key Int let k2 = Key 2 :: Key Double let k3 = Key 3 :: Key String let k4 = Key 4 :: Key Bool let d0 = [] let d1 = put k1 123 d0 let d2 = put k2 123 d1 let d3 = put k3 "123" d2 let d4 = put k4 True d3 print (get k1 d4) print (get k2 d4) print (get k3 d4) print (get k4 d4) Unsafe coerce, anyone? This particular example appears to run without incident, but the GHC docs suggest that this is very... well, unsafe. (In particular, the docs claim this will fall over on function types.) I presume there's some less-evil way of doing this? From lemming at henning-thielemann.de Thu Oct 15 17:16:03 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Oct 15 16:53:15 2009 Subject: [Haskell-cafe] more improvable randomness In-Reply-To: <1446.75.50.146.107.1255016326.squirrel@mail.alumni.caltech.edu> References: <1446.75.50.146.107.1255016326.squirrel@mail.alumni.caltech.edu> Message-ID: On Thu, 8 Oct 2009, Michael Mossey wrote: > I wrote some code to model the keystroke-to-keystroke delay in a person > typing, with pseudorandomness. There are two kinds of delays.. one is a > very small delay as the person reaches for a new key (call this 'reach' > delays), the other is a larger delay that represents a pause to think or > to take a break (call this 'break' delays). Has this to do with your PortMidi problems? > breakSeries :: Int -> Int -> StdGen -> [Float] > breakSeries lowerB upperB gen = > let (n,gen1) = randomR (lowerB,upperB) gen > (gen2,gen3) = split gen1 > delay = generate 1 gen2 breakM > in replicate n 0 ++ [delay] ++ breakSeries lowerB upperB gen3 > > breakM :: Gen Float > breakM = frequency [ (10, choose( 1::Float , 2)) > , (10, choose( 4::Float , 6)) ] > > test = (print . take 100 . breakSeries 2 4 ) =<< newStdGen Gen is from QuickCheck package, isn't it? That can't be mixed with Random from 'random' package. You could wrap 'randomR' in a State monad ('transformers' package), write your own 'frequency' function for that, and run that with the seed from 'newStdGen'. From pumpkingod at gmail.com Thu Oct 15 17:23:19 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Oct 15 17:00:27 2009 Subject: [Haskell-cafe] Very evil In-Reply-To: <4AD78FD5.1060500@btinternet.com> References: <4AD78FD5.1060500@btinternet.com> Message-ID: It looks like you may want http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Dynamic.html . It does more or less what you're talking about behind the scenes, but probably uses the magical Any type to not encounter issues with functions, and gives you a Nothing if you attempt to coerce it to the wrong type. On Thu, Oct 15, 2009 at 5:10 PM, Andrew Coppin wrote: > {-# LANGUAGE EmptyDataDecls #-} > > module Main (main) where > > import Unsafe.Coerce > > data Anything > > newtype Key x = Key Int deriving Eq > > type Dict = [(Key Anything, Anything)] > > put :: Key x -> x -> Dict -> Dict > put k' v' = raw (unsafeCoerce k') (unsafeCoerce v') > ?where > ? raw k0 v0 [] = [(k0,v0)] > ? raw k0 v0 ((k,v):zs) > ? ? | k == k0 ? = (k0 ,v0) : ? ? ? ? ? zs > ? ? | otherwise = (k ?,v ) : raw k0 v0 zs > > get :: Key x -> Dict -> Maybe x > get k' zs = unsafeCoerce (raw (unsafeCoerce k') zs) > ?where > ? raw k0 [] = Nothing > ? raw k0 ((k,v):zs) > ? ? | k == k0 ? = Just v > ? ? | otherwise = raw k0 zs > > main = do > ?let k1 = Key 1 :: Key Int > ?let k2 = Key 2 :: Key Double > ?let k3 = Key 3 :: Key String > ?let k4 = Key 4 :: Key Bool > > ?let d0 = [] > ?let d1 = put k1 ?123 ?d0 > ?let d2 = put k2 ?123 ?d1 > ?let d3 = put k3 "123" d2 > ?let d4 = put k4 True ?d3 > > ?print (get k1 d4) > ?print (get k2 d4) > ?print (get k3 d4) > ?print (get k4 d4) > > > > Unsafe coerce, anyone? > > This particular example appears to run without incident, but the GHC docs > suggest that this is very... well, unsafe. (In particular, the docs claim > this will fall over on function types.) > > I presume there's some less-evil way of doing this? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From doaitse at swierstra.net Thu Oct 15 18:07:30 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Thu Oct 15 17:44:43 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <65d7a7e0910150758h525c460eufe61951e345eff8e@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> <1A7D4098-2CEB-4C90-80B0-066FFE15559C@swierstra.net> <65d7a7e0910150758h525c460eufe61951e345eff8e@mail.gmail.com> Message-ID: <49890AC1-AC20-4E66-9235-F8CE7D9E29AE@swierstra.net> On 15 okt 2009, at 16:58, Uwe Hollerbach wrote: > Hi, all, thanks for the further inputs, all good stuff to think > about... although it's going to be a little while before I can > appreciate the inner beauty of Doaitse's version! :-) The nice thing is that you do not have to understand the inner workings ;-} I basically builds a greedy parser for each word to be recognised which can stop and assume the rest is there if it can no longer proceed (the `opt` is greedy in its left alternative) . Hence it recognises the longest possible prefix. Since my parsers pursue all alternatives in parallel you automatically get what you want, without having to indicate prefix lengths, calls to try, etc. The "amb" combinator has type amb :: Parser a -> Parser [a] and collects the result from all alternatives its argument parser is constructed from; you might say it convert an ambiguous parser to a parser with a list as result, hence preventing the rest of the input being parsed over and over again. I am currently working on bringing back more abstract interpretation in the implementation (i.e. what we have had for almost 10 years in the uulib library), but I do not expect you to see a lot of that from the outside. If you want to work with left-recursive parsers (which does not seem to be the case), you may revert to more complicated solutions such as found in the "christmastree" (Changing Haskell's Read Implementation Such That by Manipulationg Abstract Syntax Trees Read Evaluates Efficiently) package if you need to generate parsers online, or to happy-based solutions in case your grammar is fixed. If you have any questions do not hesitate to ask, Doaitse > I had considered > the approach of doing a post-parsec verification, but decided I wanted > to keep it all inside the parser, hence the desire to match prefixes > there (and lack of desire to write 'string "p" <|> string "pr" <|> > string "pre" ...'. > > By way of background, the actual stuff I'm wanting to match is not > food names, but some commands for a small ledger program I'm working > on. I needed something like that and was tired of losing data to > quicken every so often. I realize of course that there are other > excellent ledger-type programs out there, but hey, I also needed > another hacking project. I'll put this onto hackage in a while, once > it does most of the basics of what I need. No doubt the main > differentiator between mine and those other excellent ledger programs > out there will be that mine has fewer features and more bugs... > > thanks again, all! > > Uwe From mauricio.antunes at gmail.com Thu Oct 15 19:04:57 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Oct 15 18:42:35 2009 Subject: [Haskell-cafe] Re: ANN: Reverse Dependencies in Hackage (demo) In-Reply-To: References: Message-ID: > You can sort the tables of reverse dependencies by clicking on > the column headers. I wouldn't have thought about clicking in the columns headers. Maybe you could show the order arrow already in the beggining, before any clicks, this would give a hint. > - Rev. deps overview for all packages; is it useful? Sure! Do you think it could be complemented with a graph view? I liked this, from graphviz page: http://graphviz.org/Gallery/undirected/softmaint.html > - Is this the best way to present the information? Just cosmetics: in the individual package rev. dependencies, what do you think of using two columns, one for direct dependencies table and other for indirect dependencies? This would remove the need for navigation links in the main table. Also, here, if it's feasible, I think a graph with just the central package and 1fst and 2nd order dependencies could be usefull. Best, Maur?cio From tomamundsen at gmail.com Thu Oct 15 19:31:17 2009 From: tomamundsen at gmail.com (Tom.Amundsen) Date: Thu Oct 15 19:08:25 2009 Subject: [Haskell-cafe] Best Editor In Windows In-Reply-To: <25908187.post@talk.nabble.com> References: <25908187.post@talk.nabble.com> Message-ID: <25917670.post@talk.nabble.com> Nathan P. Campos wrote: > > Hello, > I'm very new at Haskell, i'm reading a book and starting, but i want to > know which is the best editor for development under Windows, because now > i'm using Notepad++(That i use to develop in C++). > > Thanks, > Nathan Paullino Campos > If you use emacs, check out http://www.haskell.org/haskell-mode/ -- View this message in context: http://www.nabble.com/Best-Editor-In-Windows-tp25908187p25917670.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From monnier at iro.umontreal.ca Thu Oct 15 21:10:04 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu Oct 15 20:47:51 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: > I'm very new at Haskell, i'm reading a book and starting, but i want to > know which is the best editor for development under Windows, because now > i'm using Notepad++(That i use to develop in C++). The best editor for development is Emacs, of course. http://www.gnu.org/software/emacs Stefan From tanimoto at arizona.edu Thu Oct 15 21:30:02 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Thu Oct 15 21:07:32 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: Hello! On Thu, Oct 15, 2009 at 8:10 PM, Stefan Monnier wrote: >> I'm very new at Haskell, i'm reading a book and starting, but i want to >> know which is the best editor for development under Windows, because now >> i'm using Notepad++(That i use to develop in C++). > > The best editor for development is Emacs, of course. > http://www.gnu.org/software/emacs > > > ? ? ? ?Stefan I've been using Emacs with haskell-mode that Stefan Monnier created and maintains, and I have to say, it's fantastic! On Linux or Windows, it just works(TM). Thank you, Stefan! The only thing I haven't figured out is how to do tab-completion of words in the ghci buffer. Do I need to use a different key combination? I couldn't find that in the documentation. Paulo From gcross at phys.washington.edu Thu Oct 15 21:30:20 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Oct 15 21:07:47 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> In my humble opinion, one of the best editors for development of all time is Leo: http://webpages.charter.net/edreamleo/front.html Leo takes the idea of "code folding" and gives you complete control over it. That is, unlike other editors which only let you fold the code inside if/while/for/etc. statements and which only show you an outline consisting of a level for files and a level for function, Leo lets you structure the levels of your outline arbitrarily so that you can "fold" arbitrary chunks of code and do things like grouping together functions and files with a similar purpose or implementation. By structuring your code as an outline, you make it easier for others and yourself both to navigate through the code and also to see at a glance the high-level structure. Anyway, just wanted to use this opportunity to plug my favorite tool. :-) The downside about it is that the implementation sometimes feels a bit slow and clunky, so part of me really hopes that at the very least people will learn enough about this tool to take its ideas and steal them for other editors! Cheers, Greg On Oct 15, 2009, at 6:10 PM, Stefan Monnier wrote: >> I'm very new at Haskell, i'm reading a book and starting, but i >> want to >> know which is the best editor for development under Windows, >> because now >> i'm using Notepad++(That i use to develop in C++). > > The best editor for development is Emacs, of course. > http://www.gnu.org/software/emacs > > > Stefan > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From monnier at iro.umontreal.ca Thu Oct 15 22:19:17 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu Oct 15 21:56:56 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: > The only thing I haven't figured out is how to do tab-completion of > words in the ghci buffer. Do I need to use a different key > combination? I couldn't find that in the documentation. I think it's just a missing feature. Stefan From ravi at bluespec.com Thu Oct 15 23:08:33 2009 From: ravi at bluespec.com (Ravi Nanavati) Date: Thu Oct 15 22:45:42 2009 Subject: [Haskell-cafe] Fwd: [BostonHaskell] Next meeting: October 21st at MIT (32G-882) In-Reply-To: <161d443c0910152007w1e48b90ob424dcc2e3033a45@mail.gmail.com> References: <161d443c0910152007w1e48b90ob424dcc2e3033a45@mail.gmail.com> Message-ID: <7b977d860910152008m32c3ecb0h36ea537bf7d4357b@mail.gmail.com> ---------- Forwarded message ---------- From: Ravi Nanavati Date: Thu, Oct 15, 2009 at 11:07 PM Subject: [BostonHaskell] Next meeting: October 21st at MIT (32G-882) To: bostonhaskell@googlegroups.com I'm pleased to announce the October meeting of the Boston Area Haskell Users' Group. Based on the feedback from the meeting polls and the constraints of our speakers, the October meeting has been scheduled for Wednesday, October 21st from 7pm - 9pm. Like the past three meetings, it will be held in the MIT CSAIL Reading Room (32-G882, i.e. a room on the 8th floor of the Gates Tower of the MIT's Stata Center at 32 Vassar St in Cambridge, MA). Based on the topic poll (and because he volunteered), our first speaker will be Brian Sniffen with an introduction to Parsec. Following his presentation will be our traditional break (with the now-traditional baked goods). Our second speaker will be Edward Kmett, who will be picking up the part of his monoids and parsing presentation that we didn't get to in August or September (third time's the charm!): "A Parallel Parsing Trifecta: Iteratees, Parsec, and Monoids". Edward's slides from August are here: http://comonad.com/reader/wp-content/uploads/2009/08/IntroductionToMonoids.pdf I'd recommend looking at them if you weren't at the August meeting (or want a refresher on the material) since the two parts of his presentation were designed to go concurrently. There's also a preview of the presentation as part of this post on Edward's blog: http://comonad.com/reader/2009/iteratees-parsec-and-monoid/ The October attendance poll is at: http://doodle.com/u7762nfxpghsrn2r As always, responding to this poll will help with two things: 1. Getting an idea of what fraction of the Boston-area Haskell community can and can't attend this meeting (to help with future scheduling). 2. Giving me an estimated count of attendees, since I have talked my wife into baking some more goodies and bringing drinks again. Helping with BostonHaskell (besides volunteering to speak at future meetings): 1. Sponsorship of refreshments is still being eagerly solicited. 2. Please let me know if you're willing to arrive early (6:30pm) to help me move refreshments from my car. Based on past experience, I could use 3-4 volunteers. 3. Please let me know if you're willing to arrive early (6:30pm) to stand by the door and let people into the 8th floor. I'm guessing 1 or 2 volunteers is enough here. 4. If someone is willing to edit the HaskellWiki page, post to reddit or otherwise publicize the meeting please just go ahead and do that (especially as I'm sending this out a bit later than intended). 5. I'm also still having trouble embedding this poll in a page on our Google Group, so if anyone has any ideas about that, please feel free to try (any group member can edit pages) and/or offer other suggestions. If you have any questions about the meeting please send them to the BostonHaskell mailing list: bostonhaskell@googlegroups.com or contact me directly. I look forward to seeing many Boston-area Haskellers at the October meeting! Thank you, ?- Ravi Nanavati --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "BostonHaskell" group. To post to this group, send email to bostonhaskell@googlegroups.com To unsubscribe from this group, send email to bostonhaskell+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/bostonhaskell?hl=en -~----------~----~----~----~------~----~------~--~--- From mxcantor at gmail.com Thu Oct 15 23:48:06 2009 From: mxcantor at gmail.com (Max Cantor) Date: Thu Oct 15 23:25:22 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4AD76A4C.7070105@btinternet.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <20091015032453.GA15031@whirlpool.galois.com> <4AD7615B.3030706@btinternet.com> <4AD76A4C.7070105@btinternet.com> Message-ID: It is pretty amazing what such a small coterie of devs has accomplished in GHC. Compare this to the thousands that work on GCC/ javac/csc and vis studio etc. So, once again, kudos. max On Oct 16, 2009, at 2:30 AM, Andrew Coppin wrote: > Daniel Peebles wrote: >> Well-Typed is in the UK too :) >> > > Really? Cool! I wonder where... Oh, Oxford. So also not far from me. > > However, given that I can't even construct a simple sentence > correctly... > >> On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin >> wrote: >> >>> Sometimes I have these delusions that I should go ever there and >>> see if >>> they'll hire me... >>> > > ...I think we can safely conclude that nobody is going to be > interested in hiring me. :-/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lrpalmer at gmail.com Fri Oct 16 01:12:03 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 16 00:49:10 2009 Subject: [Haskell-cafe] Very evil In-Reply-To: <4AD78FD5.1060500@btinternet.com> References: <4AD78FD5.1060500@btinternet.com> Message-ID: <7ca3f0160910152212u5fd6e877o1bfc417671141f39@mail.gmail.com> Maybe you would like the hetero-map package. Its purpose is to do precisely what you are doing, but in a typesafe way. On Thu, Oct 15, 2009 at 3:10 PM, Andrew Coppin wrote: > {-# LANGUAGE EmptyDataDecls #-} > > module Main (main) where > > import Unsafe.Coerce > > data Anything > > newtype Key x = Key Int deriving Eq > > type Dict = [(Key Anything, Anything)] > > put :: Key x -> x -> Dict -> Dict > put k' v' = raw (unsafeCoerce k') (unsafeCoerce v') > ?where > ? raw k0 v0 [] = [(k0,v0)] > ? raw k0 v0 ((k,v):zs) > ? ? | k == k0 ? = (k0 ,v0) : ? ? ? ? ? zs > ? ? | otherwise = (k ?,v ) : raw k0 v0 zs > > get :: Key x -> Dict -> Maybe x > get k' zs = unsafeCoerce (raw (unsafeCoerce k') zs) > ?where > ? raw k0 [] = Nothing > ? raw k0 ((k,v):zs) > ? ? | k == k0 ? = Just v > ? ? | otherwise = raw k0 zs > > main = do > ?let k1 = Key 1 :: Key Int > ?let k2 = Key 2 :: Key Double > ?let k3 = Key 3 :: Key String > ?let k4 = Key 4 :: Key Bool > > ?let d0 = [] > ?let d1 = put k1 ?123 ?d0 > ?let d2 = put k2 ?123 ?d1 > ?let d3 = put k3 "123" d2 > ?let d4 = put k4 True ?d3 > > ?print (get k1 d4) > ?print (get k2 d4) > ?print (get k3 d4) > ?print (get k4 d4) > > > > Unsafe coerce, anyone? > > This particular example appears to run without incident, but the GHC docs > suggest that this is very... well, unsafe. (In particular, the docs claim > this will fall over on function types.) > > I presume there's some less-evil way of doing this? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Fri Oct 16 02:28:43 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 16 02:06:02 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4c88418c0910150017h79738127oe2840703286d6d0d@mail.gmail.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <4c88418c0910150017h79738127oe2840703286d6d0d@mail.gmail.com> Message-ID: <4AD8129B.6080704@van.steenbergen.nl> David Virebayre wrote: > Taking the opportunity to thank very much both Simons and Ian for the > work they do and the enthusiasm they show. You guys rock. I heartily second that! Martijn. From oleg at okmij.org Fri Oct 16 03:10:03 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Fri Oct 16 02:51:04 2009 Subject: [Haskell-cafe] Re: Relational Algebra Message-ID: <20091016071003.F34FA174DD@Adric.metnet.navy.mil> > In hindsight it occurred to me that the algorithm can be abstractly > expressed in terms of relational algebra for which I need an EDSL. > > One concrete implementation could then be an interpreter / compiler to > SQL, if I choose to use a database backend, and another implementation > could be a interpretor to in-memory data structures (maps, whathaveyou), > or a debugger to see if I have got the abstract algorithm right. Perhaps the CoddFish project (what a great name!) may be relevant here: http://wiki.di.uminho.pt/twiki/bin/view/Research/PURe/CoddFish Perhaps it is the first project that systematically exploited the connection between functional dependencies in type classes and functional dependencies among database attributes. From pirelo at googlemail.com Fri Oct 16 04:59:15 2009 From: pirelo at googlemail.com (Pablo Nogueira) Date: Fri Oct 16 04:36:23 2009 Subject: [Haskell-cafe] ANN: WFLP 2010 Call for papers Message-ID: [Apologies for multiple receptions of this message] ******************************************************************** Preliminary Call For Papers 19th International Workshop on Functional and (Constraint) Logic Programming Madrid, Spain, January 17, 2010 http://babel.ls.fi.upm.es/events/wflp2010/ ********* colocated with Principles of Programming Languages POPL 2010 http://www.cse.psu.edu/popl/10/ ******************************************************************** IMPORTANT DATES Abstract Submission: November 9, 2009 Full Paper Submission: November 15, 2009 Acceptance Notification: December 15, 2009 Preliminary Proceedings: January 5, 2010 Workshop: January 17, 2010 SCOPE The aim of the Workshop on Functional and (Constraint) Logic Programming is to bring together researchers interested in functional programming and (constraint) logic programming with special emphasis on the integration of both paradigms and of other declarative programming extensions. It promotes the cross-fertilizing exchange of ideas and experiences among researchers and students from the different communities interested in the foundations, applications, and combinations of high-level declarative programming languages and related areas. The previous WFLP editions are: WFLP 2009 (Brasilia, Brazil), WFLP 2008 (Siena, Italy), WFLP 2007 (Paris, France), WFLP 2006 (Madrid, Spain), WCFLP 2005 (Tallinn, Estonia), WFLP 2004 (Aachen, Germany), WFLP 2003 (Valencia, Spain), WFLP 2002 (Grado, Italy), WFLP 2001 (Kiel, Germany), WFLP 2000 (Benicassim, Spain), WFLP'99 (Grenoble, France), WFLP'98 (Bad Honnef, Germany), WFLP'97 (Schwarzenberg, Germany), WFLP'96 (Marburg, Germany), WFLP'95 (Schwarzenberg, Germany), WFLP'94 (Schwarzenberg, Germany), WFLP'93 (Rattenberg, Germany), and WFLP'92 (Karlsruhe, Germany). LOCATION WFLP 2010 will be held on January 17, 2010 in Madrid, Spain, colocated with the 37th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2010). WFLP 2010 solicits papers in all areas of functional and (constraint) logic programming, including but not limited to: * Foundations: formal semantics, logic variables, binding and abstract syntax, rewriting and narrowing, unification, constraint solving, dynamics, type theory, meta-theory, effects, etc. * Language Design: security, services, modules, type systems, multi-paradigm languages, concurrency and distribution, objects, libraries, generic programming, interoperability, etc. * Implementation: abstract machines, parallelism, compile-time and run-time optimizations, foreign-language interfaces, memory management, multi-threading, exploiting parallel hardware, etc. * Transformation and Analysis: abstract interpretation, specialization, partial evaluation, program transformation, program calculation, program proof, meta-programming, generative programming, etc. * Software Development: algorithms, data structures, design patterns, components and composition, specification, proof assistants, verification and validation, model checking, debugging, testing, profiling, tracing, etc. * Paradigm Integration: integration of declarative programming with other paradigms or features such as imperative, object-oriented, aspect-oriented, concurrent, real-time programming, event-driven architectures, etc. * Applications: education, industry, commercial uses, domain-specific languages, visual/graphical user interfaces, embedded systems, WWW applications, XML processing, artificial intelligence, knowledge representation and machine learning, deductive databases, advanced programming environments and tools, etc. SUBMISSIONS and PROCEEDINGS Authors are invited to submit papers presenting original unpublished work. Papers must be at most 15 pages long. Exceptionally, authors may surpass the page limit by providing well-marked appendices intended as reviewing aids. Appendices will not appear in the final publication. Submission categories include regular research papers, system descriptions, and short papers describing on-going work (at most 8 pages). Submissions must be formatted in Lecture Notes in Computer Science (LNCS) style. This requirement needs not apply to appendices. Papers should be submitted in pdf or postscript format electronically via the web-based submission site http://www.easychair.org/conferences/?conf=wflp2010 Preliminary proceedings will be available at the workshop. Selected authors will be invited to submit a full version of their papers after the workshop. Contributions accepted for the post-workshop proceedings have usually appeared in journals -- those of the 2009 edition have been published in LNCS, previous editions in ENTCS, etc. PROGRAMME CHAIR Julio Marino (Universidad Politecnica de Madrid, Spain) PROGRAMME COMMITTEE Maria Alpuente (Universidad Politecnica de Valencia, Spain) Sergio Antoy (Portland State University, USA) Rachid Echahed (CNRS-IMAG, France) Santiago Escobar (Universidad Politecnica de Valencia, Spain) Moreno Falaschi (Universita di Siena, Italy) Murdoch Gabbay (Heriot-Watt University, UK) Maria Garcia de la Banda (Monash University, Australia) Victor Gulias (Lambdastream SL, Spain) Michael Hanus (CAU Kiel, Germany) Herbert Kuchen (Univ. of Muenster, Germany) Francisco Lopez-Fraguas (Universidad Complutense de Madrid, Spain) James Lipton (Wesleyan University, USA) Mircea Marin (University of Tsukuba, Japan) Juan Jose Moreno-Navarro (Ministry of Science & Innovation, Spain) Brigitte Pientka (McGill University, Canada) -------------- next part -------------- [Apologies for multiple receptions of this message] ******************************************************************** Preliminary Call For Papers 19th International Workshop on Functional and (Constraint) Logic Programming Madrid, Spain, January 17, 2010 http://babel.ls.fi.upm.es/events/wflp2010/ ********* colocated with Principles of Programming Languages POPL 2010 http://www.cse.psu.edu/popl/10/ ******************************************************************** IMPORTANT DATES Abstract Submission: November 9, 2009 Full Paper Submission: November 15, 2009 Acceptance Notification: December 15, 2009 Preliminary Proceedings: January 5, 2010 Workshop: January 17, 2010 SCOPE The aim of the Workshop on Functional and (Constraint) Logic Programming is to bring together researchers interested in functional programming and (constraint) logic programming with special emphasis on the integration of both paradigms and of other declarative programming extensions. It promotes the cross-fertilizing exchange of ideas and experiences among researchers and students from the different communities interested in the foundations, applications, and combinations of high-level declarative programming languages and related areas. The previous WFLP editions are: WFLP 2009 (Brasilia, Brazil), WFLP 2008 (Siena, Italy), WFLP 2007 (Paris, France), WFLP 2006 (Madrid, Spain), WCFLP 2005 (Tallinn, Estonia), WFLP 2004 (Aachen, Germany), WFLP 2003 (Valencia, Spain), WFLP 2002 (Grado, Italy), WFLP 2001 (Kiel, Germany), WFLP 2000 (Benicassim, Spain), WFLP'99 (Grenoble, France), WFLP'98 (Bad Honnef, Germany), WFLP'97 (Schwarzenberg, Germany), WFLP'96 (Marburg, Germany), WFLP'95 (Schwarzenberg, Germany), WFLP'94 (Schwarzenberg, Germany), WFLP'93 (Rattenberg, Germany), and WFLP'92 (Karlsruhe, Germany). LOCATION WFLP 2010 will be held on January 17, 2010 in Madrid, Spain, colocated with the 37th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2010). WFLP 2010 solicits papers in all areas of functional and (constraint) logic programming, including but not limited to: * Foundations: formal semantics, logic variables, binding and abstract syntax, rewriting and narrowing, unification, constraint solving, dynamics, type theory, meta-theory, effects, etc. * Language Design: security, services, modules, type systems, multi-paradigm languages, concurrency and distribution, objects, libraries, generic programming, interoperability, etc. * Implementation: abstract machines, parallelism, compile-time and run-time optimizations, foreign-language interfaces, memory management, multi-threading, exploiting parallel hardware, etc. * Transformation and Analysis: abstract interpretation, specialization, partial evaluation, program transformation, program calculation, program proof, meta-programming, generative programming, etc. * Software Development: algorithms, data structures, design patterns, components and composition, specification, proof assistants, verification and validation, model checking, debugging, testing, profiling, tracing, etc. * Paradigm Integration: integration of declarative programming with other paradigms or features such as imperative, object-oriented, aspect-oriented, concurrent, real-time programming, event-driven architectures, etc. * Applications: education, industry, commercial uses, domain-specific languages, visual/graphical user interfaces, embedded systems, WWW applications, XML processing, artificial intelligence, knowledge representation and machine learning, deductive databases, advanced programming environments and tools, etc. SUBMISSIONS and PROCEEDINGS Authors are invited to submit papers presenting original unpublished work. Papers must be at most 15 pages long. Exceptionally, authors may surpass the page limit by providing well-marked appendices intended as reviewing aids. Appendices will not appear in the final publication. Submission categories include regular research papers, system descriptions, and short papers describing on-going work (at most 8 pages). Submissions must be formatted in Lecture Notes in Computer Science (LNCS) style. This requirement needs not apply to appendices. Papers should be submitted in pdf or postscript format electronically via the web-based submission site http://www.easychair.org/conferences/?conf=wflp2010 Preliminary proceedings will be available at the workshop. Selected authors will be invited to submit a full version of their papers after the workshop. Contributions accepted for the post-workshop proceedings have usually appeared in journals -- those of the 2009 edition have been published in LNCS, previous editions in ENTCS, etc. PROGRAMME CHAIR Julio Marino (Universidad Politecnica de Madrid, Spain) PROGRAMME COMMITTEE Maria Alpuente (Universidad Politecnica de Valencia, Spain) Sergio Antoy (Portland State University, USA) Rachid Echahed (CNRS-IMAG, France) Santiago Escobar (Universidad Politecnica de Valencia, Spain) Moreno Falaschi (Universita di Siena, Italy) Murdoch Gabbay (Heriot-Watt University, UK) Maria Garcia de la Banda (Monash University, Australia) Victor Gulias (Lambdastream SL, Spain) Michael Hanus (CAU Kiel, Germany) Herbert Kuchen (Univ. of Muenster, Germany) Francisco Lopez-Fraguas (Universidad Complutense de Madrid, Spain) James Lipton (Wesleyan University, USA) Mircea Marin (University of Tsukuba, Japan) Juan Jose Moreno-Navarro (Ministry of Science & Innovation, Spain) Brigitte Pientka (McGill University, Canada) From v.dijk.bas at gmail.com Fri Oct 16 05:15:12 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Oct 16 04:52:20 2009 Subject: [Haskell-cafe] How to reliably open and close resources in MonadIO in the presence of exceptions? Message-ID: > import Control.Monad.Trans ( MonadIO, liftIO ) > import Control.Exception ( throwIO, ArithException(DivideByZero), onException ) > import Foreign.Marshal.Alloc ( malloc, free ) > import Foreign.Storable ( poke, peek ) Suppose we define a function which receives a computation in an arbitrary monad that is capable of lifting IO actions and returns a computation in the same monad: > foo :: MonadIO m => m () -> m () In 'foo', I would like to open some resource (in this case: allocate memory) and after performing some lifted IO actions and some arbitrary computations in 'm' I want to close the resource (in this case: freeing the allocated memory). Of course the resource should also be closed when an exception is thrown in some lifted IO computation. If I was performing a computation directly in IO I could use: alloca :: Storable a => (Ptr a -> IO b) -> IO b which allocates the memory, performs some action on it and frees the memory after the action terminates (either normally or via an exception). Unfortunately the type of 'alloca' does not allow it to be used in our arbitrary monad 'm'. So it looks like I'm forced to manually allocate the memory using 'malloc' and finally free it using 'free'. To handle exceptions in lifted IO computations I have to put a (`onException` free ptr) around every lifted IO computation: For example: > foo action = do ptr <- liftIO malloc > liftIO $ putStrLn "aaa" `onException` free ptr > liftIO $ poke ptr (3 :: Int) `onException` free ptr > liftIO $ putStrLn "bbb" `onException` free ptr > action > x <- liftIO $ peek ptr `onException` free ptr > liftIO $ print x `onException` free ptr > liftIO $ putStrLn "ccc" `onException` free ptr > liftIO $ free ptr I find this rather ugly. What's worse is that exceptions, thrown in lifted IO computations in 'action' can't be handled! For example, the following won't free the memory: > bar :: MonadIO m => m () > bar = foo action > where > action = liftIO $ throwIO DivideByZero So my question is: How can I reliably open and close resources in MonadIO? And as a supplementary question: Is it possible to define a generalized alloca: genAlloca :: (MonadIO m, Storable a) => (Ptr a -> m b) -> m b Thanks, Bas From deniz.a.m.dogan at gmail.com Fri Oct 16 05:29:07 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Fri Oct 16 05:06:35 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> Message-ID: <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> 2009/10/16 Gregory Crosswhite : > In my humble opinion, one of the best editors for development of all time is > Leo: > > ? ? ? ?http://webpages.charter.net/edreamleo/front.html > > Leo takes the idea of "code folding" and gives you complete control over it. > ?That is, unlike other editors which only let you fold the code inside > if/while/for/etc. statements and which only show you an outline consisting > of a level for files and a level for function, Leo lets you structure the > levels of your outline arbitrarily so that you can "fold" arbitrary chunks > of code and do things like grouping together functions and files with a > similar purpose or implementation. ?By structuring your code as an outline, > you make it easier for others and yourself both to navigate through the code > and also to see at a glance the high-level structure. > > Anyway, just wanted to use this opportunity to plug my favorite tool. ?:-) > ?The downside about it is that the implementation sometimes feels a bit slow > and clunky, so part of me really hopes that at the very least people will > learn enough about this tool to take its ideas and steal them for other > editors! > > Cheers, > Greg > This should come as no surprise, but Emacs can do this as well. -- Deniz Dogan From v.reshetnikov at gmail.com Fri Oct 16 05:52:45 2009 From: v.reshetnikov at gmail.com (Vladimir Reshetnikov) Date: Fri Oct 16 05:30:13 2009 Subject: [Haskell-cafe] Why there is not standard Monoid instance for ZipList a? Message-ID: <4770d2590910160252q57e2910at99ed065f97e268f7@mail.gmail.com> I find the following instance very convenient: ------------------------------------------------------------------------ import Data.Monoid import Control.Applicative instance Monoid a => Monoid (ZipList a) where mempty = pure mempty mappend = liftA2 mappend ------------------------------------------------------------------------ Any reason why it is not in the standard library? Thanks, Vladimir -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/2ea2e0e2/attachment.html From v.dijk.bas at gmail.com Fri Oct 16 06:09:40 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Oct 16 05:46:48 2009 Subject: [Haskell-cafe] Re: How to reliably open and close resources in MonadIO in the presence of exceptions? In-Reply-To: References: Message-ID: On Fri, Oct 16, 2009 at 11:15 AM, Bas van Dijk wrote: >> import Control.Monad.Trans ? ( MonadIO, liftIO ) >> import Control.Exception ? ? ( throwIO, ArithException(DivideByZero), onException ) >> import Foreign.Marshal.Alloc ( malloc, free ) >> import Foreign.Storable ? ? ?( poke, peek ) > > Suppose we define a function which receives a computation in an > arbitrary monad that is capable of lifting IO actions and returns a > computation in the same monad: > >> foo :: MonadIO m => m () -> m () > > In 'foo', I would like to open some resource (in this case: allocate > memory) and after performing some lifted IO actions and some arbitrary > computations in 'm' I want to close the resource (in this case: > freeing the allocated memory). Of course the resource should also be > closed when an exception is thrown in some lifted IO computation. > > If I was performing a computation directly in IO I could use: > > alloca :: Storable a => (Ptr a -> IO b) -> IO b > > which allocates the memory, performs some action on it and frees the > memory after the action terminates (either normally or via an > exception). > > Unfortunately the type of 'alloca' does not allow it to be used in our > arbitrary monad 'm'. > > So it looks like I'm forced to manually allocate the memory using > 'malloc' and finally free it using 'free'. To handle exceptions in > lifted IO computations I have to put a (`onException` free ptr) around > every lifted IO computation: > > For example: > >> foo action = do ptr <- liftIO malloc >> ? ? ? ? ? ? ? ? liftIO $ putStrLn "aaa" ? ? ? `onException` free ptr >> ? ? ? ? ? ? ? ? liftIO $ poke ptr (3 :: Int) ?`onException` free ptr >> ? ? ? ? ? ? ? ? liftIO $ putStrLn "bbb" ? ? ? `onException` free ptr >> ? ? ? ? ? ? ? ? action >> ? ? ? ? ? ? ? ? x <- liftIO $ peek ptr ? ? ? ?`onException` free ptr >> ? ? ? ? ? ? ? ? liftIO $ print x ? ? ? ? ? ? ?`onException` free ptr >> ? ? ? ? ? ? ? ? liftIO $ putStrLn "ccc" ? ? ? `onException` free ptr >> ? ? ? ? ? ? ? ? liftIO $ free ptr > > I find this rather ugly. What's worse is that exceptions, thrown in > lifted IO computations in 'action' can't be handled! For example, the > following won't free the memory: > >> bar :: MonadIO m => m () >> bar = foo action >> ? ? where >> ? ? ? action = liftIO $ throwIO DivideByZero > > So my question is: How can I reliably open and close resources in MonadIO? > > And as a supplementary question: Is it possible to define a generalized alloca: > > genAlloca :: (MonadIO m, Storable a) => (Ptr a -> m b) -> m b > > Thanks, > > Bas > I could of course write a genAlloca if the MonadIO class was extended with a bracket method: ---------------------------------------------------------------------------------------------------- import qualified Control.Exception as E import Control.Exception ( throwIO, ArithException(DivideByZero) ) import Foreign.Marshal.Alloc ( malloc, free ) import Foreign.Ptr ( Ptr ) import Foreign.Storable ( Storable, poke, peek ) class Monad m => MonadIO m where liftIO :: IO a -> m a bracket :: IO a -> (a -> IO b) -> (a -> m c) -> m c instance MonadIO IO where liftIO = id bracket = E.bracket genAlloca :: (MonadIO m, Storable a) => (Ptr a -> m b) -> m b genAlloca = bracket malloc free foo :: MonadIO m => m () -> m () foo action = genAlloca $ \ptr -> do liftIO $ putStrLn "aaa" liftIO $ poke ptr (3 :: Int) liftIO $ putStrLn "bbb" action x <- liftIO $ peek ptr liftIO $ print x liftIO $ putStrLn "ccc" bar :: MonadIO m => m () bar = foo action where action = liftIO $ throwIO DivideByZero ---------------------------------------------------------------------------------------------------- Besides extending MonadIO with bracket, maybe it's also useful to extend it with: catch :: Exception e => m a -> (e -> m a) -> m a regards, Bas From bugfact at gmail.com Fri Oct 16 06:32:50 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Oct 16 06:09:58 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> Message-ID: If you're a Windows developer and don't want to spent time to learn all the alien emacs keyboard shortcuts, you can get going quickly by using this emacs patch: http://ourcomments.org/Emacs/EmacsW32.html Then use "set all to Emacs!W32" and your keys behave like all other editors on Windows. Of course I guess the Emacs shortcuts are deliberately chosen the way they are, but using these Emacs shortcuts makes it hard to also use any other editor on Windows IMO. On Fri, Oct 16, 2009 at 11:29 AM, Deniz Dogan wrote: > 2009/10/16 Gregory Crosswhite : > > In my humble opinion, one of the best editors for development of all time > is > > Leo: > > > > http://webpages.charter.net/edreamleo/front.html > > > > Leo takes the idea of "code folding" and gives you complete control over > it. > > That is, unlike other editors which only let you fold the code inside > > if/while/for/etc. statements and which only show you an outline > consisting > > of a level for files and a level for function, Leo lets you structure the > > levels of your outline arbitrarily so that you can "fold" arbitrary > chunks > > of code and do things like grouping together functions and files with a > > similar purpose or implementation. By structuring your code as an > outline, > > you make it easier for others and yourself both to navigate through the > code > > and also to see at a glance the high-level structure. > > > > Anyway, just wanted to use this opportunity to plug my favorite tool. > :-) > > The downside about it is that the implementation sometimes feels a bit > slow > > and clunky, so part of me really hopes that at the very least people will > > learn enough about this tool to take its ideas and steal them for other > > editors! > > > > Cheers, > > Greg > > > > This should come as no surprise, but Emacs can do this as well. > > -- > Deniz Dogan > _______________________________________________ > 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/20091016/d4cc8889/attachment.html From RafaelGCPP.Linux at gmail.com Fri Oct 16 06:40:58 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Fri Oct 16 06:18:06 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> Message-ID: <351ff25e0910160340r78fd599bwbe78133a6227ec70@mail.gmail.com> Real programmers use butterflies!! http://xkcd.com/378/ The best editor is the one that suites YOU better. I use VIM, even in Windows, but that's me! Best regards, Rafael On Fri, Oct 16, 2009 at 07:32, Peter Verswyvelen wrote: > If you're a Windows developer and don't want to spent time to learn all the > alien emacs keyboard shortcuts, you can get going quickly by using this > emacs patch: > http://ourcomments.org/Emacs/EmacsW32.html > > Then use "set all to > Emacs!W32" and your keys behave like all other editors on Windows. > > Of course I guess the Emacs shortcuts are deliberately chosen the way they > are, but using these Emacs shortcuts makes it hard to also use any other > editor on Windows IMO. > > On Fri, Oct 16, 2009 at 11:29 AM, Deniz Dogan wrote: > >> 2009/10/16 Gregory Crosswhite : >> > In my humble opinion, one of the best editors for development of all >> time is >> > Leo: >> > >> > http://webpages.charter.net/edreamleo/front.html >> > >> > Leo takes the idea of "code folding" and gives you complete control over >> it. >> > That is, unlike other editors which only let you fold the code inside >> > if/while/for/etc. statements and which only show you an outline >> consisting >> > of a level for files and a level for function, Leo lets you structure >> the >> > levels of your outline arbitrarily so that you can "fold" arbitrary >> chunks >> > of code and do things like grouping together functions and files with a >> > similar purpose or implementation. By structuring your code as an >> outline, >> > you make it easier for others and yourself both to navigate through the >> code >> > and also to see at a glance the high-level structure. >> > >> > Anyway, just wanted to use this opportunity to plug my favorite tool. >> :-) >> > The downside about it is that the implementation sometimes feels a bit >> slow >> > and clunky, so part of me really hopes that at the very least people >> will >> > learn enough about this tool to take its ideas and steal them for other >> > editors! >> > >> > Cheers, >> > Greg >> > >> >> This should come as no surprise, but Emacs can do this as well. >> >> -- >> Deniz Dogan >> _______________________________________________ >> 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 > > -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/f310fa9d/attachment.html From Patrick.Browne at comp.dit.ie Fri Oct 16 06:42:22 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Fri Oct 16 06:21:00 2009 Subject: [Haskell-cafe] Merging modules Message-ID: <4AD84E0E.5060600@comp.dit.ie> Hi, I want to establish the strengths and weakness of the Haskell module system for the ontology merging task (I know it was not designed for this!). I wish to make a new module (MERGEDONTOLOGY) from three input modules one of which is common to the other two. The desired merge should contain the following data types: Woman FinancialBank HumanBeing RiverBank Which are all identifiable without any qualifying module names. Below is the detailed requirement and my first attempt at this task in Haskell. I would be grateful for any information on how to merge these modules giving a set of unique unqualified types (i.e. without reference to their originating modules). Regards, Pat ======================== Informal Specification ======================== The diagram and text below explain the requirement MERGEDONTOLOGY { Woman, RiverBank, FinancialBank, HumanBeing} /\ /\ / \ / \ / \ / \ / \ / \ ONTOLOGY1 ONTOLOGY2 {Woman, Bank, Person} {Woman, Bank, Human} /\ /\ \ / \ / \ / \ / \ / \ / \ / {Woman , Person} COMMMON This example includes both synonyms and homonyms. 1)The Woman sort (or data type) should be the same in all modules, there is only one Woman sort and it is named as such in each module. Hence there should be only one MERGEDONTOLOGY.Woman. 2)There is only one sort MERGEDONTOLOGY.HumanBeing, but there are 3 synonyms for it called ONTOLOGY2.Human, ONTOLOGY1.Person, and COMMON.Person. The last sentence considers ONTOLOGY1.Person and COMMON.Person as synonyms; they have different qualifiers but the intention is that they represnt the same thing. Hence should be mapped to same MERGEDONTOLOGY.HumanBeing. To do this (in Maude) COMMON.Person was renamed to ONTOLOGY2.Human which in turn was renamed to MERGEDONTOLOGY.HumanBeing. 3)The homonyms are ONTOLOGY1.Bank and ONTOLOGY2.Bank should become distinct sorts MERGEDONTOLOGY.RiverBank and MERGEDONTOLOGY.FinancialBank in the final ontology at the top of the diagram. ================================================ My first attemt at merging using Haskell modules ================================================= module COMMON where data Woman = WomanC data Person = PersonC module ONTOLOGY1 where import COMMON data Bank = BankC module ONTOLOGY2 where import COMMON data Bank = BankC module MERGEDONTOLOGY where import ONTOLOGY1 import ONTOLOGY2 If I use qualified names all the constructors are interpreted correctly MERGEDONTOLOGY> :t COMMON.WomanC COMMON.WomanC :: COMMON.Woman MERGEDONTOLOGY> :t COMMON.PersonC COMMON.PersonC :: COMMON.Person MERGEDONTOLOGY> :t ONTOLOGY2.BankC ONTOLOGY2.BankC :: ONTOLOGY2.Bank MERGEDONTOLOGY> :t ONTOLOGY1.BankC ONTOLOGY1.BankC :: ONTOLOGY1.Bank MERGEDONTOLOGY> :t COMMON.Woman However, I wish that these types and constructors be fully defined in the context of the MERGEDONTOLOGY. I have tried type synonyms and newtypes. type RiverBank = ONTOLOGY1.Bank type FinancialBank = ONTOLOGY2.Bank newtype RiverBank = BankC Int I have not explored import modes or qualified imports. From Alistair.Bayley at invesco.com Fri Oct 16 07:16:52 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Oct 16 06:54:00 2009 Subject: [Haskell-cafe] Re: How to reliably open and close resources inMonadIO in the presence of exceptions? In-Reply-To: References: Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911026396@GBLONXMB02.corp.amvescap.net> > -----Original Message----- > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Bas van Dijk > > > I could of course write a genAlloca if the MonadIO class was extended > with a bracket method: > > Besides extending MonadIO with bracket, maybe it's also useful to > extend it with: > > catch :: Exception e => m a -> (e -> m a) -> m a You might want this library: http://hackage.haskell.org/packages/archive/MonadCatchIO-transformers/0. 0.1.0/doc/html/Control-Monad-CatchIO.html There's also an mtl version; not sure which is to be prefered. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From mf-hcafe-15c311f0c at etc-network.de Fri Oct 16 07:36:45 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Fri Oct 16 07:14:03 2009 Subject: [Haskell-cafe] Merging modules In-Reply-To: <4AD84E0E.5060600@comp.dit.ie> References: <4AD84E0E.5060600@comp.dit.ie> Message-ID: <20091016113645.GH3252@yoyo> On Fri, Oct 16, 2009 at 11:42:22AM +0100, pat browne wrote: > To: haskell-cafe@haskell.org > From: pat browne > Date: Fri, 16 Oct 2009 11:42:22 +0100 > Subject: [Haskell-cafe] Merging modules > > Hi, > I want to establish the strengths and weakness of the Haskell module > system for the ontology merging task (I know it was not designed for > this!). I wish to make a new module (MERGEDONTOLOGY) from three input > modules one of which is common to the other two. > The desired merge should contain the following data types: > Woman FinancialBank HumanBeing RiverBank > Which are all identifiable without any qualifying module names. > > Below is the detailed requirement and my first attempt at this task in > Haskell. I would be grateful for any information on how to merge these > modules giving a set of unique unqualified types (i.e. without reference > to their originating modules). > > Regards, > Pat > > > > > ======================== > Informal Specification > ======================== > > The diagram and text below explain the requirement > > MERGEDONTOLOGY > { Woman, RiverBank, FinancialBank, HumanBeing} > /\ /\ > / \ > / \ > / \ > / \ > / \ > / \ > > ONTOLOGY1 ONTOLOGY2 > {Woman, Bank, Person} {Woman, Bank, Human} > /\ /\ > \ / > \ / > \ / > \ / > \ / > \ / > \ / > {Woman , Person} > COMMMON > > This example includes both synonyms and homonyms. > 1)The Woman sort (or data type) should be the same in all modules, there > is only one Woman sort and it is named as such in each module. Hence > there should be only one MERGEDONTOLOGY.Woman. > > 2)There is only one sort MERGEDONTOLOGY.HumanBeing, but there are 3 > synonyms for it called ONTOLOGY2.Human, ONTOLOGY1.Person, and > COMMON.Person. The last sentence considers ONTOLOGY1.Person and > COMMON.Person as synonyms; they have different qualifiers but the > intention is that they represnt the same thing. Hence should be mapped > to same MERGEDONTOLOGY.HumanBeing. To do this (in Maude) COMMON.Person > was renamed to ONTOLOGY2.Human which in turn was renamed to > MERGEDONTOLOGY.HumanBeing. > > 3)The homonyms are ONTOLOGY1.Bank and ONTOLOGY2.Bank should become > distinct sorts MERGEDONTOLOGY.RiverBank and > MERGEDONTOLOGY.FinancialBank in the final ontology at the top of the > diagram. > > > ================================================ > My first attemt at merging using Haskell modules > ================================================= > module COMMON where > data Woman = WomanC > data Person = PersonC > > > > module ONTOLOGY1 where > import COMMON > data Bank = BankC > > > module ONTOLOGY2 where > import COMMON > data Bank = BankC > > > > module MERGEDONTOLOGY where > import ONTOLOGY1 > import ONTOLOGY2 > > If I use qualified names all the constructors are interpreted correctly > MERGEDONTOLOGY> :t COMMON.WomanC > COMMON.WomanC :: COMMON.Woman > MERGEDONTOLOGY> :t COMMON.PersonC > COMMON.PersonC :: COMMON.Person > MERGEDONTOLOGY> :t ONTOLOGY2.BankC > ONTOLOGY2.BankC :: ONTOLOGY2.Bank > MERGEDONTOLOGY> :t ONTOLOGY1.BankC > ONTOLOGY1.BankC :: ONTOLOGY1.Bank > MERGEDONTOLOGY> :t COMMON.Woman > > However, I wish that these types and constructors be fully defined in > the context of the MERGEDONTOLOGY. I have tried type synonyms and newtypes. > type RiverBank = ONTOLOGY1.Bank > type FinancialBank = ONTOLOGY2.Bank > newtype RiverBank = BankC Int > I have not explored import modes or qualified imports. The way you import ONTOLOGY* and COMMON without "qualified", you can use any name that you import without qualifier, as long as the name is unique over all imported modules. Where names would conflict, you can list the names to be imported explicitly, and omit the names that cause conflicts: import ONTOLOGY1 (Woman (..), Person (..)) or list the names to be omitted: import ONTOLOGY1 hiding (Bank (..)) In your example, you want both banks (from both ontologies), and name them differently. If this is a common thing in your application, perhaps you want to use type classes instead of plain data types, or one of the other many extensions to Hindley-Milner. Or you stick with module qualifiers wherever ambiguity error messages require it. May be the safest and most convenient way. This is all pretty basic stuff. Not sure any of it is very helpful. (Why do you want to spread an ontology over several Haskell modules?) -matthias From Patrick.Browne at comp.dit.ie Fri Oct 16 07:56:30 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Fri Oct 16 07:35:49 2009 Subject: [Haskell-cafe] Merging modules In-Reply-To: <20091016113645.GH3252@yoyo> References: <4AD84E0E.5060600@comp.dit.ie> <20091016113645.GH3252@yoyo> Message-ID: <4AD85F6E.7020207@comp.dit.ie> > This is all pretty basic stuff. Not sure any of it is very helpful. > (Why do you want to spread an ontology over several Haskell modules?) > > > -matthias Yes it is very helpful, I have limited time to study Haskell. The reason for spreading the information over modules is to simulate actual ontologies and the mappings to other ontologies. My next step is, as you suggested, to use type classes. My overall thesis is the study of current algebraic specification and programming techniques. Thanks, Pat mf-hcafe-15c311f0c@etc-network.de wrote: > On Fri, Oct 16, 2009 at 11:42:22AM +0100, pat browne wrote: >> To: haskell-cafe@haskell.org >> From: pat browne >> Date: Fri, 16 Oct 2009 11:42:22 +0100 >> Subject: [Haskell-cafe] Merging modules >> >> Hi, >> I want to establish the strengths and weakness of the Haskell module >> system for the ontology merging task (I know it was not designed for >> this!). I wish to make a new module (MERGEDONTOLOGY) from three input >> modules one of which is common to the other two. >> The desired merge should contain the following data types: >> Woman FinancialBank HumanBeing RiverBank >> Which are all identifiable without any qualifying module names. >> >> Below is the detailed requirement and my first attempt at this task in >> Haskell. I would be grateful for any information on how to merge these >> modules giving a set of unique unqualified types (i.e. without reference >> to their originating modules). >> >> Regards, >> Pat >> >> >> >> >> ======================== >> Informal Specification >> ======================== >> >> The diagram and text below explain the requirement >> >> MERGEDONTOLOGY >> { Woman, RiverBank, FinancialBank, HumanBeing} >> /\ /\ >> / \ >> / \ >> / \ >> / \ >> / \ >> / \ >> >> ONTOLOGY1 ONTOLOGY2 >> {Woman, Bank, Person} {Woman, Bank, Human} >> /\ /\ >> \ / >> \ / >> \ / >> \ / >> \ / >> \ / >> \ / >> {Woman , Person} >> COMMMON >> >> This example includes both synonyms and homonyms. >> 1)The Woman sort (or data type) should be the same in all modules, there >> is only one Woman sort and it is named as such in each module. Hence >> there should be only one MERGEDONTOLOGY.Woman. >> >> 2)There is only one sort MERGEDONTOLOGY.HumanBeing, but there are 3 >> synonyms for it called ONTOLOGY2.Human, ONTOLOGY1.Person, and >> COMMON.Person. The last sentence considers ONTOLOGY1.Person and >> COMMON.Person as synonyms; they have different qualifiers but the >> intention is that they represnt the same thing. Hence should be mapped >> to same MERGEDONTOLOGY.HumanBeing. To do this (in Maude) COMMON.Person >> was renamed to ONTOLOGY2.Human which in turn was renamed to >> MERGEDONTOLOGY.HumanBeing. >> >> 3)The homonyms are ONTOLOGY1.Bank and ONTOLOGY2.Bank should become >> distinct sorts MERGEDONTOLOGY.RiverBank and >> MERGEDONTOLOGY.FinancialBank in the final ontology at the top of the >> diagram. >> >> >> ================================================ >> My first attemt at merging using Haskell modules >> ================================================= >> module COMMON where >> data Woman = WomanC >> data Person = PersonC >> >> >> >> module ONTOLOGY1 where >> import COMMON >> data Bank = BankC >> >> >> module ONTOLOGY2 where >> import COMMON >> data Bank = BankC >> >> >> >> module MERGEDONTOLOGY where >> import ONTOLOGY1 >> import ONTOLOGY2 >> >> If I use qualified names all the constructors are interpreted correctly >> MERGEDONTOLOGY> :t COMMON.WomanC >> COMMON.WomanC :: COMMON.Woman >> MERGEDONTOLOGY> :t COMMON.PersonC >> COMMON.PersonC :: COMMON.Person >> MERGEDONTOLOGY> :t ONTOLOGY2.BankC >> ONTOLOGY2.BankC :: ONTOLOGY2.Bank >> MERGEDONTOLOGY> :t ONTOLOGY1.BankC >> ONTOLOGY1.BankC :: ONTOLOGY1.Bank >> MERGEDONTOLOGY> :t COMMON.Woman >> >> However, I wish that these types and constructors be fully defined in >> the context of the MERGEDONTOLOGY. I have tried type synonyms and newtypes. >> type RiverBank = ONTOLOGY1.Bank >> type FinancialBank = ONTOLOGY2.Bank >> newtype RiverBank = BankC Int >> I have not explored import modes or qualified imports. > > The way you import ONTOLOGY* and COMMON without "qualified", you can > use any name that you import without qualifier, as long as the name is > unique over all imported modules. > > Where names would conflict, you can list the names to be imported > explicitly, and omit the names that cause conflicts: > > import ONTOLOGY1 (Woman (..), Person (..)) > > or list the names to be omitted: > > import ONTOLOGY1 hiding (Bank (..)) > > In your example, you want both banks (from both ontologies), and name > them differently. If this is a common thing in your application, > perhaps you want to use type classes instead of plain data types, or > one of the other many extensions to Hindley-Milner. Or you stick with > module qualifiers wherever ambiguity error messages require it. May > be the safest and most convenient way. > > This is all pretty basic stuff. Not sure any of it is very helpful. > (Why do you want to spread an ontology over several Haskell modules?) > > > -matthias > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jvranish at gmail.com Fri Oct 16 08:56:28 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Oct 16 08:33:35 2009 Subject: [Haskell-cafe] Why there is not standard Monoid instance for ZipList a? In-Reply-To: <4770d2590910160252q57e2910at99ed065f97e268f7@mail.gmail.com> References: <4770d2590910160252q57e2910at99ed065f97e268f7@mail.gmail.com> Message-ID: Nope, Other than possibly adding library clutter. I have a package that provides many instances and common functions for ZipLists. Eventually I might stick it on hackage, but currently it's here: http://github.com/jvranish/ZipList I really with there was a way to switch Applicative (or other) instances for list (or other) types. Then we wouldn't have this problem. - Job On Fri, Oct 16, 2009 at 5:52 AM, Vladimir Reshetnikov < v.reshetnikov@gmail.com> wrote: > I find the following instance very convenient: > ------------------------------------------------------------------------ > import Data.Monoid > import Control.Applicative > instance Monoid a => Monoid (ZipList a) where > mempty = pure mempty > mappend = liftA2 mappend > ------------------------------------------------------------------------ > > Any reason why it is not in the standard library? > > Thanks, > Vladimir > > _______________________________________________ > 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/20091016/2642c704/attachment.html From mf-hcafe-15c311f0c at etc-network.de Fri Oct 16 09:04:26 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Fri Oct 16 08:41:42 2009 Subject: [Haskell-cafe] Merging modules In-Reply-To: <4AD85F6E.7020207@comp.dit.ie> References: <4AD84E0E.5060600@comp.dit.ie> <20091016113645.GH3252@yoyo> <4AD85F6E.7020207@comp.dit.ie> Message-ID: <20091016130426.GJ3252@yoyo> On Fri, Oct 16, 2009 at 12:56:30PM +0100, pat browne wrote: > To: haskell-cafe@haskell.org > From: pat browne > Date: Fri, 16 Oct 2009 12:56:30 +0100 > Subject: Re: [Haskell-cafe] Merging modules > > > > > This is all pretty basic stuff. Not sure any of it is very helpful. > > (Why do you want to spread an ontology over several Haskell modules?) > > > > > > -matthias > > Yes it is very helpful, I have limited time to study Haskell. excellent (: > The reason for spreading the information over modules is to simulate > actual ontologies and the mappings to other ontologies. My next step is, > as you suggested, to use type classes. My overall thesis is the study of > current algebraic specification and programming techniques. another thing you may want to know about is template haskell (what haskellers use instead of lisp macros). instead of creating trivial type instances for hundrets or thousands of type classes, you can call one macro for each class / data pair that unfolds into both. this may make your source code a lot more concise and elegant. please post the outcome of this if you can find the time. cheers, matthias From jp at moresmau.fr Fri Oct 16 09:01:40 2009 From: jp at moresmau.fr (JP Moresmau) Date: Fri Oct 16 08:42:32 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> <351ff25e0910160340r78fd599bwbe78133a6227ec70@mail.gmail.com> Message-ID: Hello I've been working on eclipse-fp to bring it up to working order again, so if you like Eclipse, you can download the source from git://github.com/JPMoresmau/eclipsefp.git (hopefully there will be a binary release soon). This is based on my customized Scion library (git://github.com/JPMoresmau/scion.git). I'm using Windows myself. JP Moresmau From johan.tibell at gmail.com Fri Oct 16 09:06:02 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Fri Oct 16 08:43:29 2009 Subject: [Haskell-cafe] ANN: Haskell Hackathon in Zurich, Switzerland Message-ID: <90889fe70910160606u3630210dr8c90a9da281e1c7a@mail.gmail.com> Hi all! We are in the early stages of planning a Haskell hackathon/get together, ZuriHac, to be held this March at the Google office, in Zurich, Switzerland. Right now we're looking at four possible dates (Friday-Sunday): March 5-7, March 12-14, March 19-21, or March 26-28. If you might be interested in attending, please add your name on the wiki page: http://haskell.org/haskellwiki/ZuriHac#Possible_Attendees If you don't have an account on the wiki feel free to just respond to this email. If there are any dates that absolutely don't work for you then please note them on the wiki. I'll come back with a finalized date and more details soon. Hope to see you in Zurich! Johan Tibell (tibbe) From monnier at iro.umontreal.ca Fri Oct 16 09:30:53 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Fri Oct 16 09:08:29 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> <351ff25e0910160340r78fd599bwbe78133a6227ec70@mail.gmail.com> Message-ID: > Real programmers use butterflies!! In Emacs-23, this is available as M-x butterfly C-M-c Too bad it wasn't around when I was writing my thesis, Stefan From doaitse at swierstra.net Fri Oct 16 10:24:21 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Fri Oct 16 10:01:29 2009 Subject: [Haskell-cafe] Lecture Notes Advanced Functional programming available Message-ID: I am happy to announce that the rworked lecture notes for the 6th Advance Functional programming summer school have become available. For further information about the lecture notes: http://www.springer.com/computer/programming/book/978-3-642-04651-3?cm_mmc=NBA-_-Oct-09_EAST_4063641-_-product-_-978-3-642-04651-3 Contents: ? Umut Acar (Toyota Technological Institute, University of Chicago, USA): Self-Adjusting Computation ? Richard Bird (University of Oxford, UK): Spider Spinning ? Olivier Danvy (University of Aarhus, DK): On deriving abstract machines from interpreters and calculi ? Johan Jeuring (Utrecht University, NL): Libraries for Generic Programming in Haskell ? Ulf Norell (Chalmers University, SE): Dependently Typed Programming in Agda ? Simon Peyton Jones and Satnam Singh (update) (Microsoft Research, UK): Parallel Functional Programming ? Rinus Plasmeijer (Radboud University Nijmegen, NL): Specifying Interactive Workflows for the Web Doaitse From v.dijk.bas at gmail.com Fri Oct 16 11:02:39 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Oct 16 10:39:46 2009 Subject: [Haskell-cafe] Re: How to reliably open and close resources inMonadIO in the presence of exceptions? In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911026396@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA911026396@GBLONXMB02.corp.amvescap.net> Message-ID: On Fri, Oct 16, 2009 at 1:16 PM, Bayley, Alistair wrote: > You might want this library: > http://hackage.haskell.org/packages/archive/MonadCatchIO-transformers/0. > 0.1.0/doc/html/Control-Monad-CatchIO.html Thanks, this is exactly what I need! regards, Bas From tanimoto at arizona.edu Fri Oct 16 11:43:37 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Fri Oct 16 11:21:05 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: On Thu, Oct 15, 2009 at 9:19 PM, Stefan Monnier wrote: >> The only thing I haven't figured out is how to do tab-completion of >> words in the ghci buffer. ?Do I need to use a different key >> combination? ?I couldn't find that in the documentation. > > I think it's just a missing feature. > OK! Let me know if there's anything I can do to help. I noticed that other modes, e.g. ESS for R, do have tab-completion, but just skimming the source code I couldn't find how exactly they do that. Paulo From Patrick.Browne at comp.dit.ie Fri Oct 16 12:58:04 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Fri Oct 16 12:36:54 2009 Subject: [Haskell-cafe] Merging classes Message-ID: <4AD8A61C.2010004@comp.dit.ie> Hi, Following on from my earlier *Merging modules* email, where I tried to simulate ontology merging with Haskell modules; http://article.gmane.org/gmane.comp.lang.haskell.cafe/64943 I *think* that the type of merging that I am attempting is difficult with modules so I gave classes a try. I did not get very far (see below). Perhaps I need a combination of type classes and modules. In fairness this is more of a specification task than a programming task and perhaps I am barking up the wrong tree. Any help appreciated. Regards, Pat ============================================== attempting an ontology merge with type classes For specification of requirement see http://article.gmane.org/gmane.comp.lang.haskell.cafe/64943 ============================================== -- Data types for COMMON data Woman = WomanC data Person = PersonC -- Additional data type for ONTOLOGY1 data Bank = BankC -- Additional data type for ONTOLOGY2 -- but how do I let type Bank have the same name in both classes and -- still be distinct (homonyms) in the merged class -- data Bank = BankC class COMMON a b where class (COMMON a b) => ONTOLOGY1 a b where class (COMMON a b) => ONTOLOGY2 a b where class (ONTOLOGY1 a b, ONTOLOGY2 a b) => MERGEDONTOLOGY a b where -- not really sure how to proceed from here instance COMMON Woman Person where From gcross at phys.washington.edu Fri Oct 16 13:41:05 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Fri Oct 16 13:18:43 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> Message-ID: <8A5A333D-32FE-42F8-A4CF-2BDD7A20F4AC@phys.washington.edu> While Emacs has some outline capabilities, they are not at this time remotely as nice or as powerful as Leo, which among other things: *) does not require that you manually specify the depth of each node *) can automatically concatenate child nodes together so that you don't have to insert a section heading for each child node inside of the parent *) has a separate navigation and editing panel, rather than doing everything inline *) allows you to view your whole project as an outline spanning multiple files in multiple directories *) automatically takes care of embedding the outline information into the source files for you, so that you can use a single set of outline commands for source files in any language and Leo will work out how to translate them into comments behind-the-scenes *) allows you to "clone" nodes so that you can have multiple views of your project; this way, for example, when working on a feature that spans several nodes you can clone all of the affected nodes and gather them together in one place *) has a special command "@ .... @c" that lets you easily put multi- line comments in source files even if the language only supports line comments Don't get me wrong, I would welcome seeing Emacs have outlining features for code development that are as powerful as Leo's, but it isn't there yet and hacking what is there to bring it up to parity with Leo would be highly non-trivial. - Greg On Oct 16, 2009, at 2:29 AM, Deniz Dogan wrote: > 2009/10/16 Gregory Crosswhite : >> In my humble opinion, one of the best editors for development of >> all time is >> Leo: >> >> http://webpages.charter.net/edreamleo/front.html >> >> Leo takes the idea of "code folding" and gives you complete control >> over it. >> That is, unlike other editors which only let you fold the code >> inside >> if/while/for/etc. statements and which only show you an outline >> consisting >> of a level for files and a level for function, Leo lets you >> structure the >> levels of your outline arbitrarily so that you can "fold" arbitrary >> chunks >> of code and do things like grouping together functions and files >> with a >> similar purpose or implementation. By structuring your code as an >> outline, >> you make it easier for others and yourself both to navigate through >> the code >> and also to see at a glance the high-level structure. >> >> Anyway, just wanted to use this opportunity to plug my favorite >> tool. :-) >> The downside about it is that the implementation sometimes feels a >> bit slow >> and clunky, so part of me really hopes that at the very least >> people will >> learn enough about this tool to take its ideas and steal them for >> other >> editors! >> >> Cheers, >> Greg >> > > This should come as no surprise, but Emacs can do this as well. > > -- > Deniz Dogan From waldmann at imn.htwk-leipzig.de Fri Oct 16 13:52:27 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Oct 16 13:29:51 2009 Subject: [Haskell-cafe] package name in TypeRep? Message-ID: <4AD8B2DB.6040500@imn.htwk-leipzig.de> Dear all, I want a function that produces the URL of the haddocumentation of a given type, generically. My solution is that the argument (type) is an instance of Data.Typeable and I am parsing the output of show of the TypeRep, cf. http://dfa.imn.htwk-leipzig.de/cgi-bin/cvsweb/common/Gateway/Help.hs?rev=1.11 That stops working when I split my project into several packages. Is there a way to obtain the package name from the TypeRep? Because I seem to need it to procuce the correct URL. Or else, is there a way to merge all the per-package haddock outputs? Perhaps a pseudo-package that imports all and re-exports everything? Best - Johannes. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/acdaaba3/signature.bin From andrewcoppin at btinternet.com Fri Oct 16 14:19:46 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 16 13:56:52 2009 Subject: [Haskell-cafe] x -> String Message-ID: <4AD8B942.5070202@btinternet.com> Is there any way that you can turn an arbitrary Haskell value into a string? I rephrase: There *is* a way to turn arbitrary values into strings. I know there is, because the GHCi debugger *does* it. The question is, does anybody know of an /easy/ way to do this? Basically, I'm writing a mutable container implementation. It can hold any type of data, but it would massively aid debugging if I could actually print out what's in it. On the other hand, I don't want to alter the entire program to have Show constraints everywhere just so I can print out some debug traces (and then alter everything back again afterwards once I'm done debugging). Anybody know of a way to do this? (As it happens, the values I'm testing with are all Showable anyway, but the type checker doesn't know that...) From dav.vire+haskell at gmail.com Fri Oct 16 14:22:00 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Fri Oct 16 13:59:05 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD8B942.5070202@btinternet.com> References: <4AD8B942.5070202@btinternet.com> Message-ID: <4c88418c0910161122k54978944q41b3de6d3bbf2943@mail.gmail.com> On Fri, Oct 16, 2009 at 8:19 PM, Andrew Coppin wrote: > Is there any way that you can turn an arbitrary Haskell value into a string? > I rephrase: There *is* a way to turn arbitrary values into strings. I know > there is, because the GHCi debugger *does* it. The question is, does anybody > know of an /easy/ way to do this? Ghci only displays values with a Show instance. From andrewcoppin at btinternet.com Fri Oct 16 14:26:38 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 16 14:03:44 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4c88418c0910161122k54978944q41b3de6d3bbf2943@mail.gmail.com> References: <4AD8B942.5070202@btinternet.com> <4c88418c0910161122k54978944q41b3de6d3bbf2943@mail.gmail.com> Message-ID: <4AD8BADE.3070105@btinternet.com> David Virebayre wrote: > On Fri, Oct 16, 2009 at 8:19 PM, Andrew Coppin > wrote: > >> Is there any way that you can turn an arbitrary Haskell value into a string? >> > > >> I rephrase: There *is* a way to turn arbitrary values into strings. I know >> there is, because the GHCi debugger *does* it. The question is, does anybody >> know of an /easy/ way to do this? >> > > Ghci only displays values with a Show instance. > Well, I can live with getting an empty string if no Show instance is available. But I can't figure out how to even do that... From pumpkingod at gmail.com Fri Oct 16 14:27:37 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Oct 16 14:04:43 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD8B942.5070202@btinternet.com> References: <4AD8B942.5070202@btinternet.com> Message-ID: GHCi can't show you functions can it? Unless you have a Show instance for functions loaded. I think the basic answer is no, not even with crazy unsafe stuff, because without the typeclass constraint GHC doesn't know to pass around the secret dictionary containing the methods that tell it how to show your data. On Fri, Oct 16, 2009 at 2:19 PM, Andrew Coppin wrote: > Is there any way that you can turn an arbitrary Haskell value into a string? > > I rephrase: There *is* a way to turn arbitrary values into strings. I know > there is, because the GHCi debugger *does* it. The question is, does anybody > know of an /easy/ way to do this? > > Basically, I'm writing a mutable container implementation. It can hold any > type of data, but it would massively aid debugging if I could actually print > out what's in it. On the other hand, I don't want to alter the entire > program to have Show constraints everywhere just so I can print out some > debug traces (and then alter everything back again afterwards once I'm done > debugging). > > Anybody know of a way to do this? (As it happens, the values I'm testing > with are all Showable anyway, but the type checker doesn't know that...) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jochem at functor.nl Fri Oct 16 14:29:07 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Fri Oct 16 14:06:15 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD8B942.5070202@btinternet.com> References: <4AD8B942.5070202@btinternet.com> Message-ID: <4AD8BB73.4030307@functor.nl> Andrew Coppin wrote: > Is there any way that you can turn an arbitrary Haskell value into a > string? No, the only values of type a -> String are the constant functions and _|_. > I rephrase: There *is* a way to turn arbitrary values into strings. I > know there is, because the GHCi debugger *does* it. The question is, > does anybody know of an /easy/ way to do this? No. GHCi does not always do this: Prelude Data.Ratio> let plus1 = (+1) Prelude Data.Ratio> plus1 :1:0: No instance for (Show (a -> a)) arising from a use of `print' at :1:0-4 Possible fix: add an instance declaration for (Show (a -> a)) In a stmt of a 'do' expression: print it Prelude Data.Ratio> > Basically, I'm writing a mutable container implementation. It can hold > any type of data, but it would massively aid debugging if I could > actually print out what's in it. On the other hand, I don't want to > alter the entire program to have Show constraints everywhere just so I > can print out some debug traces (and then alter everything back again > afterwards once I'm done debugging). This is not advisable, as you see. > Anybody know of a way to do this? (As it happens, the values I'm testing > with are all Showable anyway, but the type checker doesn't know that...) What is the problem with adding a function showMyContainer :: (Show a) => Container a -> String ? In this case you can show your container (for debugging purposes), but only if you have Showable elements in your container. Cheers, Jochem -- Jochem Berndsen | jochem@functor.nl | jochem@????.com From bulat.ziganshin at gmail.com Fri Oct 16 14:37:16 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Oct 16 14:14:28 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD8B942.5070202@btinternet.com> References: <4AD8B942.5070202@btinternet.com> Message-ID: <1938956002.20091016223716@gmail.com> Hello Andrew, Friday, October 16, 2009, 10:19:46 PM, you wrote: > actually print out what's in it. On the other hand, I don't want to > alter the entire program to have Show constraints everywhere just so I > can print out some debug traces (and then alter everything back again > afterwards once I'm done debugging). i personally just never use explicit function type declarations. this way constraints are added and removed automatically depending on functions you are using inside -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From andrewcoppin at btinternet.com Fri Oct 16 14:40:16 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 16 14:17:21 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD8BB73.4030307@functor.nl> References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> Message-ID: <4AD8BE10.8020105@btinternet.com> Jochem Berndsen wrote: > >> I rephrase: There *is* a way to turn arbitrary values into strings. I >> know there is, because the GHCi debugger *does* it. The question is, >> does anybody know of an /easy/ way to do this? >> > > No. GHCi does not always do this: > > Prelude Data.Ratio> let plus1 = (+1) > Prelude Data.Ratio> plus1 > > :1:0: > No instance for (Show (a -> a)) > arising from a use of `print' at :1:0-4 > Possible fix: add an instance declaration for (Show (a -> a)) > In a stmt of a 'do' expression: print it > Prelude Data.Ratio> > The GHCi *debugger* can print out even values for which no Show instance exists. (But yes, it fails to print anything interesting for function types... It works for ADTs that don't have Show though.) >> Anybody know of a way to do this? (As it happens, the values I'm testing >> with are all Showable anyway, but the type checker doesn't know that...) >> > > What is the problem with adding a function > showMyContainer :: (Show a) => Container a -> String > ? > In this case you can show your container (for debugging purposes), but > only if you have Showable elements in your container. > This could plausibly work... From pumpkingod at gmail.com Fri Oct 16 14:46:23 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Oct 16 14:23:30 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD8BE10.8020105@btinternet.com> References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> Message-ID: My GHCi can't do that :o I just wrote data A = B | C and loaded the file into GHCi. Typing B gives me: :1:0: No instance for (Show A) arising from a use of `print' at :1:0 Possible fix: add an instance declaration for (Show A) In a stmt of a 'do' expression: print it The error also gives an idea of what GHCi is doing behind the scenes: it's just calling print, which has a Show constraint. On Fri, Oct 16, 2009 at 2:40 PM, Andrew Coppin wrote: > Jochem Berndsen wrote: >> >>> I rephrase: There *is* a way to turn arbitrary values into strings. I >>> know there is, because the GHCi debugger *does* it. The question is, >>> does anybody know of an /easy/ way to do this? >>> >> >> No. GHCi does not always do this: >> >> Prelude Data.Ratio> let plus1 = (+1) >> Prelude Data.Ratio> plus1 >> >> :1:0: >> ? ?No instance for (Show (a -> a)) >> ? ? ?arising from a use of `print' at :1:0-4 >> ? ?Possible fix: add an instance declaration for (Show (a -> a)) >> ? ?In a stmt of a 'do' expression: print it >> Prelude Data.Ratio> >> > > The GHCi *debugger* can print out even values for which no Show instance > exists. (But yes, it fails to print anything interesting for function > types... It works for ADTs that don't have Show though.) > >>> Anybody know of a way to do this? (As it happens, the values I'm testing >>> with are all Showable anyway, but the type checker doesn't know that...) >>> >> >> What is the problem with adding a function >> showMyContainer :: (Show a) => Container a -> String >> ? >> In this case you can show your container (for debugging purposes), but >> only if you have Showable elements in your container. >> > > This could plausibly work... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rmm-haskell at z.odi.ac Fri Oct 16 14:59:03 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Oct 16 14:36:15 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> Message-ID: <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> Andrew has mentioned the debugger several times, NOT the interactive REPL. That is, using :-commands to inspect values. -Ross On Oct 16, 2009, at 2:46 PM, Daniel Peebles wrote: > My GHCi can't do that :o > > I just wrote data A = B | C and loaded the file into GHCi. Typing B > gives me: > > :1:0: > No instance for (Show A) > arising from a use of `print' at :1:0 > Possible fix: add an instance declaration for (Show A) > In a stmt of a 'do' expression: print it > > The error also gives an idea of what GHCi is doing behind the scenes: > it's just calling print, which has a Show constraint. > > On Fri, Oct 16, 2009 at 2:40 PM, Andrew Coppin > wrote: >> Jochem Berndsen wrote: >>> >>>> I rephrase: There *is* a way to turn arbitrary values into >>>> strings. I >>>> know there is, because the GHCi debugger *does* it. The question >>>> is, >>>> does anybody know of an /easy/ way to do this? >>>> >>> >>> No. GHCi does not always do this: >>> >>> Prelude Data.Ratio> let plus1 = (+1) >>> Prelude Data.Ratio> plus1 >>> >>> :1:0: >>> No instance for (Show (a -> a)) >>> arising from a use of `print' at :1:0-4 >>> Possible fix: add an instance declaration for (Show (a -> a)) >>> In a stmt of a 'do' expression: print it >>> Prelude Data.Ratio> >>> >> >> The GHCi *debugger* can print out even values for which no Show >> instance >> exists. (But yes, it fails to print anything interesting for function >> types... It works for ADTs that don't have Show though.) >> >>>> Anybody know of a way to do this? (As it happens, the values I'm >>>> testing >>>> with are all Showable anyway, but the type checker doesn't know >>>> that...) >>>> >>> >>> What is the problem with adding a function >>> showMyContainer :: (Show a) => Container a -> String >>> ? >>> In this case you can show your container (for debugging purposes), >>> but >>> only if you have Showable elements in your container. >>> >> >> This could plausibly work... >> >> _______________________________________________ >> 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 alangcarter at gmail.com Fri Oct 16 14:59:16 2009 From: alangcarter at gmail.com (Alan Carter) Date: Fri Oct 16 14:36:24 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? Message-ID: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> Hi, I've been looking at the patches given by Tom at Beware the Jabberwolk, for building Linux kernel modules in Haskell. Once I'd got Tom's stuff building, the next thing was to build a little driver which actually does something. Step by step I was making progress, and I've now got a little function which can see all the characters which are catted to the device file. That's when I got stuck. Trouble is, my function is (ultimately) being called from the C kernel stuff. It isn't on the bottom of a call graph coming from a Haskell main. A driver really needs to know where it's at. So I seem to need some kind of global, persistent state, and Control.Monad.State seems to be out because I can't pass a State around my call graph. I've thought about trying to create some State when I initialize, pass some kind of pointer back to the C shim which actually does the calling into Haskell, and then passing it back into Haskell on the writes and reads, but that seems dangerous because the Haskell garbage collector would (understandably) get the wrong idea and delete it. Also it's ugly - having to use C for something Haskell can't do. I've been looking at the Halfs Haskell file system, which surely must have solved its own version of this problem, but whatever it does in its FSState seems very complicated and is beyond my comprehension :-( So my questions are: 1) Am I right in thinking that I have a genuine need for global, persistent state? 2) Halfs works. Am I right in thinking it has (somehow) solved this problem? 3) Is there a simple way to maintain global persistent state that I can stash between calls into a function, and access without needing to pass the state in? If so, is there an example anywhere? Thanks in advance, Alan -- ... the PA system was moaning unctuously, like a lady hippopotamus reading A. E. Housman ..." -- James Blish, "They Shall Have Stars" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/d3951d27/attachment.html From dons at galois.com Fri Oct 16 15:02:29 2009 From: dons at galois.com (Don Stewart) Date: Fri Oct 16 14:39:43 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? In-Reply-To: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> References: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> Message-ID: <20091016190229.GI20136@whirlpool.galois.com> alangcarter: > 1) Am I right in thinking that I have a genuine need for global, persistent > state? > 2) Halfs works. Am I right in thinking it has (somehow) solved this problem? > 3) Is there a simple way to maintain global persistent state that I can stash > between calls into a function, and access without needing to pass the state in? > If so, is there an example anywhere? You don't necessarily need to have global mutable state, since you can pass a reference to the state back and forth from C. That saves you having to build a top level table on the Haskell side to store all the state while you're in C. However, you can stash state on the Haskell side via a top level IORef, or you can make a foreign pointer of the Haskell state, and pass it to C and back. I'd probably do the former. -- Don From agocorona at gmail.com Fri Oct 16 15:15:06 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Oct 16 14:52:13 2009 Subject: Fwd: [Haskell-cafe] x -> String In-Reply-To: References: <4AD8B942.5070202@btinternet.com> <4c88418c0910161122k54978944q41b3de6d3bbf2943@mail.gmail.com> Message-ID: yep add Show to your abstrac container. , for example: data SDynamic= forall a.Show a => SDynamic a instance Show SDynamic where show (SDynamic a)= show a 2009/10/16 David Virebayre > On Fri, Oct 16, 2009 at 8:19 PM, Andrew Coppin > wrote: > > Is there any way that you can turn an arbitrary Haskell value into a > string? > > > I rephrase: There *is* a way to turn arbitrary values into strings. I > know > > there is, because the GHCi debugger *does* it. The question is, does > anybody > > know of an /easy/ way to do this? > > Ghci only displays values with a Show instance. > _______________________________________________ > 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/20091016/6c2b07a0/attachment.html From jvranish at gmail.com Fri Oct 16 15:24:19 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Oct 16 15:01:26 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? In-Reply-To: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> References: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> Message-ID: Stable pointers might do what you want: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-StablePtr.html Though an IORef would probably work just as well, depending on how you needed to use it.. - Job On Fri, Oct 16, 2009 at 2:59 PM, Alan Carter wrote: > Hi, > I've been looking at the patches given by Tom at Beware the Jabberwolk, for > building Linux kernel modules in Haskell. Once I'd got Tom's stuff building, > the next thing was to build a little driver which actually does something. > Step by step I was making progress, and I've now got a little function which > can see all the characters which are catted to the device file. That's when > I got stuck. > > Trouble is, my function is (ultimately) being called from the C kernel > stuff. It isn't on the bottom of a call graph coming from a Haskell main. A > driver really needs to know where it's at. So I seem to need some kind of > global, persistent state, and Control.Monad.State seems to be out because I > can't pass a State around my call graph. > > I've thought about trying to create some State when I initialize, pass some > kind of pointer back to the C shim which actually does the calling into > Haskell, and then passing it back into Haskell on the writes and reads, but > that seems dangerous because the Haskell garbage collector would > (understandably) get the wrong idea and delete it. Also it's ugly - having > to use C for something Haskell can't do. > > I've been looking at the Halfs Haskell file system, which surely must have > solved its own version of this problem, but whatever it does in its FSState > seems very complicated and is beyond my comprehension :-( > > So my questions are: > > 1) Am I right in thinking that I have a genuine need for global, persistent > state? > 2) Halfs works. Am I right in thinking it has (somehow) solved this > problem? > 3) Is there a simple way to maintain global persistent state that I can > stash between calls into a function, and access without needing to pass the > state in? If so, is there an example anywhere? > > Thanks in advance, > > Alan > > -- > ... the PA system was moaning unctuously, like a lady hippopotamus reading > A. E. Housman ..." > -- James Blish, "They Shall Have Stars" > > _______________________________________________ > 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/20091016/b38dd3de/attachment.html From pumpkingod at gmail.com Fri Oct 16 15:26:33 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Oct 16 15:03:39 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> Message-ID: Whoops, sorry about that then! On Fri, Oct 16, 2009 at 2:59 PM, Ross Mellgren wrote: > Andrew has mentioned the debugger several times, NOT the interactive REPL. > That is, using :-commands to inspect values. > > -Ross > > On Oct 16, 2009, at 2:46 PM, Daniel Peebles wrote: > >> My GHCi can't do that :o >> >> I just wrote data A = B | C and loaded the file into GHCi. Typing B gives >> me: >> >> :1:0: >> ? No instance for (Show A) >> ? ? arising from a use of `print' at :1:0 >> ? Possible fix: add an instance declaration for (Show A) >> ? In a stmt of a 'do' expression: print it >> >> The error also gives an idea of what GHCi is doing behind the scenes: >> it's just calling print, which has a Show constraint. >> >> On Fri, Oct 16, 2009 at 2:40 PM, Andrew Coppin >> wrote: >>> >>> Jochem Berndsen wrote: >>>> >>>>> I rephrase: There *is* a way to turn arbitrary values into strings. I >>>>> know there is, because the GHCi debugger *does* it. The question is, >>>>> does anybody know of an /easy/ way to do this? >>>>> >>>> >>>> No. GHCi does not always do this: >>>> >>>> Prelude Data.Ratio> let plus1 = (+1) >>>> Prelude Data.Ratio> plus1 >>>> >>>> :1:0: >>>> ? No instance for (Show (a -> a)) >>>> ? ? arising from a use of `print' at :1:0-4 >>>> ? Possible fix: add an instance declaration for (Show (a -> a)) >>>> ? In a stmt of a 'do' expression: print it >>>> Prelude Data.Ratio> >>>> >>> >>> The GHCi *debugger* can print out even values for which no Show instance >>> exists. (But yes, it fails to print anything interesting for function >>> types... It works for ADTs that don't have Show though.) >>> >>>>> Anybody know of a way to do this? (As it happens, the values I'm >>>>> testing >>>>> with are all Showable anyway, but the type checker doesn't know >>>>> that...) >>>>> >>>> >>>> What is the problem with adding a function >>>> showMyContainer :: (Show a) => Container a -> String >>>> ? >>>> In this case you can show your container (for debugging purposes), but >>>> only if you have Showable elements in your container. >>>> >>> >>> This could plausibly work... >>> >>> _______________________________________________ >>> 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 rmm-haskell at z.odi.ac Fri Oct 16 15:27:05 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Oct 16 15:04:14 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> Message-ID: No problem, just trying to make sure the conversation stays on track :-) -Ross On Oct 16, 2009, at 3:26 PM, Daniel Peebles wrote: > Whoops, sorry about that then! > > On Fri, Oct 16, 2009 at 2:59 PM, Ross Mellgren haskell@z.odi.ac> wrote: >> Andrew has mentioned the debugger several times, NOT the >> interactive REPL. >> That is, using :-commands to inspect values. >> >> -Ross >> >> On Oct 16, 2009, at 2:46 PM, Daniel Peebles wrote: >> >>> My GHCi can't do that :o >>> >>> I just wrote data A = B | C and loaded the file into GHCi. Typing >>> B gives >>> me: >>> >>> :1:0: >>> No instance for (Show A) >>> arising from a use of `print' at :1:0 >>> Possible fix: add an instance declaration for (Show A) >>> In a stmt of a 'do' expression: print it >>> >>> The error also gives an idea of what GHCi is doing behind the >>> scenes: >>> it's just calling print, which has a Show constraint. >>> >>> On Fri, Oct 16, 2009 at 2:40 PM, Andrew Coppin >>> wrote: >>>> >>>> Jochem Berndsen wrote: >>>>> >>>>>> I rephrase: There *is* a way to turn arbitrary values into >>>>>> strings. I >>>>>> know there is, because the GHCi debugger *does* it. The >>>>>> question is, >>>>>> does anybody know of an /easy/ way to do this? >>>>>> >>>>> >>>>> No. GHCi does not always do this: >>>>> >>>>> Prelude Data.Ratio> let plus1 = (+1) >>>>> Prelude Data.Ratio> plus1 >>>>> >>>>> :1:0: >>>>> No instance for (Show (a -> a)) >>>>> arising from a use of `print' at :1:0-4 >>>>> Possible fix: add an instance declaration for (Show (a -> a)) >>>>> In a stmt of a 'do' expression: print it >>>>> Prelude Data.Ratio> >>>>> >>>> >>>> The GHCi *debugger* can print out even values for which no Show >>>> instance >>>> exists. (But yes, it fails to print anything interesting for >>>> function >>>> types... It works for ADTs that don't have Show though.) >>>> >>>>>> Anybody know of a way to do this? (As it happens, the values I'm >>>>>> testing >>>>>> with are all Showable anyway, but the type checker doesn't know >>>>>> that...) >>>>>> >>>>> >>>>> What is the problem with adding a function >>>>> showMyContainer :: (Show a) => Container a -> String >>>>> ? >>>>> In this case you can show your container (for debugging >>>>> purposes), but >>>>> only if you have Showable elements in your container. >>>>> >>>> >>>> This could plausibly work... >>>> >>>> _______________________________________________ >>>> 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 dons at galois.com Fri Oct 16 15:29:53 2009 From: dons at galois.com (Don Stewart) Date: Fri Oct 16 15:07:01 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? In-Reply-To: References: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> Message-ID: <20091016192953.GL20136@whirlpool.galois.com> StablePtrs are relatively easy to use, and have precisely the guarantees you need -- the state can be passed to C and recovered. Any use of IORefs that will scale past more than one state object will essentially duplicate the stable pointer functionality. They're a reasonable choice. -- Don jvranish: > Stable pointers might do what you want: > http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-StablePtr.html > > Though an IORef would probably work just as well, depending on how you needed > to use it.. > > - Job > > On Fri, Oct 16, 2009 at 2:59 PM, Alan Carter wrote: > > Hi, > > I've been looking at the patches given by Tom at Beware the Jabberwolk, for > building Linux kernel modules in Haskell. Once I'd got Tom's stuff > building, the next thing was to build a little driver which actually does > something. Step by step I was making progress, and I've now got a little > function which can see all the characters which are catted to the device > file. That's when I got stuck. > > Trouble is, my function is (ultimately) being called from the C kernel > stuff. It isn't on the bottom of a call graph coming from a Haskell main. A > driver really needs to know where it's at. So I seem to need some kind of > global, persistent state, and Control.Monad.State seems to be out because I > can't pass a State around my call graph. > > I've thought about trying to create some State when I initialize, pass some > kind of pointer back to the C shim which actually does the calling into > Haskell, and then passing it back into Haskell on the writes and reads, but > that seems dangerous because the Haskell garbage collector would > (understandably) get the wrong idea and delete it. Also it's ugly - having > to use C for something Haskell can't do. > > I've been looking at the Halfs Haskell file system, which surely must have > solved its own version of this problem, but whatever it does in its FSState > seems very complicated and is beyond my comprehension :-( > > So my questions are: > > 1) Am I right in thinking that I have a genuine need for global, persistent > state? > 2) Halfs works. Am I right in thinking it has (somehow) solved this > problem? > 3) Is there a simple way to maintain global persistent state that I can > stash between calls into a function, and access without needing to pass the > state in? If so, is there an example anywhere? > > Thanks in advance, > > Alan > > -- > ... the PA system was moaning unctuously, like a lady hippopotamus reading > A. E. Housman ..." > -- James Blish, "They Shall Have Stars" > > _______________________________________________ > 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 nowgate at yahoo.com Fri Oct 16 15:36:16 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Oct 16 15:13:22 2009 Subject: [Haskell-cafe] Generating random enums Message-ID: <810112.50228.qm@web31106.mail.mud.yahoo.com> What is the minimum I need to do to get this function to generate a three direction tuple? Michael ===================== import System.Random import Data.Ord data Dir ??? = North ??? | South ??? | East ??? | West ??? deriving (Show, Read, Eq, Enum, Ord, Bounded) threeDirs :: StdGen -> (Dir,Dir,Dir) threeDirs gen = ? let (firstDir, newGen) = random gen ????? (secondDir, newGen') = random newGen ????? (thirdDir, newGen'') = random newGen' ? in (firstDir, secondDir, thirdDir) ===================== GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> :l dir.hs [1 of 1] Compiling Main???????????? ( dir.hs, interpreted ) dir.hs:15:29: ??? No instance for (Random Dir) ????? arising from a use of `random' at dir.hs:15:29-42 ??? Possible fix: add an instance declaration for (Random Dir) ??? In the expression: random newGen' ??? In a pattern binding: (thirdDir, newGen'') = random newGen' ??? In the expression: ??????? let ????????? (firstDir, newGen) = random gen ????????? (secondDir, newGen') = random newGen ????????? (thirdDir, newGen'') = random newGen' ??????? in (firstDir, secondDir, thirdDir) Failed, modules loaded: none. Prelude> ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/a0ef3b3b/attachment.html From rmm-haskell at z.odi.ac Fri Oct 16 15:40:42 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Oct 16 15:17:50 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <810112.50228.qm@web31106.mail.mud.yahoo.com> References: <810112.50228.qm@web31106.mail.mud.yahoo.com> Message-ID: <184E6A21-538B-4444-9276-89B9ABDC42A2@z.odi.ac> I didn't try to compile this: import Control.Arrow (first) import System.Random (Random(..)) instance Random Dir where randomR (lo, hi) gen = first fromEnum (randomR (toEnum lo) (toEnum hi) gen) random gen = randomR (minBound, maxBound) But something along those lines should help you I think. -Ross On Oct 16, 2009, at 3:36 PM, michael rice wrote: > What is the minimum I need to do to get this function to generate a > three direction tuple? > > Michael > > > ===================== > > import System.Random > import Data.Ord > > data Dir > = North > | South > | East > | West > deriving (Show, Read, Eq, Enum, Ord, Bounded) > > threeDirs :: StdGen -> (Dir,Dir,Dir) > threeDirs gen = > let (firstDir, newGen) = random gen > (secondDir, newGen') = random newGen > (thirdDir, newGen'') = random newGen' > in (firstDir, secondDir, thirdDir) > > > > ===================== > > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> :l dir.hs > [1 of 1] Compiling Main ( dir.hs, interpreted ) > > dir.hs:15:29: > No instance for (Random Dir) > arising from a use of `random' at dir.hs:15:29-42 > Possible fix: add an instance declaration for (Random Dir) > In the expression: random newGen' > In a pattern binding: (thirdDir, newGen'') = random newGen' > In the expression: > let > (firstDir, newGen) = random gen > (secondDir, newGen') = random newGen > (thirdDir, newGen'') = random newGen' > in (firstDir, secondDir, thirdDir) > Failed, modules loaded: none. > Prelude> > > > > _______________________________________________ > 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/20091016/618c41b9/attachment.html From bos at serpentine.com Fri Oct 16 16:13:03 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Oct 16 15:50:13 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? In-Reply-To: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> References: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> Message-ID: On Fri, Oct 16, 2009 at 11:59 AM, Alan Carter wrote: > > Trouble is, my function is (ultimately) being called from the C kernel > stuff. It isn't on the bottom of a call graph coming from a Haskell main. A > driver really needs to know where it's at. So I seem to need some kind of > global, persistent state, and Control.Monad.State seems to be out because I > can't pass a State around my call graph. > You don't need anything special for this. A Linux kernel "struct device" has a "void *driver_data" member which is private for your use, and intended for precisely this purpose. Global persistent state makes no more sense for kernel drivers than for most other code: how would it work if you had two mice plugged into your system? If you want a decent reference on writing Linux driver code, see http://lwn.net/Kernel/LDD3/ Your friendly kernel and Haskell hacker, Bryan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/a4570d3b/attachment-0001.html From monnier at IRO.UMontreal.CA Fri Oct 16 16:16:01 2009 From: monnier at IRO.UMontreal.CA (Stefan Monnier) Date: Fri Oct 16 15:53:11 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: (Paulo Tanimoto's message of "Fri, 16 Oct 2009 10:43:37 -0500") References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: >>> The only thing I haven't figured out is how to do tab-completion of >>> words in the ghci buffer. ?Do I need to use a different key >>> combination? ?I couldn't find that in the documentation. >> I think it's just a missing feature. > OK! Let me know if there's anything I can do to help. I noticed that > other modes, e.g. ESS for R, do have tab-completion, but just skimming > the source code I couldn't find how exactly they do that. You could try to just send the TAB directly to the underlying process and let ghci do the completion. Stefan From agocorona at gmail.com Fri Oct 16 16:21:04 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Oct 16 15:58:11 2009 Subject: Fwd: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> Message-ID: I use Leksah. It?s an IDE . It works fine in Windows. http://leksah.org/ http://leksah.org/Leksah-0.6.1.0.exe By the way, keep the good work Leksah people !. 2009/10/16 Stefan Monnier > The only thing I haven't figured out is how to do tab-completion of > > words in the ghci buffer. Do I need to use a different key > > combination? I couldn't find that in the documentation. > > I think it's just a missing feature. > > > Stefan > > _______________________________________________ > 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/20091016/fd663a84/attachment.html From derek.a.elkins at gmail.com Fri Oct 16 17:21:09 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Oct 16 16:58:14 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> Message-ID: <61f84eff0910161421vd895c8bn6e2c51d715815fd6@mail.gmail.com> See vacuum: http://hackage.haskell.org/package/vacuum From agocorona at gmail.com Fri Oct 16 18:16:17 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Oct 16 17:53:24 2009 Subject: [Haskell-cafe] ANNOUNCE IDynamic-0.1 Message-ID: IDynamic is variant of Data.Dynamic that can be indexed, serialized., stored, transmitted trough communications etc. So it can be used in abstract data containers, persistence, communications etc. http://hackage.haskell.org/package/IDynamic I Just uploaded it, so the documentation has not been created by Hackage. However I uincluded an example in the pachage. {-# OPTIONS -XTypeSynonymInstances #-} module Main where import Data.IResource import Data.IDynamic import Data.Typeable instance IResource Int where keyResource x= "I" serialize = show deserialize = read defPath _= "saved/" instance IResource String where keyResource x= take 5 x serialize = show deserialize = read defPath _= "saved/" main= do putStrLn "see the code to know the meaning of he results" registerType :: IO Int -- register both datatypes (Int, and String) registerType :: IO String let x= 1 :: Int let list= [IDynamic x, IDynamic "hello, how are you"] --typical Dynamic usage let assoc= zip (map keyResource list) list print $ lookup (keyResource (5 ::Int)) assoc -- lookup a IDynamic object from a container and show it mapM writeResource list mds ? readResource $ IDynamic "hello" -- save both objects case mds of Nothing ? error "must have been Just!" --why? Just ds ? do putStrLn $ serialize ds -- serialize the dynamic object and print it let str= fromIDyn ds :: String -- casting putStrLn str -- print the string read let y= fromIDyn ds :: Int -- casting error print y -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091016/8715943e/attachment.html From z_axis at 163.com Sat Oct 17 00:17:39 2009 From: z_axis at 163.com (zaxis) Date: Fri Oct 16 23:54:43 2009 Subject: [Haskell-cafe] There is no Text.Regex module Message-ID: <25935308.post@talk.nabble.com> In Archlinux i can use Text.Regex as below: import Text.Regex let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr However, in Ubuntu 9.10 it doesnot work reporting no Text.Regex module. So i download and install regex-base and regex-posix from Hackage. But it still doesnot work ! $dpkg -l ghc6 ?? ?? ?? ================================================================================== ghc6 6.10.4-1ubuntu2 GHC - the Glasgow Haskell Compilation system SIncerely! -- View this message in context: http://www.nabble.com/There-is-no-Text.Regex-module-tp25935308p25935308.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From thomas.dubuisson at gmail.com Sat Oct 17 00:39:34 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sat Oct 17 00:16:39 2009 Subject: [Haskell-cafe] There is no Text.Regex module In-Reply-To: <25935308.post@talk.nabble.com> References: <25935308.post@talk.nabble.com> Message-ID: <4c44d90b0910162139of8dbaf2s794e13aee44cda66@mail.gmail.com> Modules come from Haskell packages, most of which can be found on hackage.haskell.org. If you are looking for a module but you don't know which package it comes from then feel free to search using hoogle or hayoo!. Obviously manually checking all the seemingly related packages on hackage is also an option (and still practical for sufficiently narrow categories). Hoogle: http://haskell.org/hoogle/?hoogle=Text.Regex Hayoo!: http://holumbus.fh-wedel.de/hayoo/hayoo.html Thomas On Fri, Oct 16, 2009 at 9:17 PM, zaxis wrote: > > In Archlinux i can use Text.Regex as below: > import Text.Regex > let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr > > However, in Ubuntu 9.10 it doesnot work reporting no Text.Regex module. So i > download and install regex-base and regex-posix from Hackage. But it still > doesnot work ! > > $dpkg -l ghc6 > ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? > ================================================================================== > ?ghc6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 6.10.4-1ubuntu2 > GHC - the Glasgow Haskell Compilation system > > SIncerely! > -- > View this message in context: http://www.nabble.com/There-is-no-Text.Regex-module-tp25935308p25935308.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From z_axis at 163.com Sat Oct 17 00:43:37 2009 From: z_axis at 163.com (zaxis) Date: Sat Oct 17 00:20:41 2009 Subject: [Haskell-cafe] There is no Text.Regex module In-Reply-To: <4c44d90b0910162139of8dbaf2s794e13aee44cda66@mail.gmail.com> References: <25935308.post@talk.nabble.com> <4c44d90b0910162139of8dbaf2s794e13aee44cda66@mail.gmail.com> Message-ID: <25935393.post@talk.nabble.com> Hoogle is great ! thanks! Thomas DuBuisson wrote: > > Modules come from Haskell packages, most of which can be found on > hackage.haskell.org. > > If you are looking for a module but you don't know which package it > comes from then feel free to search using hoogle or hayoo!. Obviously > manually checking all the seemingly related packages on hackage is > also an option (and still practical for sufficiently narrow > categories). > > Hoogle: > http://haskell.org/hoogle/?hoogle=Text.Regex > > Hayoo!: > http://holumbus.fh-wedel.de/hayoo/hayoo.html > > Thomas > > > On Fri, Oct 16, 2009 at 9:17 PM, zaxis wrote: >> >> In Archlinux i can use Text.Regex as below: >> import Text.Regex >> let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr >> >> However, in Ubuntu 9.10 it doesnot work reporting no Text.Regex module. >> So i >> download and install regex-base and regex-posix from Hackage. But it >> still >> doesnot work ! >> >> $dpkg -l ghc6 >> ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? >> ================================================================================== >> ?ghc6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 6.10.4-1ubuntu2 >> GHC - the Glasgow Haskell Compilation system >> >> SIncerely! >> -- >> View this message in context: >> http://www.nabble.com/There-is-no-Text.Regex-module-tp25935308p25935308.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/There-is-no-Text.Regex-module-tp25935308p25935393.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jfredett at gmail.com Sat Oct 17 00:53:21 2009 From: jfredett at gmail.com (jfredett@gmail.com) Date: Sat Oct 17 00:30:26 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 136 - October 17, 2009 Message-ID: <4ad94dc1.9553f10a.598b.ffff881d@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20091017 Issue 136 - October 17, 2009 --------------------------------------------------------------------------- Welcome to issue 136 of HWN, a newsletter covering developments in the [1]Haskell community. Over the last week, fpisfun from reddit announced a [2]new subreddit for simple, direct applications of Haskell to common problems which normally might be solved by a perl script or bit of bash. There are a number of examples already there, and the numbers keep growing. It's not just command-line utilities either, there is also [3]this post on calculating the bend needed for a bay window curtainrod. There is plenty of great material if you're new to Haskell and looking for some basic examples of different simple projects, examples of using monads and functors appropriately, or just want to see some 'real' programs in Haskell, it's worth a look! Also, a small correction, due to some issues with the tools, unicode characters get replaced with their ASCII 'equivalents' so that an 'e' with an umlaut becomes an 'e' character. Thanks to Wolfram Kahl for pointing out that this change is not as innocent as I thought, apologies thusly to Guenther Schmidt (I'm told thats a better approximation of the correct spelling) for the error, I apologize in advance for any other similar errors. I'm working on improving the unicode support in the tools, but it's a nasty bug to catch. This was a long editorial, so I won't take any more of your time, Haskellers, the Haskell Weekly News! Announcements Call for Contributions - Haskell Communities and Activities Report, November 2009 edition. voigt [4]called for contributions to the November 2009 issue of the Haskell Communities and Activities Report. See post for details. Call for Participation: VSTTE 2009. Jean-Christophe Filliatre [5]announced a call for participation for the VSTTE Workshop. WFLP 2010 Call for papers. Pablo Nogueira [6]announced a call for papers for the 2010 WFLP. BAHUG Next meeting: October 21st at MIT (32G-882). Ravi Nanavati [7]announced the next meeting of the Boston Area Haskell User's Group. Which will be in the CSAIL Reading Room at MIT. This editor hopes to actually make it to this one, so maybe I'll see you there! fp-southwales, the South Wales Functional Programming User Group. Andy Gimblett [8]announced the formation of fp-southwales, a user group for anybody interested in functional programming in the area of south Wales, UK. The Monad.Reader (14) - Call for copy. Brent Yorgey [9]announced the call for copy for the next issue of `The Monad.Reader`, Issue #14 Extensions to Vec uploaded (useful for GPipe programs). Tobias Bexelius [10]announced two extensions to the Vec package: Vec-Transform and Vec-Boolean. Vec-Transform provides some 4x4 transform matrices such as perspective projection and rotation. Vec-Boolean provides Data.Boolan instances for the Vec data types. Bindings to FFMpeg library. Vasyl Pasternak [11]announced the next release of the hs-ffmpeg library. Downloadable from Hackage along with the ffmpeg-tutorials, which show capabilities of this library. The installation process is a bit tricky so Vasyl put up a [12]blog post which describes the installation process. Haskell Hackathon in Zurich, Switzerland. Johan Tibell [13]announced a Hackathon in Zurich, to be held in March in the Google office. No concrete date has been decided, but if your interested, make sure to add your name [14]here. Reverse Dependencies in Hackage (demo). Roel van Dijk [15]announced his patch to add reverse-dependencies to Hackage, see the linked post for information on where to see an example version of hackage. Discussion Relational Algebra. Guenther Schmidt [16]asked about whether or not a EDSL for relational algebra in Haskell. GHC devs. Andrew Coppin [17]asked about how many GHC Developers there are, and was somewhat surprised with the answer. Fuzzy Logic / Linguistic Variables. Neal Alexander [18]demonstrated an implementation of fuzzy logic taken from the book: 'Programming Game AI by Example' by Mat Buckland. In the book, the code was in C++, rewriting it in Haskell made for much more succint, readable code. Graph Library Using Associated Types. Lajos Nagy [19]asked about using Associated types in a Graph library. Is proof by testing possible? Muad'Dib [20]asked us Haskell Mentat's about whether it was possible to prove a function correct in a finite number of tests. The discussion brought forth not only answers but some /very cool/ results about the application of compactness (in the topological sense) to testing. Blog noise [21]Haskell news from the [22]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Don Stewart (dons): [23]LACSS 2009: Domain Specific Languages and Haskell. * FP Lunch: [24]Factorising folds for faster functions. * Mikael Vejdemo Johansson (Syzygy-): [25][MATH 198] Lecture 4 and a question for the community. More of Syzygy's lectures on category theory, Syzygy also asks about what it means to 'integrate' a datatype. * Neil Brown: [26]Emulating Shared Mutable Variables with Message-Passing Processes. * Galois, Inc: [27]Tech Talk: Writing Linux Kernel Modules with Haskell. * Galois, Inc: [28]Domain Specific Languages for Domain Specific Problems. * FP-Syd: [29]Sydney FP Group: FP-Syd #18.. * Neil Brown: [30]The octopus, the boids and GHC 6.12.1rc1. * Brent Yorgey: [31]Call for submissions: Monad.Reader issue 15. * Brent Yorgey: [32]diagrams 0.2.1, and future plans. * Don Stewart (dons): [33]Self-optimizing data structures: using types to make lists faster. * Martijn van Steenbergen: [34]Context Synonyms. * Joachim Breitner: [35]arbtt: Now with Documentation. * Dan Piponi (sigfpe): [36]Vectors, Invariance, and Math APIs. * Creighton Hogg: [37]How to teach Category Theory?. Quotes of the Week * sproingie: How do you beta-reduce a problem like Maria * Baughn: There's also the language, Quine, whose interpreter is implemented as a symlink to /bin/cat * benmachine: [on the best editor] opinions vary. from correct opinions i.e. mine to other ones. [editor's comment: Obviously, this question is settled, the best editor is *garbled*] * pozic: statistics. a wonderful tool to control people. * FunctorSalad: I think the 'asks', 'gets' etc family of names is sort of cute, like the program is talking about itself in the third person * mmorrow:: Right, that's just beggin for a State monad. About the Haskell Weekly News New editions are posted to [38]the Haskell mailing list as well as to [39]the Haskell Sequence and [40]Planet Haskell. [41]RSS is also available, and headlines appear on [42]haskell.org. To help create new editions of this newsletter, please see the information on [43]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [44]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://www.reddit.com/r/EnHaskell 3. http://www.reddit.com/r/EnHaskell/comments/9syi3/calculating_the_bend_for_a_curtain_rail_for_a_bay/ 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17572 5. http://article.gmane.org/gmane.comp.lang.haskell.general/17570 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64933 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64928 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64858 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64717 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64673 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64901 12. http://progandprog.blogspot.com/2009/10/video-processing-on-haskell-easy.html 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64947 14. http://haskell.org/haskellwiki/ZuriHac#Possible_Attendees 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/64915 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64899 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64867 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64860 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64812 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64757 21. http://planet.haskell.org/ 22. http://haskell.org/haskellwiki/Blog_articles 23. http://donsbot.wordpress.com/2009/10/16/lacss-2009-domain-specific-languages-and-haskell/ 24. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=267 25. http://blog.mikael.johanssons.org/archive/2009/10/math-198-lecture-4-and-a-question-for-the-community/ 26. http://chplib.wordpress.com/2009/10/14/emulating-shared-mutable-variables-with-message-passing-processes/ 27. http://www.galois.com/blog/2009/10/13/haskellkernelmodules/ 28. http://www.galois.com/blog/2009/10/13/domain-specific-languages-for-domain-specific-problems/ 29. http://www.mega-nerd.com/erikd/Blog/FP-Syd/fp-syd-18.html 30. http://chplib.wordpress.com/2009/10/12/the-octopus-the-boids-and-ghc-6-12-1rc1/ 31. http://byorgey.wordpress.com/2009/10/12/call-for-submissions-monad-reader-issue-15/ 32. http://byorgey.wordpress.com/2009/09/24/diagrams-0-2-1-and-future-plans/ 33. http://donsbot.wordpress.com/2009/10/11/self-optimizing-data-structures-using-types-to-make-lists-faster/ 34. http://martijn.van.steenbergen.nl/journal/2009/10/11/context-synonyms/ 35. https://www.joachim-breitner.de/blog/archives/342-arbtt-Now-with-Documentation.html 36. http://blog.sigfpe.com/2009/10/vectors-invariance-and-math-apis.html 37. http://abstractabsurd.blogspot.com/2009/10/how-to-teach-category-theory.html 38. http://www.haskell.org/mailman/listinfo/haskell 39. http://sequence.complete.org/ 40. http://planet.haskell.org/ 41. http://sequence.complete.org/node/feed 42. http://haskell.org/ 43. http://haskell.org/haskellwiki/HWN 44. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From mle+hs at mega-nerd.com Sat Oct 17 01:45:44 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat Oct 17 01:22:51 2009 Subject: [Haskell-cafe] There is no Text.Regex module In-Reply-To: <25935308.post@talk.nabble.com> References: <25935308.post@talk.nabble.com> Message-ID: <20091017164544.cb4ae3e9.mle+hs@mega-nerd.com> zaxis wrote: > > In Archlinux i can use Text.Regex as below: > import Text.Regex > let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") dateStr > > However, in Ubuntu 9.10 it doesnot work reporting no Text.Regex module If you installed ghc6 from a package you should do: sudo apt-get install libghc6-regex-* Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From andrewcoppin at btinternet.com Sat Oct 17 05:57:46 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 17 05:34:48 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <61f84eff0910161421vd895c8bn6e2c51d715815fd6@mail.gmail.com> References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> <61f84eff0910161421vd895c8bn6e2c51d715815fd6@mail.gmail.com> Message-ID: <4AD9951A.1030207@btinternet.com> Derek Elkins wrote: > See vacuum: http://hackage.haskell.org/package/vacuum > Could be useful... Thanks! From deb at pudlak.name Sat Oct 17 07:42:22 2009 From: deb at pudlak.name (Petr Pudlak) Date: Sat Oct 17 07:19:28 2009 Subject: [Haskell-cafe] Approaches to dependent types (DT) In-Reply-To: <4ACF3682.80000@comp.dit.ie> References: <4ACF3682.80000@comp.dit.ie> Message-ID: <20091017114221.GA13867@pudlak.name> Hi Pat, you might be interested in Agda [1] and the tutorial "Dependently Typed Programming in Agda" [2]. I'm just reading the tutorial and it helps me a lot with understanding the concept. Also if you'd like to have a deeper understanding of the underlying theory, I'd suggest reading Barendregt's "Lambda Calculi with Types" [3]. Best regards, Petr [1] http://wiki.portal.chalmers.se/agda/ [2] http://www.cse.chalmers.se/~ulfn/papers/afp08/tutorial.pdf [3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.4391 and ftp://ftp.cs.kun.nl/pub/CompMath.Found/HBKJ.ps.Z On Fri, Oct 09, 2009 at 02:11:30PM +0100, pat browne wrote: > Hi, > I am trying to understand the concept of dependent types as described in > Haskell literature (Hallgren 2001),(Hinze,Jeuring et al. 2006). I am > particularly interested in understanding two flavours of dependency > mentioned by Hinze et al: > 1) Types depending on values called dependent types > 2) Types depending on types called parametric and type-indexed types > > I think that ascending levels of abstraction are important here: values > - types - classes (Hallgren 2001). Here is a Haskell example of the use > of DT: > > class Named object name | object -> name where > name :: object -> name > > instance (Eq name, Named object name) => Eq object where > object1 == object2 = (name object1) == (name object2) > > I think that the intended semantics are: > 1) Objects have names and can be compared for equality using these names. > 2) Two objects are considered equal (identical) if they have the same name. > 3) The type of a name depends on the type of the object, which gets > expressed as a type dependency (object -> name). > I am not sure about the last semantic it might be interpreted as "the > named object depends on..". This may indicate a flaw in my understanding > of DT. > > I am aware that dependent types can be used to express constraints on > the size of lists and other collections. My understanding of Haskell's > functional dependency is that object -> name indicates that fixing the > type object should fix the type name (equivalently we could say that > type name depends on type object). The class definition seems to show a > *type-to-type* dependency (object to name), while the instance > definition shows how a name value is used to define equality for objects > which could be interpreted as a *value-to-type* dependency (name to > object) in the opposite direction to that of the class. > > My questions are: > Question 1: Is my understanding correct? > Question 2: What flavour of DT is this does this example exhibit? > > Best regards, > Pat > > > Hallgren, T. (2001). Fun with Functional Dependencies. In the > Proceedings of the Joint CS/CE Winter Meeting, Varberg, Sweden, January > 2001. > Hinze, R., J. Jeuring, et al. (2006). Comparing Approaches to Generic > Programming in Haskell. Datatype-generic programming: international > spring school, SSDGP 2006. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From Patrick.Browne at comp.dit.ie Sat Oct 17 10:16:44 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Sat Oct 17 09:55:23 2009 Subject: [Haskell-cafe] Approaches to dependent types (DT) In-Reply-To: <20091017114221.GA13867@pudlak.name> References: <4ACF3682.80000@comp.dit.ie> <20091017114221.GA13867@pudlak.name> Message-ID: <4AD9D1CC.9070302@comp.dit.ie> Petr, Thanks for the links. My research involves the study of current algebraic specification and programming languages. I have posted some very general and abstract style questions in order to get a better feel of the individual languages. I do not wish to become highly proficient in each language, so any links that speed up my research are much appreciated. Thanks again, Pat Petr Pudlak wrote: > Hi Pat, > > you might be interested in Agda [1] and the tutorial "Dependently Typed > Programming in Agda" [2]. I'm just reading the tutorial and it helps me > a lot with understanding the concept. > > Also if you'd like to have a deeper understanding of the underlying > theory, I'd suggest reading Barendregt's "Lambda Calculi with Types" > [3]. > > Best regards, > Petr > > [1] http://wiki.portal.chalmers.se/agda/ > [2] http://www.cse.chalmers.se/~ulfn/papers/afp08/tutorial.pdf > [3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.4391 > and ftp://ftp.cs.kun.nl/pub/CompMath.Found/HBKJ.ps.Z > > On Fri, Oct 09, 2009 at 02:11:30PM +0100, pat browne wrote: >> Hi, >> I am trying to understand the concept of dependent types as described in >> Haskell literature (Hallgren 2001),(Hinze,Jeuring et al. 2006). I am >> particularly interested in understanding two flavours of dependency >> mentioned by Hinze et al: >> 1) Types depending on values called dependent types >> 2) Types depending on types called parametric and type-indexed types >> >> I think that ascending levels of abstraction are important here: values >> - types - classes (Hallgren 2001). Here is a Haskell example of the use >> of DT: >> >> class Named object name | object -> name where >> name :: object -> name >> >> instance (Eq name, Named object name) => Eq object where >> object1 == object2 = (name object1) == (name object2) >> >> I think that the intended semantics are: >> 1) Objects have names and can be compared for equality using these names. >> 2) Two objects are considered equal (identical) if they have the same name. >> 3) The type of a name depends on the type of the object, which gets >> expressed as a type dependency (object -> name). >> I am not sure about the last semantic it might be interpreted as "the >> named object depends on..". This may indicate a flaw in my understanding >> of DT. >> >> I am aware that dependent types can be used to express constraints on >> the size of lists and other collections. My understanding of Haskell's >> functional dependency is that object -> name indicates that fixing the >> type object should fix the type name (equivalently we could say that >> type name depends on type object). The class definition seems to show a >> *type-to-type* dependency (object to name), while the instance >> definition shows how a name value is used to define equality for objects >> which could be interpreted as a *value-to-type* dependency (name to >> object) in the opposite direction to that of the class. >> >> My questions are: >> Question 1: Is my understanding correct? >> Question 2: What flavour of DT is this does this example exhibit? >> >> Best regards, >> Pat >> >> >> Hallgren, T. (2001). Fun with Functional Dependencies. In the >> Proceedings of the Joint CS/CE Winter Meeting, Varberg, Sweden, January >> 2001. >> Hinze, R., J. Jeuring, et al. (2006). Comparing Approaches to Generic >> Programming in Haskell. Datatype-generic programming: international >> spring school, SSDGP 2006. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewcoppin at btinternet.com Sat Oct 17 10:35:30 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 17 10:12:31 2009 Subject: [Haskell-cafe] GHC devs In-Reply-To: <4AD8129B.6080704@van.steenbergen.nl> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <4c88418c0910150017h79738127oe2840703286d6d0d@mail.gmail.com> <4AD8129B.6080704@van.steenbergen.nl> Message-ID: <4AD9D632.2030804@btinternet.com> Martijn van Steenbergen wrote: > David Virebayre wrote: >> Taking the opportunity to thank very much both Simons and Ian for the >> work they do and the enthusiasm they show. You guys rock. > > I heartily second that! I won't disagree with that sentiment. ;-) According to a paper I just read, GHC is "about 150,000 lines of code". It's pretty impressive that such a small team could write and actually maintain such a big thing. (At least, it impresses me.) Speaking of which... One of the things I like about the GHC team is that they keep putting out really interesting papers. Most of them are pretty easy reading, even for somebody as stupid as me. Things like the papers on STM, parallel GC, stream fusion, DPH, and low-level performance tuning of the GHC RTS and STG implementation. For example, I've just been reading a paper which suggests that turning off vectored returns yields a net performance win. One slightly frustrating aspect of all this is that these papers describe interesting techniques or new optimisations, but it's usually quite hard to track down when/if these things made it into the production GHC releases... Sometimes you can tell from the paper (e.g., there was recently a paper about a bunch of things being done to the parallel RTS to remove bottlenecks from it, and IIRC it stated that this work will be released in GHC 6.12.x) Sometimes the GHC release notes will tell you (e.g., GHC 6.10.1 says "there's a new flag to turn on parallel GC", which pretty much means that this is the first version to support this feature). But sometimes it's really hard to cross-reference this stuff. It would be nice if somebody could collect together all the papers about GHC, and which (if any) GHC release versions implement this stuff... From alangcarter at gmail.com Sat Oct 17 13:54:42 2009 From: alangcarter at gmail.com (Alan Carter) Date: Sat Oct 17 13:31:45 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? In-Reply-To: References: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> Message-ID: <56a54d4d0910171054k625d67b3w8a70a1a7a2258998@mail.gmail.com> On Fri, Oct 16, 2009 at 9:13 PM, Bryan O'Sullivan wrote: > You don't need anything special for this. A Linux kernel "struct device" > has a "void *driver_data" member which is private for your use, and intended > for precisely this purpose. Global persistent state makes no more sense for > kernel drivers than for most other code: how would it work if you had two > mice plugged into your system? > > Thanks Bryan - your thought on this is pure and true :-) Although I'm just making a toy driver, I wanted to exercise the bits a real one would need, and wrongly thought persistent state would matter. You're quite right though - generally, things that matter should go in the per device store, which can easily be kmalloc()ed/kfree()ed on open/close, picked up and passed into Haskell as a Ptr on write/read (so avoiding even the need to understand the C struct in Haskell), then peeked and poked. My driver can now accumulate data as I wanted, and I don't feel like I've cheated. Alan -- ... the PA system was moaning unctuously, like a lady hippopotamus reading A. E. Housman ..." -- James Blish, "They Shall Have Stars" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091017/d1990812/attachment.html From dons at galois.com Sat Oct 17 14:15:37 2009 From: dons at galois.com (Don Stewart) Date: Sat Oct 17 13:52:42 2009 Subject: [Haskell-cafe] Genuine Need For Persistent Global State? In-Reply-To: <56a54d4d0910171054k625d67b3w8a70a1a7a2258998@mail.gmail.com> References: <56a54d4d0910161159j4de231e7r354c5df739d6ed3e@mail.gmail.com> <56a54d4d0910171054k625d67b3w8a70a1a7a2258998@mail.gmail.com> Message-ID: <20091017181537.GA27651@whirlpool.galois.com> alangcarter: > On Fri, Oct 16, 2009 at 9:13 PM, Bryan O'Sullivan wrote: > > You don't need anything special for this. A Linux kernel "struct device" > has a "void *driver_data" member which is private for your use, and > intended for precisely this purpose. Global persistent state makes no more > sense for kernel drivers than for most other code: how would it work if you > had two mice plugged into your system? > > > > Thanks Bryan - your thought on this is pure and true :-) > > Although I'm just making a toy driver, I wanted to exercise the bits a real one > would need, and wrongly thought persistent state would matter. You're quite > right though - generally, things that matter should go in the per device store, > which can easily be kmalloc()ed/kfree()ed on open/close, picked up and passed > into Haskell as a Ptr on write/read (so avoiding even the need to understand > the C struct in Haskell), then peeked and poked. > > My driver can now accumulate data as I wanted, and I don't feel like I've > cheated. So what solution did you pick in the end? Allocate on the C side, and pass a reference back and forth? -- Don From andrewcoppin at btinternet.com Sat Oct 17 15:21:28 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 17 14:58:30 2009 Subject: [Haskell-cafe] Monadic correctness Message-ID: <4ADA1938.6020209@btinternet.com> Suppose we have newtype Foo x instance Monad Foo runFoo :: Foo x -> IO x What sort of things can I do to check that I actually implemented this correctly? I mean, ignoring what makes Foo special for a moment, how can I check that it works correctly as a monad. From ezyang at MIT.EDU Sat Oct 17 15:29:57 2009 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Sat Oct 17 15:07:18 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <4ADA1938.6020209@btinternet.com> References: <4ADA1938.6020209@btinternet.com> Message-ID: <1255807603-sup-2981@ezyang> Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009: > Suppose we have > > newtype Foo x > instance Monad Foo > runFoo :: Foo x -> IO x > > What sort of things can I do to check that I actually implemented this > correctly? I mean, ignoring what makes Foo special for a moment, how can > I check that it works correctly as a monad. A proper monad obeys the monad laws: http://www.haskell.org/haskellwiki/Monad_Laws You can probably cook up some quickcheck properties to test for these, but really you should be able to convince yourself by inspection that your monad follows these laws. Cheers, Edward From dave at zednenem.com Sat Oct 17 15:37:01 2009 From: dave at zednenem.com (David Menendez) Date: Sat Oct 17 15:14:03 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <4ADA1938.6020209@btinternet.com> References: <4ADA1938.6020209@btinternet.com> Message-ID: <49a77b7a0910171237s722e7c39x92572bc31cdb5e6b@mail.gmail.com> On Sat, Oct 17, 2009 at 3:21 PM, Andrew Coppin wrote: > Suppose we have > > ?newtype Foo x > ?instance Monad Foo > ?runFoo :: Foo x -> IO x > > What sort of things can I do to check that I actually implemented this > correctly? I mean, ignoring what makes Foo special for a moment, how can I > check that it works correctly as a monad. Anything which satisfies the monad laws is a monad. In other words, do you have: return a >>= f = f a m >>= return = m (m >>= f) >>= g = m >>= (\a -> f a >>= g) When I bother, I usually just work out the proofs by hand. -- Dave Menendez From andrewcoppin at btinternet.com Sat Oct 17 16:24:08 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 17 16:01:09 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <1255807603-sup-2981@ezyang> References: <4ADA1938.6020209@btinternet.com> <1255807603-sup-2981@ezyang> Message-ID: <4ADA27E8.4000603@btinternet.com> Edward Z. Yang wrote: > Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009: > >> Suppose we have >> >> newtype Foo x >> instance Monad Foo >> runFoo :: Foo x -> IO x >> >> What sort of things can I do to check that I actually implemented this >> correctly? I mean, ignoring what makes Foo special for a moment, how can >> I check that it works correctly as a monad. >> > > A proper monad obeys the monad laws: > > http://www.haskell.org/haskellwiki/Monad_Laws > > You can probably cook up some quickcheck properties to test for these, > but really you should be able to convince yourself by inspection that > your monad follows these laws. > I'm reasonably confident it works, but not 100% sure... newtype Foo x = Foo (M -> IO x) instance Monad Foo where return x = Foo (\_ -> return x) (Foo f1) >>= fn = Foo $ \m -> do x <- f1m let Foo f2 = fn x f2 m runFoo (Foo f) = do let m = ... f m I can do something like "runFoo (return 1)" and check that it yields 1. (If it doesn't, my implementation is *completely* broken!) But I'm not sure how to proceed further. I need to assure myself of 3 things: 1. runFoo correctly runs the monad and retrives its result. 2. return does that it's supposed to. 3. (>>=) works correctly. Doing "runFoo (return 1)" seems to cover #1 and #2, but I'm not so sure about #3... I guess I could maybe try "runFoo (return 1 >>= return)"... From derek.a.elkins at gmail.com Sat Oct 17 16:54:22 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Oct 17 16:31:26 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <4ADA27E8.4000603@btinternet.com> References: <4ADA1938.6020209@btinternet.com> <1255807603-sup-2981@ezyang> <4ADA27E8.4000603@btinternet.com> Message-ID: <61f84eff0910171354g62d3588dse3da9a14b05553f2@mail.gmail.com> On Sat, Oct 17, 2009 at 3:24 PM, Andrew Coppin wrote: > Edward Z. Yang wrote: >> >> Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009: >> >>> >>> Suppose we have >>> >>> ? newtype Foo x >>> ? instance Monad Foo >>> ? runFoo :: Foo x -> IO x >>> >>> What sort of things can I do to check that I actually implemented this >>> correctly? I mean, ignoring what makes Foo special for a moment, how can I >>> check that it works correctly as a monad. >>> >> >> A proper monad obeys the monad laws: >> >> http://www.haskell.org/haskellwiki/Monad_Laws >> >> You can probably cook up some quickcheck properties to test for these, >> but really you should be able to convince yourself by inspection ?that >> your monad follows these laws. >> > > I'm reasonably confident it works, but not 100% sure... > > newtype Foo x = Foo (M -> IO x) In this case it is trivial, Foo = ReaderT M IO which is a monad. If you want, you can verify for yourself that this is a monad. It isn't, however, uncommon for custom monads to be (equivalent to) stacks of monad transformers. From andrewcoppin at btinternet.com Sat Oct 17 17:15:47 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 17 16:52:47 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <61f84eff0910171354g62d3588dse3da9a14b05553f2@mail.gmail.com> References: <4ADA1938.6020209@btinternet.com> <1255807603-sup-2981@ezyang> <4ADA27E8.4000603@btinternet.com> <61f84eff0910171354g62d3588dse3da9a14b05553f2@mail.gmail.com> Message-ID: <4ADA3403.6060708@btinternet.com> Derek Elkins wrote: > On Sat, Oct 17, 2009 at 3:24 PM, Andrew Coppin > wrote: > >> I'm reasonably confident it works, but not 100% sure... >> >> newtype Foo x = Foo (M -> IO x) >> > > In this case it is trivial, Foo = ReaderT M IO which is a monad. Ah yes, of course... I keep forgetting that the Reader monad doesn't do what it sounds like it does! Oh well. ;-) From daniel.is.fischer at web.de Sat Oct 17 17:20:05 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Oct 17 16:58:26 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <4ADA27E8.4000603@btinternet.com> References: <4ADA1938.6020209@btinternet.com> <1255807603-sup-2981@ezyang> <4ADA27E8.4000603@btinternet.com> Message-ID: <200910172320.05538.daniel.is.fischer@web.de> Am Samstag 17 Oktober 2009 22:24:08 schrieb Andrew Coppin: > Edward Z. Yang wrote: > > Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009: > >> Suppose we have > >> > >> newtype Foo x > >> instance Monad Foo > >> runFoo :: Foo x -> IO x Are you sure that's really the type you want for runFoo ? By the definition below, runFoo :: Foo x -> M -> IO x would be the natural type. > >> > >> What sort of things can I do to check that I actually implemented this > >> correctly? I mean, ignoring what makes Foo special for a moment, how can > >> I check that it works correctly as a monad. > > > > A proper monad obeys the monad laws: > > > > http://www.haskell.org/haskellwiki/Monad_Laws > > > > You can probably cook up some quickcheck properties to test for these, > > but really you should be able to convince yourself by inspection that > > your monad follows these laws. > > I'm reasonably confident it works, but not 100% sure... > > newtype Foo x = Foo (M -> IO x) > > instance Monad Foo where > return x = Foo (\_ -> return x) > > (Foo f1) >>= fn = Foo $ \m -> do > x <- f1m > let Foo f2 = fn x > f2 m So, (Foo f) >>= return ~> Foo $ \m -> do x <- f m let Foo g = return x g m ~> (since g is (\_ -> return x)) Foo $ \m -> do x <- f m (\_ -> return x) m ~> Foo $ \m -> do x <- f m return x ~> (monad laws for IO) Foo $ \m -> f m ~> Foo f That's number 1. return a >>= f ~> Foo $ \m -> do x <- (\_ -> return a) m let Foo g = f x g m ~> Foo $ \m -> do x <- return a let Foo g = f x g m ~> Foo $ \m -> do let Foo g = f a g m ~> Foo $ \m -> unFoo (f a) m ~> Foo (unFoo $ f a) ~> f a where I've used unFoo :: Foo x -> M -> IO x; unFoo (Foo f) = f, that's number 2. (Foo f >>= g) >>= h ~> Foo $ \m -> do y <- unFoo (Foo f >>= g) m let Foo h1 = h y h1 m ~> Foo $ \m -> do y <- (unFoo . Foo $ \m1 -> do x <- f m1 let Foo g1 = g x g1 m1) m let Foo h1 = h y h1 m ~> Foo $ \m -> do y <- do x <- f m let Foo g1 = g x g1 m let Foo h1 = h y h1 m ~> Foo $ \m -> do y <- f m >>= \x -> unFoo (g x) m unFoo (h y) m ~> Foo $ \m -> (f m >>= \x -> unFoo (g x) m) >>= \y -> unFoo (h y) m ~> Foo $ \m -> f m >>= \x -> (unFoo (g x) m >>= \y -> unFoo (h y) m) And Foo f >>= (\z -> g z >>= h) ~> Foo $ \m -> do x <- f m let Foo k = (\z -> g z >>= h) x k m ~> Foo $ \m -> do x <- f m unFoo (g x >>= h) m ~> Foo $ \m -> f m >>= \x -> unFoo (g x >>= h) m ~> Foo $ \m -> f m >>= \x -> (\m1 -> (unFoo (g x) m1) >>= \y -> unFoo (h y) m1) m ~> Foo $ \m -> f m >>= \x -> (unFoo (g x) m >>= \y -> unFoo (h y) m) That's number 3. > > runFoo (Foo f) = do > let m = ... > f m > > I can do something like "runFoo (return 1)" and check that it yields 1. > (If it doesn't, my implementation is *completely* broken!) But I'm not > sure how to proceed further. I need to assure myself of 3 things: > > 1. runFoo correctly runs the monad and retrives its result. > 2. return does that it's supposed to. > 3. (>>=) works correctly. > > Doing "runFoo (return 1)" seems to cover #1 and #2, but I'm not so sure > about #3... I guess I could maybe try "runFoo (return 1 >>= return)"... From andrewcoppin at btinternet.com Sat Oct 17 17:32:29 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 17 17:09:31 2009 Subject: [Haskell-cafe] Monadic correctness In-Reply-To: <200910172320.05538.daniel.is.fischer@web.de> References: <4ADA1938.6020209@btinternet.com> <1255807603-sup-2981@ezyang> <4ADA27E8.4000603@btinternet.com> <200910172320.05538.daniel.is.fischer@web.de> Message-ID: <4ADA37ED.3080703@btinternet.com> Daniel Fischer wrote: > Am Samstag 17 Oktober 2009 22:24:08 schrieb Andrew Coppin: > >> Edward Z. Yang wrote: >> >>> Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009: >>> >>>> Suppose we have >>>> >>>> newtype Foo x >>>> instance Monad Foo >>>> runFoo :: Foo x -> IO x >>>> > > Are you sure that's really the type you want for runFoo ? > By the definition below, runFoo :: Foo x -> M -> IO x would be the natural type. > M is a type containing a bunch of IORefs. runFoo generates M, feeds M to Foo x, and then does magical stuff with M afterwards. From lemming at henning-thielemann.de Sat Oct 17 19:32:49 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Oct 17 19:08:33 2009 Subject: [Haskell-cafe] Reverse dependencies in Hackage In-Reply-To: References: Message-ID: <4ADA5421.3000001@henning-thielemann.de> Roel van Dijk schrieb: > A few weeks ago I wrote a patch that adds reverse dependencies to > hackage [1]. I have know hosted a small test hackage which > demonstrates this feature. It can be found here: > > http://bifunctor.homelinux.net/~roel/hackage > > Browse to your favorite packages and find out how much other packages > depend on them! Great! This should definitely go into the main hackage server. From kotowicz.maciej at gmail.com Sun Oct 18 06:49:49 2009 From: kotowicz.maciej at gmail.com (Maciej Kotowicz) Date: Sun Oct 18 06:26:51 2009 Subject: [Haskell-cafe] \Statically checked binomail heaps? Message-ID: <7dfaed80910180349t6cbd688bref0e6de70067fb9c@mail.gmail.com> Hi, first of all this post is literate haskell I'm trying to implement a binomial heaps from okaski's book [1] but as most it's possible to be statically checked for correctness of definition. Remark that binomial heap is list of binomial trees in increasing order of rank and binomial heap of rank r is a node with r child t_1..t_r, where each t_i is binomial tree of rank r - i First I need some langue extension > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE EmptyDataDecls #-} > {-# LANGUAGE GADTs #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE ScopedTypeVariables #-} > module BinTree where second type-level Nats and Bools, and Void i some kind of Top for Nats > data Z > data S a > data Void > data True > data False Ok, let define some nice types ;) OrdLList is list of decreasing collections parametrised by type of element and length with is also highest rank of elements plus one, they are heterogeneous by they ranks > type Forest = OrdLList BinTree > data OrdLList (t :: * -> * -> * ) a :: * -> * where > ? LNil :: OrdLList t a Z > ? LCons :: t a n -> OrdLList t a n -> OrdLList t a (S n ) Binomial tree is here, a I know i can't check statically an heap property > data BinTree a :: * -> * where > ? Node :: Ord a => a -> Forest a n -> BinTree a n Heap is very similar to Forest just reversed order > data ?OrdGList ?(t :: * -> * -> * ) a ?:: * -> * where > ? GNil :: OrdGList t a Void > ? GCons :: Lt n m ?~ True => t a n -> OrdGList t a m -> OrdGList t a n > type Heap a n = OrdGList BinTree a n Predicate for testing order in Heap > type family Lt a b > type instance Lt Z (S a) = True > type instance Lt (S a) Z = False > type instance Lt (S a) (S b) = Lt a b > type instance Lt a Void = True reflection form type-level nats to Int > class TNum a where > ? toNum :: a -> Int > instance TNum Z where > ? ?toNum _ = 0 > instance TNum a => TNum (S a) where > ? ?toNum _ = 1 + toNum (undefined :: a) rank of binomial tree > rank :: TNum n => BinTree a n -> Int > rank ?t = toNum $ ?undefined `asTypeOf` (getN t) > getN :: t a n -> n > getN _ = undefined :: n root of binomial trees > root :: BinTree e n -> e > root (Node x _ ) = x And finally first of quite serious function linking two trees with must have the same ranks, giving trees with rank greater by one > link :: Ord a => BinTree a n -> BinTree a n -> BinTree a (S n) > link t1@(Node x c1) t2@(Node y c2) > ? | x <= y = Node x ?$ LCons t2 c1 > ? | otherwise = Node y ?$ LCons t1 c2 some simple trees for tests > h = ?GCons t3 $ GCons t GNil > t = link t1 t2 > t1 = Node 3 LNil > t2 = Node 2 LNil > t3 = Node 5 LNil And sadly that's all I can write... for full functionality these data structure should have merge, insert, deleteMin, findMin, defined in [1] as fallow insTree t [] = [t] insTree t ts@(t':ts') ?| rank t < rank t' = t : ts ?| otherwise = insTree (link t t') ts' insert x = insTree (Node 0 x []) -- in [1] rank's are write explicit in nodes merge ts [] = ts merge [] ts = ts merge ts1@(t1:ts1') ts2@(t2:ts2') ?| rank t1 < rank t2 = t1 : merge ts1' ts2 ?| rank t1 > rank t2 = t2 : merge ts1 ts2' ?| otherwise = insTree (link t1 t2) $ merge ts1' ts2' removeMinTree [] = error "empty" removeMinTree [t] = (t,[] removeMinTree (t:ts) ?| root t < root t' = (t,ts) ?| otherwise = (t',t:ts') ?where (t',ts') = removeMinTree ts findMin = root . fst . removeMinTree deleteMin ts = merge (rev ts1, ts2) ?where (Node _ x ts1,ts2) = removeMinTree I try with all this function and with all I have problems with types the types of insTree in my opinion should be sth like: insTree :: (Min n m ~ k,TNum n, TNum m) => BinTree a n -> Heap a m -> Heap a k where Min looks like: type family Min a b type instance Min a Z = Z type instance Min Z a = Z type instance Min (S a) (S b) = S (Min a b) but this won't compile, ghc don't see that k can be the same type as m in first pattern, problems with rest of function was similar exclude removeMinTree with I have no idea what type it should have... Have anyone an idea how make this code working? Any help will be appreciated [1] Purely Functional Data Structures by Chris Okasaki. Cambridge University Press, 1998. From leather at cs.uu.nl Sun Oct 18 07:02:21 2009 From: leather at cs.uu.nl (Sean Leather) Date: Sun Oct 18 06:39:42 2009 Subject: [Haskell-cafe] Happstack + network package issue on the Mac In-Reply-To: <1255180435.28525.6790.camel@localhost> References: <3c6288ab0910080220s3a0895dbiecd42f788328bf3b@mail.gmail.com> <87iqeqt0kw.fsf@gregorycollins.net> <3c6288ab0910090511n38987603w13ea3801e9f06719@mail.gmail.com> <87skdsfxv1.fsf@gregorycollins.net> <1255180435.28525.6790.camel@localhost> Message-ID: <3c6288ab0910180402y77aad45xf0da6992471f422c@mail.gmail.com> On Sat, Oct 10, 2009 at 15:13, Duncan Coutts wrote: > From what Gregory and Anton have said, it sounds like the SockAddr6, > HostAddress6 constructors should always be available, but that using > them with the socket functions should fail at runtime on platforms with > no IPv6 support, or when IPv6 support is turned off for some reason. > > That would probably make it rather easier to have portable programs that > can optionally use IPv6. Having to use TH to test at compile time if a > constructor is or is not exported from another package is more than a > little unpleasant. > +1 Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091018/9ec29c2a/attachment.html From leather at cs.uu.nl Sun Oct 18 07:20:47 2009 From: leather at cs.uu.nl (Sean Leather) Date: Sun Oct 18 06:58:08 2009 Subject: [Haskell-cafe] Lecture Notes Advanced Functional programming available In-Reply-To: References: Message-ID: <3c6288ab0910180420q576d920dl27abc9ef95296534@mail.gmail.com> > I am happy to announce that the rworked lecture notes for the 6th Advance > Functional programming summer school have become available. > Thanks, Doaitse. > ? Johan Jeuring (Utrecht University, NL): Libraries for Generic > Programming in Haskell An extended version of this article is available as a technical report: http://www.cs.uu.nl/research/techreps/UU-CS-2008-025.html It introduces the concepts of datatype-generic programming using the libraries LIGD, SYB, and EMGM and compares them. There's also an additional section not in the published lecture notes on type-indexed datatypes with type families. You can even do the exercises in the lecture notes and check out the solutions in the tech report. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091018/248e0918/attachment.html From duncan.coutts at googlemail.com Sat Oct 17 11:14:16 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sun Oct 18 07:14:44 2009 Subject: [Haskell-cafe] Too much strictness in binary-0.5.0.2 In-Reply-To: <200909190036.10694.alexey.skladnoy@gmail.com> References: <200909190036.10694.alexey.skladnoy@gmail.com> Message-ID: <1255792456.8777.3467.camel@localhost> On Sat, 2009-09-19 at 00:36 +0400, Khudyakov Alexey wrote: > Hello > > I run into problems with new binary package. Following function reads a list > of elements one by one until end of stream. List is very long (won't fit into > memory). Sorry for the late reply. > In binary-0.5.0.1 and earlier it read list lazily. Now it seems that it tries > to read whole list to memory. Program does not produce any output and memory > usage steadily grows. Yes. We decided that having the Get monad as a lazy state monad just doesn't make sense. It makes this one use case work, but causes more problems generally. Certainly we need to be able to do lazy binary deserialisation too, but our feeling is that it should be more explicit and integrate better with error handling. Using a lazy state monad gives us neither. > > getStream :: Get a -> Get [a] > > getStream getter = do > > empty <- isEmpty > > if empty > > then return [] > > else do x <- getter > > xs <- getStream getter > > return (x:xs) > > How could I add laziness to this function to revert to old behavior. You can make it explicitly lazy using something like: getStream :: Get a -> BS.ByteString -> [a] getStream getter bs = unfoldr step (bs, 0) where step (bs, off) = case runGetState getOne bs off of (Nothing, _, _ ) -> Nothing (Just x, bs', off') -> Just (x, (bs', off')) getOne = do empty <- isEmpty if empty then return Nothing else fmap Just getter Note the distinct lack of error handling, but if we had runGetState return an Either then you could still make this code lazy, but you'd have to decide what to do when you got a decoding error. You could at this point translate it into a pure error, or enrich your output stream type to account for the possibility of errors. Note also that if we changed runGetState to do any error handling that this would also break the lazy state monad properties that you were previously relying upon. Duncan From leather at cs.uu.nl Sun Oct 18 10:25:00 2009 From: leather at cs.uu.nl (Sean Leather) Date: Sun Oct 18 10:02:20 2009 Subject: [Haskell-cafe] Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) In-Reply-To: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> References: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> Message-ID: <3c6288ab0910180725i60ba2874p1fc98d830cb07cf8@mail.gmail.com> Hi John, On Sun, Oct 11, 2009 at 14:58, John Lato wrote: > For anyone writing introductions to generic programming, take this as > a plea from Haskellers everywhere. If one of the RWH authors can't > understand how to make use of these techniques, what hope do the rest > of us have? > I would like to help you with this problem, though with a different library. You can find EMGM [1] on Hackage. If you have a problem with the documentation there, please let me know. I would consider it a bug. To understand it, however, you should consider reading the tech report "Libraries for Generic Programming in Haskell" [2], an extended version of an article in a recently published collection of lecture notes from the 2008 Advanced Functional Programming Summer School [3]. [1] http://hackage.haskell.org/package/emgm [2] http://www.cs.uu.nl/research/techreps/UU-CS-2008-025.html [3] http://www.springerlink.com/content/978-3-642-04651-3 I agree that a lot more documentation could help, but I hope this helps. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091018/ec4c9e2a/attachment.html From alexey.skladnoy at gmail.com Sun Oct 18 11:53:46 2009 From: alexey.skladnoy at gmail.com (Alexey Khudyakov) Date: Sun Oct 18 11:30:47 2009 Subject: [Haskell-cafe] Too much strictness in binary-0.5.0.2 In-Reply-To: <1255792456.8777.3467.camel@localhost> References: <200909190036.10694.alexey.skladnoy@gmail.com> <1255792456.8777.3467.camel@localhost> Message-ID: <8425cc0e0910180853r6cc0df9dxdde69adaf9a12e7b@mail.gmail.com> > Yes. We decided that having the Get monad as a lazy state monad just > doesn't make sense. It makes this one use case work, but causes more > problems generally. Certainly we need to be able to do lazy binary > deserialisation too, but our feeling is that it should be more explicit > and integrate better with error handling. Using a lazy state monad gives > us neither. This is valid point. I think I'll just use variant with explicit laziness. > Note also that if we changed runGetState to do any error handling that > this would also break the lazy state monad properties that you were > previously relying upon. I'd appreciate addition of error handling very much. Currently I have to use ErrorT and do checks by hands. I have very simple parsers so it's possible. It's not possible to do such things in general. Trading laziness for error handling is good thing I believe. At the moment it's hard to decode possibly malformed data. On 10/17/09, Duncan Coutts wrote: > On Sat, 2009-09-19 at 00:36 +0400, Khudyakov Alexey wrote: >> Hello >> >> I run into problems with new binary package. Following function reads a >> list >> of elements one by one until end of stream. List is very long (won't fit >> into >> memory). > > Sorry for the late reply. > >> In binary-0.5.0.1 and earlier it read list lazily. Now it seems that it >> tries >> to read whole list to memory. Program does not produce any output and >> memory >> usage steadily grows. > > Yes. We decided that having the Get monad as a lazy state monad just > doesn't make sense. It makes this one use case work, but causes more > problems generally. Certainly we need to be able to do lazy binary > deserialisation too, but our feeling is that it should be more explicit > and integrate better with error handling. Using a lazy state monad gives > us neither. > >> > getStream :: Get a -> Get [a] >> > getStream getter = do >> > empty <- isEmpty >> > if empty >> > then return [] >> > else do x <- getter >> > xs <- getStream getter >> > return (x:xs) >> >> How could I add laziness to this function to revert to old behavior. > > You can make it explicitly lazy using something like: > > getStream :: Get a -> BS.ByteString -> [a] > getStream getter bs = unfoldr step (bs, 0) > where > step (bs, off) = case runGetState getOne bs off of > (Nothing, _, _ ) -> Nothing > (Just x, bs', off') -> Just (x, (bs', off')) > > getOne = do > empty <- isEmpty > if empty > then return Nothing > else fmap Just getter > > Note the distinct lack of error handling, but if we had runGetState > return an Either then you could still make this code lazy, but you'd > have to decide what to do when you got a decoding error. You could at > this point translate it into a pure error, or enrich your output stream > type to account for the possibility of errors. > > Note also that if we changed runGetState to do any error handling that > this would also break the lazy state monad properties that you were > previously relying upon. > > Duncan > > From moonpatio at gmail.com Sun Oct 18 12:06:45 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Sun Oct 18 11:43:45 2009 Subject: [Haskell-cafe] x -> String In-Reply-To: <4AD9951A.1030207@btinternet.com> References: <4AD8B942.5070202@btinternet.com> <4AD8BB73.4030307@functor.nl> <4AD8BE10.8020105@btinternet.com> <35F426A2-5065-419F-871A-615255ACA8BD@z.odi.ac> <61f84eff0910161421vd895c8bn6e2c51d715815fd6@mail.gmail.com> <4AD9951A.1030207@btinternet.com> Message-ID: <1bc51a990910180906j30ceb957ye269166e1626aeb9@mail.gmail.com> On 10/17/09, Andrew Coppin wrote: > Derek Elkins wrote: >> See vacuum: http://hackage.haskell.org/package/vacuum >> > Could be useful... Thanks! > As Derek mentioned, vacuum would be perfect for this: ----------------------------------------------------------------------------- import Data.Word import GHC.Vacuum import GHC.Vacuum.ClosureType import qualified Data.IntMap as IM type Info = (ClosureType -- what kind of heap node is this? ,[String] -- [pkg,mod,con] for constructors ,[Int] -- "pointers" refering to other nodes in IntMap ,[Word]) -- literal data in constructors overview :: HNode -> Info overview o = let ptrs = nodePtrs o lits = nodeLits o itab = nodeInfo o ctyp = itabType itab -- only available -- for constructors (pkg,mod,con) = itabName itab names = filter (not . null) [pkg,mod,con] in (ctyp ,names -- [] for non-data ,ptrs ,lits) -- returns an adjacency-list graph info :: a -> [(Int,Info)] info = fmap (\(a,b)->(a,overview b)) . IM.toList . vacuum -- returns an adjacency-list graph infoLazy :: a -> [(Int,Info)] infoLazy = fmap (\(a,b)->(a,overview b)) . IM.toList . vacuumLazy ----------------------------------------------------------------------------- -- example usage data A a = A Int | B a | forall b. C b [A a] val0 = [A 42, B (Left Nothing), C (pi,()) val0] val1 = fmap (\n -> C n []) [0..] {- ghci> mapM_ print (info val0) Loading package vacuum-1.0.0 ... linking ... done. (0,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[1,2],[])) (1,(CONSTR,["main","Main","A"],[3],[])) (2,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[4,5],[])) (3,(CONSTR_0_1,["ghc-prim","GHC.Types","I#"],[],[42])) (4,(CONSTR,["main","Main","B"],[6],[])) (5,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[8,9],[])) (6,(CONSTR_1_0,["base","Data.Either","Left"],[7],[])) (7,(CONSTR_NOCAF_STATIC,["base","Data.Maybe","Nothing"],[],[])) (8,(CONSTR,["main","Main","C"],[10,0],[])) (9,(CONSTR_NOCAF_STATIC,["ghc-prim","GHC.Types","[]"],[],[])) (10,(CONSTR_2_0,["ghc-prim","GHC.Tuple","(,)"],[11,12],[])) (11,(CONSTR_NOCAF_STATIC,["ghc-prim","GHC.Types","D#"],[],[4614256656552045848])) (12,(CONSTR_NOCAF_STATIC,["ghc-prim","GHC.Unit","()"],[],[])) ghci> mapM_ print (infoLazy val1) (0,(AP,[],[],[])) ghci> val1 `seq` () () ghci> mapM_ print (infoLazy val1) (0,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[1,2],[])) (1,(THUNK_2_0,[],[],[])) (2,(THUNK_2_0,[],[],[])) ghci> length . take 2 $ val1 2 ghci> mapM_ print (infoLazy val1) (0,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[1,2],[])) (1,(THUNK_2_0,[],[],[])) (2,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[3,4],[])) (3,(THUNK_2_0,[],[],[])) (4,(THUNK_2_0,[],[],[])) ghci> case val1 of a:b:_ -> a `seq` b `seq` () () ghci> mapM_ print (infoLazy val1) (0,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[1,2],[])) (1,(CONSTR,["main","Main","C"],[3,4],[])) (2,(CONSTR_2_0,["ghc-prim","GHC.Types",":"],[5,6],[])) (3,(CONSTR_0_1,["integer","GHC.Integer.Internals","S#"],[],[0])) (4,(CONSTR_NOCAF_STATIC,["ghc-prim","GHC.Types","[]"],[],[])) (5,(CONSTR,["main","Main","C"],[7,4],[])) (6,(THUNK_2_0,[],[],[])) (7,(CONSTR_0_1,["integer","GHC.Integer.Internals","S#"],[],[1])) -} ----------------------------------------------------------------------------- Matt From Patrick.Browne at comp.dit.ie Sun Oct 18 13:11:13 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Sun Oct 18 12:49:49 2009 Subject: [Haskell-cafe] Re: Merging modules (again) In-Reply-To: <4AD84E0E.5060600@comp.dit.ie> References: <4AD84E0E.5060600@comp.dit.ie> Message-ID: <4ADB4C31.5010906@comp.dit.ie> Hi, I have tried qualified imports, synonyms and newtypes but still I could not implement the merging task (previously posted). This is probably because I have little knowledge of Haskell *or* the task is not really suited to Haskell (more of a specification task than a programming task). My main questions are; Can the merging task be achieved using the Haskell module system? I also posted a question on how this task could be done using type classes. I would ask the same question with respect to type classes. Regards, Pat pat browne wrote: > Hi, > I want to establish the strengths and weakness of the Haskell module > system for the ontology merging task (I know it was not designed for > this!). I wish to make a new module (MERGEDONTOLOGY) from three input > modules one of which is common to the other two. > The desired merge should contain the following data types: > Woman FinancialBank HumanBeing RiverBank > Which are all identifiable without any qualifying module names. > > Below is the detailed requirement and my first attempt at this task in > Haskell. I would be grateful for any information on how to merge these > modules giving a set of unique unqualified types (i.e. without reference > to their originating modules). > > Regards, > Pat > > > > > ======================== > Informal Specification > ======================== > > The diagram and text below explain the requirement > > MERGEDONTOLOGY > { Woman, RiverBank, FinancialBank, HumanBeing} > /\ /\ > / \ > / \ > / \ > / \ > / \ > / \ > > ONTOLOGY1 ONTOLOGY2 > {Woman, Bank, Person} {Woman, Bank, Human} > /\ /\ > \ / > \ / > \ / > \ / > \ / > \ / > \ / > {Woman , Person} > COMMMON > > This example includes both synonyms and homonyms. > 1)The Woman sort (or data type) should be the same in all modules, there > is only one Woman sort and it is named as such in each module. Hence > there should be only one MERGEDONTOLOGY.Woman. > > 2)There is only one sort MERGEDONTOLOGY.HumanBeing, but there are 3 > synonyms for it called ONTOLOGY2.Human, ONTOLOGY1.Person, and > COMMON.Person. The last sentence considers ONTOLOGY1.Person and > COMMON.Person as synonyms; they have different qualifiers but the > intention is that they represnt the same thing. Hence should be mapped > to same MERGEDONTOLOGY.HumanBeing. To do this (in Maude) COMMON.Person > was renamed to ONTOLOGY2.Human which in turn was renamed to > MERGEDONTOLOGY.HumanBeing. > > 3)The homonyms are ONTOLOGY1.Bank and ONTOLOGY2.Bank should become > distinct sorts MERGEDONTOLOGY.RiverBank and > MERGEDONTOLOGY.FinancialBank in the final ontology at the top of the > diagram. > > > ================================================ > My first attemt at merging using Haskell modules > ================================================= > module COMMON where > data Woman = WomanC > data Person = PersonC > > > > module ONTOLOGY1 where > import COMMON > data Bank = BankC > > > module ONTOLOGY2 where > import COMMON > data Bank = BankC > > > > module MERGEDONTOLOGY where > import ONTOLOGY1 > import ONTOLOGY2 > > If I use qualified names all the constructors are interpreted correctly > MERGEDONTOLOGY> :t COMMON.WomanC > COMMON.WomanC :: COMMON.Woman > MERGEDONTOLOGY> :t COMMON.PersonC > COMMON.PersonC :: COMMON.Person > MERGEDONTOLOGY> :t ONTOLOGY2.BankC > ONTOLOGY2.BankC :: ONTOLOGY2.Bank > MERGEDONTOLOGY> :t ONTOLOGY1.BankC > ONTOLOGY1.BankC :: ONTOLOGY1.Bank > MERGEDONTOLOGY> :t COMMON.Woman > > However, I wish that these types and constructors be fully defined in > the context of the MERGEDONTOLOGY. I have tried type synonyms and newtypes. > type RiverBank = ONTOLOGY1.Bank > type FinancialBank = ONTOLOGY2.Bank > newtype RiverBank = BankC Int > I have not explored import modes or qualified imports. > > > From duncan.coutts at googlemail.com Sun Oct 18 13:21:37 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sun Oct 18 12:58:38 2009 Subject: [Haskell-cafe] Too much strictness in binary-0.5.0.2 In-Reply-To: <8425cc0e0910180853r6cc0df9dxdde69adaf9a12e7b@mail.gmail.com> References: <200909190036.10694.alexey.skladnoy@gmail.com> <1255792456.8777.3467.camel@localhost> <8425cc0e0910180853r6cc0df9dxdde69adaf9a12e7b@mail.gmail.com> Message-ID: <1255886497.8777.3473.camel@localhost> On Sun, 2009-10-18 at 19:53 +0400, Alexey Khudyakov wrote: > > Yes. We decided that having the Get monad as a lazy state monad just > > doesn't make sense. It makes this one use case work, but causes more > > problems generally. Certainly we need to be able to do lazy binary > > deserialisation too, but our feeling is that it should be more explicit > > and integrate better with error handling. Using a lazy state monad gives > > us neither. > > This is valid point. I think I'll just use variant with explicit laziness. > > > > Note also that if we changed runGetState to do any error handling that > > this would also break the lazy state monad properties that you were > > previously relying upon. > > I'd appreciate addition of error handling very much. Currently I have > to use ErrorT and do checks by hands. I have very simple parsers so > it's possible. It's not possible to do such things in general. > > Trading laziness for error handling is good thing I believe. At the > moment it's hard to decode possibly malformed data. It's possible to have both error handling and lazyness by extending the result to include the representation of the errors. Duncan From warren.henning at gmail.com Sun Oct 18 13:56:42 2009 From: warren.henning at gmail.com (Warren Henning) Date: Sun Oct 18 13:33:41 2009 Subject: [Haskell-cafe] Lecture Notes Advanced Functional programming available In-Reply-To: References: Message-ID: <9e5767b0910181056i6609579bn2060bc14d99d6bc6@mail.gmail.com> $83 and "3-4 weeks" for a 300 page book? Oy vey. Warren On Fri, Oct 16, 2009 at 7:24 AM, S. Doaitse Swierstra wrote: > I am happy to announce that the rworked lecture notes for the 6th Advance > Functional programming summer school have become available. From michael at snoyman.com Sun Oct 18 15:45:57 2009 From: michael at snoyman.com (Michael Snoyman) Date: Sun Oct 18 15:23:00 2009 Subject: [Haskell-cafe] Error handling package Message-ID: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> While working on the next release of data-object, I wanted to represent some operations that might fail. The typical candidates were: 1) Maybe 2) Either 3) Monad Monad is always iffy because of the often times poorly defined fail. Maybe doesn't provide any means of reporting what the problem was. Either is not defined as a Monad in the base library. Also, the usual candidate of Either String only provides for an error message. It would be nice to have more in-depth information available. So I've put together a package I call "attempt". It defines a data type called (surprise) Attempt with a Success and Failure constructor. The trick here is that it using the new extensible exceptions under the surface, so you can report any kind of exception you want. It also provides a "FromAttempt" type class for possible conversion targets from an Attempt, provides an attempt function with some helpers for performing the equivalent of Control.Exception.catches, and provides two samples of functions I would want to implement with this library: attemptJoin and attemptLookup. My questions for the list are: 1) Is the overall approach sound, or do people have better ideas? 2) Are there any other FromAttempt instances I should provide out of the box? 3) I was considering adding specialized versions of the fromAttempt function, ie ioFromAttempt, maybeFromAttempt. Thoughts? 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, or just call the functions join, lookup and force people to import the module qualified? 5) Any other suggestions for attempt functions? I've considered head/tail/etc. 6) Include ToAttempt? The code is available on github at http://github.com/snoyberg/attempt/blob/master/Data/Attempt.hs . I appreciate the review. Also, I have not yet documented the code, but I will do so before uploading to Hackage; I just didn't want to document a changing target. Thank you, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091018/dda5d9b5/attachment.html From lemming at henning-thielemann.de Sun Oct 18 17:38:39 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Oct 18 17:15:40 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> Message-ID: On Sun, 18 Oct 2009, Michael Snoyman wrote: > While working on the next release of data-object, I wanted to represent some operations > that might fail. The typical candidates were: > > 1) Maybe > 2) Either > 3) Monad > > Monad is always iffy because of the often times poorly defined fail. Maybe doesn't > provide any means of reporting what the problem was. Either is not defined as a Monad in > the base library. Also, the usual candidate of Either String only provides for an error > message. It would be nice to have more in-depth information available. > > So I've put together a package I call "attempt". It defines a data type called > (surprise) Attempt with a Success and Failure constructor. Does the explicit-exception package provide what you need? http://hackage.haskell.org/package/explicit-exception From will_n48 at yahoo.com Sun Oct 18 18:47:00 2009 From: will_n48 at yahoo.com (Will Ness) Date: Sun Oct 18 18:27:05 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> Message-ID: Gregory Propf yahoo.com> writes: > > > I actually meant it as sort of a joke but maybe it's not after all. Seriously though, using anything non-ASCII in source code is a bad idea, because there are lots of fonts and editors in the world. It seems natural to me to have (`-`2) stand for (flip (-) 2), if only that would be made legal syntax, just as (`foldl`0) stands for (flip (foldl) 0). Supposedly there is no reason to write (`:`[]) since ":" is already an infix operator, but making it a no-op wouldn't hurt, and would give us a benefit of being able finally to write the binary-minus flip-section in a visually apparent way. From lrpalmer at gmail.com Sun Oct 18 18:59:34 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Oct 18 18:36:33 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> Message-ID: <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> On Sun, Oct 18, 2009 at 4:47 PM, Will Ness wrote: > Gregory Propf yahoo.com> writes: > >> >> >> I actually meant it as sort of a joke but maybe it's not after all. > > Seriously though, using anything non-ASCII in source code is a bad idea, > because there are lots of fonts and editors in the world. > > It seems natural to me to have (`-`2) stand for (flip (-) 2), if only that > would be made legal syntax, just as (`foldl`0) stands for (flip (foldl) 0). Or you could use the "subtract" function. >>> map (subtract 2) [3,4,5] [1,2,3] I don't think syntax sugar is worth it in this case. Luke From michael at snoyman.com Sun Oct 18 19:00:22 2009 From: michael at snoyman.com (Michael Snoyman) Date: Sun Oct 18 18:37:21 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910181504x4bade642pffbc34f6ed5d5142@mail.gmail.com> Message-ID: <29bf512f0910181600v2d283cbem3a5bc211d59d2aa@mail.gmail.com> (Sorry, accidently took off cafe.) On Mon, Oct 19, 2009 at 12:44 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Mon, 19 Oct 2009, Michael Snoyman wrote: > > Does the explicit-exception package provide what you need? >> >> http://hackage.haskell.org/package/explicit-exception >> >> >> I don't think so, but correct me if I'm wrong. I want to make it easy to >> chain together >> computations which could fail in different ways. For example, something >> like this: >> >> attemptReadInt :: String -> Attempt Int >> attemptLookup :: String -> [(String, String)] -> Attempt String >> attemptLookupInt :: String -> [(String, String)] -> Attempt Int >> attemptLookupInt k m = attemptLookup k m >>= attemptReadInt >> >> Now, in the explicit-exception package, I could- in this simple example- >> define >> something like: >> >> data MyErrors = KeyNotFound | InvalidInt >> > > > type Attempt = Exceptional MyErrors > True; that's what I meant by I could do this in my simple example. > > > But this solution would not scale. >> > > You want to add other exceptions? The idea of my package is to make > exceptions explicit in the type. Otherwise you would use > extensible-exceptions. Or you could define MyErrors using an existential > type. Which is my point. I'm trying to provide a package for non-explicit exceptions. To compare to other programming languages, I think your package is providing the equivalent of Java checked exceptions, while mine is providing (safe) unchecked exceptions. I say safe because you still need to explicitly decide to turn an Attempt into a possible runtime exception which will bring down your program. Defining MyErrors using an existential type would essentially recreate the entire attempt package; I don't see that purpose in everyone wanted unchecked exceptions needing to reinvent the wheel in non-compatible ways. If multiple libraries use attempt, they can easily have their possible-error-returning functions chain together safely. > > > Additionally, there's two immediate features I think I would miss from my >> package: >> >> 1) fail works properly, so an Attempt would be a valid monad response from >> people who >> use that function. >> > > As far as I understand, 'fail' is used/abused for reporting failed pattern > matches in do notation. If a failed pattern match indicates a programming > error, it should be a really error, and not something that must be handled > at run-time. > That's a lot of very debateable statements you just made. It might be that it's strongly encouraged to only use fail for failed pattern matching, but in practice you could use it for any monadic failure. Also, there's nothing stopping a user from re-throwing pattern match exceptions received in an Attempt. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091018/1f49a9d3/attachment.html From will_n48 at yahoo.com Sun Oct 18 19:31:56 2009 From: will_n48 at yahoo.com (Will Ness) Date: Sun Oct 18 19:09:22 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> Message-ID: Luke Palmer gmail.com> writes: > > Or you could use the "subtract" function. > > >>> map (subtract 2) [3,4,5] > [1,2,3] I don't want to. > > I don't think syntax sugar is worth it in this case. I do. Operators are great because they make our intent visible, immediately apparent. Long words' meaning, like subtract's, is not immediately apparent, and they break consistency. Not everyone's first language in life was English, you see. (`foldl`2) works. (`-`2) should too. I'll settle for (+(-2)) for now, but it ain't that pretty. From phi500ac at yahoo.ca Sun Oct 18 23:07:23 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Sun Oct 18 22:44:25 2009 Subject: [Haskell-cafe] Problems with Haskell Message-ID: <95394.58142.qm@web58805.mail.re1.yahoo.com> Before anything else, I want to point out that I have no intention to confront your community, or denigrate Haskell. A few days ago I answered an email from a Clean programmer on something related to Clean. He was worried that Clean team could give up its good work, and Clean could disappear; therefore, he was thinking about switching to Haskell. Since I thought that my email could be of interest for the Clean community, I posted it in the -- small-- Clean list :-(Clean is not as popular as Haskell). I received a lot of furious and offensive private emails for suggesting the Clean programmer to stick with Clean. However, I also received a very polite, humorous, and illuminating private email from a person who seems to work at Microsoft. His name is Simon Peyton-Jones. He urged me to post my comments on a Haskell cafe. He also filed one of my comments as a bug in a Haskell bug track. Here is a couple of snippets from his email: --- I think it's v bad that a straightforward program runs so slowly, and it's certainly true that this is an area we could pay more attention to. --- Meanwhile, I'm curious: are the arrays in Philippos's program strict?? Or lazy?? If strict, that's a pretty big difference. Therefore, here are my comments, with a lot of code. A few months ago I came accross an unpublished article about a novel genetic programming system. The system was coded in Larceny Scheme. I translated it to Clean and to Haskell. Unhappily, I cannot post the program here because it is very large, and the authors of the original Lisp program don't want me to divulge it before they see in in a printed page of a Journal. Therefore, I wrote an empty genetic programming framework, just to compare languages. Comparing Clean and Haskell, I noticed: 1 -- Clean compiler almost never let me do very stupid things, like trying to unbox a tree, or to write in a closed file (I will post an example of this in a near future). For instance, Clean compiler would never swallow something like the code below: import Control.Monad.ST import Data.Array.ST import Data.Array.Base import System.Random data Op = AND | OR | NOT; data Tree= L Double | T Op [Tree] main = print $ runST ????????? (do arr <- newArray (1,2000000) (L 0.0) :: ST s? (STArray s Int Tree)????????????????? ? ???????????? ? ????????????? go? arr 2000000 0.0 ) go ::? STArray s Int Tree -> Int -> Double -> ST s Double go a i acc ? | i < 1 = return acc ? | otherwise=do ?????????????? b <- unsafeRead a i {- readArray a i -} ?????????????? writeArray a i (setDouble ((getDouble b)+3.0)) ?????????????? c <-? readArray a i ?????????????? go? a (i-1) (acc+ (getDouble c)) -- What I really need is a random index in Haskell. ??????????? ? getDouble (L r)= r getDouble _ = 0.0 setDouble r= L r 2 -- Safety does not cost much in Clean. For instance, removing array boundary check does not seem to affect Clean. I believe that it does not affect Haskell either, but I have not verified this point. 3 -- Haskell seems to loop more often than Clean. For instance, Haskell may loop if I change function mutate to mutate e (L i) xs = (e, xs) mutate e t (y:ys) = ins t (rnLen t y, ys) where ? ins (T p (L i:xs)) (0, st)=(T p (e:xs), st) ? ins (T p (t:xs)) (n,(r1:rs)) | n > 0= ??? let (T p mt, s2)= ins (T p xs)(n-1, rs) ????? in (T p (t:mt), s2) ? ins (T p (t:xs)) (n,(r1:rs)) ??? | rn 2 r1== 0= (T p (e:xs), rs) ??? | rn 2 r1== 1= let (xpr, st)= mutate e t rs ???????????????????? in (T p (xpr:xs), st) ??????????????????? ? This might be a bug in my implementation of show Tree. It would be great if you people could "show" me what I did wrong. 4 -- On the plus side, there are libraries in Haskell that seem to behave better than the Clean equivalent libraries. This could be explained by the fact that there are a lot of people coding Haskell libraries, while Clean team seems to be reluctant in accepting libraries from outsiders. For instance, lethevert made a very important improvement in ObjectIO (changing fonts in edit text field), but it was never incorporated into Clean (yes, I wrote a lot of emails to Clean? team about it). Last year, when I was learning Clean, I discovered that many of my professors and teachers are presbyopic. Therefore, it would be a good policy to use very large fonts for homework. I only succeeded in doing it thanks to lethevert. In the case of the program below, Haskell System.Random library seems to work much better than Clean MersenneTwister. 5 --- Any improvement in the program below will be welcome. The program is already very fast thanks to suggestions I received from the bug track people, and from Peyton-Jones. Function "show" seems to loop if I replace mutate in item 3 for mutate in the code below. {- ghc gp.hs -O2 --make -} {- Execute:? gp.exe +RTS -sstderr -} import Control.Monad.ST import Data.Array.ST import Data.Array.Base import System.Random data Op = AND | OR | NOT; data Tree= L Int | T Op [Tree] psz= 20000 thr=4.0 gates= [AND, NOT, OR] table= [ (False, False, False), (True, False, True), ???????? (True, True, False), (False, True, True)] prt NOT= "NOT" prt OR= "OR" prt AND= "AND" instance Show Tree where ??? show (L i) = "L"++(show i) ??? show (T p xs) = (prt p)++(show xs) main = do ?? xs <- (rnList (1, 20000)) ?? print? $ runST $ do ????? arr <- newArray_ (1,psz)? :: ST s (STArray s Int Tree) ????? (arr, xs1) <- gen0 arr psz xs ????? g1 <- evolve 30 arr (L 0) xs1; return $ g1 gen0 a i xs = if i<=0 then return(a,xs) else do ???? (tree, rs) <- return(rndXpr gates 5 xs) ???? writeArray a i tree ???? gen0 a (i-1)? rs mutate e (L i) xs = (e, xs) mutate e t (y:ys) = ins t (rnLen t y, ys) where ? ins (T p (L i:xs)) (0, st)=(T p (e:xs), st) ? ins (T p (t:xs)) (n,(r1:rs)) | n > 0= ??? let (T p mt, s2)= ins (T p xs)(n-1, rs) ????? in (T p (t:mt), s2) ? ins (T p (t:xs)) (n,(r1:rs)) ??? | rn 2 r1== 0= (T p (e:xs), rs) ??? | rn 2 r1== 1= let (xpr, st)= mutate e t rs ???????????????????? in (T p (xpr:xs), st) fxy NOT r= T NOT [L (rn 2 r)] fxy AND st = T AND [L 0, L 1] fxy OR? st = T OR? [L 0, L 1] rndXpr fs? beastSz xs= loop beastSz xs where ? rth s r= s!!(rn (length s) r) ? loop n (r1:r2:rs) ???? | n<1 = (fxy (rth fs r1) r1, rs) ???? |otherwise= mutate (fxy (rth fs r1) r2) f1 rs ??? where (f1, ys)=? loop (n-1) rs run (L 0) x y= x -- Interpreter run (L 1) x y= y run (T AND xs) x y = and [run c x y? | c <- xs] run (T OR xs) x y= or [run c x y | c <- xs] run (T NOT (t:_)) x y= not (run t x y) rn n r= (abs r) `rem` n rnLen (T _ s) r= rn (length s) r rnList :: (Int, Int) -> IO [Int] rnList r=getStdGen>>=(\x->return(randomRs r x)) frag? (L i)? st = (L i, st) frag (T p xs) (r1:r2:rs) ? | rn 2 r2==0= (xpr, rs) ? | otherwise= frag xpr rs ? ?where xpr= xs!!(rnLen (T p xs) r1) crossover e1 e2 rs = ([c2, c1], rs4)? where ?? (g1, rs1) = frag e1 rs ?? (g2, rs2) = frag e2 rs1 ?? (c1, rs3) = mutate g1 e2 rs2 ?? (c2, rs4) = mutate g2 e1 rs3 nGates (L i)= 0.0 nGates (T p xs) = (-0.1) + sum [nGates g | g <- xs]? ? fitness tt gt = (ng + 1.0 + sum [ft t | t <- tt]) where ?? ng= nGates gt ?? ft (out, t1, t2) | run gt t1 t2 == out= 1.0 ?? ft _ = 0.0 evolve n p b xs | n < 1 = do ?? (arr, xs1) <- gen0 p psz xs ?? evolve 30 arr b xs1 evolve n p b (r1:r2:rs) = do ???? n1 <- return $ 1+(rn psz r1) ???? n2 <- return $ 1+(rn psz r2) ???? g1 <- readArray p n1; g2 <- readArray p n2 ???? ([c1,c2], rs) <- return $ crossover g1 g2 rs ???? insrt c1 p 1 psz ???? insrt c2 p 1 psz ???? res <- best 1 b p ???? fitn <- return $ fitness table res ???? if fitn > thr ?????? then return res else evolve (n-1) p res rs best i res p | i >= psz= return res best i fg p= do ? g <- readArray p i ? if (fitness table fg) > (fitness table g) ?????? then best (i+1) fg p else best (i+1) g p insrt g v i sz | i >= sz = return () insrt g v i sz = do ?? a <- readArray v i ?? fg <- return $ fitness table g ?? fa <- return $ fitness table a ?? if fa > fg then insrt g v (i+1) sz ???? else do writeArray v i g ? __________________________________________________________________ Connect with friends from any web browser - no download required. Try the new Yahoo! Canada Messenger for the Web BETA at http://ca.messenger.yahoo.com/webmessengerpromo.php -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091018/e279e68f/attachment-0001.html From wren at freegeek.org Mon Oct 19 00:09:31 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Oct 18 23:46:33 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> Message-ID: <4ADBE67B.8060101@freegeek.org> Will Ness wrote: > Luke Palmer gmail.com> writes: >> Or you could use the "subtract" function. >> >> >>> map (subtract 2) [3,4,5] >> [1,2,3] > > I don't want to. > >> I don't think syntax sugar is worth it in this case. > > I do. Operators are great because they make our intent visible, immediately > apparent. Long words' meaning, like subtract's, is not immediately apparent, > and they break consistency. Not everyone's first language in life was English, > you see. I'm with Luke on this one. It's a shame that negation uses the same symbolic identifier as subtraction, but introducing this new sugar only serves to make things more complex than they already are. If anything, negation should be moved to using a different identifier to remove the current ambiguity (as is done in some other languages). > (`foldl`2) works. > > (`-`2) should too. The `` syntax is for converting lexical identifiers into infix operators. Symbolic identifiers are already infix, which is why `` doesn't work for them. If we introduced this then those striving for consistency would be right in requesting that this pattern be allowed for all symbolic operators. I for one am opposed to introducing superfluous syntax for duplicating the current ability to write things in the same ways. Attack the underlying problem, don't introduce hacks to cover up broken hacks. This isn't C++. -- Live well, ~wren From z_axis at 163.com Mon Oct 19 01:33:09 2009 From: z_axis at 163.com (zaxis) Date: Mon Oct 19 01:10:07 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? Message-ID: <25953522.post@talk.nabble.com> winSSQ count noRed noBlue = do { yesRed <- [1..33] \\ noRed; yesBlue <- [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); return () } will report: Couldn't match expected type `IO ()' against inferred type `[()]' In a stmt of a 'do' expression: bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\ hd1 -> pickSSQ count yesRed yesBlue hd1) However, the following works fine: winSSQ count noRed noBlue = do let yesRed = [1..33] \\ noRed let yesBlue = [1..16] \\ noBlue bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1) Why ? -- View this message in context: http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p25953522.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From pumpkingod at gmail.com Mon Oct 19 01:38:58 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Mon Oct 19 01:15:57 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <25953522.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> Message-ID: They're "in" different Monads. The first one does x <- [...], which means that you're operating in the list Monad instance, and bracket operates in the IO Monad. The second one uses let x = [...] which doesn't have any effect on what Monad you're in, so the whole thing can be in IO. Note that when you do x <- [1..3]; y <- [4..6] you're going to get all 9 pairs of values from x and y, by the way. Hope this helps, Dan On Mon, Oct 19, 2009 at 1:33 AM, zaxis wrote: > > winSSQ count noRed noBlue = do { > ? ?yesRed <- ?[1..33] \\ noRed; > ? ?yesBlue <- [1..16] \\ noBlue; > ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1); > ? ?return () > } > will report: > Couldn't match expected type `IO ()' against inferred type `[()]' > ? ?In a stmt of a 'do' expression: > ? ? ? ?bracket > ? ? ? ? ?(openFile "ssqNum.txt" WriteMode) > ? ? ? ? ?(hClose) > ? ? ? ? ?(\ hd1 -> pickSSQ count yesRed yesBlue hd1) > > However, the following works fine: > > winSSQ count noRed noBlue = do > ? ?let yesRed = ?[1..33] \\ noRed > ? ?let yesBlue = [1..16] \\ noBlue > ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1) > > Why ? > -- > View this message in context: http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p25953522.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From z_axis at 163.com Mon Oct 19 02:10:51 2009 From: z_axis at 163.com (zaxis) Date: Mon Oct 19 01:47:49 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: References: <25953522.post@talk.nabble.com> Message-ID: <25953716.post@talk.nabble.com> thanks for your quick answer. But winSSQ count noRed noBlue = do { let yesRed = [1..33] \\ noRed; let yesBlue = [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } will report: parse error on input `let' Daniel Peebles wrote: > > They're "in" different Monads. The first one does x <- [...], which > means that you're operating in the list Monad instance, and bracket > operates in the IO Monad. The second one uses let x = [...] which > doesn't have any effect on what Monad you're in, so the whole thing > can be in IO. > > Note that when you do x <- [1..3]; y <- [4..6] you're going to get all > 9 pairs of values from x and y, by the way. > > Hope this helps, > Dan > > On Mon, Oct 19, 2009 at 1:33 AM, zaxis wrote: >> >> winSSQ count noRed noBlue = do { >> ? ?yesRed <- ?[1..33] \\ noRed; >> ? ?yesBlue <- [1..16] \\ noBlue; >> ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ >> count yesRed yesBlue hd1); >> ? ?return () >> } >> will report: >> Couldn't match expected type `IO ()' against inferred type `[()]' >> ? ?In a stmt of a 'do' expression: >> ? ? ? ?bracket >> ? ? ? ? ?(openFile "ssqNum.txt" WriteMode) >> ? ? ? ? ?(hClose) >> ? ? ? ? ?(\ hd1 -> pickSSQ count yesRed yesBlue hd1) >> >> However, the following works fine: >> >> winSSQ count noRed noBlue = do >> ? ?let yesRed = ?[1..33] \\ noRed >> ? ?let yesBlue = [1..16] \\ noBlue >> ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ >> count yesRed yesBlue hd1) >> >> Why ? >> -- >> View this message in context: >> http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p25953522.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p25953716.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From thomas.dubuisson at gmail.com Mon Oct 19 02:35:32 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon Oct 19 02:12:30 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <25953716.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> Message-ID: <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> > thanks for your quick answer. But I think he actually answered your question. I.e. try it with this extra 'do' statement: winSSQ count noRed noBlue = do { do ? ?let yesRed = ?[1..33] \\ noRed; ? ?let yesBlue = [1..16] \\ noBlue; ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } In the future please use complete examples that have all variables and import statements. It helps us help you. Cheers, Thomas From z_axis at 163.com Mon Oct 19 02:50:55 2009 From: z_axis at 163.com (zaxis) Date: Mon Oct 19 02:27:52 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> Message-ID: <25953946.post@talk.nabble.com> The original code is: winSSQ count noRed noBlue = do let yesRed = [1..33] \\ noRed let yesBlue = [1..16] \\ noBlue bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1) It works very well. However, as i am used to C style so i want convert it into winSSQ count noRed noBlue = do { let yesRed = [1..33] \\ noRed; let yesBlue = [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } or winSSQ count noRed noBlue = do { yesRed <- [1..33] \\ noRed; yesBlue <- [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } but all fail ! Thomas DuBuisson wrote: > >> thanks for your quick answer. But > I think he actually answered your question. I.e. try it with this > extra 'do' statement: > > winSSQ count noRed noBlue = do { do > ? ?let yesRed = ?[1..33] \\ noRed; > ? ?let yesBlue = [1..16] \\ noBlue; > ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> > pickSSQ count yesRed yesBlue hd1); > } > > In the future please use complete examples that have all variables and > import statements. It helps us help you. > > Cheers, > Thomas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p25953946.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From apfelmus at quantentunnel.de Mon Oct 19 04:10:36 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Mon Oct 19 03:48:05 2009 Subject: [Haskell-cafe] Re: How to use "bracket" properly ? In-Reply-To: <25953946.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> Message-ID: zaxis wrote: > It works very well. However, as i am used to C style so i want convert it > into > > winSSQ count noRed noBlue = do { > let yesRed = [1..33] \\ noRed; > let yesBlue = [1..16] \\ noBlue; > bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1); > } You need to put brackets around the declarations in a let as well: winSSQ count noRed noBlue = do { let { yesRed = [1..33] \\ noRed }; let { yesBlue = [1..16] \\ noBlue }; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } Regards, apfelmus -- http://apfelmus.nfshost.com From ketil at malde.org Mon Oct 19 04:18:06 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Oct 19 03:55:00 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <25953946.post@talk.nabble.com> (zaxis's message of "Sun, 18 Oct 2009 23:50:55 -0700 (PDT)") References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> Message-ID: <871vkz3igx.fsf@malde.org> zaxis writes: > winSSQ count noRed noBlue = do > let yesRed = [1..33] \\ noRed > let yesBlue = [1..16] \\ noBlue > bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1) > It works very well. However, as i am used to C style so i want convert it > into > winSSQ count noRed noBlue = do { > let yesRed = [1..33] \\ noRed; ^^^ ^ Didn't you just comment out your semicolons? > let yesBlue = [1..16] \\ noBlue; > bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1); > } -k -- If I haven't seen further, it is by standing in the footprints of giants From ithika at gmail.com Mon Oct 19 04:22:44 2009 From: ithika at gmail.com (Dougal Stanton) Date: Mon Oct 19 03:59:42 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <871vkz3igx.fsf@malde.org> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> <871vkz3igx.fsf@malde.org> Message-ID: <2d3641330910190122x49eef61fk24b518b68371d6dd@mail.gmail.com> On Mon, Oct 19, 2009 at 9:18 AM, Ketil Malde wrote: > zaxis writes: > >> winSSQ count noRed noBlue = do >> ? ? let yesRed = ?[1..33] \\ noRed >> ? ? let yesBlue = [1..16] \\ noBlue >> ? ? bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ >> count yesRed yesBlue hd1) > >> It works very well. However, as i am used to C style so i want convert it >> into > >> winSSQ count noRed noBlue = do { >> ? ? let yesRed = ?[1..33] \\ noRed; > > ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^ ? ? ^ > Didn't you just comment out your semicolons? Hi Ketil, That's the first thing I thought when I read this code, then I realised.... those aren't comment delimiters in Haskell! :-) D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From miguelimo38 at yandex.ru Mon Oct 19 04:20:54 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Oct 19 04:00:08 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <871vkz3igx.fsf@malde.org> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> <871vkz3igx.fsf@malde.org> Message-ID: <4ADC2166.8050406@yandex.ru> Ketil Malde wrote: >> winSSQ count noRed noBlue = do { >> let yesRed = [1..33] \\ noRed; > > ^^^ ^ > Didn't you just comment out your semicolons? That was my initial reaction. Until I remembered that Haskell has a different comment style. From ketil at malde.org Mon Oct 19 04:25:27 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Oct 19 04:02:21 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <871vkz3igx.fsf@malde.org> (Ketil Malde's message of "Mon, 19 Oct 2009 10:18:06 +0200") References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> <871vkz3igx.fsf@malde.org> Message-ID: <87ws2r23k8.fsf@malde.org> Ketil Malde writes: > Didn't you just ... Oh, dear. Sorry about that. -k -- If I haven't seen further, it is by standing in the footprints of giants From dougal at dougalstanton.net Mon Oct 19 04:30:55 2009 From: dougal at dougalstanton.net (Dougal Stanton) Date: Mon Oct 19 04:07:53 2009 Subject: [Haskell-cafe] Hackage down Message-ID: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> Has not been responding for at least the last 12 hours. Is there somewhere to look for status reports on sysadmin details like this, so we can tell if - it's a scheduled down time - it's a problem but the admins know about it - etc etc. D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From deniz.a.m.dogan at gmail.com Mon Oct 19 04:54:15 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Mon Oct 19 04:31:36 2009 Subject: [Haskell-cafe] Hackage down In-Reply-To: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> References: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> Message-ID: <7b501d5c0910190154r3bb6f5a9ldba8158ec90cec65@mail.gmail.com> 2009/10/19 Dougal Stanton : > Has not been responding for at least the last 12 hours. > > Is there somewhere to look for status reports on sysadmin details like > this, so we can tell if > > - it's a scheduled down time > - it's a problem but the admins know about it > - etc etc. > > D > The explanations I heard were: * "The Galois guys got their math wrong and folded monk's disk into R^0 space." * "Might be concerned with CERN." * "lambdabot hacked Hackage and uses it to plot her plans for world-domination, faster." All from the same person, incidentally! -- Deniz Dogan From ross at soi.city.ac.uk Mon Oct 19 06:18:52 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Mon Oct 19 05:55:51 2009 Subject: [Haskell-cafe] Hackage down In-Reply-To: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> References: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> Message-ID: <20091019101852.GA6516@soi.city.ac.uk> On Mon, Oct 19, 2009 at 09:30:55AM +0100, Dougal Stanton wrote: > Has not been responding for at least the last 12 hours. > > Is there somewhere to look for status reports on sysadmin details like > this, so we can tell if > > - it's a scheduled down time > - it's a problem but the admins know about it > - etc etc. {hackage,darcs,cvs}.haskell.org has been up continuously for 6 days and is still working via ssh, but Apache isn't responding. From z_axis at 163.com Mon Oct 19 07:44:30 2009 From: z_axis at 163.com (zaxis) Date: Mon Oct 19 07:21:28 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> Message-ID: <25956932.post@talk.nabble.com> oh! thanks! But why ? Heinrich Apfelmus wrote: > > zaxis wrote: >> It works very well. However, as i am used to C style so i want convert it >> into >> >> winSSQ count noRed noBlue = do { >> let yesRed = [1..33] \\ noRed; >> let yesBlue = [1..16] \\ noBlue; >> bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ >> count yesRed yesBlue hd1); >> } > > You need to put brackets around the declarations in a let as well: > > winSSQ count noRed noBlue = do { > let { yesRed = [1..33] \\ noRed }; > let { yesBlue = [1..16] \\ noBlue }; > bracket (openFile "ssqNum.txt" WriteMode) (hClose) > (\hd1 -> pickSSQ count yesRed yesBlue hd1); > } > > > Regards, > apfelmus > > -- > http://apfelmus.nfshost.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/How-to-use-%22bracket%22-properly---tp25953522p25956932.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From vandijk.roel at gmail.com Mon Oct 19 08:10:30 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Oct 19 07:47:28 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <25956932.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> <25956932.post@talk.nabble.com> Message-ID: On Mon, Oct 19, 2009 at 1:44 PM, zaxis wrote: > oh! thanks! ?But why ? A let can introduce multiple declarations. So this foo = do let x = 3 let y = 4 return $ x+ y can also be written like foo = do let x = 3 y = 4 -- no let return $ x + y With explicit blocks: foo = do { let {x = 3; y = 4;}; return $ x + y; } From jpm at cs.uu.nl Mon Oct 19 08:27:02 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Mon Oct 19 08:04:21 2009 Subject: [Haskell-cafe] Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) In-Reply-To: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> References: <9979e72e0910110558p172620f9p8a4e4c726b073caa@mail.gmail.com> Message-ID: <52f14b210910190527v1f8befffu61d48080693afb63@mail.gmail.com> Hi, While I agree that the documentation of Data.Generics is not perfect, I do not think it is possible to have the haddock documentation be self-contained. For a thorough understanding of syb, a user has to read the two initial papers, which are linked from the haddock documentation. I also do not think it's reasonable to explain all the details beyond monads in the Control.Monad haddock, for instance. For the problem at hand (a Data instance for Text), I can only say that generic programming and abstract datatypes do not mix too well (although there is work on the area, see [1]). Generics work by exploiting the structure of types, and if that structure is explicitly kept hidden then (rather ad hoc) workarounds have to be used. See, for example, the Data instance for Array: -- The Data instance for Array preserves data abstraction at the cost of > -- inefficiency. We omit reflection services for the sake of data > abstraction. > instance (Typeable a, Data b, Ix a) => Data (Array a b) > where > gfoldl f z a = z (listArray (bounds a)) `f` (elems a) > toConstr _ = error "toConstr" > gunfold _ _ = error "gunfold" > dataTypeOf _ = mkNorepType "Data.Array.Array" > Cheers, Pedro [1] http://www.comlab.ox.ac.uk/publications/publication1385-abstract.html On Sun, Oct 11, 2009 at 14:58, John Lato wrote: > For anyone writing introductions to generic programming, take this as > a plea from Haskellers everywhere. If one of the RWH authors can't > understand how to make use of these techniques, what hope do the rest > of us have? > > John Lato > > P.S. Some might wryly note that I'm the maintainer of a package which > is also known for incomprehensible documentation. To which I would > reply that our effort is much newer, I consider it a problem, and it's > being worked on, contrasted to the state of GP where similarly > impenetrable documentation has been and continues to be the norm. > > > > > From: "Bryan O'Sullivan" > > > > I think maybe someone else will have to take a crack at a Data instance > for > > Text, because the documentation for Data.Data is not written in English. > In > > its syntax and structure, it closely hews to what we think of as English, > > but it is the kind of documentation that can only be understood by > someone > > who already knows what it is going to say. > > > > This is an exemplar of my experience with the cottage industry of generic > > programming in Haskell: I'd really quite like to use the stuff, but for > > goodness's sake, o beloved researchers, please aim your expository papers > at > > non-specialists once in a while. An endless chain of papers of the form > "my > > technique, which you won't understand, is better than this other > technique, > > which you haven't read about and won't anyway understand, in subtle ways > > that you won't understand" does not feel to me like progress. > > > > Yours in some misery and frustration, > > Bryan. > _______________________________________________ > 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/20091019/f633ba62/attachment.html From lrpalmer at gmail.com Mon Oct 19 08:46:01 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Oct 19 08:22:58 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> <25956932.post@talk.nabble.com> Message-ID: <7ca3f0160910190546j2589b07cw5110d0167a7253d6@mail.gmail.com> On Mon, Oct 19, 2009 at 6:10 AM, Roel van Dijk wrote: > On Mon, Oct 19, 2009 at 1:44 PM, zaxis wrote: >> oh! thanks! ?But why ? > > A let can introduce multiple declarations. > > So this > > foo = do > ?let x = 3 > ?let y = 4 > ?return $ x+ y > > can also be written like > > foo = do > ?let x = 3 > ? ? ?y = 4 -- no let > ?return $ x + y To be clear, the reason this breaks is because this is a valid let syntax: let x = 1 ; y = 2 in x + y See the semicolon? So when you put a let in a block, and it sees the semicolon at the end of the line, it is expecting another let binding. If there's a newline, then the layout rule applies and the next line is considered the start of a new layout block, even though it's at the same level. So, basically, everything gets borked up. > With explicit blocks: > > foo = do { > ?let {x = 3; y = 4;}; > ?return $ x + y; > } > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From sfvisser at cs.uu.nl Mon Oct 19 09:28:43 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Mon Oct 19 09:05:41 2009 Subject: [Haskell-cafe] Hackage down In-Reply-To: <20091019101852.GA6516@soi.city.ac.uk> References: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> <20091019101852.GA6516@soi.city.ac.uk> Message-ID: <0F7BA9EE-66EC-4FFC-A20F-C6598DE1D852@cs.uu.nl> On Oct 19, 2009, at 12:18 PM, Ross Paterson wrote: > On Mon, Oct 19, 2009 at 09:30:55AM +0100, Dougal Stanton wrote: >> Has not been responding for at least the last 12 hours. >> >> Is there somewhere to look for status reports on sysadmin details >> like >> this, so we can tell if >> >> - it's a scheduled down time >> - it's a problem but the admins know about it >> - etc etc. > > {hackage,darcs,cvs}.haskell.org has been up continuously for 6 days > and > is still working via ssh, but Apache isn't responding. Anyone any clue how to get the thing running again? We're trying to install a new Haskell-development machine here which is near impossible without the wonderful Hackage. Thanks, -- Sebastiaan Visser From pepeiborra at gmail.com Mon Oct 19 09:46:26 2009 From: pepeiborra at gmail.com (Jose Iborra) Date: Mon Oct 19 09:23:27 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: <29bf512f0910181600v2d283cbem3a5bc211d59d2aa@mail.gmail.com> References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910181504x4bade642pffbc34f6ed5d5142@mail.gmail.com> <29bf512f0910181600v2d283cbem3a5bc211d59d2aa@mail.gmail.com> Message-ID: You may want to take a look at another option in Hackage, the control- monad-exception package. http://pepeiborra.github.com/control-monad-exception/ The control-monad-exception library provides the building blocks for * Explicitly Typed exceptions (checked or not) * which are composable * and even provide stack traces (experimental feature) On 19/10/2009, at 01:00, Michael Snoyman wrote: > (Sorry, accidently took off cafe.) > > On Mon, Oct 19, 2009 at 12:44 AM, Henning Thielemann > wrote: > > On Mon, 19 Oct 2009, Michael Snoyman wrote: > > Does the explicit-exception package provide what you need? > > http://hackage.haskell.org/package/explicit-exception > > > I don't think so, but correct me if I'm wrong. I want to make it > easy to chain together > computations which could fail in different ways. For example, > something like this: > > attemptReadInt :: String -> Attempt Int > attemptLookup :: String -> [(String, String)] -> Attempt String > attemptLookupInt :: String -> [(String, String)] -> Attempt Int > attemptLookupInt k m = attemptLookup k m >>= attemptReadInt > > Now, in the explicit-exception package, I could- in this simple > example- define > something like: > > data MyErrors = KeyNotFound | InvalidInt > > > type Attempt = Exceptional MyErrors > > True; that's what I meant by I could do this in my simple example. > > > But this solution would not scale. > > You want to add other exceptions? The idea of my package is to make > exceptions explicit in the type. Otherwise you would use extensible- > exceptions. Or you could define MyErrors using an existential type. > > Which is my point. I'm trying to provide a package for non-explicit > exceptions. To compare to other programming languages, I think your > package is providing the equivalent of Java checked exceptions, > while mine is providing (safe) unchecked exceptions. I say safe > because you still need to explicitly decide to turn an Attempt into > a possible runtime exception which will bring down your program. > > Defining MyErrors using an existential type would essentially > recreate the entire attempt package; I don't see that purpose in > everyone wanted unchecked exceptions needing to reinvent the wheel > in non-compatible ways. If multiple libraries use attempt, they can > easily have their possible-error-returning functions chain together > safely. > I believe that control-monad-exception solves this tension between composability and explicit exceptions. You can have explicit exceptions which are composable: > data DivideByZero = DivideByZero deriving (Show, Typeable) > data SumOverflow = SumOverflow deriving (Show, Typeable) > instance Exception DivideByZero > instance Exception SumOverflow > data Expr = Add Expr Expr | Div Expr Expr | Val Double > eval (Val x) = return x > eval (Add a1 a2) = do > v1 <- eval a1 > v2 <- eval a2 > let sum = v1 + v2 > if sum < v1 || sum < v2 then throw SumOverflow else return sum > eval (Div a1 a2) = do > v1 <- eval a1 > v2 <- eval a2 > if v2 == 0 then throw DivideByZero else return (v1 / v2) GHCi infers the following types > :t eval > eval :: (Throws DivideByZero l, Throws SumOverflow l) => Expr -> EM l Double > :t eval `catch` \ (e::DivideByZero) -> return (-1) > .... :: Throws SumOverflow l => Expr -> EM l Double > :t runEM(eval `catch` \ (e::SomeException) -> return (-1)) > .... : Expr -> Double > > Additionally, there's two immediate features I think I would miss > from my package: > > 1) fail works properly, so an Attempt would be a valid monad > response from people who > use that function. > > As far as I understand, 'fail' is used/abused for reporting failed > pattern matches in do notation. If a failed pattern match indicates > a programming error, it should be a really error, and not something > that must be handled at run-time. > > That's a lot of very debateable statements you just made. It might > be that it's strongly encouraged to only use fail for failed pattern > matching, but in practice you could use it for any monadic failure. > Also, there's nothing stopping a user from re-throwing pattern match > exceptions received in an Attempt. I am with Henning on 'fail'. It must not be used as a replacement for throw, only for failed pattern matches which are programming errors and thus unchecked exceptions. From korpios at korpios.com Mon Oct 19 11:06:08 2009 From: korpios at korpios.com (Tom Tobin) Date: Mon Oct 19 10:43:06 2009 Subject: [Haskell-cafe] Hackage down In-Reply-To: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> References: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> Message-ID: On Mon, Oct 19, 2009 at 3:30 AM, Dougal Stanton wrote: > Has not been responding for at least the last 12 hours. > > Is there somewhere to look for status reports on sysadmin details like > this, so we can tell if Or even better, might it be possible to look into setting up a fallback mirror of Hackage? From wss at cs.nott.ac.uk Mon Oct 19 11:07:26 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Mon Oct 19 10:44:24 2009 Subject: [Haskell-cafe] \Statically checked binomail heaps? In-Reply-To: <7dfaed80910180349t6cbd688bref0e6de70067fb9c@mail.gmail.com> References: <7dfaed80910180349t6cbd688bref0e6de70067fb9c@mail.gmail.com> Message-ID: <3CB03BBC-A2A4-4BDD-976F-05BABDADD25B@cs.nott.ac.uk> Hi Maciej, > insTree t [] = [t] > insTree t ts@(t':ts') > | rank t < rank t' = t : ts > | otherwise = insTree (link t t') ts' In a way, it's unsurprising that this is where your code breaks. What you're doing here is using a boolean guard to determine where to insert. The problem is that ghc's type checker doesn't learn anything from these boolean guards. In contrast to pattern matching on a GADT, you can always exchange the two branches of an if-than-else without breaking type correctness. To get the code to work the type checker needs learn something about the ranks of t and t' after comparing them. > Have anyone an idea how make this code working? Use a different language. In particular, you might want to have a look at Agda - a programming language and proof assistand based on dependent types that has a very similar look-and-feel to Haskell. If you're interested, you may want to have a look at similar developments by some of our students at Chalmers: http://web.student.chalmers.se/groups/datx02-dtp/ They've given verified implementations in Agda of some fairly advanced data structures. Hope this helps, Wouter PS - There may be a way around this by writing even more type-level programs in Haskell, basically reflecting (<) on the type-level and doing some really hard work to relate the type level numbers to the value level numbers. Brace yourself for a world of pain. From dons at galois.com Mon Oct 19 11:54:46 2009 From: dons at galois.com (Don Stewart) Date: Mon Oct 19 11:31:51 2009 Subject: [Haskell-cafe] Hackage down In-Reply-To: <0F7BA9EE-66EC-4FFC-A20F-C6598DE1D852@cs.uu.nl> References: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> <20091019101852.GA6516@soi.city.ac.uk> <0F7BA9EE-66EC-4FFC-A20F-C6598DE1D852@cs.uu.nl> Message-ID: <20091019155446.GA4165@whirlpool.galois.com> sfvisser: > On Oct 19, 2009, at 12:18 PM, Ross Paterson wrote: >> On Mon, Oct 19, 2009 at 09:30:55AM +0100, Dougal Stanton wrote: >>> Has not been responding for at least the last 12 hours. >>> >>> Is there somewhere to look for status reports on sysadmin details >>> like >>> this, so we can tell if >>> >>> - it's a scheduled down time >>> - it's a problem but the admins know about it >>> - etc etc. >> >> {hackage,darcs,cvs}.haskell.org has been up continuously for 6 days >> and >> is still working via ssh, but Apache isn't responding. > > > Anyone any clue how to get the thing running again? We're trying to > install a new Haskell-development machine here which is near impossible > without the wonderful Hackage. We're working on getting monk back in service. More news to follow -- Don From michael at snoyman.com Mon Oct 19 15:19:26 2009 From: michael at snoyman.com (Michael Snoyman) Date: Mon Oct 19 14:56:24 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: <21E15C20-3601-4851-8996-3AA7A6DBD29F@gmail.com> References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910181504x4bade642pffbc34f6ed5d5142@mail.gmail.com> <29bf512f0910181600v2d283cbem3a5bc211d59d2aa@mail.gmail.com> <21E15C20-3601-4851-8996-3AA7A6DBD29F@gmail.com> Message-ID: <29bf512f0910191219x3f11ea8cwa1700706aa908882@mail.gmail.com> On Mon, Oct 19, 2009 at 3:39 PM, Jose Iborra wrote: > You may want to take a look at anoother option in Hackage, the > control-monad-exception package. > > http://pepeiborra.github.com/control-monad-exception/ > > The control-monad-exception library provides the building blocks for > > * Explicitly Typed exceptions (checked or not) > * which are composable > * and even provide stack traces (experimental feature) Jose, Thank you very much, thinks looks like just the thing I was looking for. The only thing that slightly concerns me is the transformers dependency, but it's not a serious worry. I'd love to try out the package right now, but with hackage being down I can't get the dependencies yet ;). I'll try it out as soon as I can. > > > > On 19/10/2009, at 01:00, Michael Snoyman wrote: > > (Sorry, accidently took off cafe.) >> >> On Mon, Oct 19, 2009 at 12:44 AM, Henning Thielemann < >> lemming@henning-thielemann.de> wrote: >> >> On Mon, 19 Oct 2009, Michael Snoyman wrote: >> >> Does the explicit-exception package provide what you need? >> >> http://hackage.haskell.org/package/explicit-exception >> >> >> I don't think so, but correct me if I'm wrong. I want to make it easy to >> chain together >> computations which could fail in different ways. For example, something >> like this: >> >> attemptReadInt :: String -> Attempt Int >> attemptLookup :: String -> [(String, String)] -> Attempt String >> attemptLookupInt :: String -> [(String, String)] -> Attempt Int >> attemptLookupInt k m = attemptLookup k m >>= attemptReadInt >> >> Now, in the explicit-exception package, I could- in this simple example- >> define >> something like: >> >> data MyErrors = KeyNotFound | InvalidInt >> >> >> type Attempt = Exceptional MyErrors >> >> True; that's what I meant by I could do this in my simple example. >> >> >> But this solution would not scale. >> >> You want to add other exceptions? The idea of my package is to make >> exceptions explicit in the type. Otherwise you would use >> extensible-exceptions. Or you could define MyErrors using an existential >> type. >> >> Which is my point. I'm trying to provide a package for non-explicit >> exceptions. To compare to other programming languages, I think your package >> is providing the equivalent of Java checked exceptions, while mine is >> providing (safe) unchecked exceptions. I say safe because you still need to >> explicitly decide to turn an Attempt into a possible runtime exception which >> will bring down your program. >> >> Defining MyErrors using an existential type would essentially recreate the >> entire attempt package; I don't see that purpose in everyone wanted >> unchecked exceptions needing to reinvent the wheel in non-compatible ways. >> If multiple libraries use attempt, they can easily have their >> possible-error-returning functions chain together safely. >> >> > I believe that control-monad-exception solves this tension between > composability and explicit exceptions. > You can have explicit exceptions which are composable: > > > data DivideByZero = DivideByZero deriving (Show, Typeable) > > data SumOverflow = SumOverflow deriving (Show, Typeable) > > > instance Exception DivideByZero > > instance Exception SumOverflow > > > data Expr = Add Expr Expr | Div Expr Expr | Val Double > > > eval (Val x) = return x > > eval (Add a1 a2) = do > > v1 <- eval a1 > > v2 <- eval a2 > > let sum = v1 + v2 > > if sum < v1 || sum < v2 then throw SumOverflow else return sum > > eval (Div a1 a2) = do > > v1 <- eval a1 > > v2 <- eval a2 > > if v2 == 0 then throw DivideByZero else return (v1 / v2) > > GHCi infers the following types > > > :t eval > > eval :: (Throws DivideByZero l, Throws SumOverflow l) => Expr -> EM l > Double > > > :t eval `catch` \ (e::DivideByZero) -> return (-1) > > .... :: Throws SumOverflow l => Expr -> EM l Double > > > :t runEM(eval `catch` \ (e::SomeException) -> return (-1)) > > .... : Expr -> Double > > >> Additionally, there's two immediate features I think I would miss from my >> package: >> >> 1) fail works properly, so an Attempt would be a valid monad response from >> people who >> use that function. >> >> As far as I understand, 'fail' is used/abused for reporting failed pattern >> matches in do notation. If a failed pattern match indicates a programming >> error, it should be a really error, and not something that must be handled >> at run-time. >> >> That's a lot of very debateable statements you just made. It might be that >> it's strongly encouraged to only use fail for failed pattern matching, but >> in practice you could use it for any monadic failure. Also, there's nothing >> stopping a user from re-throwing pattern match exceptions received in an >> Attempt. >> > > I am with Henning on 'fail'. > It must not be used as a replacement for throw, only for failed pattern > matches which are programming errors and thus unchecked exceptions. > I'm not arguing how it *should* be used, I'm arguing how it *might* be used, and I think calling error is not appropriate. An unchcked exception which can be caught if necesary (I'm assuming that's what runEMParanoid does) sounds like that right thing. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091019/137182e3/attachment.html From qdunkan at gmail.com Mon Oct 19 15:49:57 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Oct 19 15:26:53 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <25953946.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> Message-ID: <2518b95d0910191249t4efb6055k8fe5ef55e35a76c5@mail.gmail.com> On Sun, Oct 18, 2009 at 11:50 PM, zaxis wrote: > > The original code is: > > winSSQ count noRed noBlue = do > ? ?let yesRed = ?[1..33] \\ noRed > ? ?let yesBlue = [1..16] \\ noBlue > ? ?bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1) > > It works very well. However, as i am used to C style so i want convert it > into In the long run it is probably easier to just get used to haskell style. Putting in fewer braces and semicolons will be the least of the adjustments to make from C. I've seen some brace-ful code out there (notably ghc) but it tends not to be in C style even so, e.g. with leading ;s instead of trailing ones. Even though haskell style is already all over the map, using layout and omitting the punctuation seems most widespread to me. Or maybe it's just my bias since I prefer that style myself. It might be interesting to have a few "standard" styles documented, not to try to enforce anything, but have a couple self-consistent systems up there with rationale for otherwise undecided people to look at. E.g. after seeing the leading comma style around I tried it out myself and eventually adopted it, even though it looked weird at first. But it was only after seeing code in that style and guessing for myself why it was that way. From tphyahoo at gmail.com Mon Oct 19 16:51:30 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Oct 19 16:28:28 2009 Subject: [Haskell-cafe] debugtracehelpers Re: traceM and traceShowM Message-ID: <910ddf450910191351s6c322c07vc5b5a0d8572d7a50@mail.gmail.com> I have this and a couple other handy functions in DebugTraceHelpers: http://patch-tag.com/r/tphyahoo/DebugTraceHelpers/snapshot/current/content/pretty hackage: http://hackage.haskell.org/packages/archive/DebugTraceHelpers/0.12/doc/html/Debug-Trace-Helpers.html 2009/10/16 Martijn van Steenbergen : > Hello, > > I propose the addition of the following two functions to module Debug.Trace: > >> traceM :: Monad m => String -> m () >> traceM msg = trace msg (return ()) >> >> traceShowM :: (Show a, Monad m) => a -> m () >> traceShowM = traceM . show > > These functions allow tracing in any do-block. I often define them myself; I > think they are useful in general. > > Deadline: 23 October 2009. > > Martijn. > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://www.haskell.org/mailman/listinfo/libraries > From tphyahoo at gmail.com Mon Oct 19 17:00:36 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Oct 19 16:37:32 2009 Subject: [Haskell-cafe] systemtimmetypeable: Workaround for lack of deriveable data instance in either System.Time or Data.Time. Message-ID: <910ddf450910191400g4e4f2dc7h75bcfe95a0a6ffc5@mail.gmail.com> At http://osdir.com/ml/haskell-cafe@haskell.org/2009-10/msg00197.html I griped that the lack of Data-Derivable time values was causing me headache in happstack. In the proposed cabal package http://patch-tag.com/r/tphyahoo/systemtimetypeable/snapshot/current/content/pretty/systemtimetypeable.cabal I submit a workaround that, while probably not the ideal thing, has proved helpful to me. Basically, I use the type MyTime, which is data-deriveable, when working with Macid in happstack; and convert from System.Time and/or Data.Time with the accompanying utility functions when necessary. Perhaps the utility functions are useful on their own as well. I found it surprisingly hard to get from Data.Time values to System.Time values. Anyways, I am interested in what others think and, of course, patches and suggestions welcome. thomas. From shahn at cs.tu-berlin.de Mon Oct 19 17:12:47 2009 From: shahn at cs.tu-berlin.de (=?iso-8859-1?q?S=F6nke_Hahn?=) Date: Mon Oct 19 16:49:35 2009 Subject: [Haskell-cafe] Hackage down In-Reply-To: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> References: <2d3641330910190130l1a2858fex6becd62dbf2d9f1f@mail.gmail.com> Message-ID: <200910192312.47610.shahn@cs.tu-berlin.de> On Monday 19 October 2009 10:30:55 am Dougal Stanton wrote: > Has not been responding for at least the last 12 hours. > > Is there somewhere to look for status reports on sysadmin details like > this, so we can tell if > > - it's a scheduled down time > - it's a problem but the admins know about it > - etc etc. > > D > Yay, it seems to be working again. From trevor at galois.com Mon Oct 19 17:24:26 2009 From: trevor at galois.com (Trevor Elliott) Date: Mon Oct 19 17:00:17 2009 Subject: [Haskell-cafe] ANNOUNCE: cereal-0.2 Message-ID: <1255987466.2521.23.camel@trogdor> Hello Everyone, cereal is a variation on the binary package that provides strict parsing, handleable exceptions with a named call stack, and a new parsing isolation feature. The major differences from binary are a new class called Serialize replacing the Binary class, getting and putting using strict ByteStrings and a number of combinators for parsing lists, arrays and other containers. Version 0.2 is available from hackage: * http://hackage.haskell.org/package/cereal-0.2 --trevor -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091019/6a07594b/attachment.bin From orclev at gmail.com Mon Oct 19 17:32:35 2009 From: orclev at gmail.com (Kyle Murphy) Date: Mon Oct 19 17:09:33 2009 Subject: [Haskell-cafe] Re: Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) In-Reply-To: <9979e72e0910120929l21408fbev7fec1a4e5bef6633@mail.gmail.com> References: <9979e72e0910120929l21408fbev7fec1a4e5bef6633@mail.gmail.com> Message-ID: <2db78cee0910191432t774e58bcx87465ca19c1224ab@mail.gmail.com> On a somewhat related note, I think the Haskell documentation in general is rather patchy and hard to follow for most things. Part of that I think is because of the confusion between the different forms of documentation. In general as a programmer I expect to find three kinds of documentation available, preferably in a centralized location, but at least in a handful of standardized locations. The first kind, is what Haskell has in abundance, and what is hosted in Hackage, which is API documentation. API documentation is written to be terse, to assume you already know how library Foo works (and probably library Bar and Baz too), and you just need to refresh yourself on exactly what the signature of function wibble was exactly. Really good API documentation also fills the role of some of the other kinds of documentation and has some quick examples sprinkled around the most commonly used functions and maybe a nice intro paragraph with even more examples and some suggestions for further information. The second kind of documentation which is very nearly non-existant for most Haskell packages is a user manual that documents in detail all the functions and data types of a package, how you use them, and the ideas and concepts they're based on. Given only this documentation, a firm understanding of the language, and a basic knowledge of the problem domain, anyone should be able to write an application using your library. If they have to spend three hours trying to track down some obscure research paper that's referenced in your documentation a half dozen times in as many functions, you're not providing enough detail and assuming too great a knowledge of the domain. The last kind of documentation which is fortunately somewhat more prevalent then the previous kind is the classic tutorial, which documents and thoroughly explains the most commonly used functions in your library (not to be confused with thoroughly explaining your library which is the job of the user manual). There are quite a few good tutorials on Haskell in general, Monads specifically, and a lot of random bits and pieces floating around on the net, and thankfully collected for reference on the Haskell wiki. On the whole, the Haskell API docs are decent (although most of them are not what I would call "Good"), and the tutorials are also rather plentiful, but the user manuals are practically non-existent. What would be ideal is if the hackage entry for each package also included a link to the user manual for that package if it exists (and hopefully most of them would exist) in addition to the links to the API docs and homepage it already has (I suppose in theory the homepage link can serve this purpose and in some cases it currently does, but an actual "manual" link would be nice). (All of the following were chosen at random) For reference, here is a good example of an API doc: http://hackage.haskell.org/package/zlib Average API docs (but with links to good user manual and tutorial): http://hackage.haskell.org/package/DeepArrow Bad API docs (but once again with a link to average manual/tutorial): http://hackage.haskell.org/package/actor -R. Kyle Murphy -- Curiosity was framed, Ignorance killed the cat. On Mon, Oct 12, 2009 at 16:29, John Lato wrote: > > From: Derek Elkins > > > > On Sun, Oct 11, 2009 at 8:55 AM, Iain Barnett > wrote: > >> > >> On 11 Oct 2009, at 13:58, John Lato wrote: > >> > >>> For anyone writing introductions to generic programming, take this as > >>> a plea from Haskellers everywhere. If one of the RWH authors can't > >>> understand how to make use of these techniques, what hope do the rest > >>> of us have? > >>> > >>> John Lato > >>> > >>> P.S. Some might wryly note that I'm the maintainer of a package which > >>> is also known for incomprehensible documentation. To which I would > >>> reply that our effort is much newer, I consider it a problem, and it's > >>> being worked on, contrasted to the state of GP where similarly > >>> impenetrable documentation has been and continues to be the norm. > >>> > >> > >> You could say that about most documentation (for Haskell and beyond). > >> Apparently, programmers like programming better than documenting. The > effect > >> of this is that less people use their programming, making their efforts > >> redundant. > >> > >> Silly really, considering programmers are (allegedly:) intelligent. > > > > Apparently, programmers like programming better than reading as > > well... in my experience. > > I won't disagree. But I think the real difficulty is that the > intersection of programmers who can come up with really good ways to > solve problems (not even all programmers, unfortunately) and people > who are good at writing documentation is vanishingly small. > > It seems to me that when someone works in a problem domain (e.g. > Generic Programming), they gain a very deep understanding of that area > and are used to working at a certain level within it. When > introducing the topic to newcomers (even ostensibly smart programmers) > the introduction can't assume prior knowledge of the problem domain, > but the authors are so used to thinking at one level they often take > for granted knowledge that the audience doesn't have. > > I don't think this problem is particular to programming, but it is > common in Haskell. Most likely because Haskell, with a reputation as > a research language, has a lot of computer science types doing > research in wide-ranging topics. Somebody's expertise in category > theory, for example, might not directly carry over to generic > programming (or maybe it does; I'm not an expert in either). > _______________________________________________ > 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/20091019/28884eb2/attachment.html From korpios at korpios.com Mon Oct 19 17:49:53 2009 From: korpios at korpios.com (Tom Tobin) Date: Mon Oct 19 17:26:50 2009 Subject: [Haskell-cafe] Re: Documentation (was: ANN: text 0.5, a major revision of the Unicode text library) In-Reply-To: <2db78cee0910191432t774e58bcx87465ca19c1224ab@mail.gmail.com> References: <9979e72e0910120929l21408fbev7fec1a4e5bef6633@mail.gmail.com> <2db78cee0910191432t774e58bcx87465ca19c1224ab@mail.gmail.com> Message-ID: On Mon, Oct 19, 2009 at 4:32 PM, Kyle Murphy wrote: > If they have to spend three hours trying to track down some obscure > research paper that's referenced in your documentation a half dozen times > in as many functions, you're not providing enough detail and assuming too > great a knowledge of the domain. Even just a paragraph or two giving some background information and example use cases would help immensely here; sometimes I just want to quickly assess whether a library might be useful for solving a particular problem, and "go read this paper" stops me cold. From will_n48 at yahoo.com Mon Oct 19 18:34:08 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Oct 19 18:11:28 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: wren ng thornton freegeek.org> writes: > > Will Ness wrote: > > > (`foldl`2) works. > > > > (`-`2) should too. > > The `` syntax is for converting lexical identifiers into infix > operators. Symbolic identifiers are already infix, which is why `` So it would be a no-op then. Why make it illegal? Just because it makes writing the scanner easier is no answer. > doesn't work for them. If we introduced this then those striving for > consistency would be right in requesting that this pattern be allowed > for all symbolic operators. I for one am opposed to introducing > superfluous syntax for duplicating the current ability to write things > in the same ways. This syntax already exists. The '`' symbol is non-collating already, so using it for symbol chars doesn't change anything (it's not that it can be a part of some name, right?). To turn an infix op into an infix op is an id operation, made illegal artificially at the scan phase after a successful lex (or whatever). Finally enabling the missing functionality which is a common stumbling block for every beginner is hardly "duplicating". > Attack the underlying problem, don't introduce hacks to cover up broken > hacks. This isn't C++. The underlying problem is a broken scanner where it can't distinguish between a binary op and a number read syntax. Op names are collated symbol chars, and one of the symbols, -, is also a valid number prefix. So, allow for a clues from programmer to detach it from the number: backticks separate it from the following numeric chars, preventing it from "sticking" to them. And by itself, it forms an op, a binary one. Not a hack, a solution. A consistent one. Look: (`foldl` 0) (`-` 2) Don't they look exactly the same? Why wouldn't it be made legal? Show me one inconsistency it introduces. From korpios at korpios.com Mon Oct 19 19:30:48 2009 From: korpios at korpios.com (Tom Tobin) Date: Mon Oct 19 19:07:44 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: On Mon, Oct 19, 2009 at 5:34 PM, Will Ness wrote: > This syntax already exists. The '`' symbol is non-collating already, so using > it for symbol chars doesn't change anything (it's not that it can be a part of > some name, right?). To turn an infix op into an infix op is an id operation, > made illegal artificially at the scan phase after a successful lex (or > whatever). If I've accidentally applied syntax meant for a prefix operator to an infix operator, *I want the compiler to tell me*, and not to silently accept my mistake. > Not a hack, a solution. A consistent one. Look: > > ?(`foldl` 0) > ?(`-` 2) > > Don't they look exactly the same? No, because the latter is applying prefix-to-infix syntax to an infix operator. It's understood that non-alphanumerics are infix by default, and I want the compiler to scream at me if I try to use one where it expected a prefix op. > Why wouldn't it be made legal? Show me one inconsistency it introduces. You've said that you want to be able to do this for the sole case of the - (minus-sign) operator: > Operators are great because they make our intent visible, immediately > apparent. Long words' meaning, like subtract's, is not immediately apparent, > and they break consistency. Not everyone's first language in life was English, > you see. I don't buy this rationale. Haskell has plenty of English words as function names all over the place; if you can't handle "subtract", how are you handling Haskell at all? Sure, the minus-sign issue is a wart, but it's less awkward than the solution you propose for a problem I doubt you really have. :-) From will_n48 at yahoo.com Mon Oct 19 20:53:05 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Oct 19 20:30:26 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: Tom Tobin korpios.com> writes: > On Mon, Oct 19, 2009 at 5:34 PM, Will Ness yahoo.com> wrote: > > This syntax already exists. The '`' symbol is non-collating already, so > > using it for symbol chars doesn't change anything (it's not that it > > can be a part of some name, right?). To turn an infix op into an infix op > > is an id operation, made illegal artificially at the scan phase after a > > successful lex (or whatever). > > If I've accidentally applied syntax meant for a prefix operator to an > infix operator, *I want the compiler to tell me*, and not to silently > accept my mistake. You don't apply sytax, you write it. You think of functions, where domain matters (for purists?). In syntax only the result matter, does it read? Does it have an intended meaning? How is it a mistake if it expresses what I intended? Both 3 `-` 2 and curry fst `foldl` 0 are exactly the same - expressions with infix operator, read in the same way, interpreted in the same way. In the first case the backticks are made superfluous by Haskell reader for our convinience; but they shouldn't be made illegal. Why should they be? I truly don't understand the resistance to this idea. :) > > Why wouldn't it be made legal? Show me one inconsistency it introduces. > > You've said that you want to be able to do this for the sole case of > the - (minus-sign) operator: This is not an inconsistence. Plus, if we were to take this idea of using backticks as names delimeters to the extreme, it could even allow us to use such identifiers as `left-fold` or `right-fold` in infix position, and (`left-fold`) by itself. Although that seems not such a good idea. > > Operators are great because they make our intent visible, immediately > > apparent. Long words' meaning, like subtract's, is not immediately apparent, > > and they break consistency. Not everyone's first language in life was > > English, you see. > > I don't buy this rationale. Haskell has plenty of English words as > function names all over the place; if you can't handle "subtract", how > are you handling Haskell at all? Sure, the minus-sign issue is a > wart, but it's less awkward than the solution you propose for a > problem I doubt you really have. When I see `++` I don't need to think _at_all_. When I see `concatenate` or some such, I do - even if for a briefest of moments. It is _less_ convinient both to read and _write_, don't you agree? I don't see my proposal as awkward at all. On the contrary, to me it looks natural and consistent with the other uses of this device in the language. It is this asymmetry that bothers me with the (-) issue, I just want the balance restored. But it is a matter of taste of course. Or obsessing over minutiae. :) Oh well. From wren at freegeek.org Mon Oct 19 21:02:29 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Oct 19 20:39:28 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: <4ADD0C25.6070600@freegeek.org> Will Ness wrote: > wren ng thornton writes: >> Attack the underlying problem, don't introduce hacks to cover up broken >> hacks. This isn't C++. > > The underlying problem is a broken scanner where it can't distinguish between a > binary op and a number read syntax. The underlying problem is that (1) people don't want "normal" whitespace to change the meaning of code, (2) they don't want to disallow negative literals, and (3) they want to use the same symbolic operator for negation and subtraction, but these three goals cannot all be satisfied simultaneously. The current resolution is to hack at the parser in order to make things mostly work. But this hack is insufficient, as argued by the OP. The proposed solution was to introduce new syntax complicating the language by explaining how 1-2 and 1`-`2 are the same thing (either repeated for all other symbolic operators, or exceptional to the subtraction operator, and ugly by either approach). But why should we introduce all this syntactic complexity which needs explaining to newbies and only makes the wart more visible? The proper solution is not to introduce syntactic hackery on top of the parser hackery, the proper solution is to either come up with a better parser hack or to sacrifice one of the three incompatible goals. > Not a hack, a solution. A consistent one. Look: > > (`foldl` 0) > (`-` 2) > > Don't they look exactly the same? Not to me they don't. Symbolic and lexical operators are treated differently in Haskell. Considering all the places where they're treated differently, I see no compelling reason to think they should be considered similar here. -- Live well, ~wren From dagit at codersbase.com Mon Oct 19 22:23:31 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 19 22:00:26 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: On Mon, Oct 19, 2009 at 5:53 PM, Will Ness wrote: > Tom Tobin korpios.com> writes: > > > On Mon, Oct 19, 2009 at 5:34 PM, Will Ness yahoo.com> > wrote: > > > This syntax already exists. The '`' symbol is non-collating already, so > > > using it for symbol chars doesn't change anything (it's not that it > > > can be a part of some name, right?). To turn an infix op into an infix > op > > > is an id operation, made illegal artificially at the scan phase after a > > > successful lex (or whatever). > > > > If I've accidentally applied syntax meant for a prefix operator to an > > infix operator, *I want the compiler to tell me*, and not to silently > > accept my mistake. > > You don't apply sytax, you write it. > > You think of functions, where domain matters (for purists?). In syntax only > the > result matter, does it read? Does it have an intended meaning? > > How is it a mistake if it expresses what I intended? > > Both 3 `-` 2 and curry fst `foldl` 0 are exactly the same - expressions > with > infix operator, read in the same way, interpreted in the same way. In the > first > case the backticks are made superfluous by Haskell reader for our > convinience; > but they shouldn't be made illegal. Why should they be? I truly don't > understand the resistance to this idea. :) > Don't you mean 3 `(-)` 2? I'm pretty sure -, without the parens is infix and (-) is prefix. So it seems to me that you need the brackets for this to be consistent. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091019/46671e08/attachment.html From keithshep at gmail.com Mon Oct 19 23:47:47 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Mon Oct 19 23:24:43 2009 Subject: [Haskell-cafe] Problems with Haskell In-Reply-To: <95394.58142.qm@web58805.mail.re1.yahoo.com> References: <95394.58142.qm@web58805.mail.re1.yahoo.com> Message-ID: <92e42b740910192047g3559e37fmd49ca5036d23ebc3@mail.gmail.com> Hello Philippos > I received a lot of furious and offensive private emails for suggesting the Clean programmer to stick with Clean. I don't get why some people think it's OK to be disrespectful just because they're on the internet... Regarding the code, I find it hard to follow without some high level comments explaining the flow. I haven't used mutable arrays yet so I won't be any help there, but here are some minor things I noticed in your do blocks: Where you write code like: > do >??? ... >??? a <- return exp1 >??? b <- return exp2 i think it's better to write > do >??? ... >??? let a = exp1 >???????? b = exp2 also "else do writeArray v i g" could be "else writeArray v i g" since you don't need the implicit >> that "do" gives you Could you highlight the line(s) of code that are different in the 2 versions of mutate? -Keith On Sun, Oct 18, 2009 at 11:07 PM, Philippos Apolinarius wrote: > > Before anything else, I want to point out that I have no intention to confront your community, or denigrate Haskell. A few days ago I answered an email from a Clean programmer on something related to Clean. He was worried that Clean team could give up its good work, and Clean could disappear; therefore, he was thinking about switching to Haskell. Since I thought that my email could be of interest for the Clean community, I posted it in the -- small-- Clean list :-(Clean is not as popular as Haskell). I received a lot of furious and offensive private emails for suggesting the Clean programmer to stick with Clean. However, I also received a very polite, humorous, and illuminating private email from a person who seems to work at Microsoft. His name is Simon Peyton-Jones. He > urged me to post my comments on a Haskell cafe. He also filed one of my comments as a bug in a Haskell bug track. Here is a couple of snippets from his email: > > --- I think it's v bad that a straightforward program runs so slowly, and it's certainly true > that this is an area we could pay more attention to. > > --- Meanwhile, I'm curious: are the arrays in Philippos's program strict?? Or lazy?? If strict, > that's a pretty big difference. > > Therefore, here are my comments, with a lot of code. > > A few months ago I came accross an unpublished article about a novel genetic programming system. The system was coded in Larceny Scheme. I translated it to Clean and to Haskell. Unhappily, I cannot post the program here because it is very large, and the authors of the original Lisp program don't want me to divulge it before they see in in a printed page of a Journal. Therefore, I wrote an empty genetic programming framework, just to compare languages. Comparing Clean and Haskell, I noticed: > > 1 -- Clean compiler almost never let me do very stupid things, like trying to unbox a tree, or to write in a closed file (I will post an example of this in a near future). For instance, Clean compiler would never swallow something like the code below: > > > import Control.Monad.ST > import Data.Array.ST > import Data.Array.Base > import System.Random > > data Op = AND | OR | NOT; > data Tree= L Double | T Op [Tree] > > main = print $ runST > ????????? (do arr <- newArray (1,2000000) (L 0.0) :: ST s? (STArray s Int Tree) > > ????????????? go? arr 2000000 0.0 ) > > go ::? STArray s Int Tree -> Int -> Double -> ST s Double > go a i acc > ? | i < 1 = return acc > ? | otherwise=do > ?????????????? b <- unsafeRead a i {- readArray a i -} > ?????????????? writeArray a i (setDouble ((getDouble b)+3.0)) > ?????????????? c <-? readArray a i > ?????????????? go? a (i-1) (acc+ (getDouble c)) > > -- What I really need is a random index in Haskell. > > getDouble (L r)= r > getDouble _ = 0.0 > > setDouble r= L r > > 2 -- Safety does not cost much in Clean. For instance, removing array boundary check does not seem to affect Clean. I believe that it does not affect Haskell either, but I have not verified this point. > > 3 -- Haskell seems to loop more often than Clean. For instance, Haskell may loop if I change function mutate to > > mutate e (L i) xs = (e, xs) > mutate e t (y:ys) = ins t (rnLen t y, ys) where > ? ins (T p (L i:xs)) (0, st)=(T p (e:xs), st) > ? ins (T p (t:xs)) (n,(r1:rs)) | n > 0= > ??? let (T p mt, s2)= ins (T p xs)(n-1, rs) > ????? in (T p (t:mt), s2) > ? ins (T p (t:xs)) (n,(r1:rs)) > ??? | rn 2 r1== 0= (T p (e:xs), rs) > ??? | rn 2 r1== 1= let (xpr, st)= mutate e t rs > ???????????????????? in (T p (xpr:xs), st) > > This might be a bug in my implementation of show Tree. It would be great if you people could "show" me what I did wrong. > > 4 -- On the plus side, there are libraries in Haskell that seem to behave better than the Clean equivalent libraries. This could be explained by the fact that there are a lot of people coding Haskell libraries, while Clean team seems to be reluctant in accepting libraries from outsiders. For instance, lethevert made a very important improvement in ObjectIO (changing fonts in edit text field), but it was never incorporated into Clean (yes, I wrote a lot of emails to Clean? team about it). Last year, when I was learning Clean, I discovered that many of my professors and teachers are presbyopic. Therefore, it would be a good policy to use very large fonts for homework. I only succeeded in doing it thanks to lethevert. In the case of the program below, Haskell System.Random library seems to work much better than Clean MersenneTwister. > > 5 --- Any improvement in the program below will be welcome. The program is already very fast thanks to suggestions I received from the bug track people, and from Peyton-Jones. Function "show" seems to loop if I replace mutate in item 3 for mutate in the code below. > > {- ghc gp.hs -O2 --make -} > {- Execute:? gp.exe +RTS -sstderr -} > import Control.Monad.ST > import Data.Array.ST > import Data.Array.Base > import System.Random > > data Op = AND | OR | NOT; > data Tree= L Int | T Op [Tree] > psz= 20000 > thr=4.0 > gates= [AND, NOT, OR] > > table= [ (False, False, False), (True, False, True), > ???????? (True, True, False), (False, True, True)] > > prt NOT= "NOT" > prt OR= "OR" > prt AND= "AND" > > instance Show Tree where > ??? show (L i) = "L"++(show i) > ??? show (T p xs) = (prt p)++(show xs) > > main = do > ?? xs <- (rnList (1, 20000)) > ?? print? $ runST $ do > ????? arr <- newArray_ (1,psz)? :: ST s (STArray s Int Tree) > ????? (arr, xs1) <- gen0 arr psz xs > ????? g1 <- evolve 30 arr (L 0) xs1; return $ g1 > > gen0 a i xs = if i<=0 then return(a,xs) else do > ???? (tree, rs) <- return(rndXpr gates 5 xs) > ???? writeArray a i tree > ???? gen0 a (i-1)? rs > > mutate e (L i) xs = (e, xs) > mutate e t (y:ys) = ins t (rnLen t y, ys) where > ? ins (T p (L i:xs)) (0, st)=(T p (e:xs), st) > ? ins (T p (t:xs)) (n,(r1:rs)) | n > 0= > ??? let (T p mt, s2)= ins (T p xs)(n-1, rs) > ????? in (T p (t:mt), s2) > ? ins (T p (t:xs)) (n,(r1:rs)) > ??? | rn 2 r1== 0= (T p (e:xs), rs) > ??? | rn 2 r1== 1= let (xpr, st)= mutate e t rs > ???????????????????? in (T p (xpr:xs), st) > > fxy NOT r= T NOT [L (rn 2 r)] > fxy AND st = T AND [L 0, L 1] > fxy OR? st = T OR? [L 0, L 1] > > rndXpr fs? beastSz xs= loop beastSz xs where > ? rth s r= s!!(rn (length s) r) > ? loop n (r1:r2:rs) > ???? | n<1 = (fxy (rth fs r1) r1, rs) > ???? |otherwise= mutate (fxy (rth fs r1) r2) f1 rs > ??? where (f1, ys)=? loop (n-1) rs > > run (L 0) x y= x -- Interpreter > run (L 1) x y= y > run (T AND xs) x y = and [run c x y? | c <- xs] > run (T OR xs) x y= or [run c x y | c <- xs] > run (T NOT (t:_)) x y= not (run t x y) > > rn n r= (abs r) `rem` n > > rnLen (T _ s) r= rn (length s) r > > rnList :: (Int, Int) -> IO [Int] > rnList r=getStdGen>>=(\x->return(randomRs r x)) > > frag? (L i)? st = (L i, st) > frag (T p xs) (r1:r2:rs) > ? | rn 2 r2==0= (xpr, rs) > ? | otherwise= frag xpr rs > ?where xpr= xs!!(rnLen (T p xs) r1) > > crossover e1 e2 rs = ([c2, c1], rs4)? where > ?? (g1, rs1) = frag e1 rs > ?? (g2, rs2) = frag e2 rs1 > ?? (c1, rs3) = mutate g1 e2 rs2 > ?? (c2, rs4) = mutate g2 e1 rs3 > > nGates (L i)= 0.0 > nGates (T p xs) = (-0.1) + sum [nGates g | g <- xs] > > fitness tt gt = (ng + 1.0 + sum [ft t | t <- tt]) where > ?? ng= nGates gt > ?? ft (out, t1, t2) | run gt t1 t2 == out= 1.0 > ?? ft _ = 0.0 > > evolve n p b xs | n < 1 = do > ?? (arr, xs1) <- gen0 p psz xs > ?? evolve 30 arr b xs1 > evolve n p b (r1:r2:rs) = do > ???? n1 <- return $ 1+(rn psz r1) > ???? n2 <- return $ 1+(rn psz r2) > ???? g1 <- readArray p n1; g2 <- readArray p n2 > ???? ([c1,c2], rs) <- return $ crossover g1 g2 rs > ???? insrt c1 p 1 psz > ???? insrt c2 p 1 psz > ???? res <- best 1 b p > ???? fitn <- return $ fitness table res > ???? if fitn > thr > ?????? then return res else evolve (n-1) p res rs > > best i res p | i >= psz= return res > best i fg p= do > ? g <- readArray p i > ? if (fitness table fg) > (fitness table g) > ?????? then best (i+1) fg p else best (i+1) g p > > insrt g v i sz | i >= sz = return () > insrt g v i sz = do > ?? a <- readArray v i > ?? fg <- return $ fitness table g > ?? fa <- return $ fitness table a > ?? if fa > fg then insrt g v (i+1) sz > ???? else do writeArray v i g > > ________________________________ > Looking for the perfect gift? Give the gift of Flickr! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- keithsheppard.name From lrpalmer at gmail.com Tue Oct 20 00:31:26 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Oct 20 00:08:21 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> Message-ID: <7ca3f0160910192131t3658afb6ka96dba4e0ca58d7a@mail.gmail.com> On Sun, Oct 18, 2009 at 5:31 PM, Will Ness wrote: > Luke Palmer gmail.com> writes: > >> >> Or you could use the "subtract" function. >> >> ? >>> map (subtract 2) [3,4,5] >> ? [1,2,3] > > I don't want to. I think at about this point, this stopped being an intellectual discussion. Preparing for academic flame war... >> >> I don't think syntax sugar is worth it in this case. > > > I do. Operators are great because they make our intent visible, immediately > apparent. Long words' meaning, like subtract's, is not immediately apparent, > and they break consistency. Not everyone's first language in life was English, > you see. > > (`foldl`2) works. > > (`-`2) should too. > > I'll settle for (+(-2)) for now, but it ain't that pretty. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From noteed at gmail.com Tue Oct 20 02:46:22 2009 From: noteed at gmail.com (minh thu) Date: Tue Oct 20 02:23:37 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: <40a414c20910192346r7b0d75d5v72ccd27d3afea0d8@mail.gmail.com> > [snip] > Not a hack, a solution. A consistent one. Look: > > (`foldl` 0) > (`-` 2) > > Don't they look exactly the same? > [snip] These look the same too (and *are* consistent): (f a b) (+ a b) But it's not Haskell.. IMO conflating binary minus and unary minus is not consistent. Something I wonder from time to time if it would be a good thing or not is to allow a `f g` b to mean f g a b (so map (`f g` b) as would legal too). Cheers, Thu From oleg at okmij.org Tue Oct 20 03:03:05 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Tue Oct 20 02:43:58 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question Message-ID: <20091020070306.02736176D5@Adric.metnet.navy.mil> > Something I wonder from time to time if it would be a good thing or > not is to allow > a `f g` b > to mean > f g a b You don't have to wonder: http://www.haskell.org/haskellwiki/Infix_expressions Granted, you have to use different characters rather than the backquote. On the other hand, you can play with infix expressions right now, on any Haskell98 system. From nicolas.pouillard at gmail.com Tue Oct 20 05:04:17 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Oct 20 04:41:12 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> Message-ID: On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman wrote: > While working on the next release of data-object, I wanted to represent some > operations that might fail. The typical candidates were: > > 1) Maybe > 2) Either > 3) Monad > > Monad is always iffy because of the often times poorly defined fail. Maybe > doesn't provide any means of reporting what the problem was. Either is not > defined as a Monad in the base library. Also, the usual candidate of Either > String only provides for an error message. It would be nice to have more > in-depth information available. > > So I've put together a package I call "attempt". It defines a data type > called (surprise) Attempt with a Success and Failure constructor. The trick > here is that it using the new extensible exceptions under the surface, so > you can report any kind of exception you want. It also provides a > "FromAttempt" type class for possible conversion targets from an Attempt, > provides an attempt function with some helpers for performing the equivalent > of Control.Exception.catches, and provides two samples of functions I would > want to implement with this library: attemptJoin and attemptLookup. > > My questions for the list are: > > 1) Is the overall approach sound, or do people have better ideas? I think that there is a place for such a package. Given the Monad/fail issue, the Maybe/no-message issue and the Either/not-a-monad-in-base issue. About the name Attempt, I think that 'Outcome' would be a better name. > 2) Are there any other FromAttempt instances I should provide out of the > box? None that I see. > 3) I was considering adding specialized versions of the fromAttempt > function, ie ioFromAttempt, maybeFromAttempt. Thoughts? It is a bit long to spell. > 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, or > just call the functions join, lookup and force people to import the module > qualified? A nice alternative would be to make a Data.Attempt.Extra (or a better name) which would be imported qualified. > 5) Any other suggestions for attempt functions? I've considered > head/tail/etc. Why not, maybe the 'safe' package should be of some inspiration. > 6) Include ToAttempt? IMHO, no. > The code is available on github at I think that the 'attempt' function should follow functions like 'maybe' and 'either'. attempt :: (forall e. Exception e -> b) -> (a -> b) -> Attempt a -> b Regards, -- Nicolas Pouillard http://nicolaspouillard.fr From svein.ove at aas.no Tue Oct 20 05:31:52 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Oct 20 05:08:47 2009 Subject: [Haskell-cafe] cvs.haskell.org down? haskell-mode abandoned? Message-ID: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> Attempting to update haskell-mode, I've been getting authorization failures from the cvs.haskell.org pserver. I thought this might have some connection to the recent disk crash, and as nobody uses cvs anymore, it could have been overlooked. In any case, I need it fixed before I can work on haskell-mode. Preferably by migrating haskell-mode over to cvs. :-) On a different note, I've been unable to contact the apparent current maintainer of haskell-mode, while in a state of having a useful patch. Though it may already have made it to cvs, with me simply being unable to check that.. actually, who *is* the current maintainer? The last release was Dec. 2007. -- Svein Ove Aas From apfelmus at quantentunnel.de Tue Oct 20 05:58:42 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Oct 20 05:36:07 2009 Subject: [Haskell-cafe] Re: How to use "bracket" properly ? In-Reply-To: <25956932.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> <25953716.post@talk.nabble.com> <4c44d90b0910182335h1402d4f7r232fdf5f0454f769@mail.gmail.com> <25953946.post@talk.nabble.com> <25956932.post@talk.nabble.com> Message-ID: zaxis wrote: > oh! thanks! But why ? The gory details can be found in the Haskell 98 Report: syntax of do expressions http://www.haskell.org/onlinereport/exps.html#do-expressions syntax of decls http://www.haskell.org/onlinereport/decls.html Details for the layout rule http://www.haskell.org/onlinereport/lexemes.html#sect2.7 Regards, apfelmus -- http://apfelmus.nfshost.com From tittoassini at gmail.com Tue Oct 20 06:54:01 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Tue Oct 20 06:30:54 2009 Subject: [Haskell-cafe] pretty printing with comments Message-ID: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> Hi, Is there any simple way of pretty printing haskell source code while preserving the comments? I am looking at the haskell-src-ext library. It can parse files with comments and it can pretty print but, for what I can see it cannot do both :-) (prettyPrint won't work on the structure returned by parseFileWithComments). Thanks, titto From niklas.broberg at gmail.com Tue Oct 20 07:01:33 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Oct 20 06:38:28 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> Message-ID: Hi Pasqualino, > I am looking at the haskell-src-ext library. > > It can parse files with comments and it can pretty print but, for what > I can see it cannot do both :-) ?(prettyPrint won't work on the > structure returned by parseFileWithComments). What you want is exactPrint, defined in Language.Haskell.Exts.Annotated.ExactPrint. :-) Cheers, /Niklas From tittoassini at gmail.com Tue Oct 20 07:28:30 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Tue Oct 20 07:05:24 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> Message-ID: <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> Thanks Niklas, in fact this produced a source with comments: import Language.Haskell.Exts.Annotated main = do (ParseOk (mod,comments)) <- parseFileWithComments defaultParseMode "Test.hs" let pretty = exactPrint mod comments writeFile "Test_PRETTY.hs" pretty However: - The source code produced was incorrect: class Dir d where was rewritten as: class Dir dwhere{ And: instance Dir Directory where localDir (Local f) = return f type URL= String was rewritten as: instance Dir Directory where localDir (Local f) = return f typeURL= String Are these known bugs? - Also, the printing is a bit too exact :-), I would like to keep my comments AND get the code nicely reformatted. Is there a way? What people use to keep their haskell source files in tip-top shape? Thanks titto 2009/10/20 Niklas Broberg : > Hi Pasqualino, > >> I am looking at the haskell-src-ext library. >> >> It can parse files with comments and it can pretty print but, for what >> I can see it cannot do both :-) ?(prettyPrint won't work on the >> structure returned by parseFileWithComments). > > What you want is exactPrint, defined in > Language.Haskell.Exts.Annotated.ExactPrint. :-) > > Cheers, > > /Niklas From ekirpichov at gmail.com Tue Oct 20 08:01:49 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Oct 20 07:38:44 2009 Subject: [Haskell-cafe] ANN: strptime bindings Message-ID: <5e0214850910200501u70a1fae8w8da8c34326d7089b@mail.gmail.com> Hi all. I had to parse dates from bytestrings efficiently and tried to use the parsedate library, but I had to port it to parsec3 to make it usable with bytestrings, and I could not get decent performance out of the resulting version due to ghc having difficulties with parsec3's generality, so I wrote bindings to strptime. Here they are: http://hackage.haskell.org/package/strptime They work for Strings and strict and lazy bytestrings. They are several orders of magnitude faster than parsedate and than Data.Time.readTime,parseTime (a program that ran in 40s with parsec3'd parsedate runs in less than 1s). -- Eugene Kirpichov Web IR developer, market.yandex.ru From michael at snoyman.com Tue Oct 20 09:12:21 2009 From: michael at snoyman.com (Michael Snoyman) Date: Tue Oct 20 08:49:19 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> Message-ID: <29bf512f0910200612k2f79c83u2d9dd4ce2b9b6ff2@mail.gmail.com> On Tue, Oct 20, 2009 at 11:04 AM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman > wrote: > > While working on the next release of data-object, I wanted to represent > some > > operations that might fail. The typical candidates were: > > > > 1) Maybe > > 2) Either > > 3) Monad > > > > Monad is always iffy because of the often times poorly defined fail. > Maybe > > doesn't provide any means of reporting what the problem was. Either is > not > > defined as a Monad in the base library. Also, the usual candidate of > Either > > String only provides for an error message. It would be nice to have more > > in-depth information available. > > > > So I've put together a package I call "attempt". It defines a data type > > called (surprise) Attempt with a Success and Failure constructor. The > trick > > here is that it using the new extensible exceptions under the surface, so > > you can report any kind of exception you want. It also provides a > > "FromAttempt" type class for possible conversion targets from an Attempt, > > provides an attempt function with some helpers for performing the > equivalent > > of Control.Exception.catches, and provides two samples of functions I > would > > want to implement with this library: attemptJoin and attemptLookup. > > > > My questions for the list are: > > > > 1) Is the overall approach sound, or do people have better ideas? > > I think that there is a place for such a package. Given the Monad/fail > issue, > the Maybe/no-message issue and the Either/not-a-monad-in-base issue. > > About the name Attempt, I think that 'Outcome' would be a better name. > The problem with a name like "Outcome" is that it doesn't really imply the possibility of failure, simply that we are wrapping of the result for some reason. > > > 2) Are there any other FromAttempt instances I should provide out of the > > box? > > None that I see. > > > 3) I was considering adding specialized versions of the fromAttempt > > function, ie ioFromAttempt, maybeFromAttempt. Thoughts? > > It is a bit long to spell. > True, but it can be more convenient than giving explicit type signatures. The main reason this might come up would be regarding the (Either String) and (Either SomeException) instances. > > > 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, or > > just call the functions join, lookup and force people to import the > module > > qualified? > > A nice alternative would be to make a Data.Attempt.Extra (or a better > name) which > would be imported qualified. > I like. The only other name I can think of right now is Data.Attempt.Helper, but that's just painting the bike shed. > > > 5) Any other suggestions for attempt functions? I've considered > > head/tail/etc. > > Why not, maybe the 'safe' package should be of some inspiration. > Once they're all in their own module, I don't see a problem adding as many as possible. > > > 6) Include ToAttempt? > > IMHO, no. > > > The code is available on github at > > I think that the 'attempt' function should follow functions like > 'maybe' and 'either'. > > attempt :: (forall e. Exception e -> b) -> (a -> b) -> Attempt a -> b > > I was trying to more model it after fromMaybe, but instead just ended up with something ugly. I'm going to rewrite attempt using this type signature and then add fromAttempt as well. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091020/6939977b/attachment-0001.html From doaitse at swierstra.net Tue Oct 20 09:21:12 2009 From: doaitse at swierstra.net (S.Doaitse Swierstra) Date: Tue Oct 20 08:58:08 2009 Subject: [Haskell-cafe] Parsec bug, or...? In-Reply-To: <65d7a7e0910171249l6953121fv9f918957b9ee14ba@mail.gmail.com> References: <65d7a7e0910121928t621877cdr1ea24eb4b0b1a5ea@mail.gmail.com> <4AD41F22.7080705@van.steenbergen.nl> <65d7a7e0910130810u7da50686ka636ab01555778c8@mail.gmail.com> <1A7D4098-2CEB-4C90-80B0-066FFE15559C@swierstra.net> <65d7a7e0910150758h525c460eufe61951e345eff8e@mail.gmail.com> <49890AC1-AC20-4E66-9235-F8CE7D9E29AE@swierstra.net> <65d7a7e0910171249l6953121fv9f918957b9ee14ba@mail.gmail.com> Message-ID: <49ADA81E-835E-46BD-914B-F5718EC5F549@swierstra.net> After some private exchange of info between Uwe and me it became clear that it may not have been immediately clear that the error messages in my original posting where actually part of a more involved process. By removing the optional part in the pCommand (i.e. making the part starting with `opt` invisible, we can show the full power of the built- in error correction. import Text.ParserCombinators.UU.Parsing pCommand [] = pure [] pCommand (x:xs) = ((:) <$> pSym x <*> pCommand xs) -- `opt` (x:xs) pCommands = amb . foldr (<|>) pFail . map pCommand $ ["banana", "chocolate", "frito", "fromage"] t :: String -> ([String], [Error Char Char Int]) t input = parse ( (,) <$> pCommands <*> pEnd) (listToStr input) Now one also gets error messages like: *Main> t "frxi" (["frito"],[ Deleted 'x' at position 2 expecting one of ['i', 'o'], Inserted 't' at position 4 expecting 't', Inserted 'o' at position 4 expecting 'o']) for free. However, since the decision what element to take is based on a limited look-ahead, one also gets: *Main> t "xfxrxix" (["fromage"],[ Deleted 'x' at position 0 expecting one of ['b', 'c', 'f', 'f'], Deleted 'x' at position 2 expecting 'r', Deleted 'x' at position 4 expecting 'o', Deleted 'i' at position 5 expecting 'o', Deleted 'x' at position 6 expecting 'o', Inserted 'o' at position 7 expecting 'o', Inserted 'm' at position 7 expecting 'm', Inserted 'a' at position 7 expecting 'a', Inserted 'g' at position 7 expecting 'g', Inserted 'e' at position 7 expecting 'e']) *Main> which is something not completely expected; the current look-ahead is however three symbols ahead, and once a decision is taken this is not reconsidered (for cost reasons). This is currently a consequence of the rather simplistic inner organisation of the intermediate library. In the next version we hope to have gotten rid of this artefact. Best, Doaitse > > Yes, for my particular problem the complexity is very limited. I > wouldn't even have used parsec for this, in spite of the comment I had > made earlier about this, if I were not already using it in a different > part of the project to parse individual records ("buy security > for this price on this date", etc), so it was natural to add a bit > more parsec code to also deal with the commands saying what I want to > see from the data. It's all still pretty trivial, but starting already > to be useful to me... it's really quite gratifying what a small amount > of haskell code suffices to make a useful and flexible program. > > best regards, > Uwe > > On 10/15/09, S. Doaitse Swierstra wrote: >> >> On 15 okt 2009, at 16:58, Uwe Hollerbach wrote: >> >>> Hi, all, thanks for the further inputs, all good stuff to think >>> about... although it's going to be a little while before I can >>> appreciate the inner beauty of Doaitse's version! :-) >> >> The nice thing is that you do not have to understand the inner >> workings ;-} I basically builds a greedy parser for each word to be >> recognised which can stop and assume the rest is there if it can no >> longer proceed (the `opt` is greedy in its left alternative) . Hence >> it recognises the longest possible prefix. >> Since my parsers pursue all alternatives in parallel you >> automatically >> get what you want, without having to indicate prefix lengths, calls >> to >> try, etc. >> >> The "amb" combinator has type >> >> amb :: Parser a -> Parser [a] >> >> and collects the result from all alternatives its argument parser is >> constructed from; you might say it convert an ambiguous parser to a >> parser with a list as result, hence preventing the rest of the input >> being parsed over and over again. I am currently working on bringing >> back more abstract interpretation in the implementation (i.e. what we >> have had for almost 10 years in the uulib library), but I do not >> expect you to see a lot of that from the outside. >> >> If you want to work with left-recursive parsers (which does not seem >> to be the case), you may revert to more complicated solutions such as >> found in the "christmastree" (Changing Haskell's Read Implementation >> Such That by Manipulationg Abstract Syntax Trees Read Evaluates >> Efficiently) package if you need to generate parsers online, or to >> happy-based solutions in case your grammar is fixed. >> >> >> If you have any questions do not hesitate to ask, >> Doaitse >> >> >>> I had considered >>> the approach of doing a post-parsec verification, but decided I >>> wanted >>> to keep it all inside the parser, hence the desire to match prefixes >>> there (and lack of desire to write 'string "p" <|> string "pr" <|> >>> string "pre" ...'. >>> >>> By way of background, the actual stuff I'm wanting to match is not >>> food names, but some commands for a small ledger program I'm working >>> on. I needed something like that and was tired of losing data to >>> quicken every so often. I realize of course that there are other >>> excellent ledger-type programs out there, but hey, I also needed >>> another hacking project. I'll put this onto hackage in a while, once >>> it does most of the basics of what I need. No doubt the main >>> differentiator between mine and those other excellent ledger >>> programs >>> out there will be that mine has fewer features and more bugs... >>> >>> thanks again, all! >>> >>> Uwe >> >> From lennart at augustsson.net Tue Oct 20 09:46:47 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Oct 20 09:23:42 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> Message-ID: It's not an easy problem to pretty print (i.e. change indentation) and preserve the comments. And always get it right. On Tue, Oct 20, 2009 at 1:28 PM, Pasqualino "Titto" Assini wrote: > Thanks Niklas, > > in fact this produced a source with comments: > > > import Language.Haskell.Exts.Annotated > > main = do > ?(ParseOk (mod,comments)) <- parseFileWithComments defaultParseMode "Test.hs" > ?let pretty = exactPrint mod comments > ?writeFile "Test_PRETTY.hs" pretty > > > > However: > - The source code produced was incorrect: > > > class Dir d where > > was rewritten as: > > class Dir dwhere{ > > > And: > > instance Dir Directory where > ?localDir (Local f) = return f > > type URL= String > > > was rewritten as: > > > instance Dir Directory where > ?localDir (Local f) = return f > > ?typeURL= String > > > Are these known bugs? > > > - Also, the printing is a bit too exact :-), I would like to keep my > comments AND get the code nicely reformatted. > > > Is there a way? > > What people use to keep their haskell source files in tip-top shape? > > Thanks > > ? ? ? ? ?titto > > > > > > > 2009/10/20 Niklas Broberg : >> Hi Pasqualino, >> >>> I am looking at the haskell-src-ext library. >>> >>> It can parse files with comments and it can pretty print but, for what >>> I can see it cannot do both :-) ?(prettyPrint won't work on the >>> structure returned by parseFileWithComments). >> >> What you want is exactPrint, defined in >> Language.Haskell.Exts.Annotated.ExactPrint. :-) >> >> Cheers, >> >> /Niklas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Tue Oct 20 10:07:12 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Oct 20 09:44:07 2009 Subject: [Haskell-cafe] Test cases for type inference Message-ID: For learning, I would like to develop my own implementation of type inference, based on the paper "Typing Haskell in Haskell". At first sight, the source code of THIH contains a small number of tests, but I was wandering if a large test set exist? Thanks, Peter From satorisanitarium at gmail.com Tue Oct 20 10:16:43 2009 From: satorisanitarium at gmail.com (satorisanitarium) Date: Tue Oct 20 09:53:39 2009 Subject: [Haskell-cafe] list -> sublists Message-ID: <25975341.post@talk.nabble.com> I just started learning haskell and I just came to my first wtf moment. I'm trying to do something like this: calling: foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] returns: [[1,2,3],[2,4,1,6,3],[2,3]] but i have no idea how to put something into a sublist. How to make a list of sublists out of a list, whether they be a list of numbers or a string. TX in advance. -- View this message in context: http://www.nabble.com/list--%3E-sublists-tp25975341p25975341.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From marlowsd at gmail.com Tue Oct 20 10:17:40 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Tue Oct 20 09:54:40 2009 Subject: [Haskell-cafe] Re: GHC devs In-Reply-To: <4AD9D632.2030804@btinternet.com> References: <4AD6185D.3050105@btinternet.com> <715818608.20091014224309@gmail.com> <20091014192555.GA13298@whirlpool.galois.com> <4AD63A8D.8010304@btinternet.com> <1612471256.20091015010645@gmail.com> <4c88418c0910150017h79738127oe2840703286d6d0d@mail.gmail.com> <4AD8129B.6080704@van.steenbergen.nl> <4AD9D632.2030804@btinternet.com> Message-ID: <4ADDC684.1000600@gmail.com> On 17/10/2009 15:35, Andrew Coppin wrote: > Martijn van Steenbergen wrote: >> David Virebayre wrote: >>> Taking the opportunity to thank very much both Simons and Ian for the >>> work they do and the enthusiasm they show. You guys rock. >> >> I heartily second that! > > I won't disagree with that sentiment. ;-) > > According to a paper I just read, GHC is "about 150,000 lines of code". Just to give you updated numbers: the compiler itself is 190k lines now and the runtime system is another 85k (both including comments). Cheers, Simon From monnier at iro.umontreal.ca Tue Oct 20 10:22:58 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Tue Oct 20 10:00:29 2009 Subject: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned? References: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> Message-ID: > In any case, I need it fixed before I can work on haskell-mode. > Preferably by migrating haskell-mode over to cvs. :-) You mean migrating to DaRCS? That would be appreciated, yes. > who *is* the current maintainer? Last I heard, it was me. But if someone wants to take over, he's welcome. Stefan From noteed at gmail.com Tue Oct 20 10:31:16 2009 From: noteed at gmail.com (minh thu) Date: Tue Oct 20 10:08:30 2009 Subject: [Haskell-cafe] list -> sublists In-Reply-To: <25975341.post@talk.nabble.com> References: <25975341.post@talk.nabble.com> Message-ID: <40a414c20910200731u43d6becg4c854bee950608fc@mail.gmail.com> 2009/10/20 satorisanitarium : > > I just started learning haskell and I just came to my first wtf moment. > > I'm trying to do something like this: > > calling: > foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > > returns: > [[1,2,3],[2,4,1,6,3],[2,3]] > > but i have no idea how to put something into a sublist. > > How to make a list of sublists out of a list, whether they be a list of > numbers or a string. Hi, Here is a function f that looks like a recursive implementation of the function length. f is the identity for lists but shows clearly how you can build the list again. ghci> let f [] = [] ; f (x:xs) = x : f xs ghci> f "hello" "hello" But here is what happen if we change it slightly so that each element is turned into a list (which is still viewed as an element from the point of view of the enclosing list). ghci> let f [] = [] ; f (x:xs) = [x] : f xs ghci> f "hello" ["h","e","l","l","o"] If it's not clear, try to write down the type of each version of f. Now back to your original problem. Can you write a function g such that g [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] returns ([1,2,3],[2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]) g [2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] returns: ([2,4,1,6,3],[6,2,3,5,2,5,2,1,6,4]) and so on ? Then you should be able to build what you wanted by using g in a modified version of f. Yell if something doesn't make sense. Cheers, Thu From douyaxu at gmail.com Tue Oct 20 11:02:29 2009 From: douyaxu at gmail.com (xu zhang) Date: Tue Oct 20 10:39:24 2009 Subject: [Haskell-cafe] Make two windows work together Message-ID: Hi there, I am trying to make a sub-window of one window and make them work together. I mean, if I zoom or transform some content in one of the window, the other one works in the same way. What I have done so far is just open a new window which have the same drawing view as the original one, but when I try to change some content in one window, the other one does not work at the same time. They are separate. Can anyone give me some hint on how to make them work at the same time not separate anymore? Thank you so much! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091020/97a162f6/attachment.html From vanenkj at gmail.com Tue Oct 20 11:13:23 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Oct 20 10:50:17 2009 Subject: [Haskell-cafe] Make two windows work together In-Reply-To: References: Message-ID: Are you using GTK? OpenGL? Haskell? There's absolutely no context here... On Tue, Oct 20, 2009 at 11:02 AM, xu zhang wrote: > Hi there, > > I am trying to make a sub-window of one window and make them work > together. I mean, if I zoom or transform some content in one of the window, > the other one works in the same way. > What I have done so far is just open a new window which have the same > drawing view as the original one, but when I try to change some content in > one window, the other one does not work at the same time. They are separate. > Can anyone give me some hint on how to make them work at the same time not > separate anymore? > > Thank you so much! > > _______________________________________________ > 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/20091020/bd5b19b7/attachment.html From nicolas.pouillard at gmail.com Tue Oct 20 11:17:57 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Oct 20 10:54:51 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: <29bf512f0910200612k2f79c83u2d9dd4ce2b9b6ff2@mail.gmail.com> References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910200612k2f79c83u2d9dd4ce2b9b6ff2@mail.gmail.com> Message-ID: On Tue, Oct 20, 2009 at 3:12 PM, Michael Snoyman wrote: > > > On Tue, Oct 20, 2009 at 11:04 AM, Nicolas Pouillard > wrote: >> >> On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman >> wrote: >> > While working on the next release of data-object, I wanted to represent [...] >> About the name Attempt, I think that 'Outcome' would be a better name. > > The problem with a name like "Outcome" is that it doesn't really imply the > possibility of failure, simply that we are wrapping of the result for some > reason. I don't see why, the outcome of an action could be either a success or a failure. Even if the only *desired* outcome is success. >> > 2) Are there any other FromAttempt instances I should provide out of the >> > box? >> >> None that I see. >> >> > 3) I was considering adding specialized versions of the fromAttempt >> > function, ie ioFromAttempt, maybeFromAttempt. Thoughts? >> >> It is a bit long to spell. > > True, but it can be more convenient than giving explicit type signatures. > The main reason this might come up would be regarding the (Either String) > and (Either SomeException) instances. > >> >> > 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, or >> > just call the functions join, lookup and force people to import the >> > module >> > qualified? >> >> A nice alternative would be to make a Data.Attempt.Extra (or a better >> name) which >> would be imported qualified. > > I like. The only other name I can think of right now is Data.Attempt.Helper, > but that's just painting the bike shed. I also prefer Helper. >> > 5) Any other suggestions for attempt functions? I've considered >> > head/tail/etc. >> >> Why not, maybe the 'safe' package should be of some inspiration. > > Once they're all in their own module, I don't see a problem adding as many > as possible. [...] >> attempt :: (forall e. Exception e -> b) -> (a -> b) -> Attempt a -> b >> > I was trying to more model it after fromMaybe, but instead just ended up > with something ugly. I'm going to rewrite attempt using this type signature > and then add fromAttempt as well. Fine, fromAttempt should follow fromMaybe fromAttempt :: (forall e. Exception e -> a) -> Attempt a -> a fromAttempt f a = attempt f id a Regards, -- Nicolas Pouillard http://nicolaspouillard.fr From satorisanitarium at gmail.com Tue Oct 20 11:27:41 2009 From: satorisanitarium at gmail.com (satorisanitarium) Date: Tue Oct 20 11:04:34 2009 Subject: [Haskell-cafe] Re: list -> sublists In-Reply-To: <40a414c20910200731u43d6becg4c854bee950608fc@mail.gmail.com> References: <25975341.post@talk.nabble.com> <40a414c20910200731u43d6becg4c854bee950608fc@mail.gmail.com> Message-ID: <282aff59-c033-4c4b-9ab8-0ee6ac9fbce1@g1g2000vbr.googlegroups.com> > Now back to your original problem. Can you write a function g such that > g [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > returns > ([1,2,3],[2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]) > I know the diference between x and [x], my problem lies in going from [1,2,3,4,5,6,7] to [[1,2,3,4],[5,6,7]], I don't know how to write code that would group some elements together. From svein.ove at aas.no Tue Oct 20 11:57:04 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Oct 20 11:33:58 2009 Subject: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned? In-Reply-To: References: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> Message-ID: <221b53ab0910200857o5e541558yf935f328c5c761dc@mail.gmail.com> On Tue, Oct 20, 2009 at 4:22 PM, Stefan Monnier wrote: >> In any case, I need it fixed before I can work on haskell-mode. >> Preferably by migrating haskell-mode over to cvs. :-) > > You mean migrating to DaRCS? ?That would be appreciated, yes. > Um, yes. I can get the revision history into darcs pretty easily, such as it is, assuming cvs.haskell.org comes back up. Then I'll put the repository somewhere you can get at it. That fine? >> who *is* the current maintainer? > > Last I heard, it was me. ?But if someone wants to take over, > he's welcome. > You're saying you don't have time to maintain it? I'd like to say I could take over, but really, I'm not familiar enough with either elisp or haskell-mode to do that, and I don't currently have the time to familiarize myself with it either, so I know how that is. Still, there needs to be a new release, and I've got a lot of improved haskell-mode code (written by other people) that isn't currently in the repository. I can handle that much, if nobody else steps up. -- Svein Ove Aas From lrpalmer at gmail.com Tue Oct 20 12:03:54 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Oct 20 11:40:49 2009 Subject: [Haskell-cafe] Re: list -> sublists In-Reply-To: <282aff59-c033-4c4b-9ab8-0ee6ac9fbce1@g1g2000vbr.googlegroups.com> References: <25975341.post@talk.nabble.com> <40a414c20910200731u43d6becg4c854bee950608fc@mail.gmail.com> <282aff59-c033-4c4b-9ab8-0ee6ac9fbce1@g1g2000vbr.googlegroups.com> Message-ID: <7ca3f0160910200903m5ec7f245l2ff5399ce6643ea0@mail.gmail.com> On Tue, Oct 20, 2009 at 9:27 AM, satorisanitarium wrote: > >> Now back to your original problem. Can you write a function g such that >> g [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] >> returns >> ([1,2,3],[2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]) >> > I know the diference between x and [x], my problem lies in going from > [1,2,3,4,5,6,7] to [[1,2,3,4],[5,6,7]], I don't know how to write code > that would group some elements together. Here is an implementation of splitAt from the prelude (though it is not hte implementation given in the prelude) for guidance. For example, splitAt 3 ['a','b','c','d','e','f'] = (['a','b','c'],['d','e','f']) splitAt :: Int -> [a] -> ([a],[a]) splitAt 0 xs = ([], xs) splitAt n [] = ([],[]) splitAt n (x:xs) = let (rfst, rsnd) = splitAt (n-1) xs in (x:rfst, rsnd) See if you can use that pattern to make the function that splits at a particular element (as opposed to index). Luke From jgbailey at gmail.com Tue Oct 20 12:13:02 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Tue Oct 20 11:50:26 2009 Subject: [Haskell-cafe] debugtracehelpers Re: traceM and traceShowM In-Reply-To: <910ddf450910191351s6c322c07vc5b5a0d8572d7a50@mail.gmail.com> References: <910ddf450910191351s6c322c07vc5b5a0d8572d7a50@mail.gmail.com> Message-ID: These woudl be much more useful if they flushed the output handle after each message. Then you know your trace messages will be displayed/written to a file. On Mon, Oct 19, 2009 at 1:51 PM, Thomas Hartman wrote: > I have this and a couple other handy functions in > > DebugTraceHelpers: > > http://patch-tag.com/r/tphyahoo/DebugTraceHelpers/snapshot/current/content/pretty > > hackage: > > http://hackage.haskell.org/packages/archive/DebugTraceHelpers/0.12/doc/html/Debug-Trace-Helpers.html > > > 2009/10/16 Martijn van Steenbergen : >> Hello, >> >> I propose the addition of the following two functions to module Debug.Trace: >> >>> traceM :: Monad m => String -> m () >>> traceM msg = trace msg (return ()) >>> >>> traceShowM :: (Show a, Monad m) => a -> m () >>> traceShowM = traceM . show >> >> These functions allow tracing in any do-block. I often define them myself; I >> think they are useful in general. >> >> Deadline: 23 October 2009. >> >> Martijn. >> _______________________________________________ >> Libraries mailing list >> Libraries@haskell.org >> http://www.haskell.org/mailman/listinfo/libraries >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From niklas.broberg at gmail.com Tue Oct 20 12:51:13 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Oct 20 12:28:06 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> Message-ID: Hi again, > However: > - The source code produced was incorrect: > > > class Dir d where > > was rewritten as: > > class Dir dwhere{ That's weird, I'll look into it, thanks. > instance Dir Directory where > ?localDir (Local f) = return f > > type URL= String > > > was rewritten as: > > > instance Dir Directory where > ?localDir (Local f) = return f > > ?typeURL= String Sorry, I don't see the difference between these two. Did you write the correct one twice by mistake? > Are these known bugs? No, there are no known bugs so please report everything you find! exactPrint is new and most likely sparsely used as of yet. I'd expect there to be a few bugs lying around here and there, and I appreciate all reports! > - Also, the printing is a bit too exact :-), I would like to keep my > comments AND get the code nicely reformatted. > > Is there a way? No. Like Lennart points out that's a really difficult problem, not to say impossible, where do you place the comments after reformatting? Cheers, /Niklas From noteed at gmail.com Tue Oct 20 12:58:34 2009 From: noteed at gmail.com (minh thu) Date: Tue Oct 20 12:35:48 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> Message-ID: <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> 2009/10/20 Niklas Broberg : > Hi again, > >> However: >> - The source code produced was incorrect: >> >> >> class Dir d where >> >> was rewritten as: >> >> class Dir dwhere{ > > That's weird, I'll look into it, thanks. > >> instance Dir Directory where >> localDir (Local f) = return f >> >> type URL= String >> >> >> was rewritten as: >> >> >> instance Dir Directory where >> localDir (Local f) = return f >> >> typeURL= String > > Sorry, I don't see the difference between these two. Did you write the > correct one twice by mistake? In case Pasqualino doesn't see your mail real soon... Maybe the difference is the missing space between "type" and "URL". Cheers, Thu From will_n48 at yahoo.com Tue Oct 20 13:21:02 2009 From: will_n48 at yahoo.com (Will Ness) Date: Tue Oct 20 12:59:02 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> Message-ID: Jason Dagit codersbase.com> writes: > On Mon, Oct 19, 2009 at 5:53 PM, Will Ness yahoo.com> wrote: >> >> You think of functions, where domain matters (for purists?). In syntax >> only the result matter, does it read? Does it have an intended meaning? >> How is it a mistake if it expresses what I intended? >> Both 3 `-` 2 and curry fst `foldl` 0 are exactly the same - expressions with >> infix operator, read in the same way, interpreted in the same way. In >> the first case the backticks are made superfluous by Haskell reader for >> our convinience; but they shouldn't be made illegal. Why should they be? > > Don't you mean 3 `(-)` 2? I'm pretty sure -, without the parens is infix and > (-) is prefix. So it seems to me that you need the brackets for this to be > consistent.Jason You absolutely right, in current syntax that also would only be consistent, yet is illegal also. But I propose to augment the syntax by allowing symbolic ops in backticks to stand for themselves. When I see `op`, for me, it says: infix op. So `+` would also say, infix +. (`- ` 2) would finally become possible. It would read: treat - as infix binary and make a flip section out of it. Just as it does for an alphanumeric identifier in (`op` 2). Without backticks, symbolic ops are also treated as infix by default, but that's just convinience. Anyway I guess all the points in this discussion have been made, and it's just a matter of taste. From valgarv at gmx.net Tue Oct 20 13:25:38 2009 From: valgarv at gmx.net (Ariel J. Birnbaum) Date: Tue Oct 20 13:02:36 2009 Subject: [Haskell-cafe] list -> sublists In-Reply-To: <40a414c20910200731u43d6becg4c854bee950608fc@mail.gmail.com> References: <25975341.post@talk.nabble.com> <40a414c20910200731u43d6becg4c854bee950608fc@mail.gmail.com> Message-ID: <1256059538.4938.35.camel@lnx-arielb> > Now back to your original problem. Can you write a function g such that > g [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > returns > ([1,2,3],[2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]) > > g [2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > returns: > ([2,4,1,6,3],[6,2,3,5,2,5,2,1,6,4]) > > and so on ? Then you should be able to build what you wanted by using > g in a modified version of f. For this kind of questions, Hoogle[1] is your friend. You have a list of type [a], and you want to split it into a pair of (the list up to some point, the rest of the list), whose type is then ([a],[a]). So you search in Hoogle: [a] -> ([a],[a]) and the following results come up: Prelude.break :: (a -> Bool) -> [a] -> ([a], [a]) Prelude.span :: (a -> Bool) -> [a] -> ([a], [a]) (... a few more...) A quick review of the descriptions will show that one of these functions is /very/ close to what you want to achieve. You may use it to implement your solution and/or look at its source code to understand how it works. In fact, you can do better---look at your /original/ problem and figure out what type to search for in Hoogle. One of the results there should turn your problem into a one-liner. Again, you can take a look at its code for additional insight. References: [1] http://www.haskell.org/hoogle/ Have fun! -- Ariel J. Birnbaum From niklas.broberg at gmail.com Tue Oct 20 14:22:13 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Oct 20 13:59:07 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> Message-ID: >>> instance Dir Directory where >>> ?localDir (Local f) = return f >>> >>> ?typeURL= String >> >> Sorry, I don't see the difference between these two. Did you write the >> correct one twice by mistake? > > In case Pasqualino doesn't see your mail real soon... > Maybe the difference is the missing space between "type" and "URL". Ah, of course, I see it now, thanks! Cheers, /Niklas From agocorona at gmail.com Tue Oct 20 15:14:13 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue Oct 20 14:51:07 2009 Subject: [Haskell-cafe] debugtracehelpers Re: traceM and traceShowM In-Reply-To: References: <910ddf450910191351s6c322c07vc5b5a0d8572d7a50@mail.gmail.com> Message-ID: I don't know why people use trace this way instead of in the reverse form: debug = flip trace this way I can isolate debug code in the right from normal code: main= do a <- getChar b <- getChar `debug` ("a="++ show a) let c= a+b `debug` ("b="++ show b) ... and so on. I saw it for the first time in the DrIFt libtary. 2009/10/20 Justin Bailey > These woudl be much more useful if they flushed the output handle > after each message. Then you know your trace messages will be > displayed/written to a file. > > On Mon, Oct 19, 2009 at 1:51 PM, Thomas Hartman > wrote: > > I have this and a couple other handy functions in > > > > DebugTraceHelpers: > > > > > http://patch-tag.com/r/tphyahoo/DebugTraceHelpers/snapshot/current/content/pretty > > > > hackage: > > > > > http://hackage.haskell.org/packages/archive/DebugTraceHelpers/0.12/doc/html/Debug-Trace-Helpers.html > > > > > > 2009/10/16 Martijn van Steenbergen : > >> Hello, > >> > >> I propose the addition of the following two functions to module > Debug.Trace: > >> > >>> traceM :: Monad m => String -> m () > >>> traceM msg = trace msg (return ()) > >>> > >>> traceShowM :: (Show a, Monad m) => a -> m () > >>> traceShowM = traceM . show > >> > >> These functions allow tracing in any do-block. I often define them > myself; I > >> think they are useful in general. > >> > >> Deadline: 23 October 2009. > >> > >> Martijn. > >> _______________________________________________ > >> Libraries mailing list > >> Libraries@haskell.org > >> http://www.haskell.org/mailman/listinfo/libraries > >> > > _______________________________________________ > > 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/20091020/b56190ab/attachment.html From mauricio.antunes at gmail.com Tue Oct 20 15:24:36 2009 From: mauricio.antunes at gmail.com (=?UTF-8?B?TWF1csOtwq1jaW8gQ0E=?=) Date: Tue Oct 20 15:01:47 2009 Subject: [Haskell-cafe] Re: pretty printing with comments In-Reply-To: References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> Message-ID: >>>> ?typeURL= String >> Maybe the difference is the missing space between "type" and "URL". > Ah, of course, I see it now, thanks! It ocurred to me that you could catch these kind of errors faster if haskell-src-exts included a basic program to pretty print a Haskell module that we could use out of the box. What do you think? Should it better be a separate package? Maur?cio From tittoassini at gmail.com Tue Oct 20 15:55:56 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Tue Oct 20 15:32:50 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> Message-ID: <2d34474e0910201255n309606ffk77bab02e2bc3eaa4@mail.gmail.com> Hi, there is also another difference: type URL= String was a top level definition but it has been moved under the previous instance declaration. I attach a source fragment and another file with the pretty printed output containing these three errors. Regarding the problem of pretty printing while keeping the comments I imagine that you would like the comments to be associated with the previous syntactical element (module, top level declaration or expression) and be rendered in the same relative position in the pretty printed output. I agree that it doesn't sound like an easy task. However, similar systems exists for most languages (I loved my Java reformatter in Eclipse) and it would be very handy in Haskell as well. Best, titto 2009/10/20 Niklas Broberg : >>>> instance Dir Directory where >>>> ?localDir (Local f) = return f >>>> >>>> ?typeURL= String >>> >>> Sorry, I don't see the difference between these two. Did you write the >>> correct one twice by mistake? >> >> In case Pasqualino doesn't see your mail real soon... >> Maybe the difference is the missing space between "type" and "URL". > > Ah, of course, I see it now, thanks! > > Cheers, > > /Niklas > -- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ -------------- next part -------------- A non-text attachment was scrubbed... Name: TestPP.hs Type: text/x-haskell Size: 876 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091020/b59bb29b/TestPP.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: TestPP_PRETTY.hs Type: text/x-haskell Size: 873 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091020/b59bb29b/TestPP_PRETTY.bin From michael at snoyman.com Tue Oct 20 18:02:31 2009 From: michael at snoyman.com (Michael Snoyman) Date: Tue Oct 20 17:39:25 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910200612k2f79c83u2d9dd4ce2b9b6ff2@mail.gmail.com> Message-ID: <29bf512f0910201502l37d5def5n3eadd3d60d36b125@mail.gmail.com> On Tue, Oct 20, 2009 at 5:17 PM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > On Tue, Oct 20, 2009 at 3:12 PM, Michael Snoyman > wrote: > > > > > > On Tue, Oct 20, 2009 at 11:04 AM, Nicolas Pouillard > > wrote: > >> > >> On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman > >> wrote: > >> > While working on the next release of data-object, I wanted to > represent > > [...] > > >> About the name Attempt, I think that 'Outcome' would be a better name. > > > > The problem with a name like "Outcome" is that it doesn't really imply > the > > possibility of failure, simply that we are wrapping of the result for > some > > reason. > > I don't see why, the outcome of an action could be either a success or > a failure. > Even if the only *desired* outcome is success. > I think I'm going to stick with Attempt. The only other point that came to me is it's nicer to have a function called "attempt" than "outcome" IMO. > > >> > 2) Are there any other FromAttempt instances I should provide out of > the > >> > box? > >> > >> None that I see. > >> > >> > 3) I was considering adding specialized versions of the fromAttempt > >> > function, ie ioFromAttempt, maybeFromAttempt. Thoughts? > >> > >> It is a bit long to spell. > > > > True, but it can be more convenient than giving explicit type signatures. > > The main reason this might come up would be regarding the (Either String) > > and (Either SomeException) instances. > > > >> > >> > 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, > or > >> > just call the functions join, lookup and force people to import the > >> > module > >> > qualified? > >> > >> A nice alternative would be to make a Data.Attempt.Extra (or a better > >> name) which > >> would be imported qualified. > > > > I like. The only other name I can think of right now is > Data.Attempt.Helper, > > but that's just painting the bike shed. > > I also prefer Helper. > Done. Not full-featured yet, but does provide a nice core. > > >> > 5) Any other suggestions for attempt functions? I've considered > >> > head/tail/etc. > >> > >> Why not, maybe the 'safe' package should be of some inspiration. > > > > Once they're all in their own module, I don't see a problem adding as > many > > as possible. > > [...] > > >> attempt :: (forall e. Exception e -> b) -> (a -> b) -> Attempt a -> b > >> > > I was trying to more model it after fromMaybe, but instead just ended up > > with something ugly. I'm going to rewrite attempt using this type > signature > > and then add fromAttempt as well. > > Fine, fromAttempt should follow fromMaybe > > fromAttempt :: (forall e. Exception e -> a) -> Attempt a -> a > fromAttempt f a = attempt f id a > And of course I now realize this name will conflict with the FromAttempt typeclass ;). I think we'll be safe leaving this function out, considering how trivial it is to implement in terms of attempt. Also, I've added a monad transformer to the github repo. I've tried it out in some local code I have, and it *really* cleans up the error handling. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091020/d80dfde2/attachment.html From niklas.broberg at gmail.com Tue Oct 20 18:18:40 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Oct 20 17:55:33 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: <2d34474e0910201255n309606ffk77bab02e2bc3eaa4@mail.gmail.com> References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> <2d34474e0910201255n309606ffk77bab02e2bc3eaa4@mail.gmail.com> Message-ID: Hi again, > I attach a source fragment and another file with the pretty printed > output containing these three errors. Thanks, I've opened a ticket for this issue here: http://trac.haskell.org/haskell-src-exts/ticket/65 I'll see when I can get to fixing it, hopefully it won't be long. Cheers, /Niklas From nicolas.pouillard at gmail.com Tue Oct 20 18:35:27 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Oct 20 18:12:19 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: <29bf512f0910201502l37d5def5n3eadd3d60d36b125@mail.gmail.com> References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910200612k2f79c83u2d9dd4ce2b9b6ff2@mail.gmail.com> <29bf512f0910201502l37d5def5n3eadd3d60d36b125@mail.gmail.com> Message-ID: On Wed, Oct 21, 2009 at 12:02 AM, Michael Snoyman wrote: > On Tue, Oct 20, 2009 at 5:17 PM, Nicolas Pouillard > wrote: >> >> On Tue, Oct 20, 2009 at 3:12 PM, Michael Snoyman >> wrote: >> > >> > >> > On Tue, Oct 20, 2009 at 11:04 AM, Nicolas Pouillard >> > wrote: >> >> >> >> On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman >> >> wrote: >> >> > While working on the next release of data-object, I wanted to >> >> > represent >> >> [...] >> >> >> About the name Attempt, I think that 'Outcome' would be a better name. >> > >> > The problem with a name like "Outcome" is that it doesn't really imply >> > the >> > possibility of failure, simply that we are wrapping of the result for >> > some >> > reason. >> >> I don't see why, the outcome of an action could be either a success or >> a failure. >> Even if the only *desired* outcome is success. > > I think I'm going to stick with Attempt. The only other point that came to > me is it's nicer to have a function called "attempt" than "outcome" IMO. OK [...] >> fromAttempt :: (forall e. Exception e -> a) -> Attempt a -> a >> fromAttempt f a = attempt f id a > > And of course I now realize this name will conflict with the FromAttempt > typeclass ;). I think we'll be safe leaving this function out, considering > how trivial it is to implement in terms of attempt. :) BTW, fromAttempt instance can be nicely expressed using the 'attempt' function. > Also, I've added a monad transformer to the github repo. I've tried it out > in some local code I have, and it *really* cleans up the error handling. Having the monad transformer too is great. The only minor disadvantage is to make a choice between mtl and transformers. But transformers is slowly replacing mtl so no big deal. -- Nicolas Pouillard http://nicolaspouillard.fr From michael at snoyman.com Tue Oct 20 19:02:08 2009 From: michael at snoyman.com (Michael Snoyman) Date: Tue Oct 20 18:39:01 2009 Subject: [Haskell-cafe] Error handling package In-Reply-To: References: <29bf512f0910181245t7a3c53d6kf7748f4abfafdd27@mail.gmail.com> <29bf512f0910181504x4bade642pffbc34f6ed5d5142@mail.gmail.com> <29bf512f0910181600v2d283cbem3a5bc211d59d2aa@mail.gmail.com> Message-ID: <29bf512f0910201602k49eae7e3k4e22a4b042a75d80@mail.gmail.com> On Mon, Oct 19, 2009 at 3:46 PM, Jose Iborra wrote: > You may want to take a look at another option in Hackage, the > control-monad-exception package. I've tried using the package; you can see the results at this github branch: http://github.com/snoyberg/data-object/blob/control-monad-exception/Data/Object.hs. I found the result to be too difficult to work with. For my purposes in this library, non-explicit exceptions are much more appropriate. Thanks for the great library though, I'll keep it in mind for future uses. Michael > > > http://pepeiborra.github.com/control-monad-exception/ > > The control-monad-exception library provides the building blocks for > > * Explicitly Typed exceptions (checked or not) > * which are composable > * and even provide stack traces (experimental feature) > > > On 19/10/2009, at 01:00, Michael Snoyman wrote: > > (Sorry, accidently took off cafe.) >> >> On Mon, Oct 19, 2009 at 12:44 AM, Henning Thielemann < >> lemming@henning-thielemann.de> wrote: >> >> On Mon, 19 Oct 2009, Michael Snoyman wrote: >> >> Does the explicit-exception package provide what you need? >> >> http://hackage.haskell.org/package/explicit-exception >> >> >> I don't think so, but correct me if I'm wrong. I want to make it easy to >> chain together >> computations which could fail in different ways. For example, something >> like this: >> >> attemptReadInt :: String -> Attempt Int >> attemptLookup :: String -> [(String, String)] -> Attempt String >> attemptLookupInt :: String -> [(String, String)] -> Attempt Int >> attemptLookupInt k m = attemptLookup k m >>= attemptReadInt >> >> Now, in the explicit-exception package, I could- in this simple example- >> define >> something like: >> >> data MyErrors = KeyNotFound | InvalidInt >> >> >> type Attempt = Exceptional MyErrors >> >> True; that's what I meant by I could do this in my simple example. >> >> >> But this solution would not scale. >> >> You want to add other exceptions? The idea of my package is to make >> exceptions explicit in the type. Otherwise you would use >> extensible-exceptions. Or you could define MyErrors using an existential >> type. >> >> Which is my point. I'm trying to provide a package for non-explicit >> exceptions. To compare to other programming languages, I think your package >> is providing the equivalent of Java checked exceptions, while mine is >> providing (safe) unchecked exceptions. I say safe because you still need to >> explicitly decide to turn an Attempt into a possible runtime exception which >> will bring down your program. >> >> Defining MyErrors using an existential type would essentially recreate the >> entire attempt package; I don't see that purpose in everyone wanted >> unchecked exceptions needing to reinvent the wheel in non-compatible ways. >> If multiple libraries use attempt, they can easily have their >> possible-error-returning functions chain together safely. >> >> > I believe that control-monad-exception solves this tension between > composability and explicit exceptions. > You can have explicit exceptions which are composable: > > > data DivideByZero = DivideByZero deriving (Show, Typeable) > > data SumOverflow = SumOverflow deriving (Show, Typeable) > > > instance Exception DivideByZero > > instance Exception SumOverflow > > > data Expr = Add Expr Expr | Div Expr Expr | Val Double > > > eval (Val x) = return x > > eval (Add a1 a2) = do > > v1 <- eval a1 > > v2 <- eval a2 > > let sum = v1 + v2 > > if sum < v1 || sum < v2 then throw SumOverflow else return sum > > eval (Div a1 a2) = do > > v1 <- eval a1 > > v2 <- eval a2 > > if v2 == 0 then throw DivideByZero else return (v1 / v2) > > GHCi infers the following types > > > :t eval > > eval :: (Throws DivideByZero l, Throws SumOverflow l) => Expr -> EM l > Double > > > :t eval `catch` \ (e::DivideByZero) -> return (-1) > > .... :: Throws SumOverflow l => Expr -> EM l Double > > > :t runEM(eval `catch` \ (e::SomeException) -> return (-1)) > > .... : Expr -> Double > > >> Additionally, there's two immediate features I think I would miss from my >> package: >> >> 1) fail works properly, so an Attempt would be a valid monad response from >> people who >> use that function. >> >> As far as I understand, 'fail' is used/abused for reporting failed pattern >> matches in do notation. If a failed pattern match indicates a programming >> error, it should be a really error, and not something that must be handled >> at run-time. >> >> That's a lot of very debateable statements you just made. It might be that >> it's strongly encouraged to only use fail for failed pattern matching, but >> in practice you could use it for any monadic failure. Also, there's nothing >> stopping a user from re-throwing pattern match exceptions received in an >> Attempt. >> > > I am with Henning on 'fail'. > It must not be used as a replacement for throw, only for failed pattern > matches which are programming errors and thus unchecked exceptions. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091020/9270b64e/attachment.html From ok at cs.otago.ac.nz Tue Oct 20 19:44:18 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Oct 20 19:21:15 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <40a414c20910192346r7b0d75d5v72ccd27d3afea0d8@mail.gmail.com> References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> <40a414c20910192346r7b0d75d5v72ccd27d3afea0d8@mail.gmail.com> Message-ID: <88B078AB-E15D-4EEC-8DAA-EFC9AF573FC3@cs.otago.ac.nz> It's worth remembering that APL and SML, amongst others, distinguish between the sign used for a negative literal (?1 in APL, ~1 in SML) and the sign used for subtraction (the hyphen/minus in both of them). It doesn't seem to be a hard thing to get your head around in practice. From having worked on a Prolog system, I can tell you that the fact that -1 is a single token except when it isn't, yet -X is always two, caused headaches for implementors and confusion for users. In Smalltalk, -1 is a number, but x-1 is three tokens, not two. (You have to keep track of what the previous token was to tell what to do.) If I were making suggestions for Haskell' (other than please, pretty please with knobs on, let me keep n+k), one of them would be to introduce the character U+00AF (chosen because it's 8859-1, -4, -8, -9, and -15 at least) as a unary minus sign, allowing it to be used for exponent signs as well, so that ?x - ?1.0e?10 is allowed. Then Haskell'' could remove the unary - . In the mean time, the unary - / binary - issue is something you run into hard ONCE, and then avoid easily enough, not unlike forgetting the back-ticks in x `div` y. From ok at cs.otago.ac.nz Tue Oct 20 20:08:19 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Oct 20 19:45:16 2009 Subject: [Haskell-cafe] list -> sublists In-Reply-To: <25975341.post@talk.nabble.com> References: <25975341.post@talk.nabble.com> Message-ID: <1798B492-2B1C-4D7C-8B42-6BABCF3E3C82@cs.otago.ac.nz> On Oct 21, 2009, at 3:16 AM, satorisanitarium wrote: > > I just started learning haskell and I just came to my first wtf > moment. > > I'm trying to do something like this: > > calling: > foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] > > returns: > [[1,2,3],[2,4,1,6,3],[2,3]] > > but i have no idea how to put something into a sublist. From the way you talk about the problem, I suspect that you are trying to understand in a rather complicated way. Here's how I approach your example: foo item list = if there is an occurrence of item in list then a new list whose first element is everything up to and including that occurrence and whose remaining elements are found by applying foo item to everything after that occurrence else an empty list We can do this in just a couple of lines using List.elemIndex and splitAt, but let's do it in an elementary way. We'll write a helper function that either returns (before-and-including-item, after-item) or nothing. find_and_split :: Eq t => t -> [t] -> Maybe ([t], [t]) find_and_split item list = loop list [] where loop [] _ = Nothing loop (x:xs) before | x == item = Just (reverse (x:before), xs) loop (x:xs) before = loop xs (x:before) foo :: Eq t => t -> [t] -> [[t]] foo item list = case find_and_split item list of Nothing -> [] Just (before, after) -> before : foo item after The answer I get is *Main> foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] [[1,2,3],[2,4,1,6,3],[6,2,3]] ^ which differs from yours at the marked place, but which I think is right. List.elemIndex tells you where an element occurs. Just 0 is the first position. splitAt splits a list into two pieces, the size argument tells you the length of the first piece. So foo item list = case List.elemIndex item list of Nothing -> [] Just pos -> before : foo item after where (before, after) = splitAt (pos+1) list This gives the same answer as the previous version. In neither case do we do ANYTHING to "put" items into a "sublist", we just construct a list whose elements happen to be lists. It's no different from calculating a list of numbers. From wren at freegeek.org Wed Oct 21 01:17:21 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Oct 21 00:54:16 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <40a414c20910192346r7b0d75d5v72ccd27d3afea0d8@mail.gmail.com> References: <338166.65683.qm@web112202.mail.gq1.yahoo.com> <7ca3f0160910181559x600237d2x9ed408f100f39eb2@mail.gmail.com> <4ADBE67B.8060101@freegeek.org> <40a414c20910192346r7b0d75d5v72ccd27d3afea0d8@mail.gmail.com> Message-ID: <4ADE9961.10202@freegeek.org> minh thu wrote: > Something I wonder from time to time if it would be a good thing or > not is to allow > a `f g` b > to mean > f g a b This comes up from time to time, though it is often met with stern disapproval because it can easily lead to loss of clarity. There is a valid alternative, though it's not quite as pretty: ($a) (f g...) b c... == f g... a b c... With even less prettiness, this can also be generalized for other numbers of prefix arguments: ( ($a) f) b c... == f a b c... ( ($b) $($a) f) c d... == f a b c d... (($c) $($b) $($a) f) d e... == f a b c d e... And if anyone wanted to use this sort of pattern frequently, I'm sure there's some decent way to clean it up ala Matt Hellige's pointless trick[1] or ala Oleg's polyvariadic trick[2]. [1] http://matt.immute.net/content/pointless-fun [2] http://okmij.org/ftp/Haskell/polyvariadic.html -- Live well, ~wren From mpm at alumni.caltech.edu Wed Oct 21 05:29:53 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Oct 21 05:06:59 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 Message-ID: <4ADED491.2030806@alumni.caltech.edu> The examples in the "error handling" chapter (19) of RWH don't run under GHC 6.10. For instance, an example might be main = handle (\_ -> putStrLn "error") (print $ 5 `div` 0) Trying to load this results in "amigous type variable 'e' in the constraint: 'Exception e' arising from a use of 'handle' etc etc. I was able to fix this via the ludicrously complex: main2 = (handle :: (SomeException -> IO ()) -> IO () -> IO ()) (\_ -> putStrLn "Error calculating result") (print $ 5 `div` 0) Is there a more concise way to use "handle", or can someone point me to a tutorial that might explain the changes in 6.10 and in a general way how to get the RWH examples to run? Thanks, Mike From lrpalmer at gmail.com Wed Oct 21 06:36:41 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Oct 21 06:13:33 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 In-Reply-To: <4ADED491.2030806@alumni.caltech.edu> References: <4ADED491.2030806@alumni.caltech.edu> Message-ID: <7ca3f0160910210336y5d2becfcx31b672487329025d@mail.gmail.com> On Wed, Oct 21, 2009 at 3:29 AM, Michael Mossey wrote: > The examples in the "error handling" chapter (19) of RWH don't run under GHC > 6.10. > > For instance, an example might be > > main = handle (\_ -> putStrLn "error") (print $ 5 `div` 0) > > Trying to load this results in "amigous type variable 'e' in the constraint: > 'Exception e' arising from a use of 'handle' etc etc. > > I was able to fix this via the ludicrously complex: > > main2 = (handle :: (SomeException -> IO ()) -> IO () -> IO ()) > ? ? ? ?(\_ -> putStrLn "Error calculating result") > ? ? ? ?(print $ 5 `div` 0) > > Is there a more concise way to use "handle", or can someone point me to a > tutorial that might explain the changes in 6.10 and in a general way how to > get the RWH examples to run? How about: anyHandler :: IO () -> SomeException -> IO () anyHandler = const main = handle (anyHandler (putStrLn "Error calculating result")) (print $ 5 `div` 0) Luke From martijn at van.steenbergen.nl Wed Oct 21 08:07:37 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Oct 21 07:44:39 2009 Subject: [Haskell-cafe] Test cases for type inference In-Reply-To: References: Message-ID: <4ADEF989.6020303@van.steenbergen.nl> Peter Verswyvelen wrote: > For learning, I would like to develop my own implementation of type > inference, based on the paper "Typing Haskell in Haskell". > > At first sight, the source code of THIH contains a small number of > tests, but I was wandering if a large test set exist? I'm pretty sure GHC maintains a large set of test cases. Maybe you can use some of those? Or maybe you can just pick a random project from hackage and run your type checker on that? Martijn. From greg at gregorycollins.net Wed Oct 21 10:36:20 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Wed Oct 21 10:13:11 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 In-Reply-To: <4ADED491.2030806@alumni.caltech.edu> (Michael Mossey's message of "Wed, 21 Oct 2009 02:29:53 -0700") References: <4ADED491.2030806@alumni.caltech.edu> Message-ID: <87fx9cstjv.fsf@gregorycollins.net> Michael Mossey writes: > The examples in the "error handling" chapter (19) of RWH don't run under GHC > 6.10. > > For instance, an example might be > > main = handle (\_ -> putStrLn "error") (print $ 5 `div` 0) I usually use: main = handle (\(_ :: SomeException) -> putStrLn "error") (print $ 5 `div` 0) ...but you need the "ScopedTypeVariables" language extension. G -- Gregory Collins From nonowarn at gmail.com Wed Oct 21 10:37:29 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Wed Oct 21 10:14:19 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 In-Reply-To: <4ADED491.2030806@alumni.caltech.edu> References: <4ADED491.2030806@alumni.caltech.edu> Message-ID: To deal with "amigous type variable 'e'", I often write the codes like: handle (\e@SomeException{} -> print e) (5 `div` 0) and IIRC, the base-4.0 initially released with GHC 6.10.1, introduced this exceptions. It enables us to specify which exception should be caught and define types of exceptions what you want. And I hear this is based on the paper http://www.haskell.org/~simonmar/papers/ext-exceptions.pdf On Wed, Oct 21, 2009 at 6:29 PM, Michael Mossey wrote: > The examples in the "error handling" chapter (19) of RWH don't run under GHC > 6.10. > > For instance, an example might be > > main = handle (\_ -> putStrLn "error") (print $ 5 `div` 0) > > Trying to load this results in "amigous type variable 'e' in the constraint: > 'Exception e' arising from a use of 'handle' etc etc. > > I was able to fix this via the ludicrously complex: > > main2 = (handle :: (SomeException -> IO ()) -> IO () -> IO ()) > ? ? ? ?(\_ -> putStrLn "Error calculating result") > ? ? ? ?(print $ 5 `div` 0) > > Is there a more concise way to use "handle", or can someone point me to a > tutorial that might explain the changes in 6.10 and in a general way how to > get the RWH examples to run? > > Thanks, > Mike > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jvranish at gmail.com Wed Oct 21 10:47:00 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Oct 21 10:23:53 2009 Subject: [Haskell-cafe] Test cases for type inference In-Reply-To: References: Message-ID: I was recently working on an type inference algorithm and to test it I did the following: Used the quickcheck Arbitrary typeclass to generate expressions Inferred types of the expressions using my algorithm, converted the expressions that passed inference to haskell and wrote them to a file (without type signatures) converted and wrote the failed expression to a separate file compiled the "passed" file with -Wall, and extracted all the type signatures that were spit out as warnings parsed the type signatures that -Wall spit out and compare with the signatures generated by my algorithm. compiled the "failed" file and make sure I get type errors for all my expressions My algorithm also infers infinite types (which haskell does not) so I had to test that functionality manually. Overall it was kinda messy, but it worked ok. I could possibly send you one of my lists. My test expressions are all very simple, no type classes, only 2 types (function and number), and the only expression components are let, lambda, apply, identifier, and number. If something like that would work, let me know. Hope that helps, - Job On Tue, Oct 20, 2009 at 10:07 AM, Peter Verswyvelen wrote: > For learning, I would like to develop my own implementation of type > inference, based on the paper "Typing Haskell in Haskell". > > At first sight, the source code of THIH contains a small number of > tests, but I was wandering if a large test set exist? > > Thanks, > Peter > _______________________________________________ > 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/20091021/b865488d/attachment.html From ben at 0x539.de Wed Oct 21 11:56:49 2009 From: ben at 0x539.de (Benjamin Herr) Date: Wed Oct 21 11:33:43 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 In-Reply-To: <4ADED491.2030806@alumni.caltech.edu> References: <4ADED491.2030806@alumni.caltech.edu> Message-ID: <1256140519-sup-4449@vaelastrasz> Hi, Excerpts from Michael Mossey's message of Mi Okt 21 11:29:53 +0200 2009: > how to get the RWH examples to run? Changing the imports from Control.Exception to Control.OldException did it for me. I am not sure whether this is what you were looking for, but it should at least allow you to follow the RWH examples, if you want to, before diving into the new Control.Exception. -ben From tphyahoo at gmail.com Wed Oct 21 12:15:52 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Oct 21 11:52:43 2009 Subject: [Haskell-cafe] Re: systemtimmetypeable: Workaround for lack of deriveable data instance in either System.Time or Data.Time. In-Reply-To: <910ddf450910191400g4e4f2dc7h75bcfe95a0a6ffc5@mail.gmail.com> References: <910ddf450910191400g4e4f2dc7h75bcfe95a0a6ffc5@mail.gmail.com> Message-ID: <910ddf450910210915u130d340dj4dc4768c7c9c28d9@mail.gmail.com> update: on haskell reddit, dons suggested simply patching time. reasonable enough, but I hit a glitch where the Data.Fixed (in base lib) was missing a Data instance, and gave up when I couldn't find the source repo for base. Is this simply part of ghc? Anyways, that instance seems to be added in ghc 6.12 so probably a non issue now or closer to it. http://www.haskell.org/ghc/dist/current/docs/html/libraries/base/Data-Fixed.html also, aavogton #haskell suggested http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11009#a11009 as a workaround for people using time on happstack earlier than 6.12, probably nicer than the MyTime hack I created though it comes with a bit more baggage. I haven't upgraded to 6.12 but I would suggest that time now be made Data Generics friendly if it hasn't already, since this is probably a very simple change and would be helpful to happstack. If no one has time to do this I'll try to get around to it when I upgrade to 6.12. Also wouter swierstra suggested that standalone deriving ( http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#stand-alone-deriving ) could be helpful in this case but I'm not sure why, or even whether this was for data-izing data.time or system.time or both. Given all this I won't be uploading anything to hackage, and hopefully the base libs + time will be data friendly soon enough. thomas. 2009/10/19 Thomas Hartman : > At > > http://osdir.com/ml/haskell-cafe@haskell.org/2009-10/msg00197.html > > I griped that the lack of Data-Derivable time values was causing me > headache in happstack. > > In the proposed cabal package > > http://patch-tag.com/r/tphyahoo/systemtimetypeable/snapshot/current/content/pretty/systemtimetypeable.cabal > > I submit a workaround that, while probably not the ideal thing, has > proved helpful to me. > > Basically, I use the type MyTime, which is data-deriveable, when > working with Macid in happstack; and convert from System.Time and/or > Data.Time with the accompanying utility functions when necessary. > Perhaps the utility functions are useful on their own as well. I found > it surprisingly hard to get from Data.Time values to System.Time > values. > > Anyways, I am interested in what others think and, of course, patches > and suggestions welcome. > > thomas. > From leimy2k at gmail.com Wed Oct 21 12:32:20 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Oct 21 12:09:11 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 In-Reply-To: <1256140519-sup-4449@vaelastrasz> References: <4ADED491.2030806@alumni.caltech.edu> <1256140519-sup-4449@vaelastrasz> Message-ID: <3e1162e60910210932t1247bc31lbcef76567bceda44@mail.gmail.com> It's educational to port the examples yourself. Dave On Wed, Oct 21, 2009 at 8:56 AM, Benjamin Herr wrote: > Hi, > > Excerpts from Michael Mossey's message of Mi Okt 21 11:29:53 +0200 2009: > > how to get the RWH examples to run? > > Changing the imports from Control.Exception to Control.OldException did it > for > me. I am not sure whether this is what you were looking for, but it should > at > least allow you to follow the RWH examples, if you want to, before diving > into > the new Control.Exception. > > -ben > _______________________________________________ > 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/20091021/a0bc2890/attachment.html From ashley at semantic.org Wed Oct 21 13:05:18 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Wed Oct 21 12:42:13 2009 Subject: [Haskell-cafe] Re: systemtimmetypeable: Workaround for lack of deriveable data instance in either System.Time or Data.Time. In-Reply-To: <910ddf450910210915u130d340dj4dc4768c7c9c28d9@mail.gmail.com> References: <910ddf450910191400g4e4f2dc7h75bcfe95a0a6ffc5@mail.gmail.com> <910ddf450910210915u130d340dj4dc4768c7c9c28d9@mail.gmail.com> Message-ID: <1256144718.3628.5.camel@sanctuary> Data.Fixed (in base) has been updated with Data instances in HEAD. When that's released, I'll release time-extra that will contain Data instances. I've got it all ready to go. The reason Data instances are in time-extras is that the time library must be Haskell 98, while Data instances require Rank2. -- Ashley On Wed, 2009-10-21 at 11:15 -0500, Thomas Hartman wrote: > update: > > on haskell reddit, dons suggested simply patching time. reasonable > enough, but I hit a glitch where the Data.Fixed (in base lib) was > missing a Data instance, and gave up when I couldn't find the source > repo for base. Is this simply part of ghc? > > Anyways, that instance seems to be added in ghc 6.12 so probably a non > issue now or closer to it. > > http://www.haskell.org/ghc/dist/current/docs/html/libraries/base/Data-Fixed.html > > also, aavogton #haskell suggested > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11009#a11009 > > as a workaround for people using time on happstack earlier than 6.12, > probably nicer than the MyTime hack I created though it comes with a > bit more baggage. > > I haven't upgraded to 6.12 but I would suggest that time now be made > Data Generics friendly if it hasn't already, since this is probably a > very simple change and would be helpful to happstack. If no one has > time to do this I'll try to get around to it when I upgrade to 6.12. > > Also wouter swierstra suggested that standalone deriving ( > http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#stand-alone-deriving > ) could be helpful in this case but I'm not sure why, or even whether > this was for data-izing data.time or system.time or both. > > Given all this I won't be uploading anything to hackage, and hopefully > the base libs + time will be data friendly soon enough. > > thomas. > > 2009/10/19 Thomas Hartman : > > At > > > > http://osdir.com/ml/haskell-cafe@haskell.org/2009-10/msg00197.html > > > > I griped that the lack of Data-Derivable time values was causing me > > headache in happstack. > > > > In the proposed cabal package > > > > http://patch-tag.com/r/tphyahoo/systemtimetypeable/snapshot/current/content/pretty/systemtimetypeable.cabal > > > > I submit a workaround that, while probably not the ideal thing, has > > proved helpful to me. > > > > Basically, I use the type MyTime, which is data-deriveable, when > > working with Macid in happstack; and convert from System.Time and/or > > Data.Time with the accompanying utility functions when necessary. > > Perhaps the utility functions are useful on their own as well. I found > > it surprisingly hard to get from Data.Time values to System.Time > > values. > > > > Anyways, I am interested in what others think and, of course, patches > > and suggestions welcome. > > > > thomas. > > > From nowgate at yahoo.com Wed Oct 21 13:34:47 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 13:11:37 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem Message-ID: <354610.64099.qm@web31101.mail.mud.yahoo.com> There's a thread on the plt-scheme list about creating a function of NO arguments named NEXT that just returns the number of times it's been called, a piece of cake in Scheme, but how would one do this in Haskell? Would the best approach be to use a State monad? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/e6cada9f/attachment.html From byorgey at seas.upenn.edu Wed Oct 21 13:47:55 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Oct 21 13:24:45 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <354610.64099.qm@web31101.mail.mud.yahoo.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> Message-ID: <20091021174755.GA18159@seas.upenn.edu> On Wed, Oct 21, 2009 at 10:34:47AM -0700, michael rice wrote: > There's a thread on the plt-scheme list about creating a function of NO arguments named NEXT that just returns the number of times it's been called, a piece of cake in Scheme, but how would one do this in Haskell? Would the best approach be to use a State monad? Yes, a State monad would be the way to go. Such a function cannot have type () -> Int in Haskell, because a function with type () -> Int must be pure: in particular it would always have to give the same output. So giving the function the type () -> State Int Int (or really, just State Int Int) makes explicit the fact that evaluating it has a state effect. -Brent From noteed at gmail.com Wed Oct 21 13:49:13 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 21 13:26:23 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <354610.64099.qm@web31101.mail.mud.yahoo.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> Message-ID: <40a414c20910211049i6d0ea2d2obf83052c0b119074@mail.gmail.com> 2009/10/21 michael rice > > There's a thread on the plt-scheme list about creating a function of NO arguments named NEXT that just returns the number of times it's been called, a piece of cake in Scheme, but how would one do this in Haskell? Would the best approach be to use a State monad? If you really want no argument, not just syntactically in the do notation, you need ST or IO. Furthermore, you need ST or IO to allocate a mutable variable that is accessible only to the next function. Cheers, Thu From inforichland at gmail.com Wed Oct 21 14:00:29 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Wed Oct 21 13:37:18 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <354610.64099.qm@web31101.mail.mud.yahoo.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> Message-ID: <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> I'm guessing the function looks something like this? (this is common lisp not scheme) (let ((counter 0)) (defun next () (incf counter) counter)) So the first time you call (next), it returns 1, then 2, etc. The function (next) is a closure over the variable 'counter' and acts by incrementing the variable counter, which is only visible in the scope of the let-block. As you know in Haskell there is no mutable state (outside of certain monads), so a function like must take place in a monad which allows this, such as IO or ST. You would probably have to allocate an IORef or STRef which is local to the next function (effectively creating a closure over it). Cheers, - Tim On Wed, Oct 21, 2009 at 12:34 PM, michael rice wrote: > There's a thread on the plt-scheme list about creating a function of NO > arguments named NEXT that just returns the number of times it's been called, > a piece of cake in Scheme, but how would one do this in Haskell? Would the > best approach be to use a State monad? > > Michael > > _______________________________________________ > 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/20091021/d50a0e67/attachment.html From jur at cs.uu.nl Wed Oct 21 14:00:57 2009 From: jur at cs.uu.nl (jur) Date: Wed Oct 21 13:37:52 2009 Subject: [Haskell-cafe] Test cases for type inference In-Reply-To: References: Message-ID: <9B72BE92-92F7-4534-8FD7-B584A2439BCE@cs.uu.nl> > > On Tue, Oct 20, 2009 at 10:07 AM, Peter Verswyvelen > wrote: > For learning, I would like to develop my own implementation of type > inference, based on the paper "Typing Haskell in Haskell". > > At first sight, the source code of THIH contains a small number of > tests, but I was wandering if a large test set exist? > > Thanks, > Peter Dear Peter, The sources of the Helium compiler contain quite a few test files for type inference and other issues like static checking. Go to http://www.cs.uu.nl/wiki/Helium go to Downloads and get the most recent version. Then unpack it. Then go to the directory heliumsystem/helium/test/typerrrors that contains a large number of type erroneous programs,and heliumsystem/helium/test/correct contains quite a few that should pass the test (but that does depend somewhat on how extensive the language you support is). hope this helps, Jurriaan > _______________________________________________ > 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 inforichland at gmail.com Wed Oct 21 14:23:40 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Wed Oct 21 14:00:31 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> Message-ID: <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> Here's an example in the IO monad: import Data.IORef import System.IO.Unsafe counter = unsafePerformIO $ newIORef 0 next = do modifyIORef counter (+1) readIORef counter Naturally, this uses unsafePerformIO, which as you know, is not kosher... Cheers, - Tim On Wed, Oct 21, 2009 at 1:00 PM, Tim Wawrzynczak wrote: > I'm guessing the function looks something like this? (this is common lisp > not scheme) > > (let ((counter 0)) > (defun next () > (incf counter) > counter)) > > So the first time you call (next), it returns 1, then 2, etc. > The function (next) is a closure over the variable 'counter' and acts by > incrementing the variable counter, which is only visible in the scope of the > let-block. As you know in Haskell there is no mutable state (outside of > certain monads), so a function like must take place in a monad which allows > this, such as IO or ST. You would probably have to allocate an IORef or > STRef which is local to the next function (effectively creating a closure > over it). > > Cheers, > - Tim > > > On Wed, Oct 21, 2009 at 12:34 PM, michael rice wrote: > >> There's a thread on the plt-scheme list about creating a function of NO >> arguments named NEXT that just returns the number of times it's been called, >> a piece of cake in Scheme, but how would one do this in Haskell? Would the >> best approach be to use a State monad? >> >> Michael >> >> _______________________________________________ >> 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/20091021/96bb0e19/attachment.html From noteed at gmail.com Wed Oct 21 14:30:53 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 21 14:08:04 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> Message-ID: <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> 2009/10/21 Tim Wawrzynczak > > Here's an example in the IO monad: > > import Data.IORef > import System.IO.Unsafe > > counter = unsafePerformIO $ newIORef 0 > > next = do > modifyIORef counter (+1) > readIORef counter > > Naturally, this uses unsafePerformIO, which as you know, is not kosher... But you don't close around the Ref like in your schemy example. mkNext = do ref <- newIORef 0 return (do modifyIORef ref succ readIORef ref) mimic your other code better. Cheers, Thu From asandroq at gmail.com Wed Oct 21 14:31:45 2009 From: asandroq at gmail.com (Alex Queiroz) Date: Wed Oct 21 14:08:37 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> Message-ID: <54e12800910211131r2363918ak77abdeb428749c0d@mail.gmail.com> Hallo, On 10/21/09, Tim Wawrzynczak wrote: > Here's an example in the IO monad: > > import Data.IORef > import System.IO.Unsafe > > counter = unsafePerformIO $ newIORef 0 > > next = do > modifyIORef counter (+1) > readIORef counter > > Naturally, this uses unsafePerformIO, which as you know, is not kosher... > This is different because counter is global. Cheers, -- -alex http://www.ventonegro.org/ From bugfact at gmail.com Wed Oct 21 14:31:56 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Oct 21 14:08:56 2009 Subject: [Haskell-cafe] Test cases for type inference In-Reply-To: References: Message-ID: Thanks Job & Martijn for the feedback. I would like to write a type inferrer that is mostly Haskell 98 with Trex row polymorphism extensions (a bit like CAL I guess). That will certainly take a while because I'm also studying the theory in my spare time. So as soon as (or if) I have something working, I will need a larger set of tests. So Job, no need to do put any effort in preparing test sets, but I highly appreciate your offer. Cheers, Peter On Wed, Oct 21, 2009 at 4:47 PM, Job Vranish wrote: > I was recently working on an type inference algorithm and to test it I did > the following: > ? Used the quickcheck Arbitrary typeclass to generate expressions > ? Inferred types of the expressions using my algorithm, > ? converted the expressions that passed inference to haskell and wrote them > to a file (without type signatures) > ? converted and wrote the failed expression to a separate file > ? compiled the "passed" file with -Wall, and extracted all the type > signatures that were spit out as warnings > ? parsed the type signatures that -Wall spit out and compare with the > signatures generated by my algorithm. > ? compiled the "failed" file and make sure I get type errors for all my > expressions > > My algorithm also infers infinite types (which haskell does not) so I had to > test that functionality manually. > > Overall it was kinda messy, but it worked ok. > > I could possibly send you one of my lists. My test expressions are all very > simple, no type classes, only 2 types (function and number), and the only > expression components are let, lambda, apply, identifier, and number. If > something like that would work, let me know. > > Hope that helps, > > - Job > > > On Tue, Oct 20, 2009 at 10:07 AM, Peter Verswyvelen > wrote: >> >> For learning, I would like to develop my own implementation of type >> inference, based on the paper "Typing Haskell in Haskell". >> >> At first sight, the source code of THIH contains a small number of >> tests, but I was wandering if a large test set exist? >> >> Thanks, >> Peter >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From relapse.dev at gmx.com Wed Oct 21 14:34:00 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Wed Oct 21 14:11:20 2009 Subject: [Haskell-cafe] Re: Simple but interesting (for me) problem In-Reply-To: <354610.64099.qm@web31101.mail.mud.yahoo.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> Message-ID: michael rice wrote: > There's a thread on the plt-scheme list about creating a function of NO > arguments named NEXT that just returns the number of times it's been > called, a piece of cake in Scheme, but how would one do this in Haskell? > Would the best approach be to use a State monad? > > Michael > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe I think its more in the spirit of things things to have a function that produces an infinite list of values. From inforichland at gmail.com Wed Oct 21 14:40:37 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Wed Oct 21 14:17:28 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> Message-ID: <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> True...here we go then: import Data.IORef import System.IO.Unsafe mkNext :: (Num a) => IO (IO a) mkNext = do ref <- newIORef 0 return (do modifyIORef ref (+1) readIORef ref) next :: IO () next = do foo <- mkNext a <- sequence [foo,foo,foo] putStrLn $ show a running next will print [1,2,3] which is the result of calling 'foo' 3 times. But technically then, mkNext is just an IO action which returns an IO action ;) and not a function which will return the next value each time it is called, hence the need to extract the value from mkNext, then use it... Cheers, Tim On Wed, Oct 21, 2009 at 1:30 PM, minh thu wrote: > 2009/10/21 Tim Wawrzynczak > > > > Here's an example in the IO monad: > > > > import Data.IORef > > import System.IO.Unsafe > > > > counter = unsafePerformIO $ newIORef 0 > > > > next = do > > modifyIORef counter (+1) > > readIORef counter > > > > Naturally, this uses unsafePerformIO, which as you know, is not kosher... > > But you don't close around the Ref like in your schemy example. > > mkNext = do > ref <- newIORef 0 > return (do modifyIORef ref succ > readIORef ref) > > mimic your other code better. > > Cheers, > Thu > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/cadb0407/attachment.html From gcross at phys.washington.edu Wed Oct 21 15:08:16 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Wed Oct 21 14:45:08 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> Message-ID: <7FD338DB-F5E9-4CCD-B4A1-A60BE58FF990@phys.washington.edu> And just because this has not been explicitly stated: it's not just for aesthetic reasons that you couldn't do this with a pure function, but because it violates the semantics and gets you the wrong result. So for example, if you modified Tim's code to be import Data.IORef import System.IO.Unsafe mkNext :: (Num a) => IO a mkNext = do ref <- newIORef 0 return . unsafePerformIO $ do modifyIORef ref (+1) readIORef ref main :: IO () main = do foo <- mkNext print foo print foo print foo Then the output that you will see (with GHC at least) is 1 1 1 because the compiler assumes that it only needs to evaluate foo once, after which it can cache the result due to assumed referential transparency. - Greg On Oct 21, 2009, at 11:40 AM, Tim Wawrzynczak wrote: > True...here we go then: > > import Data.IORef > import System.IO.Unsafe > > mkNext :: (Num a) => IO (IO a) > mkNext = do > ref <- newIORef 0 > return (do modifyIORef ref (+1) > readIORef ref) > > next :: IO () > next = do > foo <- mkNext > a <- sequence [foo,foo,foo] > putStrLn $ show a > > > running next will print [1,2,3] which is the result of calling 'foo' > 3 times. > > But technically then, mkNext is just an IO action which returns an > IO action ;) > and not a function which will return the next value each time it is > called, > hence the need to extract the value from mkNext, then use it... > > Cheers, > Tim > > > On Wed, Oct 21, 2009 at 1:30 PM, minh thu wrote: > 2009/10/21 Tim Wawrzynczak > > > > Here's an example in the IO monad: > > > > import Data.IORef > > import System.IO.Unsafe > > > > counter = unsafePerformIO $ newIORef 0 > > > > next = do > > modifyIORef counter (+1) > > readIORef counter > > > > Naturally, this uses unsafePerformIO, which as you know, is not > kosher... > > But you don't close around the Ref like in your schemy example. > > mkNext = do > ref <- newIORef 0 > return (do modifyIORef ref succ > readIORef ref) > > mimic your other code better. > > Cheers, > Thu > > _______________________________________________ > 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/20091021/dac5efec/attachment.html From noteed at gmail.com Wed Oct 21 15:08:50 2009 From: noteed at gmail.com (minh thu) Date: Wed Oct 21 14:46:00 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> Message-ID: <40a414c20910211208kbc1c01du42ae5c2fe0ceedf5@mail.gmail.com> 2009/10/21 Tim Wawrzynczak : > True...here we go then: > > import Data.IORef > import System.IO.Unsafe > > mkNext :: (Num a) => IO (IO a) > mkNext = do > ref <- newIORef 0 > return (do modifyIORef ref (+1) > readIORef ref) > > next :: IO () > next = do > foo <- mkNext > a <- sequence [foo,foo,foo] > putStrLn $ show a > > > running next will print [1,2,3] which is the result of calling 'foo' 3 > times. > > But technically then, mkNext is just an IO action which returns an IO action > ;) > and not a function which will return the next value each time it is called, > hence the need to extract the value from mkNext, then use it... That why it is called mkNext: do next <- mkNext sequence [next, next, next] > > Cheers, > Tim > > > On Wed, Oct 21, 2009 at 1:30 PM, minh thu wrote: >> >> 2009/10/21 Tim Wawrzynczak >> > >> > Here's an example in the IO monad: >> > >> > import Data.IORef >> > import System.IO.Unsafe >> > >> > counter = unsafePerformIO $ newIORef 0 >> > >> > next = do >> > modifyIORef counter (+1) >> > readIORef counter >> > >> > Naturally, this uses unsafePerformIO, which as you know, is not >> > kosher... >> >> But you don't close around the Ref like in your schemy example. >> >> mkNext = do >> ref <- newIORef 0 >> return (do modifyIORef ref succ >> readIORef ref) >> >> mimic your other code better. >> >> Cheers, >> Thu > > From Eduard.Sergeev at gmail.com Wed Oct 21 15:25:47 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Wed Oct 21 15:02:38 2009 Subject: [Haskell-cafe] list -> sublists In-Reply-To: <25975341.post@talk.nabble.com> References: <25975341.post@talk.nabble.com> Message-ID: <25998649.post@talk.nabble.com> satorisanitarium wrote: > > How to make a list of sublists out of a list, whether they be a list of > numbers or a string. > Without recursion (with fold) starting from the tail of the input list: foo n = foldr st [[]] where st x xss | x == n = [x]:xss st x (xs:xss) = (x:xs):xss -- View this message in context: http://www.nabble.com/list--%3E-sublists-tp25975341p25998649.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From wss at cs.nott.ac.uk Wed Oct 21 15:44:15 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Wed Oct 21 15:21:06 2009 Subject: [Haskell-cafe] ANN: Data.Stream 0.4 Message-ID: I'm happy to announce a new release of the Data.Stream library. http://hackage.haskell.org/package/Stream The only change with the previous version has been to add irrefutable patterns to several function definitions. This is rather delicate design decision: too many irrefutable patterns could result in thunks not being evaluated; too few irrefutable patterns could cause your functions diverge. As a rule of thumb I've chosen only to use irrefutable patterns in functions that produce streams from streams. The operations that observe finite information (a prefix, the element at index i, etc.) do not have have irrefutable patterns and force evaluation to weak head normal form. I've uploaded a new version to Hackage. I'd be interested to hear if any existing code takes a performance hit as a result of these changes. Wouter From nowgate at yahoo.com Wed Oct 21 15:44:39 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 15:21:31 2009 Subject: [Haskell-cafe] Re: Simple but interesting (for me) problem In-Reply-To: Message-ID: <752333.2714.qm@web31103.mail.mud.yahoo.com> Thanks everyone, Hmm...I hadn't thought about it that way, but w/r/t Haskell you're absolutely right. People have said that Haskell is good to learn because it makes one think differently about programming, and they're right. Michael --- On Wed, 10/21/09, Neal Alexander wrote: From: Neal Alexander Subject: [Haskell-cafe] Re: Simple but interesting (for me) problem To: haskell-cafe@haskell.org Date: Wednesday, October 21, 2009, 2:34 PM michael rice wrote: > There's a thread on the plt-scheme list about creating a function of NO arguments named NEXT that just returns the number of times it's been called, a piece of cake in Scheme, but how would one do this in Haskell? Would the best approach be to use a State monad? > > Michael > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe I think its more in the spirit of things things to have a function that produces an infinite list of values. _______________________________________________ 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/20091021/332d11e6/attachment.html From lemming at henning-thielemann.de Wed Oct 21 16:57:48 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Oct 21 16:33:07 2009 Subject: [Haskell-cafe] How to use "bracket" properly ? In-Reply-To: <25953522.post@talk.nabble.com> References: <25953522.post@talk.nabble.com> Message-ID: <4ADF75CC.4030707@henning-thielemann.de> zaxis schrieb: > winSSQ count noRed noBlue = do { > yesRed <- [1..33] \\ noRed; > yesBlue <- [1..16] \\ noBlue; > bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1); > return () You might prefer 'withFile' or even better and if possible, write pickSSQ without IO interaction, just producing a String lazily and write this using writeFile. From tobias_bexelius at hotmail.com Wed Oct 21 17:07:51 2009 From: tobias_bexelius at hotmail.com (Tobias Bexelius) Date: Wed Oct 21 16:44:42 2009 Subject: [Haskell-cafe] ANN: GPipe 1.02 and Vec-Transform 1.0.1 Message-ID: I've uploaded new versions of these two packages to hackage: GPipe-1.0.2: * Removed rasterize and made rasterizeFront work for other primitives than triangles instead. * Fixed notB Vertex and Fragment instances Vec-Transform-1.0.1: * Added rotationLookAt Cheers Tobias Bexelius _________________________________________________________________ Windows Live: Dina v?nner f?r dina uppdateringar fr?n Flickr, Yelp och Digg n?r de skickar e-post till dig. http://www.microsoft.com/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:sv-se:SI_SB_3:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/889b5004/attachment.html From velman at cox.net Wed Oct 21 19:05:32 2009 From: velman at cox.net (John Velman) Date: Wed Oct 21 18:42:23 2009 Subject: [Haskell-cafe] Cabal says "no installed version of base" Message-ID: <20091021230532.GA1691@cox.net> I'm on OS X Leopard 10.5.8, using ghc 6.10.4 from Haskell Platform. I'm trying to get a static .a library, callable from C, that I can use in an OS X Cocoa program. I've tried a very simple case (the one in Haskell Wiki Tutorials,"calling haskell from C") I've managed to make a Mac Cocoa application by adding the ghc generated .o program, plus adding one by one the needed Haskell libraries for "symbol not found" to my Xcode project. There should be a better way. I've tried just about everything I could find on creating Haskell libraries, with no joy. My latest try is to use Cabal, following advice found both in "How to write a Haskell program" and the Cabal users guide. My output from cabal -v configure tells me, among others: --- Reading installed packages... /usr/bin/ghc-pkg dump --global /usr/bin/ghc-pkg dump --user Reading available packages... Resolving dependencies... There is no installed version of base --- But when I do ghc-pkg dump --global it appears base is listed. Apparently, "no installed version of base" short circuits the whole process. Any suggestions, pointers to reading, whatever will be appreciated. From nowgate at yahoo.com Wed Oct 21 20:43:47 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 20:20:38 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? Message-ID: <908937.11597.qm@web31104.mail.mud.yahoo.com> It looks like both the THEN and the ELSE in an IF expression must each have an expression. What's a graceful way to do nothing in either or both slots, kind of like the Fortran CONTINUE statement. ? --mr ================ [michael@localhost ~]$ ghci GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> if (1==1) then else :1:15: parse error on input `else' Prelude> if (1==1) then True else :1:24: parse error (possibly incorrect indentation) Prelude> if (1==1) then True else False True Prelude> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/2a2346c2/attachment.html From thomas.dubuisson at gmail.com Wed Oct 21 20:47:42 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Wed Oct 21 20:24:32 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? In-Reply-To: <908937.11597.qm@web31104.mail.mud.yahoo.com> References: <908937.11597.qm@web31104.mail.mud.yahoo.com> Message-ID: <4c44d90b0910211747q43e4a9ccnddc2e79a8728d5de@mail.gmail.com> If its monadic code then use Control.Monad.when. If its pure code then omitting the 'else' clause makes no sense what-so-ever; to omit the else you must know the boolean is always true so why have the if? See the "Common Misunderstandings" [1] page I put together in response to seeing one too many people trip over exactly this issue. Thomas [1] http://haskell.org/haskellwiki/Common_Misunderstandings On Wed, Oct 21, 2009 at 5:43 PM, michael rice wrote: > It looks like both the THEN and the ELSE in an IF expression must each have > an expression. What's a graceful way to do nothing in either or both slots, > kind of like the Fortran CONTINUE statement. > > --mr > > ================ > > [michael@localhost ~]$ ghci > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> if (1==1) then else > > :1:15: parse error on input `else' > Prelude> if (1==1) then True else > > :1:24: parse error (possibly incorrect indentation) > Prelude> if (1==1) then True else False > True > Prelude> > > > > _______________________________________________ > 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/20091021/4e55bce1/attachment.html From inforichland at gmail.com Wed Oct 21 20:49:14 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Wed Oct 21 20:26:03 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? In-Reply-To: <908937.11597.qm@web31104.mail.mud.yahoo.com> References: <908937.11597.qm@web31104.mail.mud.yahoo.com> Message-ID: <4335a3260910211749j21ebeeeg75e37384c225610a@mail.gmail.com> Yes, an if statement must have both 'then' and 'else' branches. As an example, what if you had let a = if b == 2 then True else False and you were missing an else branch? What would 'a' get assigned to? The if statement "returns" a value so must have both branches. However, in a monadic constraint, there are the functions 'when' and 'unless.' They allow conditional evaluation of expressions in a monadic context. For example, main = do line <- getLine when (line == "hello") putStrLn "Hello back!" Cheers, - Tim On Wed, Oct 21, 2009 at 7:43 PM, michael rice wrote: > It looks like both the THEN and the ELSE in an IF expression must each have > an expression. What's a graceful way to do nothing in either or both slots, > kind of like the Fortran CONTINUE statement. > > --mr > > ================ > > [michael@localhost ~]$ ghci > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> if (1==1) then else > > :1:15: parse error on input `else' > Prelude> if (1==1) then True else > > :1:24: parse error (possibly incorrect indentation) > Prelude> if (1==1) then True else False > True > Prelude> > > > > _______________________________________________ > 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/20091021/40a4560c/attachment.html From nowgate at yahoo.com Wed Oct 21 20:59:43 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 20:36:32 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? In-Reply-To: <4335a3260910211749j21ebeeeg75e37384c225610a@mail.gmail.com> Message-ID: <204590.36084.qm@web31103.mail.mud.yahoo.com> Thanks guys, I understand what you're telling me, but have some nested IFs and just want to fall through on one of the ELSES but then I end up with two ELSES in a row and nothing between them. Oh, well, on to restructuring. Michael --- On Wed, 10/21/09, Tim Wawrzynczak wrote: From: Tim Wawrzynczak Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Wednesday, October 21, 2009, 8:49 PM Yes, an if statement must have both 'then' and 'else' branches.? As an example, what if you had let a = if b == 2 then True else False and you were missing an else branch?? What would 'a' get assigned to? The if statement "returns" a value so must have both branches. However, in a monadic constraint, there are the functions 'when' and 'unless.'? They allow conditional evaluation of expressions in a monadic context.? For example, main = do ? line <- getLine ? when (line == "hello") putStrLn "Hello back!" Cheers, ?- Tim On Wed, Oct 21, 2009 at 7:43 PM, michael rice wrote: It looks like both the THEN and the ELSE in an IF expression must each have an expression. What's a graceful way to do nothing in either or both slots, kind of like the Fortran CONTINUE statement. ? --mr ================ [michael@localhost ~]$ ghci GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> if (1==1) then else :1:15: parse error on input `else' Prelude> if (1==1) then True else :1:24: parse error (possibly incorrect indentation) Prelude> if (1==1) then True else False True Prelude> _______________________________________________ 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/20091021/2fa60d07/attachment.html From westondan at imageworks.com Wed Oct 21 21:16:39 2009 From: westondan at imageworks.com (Dan Weston) Date: Wed Oct 21 20:53:33 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? In-Reply-To: <204590.36084.qm@web31103.mail.mud.yahoo.com> References: <204590.36084.qm@web31103.mail.mud.yahoo.com> Message-ID: <4ADFB277.5040503@imageworks.com> If you have a long if/else if/else chain, you might consider a trivial case statement with guards. Whether you think this is attractive is a matter of taste, but it has the fall-through semantics you want and ghc optimizes the _ pattern matching away: f x = case () of _| x == 2 -> 22 _| x == 4 -> 44 _| x == 7 -> 77 _| otherwise -> 55 > f 4 44 > f 9 55 michael rice wrote: > Thanks guys, > > I understand what you're telling me, but have some nested IFs and just > want to fall through on one of the ELSES but then I end up with two > ELSES in a row and nothing between them. Oh, well, on to restructuring. > > Michael > > --- On *Wed, 10/21/09, Tim Wawrzynczak //* wrote: > > > From: Tim Wawrzynczak > Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Wednesday, October 21, 2009, 8:49 PM > > Yes, an if statement must have both 'then' and 'else' branches. As > an example, what if you had > > let a = if b == 2 then True else False > > and you were missing an else branch? What would 'a' get assigned to? > > The if statement "returns" a value so must have both branches. > > However, in a monadic constraint, there are the functions 'when' and > 'unless.' They allow conditional evaluation of expressions in a > monadic context. For example, > > main = do > line <- getLine > when (line == "hello") putStrLn "Hello back!" > > Cheers, > - Tim > > > On Wed, Oct 21, 2009 at 7:43 PM, michael rice > wrote: > > It looks like both the THEN and the ELSE in an IF expression > must each have an expression. What's a graceful way to do > nothing in either or both slots, kind of like the Fortran > CONTINUE statement. > > --mr > > ================ > > [michael@localhost ~]$ ghci > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> if (1==1) then else > > :1:15: parse error on input `else' > Prelude> if (1==1) then True else > > :1:24: parse error (possibly incorrect indentation) > Prelude> if (1==1) then True else False > True > Prelude> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From nowgate at yahoo.com Wed Oct 21 21:27:56 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 21:04:47 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? In-Reply-To: <4ADFB277.5040503@imageworks.com> Message-ID: <476925.52313.qm@web31107.mail.mud.yahoo.com> Those nested IF/THEN/ELSEs are real killers. I kind of use them to sort out my thoughts, then end up with a nested mess. The restructuring to WHENs went smoothly and looks a lot cleaner besides. Michael --- On Wed, 10/21/09, Dan Weston wrote: From: Dan Weston Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? To: "michael rice" Cc: "Tim Wawrzynczak" , "haskell-cafe@haskell.org" Date: Wednesday, October 21, 2009, 9:16 PM If you have a long if/else if/else chain, you might consider a trivial case statement with guards. Whether you think this is attractive is a matter of taste, but it has the fall-through semantics you want and ghc optimizes the _ pattern matching away: f x = case () of ? _| x == 2? ? -> 22 ? _| x == 4? ? -> 44 ? _| x == 7? ? -> 77 ? _| otherwise -> 55 > f 4 44 > f 9 55 michael rice wrote: > Thanks guys, > > I understand what you're telling me, but have some nested IFs and just want to fall through on one of the ELSES but then I end up with two ELSES in a row and nothing between them. Oh, well, on to restructuring. > > Michael > > --- On *Wed, 10/21/09, Tim Wawrzynczak //* wrote: > > >? ???From: Tim Wawrzynczak >? ???Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? >? ???To: "michael rice" >? ???Cc: haskell-cafe@haskell.org >? ???Date: Wednesday, October 21, 2009, 8:49 PM > >? ???Yes, an if statement must have both 'then' and 'else' branches.? As >? ???an example, what if you had > >? ???let a = if b == 2 then True else False > >? ???and you were missing an else branch?? What would 'a' get assigned to? > >? ???The if statement "returns" a value so must have both branches. > >? ???However, in a monadic constraint, there are the functions 'when' and >? ???'unless.'? They allow conditional evaluation of expressions in a >? ???monadic context.? For example, > >? ???main = do >? ? ???line <- getLine >? ? ???when (line == "hello") putStrLn "Hello back!" > >? ???Cheers, >? ? ? - Tim > > >? ???On Wed, Oct 21, 2009 at 7:43 PM, michael rice ? ???> wrote: > >? ? ? ???It looks like both the THEN and the ELSE in an IF expression >? ? ? ???must each have an expression. What's a graceful way to do >? ? ? ???nothing in either or both slots, kind of like the Fortran >? ? ? ???CONTINUE statement. > >? ? ? ? ???--mr > >? ? ? ???================ > >? ? ? ???[michael@localhost ~]$ ghci >? ? ? ???GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help >? ? ? ???Loading package ghc-prim ... linking ... done. >? ? ? ???Loading package integer ... linking ... done. >? ? ? ???Loading package base ... linking ... done. >? ? ? ???Prelude> if (1==1) then else > >? ? ? ???:1:15: parse error on input `else' >? ? ? ???Prelude> if (1==1) then True else > >? ? ? ???:1:24: parse error (possibly incorrect indentation) >? ? ? ???Prelude> if (1==1) then True else False >? ? ? ???True >? ? ? ???Prelude> > > > >? ? ? ???_______________________________________________ >? ? ? ???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/20091021/47ef7cbd/attachment.html From nowgate at yahoo.com Wed Oct 21 22:15:56 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 21:52:46 2009 Subject: [Haskell-cafe] Needing strictness? Message-ID: <990850.72462.qm@web31107.mail.mud.yahoo.com> Busy night. I wanted the question and response to be on the same line (see below), so I used putStr instead of putStrLn, but Haskell jumps the gun and goes to the second line to get the response before the question ever gets printed. Is this an example of needing strictness? How would I do that, or something else, to get the result I want? ???????? putStrLn "Some yes/no question (y/n)?" ???????? ans <- getLine Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/4362f3ba/attachment.html From johan.tibell at gmail.com Wed Oct 21 22:18:51 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed Oct 21 21:55:59 2009 Subject: [Haskell-cafe] Needing strictness? In-Reply-To: <990850.72462.qm@web31107.mail.mud.yahoo.com> References: <990850.72462.qm@web31107.mail.mud.yahoo.com> Message-ID: <90889fe70910211918l70495a6dq92464b180467d4b4@mail.gmail.com> Hi Michael, I believe stdout uses line buffering by default so you need to explicitly flush the buffer to get the output -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/135908be/attachment.html From nowgate at yahoo.com Wed Oct 21 22:28:24 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 22:05:14 2009 Subject: [Haskell-cafe] Needing strictness? In-Reply-To: <90889fe70910211918l70495a6dq92464b180467d4b4@mail.gmail.com> Message-ID: <519214.10243.qm@web31106.mail.mud.yahoo.com> Hey Johan, And I can do that how? Michael --- On Wed, 10/21/09, Johan Tibell wrote: From: Johan Tibell Subject: Re: [Haskell-cafe] Needing strictness? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Wednesday, October 21, 2009, 10:18 PM Hi Michael, I believe stdout uses line buffering by default so you need to explicitly flush the buffer to get the output -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/572fcb53/attachment.html From daniel.is.fischer at web.de Wed Oct 21 22:25:51 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 21 22:05:28 2009 Subject: [Haskell-cafe] Needing strictness? In-Reply-To: <990850.72462.qm@web31107.mail.mud.yahoo.com> References: <990850.72462.qm@web31107.mail.mud.yahoo.com> Message-ID: <200910220425.51612.daniel.is.fischer@web.de> Am Donnerstag 22 Oktober 2009 04:15:56 schrieb michael rice: > Busy night. I wanted the question and response to be on the same line (see > below), so I used putStr instead of putStrLn, but Haskell jumps the gun and > goes to the second line to get the response before the question ever gets > printed. Is this an example of needing strictness? How would I do that, or > something else, to get the result I want? > > ???????? putStrLn "Some yes/no question (y/n)?" > ???????? ans <- getLine > > Michael It's a buffering issue. For compiled code, stdout is by default set to line buffering (it's different for interpreted code, at least on linux). import System.IO do hSetBuffering stdout NoBuffering putStr "Question" ans <- getLine should do what you want. From daniel.is.fischer at web.de Wed Oct 21 22:27:05 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 21 22:05:32 2009 Subject: [Haskell-cafe] Needing strictness? In-Reply-To: <990850.72462.qm@web31107.mail.mud.yahoo.com> References: <990850.72462.qm@web31107.mail.mud.yahoo.com> Message-ID: <200910220427.05777.daniel.is.fischer@web.de> Am Donnerstag 22 Oktober 2009 04:15:56 schrieb michael rice: > Busy night. I wanted the question and response to be on the same line (see > below), so I used putStr instead of putStrLn, but Haskell jumps the gun and > goes to the second line to get the response before the question ever gets > printed. Is this an example of needing strictness? How would I do that, or > something else, to get the result I want? > > ???????? putStrLn "Some yes/no question (y/n)?" > ???????? ans <- getLine > > Michael Hit send too quickly: alternatively hFlush stdout between question and answer. From nowgate at yahoo.com Wed Oct 21 22:49:07 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Oct 21 22:25:56 2009 Subject: [Haskell-cafe] Needing strictness? In-Reply-To: <200910220427.05777.daniel.is.fischer@web.de> Message-ID: <650322.64256.qm@web31104.mail.mud.yahoo.com> Hi Daniel, The first fix wouldn't work, but the second one (hFlush) did. Thanks, Michael --- On Wed, 10/21/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Needing strictness? To: haskell-cafe@haskell.org Cc: "michael rice" Date: Wednesday, October 21, 2009, 10:27 PM Am Donnerstag 22 Oktober 2009 04:15:56 schrieb michael rice: > Busy night. I wanted the question and response to be on the same line (see > below), so I used putStr instead of putStrLn, but Haskell jumps the gun and > goes to the second line to get the response before the question ever gets > printed. Is this an example of needing strictness? How would I do that, or > something else, to get the result I want? > > ???????? putStrLn "Some yes/no question (y/n)?" > ???????? ans <- getLine > > Michael Hit send too quickly: alternatively hFlush stdout between question and answer. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091021/7fdd4c69/attachment.html From tphyahoo at gmail.com Wed Oct 21 23:31:16 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Oct 21 23:08:07 2009 Subject: [Haskell-cafe] Re: ghci can't find Paths_ module created by cabal In-Reply-To: References: Message-ID: <910ddf450910212031s4d45af09u1fe0830654eb7fef@mail.gmail.com> from my bash hints file: thartman@ubuntu:~/haskellInstalls/gitit>thartman_ghci_with_data_files Loading a package with data files in ghci See http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html Snip: The above method works well after a program has been installed, but is harder to work with while developing a program. To alleviate these problems, we can add our own Paths module to the program, for example: module Paths_hoogle where getDataFileName :: FilePath -> IO FilePath getDataFileName = return Place this module alongside all the other modules. While developing the program our hand-created Paths module will be invoked, which says the data is always in the current directory. When doing a Cabal build, Cabal will choose its custom generated Paths module over ours, and we get the benefits of Cabal managing our data. 2009/10/21 Robin Green : > I'm trying to run cabal-install in ghci so I can run it under the ghci > debugger. However I try it, though, I always get one of these two > errors: > > /src/greenrd/darcs/cabal-install/Main.hs:70:17: > ? ?Could not find module `Paths_cabal_install': > ? ? ?Use -v to see a list of the files searched for. > Failed, modules loaded: none. > > or > > : > ? ?Could not find module `Main': > ? ? ?Use -v to see a list of the files searched for. > > -- > Robin > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://www.haskell.org/mailman/listinfo/libraries > From tomahawkins at gmail.com Wed Oct 21 23:42:50 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Wed Oct 21 23:19:42 2009 Subject: [Haskell-cafe] ANN: mecha-0.0.0 Message-ID: <594c1e830910212042q33bda84brf96d674ad5327fc9@mail.gmail.com> A few months ago, I started toying with a few alternative pump designs to power our hydraulic hybrids. After not being able to secure a ProE license, I searched for a free solid modeler to sketch out a few ideas. To my surprise, their are practically no open source 3D CAD packages available. So I created Mecha, DSL for constructive solid modeling. Mecha's geometry is based on octrees, which makes it easy to perform set operations on solids, as well as volumetric calculations such as center-of-mass, moments of inertia, and of course, total volume. Drawbacks of octrees include consuming a lot of memory and the loss of some surface information. To address the later, Mecha carries forward surface points and normals to the leaf nodes of the octree to assist in rendering, such that solids don't look like they're made from a bunch of LEGOS. Note this is a very early release. The only thing Mecha can do at the moment is draw a pretty blue ball -- well it can also zoom and pan on a pretty blue ball (mouse wheel). Establishing a primitive API and building a primitive library must be finished before Mecha an do anything useful. Any comments and suggestions are welcome. http://tomahawkins.org/ From z_axis at 163.com Thu Oct 22 01:02:21 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 00:39:09 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? Message-ID: <26004111.post@talk.nabble.com> > let aaa = unsafePerformIO $ newIORef [] > writeIORef aaa [1,2,3] > readIORef aaa [(),(),()] sincerely! -- View this message in context: http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004111.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From orclev at gmail.com Thu Oct 22 01:19:22 2009 From: orclev at gmail.com (Kyle Murphy) Date: Thu Oct 22 00:56:12 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <26004111.post@talk.nabble.com> References: <26004111.post@talk.nabble.com> Message-ID: <2db78cee0910212219v7239c9c8k5cf136d0ab44e990@mail.gmail.com> I assume you're trying this at the GHCi prompt, which is where you're problem is coming from, specifically on the first line. When you do: > let aaa = unsafePerformIO $ newIORef [] GHCi takes a wild stab at the type of [] and comes up with the type [()], so now you have a IORef [()] type, which is why when you try to store [1,2,3] in the IORef you get back [(),(),()]. Try this instead and it should work: > let aaa = unsafePerformIO $ newIORef ([] :: [Int]) -R. Kyle Murphy -- Curiosity was framed, Ignorance killed the cat. On Thu, Oct 22, 2009 at 01:02, zaxis wrote: > > > let aaa = unsafePerformIO $ newIORef [] > > writeIORef aaa [1,2,3] > > readIORef aaa > [(),(),()] > > sincerely! > -- > View this message in context: > http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004111.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091022/03c82082/attachment.html From mpm at alumni.caltech.edu Thu Oct 22 01:21:12 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Oct 22 00:58:07 2009 Subject: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10 In-Reply-To: <3e1162e60910210932t1247bc31lbcef76567bceda44@mail.gmail.com> References: <4ADED491.2030806@alumni.caltech.edu> <1256140519-sup-4449@vaelastrasz> <3e1162e60910210932t1247bc31lbcef76567bceda44@mail.gmail.com> Message-ID: <4ADFEBC8.2080707@alumni.caltech.edu> Apparently the old exception library had convenience functions like 'arithExceptions' that could be used with 'handleJust'. handleJust arithExceptions handler thing With the new module you can write something like this (I determined this from experimentation): arithExceptionTester :: ArithException -> IO () arithExceptionTester = Just () handleJust arithExceptionTester handler thing Two questions: (1) Is there a better way to do things? (2) I don't understand quite how the type system works. Somehow, on exceptions that aren't arithmetic, arithExceptionTester returns Nothing or at least behaves that way. Yet I didn't write any code to do that. Can someone explain this? Thanks, Mike From thomas.dubuisson at gmail.com Thu Oct 22 01:25:27 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Oct 22 01:02:16 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <26004111.post@talk.nabble.com> References: <26004111.post@talk.nabble.com> Message-ID: <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> zaxis wrote: >> let aaa = unsafePerformIO $ newIORef [] >> writeIORef aaa [1,2,3] >> readIORef aaa > [(),(),()] What in Haskells name do you think you're doing? Don't use unsafePerformIO like that! Its unnecessary and a bit concerning, really. Prelude> :m Data.IORef Prelude Data.IORef> x <- newIORef [] :: IO (IORef [Int]) Prelude Data.IORef> writeIORef x [1,2,3] Prelude Data.IORef> readIORef x [1,2,3] > > sincerely! > -- > View this message in context: http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004111.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From z_axis at 163.com Thu Oct 22 01:26:45 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 01:03:34 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <2db78cee0910212219v7239c9c8k5cf136d0ab44e990@mail.gmail.com> References: <26004111.post@talk.nabble.com> <2db78cee0910212219v7239c9c8k5cf136d0ab44e990@mail.gmail.com> Message-ID: <26004260.post@talk.nabble.com> Yes, it works now! thank you very much! Kyle Murphy-2 wrote: > > I assume you're trying this at the GHCi prompt, which is where you're > problem is coming from, specifically on the first line. > When you do: >> let aaa = unsafePerformIO $ newIORef [] > GHCi takes a wild stab at the type of [] and comes up with the type [()], > so > now you have a IORef [()] type, which is why when you try > to store [1,2,3] in the IORef you get back [(),(),()]. Try this instead > and > it should work: >> let aaa = unsafePerformIO $ newIORef ([] :: [Int]) > > -R. Kyle Murphy > -- > Curiosity was framed, Ignorance killed the cat. > > > On Thu, Oct 22, 2009 at 01:02, zaxis wrote: > >> >> > let aaa = unsafePerformIO $ newIORef [] >> > writeIORef aaa [1,2,3] >> > readIORef aaa >> [(),(),()] >> >> sincerely! >> -- >> View this message in context: >> http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004111.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004260.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From z_axis at 163.com Thu Oct 22 01:37:36 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 01:14:26 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> Message-ID: <26004340.post@talk.nabble.com> thank you! In fact i really donot understand "unsafePerformIO" very much ! Thomas DuBuisson wrote: > > zaxis wrote: >>> let aaa = unsafePerformIO $ newIORef [] >>> writeIORef aaa [1,2,3] >>> readIORef aaa >> [(),(),()] > > What in Haskells name do you think you're doing? Don't use > unsafePerformIO like that! Its unnecessary and a bit concerning, > really. > > Prelude> :m Data.IORef > Prelude Data.IORef> x <- newIORef [] :: IO (IORef [Int]) > Prelude Data.IORef> writeIORef x [1,2,3] > Prelude Data.IORef> readIORef x > [1,2,3] > > >> >> sincerely! >> -- >> View this message in context: >> http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004111.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/why-cannot-i-get-the-value-of-a-IORef-variable---tp26004111p26004340.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From colin at colina.demon.co.uk Thu Oct 22 01:50:07 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Oct 22 01:26:58 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <26004340.post@talk.nabble.com> (zaxis's message of "Wed\, 21 Oct 2009 22\:37\:36 -0700 \(PDT\)") References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> Message-ID: zaxis> thank you! In fact i really donot understand zaxis> "unsafePerformIO" very much ! Then all you have to understand is - never use it! -- Colin Adams Preston Lancashire From gcross at phys.washington.edu Thu Oct 22 02:23:44 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Oct 22 02:00:50 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> Message-ID: <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> For clarity, one trick that uses "unsafePerformIO" which you may have seen posted on this list earlier today is the following way of creating a globally visible IORef: import Data.IORef import System.IO.Unsafe *** counter = unsafePerformIO $ newIORef 0 *** next = do modifyIORef counter (+1) readIORef counter The key line has been starred; this created a counter IORef that "next" could access without having to be explicitly given it on each call. Personally, though, I never use this approach because it creates a race condition. Because Haskell is lazy, "counter" will not be evaluated until the first time that it is accessed. If two threads access it at the same time before it has been evaluated, then in GHC there are conditions under which they could both evaluate it and create a new IORef simultaneously, resulting in each thread effectively ending up with its own counter variable when you specifically wanted a globally shared counter variable. This is why I personally use the ReaderT monad if I want to implicitly share a global IORef, rather than using this trick. Cheers, Greg On Oct 21, 2009, at 10:50 PM, Colin Paul Adams wrote: > > zaxis> thank you! In fact i really donot understand > zaxis> "unsafePerformIO" very much ! > > Then all you have to understand is - never use it! > -- > Colin Adams > Preston Lancashire > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From warrensomebody at gmail.com Thu Oct 22 02:36:31 2009 From: warrensomebody at gmail.com (Warren Harris) Date: Thu Oct 22 02:13:29 2009 Subject: [Haskell-cafe] Time Typeable Instances In-Reply-To: <4AD48524.1080209@complete.org> References: <4AD3DD3C.7050703@complete.org> <4AD48524.1080209@complete.org> Message-ID: Hi John, I just stumbled on this issue while trying to compile turbinado with the haskell platform / ghc 6.10.4. I got past it by manually editing back in the time definitions, but just wondering if there was an official resolution. Thanks, Warren On Oct 13, 2009, at 6:48 AM, John Goerzen wrote: > Hugo Gomes wrote: >> The Glorious Glasgow Haskell Compilation System, version 6.10.4 >> with old-time-1.0.0.2 and time-1.1.2.4 >> >> This is a standard haskell platform on a windows xp. Cabal install >> didn't work complaining about missing instances of typeable for posix >> time and other datatypes, yet, after removing the macros (thus, >> adding >> those instances), hdbc and convertible compiled and installed fine. >> >> Removing the macros might be a bit overkill, probably finetuning >> them so >> that they add only the necessary instances for typeable in ghc > 610 >> might be a better solution. > > I'm going to CC haskell-cafe on this because I am confused. > > Hugo, can you confirm what version of convertible you have? > > Back on May 21, I started a thread [1] on haskell-cafe complaining > that > GHC 6.10.3 included a newer time that included instances of Typeable > for > NominalDiffTime and UTCTime. This broke my code, which had manually > defined instances for these types, as they were needed. Things got > complicated, as only time's minor version number got incremented > (x.x.x.Y) [2]. Cabal can't test against that version number. > > I wanted my code to work with old and new versions of GHC. Since > testing against the version of time was impossible, I did the next > best > thing: tested against the version of GHC. > > #if __GLASGOW_HASKELL__ >= 610 > -- instances added in GHC 6.10.3 > #else > instance Typeable NominalDiffTime where > typeOf _ = mkTypeName "NominalDiffTime" > > instance Typeable UTCTime where > typeOf _ = mkTypeName "UTCTime" > #endif > > Also, in the .cabal, there is a build-depends on time>=1.1.2.4. > > Now, that would break for GHC 6.10.1 and 6.10.2 users, but will work > for > 6.10.3 and above, or 6.8 and below. Or so I thought. > > Now I'm getting complaints from people using 6.10.4 saying that there > are now missing instances of Typeable with time 1.1.2.4. > > 1) Did the Typeable instances get dropped again from time? > 2) What exactly should I do so this library compiles on GHC 6.8 and > 6.10.x? > > I'm looking at the darcs repo for time and don't see the instances > ever > getting dropped. > > [1] http://osdir.com/ml/haskell-cafe@haskell.org/2009-05/msg00982.html > [2] http://osdir.com/ml/haskell-cafe@haskell.org/2009-05/msg00985.html > > > .... later addendum .... > > so it appears that what's happening here is that GHC 6.10.3 extralibs > included time 1.1.3, but then haskell-platform standardized on > 1.1.2.4. > This is pretty annoying -- that haskell-platform would standardize > on a > version older than what shipped with a GHC release -- but I guess I > can > work around it by restricting my build-dep to be time < 1.1.3 and > re-adding the instances. > > Does this sound right? > >> >> >> On Tue, Oct 13, 2009 at 2:51 AM, John Goerzen > > wrote: >> >> Hugo Gomes wrote: >>> Hi, >>> >>> convertible and hdbc packages fail to compile in my standard >> instalation >>> of the haskell platform. I think this has to do with those "if ghc >>> >= >>> 610" macros on the typeable instances for some datatypes. I >> removed them >>> and now they work fine... >>> >>> >>> >> >> >> What version of GHC and time do you have? >> >> -- John >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bulat.ziganshin at gmail.com Thu Oct 22 03:10:34 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 22 02:47:32 2009 Subject: [Haskell-cafe] Is there a null statement that does nothing? In-Reply-To: <204590.36084.qm@web31103.mail.mud.yahoo.com> References: <4335a3260910211749j21ebeeeg75e37384c225610a@mail.gmail.com> <204590.36084.qm@web31103.mail.mud.yahoo.com> Message-ID: <43367487.20091022111034@gmail.com> Hello michael, Thursday, October 22, 2009, 4:59:43 AM, you wrote: "return ()" does the trick if another branch also returns () > Thanks guys, > I understand what you're telling me, but have some nested IFs and > just want to fall through on one of the ELSES but then I end up with > two ELSES in a row and nothing between them. Oh, well, on to restructuring. > Michael > --- On Wed, 10/21/09, Tim Wawrzynczak wrote: > From: Tim Wawrzynczak > Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Wednesday, October 21, 2009, 8:49 PM > Yes, an if statement must have both 'then' and 'else' branches.? As an example, what if you had > let a = if b == 2 then True else False > and you were missing an else branch?? What would 'a' get assigned to? > > The if statement "returns" a value so must have both branches. > However, in a monadic constraint, there are the functions 'when' > and 'unless.'? They allow conditional evaluation of expressions in a monadic context.? For example, > > main = do > ? line <- getLine > ? when (line == "hello") putStrLn "Hello back!" > Cheers, > ?- Tim > On Wed, Oct 21, 2009 at 7:43 PM, michael rice wrote: > > It looks like both the THEN and the ELSE in an IF expression must > each have an expression. What's a graceful way to do nothing in > either or both slots, kind of like the Fortran CONTINUE statement. > ? --mr > ================ > [michael@localhost ~]$ ghci > GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. Prelude>> if (1==1) then else > :1:15: parse error on input `else' Prelude>> if (1==1) then True else > > :1:24: parse error (possibly incorrect indentation) Prelude>> if (1==1) then True else False > True Prelude>> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From z_axis at 163.com Thu Oct 22 03:28:14 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 03:05:03 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? Message-ID: <26005244.post@talk.nabble.com> aaa <- newIORef ([]::[(Int,Int)]) writeIORef aaa [(1,1),(2,2),(3,3)] then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best way ? re-write aaa is not permitted. Sincerely! -- View this message in context: http://www.nabble.com/How-can-i-safely-change-the-value-of-specified-key---tp26005244p26005244.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From noteed at gmail.com Thu Oct 22 03:37:00 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 22 03:14:09 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26005244.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> Message-ID: <40a414c20910220037u31f225e8r67fa36901f506fab@mail.gmail.com> 2009/10/22 zaxis : > > aaa <- newIORef ([]::[(Int,Int)]) > writeIORef aaa [(1,1),(2,2),(3,3)] > > then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best way > ? > re-write aaa is not permitted. Why do you say that ? You can use again writeIORef of modifyIORef to change aaa's content. Cheers, Thu From bulat.ziganshin at gmail.com Thu Oct 22 03:40:07 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 22 03:17:05 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26005244.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> Message-ID: <63387067.20091022114007@gmail.com> Hello zaxis, Thursday, October 22, 2009, 11:28:14 AM, you wrote: > aaa <- newIORef ([]::[(Int,Int)]) > writeIORef aaa [(1,1),(2,2),(3,3)] > then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best way > ? > re-write aaa is not permitted. it's the only way. in Haskell, you have *immutable* values. aaa is a reference to immutable value. you can mutate reference so it will point to another immutable value but you cannot change this value. there are two ways to make aaa==[(1,1),(2,222),(3,3)]. first, you can apply function to whole value: value <- readIORef aaa writeIORef aaa (f value) second, you may create list of IORefs, tuple of IORefs and so: a <- newIORef (1,1) ... let aaa = [a,b,c] now aaa is a immutable list of mutable IORefs. of course, you can create IORef pointing to list of IORefs too -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From martijn at van.steenbergen.nl Thu Oct 22 03:47:32 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Oct 22 03:24:26 2009 Subject: [Haskell-cafe] What's this pattern called? Message-ID: <4AE00E14.7080600@van.steenbergen.nl> Bonjour caf?, > data ExprF r > = Add r r > | Sub r r > | Mul r r > | Div r r > | Num Int This is a well-known pattern that for example allows nice notation of morphisms. But what is it called? I've heard fixed-point view, open datatypes and some others, but I'm curious where this pattern comes up in literature and what it is called there. Thanks, Martijn. From noteed at gmail.com Thu Oct 22 03:48:24 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 22 03:25:32 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <7FD338DB-F5E9-4CCD-B4A1-A60BE58FF990@phys.washington.edu> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> <7FD338DB-F5E9-4CCD-B4A1-A60BE58FF990@phys.washington.edu> Message-ID: <40a414c20910220048x32767b6ei80590cf6407c35a9@mail.gmail.com> 2009/10/21 Gregory Crosswhite : > And just because this has not been explicitly stated: it's not just for > aesthetic reasons that you couldn't do this with a pure function, but > because it violates the semantics and gets you the wrong result. So for > example, if you modified Tim's code to be > > import Data.IORef > import System.IO.Unsafe > mkNext :: (Num a) => IO a > mkNext = do > ref <- newIORef 0 > return . unsafePerformIO $ > do > modifyIORef ref (+1) > readIORef ref > main :: IO () > main = do > foo <- mkNext > print foo > print foo > print foo > > Then the output that you will see (with GHC at least) is > 1 > 1 > 1 > because the compiler assumes that it only needs to evaluate foo once, after > which it can cache the result due to assumed referential transparency. > - Greg This is indeed wrong, but not how you think it is. The code you pass to unsafePerformIO has type Num a => IO a, so the value passed to return has type Num a. So foo has type Num a too and its value is 1. Exactly like in mkNext = do ref <- newIORef 0 modifyIORef ref (+1) readIORef ref which is a complicated way to write mkNext = return 1 Now, it's clear that foo has value 1 and printing it three times should output three 1. The whole point of having mkNext return an action (that should be called next, and not foo, as it is much clearer) in previous code was too be able to execute it multiple times and having it return a new value. In general, expecting print bar print bar print bar outputing three different things is wrong, as bar should be pure. If bar is not pure, then it should be a <- bar print a b <- bar print b c <- bar print c Cheers, Thu From bulat.ziganshin at gmail.com Thu Oct 22 03:41:38 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 22 03:27:13 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26005244.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> Message-ID: <710558061.20091022114138@gmail.com> Hello zaxis, Thursday, October 22, 2009, 11:28:14 AM, you wrote: > then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best way ... well, anyway what you are doing isn't very haskellish. it may be considered as advanced topic but basically, best way to compute something in Haskell is to construct pure function -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From sebf at informatik.uni-kiel.de Thu Oct 22 04:07:26 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Oct 22 03:44:15 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <4AE00E14.7080600@van.steenbergen.nl> References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: Hi Martijn, On Oct 22, 2009, at 9:47 AM, Martijn van Steenbergen wrote: > I've heard fixed-point view, open datatypes and some others, but I'm > curious where this pattern comes up in literature and what it is > called there. Tim Sheard and Emir Pasalic call this technique "two-level types" in their JFP'04 paper Two-Level Types and Parameterized Modules: http://homepage.mac.com/pasalic/p2/papers/JfpPearl.pdf Cheers, Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From leather at cs.uu.nl Thu Oct 22 04:24:53 2009 From: leather at cs.uu.nl (Sean Leather) Date: Thu Oct 22 04:02:01 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: <3c6288ab0910220124t3c5344feq60a3e7298bb052a4@mail.gmail.com> > I've heard fixed-point view, open datatypes and some others, but I'm >> curious where this pattern comes up in literature and what it is called >> there. >> > > Tim Sheard and Emir Pasalic call this technique "two-level types" in their > JFP'04 paper Two-Level Types and Parameterized Modules: > > http://homepage.mac.com/pasalic/p2/papers/JfpPearl.pdf > Apparently from reading Section 2 of that paper, they would call ExprF non-recursive type the structure operator. I think, by itself, the type ExprF doesn't mean much. It really matters how it's used to determine what you call it. Martijn already mentioned the fixed-point view, but that only makes since in the context of something like Fix: > data ExprF r = Add r r | Sub r r | Mul r r | Div r r | Num Int > newtype Fix f = In (f (Fix f)) > type Expr = Fix ExprF I believe the F suffix that Martijn used typically means functor, and I sometimes call types like this functors (with an optional but obvious instance of Functor). Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091022/9a3fc25d/attachment.html From wb at sao.pl Thu Oct 22 04:42:37 2009 From: wb at sao.pl (Waldemar Biernacki) Date: Thu Oct 22 04:19:28 2009 Subject: [Haskell-cafe] Is there in Haskell the eval function? Message-ID: <200910221042.37259.wb@sao.pl> Hello! I have a very stupid question. Sorry for that! Is there the eval function like in imperative languages? I'd like to write an application which has to be compiled to exec file. It is neccessary to performe some additional procedures which are unknown at the moment of the compilition. Regards wb. From martijn at van.steenbergen.nl Thu Oct 22 04:45:45 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Oct 22 04:22:39 2009 Subject: [Haskell-cafe] Is there in Haskell the eval function? In-Reply-To: <200910221042.37259.wb@sao.pl> References: <200910221042.37259.wb@sao.pl> Message-ID: <4AE01BB9.704@van.steenbergen.nl> Waldemar Biernacki wrote: > Is there the eval function like in imperative languages? You mean like in interpreted languages? > I'd like to write an application which has to be compiled to exec file. It is neccessary to performe some additional procedures which are unknown at the moment of the compilition. You could use the GHC libraries, or Hint which is built on top of GHC. I've used it before and it works pretty nicely. http://hackage.haskell.org/package/hint HTH, Martijn. From magicloud.magiclouds at gmail.com Thu Oct 22 04:53:34 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Oct 22 04:30:22 2009 Subject: [Haskell-cafe] NetSnmp problem. Message-ID: <3bd412d40910220153p7ee547f6q530ec7e0fbc353e0@mail.gmail.com> Hi, I am trying to use NetSnmp to get some information from my switch. And I met this problem. After initialize, I used snmpWalk to get some information, and dealed with it. Everything is fine. Then I sleep for 5 mins. SnmpWalk again. But this time, all asnValues were unsupported format, which broke my dealing process. Why? I am sure my switch and OID, bluh bluh bluh are correct. They worked in ruby script. -- ??????? ??????? From z_axis at 163.com Thu Oct 22 05:03:21 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 04:40:10 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <63387067.20091022114007@gmail.com> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> Message-ID: <26006471.post@talk.nabble.com> >>value <- readIORef aaa >>writeIORef aaa (f value) then aaa will *point to* a new value. The original value will be Garbage Collected, right ? BTW, Is [(1,1),(2,2),(3,3)] been regarded as a hash ? If not, what is the best way to change it to [(1,1),(2,2222),(3,3)] in function `f` ? Bulat Ziganshin-2 wrote: > > Hello zaxis, > > Thursday, October 22, 2009, 11:28:14 AM, you wrote: > >> aaa <- newIORef ([]::[(Int,Int)]) >> writeIORef aaa [(1,1),(2,2),(3,3)] > >> then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best >> way >> ? >> re-write aaa is not permitted. > > it's the only way. in Haskell, you have *immutable* values. aaa is a > reference to immutable value. you can mutate reference so it will > point to another immutable value but you cannot change this value. > > there are two ways to make aaa==[(1,1),(2,222),(3,3)]. first, you can > apply function to whole value: > > value <- readIORef aaa > writeIORef aaa (f value) > > second, you may create list of IORefs, tuple of IORefs and so: > > a <- newIORef (1,1) > ... > let aaa = [a,b,c] > > now aaa is a immutable list of mutable IORefs. of course, you can > create IORef pointing to list of IORefs too > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/How-can-i-safely-change-the-value-of-specified-key---tp26005244p26006471.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ketil at malde.org Thu Oct 22 05:21:33 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 22 04:58:14 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26006471.post@talk.nabble.com> (zaxis's message of "Thu, 22 Oct 2009 02:03:21 -0700 (PDT)") References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> Message-ID: <877hunwzqa.fsf@malde.org> zaxis writes: >>>value <- readIORef aaa >>>writeIORef aaa (f value) > then aaa will *point to* a new value. Exactly. That's what IORefs are, references pointing to contents that can be changed in the IO monad. > The original value will be Garbage Collected, right ? Yes, unless something else is holding on to it. > Is [(1,1),(2,2),(3,3)] been regarded as a hash? It's a list of pairs. You can treat it as an association list using e.g. 'lookup' from Data.List, if that's what you mean. > If not, what is the best way to change it to [(1,1),(2,2222),(3,3)] in > function `f` ? Not sure if there's anything in Data.List, but you could do something like: f xs = (2,2222) : filter ((/=2) . fst) xs -k -- If I haven't seen further, it is by standing in the footprints of giants From bulat.ziganshin at gmail.com Thu Oct 22 05:23:42 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 22 05:00:41 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26006471.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> Message-ID: <1638135345.20091022132342@gmail.com> Hello zaxis, Thursday, October 22, 2009, 1:03:21 PM, you wrote: >>>value <- readIORef aaa >>>writeIORef aaa (f value) > then aaa will *point to* a new value. The original value will be Garbage > Collected, right ? yes, exactly > BTW, > Is [(1,1),(2,2),(3,3)] been regarded as a hash ? If not, what is the best > way to change it to [(1,1),(2,2222),(3,3)] in function `f` ? hm, i'm frequently use lists of tuples as dictionaries, there is Data.List.lookup function that perfroms lookup. but these are stored naively so it's useful only for small dictionaries. if you need hash, you can use Data.Hashtable module (it provides hash with imperative access), or use Data.Map that has pure interface. again, for the first time i strongly recommend to learn Data.Map. if you will learn Haskell as imperative language, you will find it slow, awkward and useless. if you will learn functional features and only then go to imperative part, you may find it much more pleasant just one example from my code: repeat_while (receiveP pipe) notTheEnd $ \(FileStart fi) -> do extract_file command fi $ \writer -> do repeat_while (receiveP pipe) notDataEnd (\(DataChunk buf len) -> do writer buf len; send_backP pipe (buf,len)) yes, it's imperative but it includes several lambdas per each line > Bulat Ziganshin-2 wrote: >> >> Hello zaxis, >> >> Thursday, October 22, 2009, 11:28:14 AM, you wrote: >> >>> aaa <- newIORef ([]::[(Int,Int)]) >>> writeIORef aaa [(1,1),(2,2),(3,3)] >> >>> then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best >>> way >>> ? >>> re-write aaa is not permitted. >> >> it's the only way. in Haskell, you have *immutable* values. aaa is a >> reference to immutable value. you can mutate reference so it will >> point to another immutable value but you cannot change this value. >> >> there are two ways to make aaa==[(1,1),(2,222),(3,3)]. first, you can >> apply function to whole value: >> >> value <- readIORef aaa >> writeIORef aaa (f value) >> >> second, you may create list of IORefs, tuple of IORefs and so: >> >> a <- newIORef (1,1) >> ... >> let aaa = [a,b,c] >> >> now aaa is a immutable list of mutable IORefs. of course, you can >> create IORef pointing to list of IORefs too >> >> >> >> -- >> Best regards, >> Bulat mailto:Bulat.Ziganshin@gmail.com >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From z_axis at 163.com Thu Oct 22 05:30:51 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 05:07:42 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <877hunwzqa.fsf@malde.org> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> <877hunwzqa.fsf@malde.org> Message-ID: <26006947.post@talk.nabble.com> >>f xs = (2,2222) : filter ((/=2) . fst) xs It works but not general as `f` still needs to change other value according to the "KEY". Maybe Data.List will supply what i need. Ketil Malde-5 wrote: > > zaxis writes: > >>>>value <- readIORef aaa >>>>writeIORef aaa (f value) > >> then aaa will *point to* a new value. > > Exactly. That's what IORefs are, references pointing to contents that > can be changed in the IO monad. > >> The original value will be Garbage Collected, right ? > > Yes, unless something else is holding on to it. > >> Is [(1,1),(2,2),(3,3)] been regarded as a hash? > > It's a list of pairs. You can treat it as an association list using > e.g. 'lookup' from Data.List, if that's what you mean. > >> If not, what is the best way to change it to [(1,1),(2,2222),(3,3)] in >> function `f` ? > > Not sure if there's anything in Data.List, but you could do something > like: > > f xs = (2,2222) : filter ((/=2) . fst) xs > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/How-can-i-safely-change-the-value-of-specified-key---tp26005244p26006947.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Thu Oct 22 05:28:35 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 22 05:10:50 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26006471.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> Message-ID: <10965852.20091022132835@gmail.com> Hello zaxis, Thursday, October 22, 2009, 1:03:21 PM, you wrote: > Is [(1,1),(2,2),(3,3)] been regarded as a hash ? If not, what is the best > way to change it to [(1,1),(2,2222),(3,3)] in function `f` ? f = map (\x@(a,b) -> if a==2 then (a,2222) else x) or f xs = [(a, if a==2 then 2222 else b) | (a,b) <- xs] but anyway, modifying one value inside complex datastructure is not FP way. you should consider writing a function that maps your entire input data to output one -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From noteed at gmail.com Thu Oct 22 05:34:21 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 22 05:11:30 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26006947.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> <877hunwzqa.fsf@malde.org> <26006947.post@talk.nabble.com> Message-ID: <40a414c20910220234x7ea937bbp7b267eead9b04165@mail.gmail.com> 2009/10/22 zaxis : > >>>f xs = (2,2222) : filter ((/=2) . fst) xs > It works but not general as `f` still needs to change other value according > to the "KEY". > Maybe Data.List will supply what i need. I don't think Data.List has what you want as-is. The above code is generalized simply: replace k v xs = (k,v) : filter ((/=v) . fst) xs Cheers, Thu From z_axis at 163.com Thu Oct 22 05:38:43 2009 From: z_axis at 163.com (zaxis) Date: Thu Oct 22 05:15:31 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <40a414c20910220234x7ea937bbp7b267eead9b04165@mail.gmail.com> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> <877hunwzqa.fsf@malde.org> <26006947.post@talk.nabble.com> <40a414c20910220234x7ea937bbp7b267eead9b04165@mail.gmail.com> Message-ID: <26007076.post@talk.nabble.com> >>replace k v xs = (k,v) : filter ((/=v) . fst) xs Great ! thanks you very much minh thu wrote: > > 2009/10/22 zaxis : >> >>>>f xs = (2,2222) : filter ((/=2) . fst) xs >> It works but not general as `f` still needs to change other value >> according >> to the "KEY". >> Maybe Data.List will supply what i need. > > I don't think Data.List has what you want as-is. The above code is > generalized simply: > replace k v xs = (k,v) : filter ((/=v) . fst) xs > > Cheers, > Thu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/How-can-i-safely-change-the-value-of-specified-key---tp26005244p26007076.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From noteed at gmail.com Thu Oct 22 05:49:07 2009 From: noteed at gmail.com (minh thu) Date: Thu Oct 22 05:26:16 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <26007076.post@talk.nabble.com> References: <26005244.post@talk.nabble.com> <63387067.20091022114007@gmail.com> <26006471.post@talk.nabble.com> <877hunwzqa.fsf@malde.org> <26006947.post@talk.nabble.com> <40a414c20910220234x7ea937bbp7b267eead9b04165@mail.gmail.com> <26007076.post@talk.nabble.com> Message-ID: <40a414c20910220249u6755c52fua29d689f334b7ec0@mail.gmail.com> 2009/10/22 zaxis : > >>>replace k v xs = (k,v) : filter ((/=v) . fst) xs > Great ! thanks you very much I'm not sure why you're so much happy: Assume some function defined as follow: foo a b c = e x y z a b c where x = some constant y = some other constant z = some other constant 'e' means just that the complete body of the function foo involves x, y, z, a, b and c. Generalizing foo to let the caller choose the values of x, y, z is just foo a b c x y z = e x y z a b c -- the where is unneeded In fact, this is what functions are made for: generalizing a given expression so that part of the expression can be given in arguements. E.g. turning e a b into f a = e a b Cheers, Thu From niklas.broberg at gmail.com Thu Oct 22 06:34:22 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Thu Oct 22 06:11:10 2009 Subject: [Haskell-cafe] pretty printing with comments In-Reply-To: References: <2d34474e0910200354u1f9ab238odcba81e98d98d4b1@mail.gmail.com> <2d34474e0910200428p6c8910f1u9a5e3b7bc8eecd2c@mail.gmail.com> <40a414c20910200958k94fc261j2ff455e362452694@mail.gmail.com> <2d34474e0910201255n309606ffk77bab02e2bc3eaa4@mail.gmail.com> Message-ID: > I'll see when I can get to fixing it, hopefully it won't be long. Two fairly easy bugs to fix, darcs repo is updated. It's probably high time I did another release, stay tuned. I just can't believe I didn't have a single class declaration in my test suite to catch the first one! Or that no one else triggered it before (I guess no one has actually started using exactPrint in their code yet). Thanks again for reporting! :-) Cheers, /Niklas From wb at sao.pl Thu Oct 22 07:07:00 2009 From: wb at sao.pl (Waldemar Biernacki) Date: Thu Oct 22 06:43:51 2009 Subject: [Haskell-cafe] Is there in Haskell the eval function? In-Reply-To: <4AE01BB9.704@van.steenbergen.nl> References: <200910221042.37259.wb@sao.pl> <4AE01BB9.704@van.steenbergen.nl> Message-ID: <200910221307.01072.wb@sao.pl> Thank you Martijn! > You mean like in interpreted languages? Naturally! My mistake. > > I'd like to write an application which has to be compiled to exec file. It is neccessary to performe some additional procedures which are unknown at the moment of the compilition. > > You could use the GHC libraries, or Hint which is built on top of GHC. > I've used it before and it works pretty nicely. > > http://hackage.haskell.org/package/hint At first sight it seems be what I'm looking for. I'll try. Thank you for the help! wb. From anotheraddress at gmx.de Thu Oct 22 07:29:31 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Thu Oct 22 07:06:22 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <4AE00E14.7080600@van.steenbergen.nl> References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: <200910221329.31509.anotheraddress@gmx.de> Hi, On Thursday 22 October 2009 09:47:32 Martijn van Steenbergen wrote: > Bonjour caf?, > > > data ExprF r > > = Add r r > > > > | Sub r r > > | Mul r r > > | Div r r > > | Num Int > > This is a well-known pattern that for example allows nice notation of > morphisms. But what is it called? > ... The multirec package calls this the "pattern functor" (more accurately, it generates a sum-of-products-like higher order functor whose fixed point is isomorphic to your family of types, and calls that the pattern functor). -- Greetings, Daniel From porges at porg.es Thu Oct 22 07:33:22 2009 From: porges at porg.es (George Pollard) Date: Thu Oct 22 07:10:11 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <200910221329.31509.anotheraddress@gmx.de> References: <4AE00E14.7080600@van.steenbergen.nl> <200910221329.31509.anotheraddress@gmx.de> Message-ID: <6d942a4a0910220433j30d97d0fme1cd143ef93e0b26@mail.gmail.com> Conor also calls these functors: http://strictlypositive.org/slicing-jpgs/ "The fixpoint construction builds recursive types (think trees) from functors by identifying superstructures with substructures: each node frames its children. " From pepeiborra at gmail.com Thu Oct 22 09:04:41 2009 From: pepeiborra at gmail.com (Jose Iborra) Date: Thu Oct 22 08:41:34 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <4AE00E14.7080600@van.steenbergen.nl> References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: <5C158C5D-42BC-4A9F-AAD7-BF589D14BFA5@gmail.com> Obviously you are modelling the datatype -- data Expr = Add Expr Expr | Sub Expr Expr | Mul Expr Expr | Div Expr Expr | Num Int You already have ExprF, and now you need to throw in Fix newtype Fix f = In (f(Fix f)) in order to be able to build Expr like terms. type Expr' = Fix ExprF add a b = In (Add a b) sub a b = In (Sub a b) .... I've heard people refer to this technique of modelling datatypes as taking the initial algebra of the associated endofunctor (in this case ExprF) [http://strictlypositive.org/indexed-containers.pdf] This pattern is discussed in depth in Jeremy Gibbons work. I really recommend his "Datatype-Generic Programming" piece [http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf ]. Someone else mentioned the multirec library. If you feel really adventurous you can look at the paper behind: "Generic programming with fixed points for mutually recursive datatypes" [http://people.cs.uu.nl/andres/Rec/MutualRec.pdf] or check out Andres presentation at ICFP [http://vimeo.com/6612724 ]. Just my 2c. On 22/10/2009, at 09:47, Martijn van Steenbergen wrote: > Bonjour caf?, > >> data ExprF r >> = Add r r >> | Sub r r >> | Mul r r >> | Div r r >> | Num Int > > This is a well-known pattern that for example allows nice notation > of morphisms. But what is it called? I've heard fixed-point view, > open datatypes and some others, but I'm curious where this pattern > comes up in literature and what it is called there. > > Thanks, > > Martijn. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vanenkj at gmail.com Thu Oct 22 09:24:47 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Oct 22 09:01:38 2009 Subject: [Haskell-cafe] ANN: mecha-0.0.0 In-Reply-To: <594c1e830910212042q33bda84brf96d674ad5327fc9@mail.gmail.com> References: <594c1e830910212042q33bda84brf96d674ad5327fc9@mail.gmail.com> Message-ID: Is this on hackage yet, or should we just consult the mecha link on your home page? On Wed, Oct 21, 2009 at 11:42 PM, Tom Hawkins wrote: > A few months ago, I started toying with a few alternative pump designs > to power our hydraulic hybrids. After not being able to secure a ProE > license, I searched for a free solid modeler to sketch out a few > ideas. To my surprise, their are practically no open source 3D CAD > packages available. So I created Mecha, DSL for constructive solid > modeling. > > Mecha's geometry is based on octrees, which makes it easy to perform > set operations on solids, as well as volumetric calculations such as > center-of-mass, moments of inertia, and of course, total volume. > Drawbacks of octrees include consuming a lot of memory and the loss of > some surface information. To address the later, Mecha carries forward > surface points and normals to the leaf nodes of the octree to assist > in rendering, such that solids don't look like they're made from a > bunch of LEGOS. > > Note this is a very early release. The only thing Mecha can do at the > moment is draw a pretty blue ball -- well it can also zoom and pan on > a pretty blue ball (mouse wheel). Establishing a primitive API and > building a primitive library must be finished before Mecha an do > anything useful. > > Any comments and suggestions are welcome. > > http://tomahawkins.org/ > _______________________________________________ > 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/20091022/265842ec/attachment.html From deniz.a.m.dogan at gmail.com Thu Oct 22 09:29:07 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Oct 22 09:14:30 2009 Subject: [Haskell-cafe] ANN: mecha-0.0.0 In-Reply-To: References: <594c1e830910212042q33bda84brf96d674ad5327fc9@mail.gmail.com> Message-ID: <7b501d5c0910220629n11b34e39y7929fd40f0429411@mail.gmail.com> Hackage link: http://hackage.haskell.org/package/mecha/ 2009/10/22 John Van Enk : > Is this on hackage yet, or should we just consult the mecha link on your > home page? > > On Wed, Oct 21, 2009 at 11:42 PM, Tom Hawkins wrote: >> >> A few months ago, I started toying with a few alternative pump designs >> to power our hydraulic hybrids. ?After not being able to secure a ProE >> license, I searched for a free solid modeler to sketch out a few >> ideas. ?To my surprise, their are practically no open source 3D CAD >> packages available. ?So I created Mecha, DSL for constructive solid >> modeling. >> >> Mecha's geometry is based on octrees, which makes it easy to perform >> set operations on solids, as well as volumetric calculations such as >> center-of-mass, moments of inertia, and of course, total volume. >> Drawbacks of octrees include consuming a lot of memory and the loss of >> some surface information. ?To address the later, Mecha carries forward >> surface points and normals to the leaf nodes of the octree to assist >> in rendering, such that solids don't look like they're made from a >> bunch of LEGOS. >> >> Note this is a very early release. ?The only thing Mecha can do at the >> moment is draw a pretty blue ball -- well it can also zoom and pan on >> a pretty blue ball (mouse wheel). ?Establishing a primitive API and >> building a primitive library must be finished before Mecha an do >> anything useful. >> >> Any comments and suggestions are welcome. >> >> http://tomahawkins.org/ >> _______________________________________________ >> 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 bob.atkey at ed.ac.uk Thu Oct 22 09:44:22 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Thu Oct 22 09:21:27 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: <1256219062.4548.168.camel@antimony> On Sat, 2009-10-10 at 20:12 +0200, Ben Franksen wrote: > Since 'some' is defined recursively, this creates an infinite production for > numbers that you can neither print nor otherwise analyse in finite time. Yes, sorry, I should have been more careful there. One has to be careful to handle EDSLs that have potentially infinite syntax properly. > I can see at least two solutions: One is to parameterize everything over the > type of terminals, too. > The second solution (which I followed) is to break the recursion by adding > another nonterminal to the NT type: A third solution is to add the Kleene star to the grammar DSL, so the representation of productions becomes: > data Production nt a > = Stop a > | Terminal Char (Production nt a) > | forall b. NonTerminal (nt b) (Production nt (b -> a)) > | forall b. Star (Production nt b) (Production nt ([b] -> a)) You also need to add the necessary parts for Alternative to the Production type too, because they may be nested inside Star constructors: > | Zero > | Choose (Production nt a) (Production nt a) The type Production nt is now directly an Applicative and an Alternative and also has the combinator: > star :: Production nt a -> Production nt [a] > star p = Star p $ Stop id The type of grammars is changed to (with the additional of the starting nonterminal, as you point out): > type Grammar nt = forall a. nt a -> Production nt a It is probably also possible to write a function that converts grammars with ?Star?s in to ones without by introducing new non-terminals in the way you did. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From bob.atkey at ed.ac.uk Thu Oct 22 09:46:45 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Thu Oct 22 09:23:47 2009 Subject: [Haskell-cafe] Re: What *is* a DSL? In-Reply-To: References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> Message-ID: <1256219205.4548.171.camel@antimony> On Sun, 2009-10-11 at 21:54 +0200, Ben Franksen wrote: > Ben Franksen wrote: > > Next thing I'll try is to transform such a grammar into an actual > > parser... > > Which I also managed to get working. However, this exposed yet another > problem I am not sure how to solve. Another option is to not use a recursive descent parser, and switch to a parsing algorithm for any context-free such as CYK or Earley's algorithm. A little test implementation of a well-typed version of the CYK algorithm seems to work and seems to be as efficient as the normal imperative one if enough memoisation is used. I'm trying to see if I can get Earley's algorithm to work nicely in the well-typed setting. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From bob.atkey at ed.ac.uk Thu Oct 22 09:56:52 2009 From: bob.atkey at ed.ac.uk (Robert Atkey) Date: Thu Oct 22 09:33:54 2009 Subject: [Haskell-cafe] What *is* a DSL? In-Reply-To: <4AD47276.8020107@cs.nott.ac.uk> References: <4ACCB2C0.7060206@chalmers.se> <151FC15B-D313-4D0A-A056-F52AA41B24AF@gmail.com> <1254932943.21105.54.camel@antimony> <4AD47276.8020107@cs.nott.ac.uk> Message-ID: <1256219812.4548.181.camel@antimony> On Tue, 2009-10-13 at 13:28 +0100, Nils Anders Danielsson wrote: > On 2009-10-07 17:29, Robert Atkey wrote: > > A deep embedding of a parsing DSL (really a context-sensitive grammar > > DSL) would look something like the following. I think I saw something > > like this in the Agda2 code somewhere, but I stumbled across it when I > > was trying to work out what "free" applicative functors were. > > The Agda code you saw may have been due to Ulf Norell and me. There is a > note about it on my web page: > > http://www.cs.nott.ac.uk/~nad/publications/danielsson-norell-parser-combinators.html Yes, it might have been that, OTOH I'm sure I saw it in some Haskell code. Maybe I was imagining it. > > Note that these grammars are strictly less powerful than the ones that > > can be expressed using Parsec because we only have a fixed range of > > possibilities for each rule, rather than allowing previously parsed > > input to determine what the parser will accept in the future. > > Previously parsed input /can/ determine what the parser will accept in > the future (as pointed out by Peter Ljungl?f in his licentiate thesis). > Consider the following grammar for the context-sensitive language > {a?b?c?| n ? ?}: Yes, sorry, I was sloppy in what I said there. Do you know of a characterisation of what languages having a possibly infinite amount of nonterminals gives you. Is it all context-sensitive languages or a subset? > > And a general definition for parsing single-digit numbers. This works > > for any set of non-terminals, so it is a reusable component that works > > for any grammar: > > Things become more complicated if the reusable component is defined > using non-terminals which take rules (defined using an arbitrary > non-terminal type) as arguments. Exercise: Define a reusable variant of > the Kleene star, without using grammars of infinite depth. I see that you have an answer in the paper you linked to above. Another possible answer is to consider open sets of rules in a grammar: > data OpenRuleSet inp exp = > forall hidden. OpenRuleSet (forall a. (exp :+: hidden) a -> > Rule (exp :+: hidden :+: inp) a) > data (f :+: g) a = Left2 (f a) | Right2 (g a) So OpenRuleSet inp exp, exports definitions of the nonterminals in 'exp', imports definitions of nonterminals in 'inp' (and has a collection of hidden nonterminals). It is then possible to combine them with a function of type: > combineG :: (inp1 :=> exp1 :+: inp) -> > (inp2 :=> exp2 :+: inp) -> > OpenRuleSet inp1 exp1 -> > OpenRuleSet inp2 exp2 -> > OpenRuleSet inp (exp1 :+: exp2) One can then give a reusable Kleene star by stating it as an open rule set: > star :: forall a nt. Rule nt a -> OpenRuleSet nt (Equal [a]) where Equal is the usual equality GADT. Obviously, this would be a bit clunky to use in practice, but maybe more specialised versions combineG could be given. Bob -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From paul at cogito.org.uk Thu Oct 22 10:31:55 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Thu Oct 22 10:08:46 2009 Subject: [Haskell-cafe] Time and space complexity of "take k . sort" Message-ID: <4AE06CDB.6060203@cogito.org.uk> This question on StackOverflow asked about how to find the largest 100 items in a very long list: http://stackoverflow.com/questions/1602998/fastest-way-to-obtain-the-largest-x-numbers-from-a-very-large-unsorted-list/1603198#1603198 I replied that you could do it with something like this (but here taking the k smallest to strip out some irrelevant complications): > takeLargest k = take k . sort Because "sort" is lazily evaluated this only does enough sorting to find the first k elements. I guess the complexity is something like O(n*k*log(k)). But of equal practical interest is the space complexity. The optimum algorithm is to take the first k items, sort them, and then iterate through the remaining items by adding each item to the sorted list and then throwing out the highest one. That has space complexity O(k). What does the function above do? Paul. From orclev at gmail.com Thu Oct 22 10:48:52 2009 From: orclev at gmail.com (Kyle Murphy) Date: Thu Oct 22 10:25:42 2009 Subject: [Haskell-cafe] How can i safely change the value of specified key ? In-Reply-To: <710558061.20091022114138@gmail.com> References: <26005244.post@talk.nabble.com> <710558061.20091022114138@gmail.com> Message-ID: <2db78cee0910220748j5631d7a5v29f6eb5618537f87@mail.gmail.com> - Sorry for the late reply on this, I actually sent it last night before I went to bed but accidentally sent it only to Bulat, re-sending it now for the entire list - As Bulat said, it sounds like you're not fully understanding functional programming. You really should read one of the better tutorials or books on Haskell like Real World Haskell (you can read it for free online, just google for it), as it seems like you're trying to use a advanced feature of the language (IORefs) that's designed to help solve some particularly difficult problems in order to treat the language more like a procedural language (which is a really bad way to approach it). This would be something like if you decided to learn Java by only ever have one class that consisted of nothing but a whole bunch of public static methods, it pretty much misses the point of the language. Try not to think of variables as places to store values, instead think of them as functions that take zero or more arguments. when you do something like > let foo = [1,2,3] don't think of foo as a variable that contains a list of numbers, instead think of foo as a function that doesn't take any arguments and returns a list of numbers (in this case a constant list). You should also concentrate on ways data can be transformed particularly using higher order functions like map and foldr. For instance, if you want to convert a list like [1,2,3] into one like [(1,1),(2,2),(3,3)] (that is, convert [Int] to [(Int, Int)]) you can use map or zip like so: > map (\x -> (x,x)) [1,2,3] -- applies a function to each member, in this case the lambda \x -> (x,x) which just makes a tuple > zip [1,2,3] [1,2,3] -- combines two lists into one by making each element of the joined list a tuple of one element from each list -R. Kyle Murphy -- Curiosity was framed, Ignorance killed the cat. On Thu, Oct 22, 2009 at 03:41, Bulat Ziganshin wrote: > Hello zaxis, > > Thursday, October 22, 2009, 11:28:14 AM, you wrote: > > > then if i want to change aaa to [(1,1),(2,222),(3,3)] , what's the best > way > > ... well, anyway what you are doing isn't very haskellish. it may be > considered as advanced topic but basically, best way to compute > something in Haskell is to construct pure function > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091022/43ba5884/attachment.html From haskell at colquitt.org Thu Oct 22 11:35:36 2009 From: haskell at colquitt.org (John Dorsey) Date: Thu Oct 22 11:12:24 2009 Subject: [Haskell-cafe] NetSnmp problem. In-Reply-To: <3bd412d40910220153p7ee547f6q530ec7e0fbc353e0@mail.gmail.com> References: <3bd412d40910220153p7ee547f6q530ec7e0fbc353e0@mail.gmail.com> Message-ID: <20091022153535.GA23495@colquitt.org> > I am trying to use NetSnmp to get some information from my switch. > And I met this problem. > After initialize, I used snmpWalk to get some information, and > dealed with it. Everything is fine. Then I sleep for 5 mins. SnmpWalk > again. But this time, all asnValues were unsupported format, which > broke my dealing process. Are you on a 64-bit machine? I've made an update or two, but haven't pushed them to Hackage yet... I'll do that today. Please let me know if this fixes your problem. John From gcross at phys.washington.edu Thu Oct 22 11:43:52 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Oct 22 11:20:58 2009 Subject: [Haskell-cafe] Simple but interesting (for me) problem In-Reply-To: <40a414c20910220048x32767b6ei80590cf6407c35a9@mail.gmail.com> References: <354610.64099.qm@web31101.mail.mud.yahoo.com> <4335a3260910211100y3bb029a9j1a40c893c73cfe5f@mail.gmail.com> <4335a3260910211123u3dd4ca0axe7d24264e754e793@mail.gmail.com> <40a414c20910211130o5c8f694enfefa1554f31a3567@mail.gmail.com> <4335a3260910211140r495d9d90g8dbb871e6d7441fb@mail.gmail.com> <7FD338DB-F5E9-4CCD-B4A1-A60BE58FF990@phys.washington.edu> <40a414c20910220048x32767b6ei80590cf6407c35a9@mail.gmail.com> Message-ID: <994402B0-496F-4878-B79A-B78231FF7921@phys.washington.edu> Thank you for the additional explanation, but it isn't clear that what you have added is inconsistent with my explanation. The point I was trying to make is that in an impure/imperative world, you may assume that a function is called every time that you use it. However, in a pure world the assumption is that a function called with the same arguments will always return the same result (i.e., referential transparency) so that you only need to run it's code once and then you can re-use that value henceforth. In practice, of course, what happens under the hood (at least, with GHC) is that "foo <- mkNext" constructs a thunk named "foo" which is evaluated the at the first "print foo" and from then on the thunk is in an evaluated state and so later references to it just use this value rather than re-evaluating it. This is because, due to referential transparency, it is equivalent to think of foo both as a function whose value can be cached and as a constant value that we just don't know yet. The problem with the "foo" that was defined is that its code will actually give you a different value each time that you run it, violating the semantics of the language since all functions are assumed to be pure. The problem with violating this semantic is that the compiler uses it whenever it can to make things more efficient, which in this case means treating foo as a value that only needs to be evaluated once even though each time you run the code you actually get a different result. Hence, the results are in a sense undefined since the compiler is allowed to run foo as many times as it wants expecting to get the same result each time; for example if two threads evaluated foo at the same time then under pathological conditions the first thread might see "1" and the second thread "2". So the moral of this story --- and perhaps the point that you were trying to make --- is that it is better to think of "foo" as a constant value that you just don't know yet (until you evaluate) it rather than as a function that you can call. (Your nitpick that "next" would have been a better name than "foo" is well taken, though.) Cheers, Greg On Oct 22, 2009, at 12:48 AM, minh thu wrote: > 2009/10/21 Gregory Crosswhite : >> And just because this has not been explicitly stated: it's not >> just for >> aesthetic reasons that you couldn't do this with a pure function, but >> because it violates the semantics and gets you the wrong result. >> So for >> example, if you modified Tim's code to be >> >> import Data.IORef >> import System.IO.Unsafe >> mkNext :: (Num a) => IO a >> mkNext = do >> ref <- newIORef 0 >> return . unsafePerformIO $ >> do >> modifyIORef ref (+1) >> readIORef ref >> main :: IO () >> main = do >> foo <- mkNext >> print foo >> print foo >> print foo >> >> Then the output that you will see (with GHC at least) is >> 1 >> 1 >> 1 >> because the compiler assumes that it only needs to evaluate foo >> once, after >> which it can cache the result due to assumed referential >> transparency. >> - Greg > > This is indeed wrong, but not how you think it is. > > The code you pass to unsafePerformIO has type Num a => IO a, so the > value passed to return has type Num a. So foo has type Num a too and > its value is 1. > > Exactly like in > > mkNext = do > ref <- newIORef 0 > modifyIORef ref (+1) > readIORef ref > > which is a complicated way to write > > mkNext = return 1 > > Now, it's clear that foo has value 1 and printing it three times > should output three 1. The whole point of having mkNext return an > action (that should be called next, and not foo, as it is much > clearer) in previous code was too be able to execute it multiple times > and having it return a new value. > > In general, expecting > > print bar > print bar > print bar > > outputing three different things is wrong, as bar should be pure. If > bar is not pure, then it should be > a <- bar > print a > b <- bar > print b > c <- bar > print c > > Cheers, > Thu From paul at cogito.org.uk Thu Oct 22 11:57:44 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Thu Oct 22 11:34:34 2009 Subject: [Haskell-cafe] Time and space complexity of "take k . sort" In-Reply-To: <4AE06CDB.6060203@cogito.org.uk> References: <4AE06CDB.6060203@cogito.org.uk> Message-ID: <4AE080F8.8050308@cogito.org.uk> On 22/10/09 15:31, Paul Johnson wrote: > > > takeLargest k = take k . sort > > Because "sort" is lazily evaluated this only does enough sorting to > find the first k elements. I guess the complexity is something like > O(n*k*log(k)). > Correction: O(n*log(k)) From jfredett at gmail.com Thu Oct 22 11:58:53 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Oct 22 11:35:45 2009 Subject: [Haskell-cafe] Is there in Haskell the eval function? In-Reply-To: <200910221307.01072.wb@sao.pl> References: <200910221042.37259.wb@sao.pl> <4AE01BB9.704@van.steenbergen.nl> <200910221307.01072.wb@sao.pl> Message-ID: <137EE3A4-3DFD-4312-8778-F80122057365@gmail.com> You may also want to look at Dyre. It does dynamic recompilation of source files. Depending on your application, hint may not be what you need. Eg, if you're trying to build something like lambdabot's interpreter, then Hint is probably on the right track, if you just want to use Haskell-as-configuration file (a la xmonad), then Dyre is probably a better (or at least easier, Hint can be evil...) choice /Joe On Oct 22, 2009, at 7:07 AM, Waldemar Biernacki wrote: > Thank you Martijn! > >> You mean like in interpreted languages? > Naturally! My mistake. > >>> I'd like to write an application which has to be compiled to exec >>> file. It is neccessary to performe some additional procedures >>> which are unknown at the moment of the compilition. >> >> You could use the GHC libraries, or Hint which is built on top of >> GHC. >> I've used it before and it works pretty nicely. >> >> http://hackage.haskell.org/package/hint > > At first sight it seems be what I'm looking for. I'll try. > > Thank you for the help! > > wb. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mauricio.antunes at gmail.com Thu Oct 22 13:18:27 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Oct 22 12:55:51 2009 Subject: [Haskell-cafe] Word128, Word256 Message-ID: Hi, Do you think we could have the range of sizes for Int* and Word* expanded to allow also 128 and 256 bits sizes? My reason is that I have a long standing issue trying to bind to C numerical libraries using complex numbers, as those are usually structs passed by value. See this from GNU GSL: typedef struct { double dat[2]; } gsl_complex; I imagine I could do: type GslComplex = Word128 -- size would depend on architecture and then write foreign declarations to have: get_real :: GslComplex -> CDouble get_imag :: GslComplex -> CDouble gsl_complex_sin :: GslComplex -> GslComplex gsl_complex_cos :: GslComplex -> GslComplex Do you think this is a reasonable request? Thanks for your attention, Maur?cio From thomas.dubuisson at gmail.com Thu Oct 22 13:41:39 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Oct 22 13:18:28 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> Message-ID: <4c44d90b0910221041y3ea58d26kbec11ab9e155e3ee@mail.gmail.com> > For clarity, one trick that uses "unsafePerformIO" which you may have seen > posted on this list earlier today is the following way of creating a > globally visible IORef: > > import Data.IORef > import System.IO.Unsafe > > *** counter = unsafePerformIO $ newIORef 0 *** > > next = do > ?modifyIORef counter (+1) > ?readIORef counter This is still unsafe but it can evidently be slightly improved with NOINLINE pragma: {-# NOINLINE counter #-} counter = unsafePerformIO $ newIORef 0 without said pragma the counter could be initialized numerous times, as I understand it. All this said, I hope people avoid unsafePerformIO for mutable globals - reader monad, state monad, and partial application should be sufficient tools. Thomas From v.dijk.bas at gmail.com Thu Oct 22 14:15:32 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Oct 22 13:52:20 2009 Subject: [Haskell-cafe] ANN: Data.Stream 0.4 In-Reply-To: References: Message-ID: On Wed, Oct 21, 2009 at 9:44 PM, Wouter Swierstra wrote: > The only change with the previous version has been to add irrefutable > patterns to several function definitions. This is rather delicate design > decision: too many irrefutable patterns could result in thunks not being > evaluated; too few irrefutable patterns could cause your functions diverge. > As a rule of thumb I've chosen only to use irrefutable patterns in functions > that produce streams from streams. The operations that observe finite > information (a prefix, the element at index i, etc.) do not have have > irrefutable patterns and force evaluation to weak head normal form. Hi Wouter, I have two questions: 1) What's the difference between your: "tail ~(Cons _ xs) = xs" and the more simple: "tailStrict (Cons _ xs) = xs" ? I know they're desugared to: "tail ys = let Cons _ xs = ys in xs" and: "tailStrict ys = case ys of Cons _ xs -> xs" respectively. But aren't they operationally the same: "tail undefined = undefined" and: "tailStrict undefined = undefined" 2) Why don't you also use an irrefutable pattern in "take"? "take" is now defined as: take :: Int -> Stream a -> [a] take n (Cons x xs) | n == 0 = [] | n > 0 = x : (take (n - 1) xs) | otherwise = error "Stream.take: negative argument." so "take 0 undefined = undefined" while: takeLazy :: Int -> Stream a -> [a] takeLazy n ~(Cons x xs) | n == 0 = [] | n > 0 = x : (takeLazy (n - 1) xs) | otherwise = error "Stream.take: negative argument." "takeLazy 0 undefined = []" regards, Bas From dave at zednenem.com Thu Oct 22 14:32:47 2009 From: dave at zednenem.com (David Menendez) Date: Thu Oct 22 14:09:34 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> Message-ID: <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> On Thu, Oct 22, 2009 at 2:23 AM, Gregory Crosswhite wrote: > For clarity, one trick that uses "unsafePerformIO" which you may have seen > posted on this list earlier today is the following way of creating a > globally visible IORef: > > import Data.IORef > import System.IO.Unsafe > > *** counter = unsafePerformIO $ newIORef 0 *** Danger! If the monomorphism restriction is disabled, this ends up creating a value of type forall a. Num a => IORef a, which can be used to break type safety. More generally, cell :: IORef a cell = unsafePerformIO $ newIORef undefined unsafeCoerce :: a -> b unsafeCoerce x = unsafePerformIO $ do writeIORef cell x readIORef cell This way lies segmentation faults. That "unsafe" is there for a reason. -- Dave Menendez From john at repetae.net Thu Oct 22 14:45:55 2009 From: john at repetae.net (John Meacham) Date: Thu Oct 22 14:22:42 2009 Subject: [Haskell-cafe] Word128, Word256 In-Reply-To: References: Message-ID: <20091022184554.GK7802@sliver.repetae.net> jhc potentially has Word128, but it only has meaning when __int128_t is defined for a given target. (gcc + x86_64 for instance). What would something like Word256 mean? As in, the only reason to supply something like Word128 in the compiler is so FFI calls involving __int128_t will work, without a defined ABI type to map Word256 to, then a portable pure haskell implementation seems just as good. Your example doesn't seem to make sense, as the calling convention for __int128_t (what Word128 would map to) and double x[2] are unlikely to coincide. they are probably passed in different registers for instance. Adding the ability for the FFI to pass complex types directly would be useful. Something like 'CComplex CDouble' has been proposed before.. but that again would be independent of a Word128 type. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From gcross at phys.washington.edu Thu Oct 22 14:59:01 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Oct 22 14:35:49 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> Message-ID: <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> Yes, I was once taught that "Every time you use unsafePerformIO, God kills a kitten," so every time I consider using it I first ask myself: is this really worth an innocent kitten's life? Cheers, Greg On Oct 22, 2009, at 11:32 AM, David Menendez wrote: > On Thu, Oct 22, 2009 at 2:23 AM, Gregory Crosswhite > wrote: >> For clarity, one trick that uses "unsafePerformIO" which you may >> have seen >> posted on this list earlier today is the following way of creating a >> globally visible IORef: >> >> import Data.IORef >> import System.IO.Unsafe >> >> *** counter = unsafePerformIO $ newIORef 0 *** > > Danger! If the monomorphism restriction is disabled, this ends up > creating a value of type forall a. Num a => IORef a, which can be used > to break type safety. > > More generally, > > cell :: IORef a > cell = unsafePerformIO $ newIORef undefined > > unsafeCoerce :: a -> b > unsafeCoerce x = unsafePerformIO $ do > writeIORef cell x > readIORef cell > > This way lies segmentation faults. That "unsafe" is there for a > reason. > > -- > Dave Menendez > From monnier at iro.umontreal.ca Thu Oct 22 15:02:08 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu Oct 22 14:39:02 2009 Subject: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned? In-Reply-To: <221b53ab0910200857o5e541558yf935f328c5c761dc@mail.gmail.com> (Svein Ove Aas's message of "Tue, 20 Oct 2009 17:57:04 +0200") References: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> <221b53ab0910200857o5e541558yf935f328c5c761dc@mail.gmail.com> Message-ID: >>> In any case, I need it fixed before I can work on haskell-mode. >>> Preferably by migrating haskell-mode over to cvs. :-) >> You mean migrating to DaRCS? ?That would be appreciated, yes. > Um, yes. > I can get the revision history into darcs pretty easily, such as it > is, assuming cvs.haskell.org comes back up. Then I'll put the > repository somewhere you can get at it. That fine? Yes, that would be wonderful. Ideally, it will eventually make it into something like darcs.haskell.org. >>> who *is* the current maintainer? >> Last I heard, it was me. ?But if someone wants to take over, >> he's welcome. > You're saying you don't have time to maintain it? Pretty much, yes. At least, I don't think I've done a good job maintaining it over the last couple years. > Still, there needs to be a new release, Yes, urgently. > and I've got a lot of improved haskell-mode code (written by other > people) that isn't currently in the repository. Can you show me the patches? Stefan From inforichland at gmail.com Thu Oct 22 15:05:34 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Thu Oct 22 14:42:22 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> Message-ID: <4335a3260910221205k3317676wf9c5862a17be3246@mail.gmail.com> Well, I apologize for starting this whole thread which involves so many dead kittens :( I was just trying to help answer a question :) I guess I assumed too much.. that someone would think to be careful when using a function with the word 'unsafe' in it... So, be warned, all Haskellers! Be careful when using any function that starts with the word 'unsafe'! You may kill a kitten! And I guess this says something about using 'unsafe' functions... http://upload.wikimedia.org/wikipedia/en/1/11/God-kills-kitten.jpg (NSFW)... Cheers and sorry all, Tim On Thu, Oct 22, 2009 at 1:59 PM, Gregory Crosswhite < gcross@phys.washington.edu> wrote: > Yes, I was once taught that "Every time you use unsafePerformIO, God kills > a kitten," so every time I consider using it I first ask myself: is this > really worth an innocent kitten's life? > > Cheers, > Greg > > > On Oct 22, 2009, at 11:32 AM, David Menendez wrote: > > On Thu, Oct 22, 2009 at 2:23 AM, Gregory Crosswhite >> wrote: >> >>> For clarity, one trick that uses "unsafePerformIO" which you may have >>> seen >>> posted on this list earlier today is the following way of creating a >>> globally visible IORef: >>> >>> import Data.IORef >>> import System.IO.Unsafe >>> >>> *** counter = unsafePerformIO $ newIORef 0 *** >>> >> >> Danger! If the monomorphism restriction is disabled, this ends up >> creating a value of type forall a. Num a => IORef a, which can be used >> to break type safety. >> >> More generally, >> >> cell :: IORef a >> cell = unsafePerformIO $ newIORef undefined >> >> unsafeCoerce :: a -> b >> unsafeCoerce x = unsafePerformIO $ do >> writeIORef cell x >> readIORef cell >> >> This way lies segmentation faults. That "unsafe" is there for a reason. >> >> -- >> Dave Menendez >> > >> > > _______________________________________________ > 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/20091022/7af2ae84/attachment-0001.html From johan.tibell at gmail.com Thu Oct 22 15:21:04 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Thu Oct 22 14:58:11 2009 Subject: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned? In-Reply-To: References: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> <221b53ab0910200857o5e541558yf935f328c5c761dc@mail.gmail.com> Message-ID: <90889fe70910221221q5d2e61d8g6acdd2920b5d6d86@mail.gmail.com> Hi, I just wanted to say that I'd be really happy to see haskell-mode in code.haskell.org. I think it will make it easier for people to hack on it. Thanks, Johan From ketil at malde.org Thu Oct 22 15:45:54 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 22 15:22:32 2009 Subject: [Haskell-cafe] Time and space complexity of "take k . sort" In-Reply-To: <4AE06CDB.6060203@cogito.org.uk> (Paul Johnson's message of "Thu, 22 Oct 2009 15:31:55 +0100") References: <4AE06CDB.6060203@cogito.org.uk> Message-ID: <87my3jus99.fsf@malde.org> Paul Johnson writes: >> takeLargest k = take k . sort > But of equal practical interest is the space complexity. The optimum > algorithm is to take the first k items, sort them, and then iterate > through the remaining items by adding each item to the sorted list and > then throwing out the highest one. That has space complexity O(k). > What does the function above do? Well - 'sort' doesn't know the value of 'k', so it needs to retain all elements, just in case 'k' might be 'n'. So I don't see how you can use space less than 'n' for a construct like the above. -k -- If I haven't seen further, it is by standing in the footprints of giants From westondan at imageworks.com Thu Oct 22 16:18:48 2009 From: westondan at imageworks.com (Dan Weston) Date: Thu Oct 22 15:58:37 2009 Subject: [Haskell-cafe] Time and space complexity of "take k . sort" In-Reply-To: <87my3jus99.fsf@malde.org> References: <4AE06CDB.6060203@cogito.org.uk> <87my3jus99.fsf@malde.org> Message-ID: <4AE0BE28.2080905@imageworks.com> Unless of course you use a GHC RULE to rewrite the RHS into the LHS, which should always be a valid transformation. Ketil Malde wrote: > Paul Johnson writes: > >>> takeLargest k = take k . sort > >> But of equal practical interest is the space complexity. The optimum >> algorithm is to take the first k items, sort them, and then iterate >> through the remaining items by adding each item to the sorted list and >> then throwing out the highest one. That has space complexity O(k). >> What does the function above do? > > Well - 'sort' doesn't know the value of 'k', so it needs to retain all > elements, just in case 'k' might be 'n'. So I don't see how you can use > space less than 'n' for a construct like the above. > > -k From colin at colina.demon.co.uk Thu Oct 22 16:37:40 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Oct 22 16:14:29 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> (Gregory Crosswhite's message of "Thu\, 22 Oct 2009 11\:59\:01 -0700") References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> Message-ID: >>>>> "Gregory" == Gregory Crosswhite writes: Gregory> Yes, I was once taught that "Every time you use Gregory> unsafePerformIO, God kills a kitten," so every time I Gregory> consider using it I first ask myself: is this really Gregory> worth an innocent kitten's life? I've changed my mind. Everyone go out and use unsafePerformIO all the time. That way we can get rid of all those mudering kittens, and the dragonflies will live longer. -- Colin Adams Preston Lancashire From ben.franksen at online.de Thu Oct 22 16:38:43 2009 From: ben.franksen at online.de (Ben Franksen) Date: Thu Oct 22 16:15:55 2009 Subject: [Haskell-cafe] Re: Re: cvs.haskell.org down? haskell-mode abandoned? References: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> <221b53ab0910200857o5e541558yf935f328c5c761dc@mail.gmail.com> <90889fe70910221221q5d2e61d8g6acdd2920b5d6d86@mail.gmail.com> Message-ID: Johan Tibell wrote: > I just wanted to say that I'd be really happy to see haskell-mode in > code.haskell.org. I think it will make it easier for people to hack on > it. Another option is http://patch-tag.com/ Cheers Ben From svein.ove at aas.no Thu Oct 22 16:47:55 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Thu Oct 22 16:24:42 2009 Subject: [Haskell-cafe] Re: cvs.haskell.org down? haskell-mode abandoned? In-Reply-To: References: <221b53ab0910200231l32feab55n8e14d16296981004@mail.gmail.com> <221b53ab0910200857o5e541558yf935f328c5c761dc@mail.gmail.com> Message-ID: <221b53ab0910221347g66b25f16va54d22876b4f7bd6@mail.gmail.com> On Thu, Oct 22, 2009 at 9:02 PM, Stefan Monnier wrote: > Can you show me the patches? > Sure, once cvs.haskell.org comes back up. :P It's mostly newer variants of haskell-indentation.el, with a little homegrown code. Well, you can see what I'm currently running at http://brage.info/~svein/haskell-mode/; the other stuff is all the same as what's in CVS. I think. -- Svein Ove Aas From anton at appsolutions.com Thu Oct 22 17:39:44 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Oct 22 17:16:33 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> Message-ID: <4AE0D120.2030304@appsolutions.com> Colin Paul Adams wrote: >>>>>> "Gregory" == Gregory Crosswhite writes: > > Gregory> Yes, I was once taught that "Every time you use > Gregory> unsafePerformIO, God kills a kitten," so every time I > Gregory> consider using it I first ask myself: is this really > Gregory> worth an innocent kitten's life? > > I've changed my mind. > > Everyone go out and use unsafePerformIO all the time. That way we can > get rid of all those mudering kittens, and the dragonflies will live longer. You're missing the bigger picture. It's clear from the literature[*] that the IO monad, the type system, and possibly even Haskell itself, is powered by kittens. If you use up all the kittens, Haskell will just stop working. Terms won't even reach WHNF, they'll be stuck in KAF, Kittenless Abnormal Form. On the plus side, this does make for a slogan with high market appeal: Haskell: Kittens inside -- [*] http://arcanux.org/lambdacats.html From derek.a.elkins at gmail.com Thu Oct 22 17:39:48 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Oct 22 17:16:43 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> Message-ID: <61f84eff0910221439x5a84156v224ca478c2028787@mail.gmail.com> On Thu, Oct 22, 2009 at 1:32 PM, David Menendez wrote: > On Thu, Oct 22, 2009 at 2:23 AM, Gregory Crosswhite > wrote: >> For clarity, one trick that uses "unsafePerformIO" which you may have seen >> posted on this list earlier today is the following way of creating a >> globally visible IORef: >> >> import Data.IORef >> import System.IO.Unsafe >> >> *** counter = unsafePerformIO $ newIORef 0 *** > > Danger! If the monomorphism restriction is disabled, this ends up > creating a value of type forall a. Num a => IORef a, which can be used > to break type safety. > > More generally, > > cell :: IORef a > cell = unsafePerformIO $ newIORef undefined > > unsafeCoerce :: a -> b > unsafeCoerce x = unsafePerformIO $ do > ? ?writeIORef cell x > ? ?readIORef cell > > This way lies segmentation faults. That "unsafe" is there for a reason. This is exactly what happened in the original example. From magicloud.magiclouds at gmail.com Thu Oct 22 19:24:48 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Oct 22 19:01:35 2009 Subject: [Haskell-cafe] NetSnmp problem. In-Reply-To: <20091022153535.GA23495@colquitt.org> References: <3bd412d40910220153p7ee547f6q530ec7e0fbc353e0@mail.gmail.com> <20091022153535.GA23495@colquitt.org> Message-ID: <3bd412d40910221624u5169769fs1825816211c3a9a@mail.gmail.com> Hi, The box is just 32bit with linux. But anyway, I will try out the update. Thanks. On Thu, Oct 22, 2009 at 11:35 PM, John Dorsey wrote: >> ? I am trying to use NetSnmp to get some information from my switch. >> And I met this problem. >> ? After initialize, I used snmpWalk to get some information, and >> dealed with it. Everything is fine. Then I sleep for 5 mins. SnmpWalk >> again. But this time, all asnValues were unsupported format, which >> broke my dealing process. > > Are you on a 64-bit machine? ?I've made an update or two, but haven't pushed > them to Hackage yet... I'll do that today. ?Please let me know if this fixes > your problem. > > John > > -- ??????? ??????? From magicloud.magiclouds at gmail.com Thu Oct 22 23:15:34 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Oct 22 22:52:22 2009 Subject: [Haskell-cafe] NetSnmp problem. In-Reply-To: <3bd412d40910221624u5169769fs1825816211c3a9a@mail.gmail.com> References: <3bd412d40910220153p7ee547f6q530ec7e0fbc353e0@mail.gmail.com> <20091022153535.GA23495@colquitt.org> <3bd412d40910221624u5169769fs1825816211c3a9a@mail.gmail.com> Message-ID: <3bd412d40910222015u7e019cdoa584160060c54f12@mail.gmail.com> It works pretty well. On Fri, Oct 23, 2009 at 7:24 AM, Magicloud Magiclouds wrote: > Hi, > ?The box is just 32bit with linux. But anyway, I will try out the > update. Thanks. > > On Thu, Oct 22, 2009 at 11:35 PM, John Dorsey wrote: >>> ? I am trying to use NetSnmp to get some information from my switch. >>> And I met this problem. >>> ? After initialize, I used snmpWalk to get some information, and >>> dealed with it. Everything is fine. Then I sleep for 5 mins. SnmpWalk >>> again. But this time, all asnValues were unsupported format, which >>> broke my dealing process. >> >> Are you on a 64-bit machine? ?I've made an update or two, but haven't pushed >> them to Hackage yet... I'll do that today. ?Please let me know if this fixes >> your problem. >> >> John >> >> > > > > -- > ??????? > ??????? > -- ??????? ??????? From wren at freegeek.org Fri Oct 23 00:27:39 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Oct 23 00:04:28 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <4AE00E14.7080600@van.steenbergen.nl> References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: <4AE130BB.8010104@freegeek.org> Martijn van Steenbergen wrote: > Bonjour caf?, > >> data ExprF r >> = Add r r >> | Sub r r >> | Mul r r >> | Div r r >> | Num Int > > This is a well-known pattern that for example allows nice notation of > morphisms. But what is it called? I've heard fixed-point view, open > datatypes and some others, but I'm curious where this pattern comes up > in literature and what it is called there. This is an example of "open recursion", which is when you take some recursive function/datatype and rewrite it without recursion by passing the function/type in as an argument to itself. It's the datatype equivalent of doing: fibF _ 0 = 0 fibF _ 1 = 1 fibF f n = f(n-1) + f(n-2) fib = fix fibF Which can be useful for functions because we can use a different fixed-point operator, e.g. one that adds memoization abilities or other features in addition to the recursion. As others've mentioned, the open-recursive version of a recursive data type happens to be a "functor". Or rather, the recursive type happens to be isomorphic to the least fixed point of a generating functor[1][2] because the functor is also, in the terms of recursion theory, an "initial algebra". Part of why this pattern is so nice comes from the fact that it's a functor (so we can use fmap to apply a function one ply down), but part of it also comes from the isomorphism of using an explicit fixed-point operator (which allows us to un-fix the type and do things like storing the accumulators of a fold directly in the normal constructors, rather than needing to come up with an ad-hoc isomorphic set of constructors[3]), and the fact that it's an initial algebra ties these two things together nicely. This is also an example of Tim Sheard's "two-level types", albeit a trivial one since the fixed-point operator doesn't add anything other than recursion. One of the particular ideas behind Sheard's two-level types is that we can split the original recursive type in a different place where one of the levels contains some constructors and the other level contains other constructors. This can be helpful when you have a family (informally speaking) of similar types, as for example with implementing unification. All types that can be unified share constructors for unification variables; but the constructors for the structural components of the type are left up to another level. Thus we can reuse the variable processing code for unifying different types, and also be modular about the type being unified. [1] This should be somewhat obvious if you're familiar with the inductive phrasing of constructing the set of all values for some type. E.g. "Basis: [] is a list. Induction: (:) takes a value and a list into a list". So we have some functor and we keep applying it over and over to generate the set of all values, building up from the base cases. [2] Do note that in Haskell the least fixed point and the greatest fixed point coincide. Technically, whether the least or greatest fixed point is used depends on the construction (e.g. catamorphisms use least, anamorphisms use greatest). This is also related to the topic of "codata" which is the fixed point of a terminal coalgebra. [3] Data.List.unfoldr is a prime example of an ad-hoc isomorphic set of constructors. Instead of the current type, we could instead use an implementation where: newtype Fix f = Fix { unFix :: f (Fix f) } data ListF a r = Nil | Cons a r type List a = Fix (ListF a) unfoldr :: (b -> ListF a b) -> b -> List a unfoldr = ... which is a bit more obviously correlated with anamorphisms in recursion theory. -- Live well, ~wren From ekmett at gmail.com Fri Oct 23 02:00:35 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Oct 23 01:37:22 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <4AE00E14.7080600@van.steenbergen.nl> References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: <7fb8f82f0910222300j5ec32cb5k4b347d70969781f9@mail.gmail.com> I've often seen it referred to as the base functor for a recursive data type. You can then fix that functor in interesting ways i.e. with (Fix, Free, Cofree) and having the explicit base functor allows you to define general purpose recursion schemes over the data type. All of that extra machinery relies on your recursive data type being implemented as a functor with an explicit fixpoint, so base 'functor' seems quite appropriate. -Edward Kmett On Thu, Oct 22, 2009 at 3:47 AM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > Bonjour caf?, > > data ExprF r >> = Add r r >> | Sub r r >> | Mul r r >> | Div r r >> | Num Int >> > > This is a well-known pattern that for example allows nice notation of > morphisms. But what is it called? I've heard fixed-point view, open > datatypes and some others, but I'm curious where this pattern comes up in > literature and what it is called there. > > Thanks, > > Martijn. > _______________________________________________ > 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/20091023/6499492b/attachment.html From martijn at van.steenbergen.nl Fri Oct 23 03:13:32 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 23 02:50:28 2009 Subject: [Haskell-cafe] why cannot i get the value of a IORef variable ? In-Reply-To: <4AE0D120.2030304@appsolutions.com> References: <26004111.post@talk.nabble.com> <4c44d90b0910212225i2cf11223n7ebf034d38c73122@mail.gmail.com> <26004340.post@talk.nabble.com> <5C08B852-1FFB-473E-B40C-756E81BEA9FA@phys.washington.edu> <49a77b7a0910221132r28d2430l38bd477025cfff8d@mail.gmail.com> <1F06F263-0B6E-4EC7-9C7D-064E5C16FB0B@phys.washington.edu> <4AE0D120.2030304@appsolutions.com> Message-ID: <4AE1579C.8080707@van.steenbergen.nl> Anton van Straaten wrote: > On the plus side, this does make for a slogan with high market appeal: > > Haskell: Kittens inside Thanks. Now I have trouble getting this image of lambda-shaped bonsai kittens out of my head. ;-) Martijn. From z_axis at 163.com Fri Oct 23 03:15:01 2009 From: z_axis at 163.com (zaxis) Date: Fri Oct 23 02:51:46 2009 Subject: [Haskell-cafe] Lazy problem ? Message-ID: <26021845.post@talk.nabble.com> "ssqHitNum.txt" contains data as below: 6 7 18 24 30 32 9 4 12 20 25 28 29 16 3 5 11 12 31 32 11 2 9 13 15 19 24 3 5 17 21 25 27 32 14 5 9 15 21 26 31 13 12 16 25 26 27 31 05 ... good_ssq_red:: IO [Int] good_ssq_red = withFile "ssqHitNum.txt" ReadMode (\h -> do { samp <- fmap str2Ints $ hGetContents h; print samp; --without this line, the result will always [1..16] return $ statis samp; }) statis :: [Int] -> [Int] statis samp = take 16 $ map (\(a,b) -> a) $ sortBy (\a b-> if (snd a >= snd b) then LT else GT) $ times4n where times = map (\n -> (foldl (\acc x -> if x==n then acc+1 else acc) 0 samp)) [1..33] times4n = map (\n -> (n,times!!(n-1))) [1..33] Does it mean that the sampe will not be evalued with `print samp` line ? thanks! -- View this message in context: http://www.nabble.com/Lazy-problem---tp26021845p26021845.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From simonpj at microsoft.com Fri Oct 23 03:37:46 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Oct 23 03:14:35 2009 Subject: [Haskell-cafe] FW: Free Pizza, C++, and Haskell Message-ID: <59543203684B2244980D7E4057D5FBC1061B7FDA@DB3EX14MBXC310.europe.corp.microsoft.com> You may enjoy this interesting blog post by Bartosz Milewski about understanding C++ template metaprogramming by starting with Haskell. http://bartoszmilewski.wordpress.com/2009/10/21/what-does-haskell-have-to-do-with-c/ Bartosz gave the talk at the Northwest C++ users group; the video for the talk will be linked eventually on the NWCPP website: http://nwcpp.org/ Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091023/57afdab2/attachment.html From bulat.ziganshin at gmail.com Fri Oct 23 03:48:31 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Oct 23 03:25:31 2009 Subject: [Haskell-cafe] Lazy problem ? In-Reply-To: <26021845.post@talk.nabble.com> References: <26021845.post@talk.nabble.com> Message-ID: <17910550482.20091023114831@gmail.com> Hello zaxis, Friday, October 23, 2009, 11:15:01 AM, you wrote: > good_ssq_red = withFile "ssqHitNum.txt" ReadMode (\h -> do { > samp <- fmap str2Ints $ hGetContents h; > print samp; --without this line, the result will always [1..16] > return $ statis samp; > }) withFile and hGetContents shouldn't be used together. both closes file handle and, here, withFile closes it before hGetContents lazily reads data. it's why you need to force reading with print use readFile instead -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From apfelmus at quantentunnel.de Fri Oct 23 03:59:27 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Oct 23 03:37:21 2009 Subject: [Haskell-cafe] Re: ANN: Data.Stream 0.4 In-Reply-To: References: Message-ID: Bas van Dijk wrote: > 1) What's the difference between your: > "tail ~(Cons _ xs) = xs" > and the more simple: > "tailStrict (Cons _ xs) = xs" ? > > I know they're desugared to: > "tail ys = let Cons _ xs = ys in xs" > and: > "tailStrict ys = case ys of Cons _ xs -> xs" respectively. > > But aren't they operationally the same: > > "tail undefined = undefined" > and: > "tailStrict undefined = undefined" I concur, a strict tail is enough. Writing foo xs = bar (tail xs) has the same effect as foo xs = bar (tailStrict xs) since the evaluation of xs is deferred in both cases. Regards, apfelmus -- http://apfelmus.nfshost.com From z_axis at 163.com Fri Oct 23 04:02:57 2009 From: z_axis at 163.com (zaxis) Date: Fri Oct 23 03:39:44 2009 Subject: [Haskell-cafe] Lazy problem ? In-Reply-To: <17910550482.20091023114831@gmail.com> References: <26021845.post@talk.nabble.com> <17910550482.20091023114831@gmail.com> Message-ID: <26022301.post@talk.nabble.com> good_ssq_red:: IO [Int] good_ssq_red =do { samp <- fmap str2Ints $ readFile "ssqHitNum.txt"; return $ statis samp; } It works now ! thank you Bulat Ziganshin-2 wrote: > > Hello zaxis, > > Friday, October 23, 2009, 11:15:01 AM, you wrote: > >> good_ssq_red = withFile "ssqHitNum.txt" ReadMode (\h -> do { >> samp <- fmap str2Ints $ hGetContents h; >> print samp; --without this line, the result will always >> [1..16] >> return $ statis samp; >> }) > > withFile and hGetContents shouldn't be used together. both closes file > handle and, here, withFile closes it before hGetContents lazily reads > data. it's why you need to force reading with print > > use readFile instead > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Lazy-problem---tp26021845p26022301.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Fri Oct 23 04:09:22 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Oct 23 03:46:22 2009 Subject: [Haskell-cafe] Lazy problem ? In-Reply-To: <26022301.post@talk.nabble.com> References: <26021845.post@talk.nabble.com> <17910550482.20091023114831@gmail.com> <26022301.post@talk.nabble.com> Message-ID: <1368274963.20091023120922@gmail.com> Hello zaxis, Friday, October 23, 2009, 12:02:57 PM, you wrote: btw, good_ssq_red = fmap (statis.str2Ints) $ readFile "ssqHitNum.txt" or good_ssq_red = (statis.str2Ints) `fmap` readFile "ssqHitNum.txt" > good_ssq_red:: IO [Int] > good_ssq_red =do { > samp <- fmap str2Ints $ readFile "ssqHitNum.txt"; > return $ statis samp; > } > It works now ! thank you > Bulat Ziganshin-2 wrote: >> >> Hello zaxis, >> >> Friday, October 23, 2009, 11:15:01 AM, you wrote: >> >>> good_ssq_red = withFile "ssqHitNum.txt" ReadMode (\h -> do { >>> samp <- fmap str2Ints $ hGetContents h; >>> print samp; --without this line, the result will always >>> [1..16] >>> return $ statis samp; >>> }) >> >> withFile and hGetContents shouldn't be used together. both closes file >> handle and, here, withFile closes it before hGetContents lazily reads >> data. it's why you need to force reading with print >> >> use readFile instead >> >> >> >> -- >> Best regards, >> Bulat mailto:Bulat.Ziganshin@gmail.com >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From apfelmus at quantentunnel.de Fri Oct 23 04:21:03 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Oct 23 03:58:09 2009 Subject: [Haskell-cafe] Re: Time and space complexity of "take k . sort" In-Reply-To: <4AE080F8.8050308@cogito.org.uk> References: <4AE06CDB.6060203@cogito.org.uk> <4AE080F8.8050308@cogito.org.uk> Message-ID: Paul Johnson wrote: > Paul Johnson wrote: >> >> > takeLargest k = take k . sort >> >> Because "sort" is lazily evaluated this only does enough sorting to >> find the first k elements. I guess the complexity is something like >> O(n*k*log(k)). >> > Correction: O(n*log(k)) It's O(n + k log k) (which is the same as O(n + k log n) ): http://apfelmus.nfshost.com/quicksearch.html The remark about O(k) space complexity of the other algorithm is interesting, since this means that it's not even allowed to copy its argument of size O(n) . Regards, apfelmus -- http://apfelmus.nfshost.com From gcross at phys.washington.edu Fri Oct 23 04:39:14 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Fri Oct 23 04:16:18 2009 Subject: [Haskell-cafe] Lazy problem ? In-Reply-To: <1368274963.20091023120922@gmail.com> References: <26021845.post@talk.nabble.com> <17910550482.20091023114831@gmail.com> <26022301.post@talk.nabble.com> <1368274963.20091023120922@gmail.com> Message-ID: Or good_ssq_red = readFile "ssqHitNum.txt" >>= return . statis . str2Ints I personally prefer this because I like how the >>= illustrates that the result is being fed into "return . statis . str2Ints", but it is a matter of style. :-) Cheers, Greg On Oct 23, 2009, at 1:09 AM, Bulat Ziganshin wrote: > Hello zaxis, > > Friday, October 23, 2009, 12:02:57 PM, you wrote: > > btw, > > good_ssq_red = fmap (statis.str2Ints) $ readFile "ssqHitNum.txt" > > or > > good_ssq_red = (statis.str2Ints) `fmap` readFile "ssqHitNum.txt" > > >> good_ssq_red:: IO [Int] >> good_ssq_red =do { >> samp <- fmap str2Ints $ readFile "ssqHitNum.txt"; >> return $ statis samp; >> } >> It works now ! thank you > > >> Bulat Ziganshin-2 wrote: >>> >>> Hello zaxis, >>> >>> Friday, October 23, 2009, 11:15:01 AM, you wrote: >>> >>>> good_ssq_red = withFile "ssqHitNum.txt" ReadMode (\h -> do { >>>> samp <- fmap str2Ints $ hGetContents h; >>>> print samp; --without this line, the result will always >>>> [1..16] >>>> return $ statis samp; >>>> }) >>> >>> withFile and hGetContents shouldn't be used together. both closes >>> file >>> handle and, here, withFile closes it before hGetContents lazily >>> reads >>> data. it's why you need to force reading with print >>> >>> use readFile instead >>> >>> >>> >>> -- >>> Best regards, >>> Bulat mailto:Bulat.Ziganshin@gmail.com >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> > > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From magicloud.magiclouds at gmail.com Fri Oct 23 04:58:58 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Oct 23 04:35:46 2009 Subject: [Haskell-cafe] TimeZone bug? Message-ID: <3bd412d40910230158g268fc75do3044be3a70417c81@mail.gmail.com> Hi, As we know, "CST" could mean both +8 or -6 time zone. So I got a problem. In the same envoironment. When a ZonedTime is shown, I got "xxxxx CST". Now it means +8 time zone. Then I read it, stupidly, it turns into -6 time zone. How could I fix this? I am using ghc 6.10.4 in rhel 5. -- ??????? ??????? From martijn at van.steenbergen.nl Fri Oct 23 05:49:12 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Oct 23 05:26:02 2009 Subject: [Haskell-cafe] What's this pattern called? In-Reply-To: <4AE00E14.7080600@van.steenbergen.nl> References: <4AE00E14.7080600@van.steenbergen.nl> Message-ID: <4AE17C18.9080003@van.steenbergen.nl> Thanks for all the pointers, guys. You've been very helpful. I also found Type-indexed data types (Hinze et al) to be a good source. Much appreciated! Martijn. Martijn van Steenbergen wrote: >> data ExprF r From wss at Cs.Nott.AC.UK Fri Oct 23 06:47:07 2009 From: wss at Cs.Nott.AC.UK (Wouter Swierstra) Date: Fri Oct 23 06:23:55 2009 Subject: [Haskell-cafe] ANN: Data.Stream 0.4 In-Reply-To: References: Message-ID: > 1) What's the difference between your: > "tail ~(Cons _ xs) = xs" > and the more simple: > "tailStrict (Cons _ xs) = xs" ? I'm no expert - but I can't think of any difference at all. > 2) Why don't you also use an irrefutable pattern in "take"? "take" is > now defined as: This is a trickier question: should "take 0 undefined" by [] or undefined? I'm not sure what the best choice is. I suppose it makes sense to stick with the behaviour of Data.List and return an empty list, even if any program that relies on this not being undefined is probably broken. I've uploaded a new version. Thanks for your comments! Wouter From steen.reem at gmail.com Fri Oct 23 06:53:00 2009 From: steen.reem at gmail.com (steenreem) Date: Fri Oct 23 06:29:45 2009 Subject: [Haskell-cafe] Newbie has trouble using QuickCheck Message-ID: <26024248.post@talk.nabble.com> Hello. I have made a simple test.hs file that imports the module QuickCheck. However, when I load this module in ghci, it says that the module QuickCheck is not found. I have looked in my haskell platform folder and find the folder "QuickCheck 1.2.0.0". I also tried to :set -package QuickCheck. This added QuickCheck to the list of loaded packages. However when loading my test module it still says "Could not find module QuickCheck". Locations searched were "QuickCheck.hs" and "QuickCheck.lhs" What's wrong? Thanks, Remy. -- View this message in context: http://www.nabble.com/Newbie-has-trouble-using-QuickCheck-tp26024248p26024248.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lazycat.manatee at gmail.com Fri Oct 23 06:13:11 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Fri Oct 23 06:48:22 2009 Subject: [Haskell-cafe] Help me improve design of my project. Message-ID: <87tyxq8ll4.fsf@ubuntu.domain> Hi all, I develop some Haskell IDE, below is screenshots: http://farm4.static.flickr.com/3483/3947340553_933df88a22_o.png http://farm3.static.flickr.com/2628/3952175905_9295a7421a_o.png http://farm3.static.flickr.com/2544/3957610799_70fab5eb57_o.png http://farm3.static.flickr.com/2703/4016163374_493e3738c7_o.png Below is source code. -------------- next part -------------- A non-text attachment was scrubbed... Name: manatee-0.8.8.tar.gz Type: application/octet-stream Size: 63786 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091023/0a6f9d76/manatee-0.8.8.tar-0001.obj -------------- next part -------------- You only can compile it with darcs version of gtk2hs. The simple usage is press `F4` open terminal, then press `F7` to type file-path for open. Now is really simple, now i haven't stable time maintain project, so i will opensource my project when i have stable time. Okay, question is, IORefObject module and most module reference each other, so i will got `recursive reference problem` (looks how many .hs-boot in my project). So anyone can help me improve design to split IORefObject and other modules, make them less depend? Thanks, -- Andy From vandijk.roel at gmail.com Fri Oct 23 07:29:06 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Fri Oct 23 07:05:53 2009 Subject: [Haskell-cafe] Newbie has trouble using QuickCheck In-Reply-To: <26024248.post@talk.nabble.com> References: <26024248.post@talk.nabble.com> Message-ID: > What's wrong? The package is called "QuickCheck". The package consists of a number of modules. The main module is called "Test.QuickCheck". So import Test.QuickCheck should bring all relevant symbols in scope. From duncan.coutts at googlemail.com Fri Oct 23 09:00:55 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Oct 23 08:37:41 2009 Subject: [Haskell-cafe] Time Typeable Instances In-Reply-To: <4AD48524.1080209@complete.org> References: <4AD3DD3C.7050703@complete.org> <4AD48524.1080209@complete.org> Message-ID: <1256302855.4920.1641.camel@localhost> On Tue, 2009-10-13 at 08:48 -0500, John Goerzen wrote: > Now I'm getting complaints from people using 6.10.4 saying that there > are now missing instances of Typeable with time 1.1.2.4. Right, because 1.1.2.4 is an earlier version than 1.1.3 which is the random intermediate snapshot version included in the ghc-6.10.3 extralibs collection and the version where the Typable instances were added. So the problem you're noticing is that some people are using 1.1.2.4 and others are using 1.1.3 or 1.1.4 and these are not related to the version of ghc that they are using, so using the ghc version as a proxy fails. > 1) Did the Typeable instances get dropped again from time? No. > 2) What exactly should I do so this library compiles on GHC 6.8 and 6.10.x? Depend on the time library and use one of the following techniques: If you're prepared to depend on Cabal-1.6 then you can use the cpp macros that let you do conditional compilation on the version of a package you depend on. You mention that the time only incremented the 4th digit when it added the instances but I don't think that's right. My time-1.1.2.4 has no Typeable instances but 1.1.4 does (and I believe 1.1.3 did too). So you should be able to use this mechanism. Alternatively you can use the "flag hack" in the .cabal file: flag annoying-time-instances library ... if flag(annoying-time-instances) build-depends: time >= 1.1.3 else build-depends: time < 1.1.3 cpp-options: -DUSE_OWN_TIME_TYPABLE_INSTANCES > so it appears that what's happening here is that GHC 6.10.3 extralibs > included time 1.1.3, but then haskell-platform standardized on 1.1.2.4. > This is pretty annoying -- that haskell-platform would standardize on a > version older than what shipped with a GHC release -- but I guess I can > work around it by restricting my build-dep to be time < 1.1.3 and > re-adding the instances. No, it's the haskell-platform that was and is doing the right thing and it is ghc that subsequently accidentally shipped a random development snapshot. The platform has a commitment to provide API compatible versions of packages within a major series. The first release of the platform used time-1.1.2.4 (along with ghc-6.10.2) and thus it could not include the time-1.1.3 that the subsequent release of ghc-6.10.3 accidentally included. Duncan From bugfact at gmail.com Fri Oct 23 09:42:14 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Oct 23 09:19:00 2009 Subject: [Haskell-cafe] FW: Free Pizza, C++, and Haskell In-Reply-To: <59543203684B2244980D7E4057D5FBC1061B7FDA@DB3EX14MBXC310.europe.corp.microsoft.com> References: <59543203684B2244980D7E4057D5FBC1061B7FDA@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: Nice article from Bartosz , thanks for sharing this. The best comment (and oh so true IMO) on his article is: "I agree, however, a little more familiarity than that may result in the desire never to see another line of C++ again, so you have to be careful." Although learning Haskell improved my programming skills greatly, it also took away some of the "joy" I had in other programming languages like C++. C# 3.0 & 4.0 are the exception, it offers just the right balance for me (maybe F# or Scala too, I don't have enough