From evohunz at gmail.com Tue Jan 1 01:54:39 2013 From: evohunz at gmail.com (Thiago Negri) Date: Mon, 31 Dec 2012 22:54:39 -0200 Subject: [Haskell-cafe] Handling Joystick with GLFW Message-ID: I'm trying to handle my usb controller (xbox model) via GLFW. I can get it's input, but I see a strange behaviour in my sample application that I couldn't explain. Can you enlight me please? If I disable automatic event polling on buffer swapping (line "A"), the screen content is refreshed but OS part is unresposive: I can't resize, move, etc. With automatic event polling enabled, everything is fine. I tried disabling automatic event polling and calling "waitEvents" (line "B") before refreshing the screen. But, changes to the joystick input do not generate any event, so I need to move the mouse or type a key to release "waitEvents" call. What am I missing? I'm using Windows 7 64-bit. The code is available here: http://hpaste.org/80031 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dag.odenhall at gmail.com Tue Jan 1 02:05:00 2013 From: dag.odenhall at gmail.com (dag.odenhall at gmail.com) Date: Tue, 1 Jan 2013 02:05:00 +0100 Subject: [Haskell-cafe] Backtracking in HXT In-Reply-To: <50E1A2DB.4010801@fuuzetsu.co.uk> References: <50E1A2DB.4010801@fuuzetsu.co.uk> Message-ID: Use arrow notation and zeroArrow, like so: {-# LANGUAGE Arrows #-} import Text.XML.HXT.Core getA = hasName "a" >>> proc elem -> do text <- getText <<< getChildren -< elem if text == "Hello Two!" then getAttrValue "href" -< elem else zeroArrow -< () >>> runX $ readString [] "Hello One!Hello Two!" >>> deep getA ["example.com/anotherlink.html"] On Mon, Dec 31, 2012 at 3:36 PM, Mateusz Kowalczyk wrote: > Hello, > I'm not sure if this is the right place to ask this but here goes. > > I'm currently working with HXT and I quite like it. There's one issue I > can't solve (at least now without some dirty, dirty hacking) and I'm > sure it's fairly simple. > > Consider the following mark-up > > Hello > One! > Hello > Two! > > Now, what I'm trying to achieve is to get the href based on the text. I > can test for what the text is by traversing s, then using the > getChildren >>> getText arrow. What I can't figure out is how to check > the text and then get the href as by the time I get to the text, I'll > further down the tree! > > I imagine it would look something along the lines of > (getChildren >>> getText "Hello Two") `guards` getAttrValue > "href". is just a random operator I made up for illustration > purposes that works as a predicate over arrows. > > Is this the right approach? Is there a built-in that already does what I > want? It > seems like a common task... > > Mateusz Kowalczyk > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dag.odenhall at gmail.com Tue Jan 1 02:08:00 2013 From: dag.odenhall at gmail.com (dag.odenhall at gmail.com) Date: Tue, 1 Jan 2013 02:08:00 +0100 Subject: [Haskell-cafe] Backtracking in HXT In-Reply-To: References: <50E1A2DB.4010801@fuuzetsu.co.uk> Message-ID: (">>>" is my GHCi prompt, might be a bit confusing for an arrow example.) On Tue, Jan 1, 2013 at 2:05 AM, dag.odenhall at gmail.com < dag.odenhall at gmail.com> wrote: > Use arrow notation and zeroArrow, like so: > > {-# LANGUAGE Arrows #-} > import Text.XML.HXT.Core > getA = > hasName "a" >>> proc elem -> do > text <- getText <<< getChildren -< elem > if text == "Hello Two!" > then getAttrValue "href" -< elem > else zeroArrow -< () > > >>> runX $ readString [] "Hello > One!Hello Two!" >>> > deep getA > ["example.com/anotherlink.html"] > > > > On Mon, Dec 31, 2012 at 3:36 PM, Mateusz Kowalczyk < > fuuzetsu at fuuzetsu.co.uk> wrote: > >> Hello, >> I'm not sure if this is the right place to ask this but here goes. >> >> I'm currently working with HXT and I quite like it. There's one issue I >> can't solve (at least now without some dirty, dirty hacking) and I'm >> sure it's fairly simple. >> >> Consider the following mark-up >> >> Hello >> One! >> Hello >> Two! >> >> Now, what I'm trying to achieve is to get the href based on the text. I >> can test for what the text is by traversing s, then using the >> getChildren >>> getText arrow. What I can't figure out is how to check >> the text and then get the href as by the time I get to the text, I'll >> further down the tree! >> >> I imagine it would look something along the lines of >> (getChildren >>> getText "Hello Two") `guards` getAttrValue >> "href". is just a random operator I made up for illustration >> purposes that works as a predicate over arrows. >> >> Is this the right approach? Is there a built-in that already does what I >> want? It >> seems like a common task... >> >> Mateusz Kowalczyk >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivanperezdominguez at gmail.com Tue Jan 1 13:13:22 2013 From: ivanperezdominguez at gmail.com (Ivan Perez) Date: Tue, 1 Jan 2013 14:13:22 +0200 Subject: [Haskell-cafe] [Haskell-beginners] ghc and android In-Reply-To: References: <50E03F64.3080601@posteo.de> <50E194E2.5020900@posteo.de> Message-ID: Nathan, David is right. Using the x86 Android image in a VM could be fast enough (if you computer has virtualization support) I haven't tried to compile GHC for android myself. At the present time, and taking into account that it would probably be slow to execute and lack all the interesting libraries that I would like to use, other FP languages may be better choices. Please, let us know if you manage to compile it. Cheers, Ivan On 31 December 2012 19:04, David Thomas wrote: > Couldn't that simply be simulated? > > > On Mon, Dec 31, 2012 at 2:36 PM, Nathan H?sken > wrote: >> >> That seems almost impossible, I would need an android device with unusual >> capacity. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lemming at henning-thielemann.de Tue Jan 1 13:41:40 2013 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue, 01 Jan 2013 13:41:40 +0100 (CET) Subject: [Haskell-cafe] [Haskell] ANNOUNCE: graphviz-2999.15.0.0 In-Reply-To: References: Message-ID: On Tue, 1 Jan 2013, Ivan Lazar Miljenovic wrote: > After much prodding and poking by end-users for the past few months, > I'm finally able to announce a GHC-7.6.1 compatible release of my > Haskell bindings to the Graphviz graph visualisation toolkit: > http://hackage.haskell.org/package/graphviz-2999.15.0.0 Did you receive my work-around for the busy-wait problem? From fuuzetsu at fuuzetsu.co.uk Tue Jan 1 14:25:11 2013 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Tue, 01 Jan 2013 13:25:11 +0000 Subject: [Haskell-cafe] Backtracking in HXT In-Reply-To: References: <50E1A2DB.4010801@fuuzetsu.co.uk> Message-ID: <50E2E3B7.4030500@fuuzetsu.co.uk> Ah, zeroArrow looks exactly like what I need here! Thanks, this helps. Mateusz Kowalczyk On 01/01/13 01:08, dag.odenhall at gmail.com wrote: > (">>>" is my GHCi prompt, might be a bit confusing for an arrow example.) > > > On Tue, Jan 1, 2013 at 2:05 AM, dag.odenhall at gmail.com > > wrote: > > Use arrow notation and zeroArrow, like so: > > {-# LANGUAGE Arrows #-} > import Text.XML.HXT.Core > getA = > hasName "a" >>> proc elem -> do > text <- getText <<< getChildren -< elem > if text == "Hello Two!" > then getAttrValue "href" -< elem > else zeroArrow -< () > > >>> runX $ readString [] " href='example.com/somelink.html > '>Hello One! href='example.com/anotherlink.html > '>Hello Two!" >>> > deep getA > ["example.com/anotherlink.html "] > > > > On Mon, Dec 31, 2012 at 3:36 PM, Mateusz Kowalczyk > > wrote: > > Hello, > I'm not sure if this is the right place to ask this but here goes. > > I'm currently working with HXT and I quite like it. There's > one issue I > can't solve (at least now without some dirty, dirty hacking) > and I'm > sure it's fairly simple. > > Consider the following mark-up > > Hello One! > Hello Two! > > Now, what I'm trying to achieve is to get the href based on > the text. I > can test for what the text is by traversing s, then using the > getChildren >>> getText arrow. What I can't figure out is how > to check > the text and then get the href as by the time I get to the > text, I'll > further down the tree! > > I imagine it would look something along the lines of > (getChildren >>> getText "Hello Two") `guards` getAttrValue > "href". is just a random operator I made up for illustration > purposes that works as a predicate over arrows. > > Is this the right approach? Is there a built-in that already > does what I want? It > seems like a common task... > > Mateusz Kowalczyk > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lewurm at gmail.com Tue Jan 1 15:13:54 2013 From: lewurm at gmail.com (Bernhard Urban) Date: Tue, 1 Jan 2013 15:13:54 +0100 Subject: [Haskell-cafe] [Haskell-beginners] ghc and android In-Reply-To: References: <50E03F64.3080601@posteo.de> <50E194E2.5020900@posteo.de> Message-ID: On Tue, Jan 1, 2013 at 1:13 PM, Ivan Perez wrote: > Please, let us know if you manage to compile it. There are some comments regarding porting git-annex to android, in order to make it useable from shell (that is, not as android app). http://git-annex.branchable.com/design/assistant/android/ The main issue: The GHC runtime relies on glibc, which is not used on android. Also, glibc cannot be (fully) linked statically. Probably someone with more knowledge about GHC internals and glibc can came up with a clean solution to this problem. > An additional issue: ghci (and Template Haskell because it uses the > bytecode interpreter of ghci internally) currently(?) requires its own > custom linker instead of being able to use the system linker. Said linker > has no support for ARM. The correct fix for this is to redesign ghci so it > doesn't need its own linker; there has been some work in this direction, > but I don't know how complete it is, and it interacts with other issues > such as building Haskell libraries as shared objects. http://www.haskell.org/pipermail/glasgow-haskell-users/2012-December/023163.html I don't know the situation on ARM though. I added ghc-users mailinglist to CC. Regards, Bernhard From allbery.b at gmail.com Tue Jan 1 15:41:54 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 1 Jan 2013 09:41:54 -0500 Subject: [Haskell-cafe] [Haskell-beginners] ghc and android In-Reply-To: References: <50E03F64.3080601@posteo.de> <50E194E2.5020900@posteo.de> Message-ID: On Tue, Jan 1, 2013 at 9:13 AM, Bernhard Urban wrote: > The main issue: The GHC runtime relies on glibc > I have to assume this is not meant literally, because ghc works on OS X and *BSD. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From blake.rain at gmail.com Tue Jan 1 17:19:38 2013 From: blake.rain at gmail.com (Blake Rain) Date: Tue, 1 Jan 2013 16:19:38 +0000 Subject: [Haskell-cafe] Mancunian Haskellers out there? In-Reply-To: References: <50E0568B.8080507@fuuzetsu.co.uk> Message-ID: Hi Alfredo, I live in Leeds, which is not far from Manchester. I'd be up for a user group nearby, so will +1 your user group :) Cheers, On 30 December 2012 15:15, Alfredo Di Napoli wrote: > Hey, thanks for the response :) > Mine was more a small survey to see if we are enough to think about > creating a small user group and see each other once a month or whenever :) > > Cheers, > A. > > > On 30 December 2012 15:58, Mateusz Kowalczyk wrote: > >> Greetings, >> I'm currently residing in Bury, a metrolink ride away from Manchester. >> Unfortunately, I'm only here for Christmas holidays and am leaving tomorrow >> so a meeting is unlikely. I don't think that I'd be a good conversation >> partner anyway as my knowledge is still quite limited. >> >> I'd love to hear whether you find any other people though. It would be >> nice if some Haskell talks could be held in the area if there are enough >> people. >> >> Good luck on your search, >> Mateusz Kowalczyk >> >> >> On 30/12/12 14:38, Alfredo Di Napoli wrote: >> >> Morning Cafe, >> >> I've been living in Manchester for 1 month now and I'm wondering if >> some on you are from the Greater Manchester area, so that we could chat >> about out beloved language in front of a glass of ale / tea :P >> >> Happy new year to everyone! >> A. >> >> >> _______________________________________________ >> Haskell-Cafe mailing listHaskell-Cafe at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hutch-lists at recursive.ca Tue Jan 1 17:53:42 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Tue, 1 Jan 2013 11:53:42 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: Message-ID: On 2012-12-31, at 4:26 PM, Rico Moorman wrote: > Hello Bob and Mike, > > Reading a little within the suggested book I came across the following statement. > > We should first examine the merits and limitations of the traditional approach: using > functions as a basis for the architecture of software systems. This will not only lead us to > appreciate why we need something else ? object technology ? but also help us avoid, > when we do move into the object world, certain methodological pitfalls such as premature > operation ordering, which have been known to fool even experienced O-O developers. > > Because you both have more experience with this piece of literature, how would you interpret it? With a grain of salt or would function really mean procedure from the viewpoint of the author? He is talking about functions/procedures as in C, Pascal, Algol? structured programming basically. The first edition was written in 1988, the second about 10 years later. However, today, I *think* he might include functions as found in modern functional languages in this, and as you read on in the book you'll see why I say this. I've been considering re-reading OOSC2 for a while now (it is, believe it or not, a fun book? well, maybe that's just me) and keep Haskell and ML in mind while reading it. Meyer is trying to thoroughly explain the reasoning behind OO in this book, it isn't really a critique of anything especially (except indirectly other OO languages). Meyer can be scathing but you'll have to look elsewhere for the best/worst/most fun of that. Haskell, as it matures, is going to have to have an answer for everything in this book (answers may include 'pass' as Meyer does with Eiffel on a few issues?there's no shame in admitting Haskell, or anything else, doesn't have all the answers)? he's talking about issues that are independent of programming language. Cheers, Bob > > Thank you very much in advance. > > Best regards, > > Rico Moorman > > On Mon, Dec 31, 2012 at 6:13 PM, Bob Hutchison wrote: > On 2012-12-30, at 2:58 PM, Daniel D?az Casanueva wrote: > >> Well, my curiosity is bringing me to learn a new general purpose programming language. Haskellers are frequently comparing Object-Oriented languages with Haskell itself, but I have never programmed in any OO-language! (perhaps this is an uncommon case) I thought it could be good to me (as a programmer) to learn C/C++. Many interesting courses (most of them) use these languages and I feel like limited for being a Haskell programmer. It looks like I have to learn imperative programming (with side effects all over around) in some point of my programming life. >> >> So my questions for you all are: >> >> * Is it really worthwhile for me to learn OO-programming? > > Yes. And you should learn OO *very* well. And remember, OO doesn't really get interesting until the program gets big. > > As for languages I'd suggest Smalltalk or Eiffel, perhaps both. The big advantage to Eiffel is that you have Object Oriented Software Construction (second edition (not first)) to work from. Every OO language has to answer to the issues brought up in OOSC2 (and they don't/can't). Eiffel's inheritance mechanism is also one of the few that let you use inheritance to do useful things (OOSC2 names 16 or 18 different uses for inheritance? it's not just for 'is-a' relationships). Eiffel also has a contract system that's powerful enough to be useful. Smalltalk's advantage is that it will also introduce you to the idea of a programming 'system', for lack of better words. Smalltalk works in a live system, as you are writing code you are modifying live and already executing code. Once you realize that the 'best' editor in Smalltalk is the debugger (and what 'a good debugger' actually means) you'll understand test-driven-development's origins. This is very different from Haskell. Actually, you should probably learn both languages. > > I don't think C++ will help you learn OO, or much of anything else either. Vigorously avoid is my advice. > > C you're probably going to have to learn sooner or later but wait until you have to. And it's not OO at all. Though, if you learn K&R C (pre-ansi C) you'll get a better understanding of why people liked OO so much :-) > > Ruby might be an easy route to OO too. I like the language quite a lot, but I'm not sure I'd recommend it for your purposes. > > >> >> * If so, where should I start? There are plenty of "functional programming for OO programmers" but I have never seen "OO programming for functional programmers". >> >> * Is it true that learning other programming languages leads to a better use of your favorite programming language? > > That's been my experience. And it'll be harder to name your favourite language too. > > >> >> * Will I learn new programming strategies that I can use back in the Haskell world? > > Probably. > > Cheers, > Bob > >> >> Thanks in advance for your kind responses, >> Daniel D?az. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arthur at clune.org Tue Jan 1 18:28:50 2013 From: arthur at clune.org (Arthur Clune) Date: Tue, 1 Jan 2013 17:28:50 +0000 Subject: [Haskell-cafe] Mancunian Haskellers out there? In-Reply-To: References: <50E0568B.8080507@fuuzetsu.co.uk> Message-ID: I'm in York and would love to meet up Arthur -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.turner at tracsis.com Tue Jan 1 18:55:05 2013 From: d.turner at tracsis.com (David Turner) Date: Tue, 01 Jan 2013 17:55:05 +0000 Subject: [Haskell-cafe] Mancunian Haskellers out there? In-Reply-To: References: <50E0568B.8080507@fuuzetsu.co.uk> Message-ID: <50E322F9.70900@tracsis.com> On 01/01/2013 16:19, Blake Rain wrote: > Hi Alfredo, > > I live in Leeds, which is not far from Manchester. I'd be up for a user > group nearby, so will +1 your user group :) Similarly for me - I'm Leeds based and would be interested in joining in. Please sign me up! Cheers, David T > > Cheers, > > > On 30 December 2012 15:15, Alfredo Di Napoli > wrote: > > Hey, thanks for the response :) > Mine was more a small survey to see if we are enough to think about > creating a small user group and see each other once a month or > whenever :) > > Cheers, > A. > > > On 30 December 2012 15:58, Mateusz Kowalczyk > > wrote: > > Greetings, > I'm currently residing in Bury, a metrolink ride away from > Manchester. Unfortunately, I'm only here for Christmas holidays > and am leaving tomorrow so a meeting is unlikely. I don't think > that I'd be a good conversation partner anyway as my knowledge > is still quite limited. > > I'd love to hear whether you find any other people though. It > would be nice if some Haskell talks could be held in the area if > there are enough people. > > Good luck on your search, > Mateusz Kowalczyk > > > On 30/12/12 14:38, Alfredo Di Napoli wrote: >> Morning Cafe, >> >> I've been living in Manchester for 1 month now and I'm >> wondering if some on you are from the Greater Manchester area, >> so that we could chat about out beloved language in front of a >> glass of ale / tea :P >> >> Happy new year to everyone! >> A. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- David Turner Senior Consultant Tracsis PLC Tracsis PLC is a company registered in England and Wales with number 5019106. From alfredo.dinapoli at gmail.com Tue Jan 1 19:03:07 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Tue, 1 Jan 2013 19:03:07 +0100 Subject: [Haskell-cafe] Mancunian Haskellers out there? In-Reply-To: <50E322F9.70900@tracsis.com> References: <50E0568B.8080507@fuuzetsu.co.uk> <50E322F9.70900@tracsis.com> Message-ID: Wow guys, that's a great news! I have no experience with User Groups or sites like Meetup (the only think I know is that a small contribution fee is required to create a Meetup), do you have any? Basically I think the trickiest part would be to find a place to keep the meetings: I could ask to my employer, but it's unlikely it would gives us permission to use company's premises outside working hours. Any idea? Happy new year! A. On 1 January 2013 18:55, David Turner wrote: > On 01/01/2013 16:19, Blake Rain wrote: > >> Hi Alfredo, >> >> I live in Leeds, which is not far from Manchester. I'd be up for a user >> group nearby, so will +1 your user group :) >> > > Similarly for me - I'm Leeds based and would be interested in joining in. > Please sign me up! > > Cheers, > > David T > > >> Cheers, >> >> >> On 30 December 2012 15:15, Alfredo Di Napoli > >> >> wrote: >> >> Hey, thanks for the response :) >> Mine was more a small survey to see if we are enough to think about >> creating a small user group and see each other once a month or >> whenever :) >> >> Cheers, >> A. >> >> >> On 30 December 2012 15:58, Mateusz Kowalczyk >> >> >> wrote: >> >> Greetings, >> I'm currently residing in Bury, a metrolink ride away from >> Manchester. Unfortunately, I'm only here for Christmas holidays >> and am leaving tomorrow so a meeting is unlikely. I don't think >> that I'd be a good conversation partner anyway as my knowledge >> is still quite limited. >> >> I'd love to hear whether you find any other people though. It >> would be nice if some Haskell talks could be held in the area if >> there are enough people. >> >> Good luck on your search, >> Mateusz Kowalczyk >> >> >> On 30/12/12 14:38, Alfredo Di Napoli wrote: >> >>> Morning Cafe, >>> >>> I've been living in Manchester for 1 month now and I'm >>> wondering if some on you are from the Greater Manchester area, >>> so that we could chat about out beloved language in front of a >>> glass of ale / tea :P >>> >>> Happy new year to everyone! >>> A. >>> >>> >>> ______________________________**_________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> > >>> http://www.haskell.org/**mailman/listinfo/haskell-cafe >>> >> >> >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> > >> >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> >> >> >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> >> > > -- > David Turner > Senior Consultant > Tracsis PLC > > Tracsis PLC is a company registered in > England and Wales with number 5019106. > > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From leon.v.nikitin at pravmail.ru Tue Jan 1 19:23:24 2013 From: leon.v.nikitin at pravmail.ru (=?koi8-r?B?7snLydTJziDsxdc=?=) Date: Wed, 02 Jan 2013 01:23:24 +0700 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: Message-ID: <299851357064604@web26e.yandex.ru> An HTML attachment was scrubbed... URL: From miguelimo38 at yandex.ru Tue Jan 1 19:49:34 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Tue, 1 Jan 2013 22:49:34 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <299851357064604@web26e.yandex.ru> References: <299851357064604@web26e.yandex.ru> Message-ID: <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> On Jan 1, 2013, at 10:23 PM, ??????? ??? wrote: > Eiffel, for my opinion, is a best OOP language. Meyer use a theoretical approach as it is possible in OOP. Really? Because when I studied it I had a very different impression: that behind this language there was no theory at all. And it's only feature I remember that is not present in mainstream languages is it's pre/postconditions system, which looked like an ugly hack for me. Of course, my memory could fail me, but I doubt my tutorial did; I remember it being written by Meyer himself. From rendel at informatik.uni-marburg.de Tue Jan 1 20:36:02 2013 From: rendel at informatik.uni-marburg.de (Tillmann Rendel) Date: Tue, 01 Jan 2013 20:36:02 +0100 Subject: [Haskell-cafe] lambda case (was Re: A big hurray for lambda-case (and all the other good stuff)) In-Reply-To: References: <20121229190245.GE7688@weber> Message-ID: <50E33AA2.5060409@informatik.uni-marburg.de> Hi, Brandon Allbery wrote: >>> [...] syntax extension [...] > > I think someone's already working on this (SugarHaskell?). Yes, we are working on it. See our paper [1] and Sebastian's talk [2] at the Haskell Symposium. Our current prototype can be installed as an Eclipse plugin [3] or as a command-line tool [4]. [1] http://sugarj.org/sugarhaskell.pdf [2] http://www.youtube.com/watch?v=Kjm7bOLnuy0 [3] http://update.sugarj.org/ [4] http://hackage.haskell.org/package/sugarhaskell One use case we have in mind for SugarHaskell is prototyping of language extensions like the one discussed in this thread. Tillmann From mwm at mired.org Tue Jan 1 20:41:13 2013 From: mwm at mired.org (Mike Meyer) Date: Tue, 01 Jan 2013 13:41:13 -0600 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> Message-ID: <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> MigMit wrote: >On Jan 1, 2013, at 10:23 PM, ??????? ??? >wrote: >> Eiffel, for my opinion, is a best OOP language. Meyer use a >theoretical approach as it is possible in OOP. >Really? Because when I studied it I had a very different impression: >that behind this language there was no theory at all. And it's only >feature I remember that is not present in mainstream languages is it's >pre/postconditions system, which looked like an ugly hack for me. I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much. On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code. -- Sent from my Android tablet with K-9 Mail. Please excuse my swyping. From miguelimo38 at yandex.ru Tue Jan 1 21:47:56 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Wed, 2 Jan 2013 00:47:56 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> Message-ID: <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> Well, probably one of the reasons is that I've learned Eiffel later than Haskell. But really, "Design by Contract" ? a theory? It certainly is a useful approach, but it doesn't seem to be a theory, not until we can actually prove something about it, and Eiffel doesn't seem to offer anything in this direction. And by "hack" I meant not the presence of pre/postconditions, but the fact that they don't affect anything else. Strip all of them away, and you'll have the program which is, essentially, the same (and, in fact, pre/postconditions are supposed to be removed in the final version of the program). Compare this to Haskell types, for example: an untyped version of Haskell won't be able to choose between two class instances, so, that would be an entirely different language. On Jan 1, 2013, at 11:41 PM, Mike Meyer wrote: > > > MigMit wrote: >> On Jan 1, 2013, at 10:23 PM, ??????? ??? >> wrote: >>> Eiffel, for my opinion, is a best OOP language. Meyer use a >> theoretical approach as it is possible in OOP. >> Really? Because when I studied it I had a very different impression: >> that behind this language there was no theory at all. And it's only >> feature I remember that is not present in mainstream languages is it's >> pre/postconditions system, which looked like an ugly hack for me. > > I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much. > > On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code. > > > -- > Sent from my Android tablet with K-9 Mail. Please excuse my swyping. From ivan.miljenovic at gmail.com Tue Jan 1 22:22:41 2013 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed, 2 Jan 2013 07:22:41 +1000 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: graphviz-2999.15.0.0 In-Reply-To: References: Message-ID: On 1 January 2013 22:41, Henning Thielemann wrote: > > On Tue, 1 Jan 2013, Ivan Lazar Miljenovic wrote: > >> After much prodding and poking by end-users for the past few months, >> I'm finally able to announce a GHC-7.6.1 compatible release of my >> Haskell bindings to the Graphviz graph visualisation toolkit: >> http://hackage.haskell.org/package/graphviz-2999.15.0.0 > > > Did you receive my work-around for the busy-wait problem? Whoops, forgot about that; I'll have a look now. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From hutch-lists at recursive.ca Tue Jan 1 23:26:36 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Tue, 1 Jan 2013 17:26:36 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> Message-ID: <332BF77C-CE35-49E0-B029-1EFD58EDE111@recursive.ca> On 2013-01-01, at 3:47 PM, MigMit wrote: > Well, probably one of the reasons is that I've learned Eiffel later than Haskell. > > But really, "Design by Contract" ? a theory? It certainly is a useful approach, but it doesn't seem to be a theory, not until we can actually prove something about it, and Eiffel doesn't seem to offer anything in this direction. Don't confuse OOSC2 and Eiffel. Eiffel implements the ideas in OOSC2 as best as Meyer can, but they are not the same thing. And, personally, I think I would be willing to call DbC a theory, or a close precursor to a theory. > > And by "hack" I meant not the presence of pre/postconditions, but the fact that they don't affect anything else. Strip all of them away, and you'll have the program which is, essentially, the same (and, in fact, pre/postconditions are supposed to be removed in the final version of the program). > Compare this to Haskell types, for example: an untyped version of Haskell won't be able to choose between two class instances, so, that would be an entirely different language. So, I think, you're saying take away the contracts and the outcome of compilation won't be any different. Whereas take away the types and Haskell is stopped cold. And that difference makes contracts a 'hack' but types not a 'hack'? Seems to me you're ignoring everything that happens between an empty directory and a working program. Contracts help in that process (I say but can't prove). Call that a 'hack' if you want, but I'll take as many of those kinds of hacks as I can get if they're anywhere near as good as contracts. Pre and post conditions with class invariants are neither types nor unit test, something in between. With the wonderful properties of 'useful' and 'executable'. Sometimes you just have to settle for the hacks. Cheers, Bob > > On Jan 1, 2013, at 11:41 PM, Mike Meyer wrote: > >> >> >> MigMit wrote: >>> On Jan 1, 2013, at 10:23 PM, ??????? ??? >>> wrote: >>>> Eiffel, for my opinion, is a best OOP language. Meyer use a >>> theoretical approach as it is possible in OOP. >>> Really? Because when I studied it I had a very different impression: >>> that behind this language there was no theory at all. And it's only >>> feature I remember that is not present in mainstream languages is it's >>> pre/postconditions system, which looked like an ugly hack for me. >> >> I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much. >> >> On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code. >> >> >> -- >> Sent from my Android tablet with K-9 Mail. Please excuse my swyping. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gwern0 at gmail.com Wed Jan 2 00:07:16 2013 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue, 1 Jan 2013 18:07:16 -0500 Subject: [Haskell-cafe] Haskell Summers of Code retrospective (updated for 2012) Message-ID: The Wheel turns, and months come and pass, leaving web links that fade into 403 Forbiddens; a wind rose in NYC, whispering of the coming Winter... As is now customary for me, I've looked into how the 2012 SoCs went - the better to feed my misanthropic heart by mocking the students who failed my whimsically arbitrary and subjective standards: http://www.gwern.net/Haskell%20Summer%20of%20Code#results-2 This was not a good year. 2 students simply dropped out period, and 3 other projects turned out badly, leaving just 2 clearly successful projects for the year. Hopefully 2013 will turn out better. /r/haskell: http://www.reddit.com/r/haskell/comments/15sjur/summer_of_code_2012_retrospective/ -- gwern From christopher.howard at frigidcode.com Wed Jan 2 00:24:04 2013 From: christopher.howard at frigidcode.com (Christopher Howard) Date: Tue, 01 Jan 2013 14:24:04 -0900 Subject: [Haskell-cafe] Proving programs Message-ID: <50E37014.4090809@frigidcode.com> I'm working through a video lecture describing how to prove programs correct, by first translating the program into a control flow representation and then using propositional logic. In the control flow section, the speaker described how the program should be understood in terms of an input vector (X, the inputs to the program), a program vector (Y, the storage variables), and an output vector (Z, the outputs of the program), with X mapping into Y, Y being affected by execution, and X and Y mapping into Z. However, only part way into the video, two practical questions come to mind: 1. Does this approach need to be adjusted for a functional language, in which computation is (at least idealistically) distinct from control flow? 2. How do we approach this for programs that have an input loop (or recursion)? E.g., I have an application that reads one line for stdin, modifies said line, outputs to stdout, and repeats this process until EOF? Should I be thinking of every iteration as a separate program? -- frigidcode.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 553 bytes Desc: OpenPGP digital signature URL: From qdunkan at gmail.com Wed Jan 2 00:17:35 2013 From: qdunkan at gmail.com (Evan Laforge) Date: Tue, 1 Jan 2013 15:17:35 -0800 Subject: [Haskell-cafe] hsc2hs and Storable (especially) unsafe Message-ID: It so happens that on 64 bit OS X, haskell's Int is 64 bits, while C's int is 32 bits. hsc2hs's #poke does no typechecking at all, so if you have (#poke Struct, int_field) structp int -- where int :: Int Then you probably are going to corrupt memory, and in a particularly pernicious way (since chances are it won't segfault). Similarly, don't poke haskell Chars, it has to be CChar. And what's even worse, Foreign.withArrayLen gives you an Int, not a CInt! So doing the obvious thing and poking the pointer and length directly is wrong. And besides, shouldn't it be a CSize? Another trap: C++'s bool is probably one byte, haskell's Bool Storable says it's 4. It's probably not even correct to assume Double = CDouble and Float = CFloat, though it seems likely to be always true. I carefully vetted all my #pokes but I'm annoyed that hsc2hs and Foreign let me get away with this. If Storable is for marshalling types to and from C, then non-C types should not be Storable! If Storable is useful for other things (and it is!), then Foreign should define its own CStorable, that only includes C types, and hsc2hs should use that! While we're at it, fromIntegral is not a safe way to convert a haskell type to a C one. But it sure is a tempting one, because Foreign.C doesn't provide any conversion functions (except for Bool). We should have explicit conversion functions that give the choice of crashing with an error or clamping the number to the (smaller) C type's bounds. I'm not sure if anyone wants what fromIntegral does. Or maybe I shouldn't be using hsc2hs in the first place. I feel more and more that it gives haskell a bad name, being low level and error prone. I used bindings-dsl for a libgit2 binding, and at least it automates Storable instances, so it's less error-prone that way. I'd like to generate instances directly from .h files though, so I should probably check out c2hs. Back in the day when I was deciding to use hsc2hs I noticed how it lacks typechecking, but I thought that it's just a few fields, I can be careful when writing them. But one of the lessons from haskell (and static analysis in general) is that "just be careful" is going to fail you some day, probably sooner than you think. So anyway, I wrote a ForeignC module that defines CStorable that only includes C types. At first I thought I could make Storable a superclass and just re-export functions with more restritive signatures, but then it gets tricky because you wind up needing the Storable peek and poke to declare Storable instances. So I defined a completely new CStorable, and all you need to do is import ForeignC instead of Foreign, and change 'instance Storable ...' to 'instance CStorable ...'. Unfortunately that apparently means copy-pasting over the Storable-using utilities like 'with' and 'newArray'. On the plus side, I dropped it into my .hsc modules, and it found several *more* mistakes. I was thinking of putting it on hackage (along with the conversion functions), since other people might have made these same mistakes, but it's unpleasant because it duplicates so much from Foreign. Also, I only copied over the bits I'm using, so it's not complete either. Is there a better way to create safe Storable instances for C? I'd be happier with a solution that avoids the need to write Storable instances in the first place, but hsc2hs is here now, and used in a lot of places. From wren at freegeek.org Wed Jan 2 05:39:21 2013 From: wren at freegeek.org (wren ng thornton) Date: Tue, 01 Jan 2013 23:39:21 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: Message-ID: <50E3B9F9.2050007@freegeek.org> On 12/31/12 4:26 PM, Rico Moorman wrote: > Hello Bob and Mike, > > Reading a little within the suggested book I came across the following > statement. > >> We should first examine the merits and limitations of the traditional >> approach: using >> functions as a basis for the architecture of software systems. This will >> not only lead us to >> appreciate why we need something else ? object technology ? but also help >> us avoid, >> when we do move into the object world, certain methodological pitfalls >> such as premature >> operation ordering, which have been known to fool even experienced O-O >> developers. > > Because you both have more experience with this piece of literature, how > would you interpret it? With a grain of salt or would function really mean > procedure from the viewpoint of the author? I'm not Bob nor Mike, and haven't read the text in question, but when you encounter "function" in most any imperative or OO setting, it almost certainly means a first-order procedure. No mathematical functions. No higher-order thingamabobs that you can pass to or return from other thingamabobs. Just an address in code with an expected stack frame configuration associated with it. As for learning object orientation, I'd second the suggestion of Smalltalk. I'll leave the religious wars aside, but "OOP" means very different things to very different people. Most people use the term whilst referring to C++ and Java, but most people recognize that the ideological framework is best attained by Smalltalk (and related languages like Ruby). So, if you're interested in learning the ideology, then Smalltalk is a great place to get it. Also, Smalltalk has the "become" method, which is amazing magic. -- Live well, ~wren From leon.v.nikitin at pravmail.ru Wed Jan 2 05:44:40 2013 From: leon.v.nikitin at pravmail.ru (=?koi8-r?B?7snLydTJziDsxdc=?=) Date: Wed, 02 Jan 2013 11:44:40 +0700 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> Message-ID: <2430331357101880@web22d.yandex.ru> An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image1 Type: image/gif Size: 453 bytes Desc: not available URL: From pig28789 at gmail.com Wed Jan 2 07:01:20 2013 From: pig28789 at gmail.com (xuan bach) Date: Wed, 2 Jan 2013 14:01:20 +0800 Subject: [Haskell-cafe] Makefile for a Haskell Project In-Reply-To: <20121228022037.82685tp0bc5m797p@stuttard.org> References: <20121228022037.82685tp0bc5m797p@stuttard.org> Message-ID: Dear all, Thank you for your kind replies. I tried to used ghc --make as Mr. Scott suggested. It is fine if in the C stub I do not call to a non-standard library of C language. The problem is that if I call to a non-standard C library installed (omega) in my system, I cannot compile it. Here is my make file using ghc make: ========================= BASEDIR=/usr/local INCS= -I$(BASEDIR)/include/omega -I. LIBS= -L$(BASEDIR)/lib LIB= -lcode_gen -lomega -lm GHC=ghc #---------------------------------------------------- CFILES=$(CURDIR)/cfile HSFILES=$(CURDIR)/hsfile COBJFILES=$(CFILES)/termops.o $(CFILES)/termops2.o ALLCFILES=$(CFILES)/termops.c $(CFILES)/termops2.c #---------------------------------------------------- GHC_FLAGS= -O2 -fglasgow-exts -fallow-overlapping-instances _ffi_ex: $(COBJFILES) ghc $(GHC_FLAGS) -lstdc++ --make -main-is FfiEx -o ffi_ex FfiEx.hs $(HSFILES)/*.hs $(LIBS) $(LIB) $(COBJFILES) ========================= => * fatal error: omega.h: No such file or directory * Could you please give me suggestions to solve this? Thank you. Best Regards. Bach. On Fri, Dec 28, 2012 at 5:20 PM, wrote: > Quoting xuan bach : > > Hi everyone, >> I'm a newbie in Haskell. >> >> I'm wondering that if there is any tool support >> creating Makefile for Haskell project like Ocamlbuild >> for Ocaml project? >> > > I'v just started learning how to use Neil Mitchell's Shake described at: > > http://neilmitchell.blogspot.**co.uk/2012/02/shake-better-**make.html > > Its available on hackage. > > Hth > >> Thank you, >> Regards. >> >> -- >> *Le Dinh Xuan Bach* >> *Tel: 01234711869 or +65 86967149 >> * >> *Email: pig28789 at gmail.com >> >> School of Information and Communication, >> * >> *Hanoi University of Science and Technology >> ------------------------------**------------------------------**--------- >> ?????????????? >> ?????01234711869 or +65 86967149 >> ???? pig28789 at gmail.com >> * >> >> > > > -- *Le Dinh Xuan Bach* *Tel: 01234711869 or +65 86967149 * *Email: pig28789 at gmail.com School of Information and Communication, * *Hanoi University of Science and Technology --------------------------------------------------------------------- ?????????????? ?????01234711869 or +65 86967149 ???? pig28789 at gmail.com * -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwm at mired.org Wed Jan 2 07:52:44 2013 From: mwm at mired.org (Mike Meyer) Date: Wed, 02 Jan 2013 00:52:44 -0600 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> Message-ID: [Context destroyed by top posting.] MigMit wrote: >But really, "Design by Contract" ? a theory? It certainly is a useful >approach, but it doesn't seem to be a theory, not until we can actually >prove something about it, and Eiffel doesn't seem to offer anything in >this direction. You just stated (briefly, and not very rigorously) the theory: DbC is a useful approach to programing. Note that it's a theory about *programming*, not the resulting program. >And by "hack" I meant not the presence of pre/postconditions, but the >fact that they don't affect anything else. Strip all of them away, and >you'll have the program which is, essentially, the same (and, in fact, >pre/postconditions are supposed to be removed in the final version of >the program). Compare this to Haskell types, for example: an untyped >version of Haskell won't be able to choose between two class instances, >so, that would be an entirely different language. Type classes are the wrong feature to look at. Type signatures are closer to what DbC is. Are type signatures a hack to get around deficiencies in the type inferencing engine? After all, you can strip all of them away and have essentially the same program. Personally, I think the answer is "no", and for the same reason. We add type signatures to top level functions because it helps document the function, and to help isolate type errors during compilation. They makes *programming* easier, even if they don't change the program at all. Pre and Post conditions (and class invariants - they're also part of DbC!) serve pretty much the same function. They help document the classes and methods, and tools that generate class/method documentation from source always include them. They're as important as the type signature. They also help isolate bugs, in that you get told explicitly that routine foo passed in an invalid parameter to bar rather than an exception somewhere deep in the guts of bar that you have to work back from to find foo. As I said before, I'm not sure I agree that the latter is worth the cost of using them for anything complex. The bugs they uncover are as likely to be in the pre/post conditions as in the code proper. The documentation benefit is unquestionable, though. And if some condition is worth documenting, then having it as executable documentation means it gets tested with the rest of the code, so you know the documentation is correct. Which means that just adding conditions to a language misses most of the benefit of DbC. You need to fix the documentation system as well. This is the kind of theory that you'll find in OOSC: why the features that are there help make programming easier. Not theories about how they make the resulting program better. Those two have a lot in common, though. Anything that makes witing correct code easier generally results in a better program. -- Sent from my Android tablet with K-9 Mail. Please excuse my swyping. From kazu at iij.ad.jp Wed Jan 2 09:16:08 2013 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Wed, 02 Jan 2013 17:16:08 +0900 (JST) Subject: [Haskell-cafe] Monaris Message-ID: <20130102.171608.1246914182405721786.kazu@iij.ad.jp> Happy new year from Japan. A young talented guy, @fumieval, has released Monaris, a Tetoris clone based on OpenGL. You can install it: % cabal install Monaris To my surprise, this game is implemented with free Monad. ;-) Regards, --Kazu From sedrikov at gmail.com Wed Jan 2 10:03:51 2013 From: sedrikov at gmail.com (AUGER =?UTF-8?B?Q8OpZHJpYw==?=) Date: Wed, 2 Jan 2013 10:03:51 +0100 Subject: [Haskell-cafe] Proving programs In-Reply-To: <50E37014.4090809@frigidcode.com> References: <50E37014.4090809@frigidcode.com> Message-ID: <20130102100351.14ed14c6@gmail.com> Le Tue, 01 Jan 2013 14:24:04 -0900, Christopher Howard a ?crit : > I'm working through a video lecture describing how to prove programs > correct, by first translating the program into a control flow > representation and then using propositional logic. In the control flow > section, the speaker described how the program should be understood in > terms of an input vector (X, the inputs to the program), a program > vector (Y, the storage variables), and an output vector (Z, the > outputs of the program), with X mapping into Y, Y being affected by > execution, and X and Y mapping into Z. > > However, only part way into the video, two practical questions come > to mind: > > 1. Does this approach need to be adjusted for a functional language, > in which computation is (at least idealistically) distinct from > control flow? > > 2. How do we approach this for programs that have an input loop (or > recursion)? E.g., I have an application that reads one line for stdin, > modifies said line, outputs to stdout, and repeats this process until > EOF? Should I be thinking of every iteration as a separate program? > Have you heard of Agda and Curry-Howard? For imperative programs, you may also be interested in Hoare logic. There are also some tools you may be interested in: - Atelier B - Why3 And probably many others. From miguelimo38 at yandex.ru Wed Jan 2 10:41:54 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Wed, 2 Jan 2013 13:41:54 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <332BF77C-CE35-49E0-B029-1EFD58EDE111@recursive.ca> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <332BF77C-CE35-49E0-B029-1EFD58EDE111@recursive.ca> Message-ID: <7A07A3FD-C661-4C7D-9542-66EDD8E5CCF7@yandex.ru> On Jan 2, 2013, at 2:26 AM, Bob Hutchison wrote: > > On 2013-01-01, at 3:47 PM, MigMit wrote: > >> Well, probably one of the reasons is that I've learned Eiffel later than Haskell. >> >> But really, "Design by Contract" ? a theory? It certainly is a useful approach, but it doesn't seem to be a theory, not until we can actually prove something about it, and Eiffel doesn't seem to offer anything in this direction. > > Don't confuse OOSC2 and Eiffel. Eiffel implements the ideas in OOSC2 as best as Meyer can, but they are not the same thing. Well, we were talking about Eiffel. OOSC2 deserves a few unkind words as well, but I won't go there. > > And, personally, I think I would be willing to call DbC a theory, or a close precursor to a theory. I don't know about DbC in general, but it's implementation in Eiffel seems to be nothing more than a few ASSERT macros, for some weird reason embedded into the language. > So, I think, you're saying take away the contracts and the outcome of compilation won't be any different. Whereas take away the types and Haskell is stopped cold. And that difference makes contracts a 'hack' but types not a 'hack'? I wasn't clear enough, sorry. I'm sure it's due to sleep deprivation. Or coffee deprivation. See, there are two parts of Eiffel, as I see it. First one is the "contracts" part. Second is? well, everything else. Second part seems to be doing all the "real" job, while the first one is doing something invisible, something that leaves no trace in the final result. Which doesn't mean it's unimportant, of course. The contracts part is designed to help the other part do it's job, but not to do the job by itself. Now, there are two problems with that: 1) The "real job" part needs helping. And a lot of it, actually, one doesn't need to look very closely to see that Eiffel type system is extremely unsafe (for the statically type language). 2) The "contracts" part does a very poor job. Instead of really improving the inherent unsafety, it resorts to testing. And... 2') ...not even the real, thorough testing ? contracts system would be quite happy if the program works on the developer's machine. Which is the "works for me" approach certain languages gets rightfully blamed for. > Seems to me you're ignoring everything that happens between an empty directory and a working program. Contracts help in that process (I say but can't prove). I agree. They do help ? but there are lots of things that help in this transition. Versioning systems. Collaboration tools. Bug tracking software. Text editors. Even debuggers. > Pre and post conditions with class invariants are neither types nor unit test, something in between. With the wonderful properties of 'useful' and 'executable'. > > Sometimes you just have to settle for the hacks. > > Cheers, > Bob > >> >> On Jan 1, 2013, at 11:41 PM, Mike Meyer wrote: >> >>> >>> >>> MigMit wrote: >>>> On Jan 1, 2013, at 10:23 PM, ??????? ??? >>>> wrote: >>>>> Eiffel, for my opinion, is a best OOP language. Meyer use a >>>> theoretical approach as it is possible in OOP. >>>> Really? Because when I studied it I had a very different impression: >>>> that behind this language there was no theory at all. And it's only >>>> feature I remember that is not present in mainstream languages is it's >>>> pre/postconditions system, which looked like an ugly hack for me. >>> >>> I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much. >>> >>> On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code. >>> >>> >>> -- >>> Sent from my Android tablet with K-9 Mail. Please excuse my swyping. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Wed Jan 2 10:43:55 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Wed, 2 Jan 2013 13:43:55 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <2430331357101880@web22d.yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <2430331357101880@web22d.yandex.ru> Message-ID: <86EBBB4B-A087-4CDF-A90E-CC35C63D95BC@yandex.ru> On Jan 2, 2013, at 8:44 AM, ??????? ??? wrote: > I said "theoratical", but not "mathematical" or "a scientific" theory. Than what kind of theory did you mean? > Meyer have built a quite coherent construction in comparison with other OOP langs. More than Smalltalk, for example? > BTW, when I started study haskell i had similar question: is it possible to add DbC to haskell? Does haskell need DbC? > For example, class invariants may be expressed in DbC construction (fmap id = id for Functior, for example). > > 02.01.2013, 02:41, "Mike Meyer" : > MigMit wrote: > > On Jan 1, 2013, at 10:23 PM, ??????? ??? > wrote: > Eiffel, for my opinion, is a best OOP language. Meyer use a > theoretical approach as it is possible in OOP. > Really? Because when I studied it I had a very different impression: > that behind this language there was no theory at all. And it's only > feature I remember that is not present in mainstream languages is it's > pre/postconditions system, which looked like an ugly hack for me. > I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much. > > On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code. > > > -- > Sent from my Android tablet with K-9 Mail. Please excuse my swyping. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From miguelimo38 at yandex.ru Wed Jan 2 10:48:07 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Wed, 2 Jan 2013 13:48:07 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> Message-ID: <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> On Jan 2, 2013, at 10:52 AM, Mike Meyer wrote: > > > [Context destroyed by top posting.] > MigMit wrote: >> But really, "Design by Contract" ? a theory? It certainly is a useful >> approach, but it doesn't seem to be a theory, not until we can actually >> prove something about it, and Eiffel doesn't seem to offer anything in >> this direction. > > You just stated (briefly, and not very rigorously) the theory: DbC is a useful approach to programing. Note that it's a theory about *programming*, not the resulting program. Well, you can call that a theory, for sure. But I think it's usually called an "observation". I always thought the theory is something that allows us to develop some new knowledge. Just stating that "comfortable chairs make programmers more productive" doesn't constitute a theory. > Type classes are the wrong feature to look at. Type signatures are closer to what DbC is. Are type signatures a hack to get around deficiencies in the type inferencing engine? After all, you can strip all of them away and have essentially the same program. I've tried to clarify my position in my response to Bob Hutchison. From mwm at mired.org Wed Jan 2 12:28:14 2013 From: mwm at mired.org (Mike Meyer) Date: Wed, 2 Jan 2013 05:28:14 -0600 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> Message-ID: <20130102052814.52ef1ff8@bhuda.mired.org> On Wed, 2 Jan 2013 13:48:07 +0400 MigMit wrote: > On Jan 2, 2013, at 10:52 AM, Mike Meyer wrote: > > MigMit wrote: > >> But really, "Design by Contract" ? a theory? It certainly is a useful > >> approach, but it doesn't seem to be a theory, not until we can actually > >> prove something about it, and Eiffel doesn't seem to offer anything in > >> this direction. > > You just stated (briefly, and not very rigorously) the theory: DbC is a useful approach to programing. Note that it's a theory about *programming*, not the resulting program. > Well, you can call that a theory, for sure. But I think it's usually called an "observation". An "observation" is what you make to decide if a theory is true or not. In order to make the observation (at least for theories about helping programmers) you need an implementation so you can observe people using it. > I always thought the theory is something that allows us to develop > some new knowledge. Yup. Deciding whether or not the theory is true *is* a development of new knowledge. I can say for a certainty that the documentation aspect of DbC makes me more productive. The testing aspect of it needs more testing (sorry). > Just stating that "comfortable chairs make programmers more > productive" doesn't constitute a theory. Well, it's not very rigorous, and I can think of some counterexamples. On the other hand, if you reparaphrased (sic) it as "Chairs that encourage good posture make programmers more productive", then you have a honest-to-goodness theory. Better yet, it's one that's been thoroughly tested in ergonomics labs around the world. At this point, we're arguing about the semantics of the word "theory". On Wed, 2 Jan 2013 13:41:54 +0400 MigMit wrote: > I don't know about DbC in general, but it's implementation in Eiffel > seems to be nothing more than a few ASSERT macros, for some weird > reason embedded into the language. Either you used a particularly poor implementation of Eiffel, or you didn't look at the implementation beyond writing them out. Every Eiffel system I've used included tools that computed the contracts on a method or class (remember, class invariants apply to subclasses, etc.) and displayed them. Those are just as much part of DbC as the "assert macros". If you ignore that usage, you've correctly described things. At least as well as saying that a function call implementation is a goto that records a return address, for some weird reason embedded into the language. Or is just , for some weird reason embedded into the language. The "weird reason" is pretty much always the same: the construct in question carries more semantic meaning than the implementation method. Functions capture the notion of a distinct, reusable chunk of code, that can have properties all it's own. This is a major step up from just having a goto variant with an otog that undoes it. Likewise, pre and post (and invariant) conditions capture the notion of a contract. They express the terms of the contract implemented by some specific bit of code. The contract is part of the interface to that code. If you're actually doing DbC, it's no less important than the rest of the interface. Like, for instance, the type signature. Personally, I don't believe in turning off the conditions, for much the same reason I don't believe in turning off array bounds checking. I think it's better to get the right answer later than to get the wrong answer now. http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org From f at mazzo.li Wed Jan 2 12:32:53 2013 From: f at mazzo.li (Francesco Mazzoli) Date: Wed, 02 Jan 2013 12:32:53 +0100 Subject: [Haskell-cafe] Inference for RankNTypes Message-ID: <87d2xnizve.wl%f@mazzo.li> Hi list, I am a bit puzzled by the behaviour exemplified by this code: {-# LANGUAGE RankNTypes #-} one :: (forall a. a -> a) -> b -> b one f = f two = let f = flip one in f 'x' id three = (flip one :: b -> (forall a. a -> a) -> b) 'x' id four = flip one 'x' id Try to guess if this code typechecks, and if not what?s the error. While `two' and `three' are fine, GHC (7.4.1 and 7.6.1) complains about `four': Line 8: 1 error(s), 0 warning(s) Couldn't match expected type `forall a. a -> a' with actual type `a0 -> a0' In the third argument of `flip', namely `id' In the expression: flip one 'x' id In an equation for `four': four = flip one 'x' id So for some reason the quantified variable in `id' gets instantiated before it should, and I have no idea why. Any ideas? Francesco From f at mazzo.li Wed Jan 2 13:04:36 2013 From: f at mazzo.li (Francesco Mazzoli) Date: Wed, 02 Jan 2013 13:04:36 +0100 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: <87d2xnizve.wl%f@mazzo.li> References: <87d2xnizve.wl%f@mazzo.li> Message-ID: <87a9sriyej.wl%f@mazzo.li> At Wed, 02 Jan 2013 12:32:53 +0100, Francesco Mazzoli wrote: > > Hi list, > > I am a bit puzzled by the behaviour exemplified by this code: > > {-# LANGUAGE RankNTypes #-} > > one :: (forall a. a -> a) -> b -> b > one f = f > > two = let f = flip one in f 'x' id > three = (flip one :: b -> (forall a. a -> a) -> b) 'x' id > four = flip one 'x' id > > Try to guess if this code typechecks, and if not what?s the error. > > While `two' and `three' are fine, GHC (7.4.1 and 7.6.1) complains about `four': > > Line 8: 1 error(s), 0 warning(s) > > Couldn't match expected type `forall a. a -> a' > with actual type `a0 -> a0' > In the third argument of `flip', namely `id' > In the expression: flip one 'x' id > In an equation for `four': four = flip one 'x' id > > So for some reason the quantified variable in `id' gets instantiated before it > should, and I have no idea why. > > Any ideas? > > Francesco OK, I should have looked at the manual first. From : ?For a lambda-bound or case-bound variable, x, either the programmer provides an explicit polymorphic type for x, or GHC's type inference will assume that x's type has no foralls in it.?. So there is a difference between let-bound things and the rest. I still don?t get exactly what?s going on there. What?s the inferred type for `flip one', and why is it causing that error? Since there really isn?t much to infer here. Francesco From leon.v.nikitin at pravmail.ru Wed Jan 2 13:24:20 2013 From: leon.v.nikitin at pravmail.ru (=?koi8-r?B?7snLydTJziDsxdc=?=) Date: Wed, 02 Jan 2013 19:24:20 +0700 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <20130102052814.52ef1ff8@bhuda.mired.org> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> Message-ID: <298951357129460@web21h.yandex.ru> An HTML attachment was scrubbed... URL: From leon.v.nikitin at pravmail.ru Wed Jan 2 13:37:26 2013 From: leon.v.nikitin at pravmail.ru (=?koi8-r?B?7snLydTJziDsxdc=?=) Date: Wed, 02 Jan 2013 19:37:26 +0700 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <298951357129460@web21h.yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> Message-ID: <944891357130246@web1h.yandex.ru> An HTML attachment was scrubbed... URL: From roma at ro-che.info Wed Jan 2 13:49:51 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 2 Jan 2013 14:49:51 +0200 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: <87a9sriyej.wl%f@mazzo.li> References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> Message-ID: <20130102124951.GA1171@sniper> * Francesco Mazzoli [2013-01-02 13:04:36+0100] > At Wed, 02 Jan 2013 12:32:53 +0100, > Francesco Mazzoli wrote: > > > > Hi list, > > > > I am a bit puzzled by the behaviour exemplified by this code: > > > > {-# LANGUAGE RankNTypes #-} > > > > one :: (forall a. a -> a) -> b -> b > > one f = f > > > > two = let f = flip one in f 'x' id > > three = (flip one :: b -> (forall a. a -> a) -> b) 'x' id > > four = flip one 'x' id > > > > Try to guess if this code typechecks, and if not what?s the error. > > > > While `two' and `three' are fine, GHC (7.4.1 and 7.6.1) complains about `four': > > > > Line 8: 1 error(s), 0 warning(s) > > > > Couldn't match expected type `forall a. a -> a' > > with actual type `a0 -> a0' > > In the third argument of `flip', namely `id' > > In the expression: flip one 'x' id > > In an equation for `four': four = flip one 'x' id > > > > So for some reason the quantified variable in `id' gets instantiated before it > > should, and I have no idea why. > > > > Any ideas? > > > > Francesco > > OK, I should have looked at the manual first. From > : > ?For a lambda-bound or case-bound variable, x, either the programmer provides an > explicit polymorphic type for x, or GHC's type inference will assume that x's > type has no foralls in it.?. So there is a difference between let-bound things > and the rest. I don't see how this is relevant. GHC correctly infers the type of "flip one 'x'": *Main> :t flip one 'x' flip one 'x' :: (forall a. a -> a) -> Char But then somehow it fails to apply this to id. And there are no bound variables here that we should need to annotate. Roman From hutch-lists at recursive.ca Wed Jan 2 13:56:28 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Wed, 2 Jan 2013 07:56:28 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <7A07A3FD-C661-4C7D-9542-66EDD8E5CCF7@yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <332BF77C-CE35-49E0-B029-1EFD58EDE111@recursive.ca> <7A07A3FD-C661-4C7D-9542-66EDD8E5CCF7@yandex.ru> Message-ID: <8D078EF7-5050-4EFA-847A-7159540214D9@recursive.ca> On 2013-01-02, at 4:41 AM, MigMit wrote: > > On Jan 2, 2013, at 2:26 AM, Bob Hutchison wrote: > >> >> On 2013-01-01, at 3:47 PM, MigMit wrote: >> >>> Well, probably one of the reasons is that I've learned Eiffel later than Haskell. >>> >>> But really, "Design by Contract" ? a theory? It certainly is a useful approach, but it doesn't seem to be a theory, not until we can actually prove something about it, and Eiffel doesn't seem to offer anything in this direction. >> >> Don't confuse OOSC2 and Eiffel. Eiffel implements the ideas in OOSC2 as best as Meyer can, but they are not the same thing. > > Well, we were talking about Eiffel. OOSC2 deserves a few unkind words as well, but I won't go there. > >> >> And, personally, I think I would be willing to call DbC a theory, or a close precursor to a theory. > > I don't know about DbC in general, but it's implementation in Eiffel seems to be nothing more than a few ASSERT macros, for some weird reason embedded into the language. Hmm. I must disagree with you here. I've used three Eiffel systems, ISE, Small/SmartEiffel, and Tower. They all implemented DbC pretty thoroughly. In my opinion, every other implementation of DbC pale in comparison, to the point where they're hardly DbC at all. Are we talking about the same thing? There are three major components (in my opinion) to DbC: pre and post conditions, and class invariants. Pre and post conditions and invariants cannot be implemented simply as asserts. I'll have to refer you to OOSC2 for the (many) details, but a few of the more interesting aspects of these constructs are: 1) error reporting. If a precondition is violated the caller is flagged as the source of the error and error messages, stack traces, etc all reflect the caller. If a post condition is violated it's the callee who is responsible. And the error reports generated are rather good. 2) pre&post conditions and class invariants have defined behaviour in cases of inheritance, even/especially multiple inheritance. They are combined non-trivially in subclasses. Without this I don't think you have DbC. 3) invariants are not checked for calls within a class (self.method does not have them checked, other.method does) 4) You have access to all the parameters for pre&post conditions, and results for post conditions. Access to the initial state of the object is supposed to be there but I don't think all implementations support that. That's only a brief summary, it goes further than that, again I refer you to OOSC2 (and any of the Eiffel implementations I mentioned, and I don't know of any other implementations). This is nothing like a few assert macros. > >> So, I think, you're saying take away the contracts and the outcome of compilation won't be any different. Whereas take away the types and Haskell is stopped cold. And that difference makes contracts a 'hack' but types not a 'hack'? > > I wasn't clear enough, sorry. I'm sure it's due to sleep deprivation. Or coffee deprivation. > > See, there are two parts of Eiffel, as I see it. First one is the "contracts" part. Second is? well, everything else. Second part seems to be doing all the "real" job, while the first one is doing something invisible, something that leaves no trace in the final result. Which doesn't mean it's unimportant, of course. The contracts part is designed to help the other part do it's job, but not to do the job by itself. Now, there are two problems with that: > > 1) The "real job" part needs helping. And a lot of it, actually, one doesn't need to look very closely to see that Eiffel type system is extremely unsafe (for the statically type language). Feel free to enlighten me about these obvious and extremely unsafe aspects of Eiffel's type system. Personally, I can't say I ever noticed. > > 2) The "contracts" part does a very poor job. Instead of really improving the inherent unsafety, it resorts to testing. And? What constitutes a 'good' job? 'Resorts' to testing. I have to admit to resorting to testing on occasion myself. Frequent occasion. Routinely even. :-) > > 2') ...not even the real, thorough testing ? contracts system would be quite happy if the program works on the developer's machine. Which is the "works for me" approach certain languages gets rightfully blamed for. Really? You believe that automated testing and contracts are why software bugs *are not* found? > >> Seems to me you're ignoring everything that happens between an empty directory and a working program. Contracts help in that process (I say but can't prove). > > I agree. They do help ? but there are lots of things that help in this transition. Versioning systems. Collaboration tools. Bug tracking software. Text editors. Even debuggers. You should read OOSC2. You'll find that this is completely consistent with it. Don't forget that the 'C' in OOSC2 is 'contraction'. Cheers, Bob > >> Pre and post conditions with class invariants are neither types nor unit test, something in between. With the wonderful properties of 'useful' and 'executable'. >> >> Sometimes you just have to settle for the hacks. >> >> Cheers, >> Bob >> >>> >>> On Jan 1, 2013, at 11:41 PM, Mike Meyer wrote: >>> >>>> >>>> >>>> MigMit wrote: >>>>> On Jan 1, 2013, at 10:23 PM, ??????? ??? >>>>> wrote: >>>>>> Eiffel, for my opinion, is a best OOP language. Meyer use a >>>>> theoretical approach as it is possible in OOP. >>>>> Really? Because when I studied it I had a very different impression: >>>>> that behind this language there was no theory at all. And it's only >>>>> feature I remember that is not present in mainstream languages is it's >>>>> pre/postconditions system, which looked like an ugly hack for me. >>>> >>>> I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much. >>>> >>>> On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code. >>>> >>>> >>>> -- >>>> Sent from my Android tablet with K-9 Mail. Please excuse my swyping. >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From f at mazzo.li Wed Jan 2 14:21:55 2013 From: f at mazzo.li (Francesco Mazzoli) Date: Wed, 02 Jan 2013 14:21:55 +0100 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: <20130102124951.GA1171@sniper> References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> <20130102124951.GA1171@sniper> Message-ID: <877gnviuto.wl%f@mazzo.li> At Wed, 2 Jan 2013 14:49:51 +0200, Roman Cheplyaka wrote: > I don't see how this is relevant. Well, moving `flip one' in a let solves the problem, and The fact that let-bound variables are treated differently probably has a play here. I originally thought that this was because the quantifications will be all to the left in the let-bound variable while without a let-bound variable the types are used directly. However this doesn?t explain the behaviour I?m seeing. > GHC correctly infers the type of "flip one 'x'": > > *Main> :t flip one 'x' > flip one 'x' :: (forall a. a -> a) -> Char > > But then somehow it fails to apply this to id. And there are no bound > variables here that we should need to annotate. Right. The weirdest thing is that annotating `flip one' (as in `three' in my code) or indeed `flip one 'x'' with the type that shows up in ghci makes things work: five = (flip one 'x' :: (forall a. a -> a) -> Char) id Francesco From hutch-lists at recursive.ca Wed Jan 2 15:01:51 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Wed, 2 Jan 2013 09:01:51 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <8D078EF7-5050-4EFA-847A-7159540214D9@recursive.ca> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <332BF77C-CE35-49E0-B029-1EFD58EDE111@recursive.ca> <7A07A3FD-C661-4C7D-9542-66EDD8E5CCF7@yandex.ru> <8D078EF7-5050-4EFA-847A-7159540214D9@recursive.ca> Message-ID: <7A8DF45B-0A1D-4061-992A-E747662A3009@recursive.ca> On 2013-01-02, at 7:56 AM, Bob Hutchison wrote: > > You should read OOSC2. You'll find that this is completely consistent with it. Don't forget that the 'C' in OOSC2 is 'contraction'. 'Construction' of course? the automated spell checker is not my friend :-( From poczta at emanuelkoczwara.pl Wed Jan 2 15:12:30 2013 From: poczta at emanuelkoczwara.pl (Emanuel Koczwara) Date: Wed, 02 Jan 2013 15:12:30 +0100 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: Message-ID: <1357135950.8138.37.camel@emanuel-Dell-System-Vostro-3750> Hi, First, I see (posts on this mailing list) that OO ideas are well known in functional community :) > > So my questions for you all are: > > > * Is it really worthwhile for me to learn OO-programming? > > Learn or not to learn? I would say: yes! There is whole new universe to discover: UML, design patterns, classes and objects, data structures based on 'pointers' (and you can modify them, surprise!) and of course many algorithms that work on this structures (please note, that many books about algorithms and data structures take imperative approach), OO databases, many many many libraries for almost any thing! and finally, you will be able to try stable, well known and widely used tools (think about GUIs, game engines, embedded systems, mobile devices and all this fascinating stuff you can do with them). > * If so, where should I start? There are plenty of "functional > programming for OO programmers" but I have never seen "OO programming > for functional programmers". > Get a book (big and heavy!), forget all about programming and read it with fresh mind. Do _all_ exercises from that book. > > * Is it true that learning other programming languages leads to a > better use of your favorite programming language? > > I would say, any know knowledge has impact on your life. Programming skills also. > * Will I learn new programming strategies that I can use back in the > Haskell world? > Here I can't say much, I'm just starting with Haskell, but if you would go with C++, then you will also learn some C by the way, FFI is waiting.. > > Thanks in advance for your kind responses, > I hope it was helpful. Emanuel From hutch-lists at recursive.ca Wed Jan 2 16:01:50 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Wed, 2 Jan 2013 10:01:50 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> Message-ID: <757AD8A2-D305-4EB1-8535-7708D806FDFA@recursive.ca> On 2013-01-02, at 1:52 AM, Mike Meyer wrote: > > > [Context destroyed by top posting.] > MigMit wrote: >> But really, "Design by Contract" ? a theory? It certainly is a useful >> approach, but it doesn't seem to be a theory, not until we can actually >> prove something about it, and Eiffel doesn't seem to offer anything in >> this direction. > > You just stated (briefly, and not very rigorously) the theory: DbC is a useful approach to programing. Note that it's a theory about *programming*, not the resulting program. > >> And by "hack" I meant not the presence of pre/postconditions, but the >> fact that they don't affect anything else. Strip all of them away, and >> you'll have the program which is, essentially, the same (and, in fact, >> pre/postconditions are supposed to be removed in the final version of >> the program). Compare this to Haskell types, for example: an untyped >> version of Haskell won't be able to choose between two class instances, >> so, that would be an entirely different language. > > Type classes are the wrong feature to look at. Type signatures are closer to what DbC is. Are type signatures a hack to get around deficiencies in the type inferencing engine? After all, you can strip all of them away and have essentially the same program. Eiffel programmers certainly consider the pre&post conditions and invariants to be part of the signature. DbC is closely related to the management of state, and so to the object as a whole not just the parameters to a method. Now, I'm no expert in Haskell so treat the next part of this paragraph accordingly... putting invariants and conditions on monads, in particular to the entry and exit from do notation might be interesting. No particular ideas as to how you'd do that, or even if it'd be useful, but it seems to me to be a bit closer to the level of abstraction where DbC is at in Eiffel. > > Personally, I think the answer is "no", and for the same reason. We add type signatures to top level functions because it helps document the function, and to help isolate type errors during compilation. They makes *programming* easier, even if they don't change the program at all. Pre and Post conditions (and class invariants - they're also part of DbC!) serve pretty much the same function. They help document the classes and methods, and tools that generate class/method documentation from source always include them. They're as important as the type signature. They also help isolate bugs, in that you get told explicitly that routine foo passed in an invalid parameter to bar rather than an exception somewhere deep in the guts of bar that you have to work back from to find foo. > > As I said before, I'm not sure I agree that the latter is worth the cost of using them for anything complex. The bugs they uncover are as likely to be in the pre/post conditions as in the code proper. The documentation benefit is unquestionable, though. And if some condition is worth documenting, then having it as executable documentation means it gets tested with the rest of the code, so you know the documentation is correct. Which means that just adding conditions to a language misses most of the benefit of DbC. You need to fix the documentation system as well. I can only speak from personal experience here. I used Eiffel as my primary programming language in the 1990's for about 10 years. I wrote a lot of code in Eiffel, and I used pre&post conditions and class invariants extensively (and loop invariants surprisingly often). Some of that code would certainly be described as 'complex'. Yes, documentation is a huge part of what DbC gives you, but a peculiarly aggressive kind of documentation that tells you when you're doing it wrong. The biggest problem I had with writing pre&post conditions and class invariants was missing part of what should be specified and so letting things pass that shouldn't have. The next biggest problem was being overly specific (I sometimes do the same thing with type signatures in Haskell I'm afraid). Bugs in the code of the conditions and invariants was not much of a problem I found (I can't recall any). It does take a while to learn how to write the conditions and how to accommodate DbC concepts when you write a class or class hierarchy. And, occasionally, the balancing act between DbC and unit tests is tricky. > > This is the kind of theory that you'll find in OOSC: why the features that are there help make programming easier. Not theories about how they make the resulting program better. Those two have a lot in common, though. Anything that makes witing correct code easier generally results in a better program. > -- > Sent from my Android tablet with K-9 Mail. Please excuse my swyping. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dan.doel at gmail.com Wed Jan 2 17:20:46 2013 From: dan.doel at gmail.com (Dan Doel) Date: Wed, 2 Jan 2013 11:20:46 -0500 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: <877gnviuto.wl%f@mazzo.li> References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> <20130102124951.GA1171@sniper> <877gnviuto.wl%f@mazzo.li> Message-ID: Your example doesn't work for the same reason the following doesn't work: id runST () It requires the inferencer to instantiate certain variables of id's type to polymorphic types based on runST (or flip's based on one), and then use that information to check (id in your example) as a polymorphic type. At various times, GHC has had ad-hoc left-to-right behavior that made this work, but it no longer does. Right now, I believe it only has an ad-hoc check to make sure that: runST $ works, and not much else. Note that even left-to-right behavior covers all cases, as you might have: f x y such that y requires x to be checked polymorphically in the same way. There are algorithms that can get this right in general, but it's a little tricky, and they're rather different than GHC's algorithm, so I don't know whether it's possible to make GHC behave correctly. The reason it works when you factor out or annotate "flip one 'x'" is that that is the eventual inferred type of the expression, and then it knows to expect the id to be polymorphic. But when it's all at once, we just have a chain of unifications relating things like: (forall a. a -> a) ~ beta ~ (alpha -> alpha), where beta is part of type checking flip, and alpha -> alpha is the instantiation of id's type with unification variables, because we didn't know that it was supposed to be a fully polymorphic use. And that unification fails. On Wed, Jan 2, 2013 at 8:21 AM, Francesco Mazzoli wrote: > At Wed, 2 Jan 2013 14:49:51 +0200, > Roman Cheplyaka wrote: > > I don't see how this is relevant. > > Well, moving `flip one' in a let solves the problem, and The fact that > let-bound > variables are treated differently probably has a play here. I originally > thought that this was because the quantifications will be all to the left > in the > let-bound variable while without a let-bound variable the types are used > directly. However this doesn?t explain the behaviour I?m seeing. > > > GHC correctly infers the type of "flip one 'x'": > > > > *Main> :t flip one 'x' > > flip one 'x' :: (forall a. a -> a) -> Char > > > > But then somehow it fails to apply this to id. And there are no bound > > variables here that we should need to annotate. > > Right. The weirdest thing is that annotating `flip one' (as in `three' in > my > code) or indeed `flip one 'x'' with the type that shows up in ghci makes > things work: > > five = (flip one 'x' :: (forall a. a -> a) -> Char) id > > Francesco > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lewurm at gmail.com Wed Jan 2 17:29:08 2013 From: lewurm at gmail.com (Bernhard Urban) Date: Wed, 2 Jan 2013 17:29:08 +0100 Subject: [Haskell-cafe] [Haskell-beginners] ghc and android In-Reply-To: References: <50E03F64.3080601@posteo.de> <50E194E2.5020900@posteo.de> Message-ID: On Tue, Jan 1, 2013 at 3:41 PM, Brandon Allbery wrote: > On Tue, Jan 1, 2013 at 9:13 AM, Bernhard Urban wrote: >> >> The main issue: The GHC runtime relies on glibc > > > I have to assume this is not meant literally, because ghc works on OS X and > *BSD. Right. I was talking about the situation on Linux, hopefully I'm totally wrong with that statement :) How can I build GHC without glibc on Linux? What should I use instead? That would certainly help. Thanks, Bernhard From dan.doel at gmail.com Wed Jan 2 17:39:57 2013 From: dan.doel at gmail.com (Dan Doel) Date: Wed, 2 Jan 2013 11:39:57 -0500 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> <20130102124951.GA1171@sniper> <877gnviuto.wl%f@mazzo.li> Message-ID: On Wed, Jan 2, 2013 at 11:20 AM, Dan Doel wrote: > Note that even left-to-right behavior covers all cases, as you might have: > > f x y > > such that y requires x to be checked polymorphically in the same way. > There are algorithms that can get this right in general, but it's a little > tricky, and they're rather different than GHC's algorithm, so I don't know > whether it's possible to make GHC behave correctly. > Oops, that should have been, "note that not even left-to-right behavior covers all cases." Also, I don't mean to imply that GHC is behaving wrongly. Situations like these are usually the result of necessary trade-offs in the algorithms. GHC does a lot of things that algorithms that successfully check this type of examples don't have to deal with at all. You have to pick your poison. -- Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: From f at mazzo.li Wed Jan 2 17:47:00 2013 From: f at mazzo.li (Francesco Mazzoli) Date: Wed, 02 Jan 2013 17:47:00 +0100 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> <20130102124951.GA1171@sniper> <877gnviuto.wl%f@mazzo.li> Message-ID: <874nizilbv.wl%f@mazzo.li> At Wed, 2 Jan 2013 11:20:46 -0500, Dan Doel wrote: > Your example doesn't work for the same reason the following doesn't work: > > id runST () > > It requires the inferencer to instantiate certain variables of id's type to > polymorphic types based on runST (or flip's based on one), and then use > that information to check (id in your example) as a > polymorphic type. At various times, GHC has had ad-hoc left-to-right > behavior that made this work, but it no longer does. Right now, I believe > it only has an ad-hoc check to make sure that: > > runST $ > > works, and not much else. Note that even left-to-right behavior covers all > cases, as you might have: > > f x y > > such that y requires x to be checked polymorphically in the same way. There > are algorithms that can get this right in general, but it's a little > tricky, and they're rather different than GHC's algorithm, so I don't know > whether it's possible to make GHC behave correctly. > > The reason it works when you factor out or annotate "flip one 'x'" is that > that is the eventual inferred type of the expression, and then it knows to > expect the id to be polymorphic. But when it's all at once, we just have a > chain of unifications relating things like: (forall a. a -> a) ~ beta ~ > (alpha -> alpha), where beta is part of type checking flip, and alpha -> > alpha is the instantiation of id's type with unification variables, because > we didn't know that it was supposed to be a fully polymorphic use. And that > unification fails. Hi Dan, Thanks a lot for the answer, one forgets that with HM you always replace the quantified variables immediately. However I am still confused on how GHC makes it work when I annotate or put things in separate variables. In other words, can you provide links or clarify how this procedure works: The reason it works when you factor out or annotate "flip one 'x'" is that that is the eventual inferred type of the expression, and then it knows to expect the id to be polymorphic. Thanks, Francesco From karel.gardas at centrum.cz Wed Jan 2 18:06:20 2013 From: karel.gardas at centrum.cz (Karel Gardas) Date: Wed, 02 Jan 2013 18:06:20 +0100 Subject: [Haskell-cafe] [Haskell-beginners] ghc and android In-Reply-To: References: <50E03F64.3080601@posteo.de> <50E194E2.5020900@posteo.de> Message-ID: <50E4690C.5090607@centrum.cz> Hello, rather than native GHC run on top of Android, I would recommend to have a look at GHC HEAD and attempt to cross-compile to Android. On ghc-cvs@ mailing list I've seen some work done for cross-compiling to QNX/BlackBerry OS 10 so I think Androind should be also doable with some work... Cheers, Karel On 01/ 2/13 05:29 PM, Bernhard Urban wrote: > On Tue, Jan 1, 2013 at 3:41 PM, Brandon Allbery wrote: >> On Tue, Jan 1, 2013 at 9:13 AM, Bernhard Urban wrote: >>> >>> The main issue: The GHC runtime relies on glibc >> >> >> I have to assume this is not meant literally, because ghc works on OS X and >> *BSD. > > Right. I was talking about the situation on Linux, hopefully I'm > totally wrong with that statement :) > How can I build GHC without glibc on Linux? What should I use instead? > That would certainly help. > > > Thanks, > Bernhard > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From s.j.thompson at kent.ac.uk Wed Jan 2 18:22:54 2013 From: s.j.thompson at kent.ac.uk (Simon Thompson) Date: Wed, 2 Jan 2013 17:22:54 +0000 Subject: [Haskell-cafe] Proving programs In-Reply-To: <50E37014.4090809@frigidcode.com> References: <50E37014.4090809@frigidcode.com> Message-ID: <7D5F3176-144D-48F5-A3E4-5B6521B0A4DE@kent.ac.uk> Christopher, there's an introduction to proof for functional programs at http://www.cs.kent.ac.uk/people/staff/sjt/Pubs/ProofChapter.pdf I hope that you find it useful. Kind regards Simon On 1 Jan 2013, at 23:24, Christopher Howard wrote: > 1. Does this approach need to be adjusted for a functional language, in > which computation is (at least idealistically) distinct from control flow? > > 2. How do we approach this for programs that have an input loop (or > recursion)? E.g., I have an application that reads one line for stdin, > modifies said line, outputs to stdout, and repeats this process until > EOF? Should I be thinking of every iteration as a separate program? Simon Thompson | Professor of Logic and Computation School of Computing | University of Kent | Canterbury, CT2 7NF, UK s.j.thompson at kent.ac.uk | M +44 7986 085754 | W www.cs.kent.ac.uk/~sjt From dan.doel at gmail.com Wed Jan 2 19:35:24 2013 From: dan.doel at gmail.com (Dan Doel) Date: Wed, 2 Jan 2013 13:35:24 -0500 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: <874nizilbv.wl%f@mazzo.li> References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> <20130102124951.GA1171@sniper> <877gnviuto.wl%f@mazzo.li> <874nizilbv.wl%f@mazzo.li> Message-ID: If you want to know the inner workings, you probably need to read the OutsideIn(X) paper.* I'm not that familiar with the algorithm. But what happens is something like this.... When GHC goes to infer the type of 'f x' where it knows that f's argument is expected to be polymorphic, this triggers a different code path that will check that x can be given a type that is at least as general as is necessary for the argument. However, "flip one 'x' id" gives flip a type like (alpha -> beta -> gamma) -> beta -> alpha -> gamma. Then, we probably get some constraints collected up like: alpha ~ (forall a. a -> a) alpha ~ (delta -> delta) That is, it does not compute the higher-rank type of "flip one 'x'" and then decide how the application of that to id should be checked; it decides how all the arguments should be checked based only on flip's type, and flip does not have a higher-rank type on its own. And solving the above constraints cannot trigger the alternate path. However, when you factor out or annotate "flip one 'x'", it knows that it's applying something with a higher-rank type (whether because it inferred it separately, or you gave it), and that does trigger the alternate code path. If that's still too vague, you'll have to refer to the paper. -- Dan * http://research.microsoft.com/en-us/um/people/simonpj/papers/constraints/jfp-outsidein.pdf On Wed, Jan 2, 2013 at 11:47 AM, Francesco Mazzoli wrote: > At Wed, 2 Jan 2013 11:20:46 -0500, > Dan Doel wrote: > > Your example doesn't work for the same reason the following doesn't work: > > > > id runST () > > > > It requires the inferencer to instantiate certain variables of id's type > to > > polymorphic types based on runST (or flip's based on one), and then use > > that information to check (id in your example) as a > > polymorphic type. At various times, GHC has had ad-hoc left-to-right > > behavior that made this work, but it no longer does. Right now, I believe > > it only has an ad-hoc check to make sure that: > > > > runST $ > > > > works, and not much else. Note that even left-to-right behavior covers > all > > cases, as you might have: > > > > f x y > > > > such that y requires x to be checked polymorphically in the same way. > There > > are algorithms that can get this right in general, but it's a little > > tricky, and they're rather different than GHC's algorithm, so I don't > know > > whether it's possible to make GHC behave correctly. > > > > The reason it works when you factor out or annotate "flip one 'x'" is > that > > that is the eventual inferred type of the expression, and then it knows > to > > expect the id to be polymorphic. But when it's all at once, we just have > a > > chain of unifications relating things like: (forall a. a -> a) ~ beta ~ > > (alpha -> alpha), where beta is part of type checking flip, and alpha -> > > alpha is the instantiation of id's type with unification variables, > because > > we didn't know that it was supposed to be a fully polymorphic use. And > that > > unification fails. > > Hi Dan, > > Thanks a lot for the answer, one forgets that with HM you always replace > the > quantified variables immediately. > > However I am still confused on how GHC makes it work when I annotate or put > things in separate variables. In other words, can you provide links or > clarify > how this procedure works: > > The reason it works when you factor out or annotate "flip one 'x'" is > that > that is the eventual inferred type of the expression, and then it > knows to > expect the id to be polymorphic. > > Thanks, > Francesco > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f at mazzo.li Wed Jan 2 21:02:05 2013 From: f at mazzo.li (Francesco Mazzoli) Date: Wed, 02 Jan 2013 21:02:05 +0100 Subject: [Haskell-cafe] Inference for RankNTypes In-Reply-To: References: <87d2xnizve.wl%f@mazzo.li> <87a9sriyej.wl%f@mazzo.li> <20130102124951.GA1171@sniper> <877gnviuto.wl%f@mazzo.li> <874nizilbv.wl%f@mazzo.li> Message-ID: <87zk0rgxqa.wl%f@mazzo.li> At Wed, 2 Jan 2013 13:35:24 -0500, Dan Doel wrote: > If you want to know the inner workings, you probably need to read the > OutsideIn(X) paper.* > > I'm not that familiar with the algorithm. But what happens is something > like this.... When GHC goes to infer the type of 'f x' where it knows that > f's argument is expected to be polymorphic, this triggers a different code > path that will check that x can be given a type that is at least as general > as is necessary for the argument. > > However, "flip one 'x' id" gives flip a type like (alpha -> beta -> gamma) > -> beta -> alpha -> gamma. Then, we probably get some constraints collected > up like: > > alpha ~ (forall a. a -> a) > alpha ~ (delta -> delta) > > That is, it does not compute the higher-rank type of "flip one 'x'" and > then decide how the application of that to id should be checked; it decides > how all the arguments should be checked based only on flip's type, and flip > does not have a higher-rank type on its own. And solving the above > constraints cannot trigger the alternate path. > > However, when you factor out or annotate "flip one 'x'", it knows that it's > applying something with a higher-rank type (whether because it inferred it > separately, or you gave it), and that does trigger the alternate code path. > > If that's still too vague, you'll have to refer to the paper. > > -- Dan > > * > http://research.microsoft.com/en-us/um/people/simonpj/papers/constraints/jfp-outsidein.pdf Thanks again for the answer. I understood more or less what was going on with the constraints - what I was wondering is how that alternate code path you cite works. I guess I?ll have to attack that epic paper sooner or later :). Francesco From miguelimo38 at yandex.ru Wed Jan 2 22:29:16 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Thu, 3 Jan 2013 01:29:16 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <298951357129460@web21h.yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> Message-ID: <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> On Jan 2, 2013, at 4:24 PM, ??????? ??? wrote: > > Well, we can say "concepts" in place of "theory". And I'm comparing Eiffel with other OOP lang, not with some langs based on a solid math theory (lambda calcules for FP langs, for example). ok? I agree that there are certain concepts, or ideas, that Eiffel is built on. If that is what you meant, sure, I have no problem with that. Of course, there are plenty of languages based on some specific ideas. For example, take the following concepts: 1) it's better to do something instead of failing, even if it doesn't make any sense; 2) global is better then local; 3) for every feature that can be implemented in two ways there should be a switch that the user can set as xe wishes. Implement these as fully as possible ? and you'll get PHP. So, somehow I doubt that being based on some set of ideas is a very strong selling point. > BTW. Why you think that Eiffel type system is unsafe? Well, if I remember correctly, if you call some method of a certain object, and this call compiles, you can't be certain that this object actually has this method. Could be that this object belongs to some subclass which removes this method. From miguelimo38 at yandex.ru Wed Jan 2 22:38:39 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Thu, 3 Jan 2013 01:38:39 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <8D078EF7-5050-4EFA-847A-7159540214D9@recursive.ca> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <332BF77C-CE35-49E0-B029-1EFD58EDE111@recursive.ca> <7A07A3FD-C661-4C7D-9542-66EDD8E5CCF7@yandex.ru> <8D078EF7-5050-4EFA-847A-7159540214D9@recursive.ca> Message-ID: <1269A76F-ACD4-4FCD-B3C5-6F6F18D82120@yandex.ru> > 2) pre&post conditions and class invariants have defined behaviour in cases of inheritance, even/especially multiple inheritance. They are combined non-trivially in subclasses. Without this I don't think you have DbC. Yes, I forgot about that. Thanks. > Feel free to enlighten me about these obvious and extremely unsafe aspects of Eiffel's type system. Personally, I can't say I ever noticed. Correct me if I'm wrong, but isn't it true that methods can be removed in subclasses? If that's not extreme, I don't know what is. >> 2) The "contracts" part does a very poor job. Instead of really improving the inherent unsafety, it resorts to testing. And? > > What constitutes a 'good' job? Well, a sound type system would certainly help. > 'Resorts' to testing. I have to admit to resorting to testing on occasion myself. Frequent occasion. Routinely even. :-) You routinely try to overcome language weakness with tests? >> 2') ...not even the real, thorough testing ? contracts system would be quite happy if the program works on the developer's machine. Which is the "works for me" approach certain languages gets rightfully blamed for. > > Really? You believe that automated testing and contracts are why software bugs *are not* found? Is that what I said? I believe that testing means a lot more than just making sure the program works on the developer's computer. I believe that system that encourages the "works for me" approach is one of the reasons software bugs are not found. >>> Seems to me you're ignoring everything that happens between an empty directory and a working program. Contracts help in that process (I say but can't prove). >> >> I agree. They do help ? but there are lots of things that help in this transition. Versioning systems. Collaboration tools. Bug tracking software. Text editors. Even debuggers. > > You should read OOSC2. You'll find that this is completely consistent with it. I've never said it's not. But all of these tools are external to the language, which means that they can be easily replaced if a better alternative surfaces. From gershomb at gmail.com Wed Jan 2 23:09:03 2013 From: gershomb at gmail.com (Gershom Bazerman) Date: Wed, 02 Jan 2013 17:09:03 -0500 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> Message-ID: <50E4AFFF.9050705@gmail.com> On 1/2/13 4:29 PM, MigMit wrote: > >> BTW. Why you think that Eiffel type system is unsafe? > Well, if I remember correctly, if you call some method of a certain object, and this call compiles, you can't be certain that this object actually has this method. Could be that this object belongs to some subclass which removes this method. > Eiffel doesn't handle the relationship of co- and contra-variance of arguments with subtyping in a principled way. This is apparently known as the "catcall" problem. See, e.g., this article: http://www.eiffelroom.org/node/517 --Gershom From miguelimo38 at yandex.ru Wed Jan 2 23:19:11 2013 From: miguelimo38 at yandex.ru (MigMit) Date: Thu, 3 Jan 2013 02:19:11 +0400 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: <50E4AFFF.9050705@gmail.com> References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> <50E4AFFF.9050705@gmail.com> Message-ID: On Jan 3, 2013, at 2:09 AM, Gershom Bazerman wrote: > On 1/2/13 4:29 PM, MigMit wrote: >> >>> BTW. Why you think that Eiffel type system is unsafe? >> Well, if I remember correctly, if you call some method of a certain object, and this call compiles, you can't be certain that this object actually has this method. Could be that this object belongs to some subclass which removes this method. >> > > Eiffel doesn't handle the relationship of co- and contra-variance of arguments with subtyping in a principled way. This is apparently known as the "catcall" problem. See, e.g., this article: http://www.eiffelroom.org/node/517 Yes, variance is another big source of unsafety, that's for sure. And another reason I think there is no real "theory" behind Eiffel, just a bunch of features (or "concepts") boiled together. From erkokl at gmail.com Thu Jan 3 05:12:32 2013 From: erkokl at gmail.com (Levent Erkok) Date: Wed, 2 Jan 2013 20:12:32 -0800 Subject: [Haskell-cafe] [Announcement] New SBV release Message-ID: I'm happy to announce v2.9 release of the Haskell SBV library: http://leventerkok.github.com/sbv/ SBV (SMT Based Verification) is a library that allows Haskell programs to take advantage of modern SMT solvers, by providing a symbolic simulation engine that can invoke 3rd party SMT solvers to prove/falsify properties about (a certain class of) Haskell programs. New in this release is the support for the CVC4 SMT solver: http://cvc4.cs.nyu.edu/web/ If you were planning to use SMT solvers before, but were worried about the not-so-commercial-friendly licenses of Yices and Z3, then this is a great opportunity: *CVC4 comes with essentially no limit on its use for research or commercial purposes*! Feedback, patches and bug reports are always welcome. -Levent. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andres.sicard.ramirez at gmail.com Thu Jan 3 07:14:21 2013 From: andres.sicard.ramirez at gmail.com (=?UTF-8?B?QW5kcsOpcyBTaWNhcmQtUmFtw61yZXo=?=) Date: Thu, 3 Jan 2013 01:14:21 -0500 Subject: [Haskell-cafe] Proving programs In-Reply-To: <7D5F3176-144D-48F5-A3E4-5B6521B0A4DE@kent.ac.uk> References: <50E37014.4090809@frigidcode.com> <7D5F3176-144D-48F5-A3E4-5B6521B0A4DE@kent.ac.uk> Message-ID: On Wed, Jan 2, 2013 at 12:22 PM, Simon Thompson wrote: > Christopher, there's an introduction to proof for functional programs at > > http://www.cs.kent.ac.uk/people/staff/sjt/Pubs/ProofChapter.pdf > Simon, is it possible to get the list of the bibliographic references used in the chapter? Best regards, -- Andr?s From myles.maxfield at gmail.com Thu Jan 3 08:50:51 2013 From: myles.maxfield at gmail.com (Myles C. Maxfield) Date: Wed, 2 Jan 2013 23:50:51 -0800 Subject: [Haskell-cafe] Safe 'chr' function? Message-ID: Hello, I'm working on a general text-processing library [1] and one of my quickcheck tests is designed to make sure that my library doesn't throw exceptions (it returns an Either type on failure). However, there are some inputs that cause me to pass bogus values to the 'chr' function (such as 1208914), which causes it to throw an exception. Is there a version of that function that is safe? (I'm hoping for something like Int -> Maybe Char). Alternatively, is there a way to know ahead of time whether or not an Int will cause 'chr' to throw an exception? Thanks, Myles C. Maxfield [1] http://hackage.haskell.org/package/punycode -------------- next part -------------- An HTML attachment was scrubbed... URL: From saihemanth at gmail.com Thu Jan 3 09:04:18 2013 From: saihemanth at gmail.com (Sai Hemanth K) Date: Thu, 3 Jan 2013 13:34:18 +0530 Subject: [Haskell-cafe] Safe 'chr' function? In-Reply-To: References: Message-ID: >Alternatively, is there a way to know ahead of time whether or not an Int will cause 'chr' to throw an exception? since Char is in instance of 'Bounded' as well as 'Enum' wouldn't fromEnum (maxBound :: Char) give the max value of Int for which a valid char exists? On Thu, Jan 3, 2013 at 1:20 PM, Myles C. Maxfield wrote: > Hello, > I'm working on a general text-processing library [1] and one of my > quickcheck tests is designed to make sure that my library doesn't throw > exceptions (it returns an Either type on failure). However, there are some > inputs that cause me to pass bogus values to the 'chr' function (such > as 1208914), which causes it to throw an exception. Is there a version of > that function that is safe? (I'm hoping for something like Int -> Maybe > Char). Alternatively, is there a way to know ahead of time whether or not > an Int will cause 'chr' to throw an exception? > > Thanks, > Myles C. Maxfield > > [1] http://hackage.haskell.org/package/punycode > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- I drink I am thunk. -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Thu Jan 3 09:05:35 2013 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 3 Jan 2013 10:05:35 +0200 Subject: [Haskell-cafe] Safe 'chr' function? In-Reply-To: References: Message-ID: You could wrap chr with a call to spoon[1]. It's not the most elegant solution, but it works. [1] http://hackage.haskell.org/packages/archive/spoon/0.3/doc/html/Control-Spoon.html#v:spoon On Thu, Jan 3, 2013 at 9:50 AM, Myles C. Maxfield wrote: > Hello, > I'm working on a general text-processing library [1] and one of my > quickcheck tests is designed to make sure that my library doesn't throw > exceptions (it returns an Either type on failure). However, there are some > inputs that cause me to pass bogus values to the 'chr' function (such > as 1208914), which causes it to throw an exception. Is there a version of > that function that is safe? (I'm hoping for something like Int -> Maybe > Char). Alternatively, is there a way to know ahead of time whether or not > an Int will cause 'chr' to throw an exception? > > Thanks, > Myles C. Maxfield > > [1] http://hackage.haskell.org/package/punycode > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From myles.maxfield at gmail.com Thu Jan 3 09:52:29 2013 From: myles.maxfield at gmail.com (Myles C. Maxfield) Date: Thu, 3 Jan 2013 00:52:29 -0800 Subject: [Haskell-cafe] Safe 'chr' function? In-Reply-To: References: Message-ID: Thanks you two for your answers. Consider this issue closed now :-) --Myles On Thu, Jan 3, 2013 at 12:05 AM, Michael Snoyman wrote: > You could wrap chr with a call to spoon[1]. It's not the most elegant > solution, but it works. > > [1] > http://hackage.haskell.org/packages/archive/spoon/0.3/doc/html/Control-Spoon.html#v:spoon > > > On Thu, Jan 3, 2013 at 9:50 AM, Myles C. Maxfield < > myles.maxfield at gmail.com> wrote: > >> Hello, >> I'm working on a general text-processing library [1] and one of my >> quickcheck tests is designed to make sure that my library doesn't throw >> exceptions (it returns an Either type on failure). However, there are some >> inputs that cause me to pass bogus values to the 'chr' function (such >> as 1208914), which causes it to throw an exception. Is there a version of >> that function that is safe? (I'm hoping for something like Int -> Maybe >> Char). Alternatively, is there a way to know ahead of time whether or not >> an Int will cause 'chr' to throw an exception? >> >> Thanks, >> Myles C. Maxfield >> >> [1] http://hackage.haskell.org/package/punycode >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From muranushi at gmail.com Thu Jan 3 10:48:07 2013 From: muranushi at gmail.com (Takayuki Muranushi) Date: Thu, 3 Jan 2013 18:48:07 +0900 Subject: [Haskell-cafe] Lens, with ability to create a data-field when it's missing Message-ID: Dear All, I really am enjoying the lens (it is tough to learn, though :) Recently, I've been trying to implement a dynamic object --- a collection of methods that you can update at run-time --- using lens [1][2][3]. After several attempts, I think I have located the center of my problem: Lens with the ability "to create a data-field when it's missing." My question: is it possible? There are many excellent examples of partial lenses in the lens library, such as '_head' from Data.List.Lens 'dynamic' from Data.Dynamic.Lens . To me, they seem to share the following set of common behavior (allow me to use inaccurate terms...) - set l a s : if the field is present, insert 'a'; otherwise, do nothing. - over l f s : if the field is present, map 'f' over it. otherwise, do nothing. - preview l s : if the field is present, return 'Just a'. otherwise, return 'Nothing' . Instead, I want the following set of behaviors: - set l a s : if the field is present, insert 'a'; otherwise, *create the field* and insert 'a'. - over l f s : if the field is present, map 'f' over it. otherwise, do nothing. - preview l s : if the field is present, return 'Just a'. otherwise, return 'Nothing' . For example, the current behavior of _head is >>> [] & _head .~ 1 [] I want to implement a variant _head' , such that >>> [] & _head' .~ 1 [1] Let us call this behavior 'Member' for the moment. I have a implementation of 'Member' [4][5] but they are unsatisfactory. [4] involves runtime errors and breaking of lens laws. [5] shows that we can "create a field" only if we treat Dynamic explicitly out of lens context. I don't know how 'Member' will fit in the lens hierarchy http://i.imgur.com/FgfVW.png or even if it fits at all. Member is weaker than Getter and probably is a Fold since you have only partial getting (^?) for Member. Member is weaker than Prism since you cannot construct a whole Object from just one Member. On the other hand, setter side of Member requires (s -> b -> t) interface of a Lens, because the setter need to update the whole Object when the field under concern is missing. That said, let me put this question in another way; " We can construct a (Simple Lens s a) from (getter :: s -> a) and (setter :: s -> a -> s), and we can construct a (Getter s a) from (getter :: s -> a). Then why we cannot construct a (Simple Setter s a) from (setter :: s -> a -> s) ? " Does Member deserve a new node in The Lens Hierarchy tree? Or can we implement it by combinations of existing prisms, folds etc? Or does it fall outside of the lens framework? I appreciate any comments. Takayuki [1] https://github.com/nushio3/practice/tree/master/duck [2] http://d.hatena.ne.jp/nushio/20121226#p2 (Japanese) [3] http://hackage.haskell.org/packages/archive/dynamic-object/0.1.0.1/doc/html/Data-Object-Dynamic-Types.html [4] https://github.com/nushio3/practice/blob/master/lens/newfield.hs [5] https://github.com/nushio3/practice/blob/master/lens/object-4.hs -- Takayuki MURANUSHI The Hakubi Center for Advanced Research, Kyoto University http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html From agocorona at gmail.com Thu Jan 3 10:56:07 2013 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu, 3 Jan 2013 10:56:07 +0100 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> <50E4AFFF.9050705@gmail.com> Message-ID: Anyway, Type checking is essentially an application of set theory : (I did no search in te literature for this, It is just my perception). When I say (+) :: Num a => a -> a -> a . I mean that (+) takes two elements of the set of Num typeclass and return another. This is in principle a weak restriction, because many functions do it as well, for example (*). A propery check or a contract would be much more restrictive and thus would detect much more program errors. But it seems that no other language but haskell took this set theoretical analysis so exhaustively, and without it, a property check is like detecting microscopic cracks in nuclear waste vessel without first making sure that the cover has been sealed. 2013/1/2 MigMit > > On Jan 3, 2013, at 2:09 AM, Gershom Bazerman wrote: > > > On 1/2/13 4:29 PM, MigMit wrote: > >> > >>> BTW. Why you think that Eiffel type system is unsafe? > >> Well, if I remember correctly, if you call some method of a certain > object, and this call compiles, you can't be certain that this object > actually has this method. Could be that this object belongs to some > subclass which removes this method. > >> > > > > Eiffel doesn't handle the relationship of co- and contra-variance of > arguments with subtyping in a principled way. This is apparently known as > the "catcall" problem. See, e.g., this article: > http://www.eiffelroom.org/node/517 > > Yes, variance is another big source of unsafety, that's for sure. And > another reason I think there is no real "theory" behind Eiffel, just a > bunch of features (or "concepts") boiled together. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jamesjeffries1 at gmail.com Thu Jan 3 13:59:58 2013 From: jamesjeffries1 at gmail.com (James Jeffries) Date: Thu, 3 Jan 2013 12:59:58 +0000 Subject: [Haskell-cafe] Mancunian Haskellers out there? Message-ID: Hi there There isn't currently a haskell user groupu in Manchester, however there is a functional programming group where a lot of the member s are haskellers. http://www.lambdalounge.org.uk/ https://groups.google.com/forum/?fromgroups#!forum/lambda-lounge-manchester It is at Madlab in the Northern Quarter and there is usually a trip to the pub afterwards. Thanks James On 30/12/12 14:38, Alfredo Di Napoli wrote: Morning Cafe, I've been living in Manchester for 1 month now and I'm wondering if some on you are from the Greater Manchester area, so that we could chat about out beloved language in front of a glass of ale / tea :P Happy new year to everyone! A. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From mystic.satvik at gmail.com Thu Jan 3 14:07:17 2013 From: mystic.satvik at gmail.com (satvik chauhan) Date: Thu, 3 Jan 2013 18:37:17 +0530 Subject: [Haskell-cafe] Proving programs In-Reply-To: References: <50E37014.4090809@frigidcode.com> <7D5F3176-144D-48F5-A3E4-5B6521B0A4DE@kent.ac.uk> Message-ID: Which book does that chapter belongs to? -Satvik On Thu, Jan 3, 2013 at 11:44 AM, Andr?s Sicard-Ram?rez < andres.sicard.ramirez at gmail.com> wrote: > On Wed, Jan 2, 2013 at 12:22 PM, Simon Thompson > wrote: > > Christopher, there's an introduction to proof for functional programs at > > > > http://www.cs.kent.ac.uk/people/staff/sjt/Pubs/ProofChapter.pdf > > > > Simon, is it possible to get the list of the bibliographic references > used in the chapter? > > Best regards, > > -- > Andr?s > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andres.sicard.ramirez at gmail.com Thu Jan 3 14:11:09 2013 From: andres.sicard.ramirez at gmail.com (=?UTF-8?B?QW5kcsOpcyBTaWNhcmQtUmFtw61yZXo=?=) Date: Thu, 3 Jan 2013 08:11:09 -0500 Subject: [Haskell-cafe] Proving programs In-Reply-To: References: <50E37014.4090809@frigidcode.com> <7D5F3176-144D-48F5-A3E4-5B6521B0A4DE@kent.ac.uk> Message-ID: On Thu, Jan 3, 2013 at 8:07 AM, satvik chauhan wrote: > Which book does that chapter belongs to? http://www-fp.dcs.st-and.ac.uk/pfpbook/ -- Andr?s From lemming at henning-thielemann.de Thu Jan 3 14:13:24 2013 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 03 Jan 2013 14:13:24 +0100 (CET) Subject: [Haskell-cafe] [Haskell] Importing Repa library In-Reply-To: References: Message-ID: On Thu, 3 Jan 2013, ???????? ??????? wrote: > Hello! :) I think you should better post your question to haskell-cafe at haskell.org. > Then I put this script? > > import qualified Data.Array.Repa as R > :m +Data.Array.Repa > Z > > into the file "file.hs", This is GHCi syntax, but it is not a valid Haskell module as indicated by the .hs filename extension. > opened WinGHCi and loaded the file, and then evaluated it, but what I get is:? > > Could not find module `Data.Array.Repa' > Perhaps you meant > Data.Array.Base (from array-0.4.0.0) > Data.Array.IO (from array-0.4.0.0) > Data.Array.ST (from array-0.4.0.0) > Use -v to see a list of the files searched for. > Failed, modules loaded: none. I wonder why it loads file.hs at all. I would expect that it gives a syntax error. > Also ghc-pkg list repa says: > > WARNING: cache is out of date: C:/Program Files/Haskell Platform/2012.4.0.0\lib\package.conf.d\package.cache > use 'ghc-pkg recache' to fix. C:/Program Files/Haskell Platform/2012.4.0.0\lib\package.conf.d: > C:\Users\Faery\AppData\Roaming\ghc\i386mingw32-7.4.2\package.conf.d: Since 'repa' is not listed, it was not installed successfully. This would be consistent with the "Could not find module" message of GHCi. You may post the output of the 'cabal install repa' run. From alfredo.dinapoli at gmail.com Thu Jan 3 14:39:30 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Thu, 3 Jan 2013 13:39:30 +0000 Subject: [Haskell-cafe] Mancunian Haskellers out there? In-Reply-To: References: Message-ID: Great news James, thanks! I've checked on the map and is near Piccadilly Gardens, in the heart of Manchester! I'll join the google group and attend the next meeting for sure :) Cheers, A. On 3 January 2013 12:59, James Jeffries wrote: > Hi there > > There isn't currently a haskell user groupu in Manchester, however there > is a functional programming group where a lot of the member s are > haskellers. > > http://www.lambdalounge.org.uk/ > https://groups.google.com/forum/?fromgroups#!forum/lambda-lounge-manchester > > It is at Madlab in the Northern Quarter and there is usually a trip to the > pub afterwards. > > Thanks > James > > On 30/12/12 14:38, Alfredo Di Napoli wrote: > > Morning Cafe, > > I've been living in Manchester for 1 month now and I'm > wondering if some on you are from the Greater Manchester area, > so that we could chat about out beloved language in front of a > glass of ale / tea :P > > Happy new year to everyone! > A. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timon.gehr at gmx.ch Thu Jan 3 23:02:33 2013 From: timon.gehr at gmx.ch (Timon Gehr) Date: Thu, 03 Jan 2013 23:02:33 +0100 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> <50E4AFFF.9050705@gmail.com> Message-ID: On 01/03/2013 10:56 AM, Alberto G. Corona wrote: > Anyway, Type checking is essentially an application of set theory : (I > did no search in te literature for this, It is just my perception). Not exactly. Type theory is not an application of set theory, it is an alternative to set theory. > When > I say (+) :: Num a => a -> a -> a . I mean that (+) takes two elements > of the set of Num typeclass and return another. If I get this right, you consider Num to be a set, and then its inhabitants would need to be be types, thus this describes a type-level mapping. This is a more accurate description, (but there might be a better one): (+) : (a : Type)->(i : (Num a : Prop))->(x : a)->(y : a)->(z : a) (+) is a mapping from types 'a' to mappings from proofs 'i' of the proposition that 'a' is an instance of the 'Num' type class to a curried function that takes two arguments of type 'a' and produces a result of type 'a'. > This is in principle a > weak restriction, because many functions do it as well, for example (*). > > A propery check or a contract would be much more restrictive and thus > would detect much more program errors. But it seems that no other > language but haskell took this set theoretical analysis so exhaustively, There are quite a few that take it further than Haskell. http://wiki.portal.chalmers.se/agda/pmwiki.php > and without it, a property check is like detecting microscopic cracks in > nuclear waste vessel without first making sure that the cover has been > sealed. > From timon.gehr at gmx.ch Thu Jan 3 23:07:45 2013 From: timon.gehr at gmx.ch (Timon Gehr) Date: Thu, 03 Jan 2013 23:07:45 +0100 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> <50E4AFFF.9050705@gmail.com> Message-ID: On 01/02/2013 11:19 PM, MigMit wrote: > > On Jan 3, 2013, at 2:09 AM, Gershom Bazerman wrote: > >> On 1/2/13 4:29 PM, MigMit wrote: >>> >>>> BTW. Why you think that Eiffel type system is unsafe? >>> Well, if I remember correctly, if you call some method of a certain object, and this call compiles, you can't be certain that this object actually has this method. Could be that this object belongs to some subclass which removes this method. >>> >> >> Eiffel doesn't handle the relationship of co- and contra-variance of arguments with subtyping in a principled way. This is apparently known as the "catcall" problem. See, e.g., this article: http://www.eiffelroom.org/node/517 > > Yes, variance is another big source of unsafety, that's for sure. And another reason I think there is no real "theory" behind Eiffel, just a bunch of features (or "concepts") boiled together. > There seem to be efforts to fix this: http://tecomp.sourceforge.net/index.php?file=doc/papers/proof/ The resulting language appears to be type safe: http://tecomp.sourceforge.net/index.php?file=doc/papers/lang/modern_eiffel.txt#chapter_20 From efiish at gmail.com Fri Jan 4 08:20:59 2013 From: efiish at gmail.com (Junior White) Date: Fri, 4 Jan 2013 15:20:59 +0800 Subject: [Haskell-cafe] Fwd: Foreign.Erlang help In-Reply-To: References: <50D95EF0.1060701@eax.me> Message-ID: Hi Alexandar, Thanks for your help! I give up Foreign.Erlang and try usual tcp server in Haskell instead. ---------- Forwarded message ---------- From: Junior White Date: Fri, Jan 4, 2013 at 3:18 PM Subject: Re: [Haskell-cafe] Foreign.Erlang help To: Alexander Alexeev Hi Alexandar, Thanks for your help! I'll give up Foreign.Erlang and try usual tcp server in Haskell instead. On Tue, Dec 25, 2012 at 4:08 PM, Alexander Alexeev wrote: > First of all, you can write usual TCP server in Haskell and use it from > Erlang. It would be handy to use some widely used protocol, like Memcached > or Redis. > > If in some reason you want to use Foreign.Erlang, make sure that you are > using the same cookie and the same node name type (short or full) in Erlang > node and Haskell application. > > > On 12/24/2012 08:46 PM, Junior White wrote: > > Hi all, > I have a game server programming in erlang, but now i want to write some > game logic in haskell, how to write a haskell node for erlang? > > ps:I have read the introduce of Foreign.Erlang,I use haskell send a > message to a erlang echo server, but the server not receive anything. > > > _______________________________________________ > Haskell-Cafe mailing listHaskell-Cafe at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Best regards, > Alexander Alexeevhttp://eax.me/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidleothomas at gmail.com Fri Jan 4 13:27:51 2013 From: davidleothomas at gmail.com (David Thomas) Date: Fri, 4 Jan 2013 04:27:51 -0800 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: Message-ID: On Sun, Dec 30, 2012 at 1:27 PM, Brandon Allbery wrote: > > [T]he "Monad m =>" in the signature really means "hey, compiler, pass me > the appropriate implementation of Monad so I can figure out what I'm doing > with this type m". It's not a built in table, it's a hidden parameter. > > Well, "hidden" - it *is* right there in the type signature still, it just doesn't *look* like an argument. It also might be optimized away in static cases (certainly, it *could* happen, whether does or is even worthwhile is another question). -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Fri Jan 4 13:51:13 2013 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Fri, 4 Jan 2013 19:51:13 +0700 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: Message-ID: On Fri, Jan 4, 2013 at 7:27 PM, David Thomas wrote: > Well, "hidden" - it *is* right there in the type signature still, it just > doesn't *look* like an argument. > If you squint hard enough, (=>) looks like (->). Or maybe the other way round. Whatever. :) > It also might be optimized away in static cases (certainly, it *could* > happen, whether does or is even worthwhile is another question). > The optimization at stake is specialization. Given (Num a => a), specialize it to Int or Double or X so that it's memoizably first-class, which is where functions still fall down [1]. All functions are values but data values still play nicer than others. Isn't fixing this the real cure for the monomorphism restriction? [1] http://lukepalmer.wordpress.com/2009/07/07/emphasizing-specialization/#comment-862 -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Fri Jan 4 20:34:32 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Fri, 04 Jan 2013 14:34:32 -0500 Subject: [Haskell-cafe] Makefile for a Haskell Project In-Reply-To: References: <20121228022037.82685tp0bc5m797p@stuttard.org> Message-ID: <50E72EC8.9020608@vex.net> On 13-01-02 01:01 AM, xuan bach wrote: > ========================= > BASEDIR=/usr/local > INCS= -I$(BASEDIR)/include/omega -I. > LIBS= -L$(BASEDIR)/lib > LIB= -lcode_gen -lomega -lm > > GHC=ghc > > #---------------------------------------------------- > CFILES=$(CURDIR)/cfile > HSFILES=$(CURDIR)/hsfile > COBJFILES=$(CFILES)/termops.o $(CFILES)/termops2.o > ALLCFILES=$(CFILES)/termops.c $(CFILES)/termops2.c > #---------------------------------------------------- > > GHC_FLAGS= -O2 -fglasgow-exts -fallow-overlapping-instances > > _ffi_ex: $(COBJFILES) > ghc $(GHC_FLAGS) -lstdc++ --make -main-is FfiEx -o ffi_ex > FfiEx.hs $(HSFILES)/*.hs $(LIBS) $(LIB) $(COBJFILES) > ========================= > => *fatal error: omega.h: No such file or directory An implicit rule is triggered to compile *.c to *.o. The rule goes like $(CC) -c $(CPPFLAGS) $(CFLAGS) Therefore, your -I$(BASEDIR)/include/omega -I. is ignored. To solve, put -I$(BASEDIR)/include/omega -I. in CFLAGS, or write your own rule for compiling *.c to *.o. From mail at nh2.me Fri Jan 4 22:36:31 2013 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Fri, 04 Jan 2013 22:36:31 +0100 Subject: [Haskell-cafe] Cabal bug? repeat "--reinstall" Message-ID: <50E74B5F.6040307@nh2.me> I get the following: $ cabal install --only-dependencies --reinstall Resolving dependencies... All the requested packages are already installed: Use --reinstall if you want to reinstall anyway. Can somebody confirm that they see the same? From colinpauladams at gmail.com Sat Jan 5 01:14:55 2013 From: colinpauladams at gmail.com (Colin Adams) Date: Sat, 5 Jan 2013 00:14:55 +0000 Subject: [Haskell-cafe] Object Oriented programming for Functional Programmers In-Reply-To: References: <299851357064604@web26e.yandex.ru> <5A9B284B-294E-4576-B757-4BC26B78D6B5@yandex.ru> <2ee56591-1a54-4460-90fc-6f0bdb47d84d@email.android.com> <9EAEF82B-15C4-4FCF-8D99-C0EEDB7898DE@yandex.ru> <33BB9242-CA9C-4B67-95D7-D146319DBD06@yandex.ru> <20130102052814.52ef1ff8@bhuda.mired.org> <298951357129460@web21h.yandex.ru> <05BA155F-5ED6-4ED7-A8BD-40F33333E023@yandex.ru> <50E4AFFF.9050705@gmail.com> Message-ID: There have been lots of proposals to fix the CATCALL problems in recent years. None have been implemented (at least in ISE/GEC compilers. And tecomp has been abandonded by its author - he is now writing a series of blogs about a vapourware product called "Modern Eiffel"). I don't find the CATCALL problem a great problem in practice (one gets used to avoiding the problem). But it is a nasty whole in the theory of the type system. On 3 January 2013 22:07, Timon Gehr wrote: > On 01/02/2013 11:19 PM, MigMit wrote: > >> >> On Jan 3, 2013, at 2:09 AM, Gershom Bazerman wrote: >> >> On 1/2/13 4:29 PM, MigMit wrote: >>> >>>> >>>> BTW. Why you think that Eiffel type system is unsafe? >>>>> >>>> Well, if I remember correctly, if you call some method of a certain >>>> object, and this call compiles, you can't be certain that this object >>>> actually has this method. Could be that this object belongs to some >>>> subclass which removes this method. >>>> >>>> >>> Eiffel doesn't handle the relationship of co- and contra-variance of >>> arguments with subtyping in a principled way. This is apparently known as >>> the "catcall" problem. See, e.g., this article: >>> http://www.eiffelroom.org/**node/517 >>> >> >> Yes, variance is another big source of unsafety, that's for sure. And >> another reason I think there is no real "theory" behind Eiffel, just a >> bunch of features (or "concepts") boiled together. >> >> > There seem to be efforts to fix this: > http://tecomp.sourceforge.net/**index.php?file=doc/papers/**proof/ > > The resulting language appears to be type safe: > http://tecomp.sourceforge.net/**index.php?file=doc/papers/** > lang/modern_eiffel.txt#**chapter_20 > > > > > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Sat Jan 5 02:36:06 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Fri, 04 Jan 2013 20:36:06 -0500 Subject: [Haskell-cafe] Cabal bug? repeat "--reinstall" In-Reply-To: <50E74B5F.6040307@nh2.me> References: <50E74B5F.6040307@nh2.me> Message-ID: <50E78386.1070203@vex.net> On 13-01-04 04:36 PM, Niklas Hamb?chen wrote: > I get the following: > > $ cabal install --only-dependencies --reinstall > > Resolving dependencies... > All the requested packages are already installed: > Use --reinstall if you want to reinstall anyway. > > > Can somebody confirm that they see the same? I confirm. From efiish at gmail.com Sat Jan 5 04:33:48 2013 From: efiish at gmail.com (Junior White) Date: Sat, 5 Jan 2013 11:33:48 +0800 Subject: [Haskell-cafe] Compliments on the "IO inside" tutorial In-Reply-To: References: Message-ID: As a Haskell Beginner I also appreciate this excellent work! On Fri, Dec 7, 2012 at 10:53 AM, Andriy Drozdyuk wrote: > I just wanted to express my gratitude to whoever wrote the "IO inside" > tutorial: > http://www.haskell.org/haskellwiki/IO_inside > > It is one of the best pieces of writing in Haskell I've ever come > across: not only is it clear and very intuitive, but it also manages > to strike a perfect balance between "programmers" and "beginner > haskell programmers". > It certainly ties together a lot of other stuff one reads in books and > category theory - and actually makes sense! > > My sincere gratitude, and keep up great job. I can only hope to write > something as clear and useful as this. > > My only complaint is that it is really wasting away inside the Haskell > Wiki - which gives it a rather bad "reputation", since a lot of wiki > pages are of much lower quality. This should be nicely formatted in a > PDF file or a even part of a book! Make it pretty and get people to > notice it!!! > > Now i must sleep, > -Andriy Drozdyuk > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christopher.howard at frigidcode.com Sun Jan 6 02:03:23 2013 From: christopher.howard at frigidcode.com (Christopher Howard) Date: Sat, 05 Jan 2013 16:03:23 -0900 Subject: [Haskell-cafe] ln, e Message-ID: <50E8CD5B.5010205@frigidcode.com> Hi. Are natural log and Euler's constant defined somewhere in base, or a convenience math module somewhere? I'm having trouble finding them with hayoo or system documentation. -- frigidcode.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 553 bytes Desc: OpenPGP digital signature URL: From chaddai.fouche at gmail.com Sun Jan 6 02:06:16 2013 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Sun, 6 Jan 2013 02:06:16 +0100 Subject: [Haskell-cafe] ln, e In-Reply-To: <50E8CD5B.5010205@frigidcode.com> References: <50E8CD5B.5010205@frigidcode.com> Message-ID: log and (exp 1) are the natural logarithm and e. -- Jeda? On Sun, Jan 6, 2013 at 2:03 AM, Christopher Howard wrote: > Hi. Are natural log and Euler's constant defined somewhere in base, or a > convenience math module somewhere? I'm having trouble finding them with > hayoo or system documentation. > > -- > frigidcode.com > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at googlemail.com Sun Jan 6 02:09:44 2013 From: daniel.is.fischer at googlemail.com (Daniel Fischer) Date: Sun, 06 Jan 2013 02:09:44 +0100 Subject: [Haskell-cafe] ln, e In-Reply-To: <50E8CD5B.5010205@frigidcode.com> References: <50E8CD5B.5010205@frigidcode.com> Message-ID: <7434158.UhSq63cXTI@linux-v7dw.site> On Samstag, 5. Januar 2013, 16:03:23, Christopher Howard wrote: > Hi. Are natural log and Euler's constant defined somewhere in base, or a > convenience math module somewhere? I'm having trouble finding them with > hayoo or system documentation. The natural logarithm is simply `log`. Euler's constant isn't defined anywhere, you get it (the best approximation, at least very nearly) with `exp 1`. From hamish at firestream.co.uk Sun Jan 6 03:16:26 2013 From: hamish at firestream.co.uk (Hamish Mackenzie) Date: Sun, 6 Jan 2013 15:16:26 +1300 Subject: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental) Message-ID: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> This has mostly bug fixes, GHC 7.4.2, GHC 7.6.1 and Gtk3 support. I have not uploaded it to Hackage as it uses Gtk2Hs patches that are not in Hackage. New features include "View->Dark" (OS X only) and "View->Fullscreen". OS X (using Gtk3) ----------------- Choose the version that matches your installed GHC http://leksah.org/packages/leksah-0.13.1.0-ghc-7.0.3.dmg http://leksah.org/packages/leksah-0.13.1.0-ghc-7.0.4.dmg http://leksah.org/packages/leksah-0.13.1.0-ghc-7.4.1.dmg http://leksah.org/packages/leksah-0.13.1.0-ghc-7.4.2.dmg http://leksah.org/packages/leksah-0.13.1.0-ghc-7.6.1.dmg (probable needs OS X 10.7) Windows (still Gtk2) -------------------- Choose the version that matches your installed GHC http://leksah.org/packages/leksah-0.13.1.0-ghc-7.0.3.exe http://leksah.org/packages/leksah-0.13.1.0-ghc-7.0.4.exe http://leksah.org/packages/leksah-0.13.1.0-ghc-7.4.1.exe http://leksah.org/packages/leksah-0.13.1.0-ghc-7.4.2.exe Linux ----- Follow the steps in the .travis.yml file... https://github.com/leksah/leksah/blob/master/.travis.yml Should go something like this... https://travis-ci.org/leksah/leksah From caseybasichis at gmail.com Sun Jan 6 18:01:44 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Sun, 6 Jan 2013 09:01:44 -0800 Subject: [Haskell-cafe] Undo records Message-ID: Hi, I am still getting a hang of Haskell. Sorry if the answer is obvious. What sorts of packages and approaches should I be looking at if I was looking to store something like an Undo stack into a database. Each table would refer to a function. Each records input and outputs would specify both a table ID and record ID. The records would also have a data and a Process ID to associate all functions to a specific process and give them an order. No records are ever deleted. Rolling something back is instead a process of recreating a new, modified graph by taking the old graph from the database. I should note that while I can generate some of the boiler parts from template haskell in advance I'm ultimately using a stage 1 compiler with no GHCI o template haskell. Thanks, Casey -- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis at gmail.com 310.387.7540 -------------- next part -------------- An HTML attachment was scrubbed... URL: From iavor.diatchki at gmail.com Sun Jan 6 22:24:59 2013 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Sun, 6 Jan 2013 13:24:59 -0800 Subject: [Haskell-cafe] ANN: New version of pretty-show, now with Html support Message-ID: Hello, I've uploaded a new version of the pretty-show package (1.5) to Hackage, which provides some useful tools for inspecting Haskell data-structures. I find it quite useful while debugging. The package provides a binary and a library: the binary, named `ppsh` can take as an input a Haskell value in standard `Show` notation, and can: * Either render it to a more human readable version by adding extra white-space and newlines, thus ensuring that the result is still a valid Haskell value, or * It can render the value as an interactive Html page, which is new in this version. The library provides similar functionality but in a programatically. Also, it has some support for working with non-Showable values, by using the `PrettyVal` class, which may be derived generically. As an example, I am attaching a picture of a part of a data-structure generated with the `language-c-quote` library, by using the standard `Show` instance. I hope you find this useful, -Iavor -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pretty-show.png Type: image/png Size: 55105 bytes Desc: not available URL: From thomashartman1 at gmail.com Mon Jan 7 06:12:14 2013 From: thomashartman1 at gmail.com (Thomas Hartman) Date: Sun, 6 Jan 2013 21:12:14 -0800 Subject: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times. In-Reply-To: References: Message-ID: I have a space leak in a function that increments a number inside IORef or STRef (either lazy or strict). Is this the kind of problem that can be diagnosed and fixed using the approach described in RWH, with space profiling? Otherwise what's the right approach to diagnose and fix? I wrote a non-list-using, and tail call-using, iterateMonadic funcation that does the same thing as replicateM, in case the problem was due to iterateM using a list structure, but iterateMonadic and replicateM had same memory leak. I can run this problem with +RTS -K100M -RTS but this aditional memory shouldn't be needed. {-# LANGUAGE RankNTypes, BangPatterns #-} import Data.List import Control.Monad.State.Strict import Data.Array.MArray import Data.Array.IO import Data.Array.ST import Control.Monad.ST import Control.Applicative import Data.IORef import Data.STRef.Strict import Data.STRef import GHC.ST import Control.Applicative ((<$>)) main = do -- putStrLn "ioIters, iterateMonadic: " -- print =<< ioIters iters iterateMonadic -- putStrLn "ioIters, replicateM_: " -- print =<< ioIters iters replicateM_ -- putStrLn "lazySTIters, iterateMonadic: " -- print $ lazySTIters iters iterateMonadic -- putStrLn "lazySTIters, replicateM_: " -- print $ lazySTIters iters replicateM_ putStrLn "strictSTIters, iterateMonadic: " print $ strictSTIters iters iterateMonadic -- putStrLn "strictSTIters, replicateM_: " -- print $ strictSTIters iters replicateM_ type Iter = (Monad m) => Int -> m () -> m () iterateMonadic :: (Monad m) => Int -> m a -> m a iterateMonadic n mx = do let loop 0 acc = acc loop n acc = loop (n-1) (acc >> mx ) loop n mx iters = 10^7 ioIters :: Int -> Iter -> IO Int ioIters numIters iteratorM = do tmp <- newIORef 0 iteratorM numIters ( modifyIORef tmp (+1) ) readIORef tmp lazySTIters :: Int -> Iter -> Int lazySTIters numIters iteratorM = runST $ do tmp <- Data.STRef.newSTRef 0 iteratorM numIters ( Data.STRef.modifySTRef tmp (+1) ) Data.STRef.readSTRef tmp strictSTIters :: Int -> Iter -> Int strictSTIters numIters iteratorM = runST $ do tmp <- Data.STRef.Strict.newSTRef 0 iteratorM numIters ( Data.STRef.Strict.modifySTRef tmp incr' ) Data.STRef.Strict.readSTRef tmp incr' (!x) = x + 1 From hamish.k.mackenzie at gmail.com Mon Jan 7 06:34:49 2013 From: hamish.k.mackenzie at gmail.com (Hamish Mackenzie) Date: Mon, 7 Jan 2013 18:34:49 +1300 Subject: [Haskell-cafe] Announce: Leksah 0.13.1.1 (a bit experimental) In-Reply-To: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> References: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> Message-ID: <1B9FF970-09B6-4FB0-AA21-08326704C8E0@gmail.com> I fixed some annoying issues with 0.13.1.0 and added "Panes->HLint". OS X (using Gtk3) ----------------- Choose the version that matches your installed GHC http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.3.dmg http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.4.dmg http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.1.dmg http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.2.dmg http://leksah.org/packages/leksah-0.13.1.1-ghc-7.6.1.dmg (probable needs OS X 10.7) Windows (still Gtk2) -------------------- Choose the version that matches your installed GHC http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.3.exe http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.4.exe http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.1.exe http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.2.exe http://leksah.org/packages/leksah-0.13.1.1-ghc-7.6.1.exe On 6 Jan 2013, at 15:16, Hamish Mackenzie wrote: > This has mostly bug fixes, GHC 7.4.2, GHC 7.6.1 and Gtk3 > support. > > I have not uploaded it to Hackage as it uses Gtk2Hs patches > that are not in Hackage. > > New features include "View->Dark" (OS X only) and > "View->Fullscreen". > > Linux > ----- > Follow the steps in the .travis.yml file... > https://github.com/leksah/leksah/blob/master/.travis.yml > Should go something like this... > https://travis-ci.org/leksah/leksah From ekirpichov at gmail.com Mon Jan 7 07:05:08 2013 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun, 6 Jan 2013 22:05:08 -0800 Subject: [Haskell-cafe] Weird problem: Couldn't read cabal file "hashable/1.2.0.0/hashable.cabal" Message-ID: Hi, A friend of mine is trying to install my "timeplotters" (see email signature). He's getting a weird error: one of the tools installs fine but the other one fails with the error "Couldn't read cabal file "hashable/ 1.2.0.0/hashable.cabal""; curiously, so does running "cabal install cabal-install". Even more curiously, hashable 1.2.0.0 does not appear anywhere in the list of dependencies, even indirect. Look: $ cabal -v3 install cabal-install searching for ghc in path. found ghc at /usr/bin/ghc ("/usr/bin/ghc",["--numeric-version"]) /usr/bin/ghc is version 7.0.3 looking for tool "ghc-pkg" near compiler in /usr/bin found ghc-pkg in /usr/bin/ghc-pkg ("/usr/bin/ghc-pkg",["--version"]) /usr/bin/ghc-pkg is version 7.0.3 ("/usr/bin/ghc",["--supported-languages"]) ("/usr/bin/ghc",["--info"]) Reading installed packages... ("/usr/bin/ghc-pkg",["dump","--global","-v2"]) ("/usr/bin/ghc-pkg",["dump","--user","-v2"]) ("/usr/bin/ghc",["--print-libdir"]) Reading available packages... Resolving dependencies... cabal: Couldn't read cabal file "hashable/1.2.0.0/hashable.cabal" He's using haskell platform on Ubuntu 12.04. $ ghc ?version The Glorious Glasgow Haskell Compilation System, version 7.0.3 $ cabal ?version cabal-install version 0.10.2 using version 1.10.1.0 of the Cabal library He *did* try erasing ~/.cabal, ~/.ghc and /usr/lib/ghc and then reinstalling haskell-platform package - it didn't change anything. He doesn't remember ever having Haskell installed before, but that can't be completely ruled out. I just tried installing a fresh Ubuntu 12.04 onto a VM and I did not have this problem that he has. What additional information can I ask him for? Maybe somebody already encountered this problem? (Actually, I have a whole strace cabal install cabal-install, but it's 33Mb - I can upload it somewhere if it could be helpful). -- Eugene Kirpichov http://www.linkedin.com/in/eugenekirpichov http://jkff.info/software/timeplotters - my performance visualization tools -------------- next part -------------- An HTML attachment was scrubbed... URL: From ekirpichov at gmail.com Mon Jan 7 07:09:35 2013 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun, 6 Jan 2013 22:09:35 -0800 Subject: [Haskell-cafe] Weird problem: Couldn't read cabal file "hashable/1.2.0.0/hashable.cabal" In-Reply-To: References: Message-ID: The curious thing about that strace is that it doesn't ever attempt to open hashable.cabal - in fact, it isn't attempting to open *any* .cabal file whatsoever before failing! So I'm totally confused as to why cabal might be complaining that it can't open hashable.cabal. On Sun, Jan 6, 2013 at 10:05 PM, Eugene Kirpichov wrote: > Couldn't read cabal file -- Eugene Kirpichov http://www.linkedin.com/in/eugenekirpichov http://jkff.info/software/timeplotters - my performance visualization tools -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Mon Jan 7 07:11:26 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 7 Jan 2013 01:11:26 -0500 Subject: [Haskell-cafe] Weird problem: Couldn't read cabal file "hashable/1.2.0.0/hashable.cabal" In-Reply-To: References: Message-ID: On Mon, Jan 7, 2013 at 1:05 AM, Eugene Kirpichov wrote: > A friend of mine is trying to install my "timeplotters" (see email > signature). > He's getting a weird error: one of the tools installs fine but the other > one fails with the error "Couldn't read cabal file "hashable/ > 1.2.0.0/hashable.cabal""; curiously, so does running "cabal install > cabal-install". > That's a symptom of too old cabal-install that crashes when it encounters certain newer cabal file features. I believe you need to upgrade cabal-install manually (since cabal-install itself will crash trying to do so...). It's not opening a cabal file directly, it is trying to parse entries in the compressed package list. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Mon Jan 7 07:35:32 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Mon, 07 Jan 2013 01:35:32 -0500 Subject: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times. In-Reply-To: References: Message-ID: <50EA6CB4.7090402@vex.net> On 13-01-07 12:12 AM, Thomas Hartman wrote: > I have a space leak in a function that increments a number inside > IORef or STRef (either lazy or strict). IORef and STRef operations do not automatically evaluate contents. "writeIORef r (x + 1)" simply stores a pointer to the expression (thunk) "x + 1" into the mutable cell. readIORef just reports back a pointer. modifyIORef just calls readIORef and writeIORef. No evaluation throughout. "modifyIORef incr" where incr !x = x + 1 does not make a difference because it is just "writeIORef r (incr x))", i.e., simply stores a pointer to the expression (thunk) "incr x" into the mutable cell. The whole process doesn't even care about how many bangs are in incr. (It is illuminating to consider how "const True (incr x)" does not evaluate x. A pointer to True and a pointer to "incr x" are passed to const, then const throws away the latter without even looking. See also "const True undefined". One day, you will thank "writeIORef r undefined"; I certainly did.) Same for both Data.STRef.Strict and Data.STRef.Lazy. They do not mean what you think. Here is what they mean: Data.STRef.Strict means what Control.Monad.ST.Strict means Data.STRef.Lazy means what Control.Monad.ST.Lazy means Control.Monad.ST.Strict means that the following hangs: x = head (runST list) where list :: ST s [Bool] list = do {xs <- list; return (True : xs)} Control.Monad.ST.Lazy means that the above terminates and gives the answer True. (Up to this point, same story for Control.Monad.State.Strict and Control.Monad.State.Lazy.) I still have not understood Control.Monad.ST.Lazy enough to articulate its full semantics, but I have some more examples to show what it does: http://hpaste.org/63925 By understanding what "Lazy" in Control.Monad.ST.Lazy means, you also see what "Strict" does *not* mean. In IO or Control.Monad.ST.Strict, use let y = x+1 in y `seq` write[IO/ST]Ref r y to expedite the evaluation of x+1. Using the same idea, you may write your own modify[IO/ST]RefNOW to evaluate while updating. From therealkludgy at gmail.com Mon Jan 7 07:54:35 2013 From: therealkludgy at gmail.com (Darren Grant) Date: Sun, 6 Jan 2013 22:54:35 -0800 Subject: [Haskell-cafe] Announce: Leksah 0.13.1.1 (a bit experimental) In-Reply-To: <1B9FF970-09B6-4FB0-AA21-08326704C8E0@gmail.com> References: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> <1B9FF970-09B6-4FB0-AA21-08326704C8E0@gmail.com> Message-ID: Thank you kindly for this release! System-wide package metadata is working with my platform install now. :) Cheers, d On Sun, Jan 6, 2013 at 9:34 PM, Hamish Mackenzie < hamish.k.mackenzie at gmail.com> wrote: > I fixed some annoying issues with 0.13.1.0 and > added "Panes->HLint". > > OS X (using Gtk3) > ----------------- > Choose the version that matches your installed GHC > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.3.dmg > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.4.dmg > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.1.dmg > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.2.dmg > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.6.1.dmg > (probable needs OS X 10.7) > > Windows (still Gtk2) > -------------------- > Choose the version that matches your installed GHC > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.3.exe > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.0.4.exe > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.1.exe > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.4.2.exe > http://leksah.org/packages/leksah-0.13.1.1-ghc-7.6.1.exe > > On 6 Jan 2013, at 15:16, Hamish Mackenzie > wrote: > > > This has mostly bug fixes, GHC 7.4.2, GHC 7.6.1 and Gtk3 > > support. > > > > I have not uploaded it to Hackage as it uses Gtk2Hs patches > > that are not in Hackage. > > > > New features include "View->Dark" (OS X only) and > > "View->Fullscreen". > > > > Linux > > ----- > > Follow the steps in the .travis.yml file... > > https://github.com/leksah/leksah/blob/master/.travis.yml > > Should go something like this... > > https://travis-ci.org/leksah/leksah > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tomberek at gmail.com Mon Jan 7 07:56:12 2013 From: tomberek at gmail.com (Thomas Bereknyei) Date: Mon, 7 Jan 2013 01:56:12 -0500 Subject: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times. Message-ID: I have had issues like this with modifySTRef before. Try to make a strict version modifySTRef' If memory serves, something like this worked for me. modifySTRef' r f = do a <- readSTRef r writeSTRef r $! f a -------------- next part -------------- An HTML attachment was scrubbed... URL: From chrisdone at gmail.com Mon Jan 7 08:14:32 2013 From: chrisdone at gmail.com (Christopher Done) Date: Mon, 7 Jan 2013 08:14:32 +0100 Subject: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times. In-Reply-To: <50EA6CB4.7090402@vex.net> References: <50EA6CB4.7090402@vex.net> Message-ID: A similar use-case and same solution with IORefs: http://hpaste.org/diff/80055/80058 Guess which one threw a stackoverflow and which one ran indefinitely when given a few hundred million lines of input. On 7 January 2013 07:35, Albert Y. C. Lai wrote: > On 13-01-07 12:12 AM, Thomas Hartman wrote: >> >> I have a space leak in a function that increments a number inside >> IORef or STRef (either lazy or strict). > > > IORef and STRef operations do not automatically evaluate contents. > "writeIORef r (x + 1)" simply stores a pointer to the expression (thunk) "x > + 1" into the mutable cell. readIORef just reports back a pointer. > modifyIORef just calls readIORef and writeIORef. No evaluation throughout. > > "modifyIORef incr" where > > incr !x = x + 1 > > does not make a difference because it is just "writeIORef r (incr x))", > i.e., simply stores a pointer to the expression (thunk) "incr x" into the > mutable cell. The whole process doesn't even care about how many bangs are > in incr. > > (It is illuminating to consider how "const True (incr x)" does not evaluate > x. A pointer to True and a pointer to "incr x" are passed to const, then > const throws away the latter without even looking. See also "const True > undefined". One day, you will thank "writeIORef r undefined"; I certainly > did.) > > Same for both Data.STRef.Strict and Data.STRef.Lazy. They do not mean what > you think. Here is what they mean: > > Data.STRef.Strict means what Control.Monad.ST.Strict means > Data.STRef.Lazy means what Control.Monad.ST.Lazy means > > Control.Monad.ST.Strict means that the following hangs: > > x = head (runST list) where > list :: ST s [Bool] > list = do {xs <- list; return (True : xs)} > > Control.Monad.ST.Lazy means that the above terminates and gives the answer > True. > > (Up to this point, same story for Control.Monad.State.Strict and > Control.Monad.State.Lazy.) > > I still have not understood Control.Monad.ST.Lazy enough to articulate its > full semantics, but I have some more examples to show what it does: > > http://hpaste.org/63925 > > By understanding what "Lazy" in Control.Monad.ST.Lazy means, you also see > what "Strict" does *not* mean. > > In IO or Control.Monad.ST.Strict, use > > let y = x+1 in y `seq` write[IO/ST]Ref r y > > to expedite the evaluation of x+1. Using the same idea, you may write your > own modify[IO/ST]RefNOW to evaluate while updating. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mail at joachim-breitner.de Mon Jan 7 13:06:35 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Mon, 07 Jan 2013 13:06:35 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? Message-ID: <1357560395.15170.4.camel@kirk> Dear Haskellers, I?m wondering if the use of deepseq to avoid unwanted lazyness might be a too large hammer in some use cases. Therefore, I?m looking for real world programs with ample use of deepseq, and ideally easy ways to test performance (so preferably no GUI applications). I?ll try to find out, by runtime observerations, which of the calls ot deepseq could be replaced by id, seq, or ?shallow seqs? that, for example, calls seq on the elements of a tuple. Thanks, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From ezyang at MIT.EDU Mon Jan 7 13:20:43 2013 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Mon, 07 Jan 2013 04:20:43 -0800 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357560395.15170.4.camel@kirk> References: <1357560395.15170.4.camel@kirk> Message-ID: <1357560810-sup-9663@javelin> There are two senses in which deepseq can be overkill: 1. The structure was already strict, and deepseq just forces another no-op traversal of the entire structure. This hypothetically affects seq too, although seq is quite cheap so it's not a problem. 2. deepseq evaluates too much, when it was actually sufficient only to force parts of the structure, e.g. the spine of a list. This is less common for the common use-cases of deepseq; e.g. if I want to force pending exceptions I am usually interested in all exceptions in a (finite) data structure; a space leak may be due to an errant closure---if I don't know which it is, deepseq will force all of them, ditto with work in parallel programs. Certainly there will be cases where you will want snip evaluation at some point, but that is somewhat difficult to encode as a typeclass, since the criterion varies from structure to structure. (Though, perhaps, this structure would be useful: data Indirection a = Indirection a class DeepSeq Indirection rnf _ = () ) Cheers, Edward Excerpts from Joachim Breitner's message of Mon Jan 07 04:06:35 -0800 2013: > Dear Haskellers, > > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > a too large hammer in some use cases. Therefore, I?m looking for real > world programs with ample use of deepseq, and ideally easy ways to test > performance (so preferably no GUI applications). > > I?ll try to find out, by runtime observerations, which of the calls ot > deepseq could be replaced by id, seq, or ?shallow seqs? that, for > example, calls seq on the elements of a tuple. > > Thanks, > Joachim > From mail at joachim-breitner.de Mon Jan 7 16:59:45 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Mon, 07 Jan 2013 16:59:45 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357560395.15170.4.camel@kirk> References: <1357560395.15170.4.camel@kirk> Message-ID: <1357574385.15170.14.camel@kirk> Hi, Am Montag, den 07.01.2013, 13:06 +0100 schrieb Joachim Breitner: > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > a too large hammer in some use cases. Therefore, I?m looking for real > world programs with ample use of deepseq, and ideally easy ways to test > performance (so preferably no GUI applications). surprisingly, deepseq is not used as much as I thought. http://packdeps.haskellers.com/reverse/deepseq lists a lot of packages, but (after grepping through some of the code) most just define NFData instances and/or use it in tests, but rarely in the ?real? code. For some reason I expected it to be in more widespread use. But therefore I am even more interested in non-hackaged applications that I can be allowed to stud ? in return I might be able to tell you way to speed up your application. Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From johan.tibell at gmail.com Mon Jan 7 17:12:31 2013 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon, 7 Jan 2013 08:12:31 -0800 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357560395.15170.4.camel@kirk> References: <1357560395.15170.4.camel@kirk> Message-ID: On Mon, Jan 7, 2013 at 4:06 AM, Joachim Breitner wrote: > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > a too large hammer in some use cases. Therefore, I?m looking for real > world programs with ample use of deepseq, and ideally easy ways to test > performance (so preferably no GUI applications). I never use deepseq, except when setting up benchmark data where it's a convenient way to make sure that the data is evaluated before the benchmark is run. When removing space leaks you want to avoid creating the thunks in the first place, not remove them after the fact. Consider a leak caused by a list of N thunks. Even if you deepseq that list to eventually remove those thunks, you won't lower your peak memory usage if the list was materialized at some point. In addition, by not creating the thunks in the first place you avoid some allocation costs. -- Johan From simons at cryp.to Mon Jan 7 19:25:22 2013 From: simons at cryp.to (Peter Simons) Date: Mon, 07 Jan 2013 19:25:22 +0100 Subject: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental) References: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> Message-ID: <87sj6cyhnx.fsf@write-only.cryp.to> Hi Hamish, would it be possible to get an update for process-leksah that works with recent versions of the 'filepath' package? I cannot build leksah-server with GCC 7.4.2 because of this issue. Take care, Peter From hamish.k.mackenzie at gmail.com Tue Jan 8 02:05:08 2013 From: hamish.k.mackenzie at gmail.com (Hamish Mackenzie) Date: Tue, 8 Jan 2013 14:05:08 +1300 Subject: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental) In-Reply-To: <87sj6cyhnx.fsf@write-only.cryp.to> References: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> <87sj6cyhnx.fsf@write-only.cryp.to> Message-ID: <1A348C74-E274-4821-B328-F9D02D8F622C@gmail.com> Features in process-leksah have been merged into process. For newer versions of GHC leksah-server just depends on process. If it is trying to install process-leksah then something else has probably gone wrong. Check "ghc-pkg list" for old versions of leksah. Make sure you have the latest versions of ltk, leksah and leksah-server from github. (if you use cabal-meta they will be in the "leksah/vendor" subdirectory). Here are the steps for installing from scratch... https://github.com/leksah/leksah/blob/master/.travis.yml Here is what it should look like when it installs... https://travis-ci.org/leksah/leksah On 8 Jan 2013, at 07:25, Peter Simons wrote: > Hi Hamish, > > would it be possible to get an update for process-leksah that works with > recent versions of the 'filepath' package? I cannot build leksah-server > with GCC 7.4.2 because of this issue. > > Take care, > Peter > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From edskodevries at gmail.com Tue Jan 8 13:22:59 2013 From: edskodevries at gmail.com (Edsko de Vries) Date: Tue, 8 Jan 2013 12:22:59 +0000 Subject: [Haskell-cafe] Difference Lists versus Accumulators Message-ID: Hey all, The connection between difference lists and accumulators is probably well known, but I only recently realized it myself and a quick Google search didn't find turn up any page where this was explicitly stated, so I thought this observation might be useful to some. Every beginner Haskell student learns that this definition of "reverse" has O(n^2) complexity: reverse [] = [] reverse (x : xs) = reverse xs ++ [x] But what happens when we return a difference list instead, replacing [] with id, (++) with (.) and [x] with (x :)? reverse' [] = id reverse' (x : xs) = reverse xs . (x :) This definition of reverse' has type reverse' :: [a] -> [a] -> [a] Let's inline the second argument: reverse' [] acc = acc reverse' (x : xs) acc = reverse' xs (x : acc) And we have recovered the standard definition using an accumulator! I thought that was cute :) And may help understanding why difference lists are useful. Edsko From roma at ro-che.info Tue Jan 8 13:57:03 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Tue, 8 Jan 2013 14:57:03 +0200 Subject: [Haskell-cafe] Difference Lists versus Accumulators In-Reply-To: References: Message-ID: <20130108125703.GA3002@sniper> * Edsko de Vries [2013-01-08 12:22:59+0000] > But what happens when we return a difference list instead, replacing > [] with id, (++) with (.) and [x] with (x :)? > > ... > > And we have recovered the standard definition using an accumulator! I > thought that was cute :) And may help understanding why difference > lists are useful. > > Edsko Perl: There Is More Than One Way To Do It Python: There Is One Way To Do It Haskell: There Is One Way To Do It, Up To Isomorphism :) Roman From waldmann at imn.htwk-leipzig.de Tue Jan 8 15:23:15 2013 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Tue, 8 Jan 2013 14:23:15 +0000 (UTC) Subject: [Haskell-cafe] Example programs with ample use of deepseq? References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> Message-ID: http://article.gmane.org/gmane.comp.lang.haskell.parallel/340 (with follow-up message about rseq => rdeepseq) - J.W. From ifigueroap at gmail.com Tue Jan 8 15:29:13 2013 From: ifigueroap at gmail.com (Ismael Figueroa Palet) Date: Tue, 8 Jan 2013 11:29:13 -0300 Subject: [Haskell-cafe] What happened to first-class modules? Message-ID: I just read this page http://www.haskell.org/haskellwiki/First-class_module. It seems there was not much no ongoing work on this topic... does somebody know what happened to first-class modules? what are the actual research papers about this topic? Thanks -- Ismael -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Tue Jan 8 15:39:30 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Tue, 8 Jan 2013 15:39:30 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? References: <1357560395.15170.4.camel@kirk> Message-ID: <20130108153930.569320c5@tritium.streitmacht.eu> Joachim Breitner wrote: > I?m wondering if the use of deepseq to avoid unwanted lazyness might > be a too large hammer in some use cases. Therefore, I?m looking for > real world programs with ample use of deepseq, and ideally easy ways > to test performance (so preferably no GUI applications). > > I?ll try to find out, by runtime observerations, which of the calls ot > deepseq could be replaced by id, seq, or ?shallow seqs? that, for > example, calls seq on the elements of a tuple. Now that you know when /not/ to use deepseq, let me tell you when it's appropriate: parallelization via parallel strategies. It's not exactly necessary to use deepseq (or rdeepseq in this case), but it's often very easy to express your algorithms in the usual way and then just change some of the 'map' applications to 'parMap rdeepseq'. When your algorithm is written with parallelization in mind this often gives you an amazingly parallel program by changing only a few words in your source code. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From stephen.tetley at gmail.com Tue Jan 8 18:30:46 2013 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Tue, 8 Jan 2013 17:30:46 +0000 Subject: [Haskell-cafe] Difference Lists versus Accumulators In-Reply-To: References: Message-ID: See the first Worker / Wrapper paper by Andy Gill and Graham Hutton. Particularly there is exactly this derivation of reverse through preliminarily using a Hughes (difference) list. On 8 January 2013 12:22, Edsko de Vries wrote: > Hey all, > > The connection between difference lists and accumulators is probably > well known, but I only recently realized it myself and a quick Google > search didn't find turn up any page where this was explicitly stated, > so I thought this observation might be useful to some. From anton.dergunov at mail.ru Tue Jan 8 20:07:48 2013 From: anton.dergunov at mail.ru (=?UTF-8?B?QW50b24gRGVyZ3Vub3Y=?=) Date: Tue, 08 Jan 2013 23:07:48 +0400 Subject: [Haskell-cafe] =?utf-8?q?Seeking_feedback_for_a_tutorial_paper_dr?= =?utf-8?q?aft_about_GADTs?= Message-ID: <1357672068.500203066@f203.mail.ru> Hi Haskellers, I have written a draft of an introductory-level tutorial paper about GADTs in Haskell (for submittion to proceedings of the recent LASER summer school) and I would like to seek initial feedback about its content: what information is probably missing? are there any subtle mistakes? The main idea of this article was to serve as a starting point for learning GADTs (I was missing this kind of information myself some time ago), so I have collected several examples?demonstrating?common use cases. -- Best Regards, Anton Dergunov -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pdf Size: 292994 bytes Desc: not available URL: From anton.dergunov at mail.ru Tue Jan 8 20:22:39 2013 From: anton.dergunov at mail.ru (=?UTF-8?B?QW50b24gRGVyZ3Vub3Y=?=) Date: Tue, 08 Jan 2013 23:22:39 +0400 Subject: [Haskell-cafe] =?utf-8?q?Seeking_feedback_for_a_tutorial_paper_dr?= =?utf-8?q?aft_about_GADTs?= Message-ID: <1357672959.506368624@f192.mail.ru> Hi Haskellers, I have written a draft of an introductory-level tutorial paper about GADTs in Haskell (for submittion to proceedings of the recent LASER summer school) and I would like to seek initial feedback about its content: what information is probably missing? are there any subtle mistakes? The main idea of this article was to serve as a starting point for learning GADTs (I was missing this kind of information myself some time ago), so I have collected several examples?demonstrating?common use cases. Here is a link to the paper: https://docs.google.com/open?id=0B9ZIIsDR0B7Hb1VBTFZOZEUzXzA -- Best Regards, Anton Dergunov -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pdf Size: 292994 bytes Desc: not available URL: From qdunkan at gmail.com Tue Jan 8 22:01:41 2013 From: qdunkan at gmail.com (Evan Laforge) Date: Tue, 8 Jan 2013 13:01:41 -0800 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357574385.15170.14.camel@kirk> References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> Message-ID: > surprisingly, deepseq is not used as much as I thought. > http://packdeps.haskellers.com/reverse/deepseq lists a lot of packages, > but (after grepping through some of the code) most just define NFData > instances and/or use it in tests, but rarely in the ?real? code. For > some reason I expected it to be in more widespread use. I've been using deepseq quite a bit lately, but for the purpose of debugging space leaks. If, when I deepseq a big structure, the space leak goes away, I can then apply it to some subset. After much trial-and-error I can find something which is insufficiently strict. Ideally I can then strictify that one thing and stop using the deepseq. I wish there was a more efficient way to do this. I also use it to explicitly force certain parts of a data structure so they evaluate in parallel, though that part is not actually done yet. From mail at joachim-breitner.de Tue Jan 8 22:54:05 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue, 08 Jan 2013 22:54:05 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> Message-ID: <1357682045.18991.3.camel@kirk> Hi, Am Dienstag, den 08.01.2013, 13:01 -0800 schrieb Evan Laforge: > > surprisingly, deepseq is not used as much as I thought. > > http://packdeps.haskellers.com/reverse/deepseq lists a lot of packages, > > but (after grepping through some of the code) most just define NFData > > instances and/or use it in tests, but rarely in the ?real? code. For > > some reason I expected it to be in more widespread use. > > I've been using deepseq quite a bit lately, but for the purpose of > debugging space leaks. If, when I deepseq a big structure, the space > leak goes away, I can then apply it to some subset. After much > trial-and-error I can find something which is insufficiently strict. > Ideally I can then strictify that one thing and stop using the > deepseq. I wish there was a more efficient way to do this. this is also a possible application of my approach, by providing a ?I want this data structure to be fully evaluated now, please tell me how it currently looks, i.e. where in the data structure still thunks lie hidden.? Do you have a nice, striking example where using your approach (using deepseq and comparing efficiency) you could make a difference, and where a tool as described above would make the analysis much easier? Thanks, Joachim -- Joachim Breitner e-Mail: mail at joachim-breitner.de Homepage: http://www.joachim-breitner.de Jabber-ID: nomeata at joachim-breitner.de -------------- 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: From simons at cryp.to Wed Jan 9 09:55:56 2013 From: simons at cryp.to (Peter Simons) Date: Wed, 09 Jan 2013 09:55:56 +0100 Subject: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental) References: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> <87sj6cyhnx.fsf@write-only.cryp.to> <1A348C74-E274-4821-B328-F9D02D8F622C@gmail.com> Message-ID: <871uduohur.fsf@write-only.cryp.to> Hi Hamish, > Features in process-leksah have been merged into process. For newer > versions of GHC leksah-server just depends on process. I trust this applies to the unreleased beta version that you just announced, right? (The latest release versions still seem to depend on process-leksah.) In that case, I'll try again building Leksah once the new version is available from Hackage. Thank you for the quick response! Peter From hesselink at gmail.com Wed Jan 9 14:23:34 2013 From: hesselink at gmail.com (Erik Hesselink) Date: Wed, 9 Jan 2013 14:23:34 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357682045.18991.3.camel@kirk> References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> <1357682045.18991.3.camel@kirk> Message-ID: On Tue, Jan 8, 2013 at 10:54 PM, Joachim Breitner wrote: > Am Dienstag, den 08.01.2013, 13:01 -0800 schrieb Evan Laforge: >> > surprisingly, deepseq is not used as much as I thought. >> > http://packdeps.haskellers.com/reverse/deepseq lists a lot of packages, >> > but (after grepping through some of the code) most just define NFData >> > instances and/or use it in tests, but rarely in the ?real? code. For >> > some reason I expected it to be in more widespread use. >> >> I've been using deepseq quite a bit lately, but for the purpose of >> debugging space leaks. If, when I deepseq a big structure, the space >> leak goes away, I can then apply it to some subset. After much >> trial-and-error I can find something which is insufficiently strict. >> Ideally I can then strictify that one thing and stop using the >> deepseq. I wish there was a more efficient way to do this. > > this is also a possible application of my approach, by providing a ?I > want this data structure to be fully evaluated now, please tell me how > it currently looks, i.e. where in the data structure still thunks lie > hidden.? > > Do you have a nice, striking example where using your approach (using > deepseq and comparing efficiency) you could make a difference, and where > a tool as described above would make the analysis much easier? We've also used this approach to debug space-leaks, and would have loved such a tool. We used deepseq, and compared the heap profiles. We finally found the leaks this way, and fixed them using strictness annotations. Finally, we verified by running deepseq again at top level and observing that it didn't change anything anymore. Erik From mail at joachim-breitner.de Wed Jan 9 14:40:41 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Wed, 09 Jan 2013 14:40:41 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> <1357682045.18991.3.camel@kirk> Message-ID: <1357738841.11574.5.camel@kirk> Hi Erik, Am Mittwoch, den 09.01.2013, 14:23 +0100 schrieb Erik Hesselink: > We've also used this approach to debug space-leaks, and would have > loved such a tool. We used deepseq, and compared the heap profiles. We > finally found the leaks this way, and fixed them using strictness > annotations. Finally, we verified by running deepseq again at top > level and observing that it didn't change anything anymore. same question to you: Would you have a suitable test case that can be used to test and demonstrate the usefulness of such tools? Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From Johannes.Reiher at fh-zwickau.de Wed Jan 9 14:44:10 2013 From: Johannes.Reiher at fh-zwickau.de (Johannes.Reiher) Date: Wed, 9 Jan 2013 13:44:10 +0000 Subject: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem Message-ID: <71E6A0070B27C8418C7AC01A323F617291D3E5B4@whz-exc-02.zw.fh-zwickau.de> Hello Community, I have a problem installing the HaskellDB-HDBC-PostgreSQL package with cabal. I'm using Haskell Platform in Windows and I tried to install this package, but there was the error "could not find pq library". So I tried to install libpq wich includes pq but there was another error: "this package needs a unix installation". Is there any way to install pq on Windows or get the HaskellDB-HDBC-PostgreSQL in another way? Thanks for your advice Johannes Reiher From chrisdone at gmail.com Wed Jan 9 14:50:13 2013 From: chrisdone at gmail.com (Christopher Done) Date: Wed, 9 Jan 2013 14:50:13 +0100 Subject: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem In-Reply-To: <71E6A0070B27C8418C7AC01A323F617291D3E5B4@whz-exc-02.zw.fh-zwickau.de> References: <71E6A0070B27C8418C7AC01A323F617291D3E5B4@whz-exc-02.zw.fh-zwickau.de> Message-ID: Tricky. For what it's worth, if you can't figure this out in the end, you could perhaps use my pgsql-simple which is implemented in pure haskell: https://github.com/chrisdone/pgsql-simple It's been in use on hpaste.org for about 2 years. On 9 January 2013 14:44, Johannes.Reiher wrote: > Hello Community, > > I have a problem installing the HaskellDB-HDBC-PostgreSQL package with cabal. > I'm using Haskell Platform in Windows and I tried to install this package, but there was the error "could not find pq library". So I tried to install libpq wich includes pq but there was another error: "this package needs a unix installation". > Is there any way to install pq on Windows or get the HaskellDB-HDBC-PostgreSQL in another way? > > Thanks for your advice > > Johannes Reiher > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From hesselink at gmail.com Wed Jan 9 15:11:15 2013 From: hesselink at gmail.com (Erik Hesselink) Date: Wed, 9 Jan 2013 15:11:15 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357738841.11574.5.camel@kirk> References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> <1357682045.18991.3.camel@kirk> <1357738841.11574.5.camel@kirk> Message-ID: On Wed, Jan 9, 2013 at 2:40 PM, Joachim Breitner wrote: > Hi Erik, > > Am Mittwoch, den 09.01.2013, 14:23 +0100 schrieb Erik Hesselink: >> We've also used this approach to debug space-leaks, and would have >> loved such a tool. We used deepseq, and compared the heap profiles. We >> finally found the leaks this way, and fixed them using strictness >> annotations. Finally, we verified by running deepseq again at top >> level and observing that it didn't change anything anymore. > > same question to you: Would you have a suitable test case that can be > used to test and demonstrate the usefulness of such tools? Sadly, no. This is a private, core part of our application that I cannot share. I can describe what we did, and also the structure of the data in broad terms: we have several Maps, where the keys are usually Text, and the values are custom data types. These contain keys into these maps again. The whole thing defines a graph with several indexes into it. We finally solved the problems by completely moving to strict map operations, strict MVar/TVar operations, and strict data types. If you have more questions, or tools you want to test, I'd be happy to help, though. Regards, Erik From mail at eax.me Wed Jan 9 15:39:20 2013 From: mail at eax.me (Alexander Alexeev) Date: Wed, 09 Jan 2013 18:39:20 +0400 Subject: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem In-Reply-To: References: <71E6A0070B27C8418C7AC01A323F617291D3E5B4@whz-exc-02.zw.fh-zwickau.de> Message-ID: <50ED8118.2000305@eax.me> Try Persistent package. It doesn't depends on libpq and has many useful features (see http://www.yesodweb.com/book/persistent for details) On 01/09/2013 05:50 PM, Christopher Done wrote: > Tricky. For what it's worth, if you can't figure this out in the end, > you could perhaps use my pgsql-simple which is implemented in pure > haskell: https://github.com/chrisdone/pgsql-simple It's been in use on > hpaste.org for about 2 years. > > On 9 January 2013 14:44, Johannes.Reiher wrote: >> Hello Community, >> >> I have a problem installing the HaskellDB-HDBC-PostgreSQL package with cabal. >> I'm using Haskell Platform in Windows and I tried to install this package, but there was the error "could not find pq library". So I tried to install libpq wich includes pq but there was another error: "this package needs a unix installation". >> Is there any way to install pq on Windows or get the HaskellDB-HDBC-PostgreSQL in another way? >> >> Thanks for your advice >> >> Johannes Reiher >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Alexander Alexeev http://eax.me/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From eual.jp at gmail.com Wed Jan 9 16:13:19 2013 From: eual.jp at gmail.com (Alexander Batischev) Date: Wed, 9 Jan 2013 17:13:19 +0200 Subject: [Haskell-cafe] Seeking feedback for a tutorial paper draft about GADTs In-Reply-To: <1357672959.506368624@f192.mail.ru> References: <1357672959.506368624@f192.mail.ru> Message-ID: <20130109151319.GA1321@antaeus> On Tue, Jan 08, 2013 at 11:22:39PM +0400, Anton Dergunov wrote: > I have written a draft of an introductory-level tutorial paper about > GADTs in Haskell (for submittion to proceedings of the recent LASER > summer school) and I would like to seek initial feedback about its > content: what information is probably missing? are there any subtle > mistakes? Not exactly the feedback you asked for, but I hope it still can be of some use. As a person with no prior knowledge about GADTs, I found your paper a good introduction. Following proof of correctness of red-black tree insertions turned out to be a little bit of a challenge as type annotations quickly become tangled (made me wondering how one should prove correctness of the proof). I particularly liked how you handle things that are not central to tutorial, like phantom and existential types: you give single-sentence explanation that provides good enough intuition to follow you further. Talking of quick explanations, I would love to see kinds and singleton types explained in the same manner. You tried to explain singleton types at page 13, but I find explanation provided by GHC documentation[1] to be much more clear. As for kinds, it just puzzles me why you use the term but don't explain it. 1. http://hackage.haskell.org/trac/ghc/wiki/TypeNats/Basics The same goes for type families - while I was able to quickly look up definition of singleton types, I failed to comprehend basics of type families by reading Haskell Wiki. I ended up pretending that type families are just type-level functions. I would love to see Yampa optimizations section expanded with more interesting examples. Are there any? Last but not least, a few minor typos and errors I spotted: * at page 8, "Than we need to declare type instances..." should be "Then we need..."; * probably due to excessive editing, parameters to repeatElem at page 13 are in the different order than before; * at page 14, you state: > As in all binary search trees, for a particular node N c l x r > values greater than x are stored in left sub-tree (in l) and values > less than x are stored in right sub-tree (in r). But later on, your code contradict that statement by recursing to left sub-tree when x we look for is less than value in the node, and to right sub-tree when x is greater than value in the node. Thank you once again for a nice introduction to GADTs! -- Regards, Alexander Batischev PGP key 356961A20C8BFD03 Fingerprint: CE6C 4307 9348 58E3 FD94 A00F 3569 61A2 0C8B FD03 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: From felipe.lessa at gmail.com Wed Jan 9 16:55:58 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Wed, 9 Jan 2013 13:55:58 -0200 Subject: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem In-Reply-To: <50ED8118.2000305@eax.me> References: <71E6A0070B27C8418C7AC01A323F617291D3E5B4@whz-exc-02.zw.fh-zwickau.de> <50ED8118.2000305@eax.me> Message-ID: AFAIK, persistent's PostgreSQL support does depend on libpq via postgresql-libpq. On Wed, Jan 9, 2013 at 12:39 PM, Alexander Alexeev wrote: > Try Persistent package. It doesn't depends on libpq and has many useful > features (see http://www.yesodweb.com/book/persistent for details) > > > On 01/09/2013 05:50 PM, Christopher Done wrote: > > Tricky. For what it's worth, if you can't figure this out in the end, > you could perhaps use my pgsql-simple which is implemented in pure > haskell: https://github.com/chrisdone/pgsql-simple It's been in use on > hpaste.org for about 2 years. > > On 9 January 2013 14:44, Johannes.Reiher > wrote: > > Hello Community, > > I have a problem installing the HaskellDB-HDBC-PostgreSQL package with > cabal. > I'm using Haskell Platform in Windows and I tried to install this package, > but there was the error "could not find pq library". So I tried to install > libpq wich includes pq but there was another error: "this package needs a > unix installation". > Is there any way to install pq on Windows or get the > HaskellDB-HDBC-PostgreSQL in another way? > > Thanks for your advice > > Johannes Reiher > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Best regards, > Alexander Alexeev > http://eax.me/ > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Felipe. From kc1956 at gmail.com Wed Jan 9 20:05:07 2013 From: kc1956 at gmail.com (KC) Date: Wed, 9 Jan 2013 11:05:07 -0800 Subject: [Haskell-cafe] Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar? Message-ID: :) -- -- Regards, KC From benjamin.peter.doyle at gmail.com Wed Jan 9 20:40:01 2013 From: benjamin.peter.doyle at gmail.com (Ben Doyle) Date: Wed, 9 Jan 2013 14:40:01 -0500 Subject: [Haskell-cafe] Undo records In-Reply-To: References: Message-ID: I think acid-state (http://hackage.haskell.org/package/acid-state) might do what you want, at least in broad strokes. It uses a durable transaction log to store query and update events. As far as I know, the interface to the library doesn't expose an undo/rollback function, so you'd have a bit of work to do to extend it to your use case. But the core functionality to make it possible should be there. Can you use ghc extensions aside from Template Haskell? Template Haskell you can do without with acid-state, but without GADTs and so on you'll have problems. On Sun, Jan 6, 2013 at 12:01 PM, Casey Basichis wrote: > Hi, > > I am still getting a hang of Haskell. Sorry if the answer is obvious. > > What sorts of packages and approaches should I be looking at if I was > looking to store something like an Undo stack into a database. > > Each table would refer to a function. > Each records input and outputs would specify both a table ID and record > ID. > The records would also have a data and a Process ID to associate all > functions to a specific process and give them an order. > > No records are ever deleted. Rolling something back is instead a process > of recreating a new, modified graph by taking the old graph from the > database. > > I should note that while I can generate some of the boiler parts from > template haskell in advance I'm ultimately using a stage 1 compiler with no > GHCI o template haskell. > > Thanks, > Casey > > -- > Casey James Basichis > Composer - Cartoon Network > http://www.caseyjamesbasichis.com > caseybasichis at gmail.com > 310.387.7540 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From caseybasichis at gmail.com Wed Jan 9 21:02:19 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Wed, 9 Jan 2013 12:02:19 -0800 Subject: [Haskell-cafe] Undo records In-Reply-To: References: Message-ID: Hi Ben, Thanks for the reply. I am planning on using Persistent which can work without template haskell, though I am planning on using the TH on my workstation to create the boiler code parts of the database setup. The part that I'm having trouble with is collecting the composed functions. It may be a very typical problem but I'm just lost. Let me just describe a simple example; A message comes through the FFI to: Haskell chooses criteria to select a sequence of data from the database --- many functions exist to do this, some may take a random number as a parameter, the seed needs to be stored Haskell similarly chooses a process to apply to the data --- A random number or other deterministic chain of functions The results from the processing are loaded into memory - (these are not the focus here) The minimal chain of functions, parameters and seeds is stored to allow for a deterministic recall/modification --- The input parameters and output parameters are Table and Row ID's So Haskell isn't reacting to many input events, just a trigger that may come with a few initialization parameters. If a function is composed of other functions which do not depend on external state they should not need to be stored in the database as they are implicit. I imagine this is a monad problem, but kind and what other things spring to mind that might help in approaching this kind of problem? Thanks, Casey On Wed, Jan 9, 2013 at 11:40 AM, Ben Doyle wrote: > I think acid-state (http://hackage.haskell.org/package/acid-state) might > do what you want, at least in broad strokes. It uses a durable transaction > log to store query and update events. > > As far as I know, the interface to the library doesn't expose an > undo/rollback function, so you'd have a bit of work to do to extend it to > your use case. But the core functionality to make it possible should be > there. > > Can you use ghc extensions aside from Template Haskell? Template Haskell > you can do without with acid-state, but without GADTs and so on you'll have > problems. > > On Sun, Jan 6, 2013 at 12:01 PM, Casey Basichis wrote: > >> Hi, >> >> I am still getting a hang of Haskell. Sorry if the answer is obvious. >> >> What sorts of packages and approaches should I be looking at if I was >> looking to store something like an Undo stack into a database. >> >> Each table would refer to a function. >> Each records input and outputs would specify both a table ID and record >> ID. >> The records would also have a data and a Process ID to associate all >> functions to a specific process and give them an order. >> >> No records are ever deleted. Rolling something back is instead a process >> of recreating a new, modified graph by taking the old graph from the >> database. >> >> I should note that while I can generate some of the boiler parts from >> template haskell in advance I'm ultimately using a stage 1 compiler with no >> GHCI o template haskell. >> >> Thanks, >> Casey >> >> -- >> Casey James Basichis >> Composer - Cartoon Network >> http://www.caseyjamesbasichis.com >> caseybasichis at gmail.com >> 310.387.7540 >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis at gmail.com 310.387.7540 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Wed Jan 9 23:38:44 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Wed, 09 Jan 2013 23:38:44 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> <1357682045.18991.3.camel@kirk> <1357738841.11574.5.camel@kirk> Message-ID: <1357771124.14416.5.camel@kirk> Hi, Am Mittwoch, den 09.01.2013, 15:11 +0100 schrieb Erik Hesselink: > We finally solved the problems by completely moving > to strict map operations, strict MVar/TVar operations, and strict data > types. do you mean strict by policy (i.e. before storing something in a [MT]Var, you ensure it is evaluated) or by construction (by `seq` or `deepseq`?ing everything before it is stored)? In the latter case: Seq or deeqseq? Again in the latter case: Do you worry about the performance of repeatedly deepseq?ing an already deepseq?ed and possibly large value? You are not the first user of Haskell who ends up with that approach to lazy evaluation. I?m not sure what that means for Haskell, though. Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From erik.flister at gmail.com Thu Jan 10 00:12:30 2013 From: erik.flister at gmail.com (erik flister) Date: Wed, 9 Jan 2013 15:12:30 -0800 Subject: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem In-Reply-To: References: <71E6A0070B27C8418C7AC01A323F617291D3E5B4@whz-exc-02.zw.fh-zwickau.de> <50ED8118.2000305@eax.me> Message-ID: >> there was another error: "this package needs a >> unix installation". you need to use MinGW, but it still fails because of a GHC bug http://hackage.haskell.org/trac/ghc/ticket/7103 https://github.com/lpsmith/postgresql-libpq/issues/7 -e From garious at gmail.com Thu Jan 10 02:04:17 2013 From: garious at gmail.com (Greg Fitzgerald) Date: Wed, 9 Jan 2013 17:04:17 -0800 Subject: [Haskell-cafe] haskell.cs.yale.edu error Message-ID: I was hoping to check on the status of Yampa, but: http://haskell.cs.yale.edu/ [an error occurred while processing this directive] You don't have permission to access the requested directory. There is either no index document or the directory is read-protected. [an error occurred while processing this directive] Do you know who maintains this website? Thanks, Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From dstcruz at gmail.com Thu Jan 10 04:26:36 2013 From: dstcruz at gmail.com (Daniel Santa Cruz) Date: Wed, 9 Jan 2013 22:26:36 -0500 Subject: [Haskell-cafe] Haskell Weekly News: Issue 254 Message-ID: Welcome to issue 254 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the week of December 02, 2012 to January 05, 2013. As some of you might have noticed, there has been an interruption in the scheduled transmission of the newsletter. I have, over the past few weeks, completed a move to NYC! It has been wonderful to meet many in the community at the Haskell NYC meetups. Here is to a great year for our cherised community. Let's get things started out the right way, with a litte "Lambda Style" :-) [1] http://goo.gl/nQYdp Quotes of the Week * GuySteele: Some people prefer not to commingle the functional, lambda-calculus part of a language with the parts that do side effects. It seems they believe in the separation of Church and state. * edwardk: type level ieee floats are a crime against nature. i had to implement them in c++ for template meta programming once. never ever again * acowley: (regarding Proxy) Haven't you ever wanted to put something in a box and never think about it? elliott: children * merijn: xenocons: I spend the entire week grading FP homework, I think it's impossible for you to surprise me :p merijn: That's confusing :< * andr00: Today's software engineering word is "farpotshket." This is a Yiddish word meaning, "broken, because someone tried to fix it." * dmwit: I know, I know. "0, 1, many". But then I also write most of my programs in a language whose type system has 4 levels. Four! Is that even a number?? * aristid: a dubious motivation IMHO edwardk: i've had worse =P * ziarkaen: I'm thinking I can kill two birds with one stone by learning Haskell while producing a website, but all the birds are still alive at the moment. * ion: monad.bind = function (func, args) { return func.apply(undefined, [value].concat(Array.prototype.slice.apply(args || []))); }; is idiomatic JavaScript? * beaky: if stacks are recursion, what are queues? Hafydd: Procrastination. * elliott: I think lens is the first library I've seen that promises letting you write abstract totally-inefficient-looking compositional code and getting reliably good compilation which has actually delivered on that promise. * elliott: I didn't say half the things I said. * shachaf: The two-letter and three-letter identifiers are for edwardk's libraries. The one-letter identifiers are for his actual code. elliott: edwardk has non-library code? * neutrino: in many ways, Haskell is like this primodial soup out of which other languages end up springing * mm_freak: bruce schneier is an endofunctor that turns all automorphisms into identities * roconnor: where are all the category theoriest? why don't they already have all the answers for us? edwardk: roconnor: this is the point in your career where you look around for the cavalry and realize that you're it ;) * cmccann: multi-letter type variables is an experimental new extension * elliott: I can't remember the last time I wrote any Haskell without an evil grin. * neutrino: when you're told you have to use javascript, the viable alternative always remains in seppuku. and it's much more honorable. * shachaf: chrisdone: Please make Author not mandatory. [on hpaste] donri: shachaf: just write "not shachaf" and no one will ever know it's you * tac: If you're not part of the solution, you're part of the precipitate * cmccann: some people blame themselves, some people blame the language, but the people who really know what they're doing blame shachaf. Top Reddit Stories * The end of an era, and the dawn of a new one Domain: haskell.org, Score: 148, Comments: 32 On Reddit: [2] http://goo.gl/fiyVt Original: [3] http://goo.gl/dlxsF * Simon Peyton-Jones invests in FP Complete Domain: fpcomplete.com, Score: 92, Comments: 15 On Reddit: [4] http://goo.gl/nPTk1 Original: [5] http://goo.gl/wzfpP * 24 Days of Hackage - Thank YOU! Domain: ocharles.org.uk, Score: 88, Comments: 12 On Reddit: [6] http://goo.gl/2yodj Original: [7] http://goo.gl/hSsH6 * Heist 0.10...now with a >3000x performance improvement Domain: snapframework.com, Score: 81, Comments: 38 On Reddit: [8] http://goo.gl/p7R7u Original: [9] http://goo.gl/znugn * 24 Days of Hackage: EKG Domain: ocharles.org.uk, Score: 68, Comments: 15 On Reddit: [10] http://goo.gl/ltPb1 Original: [11] http://goo.gl/UeYOA * pipes-3.0: Simpler, unified API Domain: haskellforall.com, Score: 64, Comments: 71 On Reddit: [12] http://goo.gl/ZSVtT Original: [13] http://goo.gl/6Yt01 * Hoodle : Pen note-taking program written in haskell Domain: youtube.com, Score: 64, Comments: 21 On Reddit: [14] http://goo.gl/aJ9G9 Original: [15] http://goo.gl/GsZ85 * 24 Days of Hackage: lens Domain: ocharles.org.uk, Score: 62, Comments: 46 On Reddit: [16] http://goo.gl/71HbV Original: [17] http://goo.gl/L78Hp * Cartesian Closed Comic #19: Facebook Domain: ro-che.info, Score: 61, Comments: 8 On Reddit: [18] http://goo.gl/LKqzz Original: [19] http://goo.gl/tSrjJ * Announcing: Snap Framework v0.10 Domain: snapframework.com, Score: 61, Comments: 11 On Reddit: [20] http://goo.gl/TibIw Original: [21] http://goo.gl/Nm98e * Surprises of the Haskell module system (part 1) Domain: ro-che.info, Score: 57, Comments: 11 On Reddit: [22] http://goo.gl/tOiiK Original: [23] http://goo.gl/vLEZP * 24 Days of Hackage: configurator Domain: ocharles.org.uk, Score: 53, Comments: 7 On Reddit: [24] http://goo.gl/jFKt2 Original: [25] http://goo.gl/nu2zj * Fay :: Haskell -> JavaScript Domain: fay-lang.org, Score: 52, Comments: 14 On Reddit: [26] http://goo.gl/wAH7C Original: [27] http://goo.gl/uitoD * Announcing: Clay, a CSS preprocessor as a Haskell EDSL. Domain: sebastiaanvisser.github.com, Score: 52, Comments: 53 On Reddit: [28] http://goo.gl/1ej1n Original: [29] http://goo.gl/bWfU2 * 24 Days of Hackage: base Domain: ocharles.org.uk, Score: 51, Comments: 10 On Reddit: [30] http://goo.gl/e5gLp Original: [31] http://goo.gl/7MY8o * Haskell for all: The Continuation Monad Domain: haskellforall.com, Score: 51, Comments: 42 On Reddit: [32] http://goo.gl/YKDOo Original: [33] http://goo.gl/zJ42x * ANNNOUNCE: lens 3.7 released Domain: haskell.org, Score: 50, Comments: 9 On Reddit: [34] http://goo.gl/FecK0 Original: [35] http://goo.gl/n4tR0 * 24 Days of Hackage: optparse-applicative Domain: ocharles.org.uk, Score: 50, Comments: 21 On Reddit: [36] http://goo.gl/JyFVh Original: [37] http://goo.gl/PP4CX * 24 Days of Hackage: snap Domain: ocharles.org.uk, Score: 50, Comments: 35 On Reddit: [38] http://goo.gl/9Wp3q Original: [39] http://goo.gl/WlHlU * What doesn't Haskell do well? Domain: self.haskell, Score: 47, Comments: 153 On Reddit: [40] http://goo.gl/VRJMn Original: [41] http://goo.gl/VRJMn * 24 Days of Hackage: criterion Domain: ocharles.org.uk, Score: 46, Comments: 10 On Reddit: [42] http://goo.gl/wYrdm Original: [43] http://goo.gl/rYT9C * Some specific thoughts on why using Haskell makes you a better programmer. Domain: dubhrosa.blogspot.co.uk, Score: 46, Comments: 30 On Reddit: [44] http://goo.gl/dN1Zd Original: [45] http://goo.gl/DDNuQ * Growing Haskell Platform Domain: mtnviewmark.wordpress.com, Score: 43, Comments: 16 On Reddit: [46] http://goo.gl/jNefn Original: [47] http://goo.gl/a5udB * 24 Days of Hackage: text Domain: ocharles.org.uk, Score: 43, Comments: 21 On Reddit: [48] http://goo.gl/3VmmH Original: [49] http://goo.gl/13MOc Top StackOverflow Questions * What's the absurd function in Data.Void useful for? votes: 34, answers: 5 Read on SO: [50] http://goo.gl/ny4gh * Benefit of avoiding multiple list traversals votes: 27, answers: 4 Read on SO: [51] http://goo.gl/Z6DNg * Images in Haddock documentation votes: 22, answers: 2 Read on SO: [52] http://goo.gl/7tFgE * Idiomatic option pricing and risk using Repa parallel arrays votes: 22, answers: 1 Read on SO: [53] http://goo.gl/Ih9cn * How much memory does a thunk use? votes: 21, answers: 2 Read on SO: [54] http://goo.gl/VkdIX * Can I constrain a type family? votes: 20, answers: 2 Read on SO: [55] http://goo.gl/0kBEU * How to write platform-independent code in Haskell (ghc) votes: 18, answers: 1 Read on SO: [56] http://goo.gl/13bEB * Play a wav file with Haskell votes: 17, answers: 3 Read on SO: [57] http://goo.gl/sKpgf * Why are difference lists more efficient than regular concatenation? votes: 16, answers: 2 Read on SO: [58] http://goo.gl/GCVpe * GUI tools that are actively developed and well documented for Haskell votes: 15, answers: 2 Read on SO: [59] http://goo.gl/M2L0l * What are the adjoint functor pairs corresponding to common monads in Haskell? votes: 15, answers: 2 Read on SO: [60] http://goo.gl/UnUik Until next time, +Daniel Santa Cruz https://plus.google.com/105107667630152149014/about References 1. http://www.youtube.com/watch?v=Ci48kqp11F8 2. http://www.haskell.org/pipermail/haskell-cafe/2012-December/105041.html 3. http://www.reddit.com/r/haskell/comments/14bvtz/the_end_of_an_era_and_the_dawn_of_a_new_one/ 4. http://fpcomplete.com/why-im-investing-in-fp-complete/ 5. http://www.reddit.com/r/haskell/comments/15wc7s/simon_peytonjones_invests_in_fp_complete/ 6. http://ocharles.org.uk/blog/posts/2012-12-24-24-days-of-hackage.html 7. http://www.reddit.com/r/haskell/comments/15e0nz/24_days_of_hackage_thank_you/ 8. http://snapframework.com/blog/2012/12/9/heist-0.10-released 9. http://www.reddit.com/r/haskell/comments/14kjct/heist_010now_with_a_3000x_performance_improvement/ 10. http://ocharles.org.uk/blog/posts/2012-12-11-24-day-of-hackage-ekg.html 11. http://www.reddit.com/r/haskell/comments/14ovdp/24_days_of_hackage_ekg/ 12. http://www.haskellforall.com/2012/12/pipes-30-simpler-unified-api.html 13. http://www.reddit.com/r/haskell/comments/14qe8b/pipes30_simpler_unified_api/ 14. http://www.youtube.com/watch?v=Z2wzpyxsVSU 15. http://www.reddit.com/r/haskell/comments/14seiv/hoodle_pen_notetaking_program_written_in_haskell/ 16. http://ocharles.org.uk/blog/posts/2012-12-09-24-days-of-hackage-lens.html 17. http://www.reddit.com/r/haskell/comments/14kbbi/24_days_of_hackage_lens/ 18. http://ro-che.info/ccc/19.html 19. http://www.reddit.com/r/haskell/comments/145cra/cartesian_closed_comic_19_facebook/ 20. http://snapframework.com/blog/2012/12/10/snap-0.10-released 21. http://www.reddit.com/r/haskell/comments/14lrlr/announcing_snap_framework_v010/ 22. http://ro-che.info/articles/2012-12-25-haskell-module-system-p1.html 23. http://www.reddit.com/r/haskell/comments/15fnrx/surprises_of_the_haskell_module_system_part_1/ 24. http://ocharles.org.uk/blog/posts/2012-12-21-24-days-of-hackage-configurator.html 25. http://www.reddit.com/r/haskell/comments/158svo/24_days_of_hackage_configurator/ 26. http://fay-lang.org/ 27. http://www.reddit.com/r/haskell/comments/14dxru/fay_haskell_javascript/ 28. http://sebastiaanvisser.github.com/clay/ 29. http://www.reddit.com/r/haskell/comments/15aoif/announcing_clay_a_css_preprocessor_as_a_haskell/ 30. http://ocharles.org.uk/blog/posts/2012-12-23-24-days-of-hackage-base.html 31. http://www.reddit.com/r/haskell/comments/15c0jm/24_days_of_hackage_base/ 32. http://www.haskellforall.com/2012/12/the-continuation-monad.html 33. http://www.reddit.com/r/haskell/comments/15ogxe/haskell_for_all_the_continuation_monad/ 34. http://www.haskell.org/pipermail/haskell/2012-December/023598.html 35. http://www.reddit.com/r/haskell/comments/14fw7l/annnounce_lens_37_released/ 36. http://ocharles.org.uk/blog/posts/2012-12-17-24-days-of-hackage-optparse-applicative.html 37. http://www.reddit.com/r/haskell/comments/150iem/24_days_of_hackage_optparseapplicative/ 38. http://ocharles.org.uk/blog/posts/2012-12-19-24-days-of-hackage-snap.html 39. http://www.reddit.com/r/haskell/comments/154i72/24_days_of_hackage_snap/ 40. file://localhost/r/haskell/comments/14nj0r/what_doesnt_haskell_do_well/ 41. http://www.reddit.com/r/haskell/comments/14nj0r/what_doesnt_haskell_do_well/ 42. http://ocharles.org.uk/blog/posts/2012-12-18-24-days-of-hackage-criterion.html 43. http://www.reddit.com/r/haskell/comments/152yv3/24_days_of_hackage_criterion/ 44. http://dubhrosa.blogspot.co.uk/2012/12/lessons-learning-haskell.html 45. http://www.reddit.com/r/haskell/comments/15ch1k/some_specific_thoughts_on_why_using_haskell_makes/ 46. http://mtnviewmark.wordpress.com/2012/12/06/growing/ 47. http://www.reddit.com/r/haskell/comments/14fmw8/growing_haskell_platform/ 48. http://ocharles.org.uk/blog/posts/2012-12-12-24-days-of-hackage-text.html 49. http://www.reddit.com/r/haskell/comments/14quxz/24_days_of_hackage_text/ 50. http://stackoverflow.com/questions/14131856/whats-the-absurd-function-in-data-void-useful-for 51. http://stackoverflow.com/questions/13686926/benefit-of-avoiding-multiple-list-traversals 52. http://stackoverflow.com/questions/14017112/images-in-haddock-documentation 53. http://stackoverflow.com/questions/14082158/idiomatic-option-pricing-and-risk-using-repa-parallel-arrays 54. http://stackoverflow.com/questions/13982863/how-much-memory-does-a-thunk-use 55. http://stackoverflow.com/questions/14133121/can-i-constrain-a-type-family 56. http://stackoverflow.com/questions/13799199/how-to-write-platform-independent-code-in-haskell-ghc 57. http://stackoverflow.com/questions/14005592/play-a-wav-file-with-haskell 58. http://stackoverflow.com/questions/13879260/why-are-difference-lists-more-efficient-than-regular-concatenation 59. http://stackoverflow.com/questions/13887213/gui-tools-that-are-actively-developed-and-well-documented-for-haskell 60. http://stackoverflow.com/questions/13937289/what-are-the-adjoint-functor-pairs-corresponding-to-common-monads-in-haskell -------------- next part -------------- An HTML attachment was scrubbed... URL: From freeman.phil at gmail.com Thu Jan 10 16:28:48 2013 From: freeman.phil at gmail.com (Phil Freeman) Date: Thu, 10 Jan 2013 07:28:48 -0800 Subject: [Haskell-cafe] First Los Angeles Haskell User Group Meetup Message-ID: Hello Haskell Cafe, I'd like to announce that I've created a meetup group for any Haskell users in the LA area. The first meeting will be a meet-and-greet session, held next Tuesday, 15th January 2013, at Wurstkuche in the Downtown LA Arts District. After that, the goal is to organise presentations and discussions on Haskell-related topics roughly once a month. Interested parties can register for the group and RSVP here: http://www.meetup.com/Los-Angeles-Haskell-User-Group/ Thanks, Phil Freeman. -------------- next part -------------- An HTML attachment was scrubbed... URL: From muranushi at gmail.com Thu Jan 10 16:11:33 2013 From: muranushi at gmail.com (Takayuki Muranushi) Date: Fri, 11 Jan 2013 00:11:33 +0900 Subject: [Haskell-cafe] Lens, with ability to create a data-field when it's missing In-Reply-To: References: Message-ID: Dear everyone, With help of many, I found ways to implement most of the features I have wanted, and I can release the new dynamic-object package. http://hackage.haskell.org/package/dynamic-object Thank you in advance for your supports, Takayuki 2013/1/3 Takayuki Muranushi : > Dear All, I really am enjoying the lens (it is tough to learn, though :) > > Recently, I've been trying to implement a dynamic object --- a > collection of methods that you can update at run-time --- using lens > [1][2][3]. After several attempts, I think I have located the center > of my problem: > > Lens with the ability "to create a data-field when it's missing." My > question: is it possible? > > There are many excellent examples of partial lenses in the lens > library, such as '_head' from Data.List.Lens 'dynamic' from > Data.Dynamic.Lens . To me, they seem to share the following set of > common behavior (allow me to use inaccurate terms...) > > - set l a s : if the field is present, insert 'a'; otherwise, do nothing. > - over l f s : if the field is present, map 'f' over it. otherwise, do nothing. > - preview l s : if the field is present, return 'Just a'. otherwise, > return 'Nothing' . > > Instead, I want the following set of behaviors: > > - set l a s : if the field is present, insert 'a'; otherwise, *create > the field* and insert 'a'. > - over l f s : if the field is present, map 'f' over it. otherwise, do nothing. > - preview l s : if the field is present, return 'Just a'. otherwise, > return 'Nothing' . > > For example, the current behavior of _head is > >>> [] & _head .~ 1 > [] > I want to implement a variant _head' , such that > >>> [] & _head' .~ 1 > [1] > > > Let us call this behavior 'Member' for the moment. > > I have a implementation of 'Member' [4][5] but they are > unsatisfactory. [4] involves runtime errors and breaking of lens laws. > [5] shows that we can "create a field" only if we treat Dynamic > explicitly out of lens context. > > I don't know how 'Member' will fit in the lens hierarchy > http://i.imgur.com/FgfVW.png or even if it fits at all. > Member is weaker than Getter and probably is a Fold since you have > only partial getting (^?) for Member. Member is weaker than Prism > since you cannot construct a whole Object from just one Member. On the > other hand, setter side of Member requires (s -> b -> t) interface of > a Lens, because the setter need to update the whole Object when the > field under concern is missing. > > That said, let me put this question in another way; > > " We can construct a (Simple Lens s a) from (getter :: s -> a) and > (setter :: s -> a -> s), and we can construct a (Getter s a) from > (getter :: s -> a). > Then why we cannot construct a (Simple Setter s a) from (setter :: s > -> a -> s) ? " > > Does Member deserve a new node in The Lens Hierarchy tree? Or can we > implement it by combinations of existing prisms, folds etc? Or does it > fall outside of the lens framework? > > I appreciate any comments. > Takayuki > > [1] https://github.com/nushio3/practice/tree/master/duck > [2] http://d.hatena.ne.jp/nushio/20121226#p2 (Japanese) > [3] http://hackage.haskell.org/packages/archive/dynamic-object/0.1.0.1/doc/html/Data-Object-Dynamic-Types.html > [4] https://github.com/nushio3/practice/blob/master/lens/newfield.hs > [5] https://github.com/nushio3/practice/blob/master/lens/object-4.hs > > > -- > Takayuki MURANUSHI > The Hakubi Center for Advanced Research, Kyoto University > http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html -- Takayuki MURANUSHI The Hakubi Center for Advanced Research, Kyoto University http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html From yuriy at couldbedone.com Thu Jan 10 23:31:27 2013 From: yuriy at couldbedone.com (Yuriy Solodkyy) Date: Fri, 11 Jan 2013 00:31:27 +0200 Subject: [Haskell-cafe] Haskell-Cafe Digest, Vol 113, Issue 11 In-Reply-To: References: Message-ID: OK. It tells me the same error message in popup, but all the projections are running after that. I'll make sure that it does not say any strange errors on empty DB in new version. Does it start projections for you as well (even if it says error)? On Tue, Jan 8, 2013 at 1:00 PM, wrote: > Send Haskell-Cafe mailing list submissions to > haskell-cafe at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.haskell.org/mailman/listinfo/haskell-cafe > or, via email, send a message with subject or body 'help' to > haskell-cafe-request at haskell.org > > You can reach the person managing the list at > haskell-cafe-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Haskell-Cafe digest..." > > Today's Topics: > > 1. Example programs with ample use of deepseq? (Joachim Breitner) > 2. Re: Example programs with ample use of deepseq? (Edward Z. Yang) > 3. Re: Example programs with ample use of deepseq? (Joachim Breitner) > 4. Re: Example programs with ample use of deepseq? (Johan Tibell) > 5. Re: Announce: Leksah 0.13.1 (a bit experimental) (Peter Simons) > 6. Re: Announce: Leksah 0.13.1 (a bit experimental) > (Hamish Mackenzie) > > > ---------- Forwarded message ---------- > From: Joachim Breitner > To: Haskell Cafe > Cc: > Date: Mon, 07 Jan 2013 13:06:35 +0100 > Subject: [Haskell-cafe] Example programs with ample use of deepseq? > Dear Haskellers, > > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > a too large hammer in some use cases. Therefore, I?m looking for real > world programs with ample use of deepseq, and ideally easy ways to test > performance (so preferably no GUI applications). > > I?ll try to find out, by runtime observerations, which of the calls ot > deepseq could be replaced by id, seq, or ?shallow seqs? that, for > example, calls seq on the elements of a tuple. > > Thanks, > Joachim > > -- > Joachim "nomeata" Breitner > mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C > xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ > > > > ---------- Forwarded message ---------- > From: "Edward Z. Yang" > To: Joachim Breitner > Cc: Haskell Cafe > Date: Mon, 07 Jan 2013 04:20:43 -0800 > Subject: Re: [Haskell-cafe] Example programs with ample use of deepseq? > There are two senses in which deepseq can be overkill: > > 1. The structure was already strict, and deepseq just forces another > no-op traversal of the entire structure. This hypothetically affects > seq too, although seq is quite cheap so it's not a problem. > > 2. deepseq evaluates too much, when it was actually sufficient only to > force parts of the structure, e.g. the spine of a list. This is less > common for the common use-cases of deepseq; e.g. if I want to force pending > exceptions I am usually interested in all exceptions in a (finite) data > structure; a space leak may be due to an errant closure---if I don't > know which it is, deepseq will force all of them, ditto with work in > parallel programs. Certainly there will be cases where you will want snip > evaluation at some point, but that is somewhat difficult to encode > as a typeclass, since the criterion varies from structure to structure. > (Though, perhaps, this structure would be useful: > > data Indirection a = Indirection a > class DeepSeq Indirection > rnf _ = () > ) > > Cheers, > Edward > > Excerpts from Joachim Breitner's message of Mon Jan 07 04:06:35 -0800 2013: > > Dear Haskellers, > > > > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > > a too large hammer in some use cases. Therefore, I?m looking for real > > world programs with ample use of deepseq, and ideally easy ways to test > > performance (so preferably no GUI applications). > > > > I?ll try to find out, by runtime observerations, which of the calls ot > > deepseq could be replaced by id, seq, or ?shallow seqs? that, for > > example, calls seq on the elements of a tuple. > > > > Thanks, > > Joachim > > > > > > > ---------- Forwarded message ---------- > From: Joachim Breitner > To: haskell-cafe at haskell.org > Cc: > Date: Mon, 07 Jan 2013 16:59:45 +0100 > Subject: Re: [Haskell-cafe] Example programs with ample use of deepseq? > Hi, > Am Montag, den 07.01.2013, 13:06 +0100 schrieb Joachim Breitner: > > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > > a too large hammer in some use cases. Therefore, I?m looking for real > > world programs with ample use of deepseq, and ideally easy ways to test > > performance (so preferably no GUI applications). > > surprisingly, deepseq is not used as much as I thought. > http://packdeps.haskellers.com/reverse/deepseq lists a lot of packages, > but (after grepping through some of the code) most just define NFData > instances and/or use it in tests, but rarely in the ?real? code. For > some reason I expected it to be in more widespread use. > > But therefore I am even more interested in non-hackaged applications > that I can be allowed to stud ? in return I might be able to tell you > way to speed up your application. > > Greetings, > Joachim > > -- > Joachim "nomeata" Breitner > mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C > xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ > > > > ---------- Forwarded message ---------- > From: Johan Tibell > To: Joachim Breitner > Cc: Haskell Cafe > Date: Mon, 7 Jan 2013 08:12:31 -0800 > Subject: Re: [Haskell-cafe] Example programs with ample use of deepseq? > On Mon, Jan 7, 2013 at 4:06 AM, Joachim Breitner > wrote: > > I?m wondering if the use of deepseq to avoid unwanted lazyness might be > > a too large hammer in some use cases. Therefore, I?m looking for real > > world programs with ample use of deepseq, and ideally easy ways to test > > performance (so preferably no GUI applications). > > I never use deepseq, except when setting up benchmark data where it's > a convenient way to make sure that the data is evaluated before the > benchmark is run. > > When removing space leaks you want to avoid creating the thunks in the > first place, not remove them after the fact. Consider a leak caused by > a list of N thunks. Even if you deepseq that list to eventually remove > those thunks, you won't lower your peak memory usage if the list was > materialized at some point. > > In addition, by not creating the thunks in the first place you avoid > some allocation costs. > > -- Johan > > > > > ---------- Forwarded message ---------- > From: Peter Simons > To: haskell-cafe at haskell.org > Cc: gtk2hs-devel at lists.sourceforge.net > Date: Mon, 07 Jan 2013 19:25:22 +0100 > Subject: Re: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental) > Hi Hamish, > > would it be possible to get an update for process-leksah that works with > recent versions of the 'filepath' package? I cannot build leksah-server > with GCC 7.4.2 because of this issue. > > Take care, > Peter > > > > > > ---------- Forwarded message ---------- > From: Hamish Mackenzie > To: Peter Simons > Cc: gtk2hs-devel at lists.sourceforge.net, haskell-cafe at haskell.org > Date: Tue, 8 Jan 2013 14:05:08 +1300 > Subject: Re: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental) > Features in process-leksah have been merged into process. For > newer versions of GHC leksah-server just depends on process. > > If it is trying to install process-leksah then something else > has probably gone wrong. > > Check "ghc-pkg list" for old versions of leksah. Make sure > you have the latest versions of ltk, leksah and leksah-server > from github. (if you use cabal-meta they will be in > the "leksah/vendor" subdirectory). > > Here are the steps for installing from scratch... > https://github.com/leksah/leksah/blob/master/.travis.yml > > Here is what it should look like when it installs... > https://travis-ci.org/leksah/leksah > > On 8 Jan 2013, at 07:25, Peter Simons wrote: > > > Hi Hamish, > > > > would it be possible to get an update for process-leksah that works with > > recent versions of the 'filepath' package? I cannot build leksah-server > > with GCC 7.4.2 because of this issue. > > > > Take care, > > Peter > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Yuriy Solodkyy (y.solodkyy at gmail.com) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at nh2.me Fri Jan 11 01:21:11 2013 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Fri, 11 Jan 2013 01:21:11 +0100 Subject: [Haskell-cafe] Cabal bug? repeat "--reinstall" In-Reply-To: <50E78386.1070203@vex.net> References: <50E74B5F.6040307@nh2.me> <50E78386.1070203@vex.net> Message-ID: <50EF5AF7.7050203@nh2.me> Where do we report this? On 05/01/13 02:36, Albert Y. C. Lai wrote: > On 13-01-04 04:36 PM, Niklas Hamb?chen wrote: >> I get the following: >> >> $ cabal install --only-dependencies --reinstall >> >> Resolving dependencies... >> All the requested packages are already installed: >> Use --reinstall if you want to reinstall anyway. >> >> >> Can somebody confirm that they see the same? > > I confirm. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mail at nh2.me Fri Jan 11 01:27:56 2013 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Fri, 11 Jan 2013 01:27:56 +0100 Subject: [Haskell-cafe] Parallel cabal install ignores order Message-ID: <50EF5C8C.5080301@nh2.me> I have "jobs: 4" enabled in my cabal config to get parallel installs with cabal-install >= 1.16. When I do cabal install --reinstall --force-reinstalls world to reinstall all packages (e.g. to enable profiling or shared), it fails after some point, complaining that the required dependency package is not compiled with the needed flag (for profiling / -dyn). It looks like for reinstalls, parallel cabal-install simply ignores the necessary order. Can somebody confirm this or tell me if this is known? If not, where should it be reported? Thanks Niklas From ivan.miljenovic at gmail.com Fri Jan 11 01:50:23 2013 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri, 11 Jan 2013 10:50:23 +1000 Subject: [Haskell-cafe] Parallel cabal install ignores order In-Reply-To: <50EF5C8C.5080301@nh2.me> References: <50EF5C8C.5080301@nh2.me> Message-ID: On 11 January 2013 10:27, Niklas Hamb?chen wrote: > I have "jobs: 4" enabled in my cabal config to get parallel installs > with cabal-install >= 1.16. > > When I do cabal install --reinstall --force-reinstalls world to > reinstall all packages (e.g. to enable profiling or shared), it fails > after some point, complaining that the required dependency package is > not compiled with the needed flag (for profiling / -dyn). > > It looks like for reinstalls, parallel cabal-install simply ignores the > necessary order. > > Can somebody confirm this or tell me if this is known? > If not, where should it be reported? As an off-the-cuff guess (not having had anything to do with developing cabal-install, etc.), it probably _does_ take dependencies into account... but it sees that the packages are all installed and thus order isn't sufficient. What it seemingly isn't taking into account is the new requirement to have profiling or dynamic builds of existing packages. > > Thanks > Niklas > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From mail at nh2.me Fri Jan 11 01:51:15 2013 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Fri, 11 Jan 2013 01:51:15 +0100 Subject: [Haskell-cafe] Parallel cabal install ignores order In-Reply-To: References: <50EF5C8C.5080301@nh2.me> Message-ID: <50EF6203.3040909@nh2.me> Done: https://github.com/haskell/cabal/issues/1174 On 11/01/13 01:50, Ivan Lazar Miljenovic wrote: > On 11 January 2013 10:27, Niklas Hamb?chen wrote: >> I have "jobs: 4" enabled in my cabal config to get parallel installs >> with cabal-install >= 1.16. >> >> When I do cabal install --reinstall --force-reinstalls world to >> reinstall all packages (e.g. to enable profiling or shared), it fails >> after some point, complaining that the required dependency package is >> not compiled with the needed flag (for profiling / -dyn). >> >> It looks like for reinstalls, parallel cabal-install simply ignores the >> necessary order. >> >> Can somebody confirm this or tell me if this is known? >> If not, where should it be reported? > > As an off-the-cuff guess (not having had anything to do with > developing cabal-install, etc.), it probably _does_ take dependencies > into account... but it sees that the packages are all installed and > thus order isn't sufficient. What it seemingly isn't taking into > account is the new requirement to have profiling or dynamic builds of > existing packages. > >> >> Thanks >> Niklas >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From mail at nh2.me Fri Jan 11 01:53:41 2013 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Fri, 11 Jan 2013 01:53:41 +0100 Subject: [Haskell-cafe] Cabal bug? repeat "--reinstall" In-Reply-To: <50EF5AF7.7050203@nh2.me> References: <50E74B5F.6040307@nh2.me> <50E78386.1070203@vex.net> <50EF5AF7.7050203@nh2.me> Message-ID: <50EF6295.4020705@nh2.me> Ahah on Github. Filed as https://github.com/haskell/cabal/issues/1175. On Fri 11 Jan 2013 01:21:11 CET, Niklas Hamb?chen wrote: > Where do we report this? > > On 05/01/13 02:36, Albert Y. C. Lai wrote: >> On 13-01-04 04:36 PM, Niklas Hamb?chen wrote: >>> I get the following: >>> >>> $ cabal install --only-dependencies --reinstall >>> >>> Resolving dependencies... >>> All the requested packages are already installed: >>> Use --reinstall if you want to reinstall anyway. >>> >>> >>> Can somebody confirm that they see the same? >> >> I confirm. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lucas.dicioccio at gmail.com Fri Jan 11 10:22:45 2013 From: lucas.dicioccio at gmail.com (lucas di cioccio) Date: Fri, 11 Jan 2013 10:22:45 +0100 Subject: [Haskell-cafe] [announce] second Haskell meetup in Paris Message-ID: Hi, I am pleased to annouce that I'm bootstrapping a Haskell-enthusiastics group in Paris. We recently scheduled our second Haskell meetup in Paris. This meetup will take place next Monday (Monday, January 14, 2013). AF83 ( http://af83.com/ ) has been kind enough to offer us a room for our meeting. You don't have to, but it is recommended to, register for the meetup on http://meetup.haskell-paris.fr/ or by sending me an email. The website for our group is http://haskell-paris.fr/ (in French). You should pay it a click not only because it's written in Haskell but also to glance at our logo, propose a talk, or read the digest of past meetup(s). Regards, --Lucas DiCioccio -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Fri Jan 11 10:34:02 2013 From: hesselink at gmail.com (Erik Hesselink) Date: Fri, 11 Jan 2013 10:34:02 +0100 Subject: [Haskell-cafe] Example programs with ample use of deepseq? In-Reply-To: <1357771124.14416.5.camel@kirk> References: <1357560395.15170.4.camel@kirk> <1357574385.15170.14.camel@kirk> <1357682045.18991.3.camel@kirk> <1357738841.11574.5.camel@kirk> <1357771124.14416.5.camel@kirk> Message-ID: On Wed, Jan 9, 2013 at 11:38 PM, Joachim Breitner wrote: > Am Mittwoch, den 09.01.2013, 15:11 +0100 schrieb Erik Hesselink: >> We finally solved the problems by completely moving >> to strict map operations, strict MVar/TVar operations, and strict data >> types. > > do you mean strict by policy (i.e. before storing something in a > [MT]Var, you ensure it is evaluated) or by construction (by `seq` or > `deepseq`?ing everything before it is stored)? In the latter case: Seq > or deeqseq? Again in the latter case: Do you worry about the performance > of repeatedly deepseq?ing an already deepseq?ed and possibly large > value? Strict by construction: we `seq` when storing in a var. This is similar to the primed functions in some places, and the new Data.Map.Strict. So repeatedly deepseq'ing isn't a problem: deepseq in our case is only used for debugging. > You are not the first user of Haskell who ends up with that approach to > lazy evaluation. I?m not sure what that means for Haskell, though. Well, we still use the 'normal' lazy approach in most places. Only where we have persistent shared state do we use the above approach of making everything strict. This means updaters pay the computational price, not readers, which seems like a sane idea. Regards, Erik From katya at computing.dundee.ac.uk Fri Jan 11 12:12:26 2013 From: katya at computing.dundee.ac.uk (Ekaterina Komendantskaya) Date: Fri, 11 Jan 2013 11:12:26 +0000 Subject: [Haskell-cafe] Permanent Academic Positions (Computational Logic/Functional Programming) in Dundee Deadline 23 January Message-ID: ****** Dundee Fellowships ****** http://www.dundee.ac.uk/dundeefellows/ University of Dundee announces several permanent positions, with a 5-year starting period of a Research Fellowship. One of the named priority areas is Computational Logic/ Functional Programming / Verification. For more details, see below or email me: Katya Komendantskaya School of Computing University of Dundee Dundee Fellowship Permanent position Closing Date for applications: Wednesday 23 January 2013. University of Dundee is advertising a series of permanent academic jobs across the College of Arts & Science and Engineering, named Dundee Fellows. The aim is to bring in a series of excellent academics onto permanent contracts (subject to the completion of 3 year probation) into any research area within the College. These staff will be labelled as Dundee Fellows during their first 5 years, over which time they will receive enhanced staff development and a research focus to their duties, while automatically moving to a regular academic contract (lecturer, senior lecturer, reader or professor) at the end of these 5 years. These will be independent researchers (and not postdocs under supervision). Their teaching load will start low, and will gradually increase over the first 5 years, to phase them into teaching. As the University of Dundee moves towards its 25 year vision of becoming Scotland?s leading University, we are actively investing in the next generation of our academic community. Our Dundee Fellows scheme offers exciting opportunities to outstanding, high potential, early career researchers of any age to establish themselves at the University of Dundee and develop towards making a full and excellent contribution to research, teaching and leadership in their chosen field. Full details are available here: http://www.dundee.ac.uk/dundeefellows/ ****************************************** From robotijn at gmail.com Fri Jan 11 22:37:33 2013 From: robotijn at gmail.com (Tijn van der Zant) Date: Fri, 11 Jan 2013 22:37:33 +0100 Subject: [Haskell-cafe] Roshask Message-ID: Hi, I want to use Haskell to program my robot using ros. I've found roshask https://github.com/acowley/roshask and I was wondering if someone on this list has experience with it and can tell me how good it is. Thanx! --Tijn -------------- next part -------------- An HTML attachment was scrubbed... URL: From acowley at seas.upenn.edu Fri Jan 11 22:53:38 2013 From: acowley at seas.upenn.edu (Anthony Cowley) Date: Fri, 11 Jan 2013 16:53:38 -0500 Subject: [Haskell-cafe] Roshask In-Reply-To: References: Message-ID: I know that it probably needs updating for Groovy. I don't think it has many users, which makes it more challenging to keep things running smoothly, but I'm willing to help any interested parties get it up and running. Anthony On Fri, Jan 11, 2013 at 4:37 PM, Tijn van der Zant wrote: > Hi, > > I want to use Haskell to program my robot using ros. I've found roshask > https://github.com/acowley/roshask > and I was wondering if someone on this list has experience with it and can > tell me how good it is. > Thanx! > > --Tijn > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tab at snarc.org Fri Jan 11 23:55:46 2013 From: tab at snarc.org (Vincent Hanquez) Date: Fri, 11 Jan 2013 23:55:46 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. Message-ID: <20130111225545.GA5972@snarc.org> Hi Cafe, I've recently released crypto-pubkey [1][2], which provide a comprehensive solution for public key cryptography. Most known RSA modes (PKCS15, OAEP, PSS) are supported, and there's also DSA and ElGamal signature support. Most of the code originally lived in cryptocipher, but have now been made better and safer, and support more modes. I've spend some good chunk of time adding KATs and tests, documentation, and making sure the performance was ahead of other haskell implementations. Enjoy, [1] http://hackage.haskell.org/package/crypto-pubkey-0.1.1 [2] https://github.com/vincenthz/hs-crypto-pubkey -- Vincent From hjgtuyl at chello.nl Sat Jan 12 00:04:39 2013 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sat, 12 Jan 2013 00:04:39 +0100 Subject: [Haskell-cafe] [Haskell-beginners] Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar? In-Reply-To: References: Message-ID: On Wed, 09 Jan 2013 20:05:07 +0100, KC wrote: > :) > I can't download it either. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From mail at joachim-breitner.de Sat Jan 12 00:34:54 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Sat, 12 Jan 2013 00:34:54 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <20130111225545.GA5972@snarc.org> References: <20130111225545.GA5972@snarc.org> Message-ID: <1357947294.19592.13.camel@kirk> Hi, Am Freitag, den 11.01.2013, 23:55 +0100 schrieb Vincent Hanquez: > I've recently released crypto-pubkey [1][2], which provide a comprehensive > solution for public key cryptography. > > Most known RSA modes (PKCS15, OAEP, PSS) are supported, and there's also DSA > and ElGamal signature support. Most of the code originally lived in cryptocipher, > but have now been made better and safer, and support more modes. > > I've spend some good chunk of time adding KATs and tests, documentation, and > making sure the performance was ahead of other haskell implementations. nice. But in the interest of possible users: Is there a reason why this code could not live in cryptocipher? Do we need multiple implementations of the cyphers, and expect our users to find out for themselves why to use one or the other? Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From tab at snarc.org Sat Jan 12 05:39:40 2013 From: tab at snarc.org (Vincent Hanquez) Date: Sat, 12 Jan 2013 04:39:40 +0000 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <1357947294.19592.13.camel@kirk> References: <20130111225545.GA5972@snarc.org> <1357947294.19592.13.camel@kirk> Message-ID: <50F0E90C.2090100@snarc.org> On 01/11/2013 11:34 PM, Joachim Breitner wrote: > nice. But in the interest of possible users: Is there a reason why this > code could not live in cryptocipher? Do we need multiple implementations > of the cyphers, and expect our users to find out for themselves why to > use one or the other? The duplicate implementations in cryptocipher have been marked as deprecated and will be removed in a near future. The only reason is has been spun off is that i think it was a mistake to put it along block and stream cipher in the first place, and i prefer smaller package with dedicated dependencies. -- Vincent From anton.dergunov at mail.ru Sat Jan 12 09:57:07 2013 From: anton.dergunov at mail.ru (=?UTF-8?B?QW50b24gRGVyZ3Vub3Y=?=) Date: Sat, 12 Jan 2013 12:57:07 +0400 Subject: [Haskell-cafe] =?utf-8?q?Seeking_feedback_for_a_tutorial_paper_dr?= =?utf-8?q?aft_about_GADTs?= In-Reply-To: <20130109151319.GA1321@antaeus> References: <1357672959.506368624@f192.mail.ru> <20130109151319.GA1321@antaeus> Message-ID: <1357981027.292855834@f148.mail.ru> I would like to thank Owen Stephens, Alexander Batischev, Denis Kasak and Mann mit Hut for the valuable comments! I am going to update the tutorial to fix the indicated issues. Also, I am going to improve description of kinds and singletons. Also, I will improve description of red-black tree example: I think I need to include the whole listing after every big step. Are there any other topics you would like to be described in the context of a practical-oriented introductory-level tutorial on GADTs? PS: Please let me know if I misspelled your names (to make sure that I do not put wrong names in acknowledgements section). You can do it by email to anton dot dergunov dog mail dot ru. -- Best Regards, Anton Dergunov ?????, 9 ?????? 2013, 17:13 +02:00 ?? Alexander Batischev : >On Tue, Jan 08, 2013 at 11:22:39PM +0400, Anton Dergunov wrote: >> I have written a draft of an introductory-level tutorial paper about >> GADTs in Haskell (for submittion to proceedings of the recent LASER >> summer school) and I would like to seek initial feedback about its >> content: what information is probably missing? are there any subtle >> mistakes? > >Not exactly the feedback you asked for, but I hope it still can be of >some use. > >As a person with no prior knowledge about GADTs, I found your paper a >good introduction. Following proof of correctness of red-black tree >insertions turned out to be a little bit of a challenge as type >annotations quickly become tangled (made me wondering how one should >prove correctness of the proof). > >I particularly liked how you handle things that are not central to >tutorial, like phantom and existential types: you give single-sentence >explanation that provides good enough intuition to follow you further. > >Talking of quick explanations, I would love to see kinds and singleton >types explained in the same manner. You tried to explain singleton types >at page 13, but I find explanation provided by GHC documentation[1] to >be much more clear. As for kinds, it just puzzles me why you use the >term but don't explain it. > >??1. http://hackage.haskell.org/trac/ghc/wiki/TypeNats/Basics > >The same goes for type families - while I was able to quickly look up >definition of singleton types, I failed to comprehend basics of type >families by reading Haskell Wiki. I ended up pretending that type >families are just type-level functions. > >I would love to see Yampa optimizations section expanded with more >interesting examples. Are there any? > >Last but not least, a few minor typos and errors I spotted: > >* at page 8, "Than we need to declare type instances..." should be "Then >??we need..."; > >* probably due to excessive editing, parameters to repeatElem at page 13 >??are in the different order than before; > >* at page 14, you state: > >??> As in all binary search trees, for a particular node N c l x r >??> values greater than x are stored in left sub-tree (in l) and values >??> less than x are stored in right sub-tree (in r). > >??But later on, your code contradict that statement by recursing to left >??sub-tree when x we look for is less than value in the node, and to >??right sub-tree when x is greater than value in the node. > >Thank you once again for a nice introduction to GADTs! > >-- >Regards, >Alexander Batischev > >PGP key 356961A20C8BFD03 >Fingerprint: CE6C 4307 9348 58E3 FD94 A00F 3569 61A2 0C8B FD03 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Sat Jan 12 14:12:44 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Sat, 12 Jan 2013 14:12:44 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. References: <20130111225545.GA5972@snarc.org> Message-ID: <20130112141244.0efa703b@tritium.streitmacht.eu> Vincent Hanquez wrote: > I've recently released crypto-pubkey [1][2], which provide a > comprehensive solution for public key cryptography. > > Most known RSA modes (PKCS15, OAEP, PSS) are supported, and there's > also DSA and ElGamal signature support. Most of the code originally > lived in cryptocipher, but have now been made better and safer, and > support more modes. This seems like a very useful library. Thanks for that! > I've spend some good chunk of time adding KATs and tests, > documentation, and making sure the performance was ahead of other > haskell implementations. I suggest looking at Daniel Fischer's arithmoi [1] library, which implements very fast Integer operations and should provide most functionality needed. However, beware of timing attacks. Also for the particular purpose of generating safe primes I have written a blazingly fast implementation that uses intelligent sieving and finds even large primes (>= 4096 bits) within seconds or minutes. It's on hpaste [2]. I might turn this into a library at some point. [1]: [2]: Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From danny.gratzer at gmail.com Sat Jan 12 16:32:12 2013 From: danny.gratzer at gmail.com (Danny Gratzer) Date: Sat, 12 Jan 2013 09:32:12 -0600 Subject: [Haskell-cafe] A Meetup Group for MN Haskellers Message-ID: Hello, After seeing the post about Manchurian Haskellers I decided to start one for people in and around the Twin Cities. Here's the meetup page: http://www.meetup.com/HaskellMN/ If any Haskell guru's are lurking around here we'd love to have you give a talk! -- Danny Gratzer -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Sat Jan 12 17:40:23 2013 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Sat, 12 Jan 2013 23:40:23 +0700 Subject: [Haskell-cafe] A Meetup Group for MN Haskellers In-Reply-To: References: Message-ID: Hey Danny, Good job taking the lead! Wish you all success because I think meetups have so many underrated benefits. (Where I am in a city > 10 million, i.e. Jakarta, Indonesia, you'd think it would be a piece of cake, but so far no dice. Me and another guy are working on this ....) Have you considered corralling a bunch of other FPers together, like the Bay Area FP group? Results from a search for "Scala / Clojure Minneapolis" look promising. -- Kim-Ee On Sat, Jan 12, 2013 at 10:32 PM, Danny Gratzer wrote: > Hello, > > After seeing the post about Manchurian Haskellers I decided to start one > for people in and around the Twin Cities. > > Here's the meetup page: http://www.meetup.com/HaskellMN/ > > If any Haskell guru's are lurking around here we'd love to have you give a > talk! > > -- > Danny Gratzer > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mystic.satvik at gmail.com Sat Jan 12 20:33:08 2013 From: mystic.satvik at gmail.com (satvik chauhan) Date: Sun, 13 Jan 2013 01:03:08 +0530 Subject: [Haskell-cafe] Generating random arguments for a function Message-ID: I am trying to use quickcheck to generate random arguments of a given function (assuming all its types have Arbitrary instance and Show instance) along with the evaluation of the function at those arguments. Suppose I have a function add :: Int -> Int -> Int add a b = a+b Then I assume a behavior like > randomEvaluate add (["1","3"],"4") where 1 and 3 are random values generated for `Int` and 4 is `f 1 3`. I have asked this on SO but am not fully satisfied with the answers. -Satvik -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Sat Jan 12 21:54:19 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Sat, 12 Jan 2013 20:54:19 +0000 Subject: [Haskell-cafe] A Meetup Group for MN Haskellers In-Reply-To: References: Message-ID: You made me upset, I thought you created a Meetup for our mancunian :( sob :( Alfredo ps. Good luck for your meetup, though :) On 12 January 2013 16:40, Kim-Ee Yeoh wrote: > Hey Danny, > > Good job taking the lead! Wish you all success because I think meetups > have so many underrated benefits. > > (Where I am in a city > 10 million, i.e. Jakarta, Indonesia, you'd think > it would be a piece of cake, but so far no dice. Me and another guy are > working on this ....) > > Have you considered corralling a bunch of other FPers together, like the > Bay Area FP group? Results from a search for "Scala / Clojure Minneapolis" > look promising. > > > -- Kim-Ee > > > On Sat, Jan 12, 2013 at 10:32 PM, Danny Gratzer wrote: > >> Hello, >> >> After seeing the post about Manchurian Haskellers I decided to start one >> for people in and around the Twin Cities. >> >> Here's the meetup page: http://www.meetup.com/HaskellMN/ >> >> If any Haskell guru's are lurking around here we'd love to have you give >> a talk! >> >> -- >> Danny Gratzer >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danny.gratzer at gmail.com Sat Jan 12 22:36:19 2013 From: danny.gratzer at gmail.com (Danny Gratzer) Date: Sat, 12 Jan 2013 15:36:19 -0600 Subject: [Haskell-cafe] A Meetup Group for MN Haskellers In-Reply-To: References: Message-ID: Haha sorry for the false hope, I'll update in a few weeks once things get rolling. On Sat, Jan 12, 2013 at 2:54 PM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > You made me upset, I thought you created a Meetup for our mancunian :( sob > :( > > Alfredo > > ps. Good luck for your meetup, though :) > > > On 12 January 2013 16:40, Kim-Ee Yeoh wrote: > >> Hey Danny, >> >> Good job taking the lead! Wish you all success because I think meetups >> have so many underrated benefits. >> >> (Where I am in a city > 10 million, i.e. Jakarta, Indonesia, you'd think >> it would be a piece of cake, but so far no dice. Me and another guy are >> working on this ....) >> >> Have you considered corralling a bunch of other FPers together, like the >> Bay Area FP group? Results from a search for "Scala / Clojure Minneapolis" >> look promising. >> >> >> -- Kim-Ee >> >> >> On Sat, Jan 12, 2013 at 10:32 PM, Danny Gratzer wrote: >> >>> Hello, >>> >>> After seeing the post about Manchurian Haskellers I decided to start one >>> for people in and around the Twin Cities. >>> >>> Here's the meetup page: http://www.meetup.com/HaskellMN/ >>> >>> If any Haskell guru's are lurking around here we'd love to have you give >>> a talk! >>> >>> -- >>> Danny Gratzer >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -- Danny Gratzer -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen.tetley at gmail.com Sun Jan 13 09:49:08 2013 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun, 13 Jan 2013 08:49:08 +0000 Subject: [Haskell-cafe] Generating random arguments for a function In-Reply-To: References: Message-ID: In general you can't do this whether you use pats of QuickCheck or not - `randomEvalute` would need to inspect the supplied function to see how many input parameters it has so it can list them, but there is no such introspection in Haskell. From roma at ro-che.info Sun Jan 13 10:28:50 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 13 Jan 2013 11:28:50 +0200 Subject: [Haskell-cafe] Generating random arguments for a function In-Reply-To: References: Message-ID: <20130113092850.GA12602@sniper> * Stephen Tetley [2013-01-13 08:49:08+0000] > In general you can't do this whether you use pats of QuickCheck or not > - `randomEvalute` would need to inspect the supplied function to see > how many input parameters it has so it can list them, but there is no > such introspection in Haskell. This can be done with relatively simple type class hackery. In fact, QuickCheck already does that in order to generate arguments and print them in case of failure. Roman From stephen.tetley at gmail.com Sun Jan 13 10:45:08 2013 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun, 13 Jan 2013 09:45:08 +0000 Subject: [Haskell-cafe] Generating random arguments for a function In-Reply-To: <20130113092850.GA12602@sniper> References: <20130113092850.GA12602@sniper> Message-ID: Yes - I was just checking the first QuickCheck paper to see how the authors did this. You would need a new type class that works like `Testable` and the versions of associated machinery `forAll` and `evaluate` to unroll function application. On 13 January 2013 09:28, Roman Cheplyaka wrote: > > This can be done with relatively simple type class hackery. In fact, > QuickCheck already does that in order to generate arguments and print > them in case of failure. > > Roman From mystic.satvik at gmail.com Sun Jan 13 10:47:13 2013 From: mystic.satvik at gmail.com (satvik chauhan) Date: Sun, 13 Jan 2013 15:17:13 +0530 Subject: [Haskell-cafe] Generating random arguments for a function In-Reply-To: <20130113092850.GA12602@sniper> References: <20130113092850.GA12602@sniper> Message-ID: I have a working code of this but for that I have to reimplement Arbitrary and Testable typeclasses which I don't want to do. I thought it might be possible to use parts of quickcheck without actually changing its code but still I am unable to find a suitable solution. -Satvik On Sun, Jan 13, 2013 at 2:58 PM, Roman Cheplyaka wrote: > * Stephen Tetley [2013-01-13 08:49:08+0000] > > In general you can't do this whether you use pats of QuickCheck or not > > - `randomEvalute` would need to inspect the supplied function to see > > how many input parameters it has so it can list them, but there is no > > such introspection in Haskell. > > This can be done with relatively simple type class hackery. In fact, > QuickCheck already does that in order to generate arguments and print > them in case of failure. > > Roman > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Sun Jan 13 13:15:43 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Sun, 13 Jan 2013 12:15:43 +0000 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? Message-ID: Morning Cafe, I'm planning to do a series of write-ups about Category Theory, to publish them on the company's blog I'm currently employed. I'm not a CT expert, but since the best way to learn something is to explain it to others, I want to take a shot :) In my mind I will structure the posts following Awodey's book, but I'm wondering how can I make my posts a little more "real world". I always read about the "Hask category", which seems to be the "bootstrap" of the whole logic behind Haskell. Can you please give my materials/papers/links/blogs to the Hask category and briefly explain me how it relates to Category Theory and Haskell itself? I hope my question is clear enough, in case is not, I'll restate :P Cheers, A. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob at redivi.com Sun Jan 13 16:34:06 2013 From: bob at redivi.com (Bob Ippolito) Date: Sun, 13 Jan 2013 07:34:06 -0800 Subject: [Haskell-cafe] Generating random arguments for a function In-Reply-To: References: <20130113092850.GA12602@sniper> Message-ID: I think it's more complicated because he doesn't know what the return type or arity of the function is. In QuickCheck they know the return type of a property is Bool. In this case, we only know that the return type is an instance of Show. I don't think that's enough to simply implement this. On Sunday, January 13, 2013, Stephen Tetley wrote: > Yes - I was just checking the first QuickCheck paper to see how the > authors did this. > > You would need a new type class that works like `Testable` and the > versions of associated machinery `forAll` and `evaluate` to unroll > function application. > > > On 13 January 2013 09:28, Roman Cheplyaka > > wrote: > > > > > This can be done with relatively simple type class hackery. In fact, > > QuickCheck already does that in order to generate arguments and print > > them in case of failure. > > > > Roman > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Sun Jan 13 17:14:32 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Sun, 13 Jan 2013 17:14:32 +0100 Subject: [Haskell-cafe] Generating random arguments for a function In-Reply-To: References: <20130113092850.GA12602@sniper> Message-ID: <1358093672.22914.0.camel@kirk> Hi, Am Sonntag, den 13.01.2013, 07:34 -0800 schrieb Bob Ippolito: > I think it's more complicated because he doesn't know what the return > type or arity of the function is. In QuickCheck they know the return > type of a property is Bool. In this case, we only know that the return > type is an instance of Show. I don't think that's enough to simply > implement this. I posted on SE an answer that tries to do it with OverlappingInstances: http://stackoverflow.com/questions/14294802/evaluating-function-at-random-arguments-using-quickcheck/14295179#14295179 Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From alex.solla at gmail.com Sun Jan 13 18:44:47 2013 From: alex.solla at gmail.com (Alexander Solla) Date: Sun, 13 Jan 2013 09:44:47 -0800 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: References: Message-ID: There was a conversation on the cafe about this last month. Check out: https://groups.google.com/forum/#!topic/haskell-cafe/tBO2AowUvMY Category theory is a "language" of composition. In "logical" terms, different categories are models of different axioms. That said, a "rich enough" category is suitable for encoding the "whole" of category theory (as a language -- not necessarily as a model containing sub-models. Typing introduces some complications, since types meant to help us escape logical paradoxes like Russell's by introducing a notion of "foundedness") Hask is the category whose objects are types and whose morphisms are Haskell functions. Hask is a very rich category, and is suitable for encoding a lot (but not all) of category theory. As far as I know, the actual boundary is as yet unknown. On Sun, Jan 13, 2013 at 4:15 AM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > Morning Cafe, > > I'm planning to do a series of write-ups about Category Theory, to publish > them on the company's blog I'm currently employed. > I'm not a CT expert, but since the best way to learn something is to > explain it to others, I want to take a shot :) > In my mind I will structure the posts following Awodey's book, but I'm > wondering how can I make my posts a little more "real world". > I always read about the "Hask category", which seems to be the "bootstrap" > of the whole logic behind Haskell. Can you please give my > materials/papers/links/blogs to the Hask category and briefly explain me > how it relates to Category Theory and Haskell itself? > > I hope my question is clear enough, in case is not, I'll restate :P > > Cheers, > A. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Sun Jan 13 19:53:50 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Sun, 13 Jan 2013 18:53:50 +0000 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: References: Message-ID: Thank you Alexander for the reply. My wondering is: is Hask a category created by Haskell researchers or was something already present in literature? Cheers, A. On 13 January 2013 17:44, Alexander Solla wrote: > There was a conversation on the cafe about this last month. Check out: > > https://groups.google.com/forum/#!topic/haskell-cafe/tBO2AowUvMY > > Category theory is a "language" of composition. In "logical" terms, > different categories are models of different axioms. That said, a "rich > enough" category is suitable for encoding the "whole" of category theory > (as a language -- not necessarily as a model containing sub-models. Typing > introduces some complications, since types meant to help us escape logical > paradoxes like Russell's by introducing a notion of "foundedness") > > Hask is the category whose objects are types and whose morphisms are > Haskell functions. > > Hask is a very rich category, and is suitable for encoding a lot (but not > all) of category theory. As far as I know, the actual boundary is as yet > unknown. > > > On Sun, Jan 13, 2013 at 4:15 AM, Alfredo Di Napoli < > alfredo.dinapoli at gmail.com> wrote: > >> Morning Cafe, >> >> I'm planning to do a series of write-ups about Category Theory, to >> publish them on the company's blog I'm currently employed. >> I'm not a CT expert, but since the best way to learn something is to >> explain it to others, I want to take a shot :) >> In my mind I will structure the posts following Awodey's book, but I'm >> wondering how can I make my posts a little more "real world". >> I always read about the "Hask category", which seems to be the >> "bootstrap" of the whole logic behind Haskell. Can you please give my >> materials/papers/links/blogs to the Hask category and briefly explain me >> how it relates to Category Theory and Haskell itself? >> >> I hope my question is clear enough, in case is not, I'll restate :P >> >> Cheers, >> A. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From conal at conal.net Sun Jan 13 20:10:42 2013 From: conal at conal.net (Conal Elliott) Date: Sun, 13 Jan 2013 11:10:42 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? Message-ID: I sometimes run into trouble with lack of injectivity for type families. I'm trying to understand what's at the heart of these difficulties and whether I can avoid them. Also, whether some of the obstacles could be overcome with simple improvements to GHC. Here's a simple example: > {-# LANGUAGE TypeFamilies #-} > > type family F a > > foo :: F a > foo = undefined > > bar :: F a > bar = foo The error message: Couldn't match type `F a' with `F a1' NB: `F' is a type function, and may not be injective In the expression: foo In an equation for `bar': bar = foo A terser (but perhaps subtler) example producing the same error: > baz :: F a > baz = baz Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. Does the difficulty here have to do with trying to *infer* the type and then compare with the given one? Or is there an issue even with type *checking* in such cases? Other insights welcome, as well as suggested work-arounds. I know about (injective) data families but don't want to lose the convenience of type synonym families. Thanks, -- Conal -------------- next part -------------- An HTML attachment was scrubbed... URL: From iavor.diatchki at gmail.com Sun Jan 13 20:39:04 2013 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Sun, 13 Jan 2013 11:39:04 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: Hello Conal, The issue with your example is that it is ambiguous, so GHC can't figure out how to instantiate the use of `foo`. It might be easier to see why this is if you write it in this form: > foo :: (F a ~ b) => b > foo = ... Now, we can see that only `b` appears on the RHS of the `=>`, so there is really no way for GHC to figure out what is the intended value for `a`. Replacing `a` with a concrete type (such as `Bool`) eliminates the problem, because now GHC does not need to come up with a value for `a`. Another way to eliminate the ambiguity would be if `F` was injective---then we'd know that `b` uniquely determines `a` so again there would be no ambiguity. If `F` is not injective, however, the only workaround would be to write the type in such a way that the function arguments appear in the signature directly (e.g., something like 'a -> F a' would be ok). -Iavor On Sun, Jan 13, 2013 at 11:10 AM, Conal Elliott wrote: > I sometimes run into trouble with lack of injectivity for type families. > I'm trying to understand what's at the heart of these difficulties and > whether I can avoid them. Also, whether some of the obstacles could be > overcome with simple improvements to GHC. > > Here's a simple example: > > > {-# LANGUAGE TypeFamilies #-} > > > > type family F a > > > > foo :: F a > > foo = undefined > > > > bar :: F a > > bar = foo > > The error message: > > Couldn't match type `F a' with `F a1' > NB: `F' is a type function, and may not be injective > In the expression: foo > In an equation for `bar': bar = foo > > A terser (but perhaps subtler) example producing the same error: > > > baz :: F a > > baz = baz > > Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. > > Does the difficulty here have to do with trying to *infer* the type and > then compare with the given one? Or is there an issue even with type > *checking* in such cases? > > Other insights welcome, as well as suggested work-arounds. > > I know about (injective) data families but don't want to lose the > convenience of type synonym families. > > Thanks, -- Conal > > > _______________________________________________ > Glasgow-haskell-users mailing list > Glasgow-haskell-users at haskell.org > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From conal at conal.net Sun Jan 13 21:05:04 2013 From: conal at conal.net (Conal Elliott) Date: Sun, 13 Jan 2013 12:05:04 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: Hi Iavor, Thanks for the remarks. so there is really no way for GHC to figure out what is the intended value > for `a`. > Indeed. Though I wonder: does the type-checker really need to find a binding for `a` in this case, i.e., given the equation `(forall a. F a) == (forall a'. F a')`? -- Conal On Sun, Jan 13, 2013 at 11:39 AM, Iavor Diatchki wrote: > Hello Conal, > > The issue with your example is that it is ambiguous, so GHC can't figure > out how to instantiate the use of `foo`. It might be easier to see why > this is if you write it in this form: > > > foo :: (F a ~ b) => b > > foo = ... > > Now, we can see that only `b` appears on the RHS of the `=>`, so there is > really no way for GHC to figure out what is the intended value for `a`. > Replacing `a` with a concrete type (such as `Bool`) eliminates the > problem, because now GHC does not need to come up with a value for `a`. > Another way to eliminate the ambiguity would be if `F` was injective---then > we'd know that `b` uniquely determines `a` so again there would be no > ambiguity. > > If `F` is not injective, however, the only workaround would be to write > the type in such a way that the function arguments appear in the signature > directly (e.g., something like 'a -> F a' would be ok). > > -Iavor > > > > > > > > > On Sun, Jan 13, 2013 at 11:10 AM, Conal Elliott wrote: > >> I sometimes run into trouble with lack of injectivity for type >> families. I'm trying to understand what's at the heart of these >> difficulties and whether I can avoid them. Also, whether some of the >> obstacles could be overcome with simple improvements to GHC. >> >> Here's a simple example: >> >> > {-# LANGUAGE TypeFamilies #-} >> > >> > type family F a >> > >> > foo :: F a >> > foo = undefined >> > >> > bar :: F a >> > bar = foo >> >> The error message: >> >> Couldn't match type `F a' with `F a1' >> NB: `F' is a type function, and may not be injective >> In the expression: foo >> In an equation for `bar': bar = foo >> >> A terser (but perhaps subtler) example producing the same error: >> >> > baz :: F a >> > baz = baz >> >> Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. >> >> Does the difficulty here have to do with trying to *infer* the type and >> then compare with the given one? Or is there an issue even with type >> *checking* in such cases? >> >> Other insights welcome, as well as suggested work-arounds. >> >> I know about (injective) data families but don't want to lose the >> convenience of type synonym families. >> >> Thanks, -- Conal >> >> >> _______________________________________________ >> Glasgow-haskell-users mailing list >> Glasgow-haskell-users at haskell.org >> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From conal at conal.net Sun Jan 13 21:13:48 2013 From: conal at conal.net (Conal Elliott) Date: Sun, 13 Jan 2013 12:13:48 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: <20130113193615.GA8787@localhost> References: <20130113193615.GA8787@localhost> Message-ID: Hi Christian, Given "bar :: Bool", I can't see how one could go from "Bool" to "F a = > Bool" and determine "a" uniquely. > The same question applies to "foo :: Bool", right? Yet no error message there. Regards, - Conal On Sun, Jan 13, 2013 at 11:36 AM, Christian H?ner zu Siederdissen < choener at tbi.univie.ac.at> wrote: > Hi, > > How would you infer "a" from "F a"? Given "bar :: Bool", I can't see how > one could go from "Bool" to "F a = Bool" and determine "a" uniquely. > > My question is not completely retorical, if there is an answer I would > like to know it :-) > > Gruss, > Christian > > > * Conal Elliott [13.01.2013 20:13]: > > I sometimes run into trouble with lack of injectivity for type > families. > > I'm trying to understand what's at the heart of these difficulties and > > whether I can avoid them. Also, whether some of the obstacles could be > > overcome with simple improvements to GHC. > > > > Here's a simple example: > > > > > {-# LANGUAGE TypeFamilies #-} > > > > > > type family F a > > > > > > foo :: F a > > > foo = undefined > > > > > > bar :: F a > > > bar = foo > > > > The error message: > > > > Couldn't match type `F a' with `F a1' > > NB: `F' is a type function, and may not be injective > > In the expression: foo > > In an equation for `bar': bar = foo > > > > A terser (but perhaps subtler) example producing the same error: > > > > > baz :: F a > > > baz = baz > > > > Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. > > > > Does the difficulty here have to do with trying to *infer* the type > and > > then compare with the given one? Or is there an issue even with type > > *checking* in such cases? > > > > Other insights welcome, as well as suggested work-arounds. > > > > I know about (injective) data families but don't want to lose the > > convenience of type synonym families. > > > > Thanks, -- Conal > > > _______________________________________________ > > Glasgow-haskell-users mailing list > > Glasgow-haskell-users at haskell.org > > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.mvd at gmail.com Sun Jan 13 21:27:44 2013 From: petr.mvd at gmail.com (Petr P) Date: Sun, 13 Jan 2013 21:27:44 +0100 Subject: [Haskell-cafe] cabal sdist warns about optimization levels Message-ID: Hi all, I'm working on a library for fast sorting of MArrays. The library is primarily about speed, so I added ghc-options: -O2 to the cabal file. Now cabal sdist complains with: 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer compile times on your users. I wonder: (1) Is there a way how to disable the warning? As the main aim of the library is speed, I believe -O2 is appropriate here. And since the code is quite short, I'm quite sure the increased compile time won't be noticeable. (2) Why does cabal complain about it at the first place? I found a reference saying the warning is adequate: https://github.com/haskell/cabal/issues/808 but not saying why. Maybe for complex programs -O2 prolongs compile time too much, but libraries are usually compiled once and used many times, so using -O2 for them seems reasonable in many cases. Thanks for help, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From iavor.diatchki at gmail.com Sun Jan 13 21:52:14 2013 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Sun, 13 Jan 2013 12:52:14 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: Hello, On Sun, Jan 13, 2013 at 12:05 PM, Conal Elliott wrote: > > > so there is really no way for GHC to figure out what is the intended value >> for `a`. >> > > Indeed. Though I wonder: does the type-checker really need to find a > binding for `a` in this case, i.e., given the equation `(forall a. F a) == > (forall a'. F a')`? > Wouldn't that make `F` a constant type family, and so one could just skip the `a` parameter? Anyway, if there was a way to assert something like that about a type-function, than there would be no problem. When something like that happens (i.e., GHC figures out that it does not know how to instantiate a type variable, but it is sure that the actual instantiation does not matter), GHC instantiates the variable a special type called `Any`, which has a very polymorphic kind. By the way, Simon recently reworked the ambiguity checker in GHC, and now HEAD correctly rejects `foo` as being ambiguous (the new ambiguity check uses exactly what's in your example: a value `f :: S` is ambiguous, if `g :: S; g = f` results in an error). -Iavor -------------- next part -------------- An HTML attachment was scrubbed... URL: From yankin013 at gmail.com Sun Jan 13 22:58:13 2013 From: yankin013 at gmail.com (Andrey Yankin) Date: Mon, 14 Jan 2013 00:58:13 +0300 Subject: [Haskell-cafe] Repa: traverse delayed array multiple times Message-ID: Greetings to all! Currently I'm trying to do physical simulations using finite difference method. To accomplish this I need to repeat some manipulations on 2-dimensional grid several thousands or millions times, you know. Is it possible to do using repa? I wrote this rough sketch that shows what I am into. Apparently, program is severely slow. I think reason is: "Every time an element is requested from a delayed array it is calculated anew, which means that delayed arrays are inefficient when the data is needed multiple times" (http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Repa_Tutorial). I started diving into Guiding Parallel Array Fusion with Indexed Typesmentioned there. Is it a right place to find any answer to my question? To summarize, I want to apply my function to Array several thousand times as fast as possible (using multi-threading and GPGPU). It seems I need a lot of memory and throughput. Do I have to call iterate only once at a time or in some kind of batches. What are my possibilities? Thanks in advance! Example program: import System.Environment import Data.Array.Repa as Repa h = 50 w = 50 grid = fromListUnboxed (Z :. h :. w) $ take (h * w) [1, 1..] main = do args <- getArgs let n = read $ head args g <- computeP $ accumulate n grid :: IO (Array U DIM2 Int) putStrLn "Ok" accumulate :: Int -> Array U DIM2 Int -> Array D DIM2 Int accumulate n g = repaIterate step n $ delay g step :: (DIM2 -> Int) -> DIM2 -> Int step f (Z :. i :. j) = center + right + left + top + bottom where left = f' j (i - 1) center = f' j i right = f' j (i + 1) top = f' (j + 1) i bottom = f' (j - 1) i f' j i = if j<0 || i<0 || i>=h || j>=w then 0 else f (Z :. j :. i) repaIterate :: ((DIM2 -> Int) -> DIM2 -> Int) -> Int -> Array D DIM2 Int -> Array D DIM2 Int repaIterate f n = (!! n) . iterate (\array -> traverse array id f) Compilation: ghc -O2 -threaded -rtsopts --make repatest.hs time output: ./repatest 3 +RTS -N2 -H 0,02s user 0,02s system 109% cpu 0,033 total ./repatest 4 +RTS -N2 -H 0,09s user 0,02s system 126% cpu 0,089 total ./repatest 5 +RTS -N2 -H 0,30s user 0,02s system 155% cpu 0,200 total ./repatest 6 +RTS -N2 -H 1,16s user 0,06s system 185% cpu 0,663 total ./repatest 7 +RTS -N2 -H 5,63s user 0,24s system 191% cpu 3,071 total ./repatest 8 +RTS -N2 -H 27,72s user 0,89s system 191% cpu 14,960 total ./repatest 8 +RTS -N1 -H 26,23s user 0,19s system 100% cpu 26,388 total -------------- next part -------------- An HTML attachment was scrubbed... URL: From jake.mcarthur at gmail.com Sun Jan 13 22:59:20 2013 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Sun, 13 Jan 2013 16:59:20 -0500 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: I have a trick that loses a little convenience, but may still be more convenient than data families. {-# LANGUAGE TypeFamilies #-} import Data.Tagged type family F a foo :: Tagged a (F a) foo = Tagged undefined bar :: Tagged a (F a) bar = foo This allows you to use the same newtype wrapper consistently, regardless of what the type instance actually is; one of the inconveniences of data families is the need to use different constructors for different types. On Sun, Jan 13, 2013 at 2:10 PM, Conal Elliott wrote: > I sometimes run into trouble with lack of injectivity for type families. > I'm trying to understand what's at the heart of these difficulties and > whether I can avoid them. Also, whether some of the obstacles could be > overcome with simple improvements to GHC. > > Here's a simple example: > > > {-# LANGUAGE TypeFamilies #-} > > > > type family F a > > > > foo :: F a > > foo = undefined > > > > bar :: F a > > bar = foo > > The error message: > > Couldn't match type `F a' with `F a1' > NB: `F' is a type function, and may not be injective > In the expression: foo > In an equation for `bar': bar = foo > > A terser (but perhaps subtler) example producing the same error: > > > baz :: F a > > baz = baz > > Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. > > Does the difficulty here have to do with trying to *infer* the type and > then compare with the given one? Or is there an issue even with type > *checking* in such cases? > > Other insights welcome, as well as suggested work-arounds. > > I know about (injective) data families but don't want to lose the > convenience of type synonym families. > > Thanks, -- Conal > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.is.fischer at googlemail.com Sun Jan 13 23:00:04 2013 From: daniel.is.fischer at googlemail.com (Daniel Fischer) Date: Sun, 13 Jan 2013 23:00:04 +0100 Subject: [Haskell-cafe] cabal sdist warns about optimization levels In-Reply-To: References: Message-ID: <21563902.q8oXyKFAyq@linux-v7dw.site> On Sunday 13 January 2013, 21:27:44, Petr P wrote: > > I wonder: > > (1) Is there a way how to disable the warning? As the main aim of the > library is speed, I believe -O2 is appropriate here. And since the code is > quite short, I'm quite sure the increased compile time won't be noticeable. > > (2) Why does cabal complain about it at the first place? I found a > reference saying the warning is adequate: > https://github.com/haskell/cabal/issues/808 > but not saying why. Maybe for complex programs -O2 prolongs compile time > too much, but libraries are usually compiled once and used many times, so > using -O2 for them seems reasonable in many cases. Sometimes compiling with -O2 instead of just -O takes significantly longer. Not always is the produced result faster (often, the results are identical). So if the code produced with -O performs equally to that produced with -O2, and the -O2 compilation takes significantly longer, choosing -O2 imposes a cost for no benefit. That's, I think, why the warning is considered adequate. You can specify -O2 on a per-module basis with an {-# OPTIONS_GHC -O2 #-} pragma where it matters, then cabal won't complain. Or, if you're too lazy to check the consequences of -O2 vs. -O for each module (like I usually am, if there are more than a handful), just verify that -O2 does indeed make a significant difference for the speed of the result in some places without increasing compile time unduly, and henceforth ignore the warning if it does. (Re-test every couple of compiler versions.) After some time, you tend to not even notice it anymore ;) Cheers, Daniel From duncan.coutts at googlemail.com Sun Jan 13 23:12:49 2013 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Sun, 13 Jan 2013 22:12:49 +0000 Subject: [Haskell-cafe] cabal sdist warns about optimization levels In-Reply-To: References: Message-ID: On 13 January 2013 20:27, Petr P wrote: > to the cabal file. Now cabal sdist complains with: > > 'ghc-options: -O2' is rarely needed. Check that it is giving a real > benefit and not just imposing longer compile times on your users. > > I wonder: > > (1) Is there a way how to disable the warning? As the main aim of the > library is speed, I believe -O2 is appropriate here. And since the code is > quite short, I'm quite sure the increased compile time won't be noticeable. No, but you can just ignore it. You clearly have checked and you're satisfied it's the right thing to do, so it's fine. You don't need to hit 0 warnings, nobody is going to give you or your package black marks becuase of it! :-) > (2) Why does cabal complain about it at the first place? There's lots of programs where it makes no measurable difference except to make compile times longer. To some extent it's to try to break the habbit of C programmers who always default to -O2. With gcc -O2 will almost always be significantly better than -O, but with ghc that's not the case: -O is the sensible default (almost by definition, to a first approximation, things that are always a win get put into -O, things that are sometimes a win and sometimes not go into -O2). Duncan From wren at freegeek.org Mon Jan 14 00:12:26 2013 From: wren at freegeek.org (wren ng thornton) Date: Sun, 13 Jan 2013 18:12:26 -0500 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: References: Message-ID: <50F33F5A.70906@freegeek.org> On 1/13/13 12:44 PM, Alexander Solla wrote: > Hask is a very rich category, and is suitable for encoding a lot (but not > all) of category theory. As far as I know, the actual boundary is as yet > unknown. I'm not sure that's the most appropriate way to render things. In general, rich categories like CCCs and Toposes are "good places" to do mathematics. This means that we can translate the bulk of mathematics into those settings--- where mathematics means the study of particular structures like rings, groups, vector spaces, etc. These rich categories also provide a good place to do logic/lambda-calculi; from which we get the idea of categorifying Haskell and seeing where that leads us (i.e., asking what Hask looks like). However, standard category theory does not provide a good place for doing category theory. In order to provide a good place for doing category theory, people move on to enriched CT and higher CT[1]. HCT is about coming up with category theoretic definitions for things like co/limits, adjunctions, etc, while moving away from the set theoretic notions inherited from the original conceptions of these terms. In other words, HCT is a good place for doing *meta*mathematics (and metalogic). While there are apparent similarities, there are big differences between doing mathematics and doing metamathematics, and one should be careful not to get them confused. Asking what Haskell looks like when viewed from CT is very different than asking what portions of CT we can implement in Haskell. Haskell is a great place for doing mathematics, but I'm wary of how good it is for doing metamathematics; we conflate too many things which should be kept distinct (e.g., morphisms vs exponentials) and we fail to monitor the boundary between object and meta languages (e.g., a morphism in a category vs a mapping as described in the language of category theory). [1] For more discussion on this point, see n-Lab and n-Cafe: http://ncatlab.org/ http://golem.ph.utexas.edu/category/ -- Live well, ~wren From wren at freegeek.org Mon Jan 14 00:18:47 2013 From: wren at freegeek.org (wren ng thornton) Date: Sun, 13 Jan 2013 18:18:47 -0500 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: References: Message-ID: <50F340D7.1000906@freegeek.org> On 1/13/13 1:53 PM, Alfredo Di Napoli wrote: > Thank you Alexander for the reply. > My wondering is: is Hask a category created by Haskell researchers or was > something already present in literature? Hask was created by Haskellers in discussions on blogs etc. If one is being particular about the details, it's not clear that Haskell types and functions actually do form a category of interest, let alone one with the properties commonly attributed to Hask (e.g., Cartesian closedness). One of the big problems is how laziness/bottoms are treated (e.g., eta-conversion does not hold in general). Thus, I'm not sure it's ever been discussed in the literature; it's more a helpful fiction than a legitimate mathematical object. -- Live well, ~wren From christopher.howard at frigidcode.com Mon Jan 14 00:43:58 2013 From: christopher.howard at frigidcode.com (Christopher Howard) Date: Sun, 13 Jan 2013 14:43:58 -0900 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: References: Message-ID: <50F346BE.8010207@frigidcode.com> On 01/13/2013 03:15 AM, Alfredo Di Napoli wrote: > Morning Cafe, > > I'm planning to do a series of write-ups about Category Theory, to > publish them on the company's blog I'm currently employed. > I'm not a CT expert, but since the best way to learn something is to > explain it to others, I want to take a shot :) > In my mind I will structure the posts following Awodey's book, but I'm > wondering how can I make my posts a little more "real world". > I always read about the "Hask category", which seems to be the > "bootstrap" of the whole logic behind Haskell. Can you please give my > materials/papers/links/blogs to the Hask category and briefly explain me > how it relates to Category Theory and Haskell itself? > > I hope my question is clear enough, in case is not, I'll restate :P > > Cheers, > A. > > You want to give us the link to that blog? If you can keep your explanations reasonably illustrative and easy to understand, you'll get a regular reader out of me. -- frigidcode.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 553 bytes Desc: OpenPGP digital signature URL: From wren at freegeek.org Mon Jan 14 00:53:56 2013 From: wren at freegeek.org (wren ng thornton) Date: Sun, 13 Jan 2013 18:53:56 -0500 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: <50F34914.3080809@freegeek.org> On 1/13/13 3:52 PM, Iavor Diatchki wrote: > On Sun, Jan 13, 2013 at 12:05 PM, Conal Elliott wrote: >>> so there is really no way for GHC to figure out what is the intended value >>> for `a`. >> >> Indeed. Though I wonder: does the type-checker really need to find a >> binding for `a` in this case, i.e., given the equation `(forall a. F a) == >> (forall a'. F a')`? > > Wouldn't that make `F` a constant type family, I don't see why. If we translate this to dependent type notation we get: ((a::*) -> F a) == ((b::*) -> F b) This equality should hold in virtue of alpha-conversion. What F is, is irrelevant; the only thing that matters is that it has kind *->*. In particular, it doesn't matter whether F is arbitrary, injective, parametric, constant, etc. The problem is that the above isn't the equation GHC sees. GHC sees: F a == F b and it can't infer any correlation between a and b, where one of those is universally quantified in the context (the definition of bar) and the other is something we need to fabricate to hand off to the polymorphic value (the call to foo). Of course, in this particular case it *ought* to be fine, by parametricity in the definition of foo. That is, since we merely need to come up with some b, any b, such that F b is the type we need (namely: F a), the a we have will suffice for that. So if we're explicit about type passing, the following is fine: foo :: forall b. F b bar :: forall a. F a bar = /\a -> foo @a The problem is that while the a is sufficient it's not (in general) necessary. And that's the ambiguity GHC is complaining about. GHC can't see that foo is parametric in b, and therefore that a is as good as any other type. -- Live well, ~wren From hamish at firestream.co.uk Mon Jan 14 06:44:02 2013 From: hamish at firestream.co.uk (Hamish Mackenzie) Date: Mon, 14 Jan 2013 18:44:02 +1300 Subject: [Haskell-cafe] Announce: Leksah 0.13.1.2 now 100% Gtk3 (still a bit experimental though) In-Reply-To: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> References: <4CF1D7DF-8BC6-4CEA-A05C-00E397A288E2@gmail.com> Message-ID: <6DBDE15F-3278-492A-A803-8A8C554F13F3@gmail.com> I used the MinGW32 RPMs included in Fedora to get Gtk3 working on Windows. So no more Gtk2 unless you really want it (in which case use -f-gtk3 when building). Issue with "Pane -> HLint" not working in the binary versions should be fixed with these too. OS X ---- Choose the version that matches your installed GHC http://leksah.org/packages/leksah-0.13.1.2-ghc-7.0.3.dmg http://leksah.org/packages/leksah-0.13.1.2-ghc-7.0.4.dmg http://leksah.org/packages/leksah-0.13.1.2-ghc-7.4.1.dmg http://leksah.org/packages/leksah-0.13.1.2-ghc-7.4.2.dmg http://leksah.org/packages/leksah-0.13.1.2-ghc-7.6.1.dmg (probable needs OS X 10.7) Windows ------- Choose the version that matches your installed GHC http://leksah.org/packages/leksah-0.13.1.2-ghc-7.0.3.exe http://leksah.org/packages/leksah-0.13.1.2-ghc-7.0.4.exe http://leksah.org/packages/leksah-0.13.1.2-ghc-7.4.1.exe http://leksah.org/packages/leksah-0.13.1.2-ghc-7.4.2.exe http://leksah.org/packages/leksah-0.13.1.2-ghc-7.6.1.exe Linux ----- Follow the steps in the .travis.yml file... https://github.com/leksah/leksah/blob/master/.travis.yml Should go something like this... https://travis-ci.org/leksah/leksah From dominic at steinitz.org Mon Jan 14 09:08:24 2013 From: dominic at steinitz.org (Dominic Steinitz) Date: Mon, 14 Jan 2013 08:08:24 +0000 (UTC) Subject: [Haskell-cafe] Repa: traverse delayed array multiple times References: Message-ID: Andrey Yankin gmail.com> writes: > > > Greetings to all! > repa?I wrote this rough sketch that shows what I am into. Apparently, program is severely slow. I think reason is:"Every time an element is requested from a delayed array it is calculated > anew, which means that delayed arrays are inefficient when the data is > needed multiple times"(http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Repa_Tutorial).I started diving into Guiding Parallel Array Fusion with Indexed Types mentioned there. Is it a right place to find any answer to my question? > It's certainly possible to do this in repa. As I understand it, that is pretty much what repa is for. I'm not sure about your explanation for the slowdown although it sounds plausible. I amended your code slightly and it runs pretty quickly for me using my 2 processors! updater :: Source r Int => Array r DIM2 Int -> Array D DIM2 Int updater a = traverse a id step updaterM :: Monad m => Int -> Array U DIM2 Int -> m (Array U DIM2 Int) updaterM n = foldr (>=>) return (replicate n (computeP . updater)) and replace g <- computeP $ accumulate n grid :: IO (Array U DIM2 Int) by g <- updaterM n grid BTW I think you can use stencils for what you are doing (I assume it is some sort of relaxation method) as the coefficients are constant. I think this should speed things up further as you won't be testing the boundary conditions on every loop. Dominic. From alfredo.dinapoli at gmail.com Mon Jan 14 09:37:45 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Mon, 14 Jan 2013 08:37:45 +0000 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: <50F346BE.8010207@frigidcode.com> References: <50F346BE.8010207@frigidcode.com> Message-ID: Thanks everyone for the answers. Mine is just an experiment, but if I succeed in keeping it up and to come with something useful, I won't hesitate to poke you :) Btw, in case I succeed, posts will appear here: http://www.alfredodinapoli.com/posts.html and here: http://www.cakesolutions.net/teamblogs/ Bye, Alfredo On 13 January 2013 23:43, Christopher Howard < christopher.howard at frigidcode.com> wrote: > On 01/13/2013 03:15 AM, Alfredo Di Napoli wrote: > > Morning Cafe, > > > > I'm planning to do a series of write-ups about Category Theory, to > > publish them on the company's blog I'm currently employed. > > I'm not a CT expert, but since the best way to learn something is to > > explain it to others, I want to take a shot :) > > In my mind I will structure the posts following Awodey's book, but I'm > > wondering how can I make my posts a little more "real world". > > I always read about the "Hask category", which seems to be the > > "bootstrap" of the whole logic behind Haskell. Can you please give my > > materials/papers/links/blogs to the Hask category and briefly explain me > > how it relates to Category Theory and Haskell itself? > > > > I hope my question is clear enough, in case is not, I'll restate :P > > > > Cheers, > > A. > > > > > > You want to give us the link to that blog? > > If you can keep your explanations reasonably illustrative and easy to > understand, you'll get a regular reader out of me. > > -- > frigidcode.com > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aleks.dimitrov at gmail.com Mon Jan 14 09:42:35 2013 From: aleks.dimitrov at gmail.com (Aleksandar Dimitrov) Date: Mon, 14 Jan 2013 09:42:35 +0100 Subject: [Haskell-cafe] Where is the "convergence point" between Category Theory and Haskell? In-Reply-To: <50F33F5A.70906@freegeek.org> References: <50F33F5A.70906@freegeek.org> Message-ID: <20130114084235.GA4120@minsk> > [1] For more discussion on this point, see n-Lab and n-Cafe: > > http://ncatlab.org/ > http://golem.ph.utexas.edu/category/ Wren, thanks very much for these two links. I've been trying for forever to get a foot into metamathematics and type theory in particular (not having the option of actually taking any university grade classes on the subject,) and I think these two links shall prove very helpful. In particular, I already like at least two posts of the blog very much, and am continuing to scavenge the archives :-). Regards, Aleks -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: From yankin013 at gmail.com Mon Jan 14 11:18:47 2013 From: yankin013 at gmail.com (Andrey Yankin) Date: Mon, 14 Jan 2013 13:18:47 +0300 Subject: [Haskell-cafe] Repa: traverse delayed array multiple times In-Reply-To: References: Message-ID: Hi, Dominic! Thanks for advice. I will definitely use it for now. When I wrote > Do I have to call iterate only once at a time It was obscure and has wrong words. I was trying to ask if it is necessary to run computeP every time I want to modify(traverse) an array? I was contemplating similar solution as you advise, but there is a concern. I want to modify it thousands of times and do not want to allocate and garbage more memory than needed. Here is the implementation I dream of: There must be function traverseNTimes that takes also an arbitrary number (the number of times to repeat traversal). Then it allocates but two new blocks and uses them to iterate the process as needed. No superfluous memory consumption. Is it unusual case? Is it worth thinking about? Do it give any performance gain? Actually I started with repa only yesterday, so I was thinking of delayed or cursored arrays which are capable of magic. Now I am beginning to see that it is not the case, though I don't know it for sure yet... ) > BTW I think you can use stencils for what you are doing (I assume it is some > sort of relaxation method) as the coefficients are constant. I think this > should speed things up further as you won't be testing the boundary conditions > on every loop. Sadly, there are much more sophisticated formulae and more than one boundary conditions on each side (and these conditions are moving)... 2013/1/14 Dominic Steinitz > Andrey Yankin gmail.com> writes: > > > > > > > Greetings to all! > > > repa?I wrote this rough sketch that shows what I am into. Apparently, > program > is severely slow. I think reason is:"Every time an element is requested > from a > delayed array it is calculated > > anew, which means that delayed arrays are inefficient when the data is > > needed multiple > times"( > http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Repa_Tutorial).I > started diving into Guiding Parallel Array Fusion with Indexed Types > mentioned > there. Is it a right place to find any answer to my question? > > > > It's certainly possible to do this in repa. As I understand it, that is > pretty > much what repa is for. I'm not sure about your explanation for the slowdown > although it sounds plausible. > > I amended your code slightly and it runs pretty quickly for me using my 2 > processors! > > updater :: Source r Int => Array r DIM2 Int -> Array D DIM2 Int > updater a = traverse a id step > > updaterM :: Monad m => Int -> Array U DIM2 Int -> m (Array U DIM2 Int) > updaterM n = foldr (>=>) return (replicate n (computeP . updater)) > > and replace > > g <- computeP $ accumulate n grid :: IO (Array U DIM2 Int) > > by > > g <- updaterM n grid > > BTW I think you can use stencils for what you are doing (I assume it is > some > sort of relaxation method) as the coefficients are constant. I think this > should speed things up further as you won't be testing the boundary > conditions > on every loop. > > Dominic. > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.mvd at gmail.com Mon Jan 14 11:59:40 2013 From: petr.mvd at gmail.com (Petr P) Date: Mon, 14 Jan 2013 11:59:40 +0100 Subject: [Haskell-cafe] How to properly optimize MArray functions for speed? Message-ID: Dear Haskellers, I'm working on a sorting library for MArrays. Speed is important, so I want to optimize it as much as possible. Currently, I simply INLINE the sorting function. This speeds up the code more than 10 times. However this can easily explode code size if the function is used in several places. The only other alternative seems to SPECIALIZE the function for all instances of MArray. This also enlarges the resulting code, but only by a constant factor, not depending on how many times the function is used. The question is, is it possible that new instanes of MArray appear? Or is MArray so special and bound to GHC's internals so that I can be sure that no new instances can be defined by some other module? Thanks for help, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Mon Jan 14 12:36:22 2013 From: tab at snarc.org (Vincent Hanquez) Date: Mon, 14 Jan 2013 12:36:22 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <20130112141244.0efa703b@tritium.streitmacht.eu> References: <20130111225545.GA5972@snarc.org> <20130112141244.0efa703b@tritium.streitmacht.eu> Message-ID: <20130114113621.GA14529@snarc.org> On Sat, Jan 12, 2013 at 02:12:44PM +0100, Ertugrul S?ylemez wrote: > > I've spend some good chunk of time adding KATs and tests, > > documentation, and making sure the performance was ahead of other > > haskell implementations. > > I suggest looking at Daniel Fischer's arithmoi [1] library, which > implements very fast Integer operations and should provide most > functionality needed. However, beware of timing attacks. Very cool library and very similar to what crypto-numbers provides albeit less sophisticated. I wished I knew about it before implementing the same(ish) functions. One caveat of the library is the dependence on integer-gmp. > Also for the particular purpose of generating safe primes I have written > a blazingly fast implementation that uses intelligent sieving and finds > even large primes (>= 4096 bits) within seconds or minutes. It's on > hpaste [2]. I might turn this into a library at some point. Seconds or minutes ? that's very different :-) But in any case, it would be a nice addition i think. My safe prime generation function is probably the most naive possible. -- Vincent From simonpj at microsoft.com Mon Jan 14 12:39:34 2013 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Mon, 14 Jan 2013 11:39:34 +0000 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: <59543203684B2244980D7E4057D5FBC1476A51B7@DB3EX14MBXC308.europe.corp.microsoft.com> | > > {-# LANGUAGE TypeFamilies #-} | > > | > > type family F a | > > | > > foo :: F a | > > foo = undefined | > > | > > bar :: F a | > > bar = foo There is a real difficulty here with type-checking 'bar'. (And that difficulty is why 'foo' is also rejected.) Namely, when typechecking 'bar', we must instantiate foo with an unknown type, say alpha. So now we must find a type 'alpha' such that F a ~ F alpha Certainly alpha=1 is one solution, but there might be others. For example, suppose type instance F [b] = F b Then alpha=[a] would also be a solution. In this particular case any solution will do, but suppose there was an addition constraint (C alpha) arising from the right hand side, where C is a class. Then if we had instance C [b] where ... then the second solution (alpha=[a]) would work, but not the first. This can get arbitrarily complicated, and GHC's type inference does not "search" various solutions; it follows one path. The solution is to provide a way to fix alpha. For example, foo :: a -> F a is fine. Simon | -----Original Message----- | From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell- | users-bounces at haskell.org] On Behalf Of Richard Eisenberg | Sent: 14 January 2013 03:47 | To: Conal Elliott | Cc: glasgow-haskell-users at haskell.org; Haskell Cafe | Subject: Re: Advice on type families and non-injectivity? | | Hi Conal, | | I agree that your initial example is a little puzzling, and I'm glad | that the new ambiguity checker prevents both definitions, not just one. | | However, your initial question seems broader than just this example. I | have run into this problem (wanting injective type functions) several | times myself, and have been successful at finding workarounds. But, I | can't think of any unifying principle or solid advice. If you can post | more information about your problem, perhaps I or others can contribute. | | For what it's worth, the desire for injective type functions has been | entered as ticket #6018 in the GHC Trac, but I see you're already on the | cc: list. I believe Simon PJ has given serious thought to implementing | this feature and may have even put in some very basic code toward this | end. | | Richard | | On Jan 13, 2013, at 2:10 PM, Conal Elliott wrote: | | > I sometimes run into trouble with lack of injectivity for type | families. I'm trying to understand what's at the heart of these | difficulties and whether I can avoid them. Also, whether some of the | obstacles could be overcome with simple improvements to GHC. | > | > Here's a simple example: | > | > > {-# LANGUAGE TypeFamilies #-} | > > | > > type family F a | > > | > > foo :: F a | > > foo = undefined | > > | > > bar :: F a | > > bar = foo | > | > The error message: | > | > Couldn't match type `F a' with `F a1' | > NB: `F' is a type function, and may not be injective | > In the expression: foo | > In an equation for `bar': bar = foo | > | > A terser (but perhaps subtler) example producing the same error: | > | > > baz :: F a | > > baz = baz | > | > Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. | > | > Does the difficulty here have to do with trying to *infer* the type | and then compare with the given one? Or is there an issue even with type | *checking* in such cases? | > | > Other insights welcome, as well as suggested work-arounds. | > | > I know about (injective) data families but don't want to lose the | convenience of type synonym families. | > | > Thanks, -- Conal | > | > _______________________________________________ | > Glasgow-haskell-users mailing list | > Glasgow-haskell-users at haskell.org | > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users | | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users at haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users From daniel.is.fischer at googlemail.com Mon Jan 14 13:49:44 2013 From: daniel.is.fischer at googlemail.com (Daniel Fischer) Date: Mon, 14 Jan 2013 13:49:44 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <20130114113621.GA14529@snarc.org> References: <20130111225545.GA5972@snarc.org> <20130112141244.0efa703b@tritium.streitmacht.eu> <20130114113621.GA14529@snarc.org> Message-ID: <8940340.0CpOZgbCMF@linux-v7dw.site> On Monday 14 January 2013, 12:36:22, Vincent Hanquez wrote: > On Sat, Jan 12, 2013 at 02:12:44PM +0100, Ertugrul S?ylemez wrote: > > > I've spend some good chunk of time adding KATs and tests, > > > documentation, and making sure the performance was ahead of other > > > haskell implementations. > > > > I suggest looking at Daniel Fischer's arithmoi [1] library, which > > implements very fast Integer operations and should provide most > > functionality needed. However, beware of timing attacks. > > Very cool library and very similar to what crypto-numbers provides albeit > less sophisticated. I see you're doing a lot of x `shiftR` 1 with Integers. That's pretty bad for performance (at least for integer-gmp, might be not for integer-simple or implementations other than GHC [last I looked, JHC didn't have arbitrary precision Integers and used 64-bit ones, so it'd be fast there]). > I wished I knew about it before implementing the > same(ish) functions. > > One caveat of the library is the dependence on integer-gmp. It was meant to be fast, so exploiting the internal representation of Integers in some places was the way to go. I intend to make it portable, but so far am too good at procrastinating. (Making it portable without losing too much performance is nontrivial in some places, that contributes.) Getting a request would make it happen sooner. > > > Also for the particular purpose of generating safe primes I have written > > a blazingly fast implementation that uses intelligent sieving and finds > > even large primes (>= 4096 bits) within seconds or minutes. It's on > > hpaste [2]. I might turn this into a library at some point. > > Seconds or minutes ? that's very different :-) > But in any case, it would be a nice addition i think. > > My safe prime generation function is probably the most naive possible. From es at ertes.de Mon Jan 14 15:33:59 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Mon, 14 Jan 2013 15:33:59 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <20130114113621.GA14529@snarc.org> References: <20130111225545.GA5972@snarc.org> <20130112141244.0efa703b@tritium.streitmacht.eu> <20130114113621.GA14529@snarc.org> Message-ID: <20130114153359.497064f4@tritium.streitmacht.eu> Vincent Hanquez wrote: > > Also for the particular purpose of generating safe primes I have > > written a blazingly fast implementation that uses intelligent > > sieving and finds even large primes (>= 4096 bits) within seconds or > > minutes. It's on hpaste [2]. I might turn this into a library at > > some point. > > Seconds or minutes ? that's very different :-) > But in any case, it would be a nice addition i think. > > My safe prime generation function is probably the most naive possible. Ok, let me give you an actual number. I want, for an integer b > 3, the smallest integer d such that 2^b - d is a safe prime. Let's find all safe primes for b <- [100..399]: % time ./primes {100..399} 2^100 - 12389 2^101 - 9009 ... 2^398 - 128981 2^399 - 191301 ** timings: real 32.355 user 32.105 krnl 0.113 cpu% 99% But of course I have four cores, and as a Haskell programmer I feel that I should use them: % time ./primes {100..399} +RTS -N 2^100 - 12389 2^101 - 9009 ... 2^398 - 128981 2^399 - 191301 ** timings: real 11.047 user 38.194 krnl 3.833 cpu% 380% At some point I'm going to parallelize even individual prime searches. =) Greets, Ertugrul -- Key-ID: E5DD8D11 "Ertugrul Soeylemez " FPrint: BD28 3E3F BE63 BADD 4157 9134 D56A 37FA E5DD 8D11 Keysrv: hkp://subkeys.pgp.net/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From waldmann at imn.htwk-leipzig.de Mon Jan 14 20:10:21 2013 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Mon, 14 Jan 2013 19:10:21 +0000 (UTC) Subject: [Haskell-cafe] using/building ghc head? Message-ID: Hi. I wanted to do some experiments with GHC Head but * I cannot use the snapshot bindist: ./configure --prefix=/opt checking for path to top of build tree... ./configure: line 2138: utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist: No such file or directory * I cannot compile snapshot from source (with ghc-7.6.1) utils/haddock/src/Haddock/Convert.hs:201:42: Not in scope: data constructor `HsBang' this is for ghc-7.7.20121213 (date Dec 21), which is the latest snapshot according to http://www.haskell.org/ghc/dist/current/dist/ what am I missing? - J.W. From mad.one at gmail.com Mon Jan 14 20:53:29 2013 From: mad.one at gmail.com (Austin Seipp) Date: Mon, 14 Jan 2013 13:53:29 -0600 Subject: [Haskell-cafe] using/building ghc head? In-Reply-To: References: Message-ID: Frankly I wouldn't be surprised if snapshots are dodgy, to be quite honest. As far as I'm aware, most people just build GHC HEAD themselves, from the git repository. And a snapshot build does not necessarily guarantee anything works in any case (there could be a million things wrong in the repository causing failures in a binary distribution you might not see in a developer build.) So, if you want to build GHC, you can. This can be done in well under an hour (or even 30 minutes) with a moderately powerful machine and paying attention to build settings. Check out the first section, 'Building GHC', here http://hackage.haskell.org/trac/ghc/wiki/Building And this page which has some good tricks for speeding up the build, like using 'mk/build.mk': http://hackage.haskell.org/trac/ghc/wiki/Building/Hacking On Mon, Jan 14, 2013 at 1:10 PM, Johannes Waldmann wrote: > Hi. I wanted to do some experiments with GHC Head but > > * I cannot use the snapshot bindist: > > ./configure --prefix=/opt > checking for path to top of build tree... ./configure: line 2138: > utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist: No such file or directory > > * I cannot compile snapshot from source (with ghc-7.6.1) > > utils/haddock/src/Haddock/Convert.hs:201:42: > Not in scope: data constructor `HsBang' > > this is for ghc-7.7.20121213 (date Dec 21), > which is the latest snapshot according to > http://www.haskell.org/ghc/dist/current/dist/ > > what am I missing? - J.W. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Regards, Austin From conal at conal.net Mon Jan 14 21:51:35 2013 From: conal at conal.net (Conal Elliott) Date: Mon, 14 Jan 2013 12:51:35 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: <59543203684B2244980D7E4057D5FBC1476A51B7@DB3EX14MBXC308.europe.corp.microsoft.com> References: <59543203684B2244980D7E4057D5FBC1476A51B7@DB3EX14MBXC308.europe.corp.microsoft.com> Message-ID: > > There is a real difficulty here with type-checking 'bar'. (And that > difficulty is why 'foo' is also rejected.) Oh! Is the definition of 'foo' rejected in recent versions of GHC? My 7.4.1 installation doesn't complain. -- Conal On Mon, Jan 14, 2013 at 3:39 AM, Simon Peyton-Jones wrote: > | > > {-# LANGUAGE TypeFamilies #-} > | > > > | > > type family F a > | > > > | > > foo :: F a > | > > foo = undefined > | > > > | > > bar :: F a > | > > bar = foo > > There is a real difficulty here with type-checking 'bar'. (And that > difficulty is why 'foo' is also rejected.) > > Namely, when typechecking 'bar', we must instantiate foo with an unknown > type, say alpha. So now we must find a type 'alpha' such that > F a ~ F alpha > Certainly alpha=1 is one solution, but there might be others. For > example, suppose > type instance F [b] = F b > Then alpha=[a] would also be a solution. > > In this particular case any solution will do, but suppose there was an > addition constraint (C alpha) arising from the right hand side, where C is > a class. Then if we had > instance C [b] where ... > then the second solution (alpha=[a]) would work, but not the first. This > can get arbitrarily complicated, and GHC's type inference does not "search" > various solutions; it follows one path. > > The solution is to provide a way to fix alpha. For example, > foo :: a -> F a > is fine. > > Simon > > > | -----Original Message----- > | From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell- > | users-bounces at haskell.org] On Behalf Of Richard Eisenberg > | Sent: 14 January 2013 03:47 > | To: Conal Elliott > | Cc: glasgow-haskell-users at haskell.org; Haskell Cafe > | Subject: Re: Advice on type families and non-injectivity? > | > | Hi Conal, > | > | I agree that your initial example is a little puzzling, and I'm glad > | that the new ambiguity checker prevents both definitions, not just one. > | > | However, your initial question seems broader than just this example. I > | have run into this problem (wanting injective type functions) several > | times myself, and have been successful at finding workarounds. But, I > | can't think of any unifying principle or solid advice. If you can post > | more information about your problem, perhaps I or others can contribute. > | > | For what it's worth, the desire for injective type functions has been > | entered as ticket #6018 in the GHC Trac, but I see you're already on the > | cc: list. I believe Simon PJ has given serious thought to implementing > | this feature and may have even put in some very basic code toward this > | end. > | > | Richard > | > | On Jan 13, 2013, at 2:10 PM, Conal Elliott wrote: > | > | > I sometimes run into trouble with lack of injectivity for type > | families. I'm trying to understand what's at the heart of these > | difficulties and whether I can avoid them. Also, whether some of the > | obstacles could be overcome with simple improvements to GHC. > | > > | > Here's a simple example: > | > > | > > {-# LANGUAGE TypeFamilies #-} > | > > > | > > type family F a > | > > > | > > foo :: F a > | > > foo = undefined > | > > > | > > bar :: F a > | > > bar = foo > | > > | > The error message: > | > > | > Couldn't match type `F a' with `F a1' > | > NB: `F' is a type function, and may not be injective > | > In the expression: foo > | > In an equation for `bar': bar = foo > | > > | > A terser (but perhaps subtler) example producing the same error: > | > > | > > baz :: F a > | > > baz = baz > | > > | > Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. > | > > | > Does the difficulty here have to do with trying to *infer* the type > | and then compare with the given one? Or is there an issue even with type > | *checking* in such cases? > | > > | > Other insights welcome, as well as suggested work-arounds. > | > > | > I know about (injective) data families but don't want to lose the > | convenience of type synonym families. > | > > | > Thanks, -- Conal > | > > | > _______________________________________________ > | > Glasgow-haskell-users mailing list > | > Glasgow-haskell-users at haskell.org > | > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > | > | > | _______________________________________________ > | Glasgow-haskell-users mailing list > | Glasgow-haskell-users at haskell.org > | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From conal at conal.net Mon Jan 14 21:53:05 2013 From: conal at conal.net (Conal Elliott) Date: Mon, 14 Jan 2013 12:53:05 -0800 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: Message-ID: Thanks, Jake! This suggestion helped a lot. -- Conal On Sun, Jan 13, 2013 at 1:59 PM, Jake McArthur wrote: > I have a trick that loses a little convenience, but may still be more > convenient than data families. > > {-# LANGUAGE TypeFamilies #-} > > import Data.Tagged > > type family F a > > foo :: Tagged a (F a) > foo = Tagged undefined > > bar :: Tagged a (F a) > bar = foo > > > This allows you to use the same newtype wrapper consistently, regardless > of what the type instance actually is; one of the inconveniences of data > families is the need to use different constructors for different types. > > > On Sun, Jan 13, 2013 at 2:10 PM, Conal Elliott wrote: > >> I sometimes run into trouble with lack of injectivity for type families. >> I'm trying to understand what's at the heart of these difficulties and >> whether I can avoid them. Also, whether some of the obstacles could be >> overcome with simple improvements to GHC. >> >> Here's a simple example: >> >> > {-# LANGUAGE TypeFamilies #-} >> > >> > type family F a >> > >> > foo :: F a >> > foo = undefined >> > >> > bar :: F a >> > bar = foo >> >> The error message: >> >> Couldn't match type `F a' with `F a1' >> NB: `F' is a type function, and may not be injective >> In the expression: foo >> In an equation for `bar': bar = foo >> >> A terser (but perhaps subtler) example producing the same error: >> >> > baz :: F a >> > baz = baz >> >> Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. >> >> Does the difficulty here have to do with trying to *infer* the type and >> then compare with the given one? Or is there an issue even with type >> *checking* in such cases? >> >> Other insights welcome, as well as suggested work-arounds. >> >> I know about (injective) data families but don't want to lose the >> convenience of type synonym families. >> >> Thanks, -- Conal >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simonpj at microsoft.com Mon Jan 14 22:19:46 2013 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Mon, 14 Jan 2013 21:19:46 +0000 Subject: [Haskell-cafe] Advice on type families and non-injectivity? In-Reply-To: References: <59543203684B2244980D7E4057D5FBC1476A51B7@DB3EX14MBXC308.europe.corp.microsoft.com> Message-ID: <59543203684B2244980D7E4057D5FBC1476A6049@DB3EX14MBXC308.europe.corp.microsoft.com> Oh! Is the definition of 'foo' rejected in recent versions of GHC? My 7.4.1 installation doesn't complain. -- Conal Yes, it is rejected. Simon From: conal.elliott at gmail.com [mailto:conal.elliott at gmail.com] On Behalf Of Conal Elliott Sent: 14 January 2013 20:52 To: Simon Peyton-Jones Cc: Richard Eisenberg; glasgow-haskell-users at haskell.org; Haskell Cafe Subject: Re: Advice on type families and non-injectivity? There is a real difficulty here with type-checking 'bar'. (And that difficulty is why 'foo' is also rejected.) Oh! Is the definition of 'foo' rejected in recent versions of GHC? My 7.4.1 installation doesn't complain. -- Conal On Mon, Jan 14, 2013 at 3:39 AM, Simon Peyton-Jones > wrote: | > > {-# LANGUAGE TypeFamilies #-} | > > | > > type family F a | > > | > > foo :: F a | > > foo = undefined | > > | > > bar :: F a | > > bar = foo There is a real difficulty here with type-checking 'bar'. (And that difficulty is why 'foo' is also rejected.) Namely, when typechecking 'bar', we must instantiate foo with an unknown type, say alpha. So now we must find a type 'alpha' such that F a ~ F alpha Certainly alpha=1 is one solution, but there might be others. For example, suppose type instance F [b] = F b Then alpha=[a] would also be a solution. In this particular case any solution will do, but suppose there was an addition constraint (C alpha) arising from the right hand side, where C is a class. Then if we had instance C [b] where ... then the second solution (alpha=[a]) would work, but not the first. This can get arbitrarily complicated, and GHC's type inference does not "search" various solutions; it follows one path. The solution is to provide a way to fix alpha. For example, foo :: a -> F a is fine. Simon | -----Original Message----- | From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell- | users-bounces at haskell.org] On Behalf Of Richard Eisenberg | Sent: 14 January 2013 03:47 | To: Conal Elliott | Cc: glasgow-haskell-users at haskell.org; Haskell Cafe | Subject: Re: Advice on type families and non-injectivity? | | Hi Conal, | | I agree that your initial example is a little puzzling, and I'm glad | that the new ambiguity checker prevents both definitions, not just one. | | However, your initial question seems broader than just this example. I | have run into this problem (wanting injective type functions) several | times myself, and have been successful at finding workarounds. But, I | can't think of any unifying principle or solid advice. If you can post | more information about your problem, perhaps I or others can contribute. | | For what it's worth, the desire for injective type functions has been | entered as ticket #6018 in the GHC Trac, but I see you're already on the | cc: list. I believe Simon PJ has given serious thought to implementing | this feature and may have even put in some very basic code toward this | end. | | Richard | | On Jan 13, 2013, at 2:10 PM, Conal Elliott > wrote: | | > I sometimes run into trouble with lack of injectivity for type | families. I'm trying to understand what's at the heart of these | difficulties and whether I can avoid them. Also, whether some of the | obstacles could be overcome with simple improvements to GHC. | > | > Here's a simple example: | > | > > {-# LANGUAGE TypeFamilies #-} | > > | > > type family F a | > > | > > foo :: F a | > > foo = undefined | > > | > > bar :: F a | > > bar = foo | > | > The error message: | > | > Couldn't match type `F a' with `F a1' | > NB: `F' is a type function, and may not be injective | > In the expression: foo | > In an equation for `bar': bar = foo | > | > A terser (but perhaps subtler) example producing the same error: | > | > > baz :: F a | > > baz = baz | > | > Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. | > | > Does the difficulty here have to do with trying to *infer* the type | and then compare with the given one? Or is there an issue even with type | *checking* in such cases? | > | > Other insights welcome, as well as suggested work-arounds. | > | > I know about (injective) data families but don't want to lose the | convenience of type synonym families. | > | > Thanks, -- Conal | > | > _______________________________________________ | > Glasgow-haskell-users mailing list | > Glasgow-haskell-users at haskell.org | > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users | | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users at haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnaud.oqube at gmail.com Tue Jan 15 00:40:04 2013 From: arnaud.oqube at gmail.com (Arnaud Bailly) Date: Tue, 15 Jan 2013 00:40:04 +0100 Subject: [Haskell-cafe] Cannot read a large integer on linux Message-ID: Hello, I am encountering a strange issue while trying to read a string into an integer. On windows 7 64bit, I have: > read "18780189038289e49" :: Integer =187801890382890000000000000000000000000000000000000000000000000 On linux (64bit, libgmp.so.3.5.2) I have: > read "18780189038289e49" :: Integer *** Exception: Prelude.read: no parse That's weird and I really have no clue what's going on. I use ghci 7.4.2 on linux and 7.4.1 on windows. What am I doing wrong ? Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From artyom.kazak at gmail.com Tue Jan 15 01:02:54 2013 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Tue, 15 Jan 2013 03:02:54 +0300 Subject: [Haskell-cafe] Cannot read a large integer on linux In-Reply-To: References: Message-ID: Right, it was fixed in GHC 7.4.2. hackage.haskell.org/trac/ghc/ticket/5688 The trouble with old behaviour was that it had been creating a security breach (anybody could pass "1e100000000000" where an Integer was expected and cause a segmentation fault). 15.01.2013 2:41 ???????????? "Arnaud Bailly" ???????: > Hello, > I am encountering a strange issue while trying to read a string into an > integer. > > On windows 7 64bit, I have: > > > read "18780189038289e49" :: Integer > =187801890382890000000000000000000000000000000000000000000000000 > > On linux (64bit, libgmp.so.3.5.2) I have: > > > read "18780189038289e49" :: Integer > *** Exception: Prelude.read: no parse > > That's weird and I really have no clue what's going on. I use ghci 7.4.2 > on linux and 7.4.1 on windows. > > What am I doing wrong ? > > Arnaud > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From waldmann at imn.htwk-leipzig.de Tue Jan 15 01:12:06 2013 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Tue, 15 Jan 2013 00:12:06 +0000 (UTC) Subject: [Haskell-cafe] Cannot read a large integer on linux References: Message-ID: > read "18780189038289e49" :: Integer this might be related: http://hackage.haskell.org/trac/ghc/ticket/5688 From magicloud.magiclouds at gmail.com Tue Jan 15 06:06:04 2013 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue, 15 Jan 2013 13:06:04 +0800 Subject: [Haskell-cafe] How to disable document in .cabal file? Message-ID: Hi, I have enabled document in .cabal/config, so I could get document every time I installed libraries or so. But when I compile my own applications, it also takes time on generating non-exist documents. How to disable it just for this project? -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Tue Jan 15 09:49:49 2013 From: tab at snarc.org (Vincent Hanquez) Date: Tue, 15 Jan 2013 09:49:49 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <8940340.0CpOZgbCMF@linux-v7dw.site> References: <20130111225545.GA5972@snarc.org> <20130112141244.0efa703b@tritium.streitmacht.eu> <20130114113621.GA14529@snarc.org> <8940340.0CpOZgbCMF@linux-v7dw.site> Message-ID: <20130115084949.GA30518@snarc.org> On Mon, Jan 14, 2013 at 01:49:44PM +0100, Daniel Fischer wrote: > On Monday 14 January 2013, 12:36:22, Vincent Hanquez wrote: > > On Sat, Jan 12, 2013 at 02:12:44PM +0100, Ertugrul S?ylemez wrote: > > > > I've spend some good chunk of time adding KATs and tests, > > > > documentation, and making sure the performance was ahead of other > > > > haskell implementations. > > > > > > I suggest looking at Daniel Fischer's arithmoi [1] library, which > > > implements very fast Integer operations and should provide most > > > functionality needed. However, beware of timing attacks. > > > > Very cool library and very similar to what crypto-numbers provides albeit > > less sophisticated. > > I see you're doing a lot of x `shiftR` 1 with Integers. That's pretty bad for > performance (at least for integer-gmp, might be not for integer-simple or > implementations other than GHC [last I looked, JHC didn't have arbitrary > precision Integers and used 64-bit ones, so it'd be fast there]). Yes, the performance are terrible in term of integers. As the library is specific to public key algorithm, i just can't reasonable work on 64 bits integer :-), and multiprecision integers is the only way to go. I'm on-and-off working on some mutable mpi library to be able to define pure function that do the necessary stuff (i.e. expmod, mulmod, etc..) I'm hoping this could be reasonably competitive with a C mpi library, but time will tell. -- Vincent From agocorona at gmail.com Tue Jan 15 10:46:00 2013 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue, 15 Jan 2013 10:46:00 +0100 Subject: [Haskell-cafe] hackage builds stopped? Message-ID: What is the schedule of the hackage builds?. My package has been uploaded since three days ago, and it has not been compiled yet... -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From agocorona at gmail.com Tue Jan 15 12:17:28 2013 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue, 15 Jan 2013 12:17:28 +0100 Subject: [Haskell-cafe] hackage builds stopped? In-Reply-To: References: Message-ID: It seems that other packages have been build. Mine is http://hackage.haskell.org/package/MFlow-0.2.0.3 the previous uploads that I sent the past week have been compiled (error logs produced). But this last version don't. Are there some processing policy that I may don?t know? 2013/1/15 Alberto G. Corona > What is the schedule of the hackage builds?. > > My package has been uploaded since three days ago, and it has not been > compiled yet... > > -- > Alberto. > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Tue Jan 15 15:27:29 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Tue, 15 Jan 2013 15:27:29 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. References: <20130111225545.GA5972@snarc.org> <20130112141244.0efa703b@tritium.streitmacht.eu> <20130114113621.GA14529@snarc.org> <8940340.0CpOZgbCMF@linux-v7dw.site> <20130115084949.GA30518@snarc.org> Message-ID: <20130115152729.6eb2629e@tritium.streitmacht.eu> Vincent Hanquez wrote: > Yes, the performance are terrible in term of integers. As the library > is specific to public key algorithm, i just can't reasonable work on > 64 bits integer :-), and multiprecision integers is the only way to > go. > > I'm on-and-off working on some mutable mpi library to be able to > define pure function that do the necessary stuff (i.e. expmod, mulmod, > etc..) > > I'm hoping this could be reasonably competitive with a C mpi library, > but time will tell. It's a waste of time. In my benchmarks Haskell Integer outperformed equivalent (sane) C implementations using GMP's mpz_* interface. You would be reinventing GMP's mpn_* interface and a custom memory manager to be able to match the speed of Integer. The things that were slower than equivalent C code were not related to Integer, but mostly to data structures like Set in my case, which was the motivation for me to write the 'quickset' library. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From ramsdell0 at gmail.com Tue Jan 15 21:00:27 2013 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Tue, 15 Jan 2013 15:00:27 -0500 Subject: [Haskell-cafe] Makefile for a Haskell Project In-Reply-To: <50E72EC8.9020608@vex.net> References: <20121228022037.82685tp0bc5m797p@stuttard.org> <50E72EC8.9020608@vex.net> Message-ID: This is the Makefile used by CPSA. It requires GNU make. John # Haskell/Cabal Makefile # Requires GNU Make # The all target creates a default configuration if need be. PACKAGE := $(wildcard *.cabal) CONFIG = dist/setup-config SETUP = runhaskell Setup.hs all: $(CONFIG) $(SETUP) build Makefile: @echo make $@ $(PACKAGE): @echo make $@ $(CONFIG): $(PACKAGE) $(SETUP) configure $(CABALFLAGS) --ghc --user --prefix="${HOME}" %: force $(SETUP) $@ .PHONY: all force From trebla at vex.net Tue Jan 15 23:45:39 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Tue, 15 Jan 2013 17:45:39 -0500 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: Message-ID: <50F5DC13.9050407@vex.net> On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: > I have enabled document in .cabal/config, so I could get document > every time I installed libraries or so. > But when I compile my own applications, it also takes time on > generating non-exist documents. How to disable it just for this project? If "cabal install": add --disable-documentation. See also "cabal install --help". If "cabal configure" and "cabal build" etc: nothing to do, just omit "cabal haddock". From magicloud.magiclouds at gmail.com Wed Jan 16 03:10:02 2013 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed, 16 Jan 2013 10:10:02 +0800 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: <50F5DC13.9050407@vex.net> References: <50F5DC13.9050407@vex.net> Message-ID: So the only way is to use param every time I build this certain project? Really hoping I could disable it in project.cabal .... On Wed, Jan 16, 2013 at 6:45 AM, Albert Y. C. Lai wrote: > On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: > >> I have enabled document in .cabal/config, so I could get document >> every time I installed libraries or so. >> But when I compile my own applications, it also takes time on >> generating non-exist documents. How to disable it just for this project? >> > > If "cabal install": add --disable-documentation. > See also "cabal install --help". > > If "cabal configure" and "cabal build" etc: nothing to do, just omit > "cabal haddock". > > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Wed Jan 16 03:16:18 2013 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed, 16 Jan 2013 13:16:18 +1100 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: <50F5DC13.9050407@vex.net> Message-ID: On 16 January 2013 13:10, Magicloud Magiclouds wrote: > So the only way is to use param every time I build this certain project? > Really hoping I could disable it in project.cabal .... Well, it's an option for the cabal-install tool, not for the Cabal build system. Note that you don't need to use this parameter every time you build your project, only every time you configure it (so if you don't change the .cabal file much and just tend to build it as you hack on it you don't need the extra params). > > > On Wed, Jan 16, 2013 at 6:45 AM, Albert Y. C. Lai wrote: >> >> On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: >>> >>> I have enabled document in .cabal/config, so I could get document >>> every time I installed libraries or so. >>> But when I compile my own applications, it also takes time on >>> generating non-exist documents. How to disable it just for this project? >> >> >> If "cabal install": add --disable-documentation. >> See also "cabal install --help". >> >> If "cabal configure" and "cabal build" etc: nothing to do, just omit >> "cabal haddock". >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From magicloud.magiclouds at gmail.com Wed Jan 16 03:26:16 2013 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed, 16 Jan 2013 10:26:16 +0800 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: <50F5DC13.9050407@vex.net> Message-ID: The problem is, I enabled it in ~/.cabal/config file. So by default, when I install, it build the document. Sorry I used "build" term, by which I meant install.... On Wed, Jan 16, 2013 at 10:16 AM, Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > On 16 January 2013 13:10, Magicloud Magiclouds > wrote: > > So the only way is to use param every time I build this certain project? > > Really hoping I could disable it in project.cabal .... > > Well, it's an option for the cabal-install tool, not for the Cabal build > system. > > Note that you don't need to use this parameter every time you build > your project, only every time you configure it (so if you don't change > the .cabal file much and just tend to build it as you hack on it you > don't need the extra params). > > > > > > > On Wed, Jan 16, 2013 at 6:45 AM, Albert Y. C. Lai > wrote: > >> > >> On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: > >>> > >>> I have enabled document in .cabal/config, so I could get document > >>> every time I installed libraries or so. > >>> But when I compile my own applications, it also takes time on > >>> generating non-exist documents. How to disable it just for this > project? > >> > >> > >> If "cabal install": add --disable-documentation. > >> See also "cabal install --help". > >> > >> If "cabal configure" and "cabal build" etc: nothing to do, just omit > >> "cabal haddock". > >> > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe at haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > > > -- > > ??????? > > ??????? > > > > And for G+, please use magiclouds#gmail.com. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Wed Jan 16 03:29:11 2013 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed, 16 Jan 2013 13:29:11 +1100 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: <50F5DC13.9050407@vex.net> Message-ID: On 16 January 2013 13:26, Magicloud Magiclouds wrote: > The problem is, I enabled it in ~/.cabal/config file. So by default, when I > install, it build the document. > Sorry I used "build" term, by which I meant install.... How often do you install that this is a problem? If you install more without documentation, disable it in your ~/.cabal/config file, and use --enable-documentation when you actually want it. > > > On Wed, Jan 16, 2013 at 10:16 AM, Ivan Lazar Miljenovic > wrote: >> >> On 16 January 2013 13:10, Magicloud Magiclouds >> wrote: >> > So the only way is to use param every time I build this certain project? >> > Really hoping I could disable it in project.cabal .... >> >> Well, it's an option for the cabal-install tool, not for the Cabal build >> system. >> >> Note that you don't need to use this parameter every time you build >> your project, only every time you configure it (so if you don't change >> the .cabal file much and just tend to build it as you hack on it you >> don't need the extra params). >> >> > >> > >> > On Wed, Jan 16, 2013 at 6:45 AM, Albert Y. C. Lai >> > wrote: >> >> >> >> On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: >> >>> >> >>> I have enabled document in .cabal/config, so I could get document >> >>> every time I installed libraries or so. >> >>> But when I compile my own applications, it also takes time on >> >>> generating non-exist documents. How to disable it just for this >> >>> project? >> >> >> >> >> >> If "cabal install": add --disable-documentation. >> >> See also "cabal install --help". >> >> >> >> If "cabal configure" and "cabal build" etc: nothing to do, just omit >> >> "cabal haddock". >> >> >> >> >> >> _______________________________________________ >> >> Haskell-Cafe mailing list >> >> Haskell-Cafe at haskell.org >> >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > >> > >> > >> > -- >> > ??????? >> > ??????? >> > >> > And for G+, please use magiclouds#gmail.com. >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.wordpress.com > > > > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From trebla at vex.net Wed Jan 16 06:51:29 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Wed, 16 Jan 2013 00:51:29 -0500 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: <50F5DC13.9050407@vex.net> Message-ID: <50F63FE1.3020808@vex.net> On 13-01-15 09:10 PM, Magicloud Magiclouds wrote: > So the only way is to use param every time I build this certain project? > Really hoping I could disable it in project.cabal .... The param is for "cabal install" only. So don't use "cabal install". cabal configure # may be skipped usually cabal build cabal copy If your project is a library (as opposed to an executable): add cabal register Why this is not controlled in project.cabal: The author of the project should not control whether users build docs or not. P.S. Ivan, --enable-documentation and --disable-documentation are not even valid flags to "cabal configure". From hesselink at gmail.com Wed Jan 16 08:57:52 2013 From: hesselink at gmail.com (Erik Hesselink) Date: Wed, 16 Jan 2013 08:57:52 +0100 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: <50F5DC13.9050407@vex.net> Message-ID: You could do what I do: create an alias in bash. I have in my ~/.bashrc: alias ciq='cabal install --disable-documentation --disable-library-profiling --disable-executable-profiling' The alias 'ciq' stands for 'cabal install quick' and disables things I don't need during development, but do slow down the build. Regards, Erik On Wed, Jan 16, 2013 at 3:10 AM, Magicloud Magiclouds wrote: > So the only way is to use param every time I build this certain project? > Really hoping I could disable it in project.cabal .... > > > On Wed, Jan 16, 2013 at 6:45 AM, Albert Y. C. Lai wrote: >> >> On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: >>> >>> I have enabled document in .cabal/config, so I could get document >>> every time I installed libraries or so. >>> But when I compile my own applications, it also takes time on >>> generating non-exist documents. How to disable it just for this project? >> >> >> If "cabal install": add --disable-documentation. >> See also "cabal install --help". >> >> If "cabal configure" and "cabal build" etc: nothing to do, just omit >> "cabal haddock". >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From magicloud.magiclouds at gmail.com Wed Jan 16 09:26:57 2013 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed, 16 Jan 2013 16:26:57 +0800 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: <50F63FE1.3020808@vex.net> References: <50F5DC13.9050407@vex.net> <50F63FE1.3020808@vex.net> Message-ID: Never noticed copy command. Let me see.... On Wed, Jan 16, 2013 at 1:51 PM, Albert Y. C. Lai wrote: > On 13-01-15 09:10 PM, Magicloud Magiclouds wrote: > >> So the only way is to use param every time I build this certain project? >> Really hoping I could disable it in project.cabal .... >> > > The param is for "cabal install" only. So don't use "cabal install". > > cabal configure # may be skipped usually > cabal build > cabal copy > > If your project is a library (as opposed to an executable): add > cabal register > > Why this is not controlled in project.cabal: The author of the project > should not control whether users build docs or not. > > > P.S. Ivan, --enable-documentation and --disable-documentation are not even > valid flags to "cabal configure". > > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Wed Jan 16 09:27:40 2013 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed, 16 Jan 2013 16:27:40 +0800 Subject: [Haskell-cafe] How to disable document in .cabal file? In-Reply-To: References: <50F5DC13.9050407@vex.net> Message-ID: That is pretty much the way I do now. Just curious if there is another way.... On Wed, Jan 16, 2013 at 3:57 PM, Erik Hesselink wrote: > You could do what I do: create an alias in bash. I have in my ~/.bashrc: > > alias ciq='cabal install --disable-documentation > --disable-library-profiling --disable-executable-profiling' > > The alias 'ciq' stands for 'cabal install quick' and disables things I > don't need during development, but do slow down the build. > > Regards, > > Erik > > On Wed, Jan 16, 2013 at 3:10 AM, Magicloud Magiclouds > wrote: > > So the only way is to use param every time I build this certain project? > > Really hoping I could disable it in project.cabal .... > > > > > > On Wed, Jan 16, 2013 at 6:45 AM, Albert Y. C. Lai > wrote: > >> > >> On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: > >>> > >>> I have enabled document in .cabal/config, so I could get document > >>> every time I installed libraries or so. > >>> But when I compile my own applications, it also takes time on > >>> generating non-exist documents. How to disable it just for this > project? > >> > >> > >> If "cabal install": add --disable-documentation. > >> See also "cabal install --help". > >> > >> If "cabal configure" and "cabal build" etc: nothing to do, just omit > >> "cabal haddock". > >> > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe at haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > > > -- > > ??????? > > ??????? > > > > And for G+, please use magiclouds#gmail.com. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Graham.Hutton at nottingham.ac.uk Wed Jan 16 12:27:36 2013 From: Graham.Hutton at nottingham.ac.uk (Graham Hutton) Date: Wed, 16 Jan 2013 11:27:36 +0000 Subject: [Haskell-cafe] PhD studentships in Nottingham Message-ID: Dear all, The School of Computer Science in Nottingham is advertising a number of PhD studentships. Applicants in the area of the Functional Programming Lab (fp.cs.nott.ac.uk) would be very welcome. If you are interested in applying, please contact a potential academic supervisor in the FP lab prior to submitting your application. Note that I'm not available to supervise new students myself this coming academic year. Graham Hutton University of Nottingham +---------------------------------------------------------------+ Fully-Funded PhD Studentships School of Computer Science University of Nottingham, UK Applications are invited for a number of fully-funded PhD studentships in the School of Computer Science at the University of Nottingham, starting on 1st October 2013. The topics for the studentships are open, but will relate to the research interests of existing members of staff within the School. Applicants should have discussed their interest and obtained the support of a named potential supervisor before applying. The studentships are for three years and include a maintenance grant of 13,726 UK pounds per year and tuition fees for UK students. The positions are open to students of any nationality, but non-UK students will require additional funding to cover tuition fees, which is awarded by the University on a competitive basis. Applicants will normally require a first-class Undergraduate or Masters degree in Computer Science or a related discipline. Informal enquiries may be addressed to Christine Fletcher . To apply, please submit the following items by email to the above address: (1) a brief covering letter that describes your reasons for wishing to pursue a PhD, any ideas you have regarding possible areas or topics, and the name of a potential supervisor; (2) a copy of your CV, including your actual or expected degree class(es), and results of all University examinations; (3) an example of your technical writing, such as a project report or dissertation; (4) contact details for two academic referees. *Closing date for applications:* 8th February 2013 +---------------------------------------------------------------+ -- Prof Graham Hutton Functional Programming Lab School of Computer Science University of Nottingham, UK http://www.cs.nott.ac.uk/~gmh This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. 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 m at jaspervdj.be Wed Jan 16 13:26:26 2013 From: m at jaspervdj.be (Jasper Van der Jeugt) Date: Wed, 16 Jan 2013 13:26:26 +0100 Subject: [Haskell-cafe] ANN: Hakyll 4 Message-ID: After a few weeks of beta status [1], I've now released version 4.0 of the Hakyll static site generator library. I'm really glad with this release, as from what I've found and heard, it makes many things a lot easier. # Main changes - The important `Compiler` type has been changed from `Arrow` to `Monad`: this makes it much easier to write custom compilers, as most Haskellers are more familiar with monads. - The template stays superficially the same, but it has grown much more powerful and flexible underneath. - Early and fast access to metadata makes things such as tags and pagination much easier. - All items (images, css...) can now have metadata associated. Metadata can no longer be manipulated, and this immutability should reduce the number of encountered bugs. - A `check` command has been added. This allows you to check that all internal (or external) links are still alive. # Installation, migration In order to install Hakyll 4, grab it from Hackage: cabal update cabal install hakyll Here are some useful links: - Website: - Tutorial index: - Migration guide: All feedback is welcome as always. [1]: https://groups.google.com/d/topic/hakyll/eRKWz8bVB0w/discussion Peace, Jasper From ivan at dragolov.net Wed Jan 16 14:25:15 2013 From: ivan at dragolov.net (ivan dragolov) Date: Wed, 16 Jan 2013 15:25:15 +0200 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 Message-ID: 9.3 - (2 * 4.5) => 0.3000000000000007 I expected 0.3 ? -- ???? ???????? dragolov.net GSM: 0888 63 19 46 GSM ?? SMS: 0878 82 83 93 facebook.com/ivan.dragolov twitter.com/dragolov -------------- next part -------------- An HTML attachment was scrubbed... URL: From haskell at patrickmylund.com Wed Jan 16 14:30:13 2013 From: haskell at patrickmylund.com (Patrick Mylund Nielsen) Date: Wed, 16 Jan 2013 07:30:13 -0600 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: Fun with floating point! # ghci GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> 9223372036854775807.0 == 9223372036854775808 True http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems On Wed, Jan 16, 2013 at 7:25 AM, ivan dragolov wrote: > > 9.3 - (2 * 4.5) => 0.3000000000000007 > > I expected 0.3 > > ? > > -- > ???? ???????? > dragolov.net > > GSM: 0888 63 19 46 > GSM ?? SMS: 0878 82 83 93 > facebook.com/ivan.dragolov > twitter.com/dragolov > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mad.one at gmail.com Wed Jan 16 14:31:18 2013 From: mad.one at gmail.com (Austin Seipp) Date: Wed, 16 Jan 2013 07:31:18 -0600 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: This is a rounding error. It will happen in any language due to the imprecision of floats; for example, using Ruby: $ irb 1.9.3-p286 :001 > 9.3 - (2 * 4.5) => 0.3000000000000007 1.9.3-p286 :001 > ^D $ Read this: http://floating-point-gui.de/ On Wed, Jan 16, 2013 at 7:25 AM, ivan dragolov wrote: > > 9.3 - (2 * 4.5) => 0.3000000000000007 > > I expected 0.3 > > ? > > -- > ???? ???????? > dragolov.net > > GSM: 0888 63 19 46 > GSM ?? SMS: 0878 82 83 93 > facebook.com/ivan.dragolov > twitter.com/dragolov > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Regards, Austin From haskell at patrickmylund.com Wed Jan 16 14:31:51 2013 From: haskell at patrickmylund.com (Patrick Mylund Nielsen) Date: Wed, 16 Jan 2013 07:31:51 -0600 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: This may be of interest if you want full-precision decimals: http://www.haskell.org/haskellwiki/Libraries_and_tools/Mathematics#Decimal_numbers On Wed, Jan 16, 2013 at 7:30 AM, Patrick Mylund Nielsen < haskell at patrickmylund.com> wrote: > Fun with floating point! > > # ghci > GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer-gmp ... linking ... done. > Loading package base ... linking ... done. > Prelude> 9223372036854775807.0 == 9223372036854775808 > True > > http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems > > > > On Wed, Jan 16, 2013 at 7:25 AM, ivan dragolov wrote: > >> >> 9.3 - (2 * 4.5) => 0.3000000000000007 >> >> I expected 0.3 >> >> ? >> >> -- >> ???? ???????? >> dragolov.net >> >> GSM: 0888 63 19 46 >> GSM ?? SMS: 0878 82 83 93 >> facebook.com/ivan.dragolov >> twitter.com/dragolov >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom.davie at gmail.com Wed Jan 16 14:55:57 2013 From: tom.davie at gmail.com (Tom Davie) Date: Wed, 16 Jan 2013 13:55:57 +0000 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: Prelude> import Data.Ratio Prelude Data.Ratio> 93 % 10 - (2 * 9 % 2) 3 % 10 Floating point sucks, avoid it if you can. Thanks Tom Davie On 16 Jan 2013, at 13:25, ivan dragolov wrote: > > 9.3 - (2 * 4.5) => 0.3000000000000007 > > I expected 0.3 > > ? > > -- > ???? ???????? > dragolov.net > > GSM: 0888 63 19 46 > GSM ?? SMS: 0878 82 83 93 > facebook.com/ivan.dragolov > twitter.com/dragolov > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From evohunz at gmail.com Wed Jan 16 16:03:22 2013 From: evohunz at gmail.com (Thiago Negri) Date: Wed, 16 Jan 2013 13:03:22 -0200 Subject: [Haskell-cafe] Type hierarchy Message-ID: Hello. How do I achieve type hierarchy in Haskell? Suppose we have the following code: foo :: A -> C bar :: B -> C I want something that allow me to say that B is a subtype of A, meaning: 1. I can use a value of type A where a value of type A is needed. 2. I can use a value of type B where a value of type B is needed. 3. I can use a value of type B where a value of type A is needed. 4. I can't use a value of type A where a value of type B is needed. What are my options? I've thought in type classes and data types with an attribute representing the extension. Any other way to do this? Thanks, Thiago. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cabellos at ifca.unican.es Wed Jan 16 16:04:57 2013 From: cabellos at ifca.unican.es (Luis Cabellos) Date: Wed, 16 Jan 2013 16:04:57 +0100 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: You should read http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 If you want to be efficient with floats. Language independent. Luis On Wed, Jan 16, 2013 at 2:25 PM, ivan dragolov wrote: > > 9.3 - (2 * 4.5) => 0.3000000000000007 > > I expected 0.3 > > ? > > -- > ???? ???????? > dragolov.net > > GSM: 0888 63 19 46 > GSM ?? SMS: 0878 82 83 93 > facebook.com/ivan.dragolov > twitter.com/dragolov > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.is.fischer at googlemail.com Wed Jan 16 16:32:41 2013 From: daniel.is.fischer at googlemail.com (Daniel Fischer) Date: Wed, 16 Jan 2013 16:32:41 +0100 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: <6123195.hNxvWYIEqR@linux-v7dw.site> On Wednesday 16 January 2013, 15:25:15, ivan dragolov wrote: > 9.3 - (2 * 4.5) => 0.3000000000000007 > > I expected 0.3 > > ? Prelude Text.FShow.RealFloat> FD 9.3 9.300000000000000710542735760100185871124267578125 The closest Double to 9.3 is somewhat larger than 9.3. Since the first two significant digits are enough to distinguish it from the next smaller number, only those are delivered by the Show instance. If you subtract 9 from that, you get, unsurprisingly, Prelude Text.FShow.RealFloat> it - 9 0.300000000000000710542735760100185871124267578125 which is not the closest Double value to 0.3 (in fact, there are 12 Double values between that and the closest Double to 0.3). To distinguish that number from its neighbours, 16 significant digits are necessary, hence so many are displayed. From felipe.lessa at gmail.com Wed Jan 16 16:57:02 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Wed, 16 Jan 2013 13:57:02 -0200 Subject: [Haskell-cafe] Type hierarchy In-Reply-To: References: Message-ID: For your particular constraints, it can be as easy as: class IsA a where toA :: a -> A foo' :: IsA a => a -> C foo' = foo . toA However, you may asking the wrong question since it smells like you're trying to embed OO into Haskell =). Cheers, On Wed, Jan 16, 2013 at 1:03 PM, Thiago Negri wrote: > Hello. > > How do I achieve type hierarchy in Haskell? > > Suppose we have the following code: > > foo :: A -> C > bar :: B -> C > > I want something that allow me to say that B is a subtype of A, meaning: > 1. I can use a value of type A where a value of type A is needed. > 2. I can use a value of type B where a value of type B is needed. > 3. I can use a value of type B where a value of type A is needed. > 4. I can't use a value of type A where a value of type B is needed. > > What are my options? > > I've thought in type classes and data types with an attribute representing > the extension. Any other way to do this? > > Thanks, > Thiago. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Felipe. From evohunz at gmail.com Wed Jan 16 17:22:12 2013 From: evohunz at gmail.com (Thiago Negri) Date: Wed, 16 Jan 2013 14:22:12 -0200 Subject: [Haskell-cafe] Type hierarchy In-Reply-To: References: Message-ID: Thanks for the answer, but I'm trying to avoid type classes. By the way, I'm not trying to embed OO into Haskell. I'm trying to solve this issue: https://github.com/haskell-opengl/OpenGLRaw/issues/15 The binding to OpenGL declares GLenum as CUInt and GLboolean as CUChar, meaning I can't use a GLenum as a GLboolean or vice-versa. The C spec allows the use of GLboolean values where GLenums are expected. Maybe I'm taking the wrong approach... 2013/1/16 Felipe Almeida Lessa > For your particular constraints, it can be as easy as: > > class IsA a where > toA :: a -> A > > foo' :: IsA a => a -> C > foo' = foo . toA > > However, you may asking the wrong question since it smells like you're > trying to embed OO into Haskell =). > > Cheers, > > On Wed, Jan 16, 2013 at 1:03 PM, Thiago Negri wrote: > > Hello. > > > > How do I achieve type hierarchy in Haskell? > > > > Suppose we have the following code: > > > > foo :: A -> C > > bar :: B -> C > > > > I want something that allow me to say that B is a subtype of A, meaning: > > 1. I can use a value of type A where a value of type A is needed. > > 2. I can use a value of type B where a value of type B is needed. > > 3. I can use a value of type B where a value of type A is needed. > > 4. I can't use a value of type A where a value of type B is needed. > > > > What are my options? > > > > I've thought in type classes and data types with an attribute > representing > > the extension. Any other way to do this? > > > > Thanks, > > Thiago. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Felipe. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Wed Jan 16 17:35:50 2013 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Wed, 16 Jan 2013 23:35:50 +0700 Subject: [Haskell-cafe] Type hierarchy In-Reply-To: References: Message-ID: On Wed, Jan 16, 2013 at 11:22 PM, Thiago Negri wrote: > The C spec allows the use of GLboolean values where GLenums are expected. > Some fixes off the top of my head (caveats apply): * define a lift :: GLboolean -> GLenum * use a typeclass GLenumlike * if there aren't too many of them, roll a GLboolean specific function for every one taking GLenum -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.turner at tracsis.com Wed Jan 16 15:56:25 2013 From: d.turner at tracsis.com (David Turner) Date: Wed, 16 Jan 2013 14:56:25 +0000 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: <50F6BF99.9020309@tracsis.com> On 16/01/2013 13:55, Tom Davie wrote: > Prelude> import Data.Ratio > Prelude Data.Ratio> 93 % 10 - (2 * 9 % 2) > 3 % 10 Or even just a type annotation: Prelude> (9.3 - (2 * 4.5)) :: Rational 3 % 10 > On 16 Jan 2013, at 13:25, ivan dragolov > wrote: > >> >> 9.3 - (2 * 4.5) => 0.3000000000000007 >> >> I expected 0.3 -- David Turner Senior Consultant Tracsis PLC Tracsis PLC is a company registered in England and Wales with number 5019106. From trebla at vex.net Wed Jan 16 20:25:26 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Wed, 16 Jan 2013 14:25:26 -0500 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: <50F6FEA6.50006@vex.net> On 13-01-16 10:04 AM, Luis Cabellos wrote: > You should read > http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 > > If you want to be efficient with floats. Language independent. And also http://floating-point-gui.de/ From headprogrammingczar at gmail.com Wed Jan 16 22:16:39 2013 From: headprogrammingczar at gmail.com (Joe Q) Date: Wed, 16 Jan 2013 16:16:39 -0500 Subject: [Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007 In-Reply-To: References: Message-ID: Welcome to IEEE floating point math! Wikipedia has a good article on the specification. If you want exact fractional numbers for your own purposes, there are a number of ways around the limits of floats. Rational will represent numbers internally as fractions, and still allow you to use the same syntax as above. The result will be "3 % 10", which you read as the fraction 3 / 10. If you also want irrational numbers, things get tricky. CReal will do it, but has some limitations. On Jan 16, 2013 8:26 AM, "ivan dragolov" wrote: > > 9.3 - (2 * 4.5) => 0.3000000000000007 > > I expected 0.3 > > ? > > -- > ???? ???????? > dragolov.net > > GSM: 0888 63 19 46 > GSM ?? SMS: 0878 82 83 93 > facebook.com/ivan.dragolov > twitter.com/dragolov > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ianwookim at gmail.com Thu Jan 17 00:47:09 2013 From: ianwookim at gmail.com (Ian-Woo Kim) Date: Wed, 16 Jan 2013 18:47:09 -0500 Subject: [Haskell-cafe] ANN: hoodle-0.1.1 Message-ID: Hi, hoodle lovers :-) I am pleased to announce hoodle v0.1.1. In this version, I added the following functionality and made several improvement. * context (popup) menu support : after you select, you will see a context menu for the selected items (make pdf, make svg, cut, copy, delete ...) You can also make your own context menu by scripting $HOME/.hoodle.d/start.hs. I will explain this later in this email. * text input support : text can be entered. currently font cannot be changed yet. * SVG import support : SVG can be imported as vector graphics * JPG import support : in addition to PNG, now JPG can be imported * embedding image : by default, hoodle now embed image in the file. It can be turned off by checking off in option menu. * full screen mode support * color picker support * rendering engine is improved much I have added the following experimental functions. * LaTeX input support (more precisely itex and MathML) : using lasem library ( https://live.gnome.org/Lasem git repository : http://git.gnome.org/cgit/lasem/ ), mathematical expression input is supported. * smooth scrolling Internally, hoodle generates SVG image from text (and latex input), so that it can be viewed exactly the same for any computer and font configuration. Hoodle has a scripting support like xmonad. If you have $HOME/.hoodle.d/start.hs , then the script will be automatically compiled using dyre and you can customize your hoodle. There are not so many hooks available yet, but I will add more and more hooks as time goes. Currently, I use file name suggestion hook (using current date/time) and custom context menu. (using this, I automatically generate png image from selected items and put it on my dropbox folder. This turned out extremely useful.) See my example start.hs : https://gist.github.com/4551914 Installation is always simple :-) after > cabal update you can install hoodle without poppler (pdf rendering support) > cabal install hoodle or with poppler (pdf rendering support) : recommended > cabal install -fpoppler hoodle-render hoodle-core hoodle If you have previous version of hoodle on your system, to uninstall previous version > ghc-pkg unregister coroutine-object --force > ghc-pkg unregister hoodle-types --force > ghc-pkg unregister xournal-types --force then install using cabal as above. Please give it a try. Hope that you will enjoy the new version. best, Ian-Woo Kim p.s. if you are interested in hoodle development and any questions about using hoodle, please subscribe to hoodle google group ( https://groups.google.com/forum/?fromgroups#!forum/hoodle ) . Issuing at http://github.com/wavewave/hoodle is also very welcome. Thanks! From kazu at iij.ad.jp Thu Jan 17 04:24:41 2013 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Thu, 17 Jan 2013 12:24:41 +0900 (JST) Subject: [Haskell-cafe] DIY vs as-a-Service with MemCachier Message-ID: <20130117.122441.1480946258246108891.kazu@iij.ad.jp> Hello, The following blog post by Joyent is worth reading: http://joyent.com/blog/diy-vs-as-a-service-with-memcachier "We don't really believe in Node.js (Go & Haskell are our choices), so that is a small concern to us, but everyone has their failings." --Kazu From jason.dusek at gmail.com Thu Jan 17 11:16:49 2013 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu, 17 Jan 2013 10:16:49 +0000 Subject: [Haskell-cafe] DIY vs as-a-Service with MemCachier In-Reply-To: <20130117.122441.1480946258246108891.kazu@iij.ad.jp> References: <20130117.122441.1480946258246108891.kazu@iij.ad.jp> Message-ID: 2013/1/17 Kazu Yamamoto : > The following blog post by Joyent is worth reading: > > http://joyent.com/blog/diy-vs-as-a-service-with-memcachier > > "We don't really believe in Node.js (Go & Haskell are our > choices), so that is a small concern to us, but everyone has > their failings." The post is on the Joyent blog; but was written by someone from MemCachier, a new partner with Joyent. MemCachier seems to have partnered with a few other cloud platforms -- Heroku, for example. It's nice to see a Bay Area "cloud" company speak up for Haskell. -- Jason Dusek pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B From noteed at gmail.com Thu Jan 17 11:24:00 2013 From: noteed at gmail.com (Vo Minh Thu) Date: Thu, 17 Jan 2013 11:24:00 +0100 Subject: [Haskell-cafe] DIY vs as-a-Service with MemCachier In-Reply-To: References: <20130117.122441.1480946258246108891.kazu@iij.ad.jp> Message-ID: 2013/1/17 Jason Dusek : > 2013/1/17 Kazu Yamamoto : >> The following blog post by Joyent is worth reading: >> >> http://joyent.com/blog/diy-vs-as-a-service-with-memcachier >> >> "We don't really believe in Node.js (Go & Haskell are our >> choices), so that is a small concern to us, but everyone has >> their failings." > > The post is on the Joyent blog; but was written by someone from > MemCachier, a new partner with Joyent. MemCachier seems to have > partnered with a few other cloud platforms -- Heroku, for > example. It's nice to see a Bay Area "cloud" company speak up > for Haskell. The person is David Terei, he's quite famous in the Haskell community for having written the LLVM backend for GHC. Cheers, Thu From agocorona at gmail.com Thu Jan 17 16:07:41 2013 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu, 17 Jan 2013 16:07:41 +0100 Subject: [Haskell-cafe] ANNOUNCE: MFlow 0.2 Message-ID: Hello. haskellers and, specially, web developpers. This is the second version of MFlow, a deep-first effort in the development of a platform for web applications at the higher level, by including as much haskell magic as possible. It is at the same time experimental and intended to be used in industry. I believe that haskell will not have its chance in the Web if it does not bring unique advantages and challenging paradigms beyond speed and type safety. Deep-first means that the effort is more in the addition higher level features rather than in being complete and bug free, with the conviction that feedback from real usage at the highest level is the best guide for development. Rather than to mimic other platforms in other languages, MFlow is as Haskell'ish as possible, and introduces new approaches like statefulness, event sourcing, back-execution, composable, active, self contained widgets and persistent STM. All of them collaborate to create a high level environment for web programming. This release adds bidings for WAI, blaze-html, stateful AJAX, active widgets, requirements, content management, multilanguage and URLs to pages inside stateful procedures. The package: [http://hackage.haskell.org/package/MFlow The entry in my blog, with the announcement and the philosophy behind http://haskell-web.blogspot.com.es/2013/01/announce-mflow-02.html The same, in other words: http://haskell-web.blogspot.com.es/2012/12/on-spirit-of-mflow-anatomy-of-widget.html An online example, with some links that explain the new features. http://81.169.134.95:8081 Stateful, but virtually stateless, thanks to event sourcing http://haskell-web.blogspot.com/2013/01/stateful-but-stateless-at-last-thanks.html Example of use of active widgets http://haskell-web.blogspot.com.es/2013/01/now-example-of-use-of-active-widget.html Bug tracker https://github.com/agocorona/MFlow/issues Source repository git clone http://github.com/agocorona/MFlow Feedback is welcomed warmly Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan.huesken at posteo.de Thu Jan 17 18:48:02 2013 From: nathan.huesken at posteo.de (=?ISO-8859-1?Q?Nathan_H=FCsken?=) Date: Thu, 17 Jan 2013 18:48:02 +0100 Subject: [Haskell-cafe] Feedback on FFI bindings for C++ library Message-ID: <50F83952.5030705@posteo.de> Hey, I would like to write FII bindings in haskell for cocos2d-x (http://www.cocos2d-x.org/), which is a C++ library. Since I have little experience with this, I would like some feedback before I discover that concept is bad half way. In cocos2d there is a base class with much functionality: CCNode Many classes derive from it (i.E. CCLayer) and use the virtual functions of CCNode (i.E. setPosition). How do I map this to haskell? The general Idea: I have a typeclass, in which everything that is derived from CCNode is an instance: class NodeDerived a where toNode :: a -> Node setPosition :: a -> (Double,Double) -> IO () setPosition a pos = setNodePosition (toNode a) pos instane NodeDerived Layer where toNode = layerToNode and layerToNode :: Layer -> Node would be implemented in C++ as: CCNode* layerToNode(CCLayer* l) { return dynamic_cast(l); } This way I would have only to implement toNode for every class derived from CCNode and get all the functions CCNode defines. What do you think if this Idea? How would you do it? Thanks! Nathan From acopton at gmail.com Thu Jan 17 22:17:33 2013 From: acopton at gmail.com (Alexander Bernauer) Date: Thu, 17 Jan 2013 22:17:33 +0100 Subject: [Haskell-cafe] ANN: hgdbmi 0.2, GDB Machine Interface Message-ID: Hi I am happy to announce the second release of hgdbmi, a Haskell implementation of the GDB Machine Interface. The Machine Interface is a machine-readable variant of the stdin/stdout-based interface of the GNU debugger. With hgdbmi you can control the execution of a GDB instance to drive debugging of arbitrary targets. Version 0.2 of this library is a substantial, non-compatible extension of version 0.1. The API provides a thread-safe and synchronous command-response function and supports user-defined call-backs for asynchronous notifications. All commands, responses and notifications are supported in this version. Also, for some response and notification types, we additionally provide semantic data types and corresponding translation functions. The package: http://hackage.haskell.org/package/hgdbmi-0.2 Greetings, Alex PS: This is my first serious Haskell package. If you see something that you consider odd, I might have done this simply because I didn't know better. I would appreciate if you would let me know in such a case. From jpm at cs.uu.nl Fri Jan 18 00:07:33 2013 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Thu, 17 Jan 2013 23:07:33 +0000 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell Message-ID: Hi all, I'd like to introduce Chordify [1], an online music player that extracts chords from musical sources like Soundcloud, Youtube or your own files, and shows you which chord to play when. Here's an example song: http://chordify.net/chords/passenger-let-her-go-official-video-passengermusic The aim of Chordify is to make state-of-the-art music technology accessible to a broader audience. Behind the scenes, Chordify uses the HarmTrace Haskell package to compute chords from audio. I've been working on this project with a couple of colleagues for a while now, and recently we have made the website public, free to use for everyone. We do not use Haskell for any of the frontend/user interface, but the backend is entirely written in Haskell (and it uses pretty advanced features, such as GADTs and type families [3]). We're particularly interested in user feedback at this stage, so if you're interested in music and could use an automatic chord transcription service, please try Chordify! Cheers, Pedro [1] http://chordify.net/ [2] http://hackage.haskell.org/package/HarmTrace [3] Jos? Pedro Magalh?es and W. Bas de Haas. Functional Modelling of Musical Harmony: an Experience Report. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP'11), pp. 156?162, ACM, 2011. http://dreixel.net/research/pdf/fmmh.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: From kudahkukarek at gmail.com Fri Jan 18 01:05:48 2013 From: kudahkukarek at gmail.com (kudah) Date: Fri, 18 Jan 2013 02:05:48 +0200 Subject: [Haskell-cafe] Feedback on FFI bindings for C++ library In-Reply-To: <50F83952.5030705@posteo.de> References: <50F83952.5030705@posteo.de> Message-ID: <20130118020548.288483a1@gmail.com> I'd suggest to first look at how other C++-bindings for haskell are implemented. e.g. wxHaskell is the most mature Haskell C++ binding out there. hogre tries to generate bindings from headers. And a number of (rather minimal) bindings to some libs were made as part of Nikki and the Robots. On Thu, 17 Jan 2013 18:48:02 +0100 Nathan H?sken wrote: > Hey, > > I would like to write FII bindings in haskell for cocos2d-x > (http://www.cocos2d-x.org/), which is a C++ library. > > Since I have little experience with this, I would like some feedback > before I discover that concept is bad half way. > > In cocos2d there is a base class with much functionality: CCNode > Many classes derive from it (i.E. CCLayer) and use the virtual > functions of CCNode (i.E. setPosition). > > How do I map this to haskell? > > The general Idea: > > I have a typeclass, in which everything that is derived from CCNode is > an instance: > > class NodeDerived a where > toNode :: a -> Node > > setPosition :: a -> (Double,Double) -> IO () > setPosition a pos = setNodePosition (toNode a) pos > > instane NodeDerived Layer where > toNode = layerToNode > > and layerToNode :: Layer -> Node would be implemented in C++ as: > > CCNode* layerToNode(CCLayer* l) { return > dynamic_cast(l); } > > This way I would have only to implement toNode for every class derived > from CCNode and get all the functions CCNode defines. > > What do you think if this Idea? > How would you do it? > > Thanks! > Nathan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From kudahkukarek at gmail.com Fri Jan 18 03:03:48 2013 From: kudahkukarek at gmail.com (kudah) Date: Fri, 18 Jan 2013 04:03:48 +0200 Subject: [Haskell-cafe] Feedback on FFI bindings for C++ library In-Reply-To: <50F83952.5030705@posteo.de> References: <50F83952.5030705@posteo.de> Message-ID: <20130118040348.5e5d2d15@gmail.com> I'd suggest to first look at how other C++-bindings for haskell are implemented. e.g. wxHaskell is the most mature Haskell C++ binding out there. hogre tries to generate bindings from headers. And a number of (rather minimal) bindings to some libs were made as part of Nikki and the Robots. On Thu, 17 Jan 2013 18:48:02 +0100 Nathan H?sken wrote: > Hey, > > I would like to write FII bindings in haskell for cocos2d-x > (http://www.cocos2d-x.org/), which is a C++ library. > > Since I have little experience with this, I would like some feedback > before I discover that concept is bad half way. > > In cocos2d there is a base class with much functionality: CCNode > Many classes derive from it (i.E. CCLayer) and use the virtual > functions of CCNode (i.E. setPosition). > > How do I map this to haskell? > > The general Idea: > > I have a typeclass, in which everything that is derived from CCNode is > an instance: > > class NodeDerived a where > toNode :: a -> Node > > setPosition :: a -> (Double,Double) -> IO () > setPosition a pos = setNodePosition (toNode a) pos > > instane NodeDerived Layer where > toNode = layerToNode > > and layerToNode :: Layer -> Node would be implemented in C++ as: > > CCNode* layerToNode(CCLayer* l) { return > dynamic_cast(l); } > > This way I would have only to implement toNode for every class derived > from CCNode and get all the functions CCNode defines. > > What do you think if this Idea? > How would you do it? > > Thanks! > Nathan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ckkashyap at gmail.com Fri Jan 18 04:10:27 2013 From: ckkashyap at gmail.com (C K Kashyap) Date: Fri, 18 Jan 2013 08:40:27 +0530 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell In-Reply-To: References: Message-ID: Very cool :) I tried this one http://chordify.net/chords/jamelia-superstar-emimusic Not sure if the places it showed E flat - was it really E flat minor? What next - index all the songs using their "chordification" and then search them using a "hum" as input :) Regards, Kashyap On Fri, Jan 18, 2013 at 4:37 AM, Jos? Pedro Magalh?es wrote: > Hi all, > > I'd like to introduce Chordify [1], an online > music player that extracts chords from musical sources like Soundcloud, > Youtube or your own files, and shows you which chord to play when. Here's > an example song: > http://chordify.net/chords/passenger-let-her-go-official-video-passengermusic > > The aim of Chordify is to make state-of-the-art music technology > accessible to a broader audience. Behind the scenes, Chordify uses the > HarmTrace Haskell package to compute chords from audio. I've been working > on this project with a couple of colleagues for a while now, and recently > we have made the website public, free to use for everyone. > > We do not use Haskell for any of the frontend/user interface, but the > backend is entirely written in Haskell (and it uses pretty advanced > features, such as GADTs and type families [3]). We're particularly > interested in user feedback at this stage, so if you're interested in music > and could use an automatic chord transcription service, please try Chordify! > > > Cheers, > Pedro > > [1] http://chordify.net/ > [2] http://hackage.haskell.org/package/HarmTrace > [3] Jos? Pedro Magalh?es and W. Bas de Haas. Functional Modelling of > Musical Harmony: an Experience Report. In Proceedings of the 16th ACM > SIGPLAN International Conference on Functional Programming (ICFP'11), pp. > 156?162, ACM, 2011. http://dreixel.net/research/pdf/fmmh.pdf > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brucker at spamfence.net Fri Jan 18 07:04:34 2013 From: brucker at spamfence.net (Achim D. Brucker) Date: Fri, 18 Jan 2013 07:04:34 +0100 Subject: [Haskell-cafe] TAP 2013: Final Call for Papers Message-ID: <20130118060434.GA11889@shinanogawa.brucker.ch> (Apologies if you receive this announcement multiple times.) !LNCS publication is confirmed! **************************************************** *** *** *** TAP 2013 *** *** *** *** Abstract submission: January 25, 2013 *** *** Paper submission: February 1, 2013 *** **************************************************** *** TAP 2013 solicits both full papers and *** *** (industrial) experience/tool papers *** *** in combining proofs and (security) testing *** **************************************************** CALL FOR PAPERS 7th INTERNATIONAL CONFERENCE ON TESTS AND PROOFS (TAP 2013) http://www.spacios.eu/TAP2013 Budapest, Hungary, June 18-19, 2013 The TAP conference is devoted to the synergy of proofs and tests, to the application of techniques from both sides and their combination for the advancement of software quality. Testing and proving seem to be contradictory techniques: once you have proved your program to be correct then additional testing seems pointless; on the other hand, when such a proof in not feasible, then testing the program seems to be the only option. This view has dominated the research community since the dawn of computer science, and has resulted in distinct communities pursuing the seemingly orthogonal research areas. However, the development of both approaches has lead to the discovery of common issues and to the realization of potential synergy. Perhaps, use of model checking in testing was one of the first signs that a counterexample to a proof may be interpreted as a test case. Recent breakthroughs in deductive techniques such as satisfiability modulo theories, abstract interpretation, and interactive theorem proving, have paved the way for new and practically effective methods of powering testing techniques. Moreover, since formal, proof-based verification is costly, testing invariants and background theories can be helpful to detect errors early and to improve cost effectiveness. Summing up, in the past few years an increasing number of research efforts have encountered the need for combining proofs and tests, dropping earlier dogmatic views of incompatibility and taking instead the best of what each of these software engineering domains has to offer. The TAP conference aims to bring together researchers and practitioners working in the converging fields of testing and proving, and will offer a generous allocation of papers, panels and informal discussions. Topics of interest cover theory definitions, tool constructions and experimentations, and include (other topics related to TAP are welcome): - Bridging the gap between concrete and symbolic techniques, e.g. using proof search in satisfiability modulo theories solvers to enhance various testing techniques - Transfer of concepts from testing to proving (e.g., coverage criteria) and from proving to testing - Program proving with the aid of testing techniques - New problematics in automated reasoning emerging from specificities of test generation - Verification and testing techniques combining proofs and tests - Generation of test data, oracles, or preambles by deductive techniques such as: theorem proving, model checking, symbolic execution, constraint logic programming - Model-based testing and verification - Generation of specifications by deduction - Automatic bug finding - Debugging of programs combining static and dynamic analysis - Formal frameworks - Tool descriptions and experience reports - Case studies combining tests and proofs - Domain specific applications of testing and proving to new application domains such as validating security protocols, vulnerability detection of programs, security Important Dates: ================ Abstract submission: January 25, 2013 Paper submission: February 1, 2013 Notification: March 3, 2013 Camera ready version: April 5, 2013 TAP conference: June 17-21, 2013 Program Chairs: =============== Margus Veanes (Microsoft Research, USA) Luca Vigano` (University of Verona, Italy) Program Committee: ================== Paul Ammann Dirk Beyer Achim D. Brucker Robert Claris? Marco Comini Catherine Dubois Juhan Ernits Gordon Fraser Angelo Gargantini Christoph Gladisch Martin Gogolla Arnaud Gotlieb Wolfgang Grieskamp Reiner H?hnle Bart Jacobs Thi?rry Jeron Jacques Julliand Gregory Kapfhammer Nikolai Kosmatov Victor Kuliamin Michael Leuschel Karl Meinke Alexandre Petrenko Holger Schlingloff T.H. Tse Margus Veanes (co-chair) Luca Vigan? (co-chair) Burkhart Wolff Fatiha Zaidi Submission: =========== Please submit your papers via easychair https://www.easychair.org/conferences/?conf=tap2013 TAP 2013 will accept two types of papers: - Research papers: full papers with at most 16 pages in LNCS format (pdf), which have to be original, unpublished and not submitted elsewhere. - Short contributions: work in progress, (industrial) experience reports or tool demonstrations, position statements; an extended abstract with at most 6 pages in LNCS format (pdf) is expected. Accepted papers will be published in the Springer LNCS series and will be available at the conference. The contents of previous TAP proceedings is available at: http://www.informatik.uni-trier.de/~ley/db/conf/tap/ -- Dr. Achim D. Brucker, SAP AG, Vincenz-Priessnitz-Str. 1, D-76131 Karlsruhe Phone: +49 6227 7-52595, http://www.brucker.ch/ From alpmestan at gmail.com Fri Jan 18 08:34:18 2013 From: alpmestan at gmail.com (Alp Mestanogullari) Date: Fri, 18 Jan 2013 08:34:18 +0100 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell In-Reply-To: References: Message-ID: That's awesome, works like a charm on the samples I've tried it on! Cheers to the Chordify team, I will use it and give any useful feedback if I have any. On Fri, Jan 18, 2013 at 12:07 AM, Jos? Pedro Magalh?es wrote: > Hi all, > > I'd like to introduce Chordify [1], an online > music player that extracts chords from musical sources like Soundcloud, > Youtube or your own files, and shows you which chord to play when. Here's > an example song: > http://chordify.net/chords/passenger-let-her-go-official-video-passengermusic > > The aim of Chordify is to make state-of-the-art music technology > accessible to a broader audience. Behind the scenes, Chordify uses the > HarmTrace Haskell package to compute chords from audio. I've been working > on this project with a couple of colleagues for a while now, and recently > we have made the website public, free to use for everyone. > > We do not use Haskell for any of the frontend/user interface, but the > backend is entirely written in Haskell (and it uses pretty advanced > features, such as GADTs and type families [3]). We're particularly > interested in user feedback at this stage, so if you're interested in music > and could use an automatic chord transcription service, please try Chordify! > > > Cheers, > Pedro > > [1] http://chordify.net/ > [2] http://hackage.haskell.org/package/HarmTrace > [3] Jos? Pedro Magalh?es and W. Bas de Haas. Functional Modelling of > Musical Harmony: an Experience Report. In Proceedings of the 16th ACM > SIGPLAN International Conference on Functional Programming (ICFP'11), pp. > 156?162, ACM, 2011. http://dreixel.net/research/pdf/fmmh.pdf > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Alp Mestanogullari -------------- next part -------------- An HTML attachment was scrubbed... URL: From alpmestan at gmail.com Fri Jan 18 08:36:21 2013 From: alpmestan at gmail.com (Alp Mestanogullari) Date: Fri, 18 Jan 2013 08:36:21 +0100 Subject: [Haskell-cafe] Feedback on FFI bindings for C++ library In-Reply-To: <20130118020548.288483a1@gmail.com> References: <50F83952.5030705@posteo.de> <20130118020548.288483a1@gmail.com> Message-ID: The simplest way generally is to make make a C binding and then bind Haskell from there. You may indeed want to take a look at wxWidgets' binding or SFML's (https://github.com/jeannekamikaze/SFML). On Fri, Jan 18, 2013 at 1:05 AM, kudah wrote: > I'd suggest to first look at how other C++-bindings for haskell are > implemented. e.g. wxHaskell is the most mature Haskell C++ binding out > there. hogre tries to generate bindings from headers. And a number of > (rather minimal) bindings to some libs were made as part of Nikki and > the Robots. > > On Thu, 17 Jan 2013 18:48:02 +0100 Nathan H?sken > wrote: > > > Hey, > > > > I would like to write FII bindings in haskell for cocos2d-x > > (http://www.cocos2d-x.org/), which is a C++ library. > > > > Since I have little experience with this, I would like some feedback > > before I discover that concept is bad half way. > > > > In cocos2d there is a base class with much functionality: CCNode > > Many classes derive from it (i.E. CCLayer) and use the virtual > > functions of CCNode (i.E. setPosition). > > > > How do I map this to haskell? > > > > The general Idea: > > > > I have a typeclass, in which everything that is derived from CCNode is > > an instance: > > > > class NodeDerived a where > > toNode :: a -> Node > > > > setPosition :: a -> (Double,Double) -> IO () > > setPosition a pos = setNodePosition (toNode a) pos > > > > instane NodeDerived Layer where > > toNode = layerToNode > > > > and layerToNode :: Layer -> Node would be implemented in C++ as: > > > > CCNode* layerToNode(CCLayer* l) { return > > dynamic_cast(l); } > > > > This way I would have only to implement toNode for every class derived > > from CCNode and get all the functions CCNode defines. > > > > What do you think if this Idea? > > How would you do it? > > > > Thanks! > > Nathan > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Alp Mestanogullari -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Fri Jan 18 09:06:07 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Fri, 18 Jan 2013 08:06:07 +0000 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell In-Reply-To: References: Message-ID: Congratulations! Keep up the good work, especially in using Haskell at a commercial level :) Bye! Alfredo On 18 January 2013 07:34, Alp Mestanogullari wrote: > That's awesome, works like a charm on the samples I've tried it on! Cheers > to the Chordify team, I will use it and give any useful feedback if I have > any. > > > On Fri, Jan 18, 2013 at 12:07 AM, Jos? Pedro Magalh?es wrote: > >> Hi all, >> >> I'd like to introduce Chordify [1], an online >> music player that extracts chords from musical sources like Soundcloud, >> Youtube or your own files, and shows you which chord to play when. Here's >> an example song: >> http://chordify.net/chords/passenger-let-her-go-official-video-passengermusic >> >> The aim of Chordify is to make state-of-the-art music technology >> accessible to a broader audience. Behind the scenes, Chordify uses the >> HarmTrace Haskell package to compute chords from audio. I've been working >> on this project with a couple of colleagues for a while now, and recently >> we have made the website public, free to use for everyone. >> >> We do not use Haskell for any of the frontend/user interface, but the >> backend is entirely written in Haskell (and it uses pretty advanced >> features, such as GADTs and type families [3]). We're particularly >> interested in user feedback at this stage, so if you're interested in music >> and could use an automatic chord transcription service, please try Chordify! >> >> >> Cheers, >> Pedro >> >> [1] http://chordify.net/ >> [2] http://hackage.haskell.org/package/HarmTrace >> [3] Jos? Pedro Magalh?es and W. Bas de Haas. Functional Modelling of >> Musical Harmony: an Experience Report. In Proceedings of the 16th ACM >> SIGPLAN International Conference on Functional Programming (ICFP'11), pp. >> 156?162, ACM, 2011. http://dreixel.net/research/pdf/fmmh.pdf >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > -- > Alp Mestanogullari > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From evohunz at gmail.com Fri Jan 18 09:39:17 2013 From: evohunz at gmail.com (Thiago Negri) Date: Fri, 18 Jan 2013 06:39:17 -0200 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell In-Reply-To: References: Message-ID: Is it possible to play the generated chords as a melody by itself, without the original music over it? 2013/1/18 Alfredo Di Napoli > Congratulations! > Keep up the good work, especially in using Haskell at a commercial level :) > > Bye! > Alfredo > > > On 18 January 2013 07:34, Alp Mestanogullari wrote: > >> That's awesome, works like a charm on the samples I've tried it on! >> Cheers to the Chordify team, I will use it and give any useful feedback if >> I have any. >> >> >> On Fri, Jan 18, 2013 at 12:07 AM, Jos? Pedro Magalh?es wrote: >> >>> Hi all, >>> >>> I'd like to introduce Chordify [1], an online >>> music player that extracts chords from musical sources like Soundcloud, >>> Youtube or your own files, and shows you which chord to play when. Here's >>> an example song: >>> http://chordify.net/chords/passenger-let-her-go-official-video-passengermusic >>> >>> The aim of Chordify is to make state-of-the-art music technology >>> accessible to a broader audience. Behind the scenes, Chordify uses the >>> HarmTrace Haskell package to compute chords from audio. I've been working >>> on this project with a couple of colleagues for a while now, and recently >>> we have made the website public, free to use for everyone. >>> >>> We do not use Haskell for any of the frontend/user interface, but the >>> backend is entirely written in Haskell (and it uses pretty advanced >>> features, such as GADTs and type families [3]). We're particularly >>> interested in user feedback at this stage, so if you're interested in music >>> and could use an automatic chord transcription service, please try Chordify! >>> >>> >>> Cheers, >>> Pedro >>> >>> [1] http://chordify.net/ >>> [2] http://hackage.haskell.org/package/HarmTrace >>> [3] Jos? Pedro Magalh?es and W. Bas de Haas. Functional Modelling of >>> Musical Harmony: an Experience Report. In Proceedings of the 16th ACM >>> SIGPLAN International Conference on Functional Programming (ICFP'11), pp. >>> 156?162, ACM, 2011. http://dreixel.net/research/pdf/fmmh.pdf >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> >> -- >> Alp Mestanogullari >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.mvd at gmail.com Fri Jan 18 11:06:24 2013 From: petr.mvd at gmail.com (Petr P) Date: Fri, 18 Jan 2013 11:06:24 +0100 Subject: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students Message-ID: Dear Haskellers, could somebody recommend me study materials for learning Hindley-Milner type inference algorithm I could recommend to undergraduate students? The original paper is harder to understand, I'm looking for something more didactic. The students are familiar with the lambda calculus, natural deduction and System F. Thanks for help, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From noteed at gmail.com Fri Jan 18 11:12:23 2013 From: noteed at gmail.com (Vo Minh Thu) Date: Fri, 18 Jan 2013 11:12:23 +0100 Subject: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students In-Reply-To: References: Message-ID: 2013/1/18 Petr P : > Dear Haskellers, > > could somebody recommend me study materials for learning Hindley-Milner type > inference algorithm I could recommend to undergraduate students? The > original paper is harder to understand, I'm looking for something more > didactic. The students are familiar with the lambda calculus, natural > deduction and System F. I think I really liked Cardelli's paper Basic Polymorphic Typechecking, 1987 HTH, Thu From daniel.trstenjak at gmail.com Fri Jan 18 11:22:30 2013 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Fri, 18 Jan 2013 11:22:30 +0100 Subject: [Haskell-cafe] ANN: hgdbmi 0.2, GDB Machine Interface In-Reply-To: References: Message-ID: <20130118102230.GA4407@machine> Hi Alexander, On Thu, Jan 17, 2013 at 10:17:33PM +0100, Alexander Bernauer wrote: > I am happy to announce the second release of hgdbmi, a Haskell > implementation of the GDB Machine Interface. Nice project! :) > PS: This is my first serious Haskell package. If you see something > that you consider odd, I might have done this simply because I didn't > know better. I would appreciate if you would let me know in such a > case. Looking at the function names: have you got a c programming background? Instead of using these prefixes you could put the functions into separate modules. If the interface depends on the GDB version, than it could make sense to encode the GDB version into the module name, something like: Gdbmi.V7_4.Commands Greetings, Daniel From anton.dergunov at mail.ru Fri Jan 18 11:29:57 2013 From: anton.dergunov at mail.ru (=?UTF-8?B?QW50b24gRGVyZ3Vub3Y=?=) Date: Fri, 18 Jan 2013 14:29:57 +0400 Subject: [Haskell-cafe] =?utf-8?q?resources_for_learning_Hindley-Milner_ty?= =?utf-8?q?pe_inference_for_undergraduate_students?= In-Reply-To: References: Message-ID: <1358504997.701842403@f79.mail.ru> I also agree that Cardelli paper is great. It was also very useful for me to follow Python implementation provided in the following blog post: http://www.smallshire.org.uk/sufficientlysmall/2010/04/11/a-hindley-milner-type-inference-implementation-in-python/ I found it useful to investigate in Python debugger?how various terms were interpreted. You may also find useful implementations in Scala and Perl: http://dysphoria.net/2009/06/28/hindley-milner-type-inference-in-scala/ http://web.archive.org/web/20050911123640/http://www.cs.berkeley.edu/~nikitab/courses/cs263/hm.html Also, I have plans to read "Typing Haskell in Haskell" by Mark Jones and "Practical type inference for arbitrary-rank types" by Simon Peyton-Jones et. al. They are also related here, but not directly. -- Best Regards, Anton Dergunov ???????, 18 ?????? 2013, 11:12 +01:00 ?? Vo Minh Thu : >2013/1/18 Petr P < petr.mvd at gmail.com >: >> Dear Haskellers, >> >> could somebody recommend me study materials for learning Hindley-Milner type >> inference algorithm I could recommend to undergraduate students? The >> original paper is harder to understand, I'm looking for something more >> didactic. The students are familiar with the lambda calculus, natural >> deduction and System F. > >I think I really liked > >????Cardelli's paper Basic Polymorphic Typechecking, 1987 > >HTH, >Thu > >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe at haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Fri Jan 18 11:35:25 2013 From: tab at snarc.org (Vincent Hanquez) Date: Fri, 18 Jan 2013 11:35:25 +0100 Subject: [Haskell-cafe] ANN: crypto-pubkey: all your public key crypto algorithms belong to us. In-Reply-To: <20130115152729.6eb2629e@tritium.streitmacht.eu> References: <20130111225545.GA5972@snarc.org> <20130112141244.0efa703b@tritium.streitmacht.eu> <20130114113621.GA14529@snarc.org> <8940340.0CpOZgbCMF@linux-v7dw.site> <20130115084949.GA30518@snarc.org> <20130115152729.6eb2629e@tritium.streitmacht.eu> Message-ID: <20130118103525.GA7473@snarc.org> On Tue, Jan 15, 2013 at 03:27:29PM +0100, Ertugrul S?ylemez wrote: > Vincent Hanquez wrote: > > > Yes, the performance are terrible in term of integers. As the library > > is specific to public key algorithm, i just can't reasonable work on > > 64 bits integer :-), and multiprecision integers is the only way to > > go. > > > > I'm on-and-off working on some mutable mpi library to be able to > > define pure function that do the necessary stuff (i.e. expmod, mulmod, > > etc..) > > > > I'm hoping this could be reasonably competitive with a C mpi library, > > but time will tell. > > It's a waste of time. In my benchmarks Haskell Integer outperformed > equivalent (sane) C implementations using GMP's mpz_* interface. You > would be reinventing GMP's mpn_* interface and a custom memory manager > to be able to match the speed of Integer. I don't plan to match (or outperform) the speed of integer for simple operations. My experiment is about overtaking haskell's Integer in composite operations (mainly for non naive expmod) by operating with mutable integers and direct access to the representation (the second point is somewhat what Daniel is doing using integer-gmp). One valid way to solve this problem, would be to export more GMP function to haskell without wrapping them for referencial transparency. However the GMP dependencies is not always welcome and the integration of GMP is slightly special (primops), which is why i'm not taking this course of action. > The things that were slower than equivalent C code were not related to > Integer, but mostly to data structures like Set in my case, which was > the motivation for me to write the 'quickset' library. AFAIK, Haskell's Integer expmod algorithms have no way to rival with real world implementation of expmod, which make all pubkey operations quite slow compare to their C friends. There's also the question of timing security with a pure & GCed interface. -- Vincent From apfelmus at quantentunnel.de Fri Jan 18 12:08:15 2013 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri, 18 Jan 2013 12:08:15 +0100 Subject: [Haskell-cafe] ANNOUNCE: MFlow 0.2 In-Reply-To: References: Message-ID: Alberto G. Corona wrote: > Hello. haskellers and, specially, web developpers. > > This is the second version of MFlow, a deep-first effort in the development > of a platform for web applications at the higher level, by including as > much haskell magic as possible. It is at the same time experimental and > intended to be used in industry. I believe that haskell will not have its > chance in the Web if it does not bring unique advantages and challenging > paradigms beyond speed and type safety. > > Deep-first means that the effort is more in the addition higher level > features rather than in being complete and bug free, with the conviction > that feedback from real usage at the highest level is the best guide for > development. > > Rather than to mimic other platforms in other languages, MFlow is as > Haskell'ish as possible, and introduces new approaches like statefulness, > event sourcing, back-execution, composable, active, self contained widgets > and persistent STM. All of them collaborate to create a high level > environment for web programming. > > This release adds bidings for WAI, blaze-html, stateful AJAX, active > widgets, requirements, content management, multilanguage and URLs to pages > inside stateful procedures. > > The package: > [http://hackage.haskell.org/package/MFlow > > The entry in my blog, with the announcement and the philosophy behind > http://haskell-web.blogspot.com.es/2013/01/announce-mflow-02.html For some reason, your blog posts are not displayed in my browser (Chrome). I block all cookies and I'm using adblock, though. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From es at ertes.de Fri Jan 18 12:19:19 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Fri, 18 Jan 2013 12:19:19 +0100 Subject: [Haskell-cafe] ANNOUNCE: MFlow 0.2 References: Message-ID: <20130118121919.278ad60a@tritium.streitmacht.eu> Heinrich Apfelmus wrote: > For some reason, your blog posts are not displayed in my browser > (Chrome). I block all cookies and I'm using adblock, though. Blogger.com blogs often need JavaScript to display anything at all. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From jan.stolarek at p.lodz.pl Fri Jan 18 13:19:49 2013 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Fri, 18 Jan 2013 13:19:49 +0100 Subject: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students In-Reply-To: References: Message-ID: <201301181319.49513.jan.stolarek@p.lodz.pl> Dnia pi?tek, 18 stycznia 2013, Petr P napisa?: > for learning Hindley-Milner type inference algorithm I could recommend to > undergraduate students? The original paper is harder to understand, I'm > looking for something more didactic. The students are familiar with the > lambda calculus, natural deduction and System F. Perhaps chapters on H-M from Appel's "Modern compiler implementation in C/Java" would be good? Janek From rustompmody at gmail.com Fri Jan 18 13:37:29 2013 From: rustompmody at gmail.com (Rustom Mody) Date: Fri, 18 Jan 2013 18:07:29 +0530 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell In-Reply-To: References: Message-ID: On Fri, Jan 18, 2013 at 2:09 PM, Thiago Negri wrote: > Is it possible to play the generated chords as a melody by itself, without > the original music over it? > > Super work! I was meaning to ask something similar -- can we get out something of the music that chordify has reverse engineered -- maybe midi maybe musicxml? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Fri Jan 18 13:44:59 2013 From: rustompmody at gmail.com (Rustom Mody) Date: Fri, 18 Jan 2013 18:14:59 +0530 Subject: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students In-Reply-To: <201301181319.49513.jan.stolarek@p.lodz.pl> References: <201301181319.49513.jan.stolarek@p.lodz.pl> Message-ID: On Fri, Jan 18, 2013 at 5:49 PM, Jan Stolarek wrote: > Dnia pi?tek, 18 stycznia 2013, Petr P napisa?: > > for learning Hindley-Milner type inference algorithm I could recommend to > > undergraduate students? The original paper is harder to understand, I'm > > looking for something more didactic. The students are familiar with the > > lambda calculus, natural deduction and System F. > What is the current opinion of Mark Jones Typing haskell in haskell? http://web.cecs.pdx.edu/~mpj/thih/TypingHaskellInHaskell.html [Note This is to add to the question more than the answer] -------------- next part -------------- An HTML attachment was scrubbed... URL: From agocorona at gmail.com Fri Jan 18 16:09:11 2013 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri, 18 Jan 2013 16:09:11 +0100 Subject: [Haskell-cafe] ANNOUNCE: MFlow 0.2 In-Reply-To: <20130118121919.278ad60a@tritium.streitmacht.eu> References: <20130118121919.278ad60a@tritium.streitmacht.eu> Message-ID: The blog has a dynamic template. and I?m afraid that it needs javascript. Sorry. I will paste the rest of the blog entry: [Continue from the first message] .... Statefulness means that the flow of execution is right in front of the eyes of the programmer, rather that in the spaghetti code of the event-handling model, the goto of the XXI century. it also means that the entire session is in a procedure, so the session data need no trickery. But, like in the stateless case, any page in the flow could have a direct URL. [1] Event sourcing in combination with statefulness means automatic logging of all the events and automatic recovery of the execution state of the server procedure and its data, thanks to the Workflow monad transformer [2]. So the server procedure can be stopped after timeout and restarted by the application server when the user invokes it. The programmer can determine the timeout and for how long the state is stored. Back button management: the flow of execution can run back when the back button is pressed [3]. Thanks to a monad transformer. In combination with event sourcing, this means automatic rollback of user session data. So if the user want to undo his last item in the shopping cart, he only has to press the back button. User interface: It is made of self contained pieces called widgets, made around the formlet concept, so they compose gracefully with applicative operators and other extra operators. A MFlow widget is more like the widgets of XWindows, ASP.NET or JavaServer Faces: they have their own HTML formatting, their own behaviours and interact with the server via AJAX, they execute actions when activated and they return statically typed data. They declare their required scripts, CSS links and server procedures in the form of requirements to the requirement service. They include the server and client code in the same piece of text. Being self contained and typed, they can be shared and plugged with a minimum of configuration and instructions. The URL links are also widgets or elements of widgets and return data to the same flow, so no spaguetty event handling occur, unless the programmer need out-of-flow links. This versions includes some active widgets with server-side controls for creating them [4]. Bindings: wai-warp, blaze-html, xhtml, HSP, hack. Persistence and transactions: Global data can be transacted with any kind of persistence framework. MFlow internally uses TCache [5], which provides with persistent STM references (DBRefs). Their serialization can be configured. For rapid prototyping, they have default persistence in files. Just add a Read-Show or a Binary instance for your data and you can have a persistent, transactional DBRef to it. Use them like you use TVars. TCache can index text and register fields. It has a simple query language. Data can be accessed by key or by any indexed field. EXAMPLE: The human mind learn by examples. There is a online demo for some of the features that you can play with and you can download the code [6] [0] http://hackage.haskell.org/package/MFlow [1] http://haskell-web.blogspot.com/2013/01/stateful-but-stateless-at-last-thanks.html [2] http://hackage.haskell.org/package/Workflow [3] http://haskell-web.blogspot.com.es/2012/03/failback-monad.html [4] http://haskell-web.blogspot.com.es/2013/01/now-example-of-use-of-active-widget.html [5] http://hackage.haskell.org/package/TCache [6] http://81.169.134.95:8081 2013/1/18 Ertugrul S?ylemez > Heinrich Apfelmus wrote: > > > For some reason, your blog posts are not displayed in my browser > > (Chrome). I block all cookies and I'm using adblock, though. > > Blogger.com blogs often need JavaScript to display anything at all. > > > Greets, > Ertugrul > > -- > Not to be or to be and (not to be or to be and (not to be or to be and > (not to be or to be and ... that is the list monad. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen.tetley at gmail.com Fri Jan 18 18:25:37 2013 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri, 18 Jan 2013 17:25:37 +0000 Subject: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students In-Reply-To: References: Message-ID: There is a summary paper by Sunil Kothari and James L. Cladwell covering the algorithms M, J and W with informal presentations plus code available in Ocaml. Paper is on Citeseer, code is available from Sunil Kothari's home page. Martin Grabmueller has a tutorial implementation of algorithm W in Haskell: http://www.grabmueller.de/martin/www/pub/pub.en.html On 18 January 2013 10:06, Petr P wrote: > Dear Haskellers, > > could somebody recommend me study materials for learning Hindley-Milner type > inference algorithm I could recommend to undergraduate students? From acopton at gmail.com Fri Jan 18 20:26:10 2013 From: acopton at gmail.com (Alexander Bernauer) Date: Fri, 18 Jan 2013 20:26:10 +0100 Subject: [Haskell-cafe] ANN: hgdbmi 0.2, GDB Machine Interface In-Reply-To: <20130118102230.GA4407@machine> References: <20130118102230.GA4407@machine> Message-ID: Hi Daniel thank you for your feedback. On Fri, Jan 18, 2013 at 11:22 AM, Daniel Trstenjak wrote: > Looking at the function names: have you got a c programming background? > Instead of using these prefixes you could put the functions into separate > modules. Although I do have some background in C programming, these naming schemes are not my idea. Instead the function names match the names of the corresponding GDB/MI commands. I thought it would make sense to use these names for ease of reference. Given this, would you still prefer them being grouped in separate modules? > If the interface depends on the GDB version, than it could make sense to > encode the GDB version into the module name, something like: > Gdbmi.V7_4.Commands Gdbmi.Commands is not the only module that depends on the GDB version. GDB/MI is in general still evolving and GDB's compliance with the documentation keeps on changing on all levels. So I would have to maintain all hgdbmi modules for each GDB version. Do you think this makes sense and is worth the effort? Greetings, Alex From nicolasbock at gmail.com Sat Jan 19 00:25:31 2013 From: nicolasbock at gmail.com (Nicolas Bock) Date: Fri, 18 Jan 2013 16:25:31 -0700 Subject: [Haskell-cafe] regular expression sub-expression matching Message-ID: Hello list, I was wondering whether there is a way to do what the following python code does in haskell: import re result = re.compile("M\(([0-9]+),([0-9]+)\) *= *([0-9.eE-]+);").search("M(1,2) = 0.1e-3;") if result: print(result.group(1), result.group(2), result.group(3)) Basically I would like to pattern match parts of a string and return the matches. I have looked at Text.Regex.Posix but (of course I might just not have understood the functions in there properly) it seems as if it does not provide anything like python's re module. Thanks already, nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Sat Jan 19 00:47:31 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sat, 19 Jan 2013 01:47:31 +0200 Subject: [Haskell-cafe] regular expression sub-expression matching In-Reply-To: References: Message-ID: <20130118234731.GA15776@sniper> * Nicolas Bock [2013-01-18 16:25:31-0700] > Hello list, > > I was wondering whether there is a way to do what the following python code > does in haskell: > > import re > > result = re.compile("M\(([0-9]+),([0-9]+)\) *= > *([0-9.eE-]+);").search("M(1,2) = 0.1e-3;") > if result: > print(result.group(1), result.group(2), result.group(3)) > > Basically I would like to pattern match parts of a string and return the > matches. I have looked at Text.Regex.Posix but (of course I might just not > have understood the functions in there properly) it seems as if it does not > provide anything like python's re module. Take a look at the regex-applicative package. http://hackage.haskell.org/packages/archive/regex-applicative/0.2.1/doc/html/Text-Regex-Applicative.html Roman From bob at redivi.com Sat Jan 19 01:52:54 2013 From: bob at redivi.com (Bob Ippolito) Date: Fri, 18 Jan 2013 16:52:54 -0800 Subject: [Haskell-cafe] regular expression sub-expression matching In-Reply-To: References: Message-ID: Note that Haskell doesn't convert "\(" to "\\(" like Python does, so the regex string has been changed. It's not so easy to figure out how to use this library from the documentation because of all the typeclass trickery. h> import Text.Regexp.Posix (getAllTextSubmatches, (=~)) h> getAllTextSubmatches ("M(1,2) = 0.1e-3;" =~ "M\\(([0-9]+),([0-9]+)\\) *= *([0-9.eE-]+);") :: [String] ["M(1,2) = 0.1e-3;","1","2","0.1e-3"] If it doesn't match, you'll get an empty list. You can join the tail of the match list together with Data.List.intercalate, and print it out with putStrLn. The if null case would just return (). To demonstrate some of the typeclass trickery going on here, you could ask for the results as an Array with Int indexes of String. h> import Text.Regexp.Posix (getAllTextSubmatches, (=~)) h> import Data.Array ((!), Array) h> let matches = getAllTextSubmatches ("M(1,2) = 0.1e-3;" =~ "M\\(([0-9]+),([0-9]+)\\) *= *([0-9.eE-]+);") :: Array Int String h> matches array (0,3) [(0,"M(1,2) = 0.1e-3;"),(1,"1"),(2,"2"),(3,"0.1e-3")] h> map (matches !) [1..3] ["1","2","0.1e-3"] -bob On Fri, Jan 18, 2013 at 3:25 PM, Nicolas Bock wrote: > Hello list, > > I was wondering whether there is a way to do what the following python > code does in haskell: > > import re > > result = re.compile("M\(([0-9]+),([0-9]+)\) *= > *([0-9.eE-]+);").search("M(1,2) = 0.1e-3;") > if result: > print(result.group(1), result.group(2), result.group(3)) > > Basically I would like to pattern match parts of a string and return the > matches. I have looked at Text.Regex.Posix but (of course I might just not > have understood the functions in there properly) it seems as if it does not > provide anything like python's re module. > > Thanks already, > > nick > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleg at okmij.org Sat Jan 19 06:57:07 2013 From: oleg at okmij.org (oleg at okmij.org) Date: 19 Jan 2013 05:57:07 -0000 Subject: [Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students Message-ID: <20130119055707.61948.qmail@www1.g3.pair.com> Petr Pudlak wrote: > could somebody recommend me study materials for learning Hindley-Milner > type inference algorithm I could recommend to undergraduate students? Perhaps you might like a two-lecture course for undergraduates, which uses Haskell throughout http://okmij.org/ftp/Haskell/AlgorithmsH.html#teval It explained HM type inference in a slightly different way, strongly emphasizing type inference as a non-standard interpretation. The second main idea was relating polymorphism and `inlining' (copying). Type schemas were then introduced as an optimization, to inlining. It becomes clear why it is unsound to infer a polymorphic type for ref []: expressions of polymorphic types are always inlined (conceptually, at least), which goes against the dynamic semantics of reference cells. The lectures also show how to infer not only the type but also the type environment. This inference helps to make the point that `tests' cannot replace typing. We can type check open expressions (and infer the minimal environment they make sense to use in). We cannot run (that is, dynamically check) open expressions. From daniel.trstenjak at gmail.com Sat Jan 19 13:14:39 2013 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Sat, 19 Jan 2013 13:14:39 +0100 Subject: [Haskell-cafe] ANN: hgdbmi 0.2, GDB Machine Interface In-Reply-To: References: <20130118102230.GA4407@machine> Message-ID: <20130119121439.GA2883@machine> Hi Alex, On Fri, Jan 18, 2013 at 08:26:10PM +0100, Alexander Bernauer wrote: > I thought it would make sense to use these names for ease of > reference. Given this, would you still prefer them being grouped in > separate modules? Yes, I still think that having separate modules can be beneficial, also for the ease of reference. > Gdbmi.Commands is not the only module that depends on the GDB version. I thought of putting all of your modules under the version indicating module. > GDB/MI is in general still evolving and GDB's compliance with the > documentation keeps on changing on all levels. So I would have to > maintain all hgdbmi modules for each GDB version. Do you think this > makes sense and is worth the effort? At the current level of development, the version indicating module might be unnecessary and overhead, but you also don't have to support multiple GDB versions. It's just a more explicit way of telling your user for which GDB version the binding should work. You can reuse most of your code for several GDB versions. Supposed you've implemented the GDB 7.4 bindings and now would like to support a new command in GDB 7.5 and all other commands behave still in the same way as in version 7.4. module Gdbmi.V7_5.Commands (module Gdbmi.V7_4.Commands, newCommand) where newCommand = ... Greetings, Daniel From jpm at cs.uu.nl Sat Jan 19 15:34:42 2013 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Sat, 19 Jan 2013 14:34:42 +0000 Subject: [Haskell-cafe] Chordify, a new web startup using Haskell In-Reply-To: References: Message-ID: Hi all, Thanks for all the feedback and kind words. Yes, we're planning to have export to PDF/midi options soon. We have plenty of ideas, but limited time :-/ User feedback is collected (and voted for) on https://chordify.uservoice.com/ Thanks, Pedro On Fri, Jan 18, 2013 at 12:37 PM, Rustom Mody wrote: > On Fri, Jan 18, 2013 at 2:09 PM, Thiago Negri wrote: > >> Is it possible to play the generated chords as a melody by itself, >> without the original music over it? >> >> > Super work! > I was meaning to ask something similar -- can we get out something of the > music that chordify has reverse engineered -- maybe midi maybe musicxml? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Sat Jan 19 18:35:47 2013 From: michael at snoyman.com (Michael Snoyman) Date: Sat, 19 Jan 2013 19:35:47 +0200 Subject: [Haskell-cafe] Stackage mailing list In-Reply-To: <1356169816.5387.4.camel@kirk> References: <1356169816.5387.4.camel@kirk> Message-ID: I've now created a Stackage mailing list: https://groups.google.com/d/forum/stackage I encourage anyone who's interested to join the list. On Sat, Dec 22, 2012 at 11:50 AM, Joachim Breitner wrote: > Dear Michael, > > I?m wondering if I missed something, but is there a mailing list for > stackage? Or has one of the standard lists (-cafe, libraries) been > designated for questions about stackage? > > > What I want to know is if you plan to provide a website for stackage > soon where the list of included packages and their dependencies, > including the tested and approved version numbers can be seen. I?d like > to take that and integrate it on > http://people.debian.org/~nomeata/platform.html > and > http://people.debian.org/~nomeata/hackagevsdebian.html > > Also, once you do that, it should be possible to add Stackage to the > list of Distributions listed on hackage, so that on hackage one already > sees the package?s stackage status and whether it lags behind there. The > integrations is rather simple, just provide a file with that format: > http://people.debian.org/~nomeata/cabalDebianMap.txt > and bug the hackage maintainers to add it. > > Greetings, > Joachim > > -- > Joachim "nomeata" Breitner > mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C > xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.pennebaker at gmail.com Sat Jan 19 19:42:01 2013 From: andrew.pennebaker at gmail.com (Andrew Pennebaker) Date: Sat, 19 Jan 2013 13:42:01 -0500 Subject: [Haskell-cafe] Mobile app development? Message-ID: There are currently very few options, especially free and open source options, when it comes to developing cross-platform mobile applications. It's basically web apps with JavaScript, or C++. If Haskell supported app development on Android, iOS, and Windows RT, that alone would bring in more developers. Similarly, there are very few languages for mobile development that take advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an amazing selling point. Can we please prioritize mobile support? I'd much rather write everything in ML than PhoneGap. -- Cheers, Andrew Pennebaker www.yellosoft.us -------------- next part -------------- An HTML attachment was scrubbed... URL: From kc1956 at gmail.com Sat Jan 19 19:58:03 2013 From: kc1956 at gmail.com (KC) Date: Sat, 19 Jan 2013 10:58:03 -0800 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: You would need native compilers for all the platforms and/or virtual machine technology. Might be easier to have the browser connect to a Haskell app. On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker wrote: > There are currently very few options, especially free and open source > options, when it comes to developing cross-platform mobile applications. > It's basically web apps with JavaScript, or C++. If Haskell supported app > development on Android, iOS, and Windows RT, that alone would bring in more > developers. > > Similarly, there are very few languages for mobile development that take > advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an > amazing selling point. Can we please prioritize mobile support? I'd much > rather write everything in ML than PhoneGap. > > -- > Cheers, > > Andrew Pennebaker > www.yellosoft.us > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- -- Regards, KC From kc1956 at gmail.com Sat Jan 19 21:41:23 2013 From: kc1956 at gmail.com (KC) Date: Sat, 19 Jan 2013 12:41:23 -0800 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: Then it looks as if the easier implementation would be small Haskell VM's for the various platforms with a byte code compiler. I do not believe the JVM supports all the optimizations GHC can do. Oh wait! Can the LLVM be easily ported to do this? On Sat, Jan 19, 2013 at 11:40 AM, Andrew Pennebaker wrote: > >> Might be easier to have the browser connect to a Haskell app. > > > Not all apps can be run as thin clients. 3D video games and other intensive > programs aren't easily done as thin clients. Mobile Haskell would be very > powerful, because concurrency and parallelism aren't something the C-family > languages are supporting that well. > >> >> >> >> On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker >> wrote: >> > There are currently very few options, especially free and open source >> > options, when it comes to developing cross-platform mobile applications. >> > It's basically web apps with JavaScript, or C++. If Haskell supported >> > app >> > development on Android, iOS, and Windows RT, that alone would bring in >> > more >> > developers. >> > >> > Similarly, there are very few languages for mobile development that take >> > advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an >> > amazing selling point. Can we please prioritize mobile support? I'd much >> > rather write everything in ML than PhoneGap. >> > >> > -- >> > Cheers, >> > >> > Andrew Pennebaker >> > www.yellosoft.us >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> >> >> -- >> -- >> Regards, >> KC > > > > > -- > Cheers, > > Andrew Pennebaker > www.yellosoft.us -- -- Regards, KC From bob at redivi.com Sat Jan 19 21:48:06 2013 From: bob at redivi.com (Bob Ippolito) Date: Sat, 19 Jan 2013 12:48:06 -0800 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: LLVM probably already supports producing native code for all of the architectures for the mobile platforms. The non-trivial parts are probably getting GHC to cross-compile and wrapping all of the libraries you need for the platforms you want to support. On Sat, Jan 19, 2013 at 12:41 PM, KC wrote: > Then it looks as if the easier implementation would be small Haskell > VM's for the various platforms with a byte code compiler. > I do not believe the JVM supports all the optimizations GHC can do. > > Oh wait! > Can the LLVM be easily ported to do this? > > > On Sat, Jan 19, 2013 at 11:40 AM, Andrew Pennebaker > wrote: > > > >> Might be easier to have the browser connect to a Haskell app. > > > > > > Not all apps can be run as thin clients. 3D video games and other > intensive > > programs aren't easily done as thin clients. Mobile Haskell would be very > > powerful, because concurrency and parallelism aren't something the > C-family > > languages are supporting that well. > > > >> > >> > >> > >> On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker > >> wrote: > >> > There are currently very few options, especially free and open source > >> > options, when it comes to developing cross-platform mobile > applications. > >> > It's basically web apps with JavaScript, or C++. If Haskell supported > >> > app > >> > development on Android, iOS, and Windows RT, that alone would bring in > >> > more > >> > developers. > >> > > >> > Similarly, there are very few languages for mobile development that > take > >> > advantage of multiple cores and multiple CPUs. Haskell's `parmap` is > an > >> > amazing selling point. Can we please prioritize mobile support? I'd > much > >> > rather write everything in ML than PhoneGap. > >> > > >> > -- > >> > Cheers, > >> > > >> > Andrew Pennebaker > >> > www.yellosoft.us > >> > > >> > _______________________________________________ > >> > Haskell-Cafe mailing list > >> > Haskell-Cafe at haskell.org > >> > http://www.haskell.org/mailman/listinfo/haskell-cafe > >> > > >> > >> > >> > >> -- > >> -- > >> Regards, > >> KC > > > > > > > > > > -- > > Cheers, > > > > Andrew Pennebaker > > www.yellosoft.us > > > > -- > -- > Regards, > KC > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan.huesken at posteo.de Sat Jan 19 22:29:36 2013 From: nathan.huesken at posteo.de (=?ISO-8859-1?Q?Nathan_H=FCsken?=) Date: Sat, 19 Jan 2013 22:29:36 +0100 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: <50FB1040.2030000@posteo.de> Well, to target javascript there is haste [1] and ghcjs [2]. Ghc can target iOS [3]. Recently I managed to get ghc to target android working (this still needs some work): [4]. And there is also an active effort by Stephen Paul Weber to get blackberry working in the devs-ghc mailinglist. So my impression is, that multiplatform haskell is on its way. Of couse, ffi bindings for all these platforms would be needed to get serious. [1]: https://github.com/valderman/haste-compiler.git [2]: https://github.com/ghcjs/ghcjs [3]: https://github.com/ghc-ios/ghc/wiki [4]: https://github.com/RudolfVonKrugstein/jshaskell-blog/blob/master/android_ghc/android_ghc.md On 01/19/2013 09:48 PM, Bob Ippolito wrote: > LLVM probably already supports producing native code for all of the > architectures for the mobile platforms. The non-trivial parts are probably > getting GHC to cross-compile and wrapping all of the libraries you need for > the platforms you want to support. > > > On Sat, Jan 19, 2013 at 12:41 PM, KC wrote: > >> Then it looks as if the easier implementation would be small Haskell >> VM's for the various platforms with a byte code compiler. >> I do not believe the JVM supports all the optimizations GHC can do. >> >> Oh wait! >> Can the LLVM be easily ported to do this? >> >> >> On Sat, Jan 19, 2013 at 11:40 AM, Andrew Pennebaker >> wrote: >>> >>>> Might be easier to have the browser connect to a Haskell app. >>> >>> >>> Not all apps can be run as thin clients. 3D video games and other >> intensive >>> programs aren't easily done as thin clients. Mobile Haskell would be very >>> powerful, because concurrency and parallelism aren't something the >> C-family >>> languages are supporting that well. >>> >>>> >>>> >>>> >>>> On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker >>>> wrote: >>>>> There are currently very few options, especially free and open source >>>>> options, when it comes to developing cross-platform mobile >> applications. >>>>> It's basically web apps with JavaScript, or C++. If Haskell supported >>>>> app >>>>> development on Android, iOS, and Windows RT, that alone would bring in >>>>> more >>>>> developers. >>>>> >>>>> Similarly, there are very few languages for mobile development that >> take >>>>> advantage of multiple cores and multiple CPUs. Haskell's `parmap` is >> an >>>>> amazing selling point. Can we please prioritize mobile support? I'd >> much >>>>> rather write everything in ML than PhoneGap. >>>>> >>>>> -- >>>>> Cheers, >>>>> >>>>> Andrew Pennebaker >>>>> www.yellosoft.us >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe at haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>> >>>> >>>> >>>> -- >>>> -- >>>> Regards, >>>> KC >>> >>> >>> >>> >>> -- >>> Cheers, >>> >>> Andrew Pennebaker >>> www.yellosoft.us >> >> >> >> -- >> -- >> Regards, >> KC >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From petr.mvd at gmail.com Sun Jan 20 00:56:28 2013 From: petr.mvd at gmail.com (Petr P) Date: Sun, 20 Jan 2013 00:56:28 +0100 Subject: [Haskell-cafe] Why should we write "a `par` b `pseq` (f a b)" instead of "a `par` b `par` (f a b)"? Message-ID: Dear Haskellers, I've been playing with par and pseq, and I wonder: Is there any reason to use a `par` b `pseq` (a + b) instead of a `par` b `par` (a + b) except that the second version sparks twice instead of just once (which probably degrades performance a bit)? It seems to me that the second variant would work as well: The main thread would block on one of the sparked computations, but the other one would still be evaluated in parallel. The second variant seems to have one additional advantage: If the function that combines 'a' and 'b' isn't strict (and perhaps we don't know that in advance), the main thread won't be blocked by evaluating the computation it doesn't need. Like a `par` b `pseq` (const a b) will block until both 'a' and 'b' are evaluated, but a `par` b `par` (const a b) will finish as soon as 'a' is evaluated. I found this link on SO: Why do we need 'seq' or 'pseq' with 'par' in Haskell? < http://stackoverflow.com/q/4576734/1333025> but it doesn't really solve this objection. Thanks for help, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Sun Jan 20 06:50:16 2013 From: tab at snarc.org (Vincent Hanquez) Date: Sun, 20 Jan 2013 06:50:16 +0100 Subject: [Haskell-cafe] [ANN] tls-extra 0.6.1 - security update, please upgrade. Message-ID: <20130120055015.GA7912@snarc.org> Hi cafe, this is a security advisory for tls-extra < 0.6.1 which are all vulnerable to bad certificate validation. Some part of the certificate validation procedure were missing (relying on the work-in-progress x509 v3 extensions), and because of this anyone with a correct end-entity certificate can issue certificate for any arbitrary domain, i.e. acting as a CA. This problem has been fixed in tls-extra 0.6.1, and I advise everyone to upgrade as soon as possible. Despite a very serious flaw in the certificate validation, I'm happy that the code is seeing some audits, and would want to thanks Ertugrul S?ylemez for the findings [1]. [1] https://github.com/vincenthz/hs-tls/issues/29 -- Vincent From mail at joachim-breitner.de Sun Jan 20 10:57:44 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Sun, 20 Jan 2013 10:57:44 +0100 Subject: [Haskell-cafe] Inferring rewrite rules for higher order functions Message-ID: <1358675864.4579.3.camel@kirk> Dear list, with rewrite rules I can tell the compiler to replace "map id" by "id", but I still have to write that rule by hand. Does anyone of you know about research into inferring such a rewrite rule automatically? I could imagine that for a function of type "f :: some -> args -> T a -> T b" and not-too-bad type constructors T it might be possible under what conditions on "some" and "args" infer when "f arg1 arg2 = id" holds, and if the conditions are fulfilled by functions like "id", generate a rewrite rule "f id id = id" automatically. Thanks, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From nomeata at debian.org Sun Jan 20 11:01:22 2013 From: nomeata at debian.org (Joachim Breitner) Date: Sun, 20 Jan 2013 11:01:22 +0100 Subject: [Haskell-cafe] [ANN] tls-extra 0.6.1 - security update, please upgrade. In-Reply-To: <20130120055015.GA7912@snarc.org> References: <20130120055015.GA7912@snarc.org> Message-ID: <1358676082.4579.6.camel@kirk> Hi, Am Sonntag, den 20.01.2013, 06:50 +0100 schrieb Vincent Hanquez: > this is a security advisory for tls-extra < 0.6.1 which are all vulnerable to bad > certificate validation. > > Some part of the certificate validation procedure were missing (relying on the > work-in-progress x509 v3 extensions), and because of this anyone with a correct > end-entity certificate can issue certificate for any arbitrary domain, i.e. > acting as a CA. > > This problem has been fixed in tls-extra 0.6.1, and I advise everyone to upgrade as > soon as possible. > > Despite a very serious flaw in the certificate validation, I'm happy that the > code is seeing some audits, and would want to thanks Ertugrul S?ylemez for the > findings [1]. Debian ships tls-extras 0.4.6 in what will become wheezy, and due to the freeze upgrading to a new major upstream release is not acceptable. Would it be possible for you to create a 0.4.6.1 with this bugfix included? Thanks a lot, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata -------------- 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: From jan.stolarek at p.lodz.pl Sun Jan 20 11:21:32 2013 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Sun, 20 Jan 2013 11:21:32 +0100 Subject: [Haskell-cafe] Inferring rewrite rules for higher order functions In-Reply-To: <1358675864.4579.3.camel@kirk> References: <1358675864.4579.3.camel@kirk> Message-ID: <201301201121.33053.jan.stolarek@p.lodz.pl> The only paper that comes to my mind is Wadler's "Theorems for free". It's an old one and not exactly about rewrite rules, but it may be a good starting point. Janek From doaitse at swierstra.net Sun Jan 20 14:29:41 2013 From: doaitse at swierstra.net (Doaitse Swierstra) Date: Sun, 20 Jan 2013 14:29:41 +0100 Subject: [Haskell-cafe] Summer school on Applied Functional Programming at Utrecht University; deadline for registration May 15 Message-ID: <49036EEC-AFE6-44CD-93D8-F9E55FE534FD@swierstra.net> Again we will teach an "Applied Functional Programming Summer in Haskell" school this year at Utrecht University. In the previous four occasions students were all very happy with the school and we plan to repeat this success this year. Among the intended audience are prospective master students who gained an interest in Functional Programming, e.g. by taking a general course on programming languages, and want to learn more about Haskell and its typical programming patterns. In previous years we have taught an introductory part (advanced bachelor level), an advanced part (beginning master level) and a shared part for both groups. Topics covered are, besides some examples of domain specific languages, also monads, monad transformers, arrows, parser combinators and self-analysing programs, underlying principles, type inferencing, etc. Half of the course time is spent on a larger programming exercise; you can also come with a problem of your own if you want, and get help from the Utrecht University Software Technology group in finding the proper Haskell idioms, tools and libraries, for solving it. Important links: -- our own page where we supply information based on questions asked http://www.cs.uu.nl/wiki/USCS/ -- on this page you can find the poster you can print and hang somewhere (why not your office door): Furthermore we ask for your cooperation to bring this announcement under the attention of potential participants. Best, Doaitse Swierstra, Atze Dijkstra and Johan Jeuring -------------- next part -------------- An HTML attachment was scrubbed... URL: From waldmann at imn.htwk-leipzig.de Sun Jan 20 14:34:54 2013 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Sun, 20 Jan 2013 13:34:54 +0000 (UTC) Subject: [Haskell-cafe] =?utf-8?q?Why_should_we_write_=22a_=60par=60_b_=60?= =?utf-8?b?cHNlcWAgKGYgYSBiKSIgaW5zdGVhZCBvZiAiYSBgcGFyYCBiIGBwYXJg?= =?utf-8?b?IChmIGEgYikiPw==?= References: Message-ID: Petr P gmail.com> writes: > Is there any reason to use > ??a `par` b `pseq` (a + b) > instead of > ??a `par` b `par` (a + b) (better ask this on parallel-haskell?) > It seems to me that the second variant would work as well: > The main thread would block on one of the sparked computations, I think the main thread would not block at all. Instead, it would start to evaluate a (or b) right away, since (+) is strict, thus duplicating the work of a spark, and causing the spark to fizzle. Why does it work in a `par` b `pseq` a+b ? I am not even sure - there might be a race condition: assume that evaluation (to WHNF) of b (and of a) takes a long time, but b (in the main thread) finishes shortly before a does (in the spark), then the spark still fizzles and its work was in vain? J.W. From Ramana.Kumar at cl.cam.ac.uk Sun Jan 20 15:13:40 2013 From: Ramana.Kumar at cl.cam.ac.uk (Ramana Kumar) Date: Sun, 20 Jan 2013 14:13:40 +0000 Subject: [Haskell-cafe] Inferring rewrite rules for higher order functions In-Reply-To: <1358675864.4579.3.camel@kirk> References: <1358675864.4579.3.camel@kirk> Message-ID: Work on deforestation might also be relevant. On Sun, Jan 20, 2013 at 9:57 AM, Joachim Breitner wrote: > Dear list, > > with rewrite rules I can tell the compiler to replace "map id" by "id", > but I still have to write that rule by hand. > > Does anyone of you know about research into inferring such a rewrite > rule automatically? I could imagine that for a function of type "f :: > some -> args -> T a -> T b" and not-too-bad type constructors T it might > be possible under what conditions on "some" and "args" infer when "f > arg1 arg2 = id" holds, and if the conditions are fulfilled by functions > like "id", generate a rewrite rule "f id id = id" automatically. > > Thanks, > Joachim > -- > Joachim "nomeata" Breitner > mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C > xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Sun Jan 20 17:21:56 2013 From: tab at snarc.org (Vincent Hanquez) Date: Sun, 20 Jan 2013 17:21:56 +0100 Subject: [Haskell-cafe] [ANN] tls-extra 0.6.1 - security update, please upgrade. In-Reply-To: <1358676082.4579.6.camel@kirk> References: <20130120055015.GA7912@snarc.org> <1358676082.4579.6.camel@kirk> Message-ID: <20130120162156.GA13747@snarc.org> On Sun, Jan 20, 2013 at 11:01:22AM +0100, Joachim Breitner wrote: > Debian ships tls-extras 0.4.6 in what will become wheezy, and due to the > freeze upgrading to a new major upstream release is not acceptable. > Would it be possible for you to create a 0.4.6.1 with this bugfix > included? (wow, the tls packages stack are quite obsolete) Apart from the fact that it took me a while to rebase to this version, I just uploaded 0.4.6.1. it compiles but got minimal testing. -- Vincent From vincent.berthoux at gmail.com Sun Jan 20 17:22:17 2013 From: vincent.berthoux at gmail.com (Vincent Berthoux) Date: Sun, 20 Jan 2013 17:22:17 +0100 Subject: [Haskell-cafe] [ANNOUNCE] JuicyPixels 3.0 Message-ID: Hello haskellers, I'm presenting the third version of JuicyPixels. As the version number indicate, this is a major version with backward compatibility break. The major reason behind this breakage is the introduction of High Dynamic Range images. High Dynamic Range images are used in photography, and in some APIs like OpenGL and DirectX for some fancy effects. Version 3.0 changelog : - Simplification of the 'Pixel' typeclass, removed many unused part. - Removal of some Storable instances for pixel types. - Amelioration of the documentation. - Support for High Dynamic range images. - Support for the Radiance file format (or RGBE, file extension .pic and .hdr). - Dropped the cereal library in favor of the last version of Binary, present in the Haskell platform. Every dependencies are now present in the platform. As usual, this version is available in Hackage and on GitHub : - Hackage : http://hackage.haskell.org/package/JuicyPixels - GitHub : https://github.com/Twinside/Juicy.Pixels Thanks Vincent Berthoux -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.solla at gmail.com Sun Jan 20 19:59:40 2013 From: alex.solla at gmail.com (Alexander Solla) Date: Sun, 20 Jan 2013 10:59:40 -0800 Subject: [Haskell-cafe] Container libraries Message-ID: Hi everybody, What is the state of container libraries? I am looking for a library which provides: * unordered containers (for "operational" type safety, I don't want to impose orders on things that don't have them -- unordered containers does this) * can handled nested containers (containers does that) * can be serialized easily, or better yet, has Generic instances Does such a library exist? What are you using for Set and Map needs? I have been fond of unordered-containers for a while, but found difficulty in creating HashSets of, for example, HashMaps, since there are no Hashable instances for their polymorphic types. I even dug into the code, looking at the possibility of submitting a patch, but gave up when I ran into funky #-suffixed values, which stymied my initial attempt. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Sun Jan 20 20:27:07 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Sun, 20 Jan 2013 20:27:07 +0100 Subject: [Haskell-cafe] [ANN] tls-extra 0.6.1 - security update, please upgrade. In-Reply-To: <20130120055015.GA7912@snarc.org> References: <20130120055015.GA7912@snarc.org> Message-ID: On Sun, Jan 20, 2013 at 6:50 AM, Vincent Hanquez wrote: > Hi cafe, > > this is a security advisory for tls-extra < 0.6.1 which are all vulnerable > to bad > certificate validation. > > Some part of the certificate validation procedure were missing (relying on > the > work-in-progress x509 v3 extensions), and because of this anyone with a > correct > end-entity certificate can issue certificate for any arbitrary domain, i.e. > acting as a CA. > > This problem has been fixed in tls-extra 0.6.1, and I advise everyone to > upgrade as > soon as possible. > > Despite a very serious flaw in the certificate validation, I'm happy that > the > code is seeing some audits, and would want to thanks Ertugrul S?ylemez for > the > findings [1]. > > [1] https://github.com/vincenthz/hs-tls/issues/29 > > Regarding testing, it looks like the Tests directory hasn't been updated to cover this bug. What would really give confidence is a set of tests encoding fixed security vulnerabilities in OpenSSL (and similar libraries). That should also give you a lot of confidence in your library. But anyways, this is fantastic work you're doing. Keep it up! Alexander > -- > Vincent > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Sun Jan 20 20:39:06 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Sun, 20 Jan 2013 20:39:06 +0100 Subject: [Haskell-cafe] Container libraries References: Message-ID: <20130120203906.7ad31303@tritium.streitmacht.eu> Alexander Solla wrote: > What is the state of container libraries? I am looking for a library > which provides: > > * unordered containers (for "operational" type safety, I don't want to > impose orders on things that don't have them -- unordered containers > does this) You are imposing an order. > * can handled nested containers (containers does that) > * can be serialized easily, or better yet, has Generic instances > > Does such a library exist? What are you using for Set and Map needs? What's wrong with 'containers' itself? I prefer Map/Set over HashMap/HashSet, because the speed difference is small and only noticable for large maps/sets. If you need multiple indices, there is IxSet. The advantage of those is that their speed and memory behavior is more predictable, and they're not subject to hash collision attacks. Serializing them is done by importing your favorite serialization package, be it binary, cereal or safecopy/acid-state. They all have the necessary instances. For all these reasons I'm not a big fan of hash-based data structures, particularly hash tables. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From alex.solla at gmail.com Sun Jan 20 21:06:04 2013 From: alex.solla at gmail.com (Alexander Solla) Date: Sun, 20 Jan 2013 12:06:04 -0800 Subject: [Haskell-cafe] Container libraries In-Reply-To: <20130120203906.7ad31303@tritium.streitmacht.eu> References: <20130120203906.7ad31303@tritium.streitmacht.eu> Message-ID: On Sun, Jan 20, 2013 at 11:39 AM, Ertugrul S?ylemez wrote: > > What is the state of container libraries? I am looking for a library > > which provides: > > > > * unordered containers (for "operational" type safety, I don't want to > > impose orders on things that don't have them -- unordered containers > > does this) > > You are imposing an order. > I mean I don't want Ord instances for types with no "natural" order. I don't mind that a container structure will impose the topological order, or that containers can be ordered by inclusion. In particular, I have datatypes whose values represent incomparable "atoms" of some type. A comparison between them should "really" yield bottom. So an Ord-based container is not appropriate. I'd rather not have an Ord instance for these types and therefore statically eliminate that bottom. > > > > * can handled nested containers (containers does that) > > * can be serialized easily, or better yet, has Generic instances > > > > Does such a library exist? What are you using for Set and Map needs? > > What's wrong with 'containers' itself? I prefer Map/Set over > HashMap/HashSet, because the speed difference is small and only > noticable for large maps/sets. If you need multiple indices, there is > IxSet. I took a look at 'hashmap', which uses 'hashable' and 'containers' to implement hash containers. I worried about the performance, and thought I'd ask for opinions on containers. My goal is to create an IxSet-like structure which can handle unordered types, and preferably whose indices can be derived GHC.Generics-ally. -------------- next part -------------- An HTML attachment was scrubbed... URL: From amindfv at gmail.com Sun Jan 20 21:12:17 2013 From: amindfv at gmail.com (Tom Murphy) Date: Sun, 20 Jan 2013 15:12:17 -0500 Subject: [Haskell-cafe] Duplicates in arbitrary instances for collections Message-ID: Every QuickCheck tutorial makes the point that, given a property on some type, the Arbitrary instance for that type is written in such a way that nearly all of the interesting edge-cases of that type are tried. So e.g. for numeric types, positive, negative, and zero numbers are tried. For collections, I think the case of duplicate elements is insufficiently covered. Say we have a list difference function: badDiff :: Eq a => [a] -> [a] -> [a] badDiff l r = filter (\e -> e `notElem` r) l And a test for it: prop_wrong :: [Int] -> [Int] -> Bool prop_wrong a b = (a `badDiff` b) == (a \\ b) `quickCheck prop_wrong` passes about 80% of the time! Obviously it shouldn't: > badDiff [1,2,3,3,3] [2,3] [1] > (\\) [1,2,3,3,3] [2,3] [1,3,3] But even with maxSuccess at 1000, this property passes at least 2/3 of the times it's run (on my machine, where (maxBound :: Int) is large). The reason is that `arbitrary` for [a] is just `sized $ \n -> choose (0,n) >>= \k -> sequence [arbitrary | _ <- [1..k]]` It would be trivial to duplicate values in the collection a certain percentage of the time (possibly sometimes adjacent). Is there a good reason not to? It shouldn't require an Eq constraint. Tom From derek.a.elkins at gmail.com Sun Jan 20 21:54:05 2013 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun, 20 Jan 2013 15:54:05 -0500 Subject: [Haskell-cafe] "Function decoration pattern" on wiki Message-ID: I created the following page on the wiki to capture one pattern that occurs often in Edward Kmett's lens library. http://www.haskell.org/haskellwiki/Function_decoration_pattern Feel free to rename it or add comments, examples, clarifications, additional notes or extensions to the technique. From mark.lentczner at gmail.com Mon Jan 21 00:15:14 2013 From: mark.lentczner at gmail.com (Mark Lentczner) Date: Sun, 20 Jan 2013 15:15:14 -0800 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: References: <20121016171706.739775e0@bhuda.mired.org> Message-ID: Sorry to be reviving this thread so long after.... but I seem to be running into similar issues as Michael S. did at the start. In short, I'm using forkProcess with the threaded RTS, and see occasional hangs: - I see these only on Linux. On Mac OS X, I never do. - I'm using GHC 7.4.2 - I noticed the warning in the doc for forkProcess, but assumed I was safe, as I wasn't holding any shared resources at the time of the fork, and no shared resources in the program are used in the child. - WIth gdb, I've traced the hang to here in the run-time: forkProcess > discardTasksExcept > freeTask > closeMutex(&task->lock) > pthread_mutex_destroy The discussion in this thread leaves me with these questions: - Is there reason to think the situation has gotten better in 7.6 and later? - Isn't the only reason *System.Process* is safer because it does an immediate exec in the child? Alas, I really want to just fork()sometimes. - Is it really true that even if my program has no shared resources with the child, that the IO subsystem and FFI system do anyway? Surely the RTS would take care of doing the right thing with those, no? - There should be no concern with exec w.r.t. library invariants since exec is wholesale replacement - all the libraries will reinitialize. Is there a problem here I'm missing? Alas, I've stopped using the threaded RTS until I understand this better. - Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Mon Jan 21 00:27:47 2013 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon, 21 Jan 2013 00:27:47 +0100 (CET) Subject: [Haskell-cafe] [Haskell] Silent error In-Reply-To: <57911.94.231.33.84.1358723837.metamail@webmail.meta.ua> References: <57911.94.231.33.84.1358723837.metamail@webmail.meta.ua> Message-ID: On Mon, 21 Jan 2013, miphis at meta.ua wrote: > The program looks like this: > > --*********************** > factorial :: Int->Int > factorial n = product [1..n] > > main = do > print $ factorial 50 > --*********************** > > And that yields "0" (no errors). Is it a bug or feature? :) This question is certainly better posted to haskell-cafe. The answer is: Int has limited bitsize (32 ord 64 bit depending on your machine), thus it computes factorial modulo 2^32 or 2^64. You can get the correct result by replacing Int by Integer. From kazu at iij.ad.jp Mon Jan 21 03:44:25 2013 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Mon, 21 Jan 2013 11:44:25 +0900 (JST) Subject: [Haskell-cafe] Up-front Unit Testing in Haskell Message-ID: <20130121.114425.2037516902645207498.kazu@iij.ad.jp> Hello cafe, Just FYI: I wrote an tutorial, "Up-front Unit Testing in Haskell". It is about how to use doctest, hspec and Cabal. Enjoy! --Kazu From felipe.lessa at gmail.com Mon Jan 21 03:54:13 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Mon, 21 Jan 2013 00:54:13 -0200 Subject: [Haskell-cafe] Up-front Unit Testing in Haskell In-Reply-To: <20130121.114425.2037516902645207498.kazu@iij.ad.jp> References: <20130121.114425.2037516902645207498.kazu@iij.ad.jp> Message-ID: Where can we find it, Kazu? =) -- Felipe. From kazu at iij.ad.jp Mon Jan 21 03:55:54 2013 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Mon, 21 Jan 2013 11:55:54 +0900 (JST) Subject: [Haskell-cafe] Up-front Unit Testing in Haskell Message-ID: <20130121.115554.69428107078146046.kazu@iij.ad.jp> #Resending due to the lack of URL. Hello cafe, Just FYI: I wrote an tutorial, "Up-front Unit Testing in Haskell". It is about how to use doctest, hspec and Cabal. https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/en/tutorial.md Enjoy! --Kazu From kazu at iij.ad.jp Mon Jan 21 03:57:47 2013 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Mon, 21 Jan 2013 11:57:47 +0900 (JST) Subject: [Haskell-cafe] Up-front Unit Testing in Haskell In-Reply-To: References: <20130121.114425.2037516902645207498.kazu@iij.ad.jp> Message-ID: <20130121.115747.1405568461234326833.kazu@iij.ad.jp> > Where can we find it, Kazu? =) Oops. Thank you for pointing out. Here it is: https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/en/tutorial.md --Kazu From fuuzetsu at fuuzetsu.co.uk Mon Jan 21 04:54:08 2013 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Mon, 21 Jan 2013 03:54:08 +0000 Subject: [Haskell-cafe] Up-front Unit Testing in Haskell In-Reply-To: <20130121.115554.69428107078146046.kazu@iij.ad.jp> References: <20130121.115554.69428107078146046.kazu@iij.ad.jp> Message-ID: <50FCBBE0.70706@fuuzetsu.co.uk> Quite informative, thank you. It was nice to see how to combine the suites together as most places only show how to use one. The mention about Travis CI is also much appreciated; it seems like a really good project and I will definitely be using it in the future. Mateusz Kowalczyk On 21/01/13 02:55, Kazu Yamamoto (????) wrote: > #Resending due to the lack of URL. > > Hello cafe, > > Just FYI: > > I wrote an tutorial, "Up-front Unit Testing in Haskell". It is about > how to use doctest, hspec and Cabal. > > https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/en/tutorial.md > > Enjoy! > > --Kazu > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From alexander.kjeldaas at gmail.com Mon Jan 21 08:18:14 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Mon, 21 Jan 2013 08:18:14 +0100 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: References: <20121016171706.739775e0@bhuda.mired.org> Message-ID: I just looked at this code and since I don't know the code I can't give you good solutions, but for others watching this thread the links might prove interesting. My main theory is that you do have some other thread in FFI-land while you are fork()ing. The task->cond, task->lock seems to be related to this (see quoted comments below). Also, pthread_mutex_destroy is undefined if the lock is locked, so I am guessing that the task->lock is somehow locked when it shouldn't be. It isn't clear from your description whether this is consistently happening on Linux, or whether this only sometimes happens. The forkProcess() code seems to hold all capabilities during fork, but that does not include FFI-land threads AFAIU. Assuming that this happens only rarely, I am trying to understand what happens if the thread that is in FFI-land returns to the RTS (in the parent) after fork(), but before the freeTask() in the child. Based on the descriptions I read, it seems likely that this thread will try to inspect task->cap, which requires holding task->lock. That would in turn make the pthread_mutex_destroy in the child invalid. https://github.com/ghc/ghc/blob/master/rts/Task.h#L57 """ ... When a task is migrated from sleeping on one Capability to another, its task->cap field must be modified. When the task wakes up, it will read the new value of task->cap to find out which Capability it belongs to. Hence some synchronisation is required on task->cap, and this is why we have task->lock. If the Task is not currently owned by task->id, then the thread is either (a) waiting on the condition task->cond. The Task is either (1) a bound Task, the TSO will be on a queue somewhere (2) a worker task, on the spare_workers queue of task->cap. ... """ freeTask: https://github.com/ghc/ghc/blob/master/rts/Task.c#L142 the comment in freeTask refers to this test: https://github.com/ghc/testsuite/blob/master/tests/concurrent/should_run/conc059.hs That test calls the RTC from C which then forkIOs off actions that are outstanding when the RTS exits. in forkProcess, child code https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L1837 It look like all this code supports the notion that some other thread can be in foreign code during the fork call. discardTasksExcept https://github.com/ghc/ghc/blob/master/rts/Task.c#L305 Alexander On Mon, Jan 21, 2013 at 12:15 AM, Mark Lentczner wrote: > Sorry to be reviving this thread so long after.... but I seem to be > running into similar issues as Michael S. did at the start. > > In short, I'm using forkProcess with the threaded RTS, and see occasional > hangs: > > - I see these only on Linux. On Mac OS X, I never do. > - I'm using GHC 7.4.2 > - I noticed the warning in the doc for forkProcess, but assumed I was > safe, as I wasn't holding any shared resources at the time of the fork, and > no shared resources in the program are used in the child. > - WIth gdb, I've traced the hang to here in the run-time: forkProcess > > discardTasksExcept > freeTask > closeMutex(&task->lock) > > pthread_mutex_destroy > > The discussion in this thread leaves me with these questions: > > - Is there reason to think the situation has gotten better in 7.6 and > later? > - Isn't the only reason *System.Process* is safer because it does an > immediate exec in the child? Alas, I really want to just fork()sometimes. > - Is it really true that even if my program has no shared resources > with the child, that the IO subsystem and FFI system do anyway? Surely the > RTS would take care of doing the right thing with those, no? > - There should be no concern with exec w.r.t. library invariants since > exec is wholesale replacement - all the libraries will reinitialize. > Is there a problem here I'm missing? > > Alas, I've stopped using the threaded RTS until I understand this better. > > - Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Mon Jan 21 08:28:16 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Mon, 21 Jan 2013 08:28:16 +0100 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: References: <20121016171706.739775e0@bhuda.mired.org> Message-ID: On Mon, Jan 21, 2013 at 12:15 AM, Mark Lentczner wrote: > Sorry to be reviving this thread so long after.... but I seem to be > running into similar issues as Michael S. did at the start. > > In short, I'm using forkProcess with the threaded RTS, and see occasional > hangs: > > - I see these only on Linux. On Mac OS X, I never do. > > Previous versions of the linux pthreads library didn't hold any shared resources in locks, so pthread_mutex_destroy could not hang. Now Linux is much improved, and thus it hangs (see pthread_mutex_destroy man page) ;-). > - I'm using GHC 7.4.2 > - I noticed the warning in the doc for forkProcess, but assumed I was > safe, as I wasn't holding any shared resources at the time of the fork, and > no shared resources in the program are used in the child. > - WIth gdb, I've traced the hang to here in the run-time: forkProcess > > discardTasksExcept > freeTask > closeMutex(&task->lock) > > pthread_mutex_destroy > > The discussion in this thread leaves me with these questions: > > - Is there reason to think the situation has gotten better in 7.6 and > later? > - Isn't the only reason *System.Process* is safer because it does an > immediate exec in the child? Alas, I really want to just fork()sometimes. > > If you immediately do exec() in the child, you can use vfork() which blocks the parent. This serializes the actions and makes this whole mess smooth and consistent. > > - Is it really true that even if my program has no shared resources > with the child, that the IO subsystem and FFI system do anyway? Surely the > RTS would take care of doing the right thing with those, no? > > It looks like the RTS is trying to do a lot of things to control all the Haskell threads etc. But I don't think it waits for FFI-land threads before commencing a fork(), so that's why I'm guessing that some interaction between threads using FFI and fork() could be the issue. > > - There should be no concern with exec w.r.t. library invariants since > exec is wholesale replacement - all the libraries will reinitialize. > Is there a problem here I'm missing? > > I think that's right. vfork() + exec() can be serialized and deterministic thus is a lot easier to reason about. Alexander -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Mon Jan 21 10:14:28 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Mon, 21 Jan 2013 10:14:28 +0100 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: References: <20121016171706.739775e0@bhuda.mired.org> Message-ID: I think you can test this theory with this patch. If a thread is waiting on the task->cond condition variable which is matched up with task->lock, then pthread_cond_destroy will return EBUSY, which must always be a bug in the RTS. Alexander diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index ae31966..0f12830 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -91,7 +91,8 @@ initCondition( Condition* pCond ) void closeCondition( Condition* pCond ) { - pthread_cond_destroy(pCond); + int ret = pthread_cond_destroy(pCond); + CHECKM(ret == 0, "RTS BUG! Someone is waiting on condvar %d.", ret); return; } On Mon, Jan 21, 2013 at 8:18 AM, Alexander Kjeldaas < alexander.kjeldaas at gmail.com> wrote: > > I just looked at this code and since I don't know the code I can't give > you good solutions, but for others watching this thread the links might > prove interesting. > > My main theory is that you do have some other thread in FFI-land while you > are fork()ing. The task->cond, task->lock seems to be related to this (see > quoted comments below). > > Also, pthread_mutex_destroy is undefined if the lock is locked, so I am > guessing that the task->lock is somehow locked when it shouldn't be. > > It isn't clear from your description whether this is consistently > happening on Linux, or whether this only sometimes happens. > > The forkProcess() code seems to hold all capabilities during fork, but > that does not include FFI-land threads AFAIU. > > Assuming that this happens only rarely, I am trying to understand what > happens if the thread that is in FFI-land returns to the RTS (in the > parent) after fork(), but before the freeTask() in the child. Based on the > descriptions I read, it seems likely that this thread will try to inspect > task->cap, which requires holding task->lock. > > That would in turn make the pthread_mutex_destroy in the child invalid. > > https://github.com/ghc/ghc/blob/master/rts/Task.h#L57 > > """ > ... > When a task is migrated from sleeping on one Capability to another, > its task->cap field must be modified. When the task wakes up, it > will read the new value of task->cap to find out which Capability > it belongs to. Hence some synchronisation is required on > task->cap, and this is why we have task->lock. > > If the Task is not currently owned by task->id, then the thread is > either > > (a) waiting on the condition task->cond. The Task is either > (1) a bound Task, the TSO will be on a queue somewhere > (2) a worker task, on the spare_workers queue of task->cap. > ... > """ > > freeTask: > https://github.com/ghc/ghc/blob/master/rts/Task.c#L142 > > the comment in freeTask refers to this test: > > https://github.com/ghc/testsuite/blob/master/tests/concurrent/should_run/conc059.hs > > That test calls the RTC from C which then forkIOs off actions that are > outstanding when the RTS exits. > > in forkProcess, child code > https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L1837 > > It look like all this code supports the notion that some other thread can > be in foreign code during the fork call. > > discardTasksExcept > https://github.com/ghc/ghc/blob/master/rts/Task.c#L305 > > > Alexander > > > On Mon, Jan 21, 2013 at 12:15 AM, Mark Lentczner > wrote: > >> Sorry to be reviving this thread so long after.... but I seem to be >> running into similar issues as Michael S. did at the start. >> >> In short, I'm using forkProcess with the threaded RTS, and see occasional >> hangs: >> >> - I see these only on Linux. On Mac OS X, I never do. >> - I'm using GHC 7.4.2 >> - I noticed the warning in the doc for forkProcess, but assumed I was >> safe, as I wasn't holding any shared resources at the time of the fork, and >> no shared resources in the program are used in the child. >> - WIth gdb, I've traced the hang to here in the run-time: forkProcess >> > discardTasksExcept > freeTask > closeMutex(&task->lock) >> > pthread_mutex_destroy >> >> The discussion in this thread leaves me with these questions: >> >> - Is there reason to think the situation has gotten better in 7.6 and >> later? >> - Isn't the only reason *System.Process* is safer because it does an >> immediate exec in the child? Alas, I really want to just fork()sometimes. >> - Is it really true that even if my program has no shared resources >> with the child, that the IO subsystem and FFI system do anyway? Surely the >> RTS would take care of doing the right thing with those, no? >> - There should be no concern with exec w.r.t. library invariants >> since exec is wholesale replacement - all the libraries will >> reinitialize. Is there a problem here I'm missing? >> >> Alas, I've stopped using the threaded RTS until I understand this better. >> >> - Mark >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Mon Jan 21 10:42:37 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Mon, 21 Jan 2013 10:42:37 +0100 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: References: <20121016171706.739775e0@bhuda.mired.org> Message-ID: Or this. It seems that you must compile with DEBUG for the mutex check. This enables error-checking mutexes on posix. Alexander diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index ae31966..e07221d 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -91,7 +91,8 @@ initCondition( Condition* pCond ) void closeCondition( Condition* pCond ) { - pthread_cond_destroy(pCond); + int ret = pthread_cond_destroy(pCond); + CHECKM(ret == 0, "RTS Bug! Someone is waiting on condvar ret=%d.", ret); return; } @@ -165,7 +166,8 @@ initMutex(Mutex* pMut) void closeMutex(Mutex* pMut) { - pthread_mutex_destroy(pMut); + int ret = pthread_mutex_destroy(pMut); + CHECKM(ret == 0, "RTS Bug! Destroying held mutex ret=%d", ret); } void On Mon, Jan 21, 2013 at 10:14 AM, Alexander Kjeldaas < alexander.kjeldaas at gmail.com> wrote: > I think you can test this theory with this patch. If a thread is waiting > on the task->cond condition variable which is matched up with task->lock, > then pthread_cond_destroy will return EBUSY, which must always be a bug in > the RTS. > > Alexander > > diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c > index ae31966..0f12830 100644 > --- a/rts/posix/OSThreads.c > +++ b/rts/posix/OSThreads.c > @@ -91,7 +91,8 @@ initCondition( Condition* pCond ) > void > closeCondition( Condition* pCond ) > { > - pthread_cond_destroy(pCond); > + int ret = pthread_cond_destroy(pCond); > + CHECKM(ret == 0, "RTS BUG! Someone is waiting on condvar %d.", ret); > return; > } > > > > On Mon, Jan 21, 2013 at 8:18 AM, Alexander Kjeldaas < > alexander.kjeldaas at gmail.com> wrote: > >> >> I just looked at this code and since I don't know the code I can't give >> you good solutions, but for others watching this thread the links might >> prove interesting. >> >> My main theory is that you do have some other thread in FFI-land while >> you are fork()ing. The task->cond, task->lock seems to be related to this >> (see quoted comments below). >> >> Also, pthread_mutex_destroy is undefined if the lock is locked, so I am >> guessing that the task->lock is somehow locked when it shouldn't be. >> >> It isn't clear from your description whether this is consistently >> happening on Linux, or whether this only sometimes happens. >> >> The forkProcess() code seems to hold all capabilities during fork, but >> that does not include FFI-land threads AFAIU. >> >> Assuming that this happens only rarely, I am trying to understand what >> happens if the thread that is in FFI-land returns to the RTS (in the >> parent) after fork(), but before the freeTask() in the child. Based on the >> descriptions I read, it seems likely that this thread will try to inspect >> task->cap, which requires holding task->lock. >> >> That would in turn make the pthread_mutex_destroy in the child invalid. >> >> https://github.com/ghc/ghc/blob/master/rts/Task.h#L57 >> >> """ >> ... >> When a task is migrated from sleeping on one Capability to another, >> its task->cap field must be modified. When the task wakes up, it >> will read the new value of task->cap to find out which Capability >> it belongs to. Hence some synchronisation is required on >> task->cap, and this is why we have task->lock. >> >> If the Task is not currently owned by task->id, then the thread is >> either >> >> (a) waiting on the condition task->cond. The Task is either >> (1) a bound Task, the TSO will be on a queue somewhere >> (2) a worker task, on the spare_workers queue of task->cap. >> ... >> """ >> >> freeTask: >> https://github.com/ghc/ghc/blob/master/rts/Task.c#L142 >> >> the comment in freeTask refers to this test: >> >> https://github.com/ghc/testsuite/blob/master/tests/concurrent/should_run/conc059.hs >> >> That test calls the RTC from C which then forkIOs off actions that are >> outstanding when the RTS exits. >> >> in forkProcess, child code >> https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L1837 >> >> It look like all this code supports the notion that some other thread can >> be in foreign code during the fork call. >> >> discardTasksExcept >> https://github.com/ghc/ghc/blob/master/rts/Task.c#L305 >> >> >> Alexander >> >> >> On Mon, Jan 21, 2013 at 12:15 AM, Mark Lentczner < >> mark.lentczner at gmail.com> wrote: >> >>> Sorry to be reviving this thread so long after.... but I seem to be >>> running into similar issues as Michael S. did at the start. >>> >>> In short, I'm using forkProcess with the threaded RTS, and see >>> occasional hangs: >>> >>> - I see these only on Linux. On Mac OS X, I never do. >>> - I'm using GHC 7.4.2 >>> - I noticed the warning in the doc for forkProcess, but assumed I >>> was safe, as I wasn't holding any shared resources at the time of the fork, >>> and no shared resources in the program are used in the child. >>> - WIth gdb, I've traced the hang to here in the run-time: forkProcess >>> > discardTasksExcept > freeTask > closeMutex(&task->lock) >>> > pthread_mutex_destroy >>> >>> The discussion in this thread leaves me with these questions: >>> >>> - Is there reason to think the situation has gotten better in 7.6 >>> and later? >>> - Isn't the only reason *System.Process* is safer because it does an >>> immediate exec in the child? Alas, I really want to just fork()sometimes. >>> - Is it really true that even if my program has no shared resources >>> with the child, that the IO subsystem and FFI system do anyway? Surely the >>> RTS would take care of doing the right thing with those, no? >>> - There should be no concern with exec w.r.t. library invariants >>> since exec is wholesale replacement - all the libraries will >>> reinitialize. Is there a problem here I'm missing? >>> >>> Alas, I've stopped using the threaded RTS until I understand this better. >>> >>> - Mark >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nomeata at debian.org Mon Jan 21 11:29:15 2013 From: nomeata at debian.org (Joachim Breitner) Date: Mon, 21 Jan 2013 11:29:15 +0100 Subject: [Haskell-cafe] [ANN] tls-extra 0.6.1 - security update, please upgrade. In-Reply-To: <20130120162156.GA13747@snarc.org> References: <20130120055015.GA7912@snarc.org> <1358676082.4579.6.camel@kirk> <20130120162156.GA13747@snarc.org> Message-ID: <1358764155.4370.1.camel@kirk> Hi, Am Sonntag, den 20.01.2013, 17:21 +0100 schrieb Vincent Hanquez: > On Sun, Jan 20, 2013 at 11:01:22AM +0100, Joachim Breitner wrote: > > Debian ships tls-extras 0.4.6 in what will become wheezy, and due to the > > freeze upgrading to a new major upstream release is not acceptable. > > > Would it be possible for you to create a 0.4.6.1 with this bugfix > > included? > > (wow, the tls packages stack are quite obsolete) > > Apart from the fact that it took me a while to rebase to this version, > I just uploaded 0.4.6.1. it compiles but got minimal testing. thanks, uploaded to Debian and on its way into the wheezy suite. Greetings, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata -------------- 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: From jan.stolarek at p.lodz.pl Mon Jan 21 13:34:03 2013 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Mon, 21 Jan 2013 13:34:03 +0100 Subject: [Haskell-cafe] Up-front Unit Testing in Haskell In-Reply-To: <50FCBBE0.70706@fuuzetsu.co.uk> References: <20130121.115554.69428107078146046.kazu@iij.ad.jp> <50FCBBE0.70706@fuuzetsu.co.uk> Message-ID: <201301211334.03805.jan.stolarek@p.lodz.pl> Thanks for a nice tutorial. A couple of months ago I spent quite some time trying to figure out how to write tests in Haskell, which resulted in this blog post: http://ics.p.lodz.pl/~stolarek/blog/2012/10/code-testing-in-haskell/ Sadly there are no test-framework providers for hspec and dostest - this would make using them a whole lot easier. Janek Dnia poniedzia?ek, 21 stycznia 2013, Mateusz Kowalczyk napisa?: > Quite informative, thank you. It was nice to see how to combine the > suites together as most places only show how to use one. > > The mention about Travis CI is also much appreciated; it seems like a > really good project and I will definitely be using it in the future. > > > Mateusz Kowalczyk > > On 21/01/13 02:55, Kazu Yamamoto (????) wrote: > > #Resending due to the lack of URL. > > > > Hello cafe, > > > > Just FYI: > > > > I wrote an tutorial, "Up-front Unit Testing in Haskell". It is about > > how to use doctest, hspec and Cabal. > > > > https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/ > >en/tutorial.md > > > > Enjoy! > > > > --Kazu > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From chris at chrisdornan.com Mon Jan 21 14:14:44 2013 From: chris at chrisdornan.com (Chris Dornan) Date: Mon, 21 Jan 2013 13:14:44 +0000 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: Message-ID: I am also sorry to be late on this but I have run into the same problem trying to demonise a programme on 7.4.2. My solution was to get a shell wrapper to run the daemon in debug mode (I.e., sans fork) and get the shell script to do the demonising. Other than this I have found the threaded RTS to be sound and I am quite reliant on it. So, where things that run ?threaded are concerned, no forkProcess calls for me until I can better understand this better. If anybody does think they understand what is going on here it would be great if they could write it up. IMHO, either the current notes on forkProcess don't go far enough, or there is a bug needing a workaround until the platform gets fixed. Chris From: Mark Lentczner Date: Sunday, 20 January 2013 23:15 To: haskell Cc: Mike Meyer Subject: Re: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime Sorry to be reviving this thread so long after.... but I seem to be running into similar issues as Michael S. did at the start. In short, I'm using forkProcess with the threaded RTS, and see occasional hangs: * I see these only on Linux. On Mac OS X, I never do. * I'm using GHC 7.4.2 * I noticed the warning in the doc for forkProcess, but assumed I was safe, as I wasn't holding any shared resources at the time of the fork, and no shared resources in the program are used in the child. * WIth gdb, I've traced the hang to here in the run-time: forkProcess > discardTasksExcept > freeTask > closeMutex(&task->lock) > pthread_mutex_destroy The discussion in this thread leaves me with these questions: * Is there reason to think the situation has gotten better in 7.6 and later? * Isn't the only reason System.Process is safer because it does an immediate exec in the child? Alas, I really want to just fork() sometimes. * Is it really true that even if my program has no shared resources with the child, that the IO subsystem and FFI system do anyway? Surely the RTS would take care of doing the right thing with those, no? * There should be no concern with exec w.r.t. library invariants since exec is wholesale replacement - all the libraries will reinitialize. Is there a problem here I'm missing? Alas, I've stopped using the threaded RTS until I understand this better. - Mark _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Mon Jan 21 14:57:31 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Mon, 21 Jan 2013 14:57:31 +0100 Subject: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime In-Reply-To: References: Message-ID: While trying to dig around this morning I started adding clang-style thread locking annotations to the source code. These can be very handy and I found at least one place where the documented locking policy doesn't seem to match what is happening. Here is an example with annotations, and what might or might not be a bug. With these annotations, clang will be able to prove whether the program obeys the locking regime or not. But this is of course only one part of the RTS, but the locking can be pretty "interesting" in itself. Does anyone else feel that this sort of annotations would help? Alexander diff --git a/rts/Task.c b/rts/Task.c index e6781a1..1e499dc 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -25,12 +25,12 @@ // Task lists and global counters. // Locks required: all_tasks_mutex. -Task *all_tasks = NULL; +Task *all_tasks GUARDED_BY(all_tasks_mutex) = NULL; -nat taskCount; -nat workerCount; -nat currentWorkerCount; -nat peakWorkerCount; +nat taskCount GUARDED_BY(all_tasks_mutex); +nat workerCount GUARDED_BY(all_tasks_mutex); +nat currentWorkerCount GUARDED_BY(all_tasks_mutex); +nat peakWorkerCount GUARDED_BY(all_tasks_mutex); static int tasksInitialized = 0; @@ -339,9 +339,11 @@ void updateCapabilityRefs (void) ACQUIRE_LOCK(&all_tasks_mutex); for (task = all_tasks; task != NULL; task=task->all_next) { + ACQUIRE_LOCK(task->lock); if (task->cap != NULL) { task->cap = &capabilities[task->cap->no]; } + RELEASE_LOCK(task->lock); for (incall = task->incall; incall != NULL; incall = incall->prev_stack) { if (incall->suspended_cap != NULL) { On Mon, Jan 21, 2013 at 2:14 PM, Chris Dornan wrote: > I am also sorry to be late on this but I have run into the same problem > trying to demonise a programme on 7.4.2. My solution was to get a shell > wrapper to run the daemon in debug mode (I.e., sans fork) and get the shell > script to do the demonising. > > Other than this I have found the threaded RTS to be sound and I am quite > reliant on it. So, where things that run ?threaded are concerned, no > forkProcess calls for me until I can better understand this better. > > If anybody does think they understand what is going on here it would be > great if they could write it up. IMHO, either the current notes on > forkProcess don't go far enough, or there is a bug needing a workaround > until the platform gets fixed. > > Chris > > From: Mark Lentczner > Date: Sunday, 20 January 2013 23:15 > To: haskell > Cc: Mike Meyer > Subject: Re: [Haskell-cafe] forkProcess, forkIO, and multithreaded runtime > > Sorry to be reviving this thread so long after.... but I seem to be > running into similar issues as Michael S. did at the start. > > In short, I'm using forkProcess with the threaded RTS, and see occasional > hangs: > > - I see these only on Linux. On Mac OS X, I never do. > - I'm using GHC 7.4.2 > - I noticed the warning in the doc for forkProcess, but assumed I was > safe, as I wasn't holding any shared resources at the time of the fork, and > no shared resources in the program are used in the child. > - WIth gdb, I've traced the hang to here in the run-time: forkProcess > > discardTasksExcept > freeTask > closeMutex(&task->lock) > > pthread_mutex_destroy > > The discussion in this thread leaves me with these questions: > > - Is there reason to think the situation has gotten better in 7.6 and > later? > - Isn't the only reason *System.Process* is safer because it does an > immediate exec in the child? Alas, I really want to just fork()sometimes. > - Is it really true that even if my program has no shared resources > with the child, that the IO subsystem and FFI system do anyway? Surely the > RTS would take care of doing the right thing with those, no? > - There should be no concern with exec w.r.t. library invariants since > exec is wholesale replacement - all the libraries will reinitialize. > Is there a problem here I'm missing? > > Alas, I've stopped using the threaded RTS until I understand this better. > > - Mark > _______________________________________________ Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tycho at tycho.ws Mon Jan 21 15:25:19 2013 From: tycho at tycho.ws (Tycho Andersen) Date: Mon, 21 Jan 2013 08:25:19 -0600 Subject: [Haskell-cafe] ANN: Hquery 0.1 Message-ID: <20130121142519.GB9672@smalls> Hi cafe, I've written a library called hquery, which can be used to manipulate xmlhtml trees (and has a similar selector syntax to jquery, hence the name). This enables easy manipulation and content generation from html templates. If you're familiar with Lift's CssSels, this is basically an implementation of those in haskell. This is my first foray into haskell, so any critiques of the code or API are welcome :-) Hquery: http://hackage.haskell.org/package/hquery-0.1.0.1 Examples: http://hackage.haskell.org/packages/archive/hquery/0.1.0.1/doc/html/Text-Hquery.html \t From emailme at andrewhbridge.co.uk Mon Jan 21 16:33:12 2013 From: emailme at andrewhbridge.co.uk (Andrew H Bridge) Date: Mon, 21 Jan 2013 15:33:12 +0000 (UTC) Subject: [Haskell-cafe] XCode Dependency for HP on Mac References: Message-ID: Tom Murphy gmail.com> writes: > > Is there a way to install HP without XCode? Could there be in the > future? I'm tired of dealing with Apple's constant upgrade > requirements, registration requirements, etc., and it seems like a > small function that XCode actually performs in the Haskell development > "toolchain." > Again, I'm ignorant of the details and I'm sorry if this is ranty, but > I'd love to hear your reactions. > > Thanks! > Tom > Hi, I know this is an old thread, but it came up on Google when I was searching around for an answer to this. So maybe I can still help someone. 10.6 users can use this installer on GitHub https://github.com/kennethreitz/osx-gcc-installer. It installs gcc and a few other bits and pieces (less than a GB to install). Then you can install the Haskell Platform. It's worked for me so far! Enjoy! Thanks, Andrew From mark.lentczner at gmail.com Mon Jan 21 17:31:07 2013 From: mark.lentczner at gmail.com (Mark Lentczner) Date: Mon, 21 Jan 2013 08:31:07 -0800 Subject: [Haskell-cafe] XCode Dependency for HP on Mac In-Reply-To: References: Message-ID: As the README at that repository states, For 10.7 and later Apple now distributes a "Command Line Tools" package on the developer site. When I build and release the Haskell Platform, I confirm that works when just this package is installed (rather than all of Xcode). The Command Line Tools from Apple include not only the compiler and bin tools that GHC needs, but also the full suite of development headers and library stubs. Many people's OS X woes with HP have stemmed from non-standard development installations. If at all possible, I suggest you stick with Apple's distributions. Please keep us appraised of how it works for you after you've used it for a bit. I'm curious if, should you start installing some of Hackage's more complicated packages, if it continues to work out. - Mark (HP release manager) -------------- next part -------------- An HTML attachment was scrubbed... URL: From emailme at andrewhbridge.co.uk Mon Jan 21 18:21:44 2013 From: emailme at andrewhbridge.co.uk (Andrew H Bridge) Date: Mon, 21 Jan 2013 17:21:44 +0000 (UTC) Subject: [Haskell-cafe] XCode Dependency for HP on Mac References: Message-ID: Mark Lentczner gmail.com> writes: > > As the README at that repository states, For 10.7 and later Apple now > distributes a "Command Line Tools" package on the developer site. > When I build and release the Haskell Platform, I confirm that works > when just this package is installed (rather than all of Xcode). > > [Message continues] > > - Mark (HP release manager) > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Hi Mark, I will keep you updated, the issue is that I refuse to upgrade to 10.7 or later, many of the brilliant features from Snow Leopard were entirely ruined and I still see people complaining about having trouble with it on my model of MacBook. So for 10.6 users, this 3rd part installer is the only option I could find! Thanks, Andrew From agocorona at gmail.com Mon Jan 21 21:29:33 2013 From: agocorona at gmail.com (Alberto G. Corona ) Date: Mon, 21 Jan 2013 21:29:33 +0100 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: MFlow 0.2 In-Reply-To: <20130120123305.4266ce07@windy.deldotd.com> References: <20130120123305.4266ce07@windy.deldotd.com> Message-ID: The template look is very simple but it uses a lot of dynamic code behind I changed the template to something more light. http://haskell-web.blogspot.com.es/ 2013/1/20 > On Thu, 17 Jan 2013 16:07:41 +0100 > "Alberto G. Corona " wrote: > > > > > The entry in my blog, with the announcement and the philosophy behind > > http://haskell-web.blogspot.com.es/2013/01/announce-mflow-02.html > > > > FYI > That page never comes up for me. I just see spinning gears. > iceweasel 10.0.7 > > Brian > > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicolasbock at gmail.com Tue Jan 22 00:21:01 2013 From: nicolasbock at gmail.com (Nicolas Bock) Date: Mon, 21 Jan 2013 16:21:01 -0700 Subject: [Haskell-cafe] regular expression sub-expression matching In-Reply-To: References: Message-ID: Hi Roman and Bob, thanks a lot for the help. I ended up using getAllTextSubmatches as explained by Bob, since I had that package already installed on my system. Works great! Thanks, nick On Fri, Jan 18, 2013 at 5:52 PM, Bob Ippolito wrote: > Note that Haskell doesn't convert "\(" to "\\(" like Python does, so the > regex string has been changed. It's not so easy to figure out how to use > this library from the documentation because of all the typeclass trickery. > > h> import Text.Regexp.Posix (getAllTextSubmatches, (=~)) > h> getAllTextSubmatches ("M(1,2) = 0.1e-3;" =~ "M\\(([0-9]+),([0-9]+)\\) > *= *([0-9.eE-]+);") :: [String] > ["M(1,2) = 0.1e-3;","1","2","0.1e-3"] > > If it doesn't match, you'll get an empty list. You can join the tail of > the match list together with Data.List.intercalate, and print it out with > putStrLn. The if null case would just return (). > > To demonstrate some of the typeclass trickery going on here, you could ask > for the results as an Array with Int indexes of String. > > h> import Text.Regexp.Posix (getAllTextSubmatches, (=~)) > h> import Data.Array ((!), Array) > h> let matches = getAllTextSubmatches ("M(1,2) = 0.1e-3;" =~ > "M\\(([0-9]+),([0-9]+)\\) *= *([0-9.eE-]+);") :: Array Int String > h> matches > array (0,3) [(0,"M(1,2) = 0.1e-3;"),(1,"1"),(2,"2"),(3,"0.1e-3")] > h> map (matches !) [1..3] > ["1","2","0.1e-3"] > > -bob > > On Fri, Jan 18, 2013 at 3:25 PM, Nicolas Bock wrote: > >> Hello list, >> >> I was wondering whether there is a way to do what the following python >> code does in haskell: >> >> import re >> >> result = re.compile("M\(([0-9]+),([0-9]+)\) *= >> *([0-9.eE-]+);").search("M(1,2) = 0.1e-3;") >> if result: >> print(result.group(1), result.group(2), result.group(3)) >> >> Basically I would like to pattern match parts of a string and return the >> matches. I have looked at Text.Regex.Posix but (of course I might just not >> have understood the functions in there properly) it seems as if it does not >> provide anything like python's re module. >> >> Thanks already, >> >> nick >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Tue Jan 22 08:08:19 2013 From: tab at snarc.org (Vincent Hanquez) Date: Tue, 22 Jan 2013 08:08:19 +0100 Subject: [Haskell-cafe] [ANN] tls-extra 0.6.1 - security update, please upgrade. In-Reply-To: References: <20130120055015.GA7912@snarc.org> Message-ID: <20130122070819.GA28383@snarc.org> On Sun, Jan 20, 2013 at 08:27:07PM +0100, Alexander Kjeldaas wrote: > Regarding testing, it looks like the Tests directory hasn't been updated to > cover this bug. What would really give confidence is a set of tests > encoding fixed security vulnerabilities in OpenSSL (and similar libraries). > That should also give you a lot of confidence in your library. > > But anyways, this is fantastic work you're doing. Keep it up! Thanks, Regarding tests, a good test suite is a hard and long job. Some security properties are just insanely hard to codify, and some others need a lots of tests. My time being very limited, it's hard to pull off, but i have plan to add some tests for the certificate validation functions. Specially since i want to harden some functions a bit more, and it will come handy to verify i'm not breaking anything :-) -- Vincent From roma at ro-che.info Tue Jan 22 14:28:56 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Tue, 22 Jan 2013 15:28:56 +0200 Subject: [Haskell-cafe] Non-derivable Typeable Message-ID: <20130122132855.GA29820@sniper> I need to declare a Typeable instance for a type which has an argument of kind * -> *. GHC refuses to derive it. What is a recommended way to go about it? In particular, if I write the instance by hand, how important is the fingerprint, and how could I generate it? Roman From jpm at cs.uu.nl Tue Jan 22 14:36:26 2013 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Tue, 22 Jan 2013 13:36:26 +0000 Subject: [Haskell-cafe] Non-derivable Typeable In-Reply-To: <20130122132855.GA29820@sniper> References: <20130122132855.GA29820@sniper> Message-ID: Won't it derive it with StandaloneDeriving? Cheers, Pedro On Tue, Jan 22, 2013 at 1:28 PM, Roman Cheplyaka wrote: > I need to declare a Typeable instance for a type which has an argument > of kind * -> *. GHC refuses to derive it. > > What is a recommended way to go about it? > > In particular, if I write the instance by hand, how important is the > fingerprint, and how could I generate it? > > Roman > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Tue Jan 22 14:43:58 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Tue, 22 Jan 2013 15:43:58 +0200 Subject: [Haskell-cafe] Non-derivable Typeable In-Reply-To: References: <20130122132855.GA29820@sniper> Message-ID: <20130122134357.GA29970@sniper> It doesn't seem to ? am I doing something wrong? GHCi, version 7.6.1.20121207: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :set -XDeriveDataTypeable -XStandaloneDeriving Prelude> :m +Data.Typeable Prelude Data.Typeable> data Foo m = Foo (m ()) Prelude Data.Typeable> deriving instance Typeable1 m => Typeable (Foo m) :5:1: Can't make a derived instance of `Typeable (Foo m)': `Foo' must only have arguments of kind `*' In the stand-alone deriving instance for `Typeable1 m => Typeable (Foo m)' Roman * Jos? Pedro Magalh?es [2013-01-22 13:36:26+0000] > Won't it derive it with StandaloneDeriving? > > > Cheers, > Pedro > > On Tue, Jan 22, 2013 at 1:28 PM, Roman Cheplyaka wrote: > > > I need to declare a Typeable instance for a type which has an argument > > of kind * -> *. GHC refuses to derive it. > > > > What is a recommended way to go about it? > > > > In particular, if I write the instance by hand, how important is the > > fingerprint, and how could I generate it? > > > > Roman > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From roma at ro-che.info Tue Jan 22 15:34:54 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Tue, 22 Jan 2013 16:34:54 +0200 Subject: [Haskell-cafe] Non-derivable Typeable In-Reply-To: <20130122132855.GA29820@sniper> References: <20130122132855.GA29820@sniper> Message-ID: <20130122143454.GA31132@sniper> I just found mkTyCon3 which generates the fingerprint automatically. (I was looking at Data.Typeable.Internal.mkTyCon before.) That answers my question. (Of course, a way to derive the instance would be even better...) Roman * Roman Cheplyaka [2013-01-22 15:28:55+0200] > I need to declare a Typeable instance for a type which has an argument > of kind * -> *. GHC refuses to derive it. > > What is a recommended way to go about it? > > In particular, if I write the instance by hand, how important is the > fingerprint, and how could I generate it? > > Roman From jpm at cs.uu.nl Tue Jan 22 15:41:25 2013 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Tue, 22 Jan 2013 14:41:25 +0000 Subject: [Haskell-cafe] Non-derivable Typeable In-Reply-To: <20130122143454.GA31132@sniper> References: <20130122132855.GA29820@sniper> <20130122143454.GA31132@sniper> Message-ID: Yes, that will work. But soon we'll have poly-kinded Typeable in HEAD, which will be able to derive that instance. Cheers, Pedro On Tue, Jan 22, 2013 at 2:34 PM, Roman Cheplyaka wrote: > I just found mkTyCon3 which generates the fingerprint automatically. > (I was looking at Data.Typeable.Internal.mkTyCon before.) > That answers my question. > > (Of course, a way to derive the instance would be even better...) > > Roman > > * Roman Cheplyaka [2013-01-22 15:28:55+0200] > > I need to declare a Typeable instance for a type which has an argument > > of kind * -> *. GHC refuses to derive it. > > > > What is a recommended way to go about it? > > > > In particular, if I write the instance by hand, how important is the > > fingerprint, and how could I generate it? > > > > Roman > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Tue Jan 22 15:43:57 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Tue, 22 Jan 2013 16:43:57 +0200 Subject: [Haskell-cafe] Non-derivable Typeable In-Reply-To: References: <20130122132855.GA29820@sniper> <20130122143454.GA31132@sniper> Message-ID: <20130122144357.GA31535@sniper> Thanks, looking forward to it! Roman * Jos? Pedro Magalh?es [2013-01-22 14:41:25+0000] > Yes, that will work. But soon we'll have poly-kinded Typeable in HEAD, > which will be able to derive that instance. > > > Cheers, > Pedro > > On Tue, Jan 22, 2013 at 2:34 PM, Roman Cheplyaka wrote: > > > I just found mkTyCon3 which generates the fingerprint automatically. > > (I was looking at Data.Typeable.Internal.mkTyCon before.) > > That answers my question. > > > > (Of course, a way to derive the instance would be even better...) > > > > Roman > > > > * Roman Cheplyaka [2013-01-22 15:28:55+0200] > > > I need to declare a Typeable instance for a type which has an argument > > > of kind * -> *. GHC refuses to derive it. > > > > > > What is a recommended way to go about it? > > > > > > In particular, if I write the instance by hand, how important is the > > > fingerprint, and how could I generate it? > > > > > > Roman > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From sk at k-hornz.de Tue Jan 22 15:53:55 2013 From: sk at k-hornz.de (Stefan Kersten) Date: Tue, 22 Jan 2013 15:53:55 +0100 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: <50FB1040.2030000@posteo.de> References: <50FB1040.2030000@posteo.de> Message-ID: On Jan 19, 2013, at 10:29 PM, Nathan H?sken wrote: > Recently I managed to get ghc to target android working (this still > needs some work): [4]. this is great news, thanks! > Of couse, ffi bindings for all these platforms would be needed to get > serious. i think that you can get quite serious already if the main "model" is implemented in haskell and you only need bindings for communicating with a native user interface. sk From apfelmus at quantentunnel.de Tue Jan 22 20:36:17 2013 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue, 22 Jan 2013 20:36:17 +0100 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: MFlow 0.2 In-Reply-To: References: <20130120123305.4266ce07@windy.deldotd.com> Message-ID: Alberto G. Corona wrote: > The template look is very simple but it uses a lot of dynamic code behind > > I changed the template to something more light. > > http://haskell-web.blogspot.com.es/ Much better, thanks! Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From andrew.pennebaker at gmail.com Tue Jan 22 20:40:04 2013 From: andrew.pennebaker at gmail.com (Andrew Pennebaker) Date: Tue, 22 Jan 2013 14:40:04 -0500 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: Can we un-deprecate GHC's ability to compile to C code? C may be the best option to bridge to mobile, as Android, iOS, and Windows RT do support C/C++ apps. On Jan 22, 2013 2:14 PM, "Dan Choi" wrote: > > What about the option of using Haskell's Parsec or AttoParsec to implement > a Haskell-ish language that compiles down not to machine code but to > Objective C or Android Java? Like how CoffeeScript compiles down to > JavaScript. > > > > On Saturday, January 19, 2013 1:58:03 PM UTC-5, Casey Hawthorne wrote: >> >> You would need native compilers for all the platforms and/or virtual >> machine technology. >> >> Might be easier to have the browser connect to a Haskell app. >> >> >> On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker >> wrote: >> > There are currently very few options, especially free and open source >> > options, when it comes to developing cross-platform mobile >> applications. >> > It's basically web apps with JavaScript, or C++. If Haskell supported >> app >> > development on Android, iOS, and Windows RT, that alone would bring in >> more >> > developers. >> > >> > Similarly, there are very few languages for mobile development that >> take >> > advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an >> > amazing selling point. Can we please prioritize mobile support? I'd >> much >> > rather write everything in ML than PhoneGap. >> > >> > -- >> > Cheers, >> > >> > Andrew Pennebaker >> > www.yellosoft.us >> > >> > ______________________________**_________________ >> > Haskell-Cafe mailing list >> > Haskel... at haskell.org >> > http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > >> >> >> >> -- >> -- >> Regards, >> KC >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskel... at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Tue Jan 22 20:50:26 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 22 Jan 2013 14:50:26 -0500 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: On Tue, Jan 22, 2013 at 2:40 PM, Andrew Pennebaker < andrew.pennebaker at gmail.com> wrote: > Can we un-deprecate GHC's ability to compile to C code? C may be the best > option to bridge to mobile, as Android, iOS, and Windows RT do support > C/C++ apps. > The C code generated by GHC, except in unregisterised mode, was not particularly suitable for that use. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From giorgidze at gmail.com Wed Jan 23 00:20:20 2013 From: giorgidze at gmail.com (George Giorgidze) Date: Wed, 23 Jan 2013 00:20:20 +0100 Subject: [Haskell-cafe] ANN: Haskell bindings for the igraph C library Message-ID: Hi Jason, > How does this compare with fgl? http://hackage.haskell.org/package/fgl A couple of months ago, I was working on a project where I had to do some graph analysis. I encountered two problems with the fgl library: (1) The fgl library did not work for large graphs, even graph construction would fail with stack overflow. (2) The fgl library did not provide the graph algorithms needed in the project: closeness centrality, Brandes betweenness centrality, eigenvector centrality, pagerank and some more. The igraph library featured all functions that I needed and also worked for large graphs without problems. I was also very pleased with its performance and started writing Haskell bindings to igraph. Cheers, George From dagitj at gmail.com Wed Jan 23 00:23:30 2013 From: dagitj at gmail.com (Jason Dagit) Date: Tue, 22 Jan 2013 15:23:30 -0800 Subject: [Haskell-cafe] ANN: Haskell bindings for the igraph C library In-Reply-To: References: Message-ID: On Tue, Jan 22, 2013 at 3:20 PM, George Giorgidze wrote: > Hi Jason, > > > How does this compare with fgl? http://hackage.haskell.org/package/fgl > > A couple of months ago, I was working on a project where I had to do > some graph analysis. I encountered two problems with the fgl library: > Thanks. That's helpful. I originally asked simply because I wanted to know when I would choose fgl vs. igraph. Your response answered that pretty well. Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnw at fpcomplete.com Wed Jan 23 01:04:36 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Tue, 22 Jan 2013 18:04:36 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 Message-ID: monad-bool implements a pair of Boolean monoids and monads, to support short-circuiting, value-returning computations similar to what Python and Ruby offer with their native && and || operators. For example, in Python you might see this: x = [1,2,3,0] print x[1] || x[3] -- prints "2" With this library, you can now mirror such code in Haskell: let x = [1,2,3,0] print $ (x !! 1) ||? (x !! 3) -- prints "Success 2" "Booleanness" is based on each type having an instance of the 'Control.Conditional.ToBool' type, for which only the basic types are covered (Bool, Int, Integer, Maybe a, Either a b, [a], Attempt a). If you wish to define a truth value for your own types, simply provide an instance for ToBool: instance ToBool MyType where toBool = ... The And/Or monoids use the Attempt library so that the actual type of the successful results depends on case analysis. It could be a list, a Maybe, an Either, or an exception in the IO Monad. The monad variants, AndM, AndMT, OrM and OrMT provide short-circuiting behavior in a Monad, which returns the last value returned before truth was determined. Here are two examples: Use 'onlyIf' with AndM and AndMT to guard later statements, which are only evaluated if every preceding 'onlyIf' evaluates to True. For example: foo :: AndM Int foo = do onlyIf (True == True) return 100 onlyIf (True == True) return 150 onlyIf (True == False) return 200 When run with `evalAndM foo (-1)` (where (-1) provides a default value), 'foo' returns 150. Use 'endIf' with OrM and OrMT to chain statements, which are only executed if every preceding 'endIf' evaluated to False. For example: bar :: OrM Int bar = do endIf (True == False) return 100 endIf (True == False) return 150 endIf (True == True) return 200 When run with `evalOrM bar (-1)` (where (-1) again provides a default value), 'bar' returns 150. And please, somebody let me know if this has already been done. A search for likely candidates did not turn up anything obvious in Hoogle, but as my knowledge of the whole of Hackage is minimal, I would appreciate any wiser minds that can inform me. Thank you, -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From lemming at henning-thielemann.de Wed Jan 23 01:12:48 2013 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed, 23 Jan 2013 01:12:48 +0100 (CET) Subject: [Haskell-cafe] [Haskell] ANN: monad-bool 0.1 In-Reply-To: References: Message-ID: On Tue, 22 Jan 2013, John Wiegley wrote: > Use 'onlyIf' with AndM and AndMT to guard later statements, which are only > evaluated if every preceding 'onlyIf' evaluates to True. For example: > > foo :: AndM Int > foo = do onlyIf (True == True) > return 100 > onlyIf (True == True) > return 150 > onlyIf (True == False) > return 200 > > When run with `evalAndM foo (-1)` (where (-1) provides a default value), 'foo' > returns 150. Does the And monad fulfill the monad laws? In a proper monad an interim (return x) (without a '<-') is a no-op. From conrad at metadecks.org Wed Jan 23 01:34:10 2013 From: conrad at metadecks.org (Conrad Parker) Date: Wed, 23 Jan 2013 08:34:10 +0800 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: Message-ID: On 23 January 2013 08:04, John Wiegley wrote: > monad-bool implements a pair of Boolean monoids and monads, to support > short-circuiting, value-returning computations similar to what Python and Ruby > offer with their native && and || operators. > ... > Use 'onlyIf' with AndM and AndMT to guard later statements, which are only > evaluated if every preceding 'onlyIf' evaluates to True. For example: > > foo :: AndM Int > foo = do onlyIf (True == True) > return 100 > onlyIf (True == True) > return 150 > onlyIf (True == False) > return 200 > > When run with `evalAndM foo (-1)` (where (-1) provides a default value), 'foo' > returns 150. > > Use 'endIf' with OrM and OrMT to chain statements, which are only executed if > every preceding 'endIf' evaluated to False. For example: > > bar :: OrM Int > bar = do endIf (True == False) > return 100 > endIf (True == False) > return 150 > endIf (True == True) > return 200 John, these sound powerful, but how would I do something esoteric like if/elseIf/endIf ? Conrad. From roma at ro-che.info Wed Jan 23 01:58:44 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 23 Jan 2013 02:58:44 +0200 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: Message-ID: <20130123005844.GA8131@sniper> * John Wiegley [2013-01-22 18:04:36-0600] > monad-bool implements a pair of Boolean monoids and monads, to support > short-circuiting, value-returning computations similar to what Python and Ruby > offer with their native && and || operators. Random thoughts after compiling/looking at the code: - your constraint on 'base' is too restrictive ? I had to relax it in order to compile the package (my 'base' is 4.6.0.1, which came with GHC 7.6.2 RC) - personally I never missed "0 as False"... - what do you need unsafeCoerce for? Roman From johnw at fpcomplete.com Wed Jan 23 02:24:59 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Tue, 22 Jan 2013 19:24:59 -0600 Subject: [Haskell-cafe] [Haskell] ANN: monad-bool 0.1 In-Reply-To: (Henning Thielemann's message of "Wed, 23 Jan 2013 01:12:48 +0100 (CET)") References: Message-ID: >>>>> Henning Thielemann writes: > Does the And monad fulfill the monad laws? In a proper monad an interim > (return x) (without a '<-') is a no-op. You are very right. I will make the necessary changes. -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From johnw at fpcomplete.com Wed Jan 23 02:25:42 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Tue, 22 Jan 2013 19:25:42 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: (Conrad Parker's message of "Wed, 23 Jan 2013 08:34:10 +0800") References: Message-ID: >>>>> Conrad Parker writes: > these sound powerful, but how would I do something esoteric like > if/elseIf/endIf ? Can you show me an example of what you'd like to express? -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From krismicinski at gmail.com Wed Jan 23 02:37:10 2013 From: krismicinski at gmail.com (Kristopher Micinski) Date: Tue, 22 Jan 2013 20:37:10 -0500 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: I don't believe that was really the point of the C compiler, and I'd suspect you'd have a hard time with the runtime. By the way, the Android APIs aren't really meant to be used by native code: the only real use for native code in Android is GPU code and math code (think games and DSP-type programs). Wrapping the libraries for use by native code is *possible*, but getting it right will be very hard: it's not like you're going to have a simple C library which lets you touch Android's `View` hierarchy, for example. On top of that, you'd also want to have a "true" functional interface to Android's API: you probably don't want to just use the Java API verbatim. What was your implementation plan for doing this, should you get a runtime up for Haskell code? I'd guess that you can pretty easily get a Haskell program to *run* on the device from the device's command line. But I'd also guess that getting it to play well with Android will be a *lot* of work. I don't really have the time or GHC internals experience to do this, but if someone wanted help on it, I'd be interested. The web interface idea is okay, but obviously you're punting on speed if you do that. You might look into the Boot2Gecko project at Mozilla, it has similar aspirations. Kris On Tue, Jan 22, 2013 at 2:40 PM, Andrew Pennebaker wrote: > Can we un-deprecate GHC's ability to compile to C code? C may be the best > option to bridge to mobile, as Android, iOS, and Windows RT do support C/C++ > apps. > > On Jan 22, 2013 2:14 PM, "Dan Choi" wrote: >> >> >> What about the option of using Haskell's Parsec or AttoParsec to implement >> a Haskell-ish language that compiles down not to machine code but to >> Objective C or Android Java? Like how CoffeeScript compiles down to >> JavaScript. >> >> >> >> On Saturday, January 19, 2013 1:58:03 PM UTC-5, Casey Hawthorne wrote: >>> >>> You would need native compilers for all the platforms and/or virtual >>> machine technology. >>> >>> Might be easier to have the browser connect to a Haskell app. >>> >>> >>> On Sat, Jan 19, 2013 at 10:42 AM, Andrew Pennebaker >>> wrote: >>> > There are currently very few options, especially free and open source >>> > options, when it comes to developing cross-platform mobile >>> > applications. >>> > It's basically web apps with JavaScript, or C++. If Haskell supported >>> > app >>> > development on Android, iOS, and Windows RT, that alone would bring in >>> > more >>> > developers. >>> > >>> > Similarly, there are very few languages for mobile development that >>> > take >>> > advantage of multiple cores and multiple CPUs. Haskell's `parmap` is an >>> > amazing selling point. Can we please prioritize mobile support? I'd >>> > much >>> > rather write everything in ML than PhoneGap. >>> > >>> > -- >>> > Cheers, >>> > >>> > Andrew Pennebaker >>> > www.yellosoft.us >>> > >>> > _______________________________________________ >>> > Haskell-Cafe mailing list >>> > Haskel... at haskell.org >>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > >>> >>> >>> >>> -- >>> -- >>> Regards, >>> KC >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskel... at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From conrad at metadecks.org Wed Jan 23 03:36:03 2013 From: conrad at metadecks.org (Conrad Parker) Date: Wed, 23 Jan 2013 10:36:03 +0800 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: Message-ID: On 23 January 2013 09:25, John Wiegley wrote: >>>>>> Conrad Parker writes: > >> these sound powerful, but how would I do something esoteric like >> if/elseIf/endIf ? > > Can you show me an example of what you'd like to express? Your examples look vaguely like an if/elseif/else block from other languages, so I was wondering if mimicking that was possible. Also, can this be used with RebindableSyntax? http://www.haskell.org/ghc/docs/7.0.2/html/users_guide/syntax-extns.html#rebindable-syntax Conrad. From es at ertes.de Wed Jan 23 04:13:42 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Wed, 23 Jan 2013 04:13:42 +0100 Subject: [Haskell-cafe] ANN: monad-bool 0.1 References: <20130123005844.GA8131@sniper> Message-ID: <20130123041342.69aa5520@tritium.streitmacht.eu> Roman Cheplyaka wrote: > - what do you need unsafeCoerce for? The unsafeCoerce is needed because the library is severely broken. Consider this: do onlyIf False x <- c onlyIf True return x There is a good reason why Haskell's type system would never have allowed to write this library. I recommend the author to try again without unsafeCoerce. It won't work. Also I'm quite sure that the monads don't have associative (>>) either. Consider this: yes = onlyIf True no = onlyIf False yes >> x >> no >> y According to the intended semantics this should result in 'x', but what does yes >> (x >> no) >> y result in? Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From johnw at fpcomplete.com Wed Jan 23 07:02:01 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Wed, 23 Jan 2013 00:02:01 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: <20130123005844.GA8131@sniper> (Roman Cheplyaka's message of "Wed, 23 Jan 2013 02:58:44 +0200") References: <20130123005844.GA8131@sniper> Message-ID: >>>>> Roman Cheplyaka writes: > - what do you need unsafeCoerce for? Ok, after much discussion with edwardk and shachaf, I came to realize a few things: 1. The functionality of my two monads 'AndM' and 'OrR' can be boiled down to two helper functions inside EitherT: returnIf :: Monad m => Bool -> e -> EitherT e m () returnIf p a = if p then left a else right () returnUnless :: Monad m => Bool -> e -> EitherT e m () returnUnless p = returnIf (not p) These let you short-circuit monadic computations, returning the short-circuiting value as a Left; or as a Right if it reaches the end. 2. The 'shortcircuit' library already provides short-circuiting variants of && and || that work just like Python's and Ruby's. In fact, I think I'll talk to aristid about merging my Monoid definitions into that library. Here are the updated docs: http://ftp.newartisans.com/pub/monoid-bool/Data-Monoid-Bool.html I'll ask Ross Paterson to deprecate monad-bool. And in future, I'll seek review here first before uploading. -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From johnw at fpcomplete.com Wed Jan 23 07:03:47 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Wed, 23 Jan 2013 00:03:47 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: <20130123041342.69aa5520@tritium.streitmacht.eu> ("Ertugrul =?utf-8?Q?S=C3=B6ylemez=22's?= message of "Wed, 23 Jan 2013 04:13:42 +0100") References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: >>>>> Ertugrul S?ylemez writes: > There is a good reason why Haskell's type system would never have allowed to > write this library. I recommend the author to try again without > unsafeCoerce. It won't work. You are right, and in fact what I wanted to do cannot be done. It requires distinguishing the final value as either a Left (result from short-circuiting) or a Right (final value). And EitherT can already do that, it just lacks a convenience function to make it easier (i.e, not having to write lots of nested if statements). -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From johnw at fpcomplete.com Wed Jan 23 07:16:26 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Wed, 23 Jan 2013 00:16:26 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: (John Wiegley's message of "Wed, 23 Jan 2013 00:03:47 -0600") References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: >>>>> John Wiegley writes: > And EitherT can already do that, it just lacks a convenience function to > make it easier (i.e, not having to write lots of nested if statements). Never mind, when/unless + left work just fine for this. -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From johnw at fpcomplete.com Wed Jan 23 08:10:10 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Wed, 23 Jan 2013 01:10:10 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: (John Wiegley's message of "Wed, 23 Jan 2013 00:16:26 -0600") References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: >>>>> John Wiegley writes: > Never mind, when/unless + left work just fine for this. You know, it's been a humorous day. First ekmett showed that I can't make a sane Monad instance for AndM or OrM. Then I discovered I can't make a reasonable Monoid (no mempty, given only 'toBool'), so I dropped down to a Semigroup. Further, my combinators for EitherT can be implemented using just 'when' and 'left' to provide the short-circuiting. Already I had very little code left, until he showed me the Applicative instance for Either, plus a little trick: >>> Right 1 *> Right 2 *> Left 2 *> Right 5 Left 2 -- same functionality as my And semigroup >>> let Left x |> y = y; x |> _ = x in Left 1 |> Right 2 |> Right 3 Right 2 -- same functionality as my Or semigroup And poof, all my code just disappeared... -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From es at ertes.de Wed Jan 23 08:18:38 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Wed, 23 Jan 2013 08:18:38 +0100 Subject: [Haskell-cafe] ANN: monad-bool 0.1 References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: <20130123081838.73e8487e@tritium.streitmacht.eu> John Wiegley wrote: > And poof, all my code just disappeared... Welcome to Haskell. =) Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From alexander.kjeldaas at gmail.com Wed Jan 23 09:00:50 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Wed, 23 Jan 2013 09:00:50 +0100 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: If we step back, I think the lesson here is that Haskell libraries exist, but the concepts are far enough from what you expect to exist given background knowledge from another programming language. So what is actually needed is not monad-bool, but the equivalent documentation that makes a programmer which is not an expert in Haskell connect the dots like you did today. Alexander On Wed, Jan 23, 2013 at 8:10 AM, John Wiegley wrote: > >>>>> John Wiegley writes: > > > Never mind, when/unless + left work just fine for this. > > You know, it's been a humorous day. > > First ekmett showed that I can't make a sane Monad instance for AndM or > OrM. > > Then I discovered I can't make a reasonable Monoid (no mempty, given only > 'toBool'), so I dropped down to a Semigroup. Further, my combinators for > EitherT can be implemented using just 'when' and 'left' to provide the > short-circuiting. > > Already I had very little code left, until he showed me the Applicative > instance for Either, plus a little trick: > > >>> Right 1 *> Right 2 *> Left 2 *> Right 5 > Left 2 -- same functionality as my And semigroup > > >>> let Left x |> y = y; x |> _ = x in Left 1 |> Right 2 |> Right 3 > Right 2 -- same functionality as my Or semigroup > > And poof, all my code just disappeared... > > -- > John Wiegley > FP Complete Haskell tools, training and consulting > http://fpcomplete.com johnw on #haskell/irc.freenode.net > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Wed Jan 23 11:28:01 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Wed, 23 Jan 2013 08:28:01 -0200 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: <20130123005844.GA8131@sniper> Message-ID: Em 23/01/2013 04:03, "John Wiegley" escreveu: > I'll ask Ross Paterson to deprecate monad-bool. And in future, I'll seek > review here first before uploading. Release early and release often, don't worry about asking the mailing list beforehand (unless you want to, of course). Cheers, -- Felipe. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Wed Jan 23 16:54:15 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 23 Jan 2013 10:54:15 -0500 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: On Tue, Jan 22, 2013 at 8:37 PM, Kristopher Micinski wrote: > By the way, the Android APIs aren't really meant to be used by native > code: the only real use for native code in Android is GPU code and > math code (think games and DSP-type programs). > They may not be "meant" to be in some sense, but from Android 2.3 on they are exposed for such use --- and I believe language porting like this is one of the intended uses. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Wed Jan 23 17:01:07 2013 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Wed, 23 Jan 2013 23:01:07 +0700 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: <20130123005844.GA8131@sniper> Message-ID: On Wed, Jan 23, 2013 at 5:28 PM, Felipe Almeida Lessa < felipe.lessa at gmail.com> wrote: > don't worry about asking the mailing list beforehand (unless you want to, > of course). > > Seconded! Just a cursory sweep of this thread reveals so much learning and discovery taking place that would be utterly lost should a self-censoring arrant pedantry take hold. Props to John for motivating the use case (on haskell-cafe, no less!) for monad-bool that sparked this discussion in the first place. Half of the time, I can't tell what problem a package is trying to solve. I look forward to seeing more of his contributions. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From krismicinski at gmail.com Wed Jan 23 19:48:24 2013 From: krismicinski at gmail.com (Kristopher Micinski) Date: Wed, 23 Jan 2013 13:48:24 -0500 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: In what way are they exposed for use? I certainly haven't seen any API which lets you touch any of the standard GUI utilities without writing JNI wrappers that communicate to the Java based UI elements. As far as I know there is no way to use the actual Android API: you have to write a wrapper through the JNI to use the Java version. Can you point to a native library which allows you to hook in to the Android SDK? I'd be very interested in seeing it. Kris On Wed, Jan 23, 2013 at 10:54 AM, Brandon Allbery wrote: > On Tue, Jan 22, 2013 at 8:37 PM, Kristopher Micinski > wrote: >> >> By the way, the Android APIs aren't really meant to be used by native >> code: the only real use for native code in Android is GPU code and >> math code (think games and DSP-type programs). > > > They may not be "meant" to be in some sense, but from Android 2.3 on they > are exposed for such use --- and I believe language porting like this is one > of the intended uses. > > > -- > brandon s allbery kf8nh sine nomine associates > allbery.b at gmail.com ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net From krismicinski at gmail.com Wed Jan 23 19:56:35 2013 From: krismicinski at gmail.com (Kristopher Micinski) Date: Wed, 23 Jan 2013 13:56:35 -0500 Subject: [Haskell-cafe] Mobile app development? In-Reply-To: References: Message-ID: For reference, the only components provided by the Android platform (listed on the Android website, and what I found digging through the provided NDK) are: libc (C library) headers libm (math library) headers JNI interface headers libz (Zlib compression) headers liblog (Android logging) header OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers libjnigraphics (Pixel buffer access) header (for Android 2.2 and above). A Minimal set of headers for C++ support OpenSL ES native audio libraries Android native application APIS Having these things is a far cry from being able to use any of the typical Android facilities from native code: you can't even implement GUI normally. The one project I've seen which attempts to generate stubs for easy use by native code is: http://code.google.com/p/cle-for-android/ I'm not sure of the current status, but the last I checked it was still a bit premature. Kris On Wed, Jan 23, 2013 at 1:48 PM, Kristopher Micinski wrote: > In what way are they exposed for use? I certainly haven't seen any > API which lets you touch any of the standard GUI utilities without > writing JNI wrappers that communicate to the Java based UI elements. > > As far as I know there is no way to use the actual Android API: you > have to write a wrapper through the JNI to use the Java version. > > Can you point to a native library which allows you to hook in to the > Android SDK? I'd be very interested in seeing it. > > Kris > > > On Wed, Jan 23, 2013 at 10:54 AM, Brandon Allbery wrote: >> On Tue, Jan 22, 2013 at 8:37 PM, Kristopher Micinski >> wrote: >>> >>> By the way, the Android APIs aren't really meant to be used by native >>> code: the only real use for native code in Android is GPU code and >>> math code (think games and DSP-type programs). >> >> >> They may not be "meant" to be in some sense, but from Android 2.3 on they >> are exposed for such use --- and I believe language porting like this is one >> of the intended uses. >> >> >> -- >> brandon s allbery kf8nh sine nomine associates >> allbery.b at gmail.com ballbery at sinenomine.net >> unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net From petr.mvd at gmail.com Wed Jan 23 21:49:33 2013 From: petr.mvd at gmail.com (Petr P) Date: Wed, 23 Jan 2013 21:49:33 +0100 Subject: [Haskell-cafe] The Coverage Condition of functional dependencies Message-ID: Hi, trying to understand UndecidableInstances (and to find and answer to < http://stackoverflow.com/q/14476230/1333025>), I was trying to find out why "mtl" needs UndecidableInstances. The reason is that instances like > instance MonadState s m => MonadState s (ContT r m) where don't satisfy the Coverage Condition: "The Coverage Condition. For each functional dependency, tvsleft -> tvsright, of the class, every type variable in S(tvsright) must appear in S(tvsleft), where S is the substitution mapping each type variable in the class declaration to the corresponding type in the instance declaration. " (See http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/type-class-extensions.html#instance-rules ) In other words, "s" isn't expressed using type variables in "ContT r m". But in these cases, it's actually possible. Because of the assertion "MonadState s m" and its dependency "m -> s" we know that "s" will be always deducible from "m". I wonder, would it be possible to augment the type checker to realize this? It seems reasonable: Before comparing if S(tvsright) is a subset of S(tvsleft), we'd add every type variable to S(tvsleft) that is determined from it using functional dependencies in the assertion of the instance. Best regards, Petr -------------- next part -------------- An HTML attachment was scrubbed... URL: From yankin013 at gmail.com Wed Jan 23 22:08:28 2013 From: yankin013 at gmail.com (Andrey Yankin) Date: Thu, 24 Jan 2013 00:08:28 +0300 Subject: [Haskell-cafe] Space leaks in function that uses Data.Vector.Mutable Message-ID: Hi! I have a "low-level" function for insertion element into mutable vector. It looks like this: place :: (PrimMonad m) => MV.MVector (PrimState m) (Int, t) -> (Int, t) -> Int -> m () place v max@(val1,_) i = place' i where place' i = do let j = i - 1 if j < 0 then return () else do curr@(val2, _) <- MV.unsafeRead v j -- <<<<< if val2 > val1 then do MV.unsafeWrite v j max MV.unsafeWrite v i curr place' j else return () It searches a right place for the i-th element, moving it towards beginning . Surprisingly, it works, but is slow. Time profiling says this: COST CENTRE MODULE %time %alloc ticks bytes place.place' Main 40.1 77.1 9167 12169223232 And heap profiling says that most of allocations are for Int and (,). I think, binding of unsafeRead to curr and val might allocate my Precious memory more than, maybe, it is needed. Am I right? Is it some strictness that I need? Is there anything I can do in this situation? Or should I look outside of this function? PS Emergence of this piece of code is a long story. Originally I was trying to solve Project Euler's problem 411. But now it is a different issue. -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.mvd at gmail.com Wed Jan 23 22:14:06 2013 From: petr.mvd at gmail.com (Petr P) Date: Wed, 23 Jan 2013 22:14:06 +0100 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: 2013/1/23 John Wiegley > >>>>> John Wiegley writes: > > > Never mind, when/unless + left work just fine for this. > > You know, it's been a humorous day. ... > Don't take it so hard. Trying to reinvent something is always a great exercise and makes you really understand the problem. And it can have interesting results too. One of my university professors once heard about some concept, but didn't know the details. He tried to derive the concept himself, and he actually invented something different, new and very useful. ... > > > >>> let Left x |> y = y; x |> _ = x in Left 1 |> Right 2 |> Right 3 > Right 2 -- same functionality as my Or semigroup > This strongly reminds me of `mplus` of `Maybe`. The problem is we cannot define a generic instance `MonadPlus Either` because we cannot define `mzero` (but if we restrict the left type, we can achieve this, like in "instance Error e => MonadPlus (Either e)"). Another possibility how to capture this "Or" behavior is `MonadError`. You could define |> for any instance of `MonadError`, including Either (currently with some restrictions): (|>) :: MonadError e m => m a -> m a -> m a x |> y = x `catchError` (const y) Best regards, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From acopton at gmail.com Wed Jan 23 23:32:25 2013 From: acopton at gmail.com (Alexander Bernauer) Date: Wed, 23 Jan 2013 23:32:25 +0100 Subject: [Haskell-cafe] ANN: hgdbmi 0.2, GDB Machine Interface In-Reply-To: <20130119121439.GA2883@machine> References: <20130118102230.GA4407@machine> <20130119121439.GA2883@machine> Message-ID: On Sat, Jan 19, 2013 at 1:14 PM, Daniel Trstenjak wrote: > Yes, I still think that having separate modules can be beneficial, > also for the ease of reference. > I thought of putting all of your modules under the version indicating > module. Thank you, Daniel. I will consider these changes (hopefully) soon. Greetings, Alex From johan.tibell at gmail.com Thu Jan 24 00:03:57 2013 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed, 23 Jan 2013 15:03:57 -0800 Subject: [Haskell-cafe] Space leaks in function that uses Data.Vector.Mutable In-Reply-To: References: Message-ID: Hi! You have to look outside the place function, which is strict enough. I would look for a call to unsafeWrite that doesn't evaluate it's argument before writing it into the vector. Perhaps you're doing something like: MV.unsafeWrite (i + 1, ...) Since tuples are lazy the i + 1 will be stored as a thunk. I recommend doing: data DescriptiveName a = DescriptiveName {-# UNPACK #-} !Int a and using a MV.MVector (PrimState m) (DescriptiveName t) if speed is really of the essence. Aside: You can't optimize place slightly by: * Making it strict in val1, and * Making it inline. The reason you want it to inline* is that's the function is polymorphic and inlining it at a call site when you know if you're working in IO and ST will improve performance. Here's the slightly optimized version: place :: (PrimMonad m) => MV.MVector (PrimState m) (Int, t) -> (Int, t) -> Int -> m () place v max@(!val1,_) i = place' i where place' i = do let j = i - 1 if j < 0 then return () else do curr@(val2, _) <- MV.unsafeRead v j if val2 > val1 then do MV.unsafeWrite v j max MV.unsafeWrite v i curr place' j else return () {-# INLINE place #-} * It should be enough to write two SPECIALIZE pragmas, one for IO and one for ST, but GHC doesn't seem to like that for some reason: /tmp/Test.hs:24:1: Warning: RULE left-hand side too complicated to desugar (place @ (ST s) @ t ($fPrimMonadST @ s ($fMonadST @ s))) `cast` ... /tmp/Test.hs:25:1: Warning: RULE left-hand side too complicated to desugar (place @ IO @ t $fPrimMonadIO) `cast` ... Cheers, Johan From wren at freegeek.org Thu Jan 24 00:23:24 2013 From: wren at freegeek.org (wren ng thornton) Date: Wed, 23 Jan 2013 15:23:24 -0800 Subject: [Haskell-cafe] ANN: monad-bool 0.1 Message-ID: On 1/23/13 3:00 AM, Alexander Kjeldaas wrote: > If we step back, I think the lesson here is that Haskell libraries exist, > but the concepts are far enough from what you expect to exist given > background knowledge from another programming language. > > So what is actually needed is not monad-bool, but the equivalent > documentation that makes a programmer which is not an expert in Haskell > connect the dots like you did today. Definitely. We could even set up NotOnHackage: a "package" repository just like Hackage, except the packages are just documentation on why there is no such package. Implementation-wise it's just a wiki; but the idea is about how to organize the wiki. NotOnHackage should be organized and searchable similar to Hackage itself, so that people can look there when nothing looks promising on Hackage. -- Live well, ~wren From davidleothomas at gmail.com Thu Jan 24 00:27:43 2013 From: davidleothomas at gmail.com (David Thomas) Date: Wed, 23 Jan 2013 15:27:43 -0800 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: Message-ID: Couldn't this be actually on hackage, so one search turns up what you want? On Jan 23, 2013 3:24 PM, "wren ng thornton" wrote: > On 1/23/13 3:00 AM, Alexander Kjeldaas wrote: > > If we step back, I think the lesson here is that Haskell libraries exist, > > but the concepts are far enough from what you expect to exist given > > background knowledge from another programming language. > > > > So what is actually needed is not monad-bool, but the equivalent > > documentation that makes a programmer which is not an expert in Haskell > > connect the dots like you did today. > > Definitely. > > We could even set up NotOnHackage: a "package" repository just like > Hackage, except the packages are just documentation on why there is no > such package. Implementation-wise it's just a wiki; but the idea is about > how to organize the wiki. NotOnHackage should be organized and searchable > similar to Hackage itself, so that people can look there when nothing > looks promising on Hackage. > > -- > Live well, > ~wren > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Thu Jan 24 00:33:14 2013 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Thu, 24 Jan 2013 06:33:14 +0700 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: Message-ID: On Thu, Jan 24, 2013 at 6:23 AM, wren ng thornton wrote: > NotOnHackage: a "package" repository just like > Hackage, except the packages are just documentation on why there is no > such package. > Love the idea! It'll make us even more unique among other PLs and even more ways to be smug: "A bigger set of libraries? So what? Haskell's the only one with a /negative/ repo. Eat your heart out, Python!" ;) -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnw at fpcomplete.com Thu Jan 24 00:57:29 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Wed, 23 Jan 2013 17:57:29 -0600 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: (Petr P.'s message of "Wed, 23 Jan 2013 22:14:06 +0100") References: <20130123005844.GA8131@sniper> <20130123041342.69aa5520@tritium.streitmacht.eu> Message-ID: >>>>> Petr P writes: > Don't take it so hard. Trying to reinvent something is always a great > exercise and makes you really understand the problem. And it can have > interesting results too. One of my university professors once heard about > some concept, but didn't know the details. He tried to derive the concept > himself, and he actually invented something different, new and very useful. Thank you very much to everyone for the encouragement, and especially to Edward and Shachaf for the education on #haskell. It will be hard to unlearn a lesson like this one. :) And I will certainly endeavor to make the most valuable mistakes I can from here on, with the help of such a gracious community. :) Yours, -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From dstcruz at gmail.com Thu Jan 24 04:49:33 2013 From: dstcruz at gmail.com (Daniel Santa Cruz) Date: Wed, 23 Jan 2013 22:49:33 -0500 Subject: [Haskell-cafe] Haskell Weekly News: Issue 255 Message-ID: Welcome to issue 255 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the weeks of January 06 to 19, 201. Quotes of the Week * ky3: Indexed monads are just categories in the category of endofunctors, what's the problem? * tac: I guess I'm just living in a fantasy world where the docs tell you how to use such a basic API :P * shachaf: 3.0 is an edwardk phase, not just a version number. It's like Picasso's Blue Period. * cmccann: Clearly the reason why edwardk uses Haskell now is because every C++ compiler has a restraining order against him. * shachaf: I'm not sure what your question is, but maybe lens is the answer. * cmccann: * cmccann has concluded that lenses are just a category whose objects are english prepositions and whose morphisms are all unsafeCoerce * shachaf: Some people, when asking about a problem in #haskell, get a link to okmij.org. Now they have two problems. * quicksilver: It returns undefined for convenience. I'm not really sure it's that convenient, but that's why. * edwardk: cmccann: let me get this straight you are saying that someone [mm_freak] who by their very nick admits to being a freak did something freakish? Top Reddit Stories * LiquidHaskell: Refinement Types in Haskell via SMT Domain: goto.ucsd.edu, Score: 71, Comments: 22 On Reddit: [1] http://goo.gl/PE2nf Original: [2] http://goo.gl/P3Gm9 * Hakyll 4.0 released Domain: jaspervdj.be, Score: 59, Comments: 19 On Reddit: [3] http://goo.gl/IQAXq Original: [4] http://goo.gl/AbLnM * When Haskell is faster than C Domain: paulspontifications.blogspot.co.uk, Score: 52, Comments: 23 On Reddit: [5] http://goo.gl/3rj8J Original: [6] http://goo.gl/N2cbA * I'm teaching an introductory 12-week class on Haskell. Join in for a journey! Domain: reddit.com, Score: 45, Comments: 15 On Reddit: [7] http://goo.gl/TsnQ5 Original: [8] http://goo.gl/EMMVR * Subtractable values are torsors Domain: ro-che.info, Score: 42, Comments: 15 On Reddit: [9] http://goo.gl/4IcMp Original: [10] http://goo.gl/6YJrY * Chordify: extract chord sequences from MP3's using HarmTrace Domain: chordify.net, Score: 42, Comments: 8 On Reddit: [11] http://goo.gl/8J7rA Original: [12] http://goo.gl/ySfR5 * Getting Started with Haskell Domain: bob.ippoli.to, Score: 41, Comments: 8 On Reddit: [13] http://goo.gl/4Evnb Original: [14] http://goo.gl/nzg9o * Using AngularJS with Haskell Snap Domain: nurpax.github.com, Score: 40, Comments: 19 On Reddit: [15] http://goo.gl/SH8e1 Original: [16] http://goo.gl/0lSyN * Down with kinds: adding dependent heterogeneous equality to to FC Domain: cis.upenn.edu, Score: 38, Comments: 14 On Reddit: [17] http://goo.gl/iEvyI Original: [18] http://goo.gl/cH0Eo * Fixing GADTs : Generic recursion schemes for GADTs using fixed points of higher-order functors Domain: timphilipwilliams.com, Score: 38, Comments: 25 On Reddit: [19] http://goo.gl/dEMq9 Original: [20] http://goo.gl/vnjhp * What's the importance of Category Theory in Haskell? Is it worth really studying? Domain: self.haskell, Score: 37, Comments: 60 On Reddit: [21] http://goo.gl/T430r Original: [22] http://goo.gl/T430r * Parsing Markdown with Parsec: How Pandoc does it Domain: youtube.com, Score: 35, Comments: 13 On Reddit: [23] http://goo.gl/TN9TJ Original: [24] http://goo.gl/zpX7f * Clckwrks, from the creator of Happstack, is developing into a clean alternative to Wordpress Domain: clckwrks.com, Score: 34, Comments: 7 On Reddit: [25] http://goo.gl/L9WXx Original: [26] http://goo.gl/FZRpU * pipes-safe-1.0 - Resource management and exception handling for pipes Domain: haskellforall.com, Score: 32, Comments: 27 On Reddit: [27] http://goo.gl/HeLWz Original: [28] http://goo.gl/1hTFc Top StackOverflow Questions * values, types, kinds,? as an infinite sequence? votes: 36, answers: 1 Read on SO: [29] http://goo.gl/lyyYc * Why is this a useful warning in Haskell when pattern matching? ?Defined but not used? votes: 17, answers: 3 Read on SO: [30] http://goo.gl/iQLFq * Why are getArgs and getProgName IO actions? votes: 16, answers: 3 Read on SO: [31] http://goo.gl/5ZPYO * Can GADTs be used to prove type inequalities in GHC? [duplicate] votes: 14, answers: 2 Read on SO: [32] http://goo.gl/fDdha * Applying Denotational Semantics to design of Programs [migrated] votes: 14, answers: 0 Read on SO: [33] http://goo.gl/KLOCX * Examples where compiler-optimized functional code performs better than imperative code votes: 14, answers: 1 Read on SO: [34] http://goo.gl/Fzqdx * Why is there only one non-strict function from Int to Int? votes: 12, answers: 2 Read on SO: [35] http://goo.gl/KXcAy * Dependency injection in Haskell: solving the task idiomatically votes: 12, answers: 3 Read on SO: [36] http://goo.gl/xTcYc * What does a Haskell comment starting with `{- |` generally mean? votes: 11, answers: 1 Read on SO: [37] http://goo.gl/zNikw * Is operational really isomorphic to a free monad? votes: 10, answers: 3 Read on SO: [38] http://goo.gl/AJlgH Until next time, [39]+Daniel Santa Cruz References 1. http://goto.ucsd.edu/~rjhala/liquid/haskell/blog/blog/2013/01/01/refinement-types-101.lhs/ 2. http://www.reddit.com/r/haskell/comments/16w3hp/liquidhaskell_refinement_types_in_haskell_via_smt/ 3. http://jaspervdj.be/posts/2013-01-16-hakyll-4.0.html 4. http://www.reddit.com/r/haskell/comments/16ojtv/hakyll_40_released/ 5. http://paulspontifications.blogspot.co.uk/2013/01/when-haskell-is-faster-than-c.html 6. http://www.reddit.com/r/haskell/comments/16tryo/when_haskell_is_faster_than_c/ 7. http://www.reddit.com/r/UniversityofReddit/comments/169jfe/class_introduction_to_haskell/ 8. http://www.reddit.com/r/haskell/comments/169k67/im_teaching_an_introductory_12week_class_on/ 9. http://ro-che.info/articles/2013-01-08-torsors.html 10. http://www.reddit.com/r/haskell/comments/166iju/subtractable_values_are_torsors/ 11. http://chordify.net/pages/how-to-use-chordify/ 12. http://www.reddit.com/r/haskell/comments/16u44u/chordify_extract_chord_sequences_from_mp3s_using/ 13. http://bob.ippoli.to/archives/2013/01/11/getting-started-with-haskell/ 14. http://www.reddit.com/r/haskell/comments/16fegr/getting_started_with_haskell/ 15. http://nurpax.github.com/posts/2013-01-13-angularjs-and-haskell.html 16. http://www.reddit.com/r/haskell/comments/16iaiq/using_angularjs_with_haskell_snap/ 17. http://www.cis.upenn.edu/~eir/papers/2013/jmnokinds/jmnokinds.pdf 18. http://www.reddit.com/r/haskell/comments/167c21/down_with_kinds_adding_dependent_heterogeneous/ 19. http://www.timphilipwilliams.com/posts/2013-01-16-fixing-gadts.html 20. http://www.reddit.com/r/haskell/comments/16qr6q/fixing_gadts_generic_recursion_schemes_for_gadts/ 21. http://www.reddit.com/r/haskell/comments/16i322/whats_the_importance_of_category_theory_in/ 22. http://www.reddit.com/r/haskell/comments/16i322/whats_the_importance_of_category_theory_in/ 23. http://www.youtube.com/watch?v=nCwG9ijQMuQ&t=01m22s 24. http://www.reddit.com/r/haskell/comments/16kf0j/parsing_markdown_with_parsec_how_pandoc_does_it/ 25. http://www.clckwrks.com/ 26. http://www.reddit.com/r/haskell/comments/168j2w/clckwrks_from_the_creator_of_happstack_is/ 27. http://www.haskellforall.com/2013/01/pipes-safe-10-resource-management-and.html 28. http://www.reddit.com/r/haskell/comments/16mban/pipessafe10_resource_management_and_exception/ 29. http://stackoverflow.com/questions/14401689/values-types-kinds-as-an-infinite-sequence 30. http://stackoverflow.com/questions/14309396/why-is-this-a-useful-warning-in-haskell-when-pattern-matching-defined-but-not 31. http://stackoverflow.com/questions/14295582/why-are-getargs-and-getprogname-io-actions 32. http://stackoverflow.com/questions/14273235/can-gadts-be-used-to-prove-type-inequalities-in-ghc 33. http://stackoverflow.com/questions/14349232/applying-denotational-semantics-to-design-of-programs 34. http://stackoverflow.com/questions/14357918/examples-where-compiler-optimized-functional-code-performs-better-than-imperativ 35. http://stackoverflow.com/questions/14262014/why-is-there-only-one-non-strict-function-from-int-to-int 36. http://stackoverflow.com/questions/14327327/dependency-injection-in-haskell-solving-the-task-idiomatically 37. http://stackoverflow.com/questions/14270500/what-does-a-haskell-comment-starting-with-generally-mean 38. http://stackoverflow.com/questions/14263363/is-operational-really-isomorphic-to-a-free-monad 39. https://plus.google.com/105107667630152149014/about -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Thu Jan 24 07:40:45 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 24 Jan 2013 07:40:45 +0100 Subject: [Haskell-cafe] ANN: monad-bool 0.1 References: Message-ID: <20130124074045.63cf39dd@tritium.streitmacht.eu> David Thomas wrote: > > We could even set up NotOnHackage: a "package" repository just like > > Hackage, except the packages are just documentation on why there is > > no such package. Implementation-wise it's just a wiki; but the idea > > is about how to organize the wiki. NotOnHackage should be organized > > and searchable similar to Hackage itself, so that people can look > > there when nothing looks promising on Hackage. > > Couldn't this be actually on hackage, so one search turns up what you > want? Yes. There is no reason to put up a second Hackage for that one. Without changing anything in the current system, packages can just update their categories, so that they will be displayed below "Defunct" or something like that. This is fine, as only the categories of the latest version are significant. If you think this is a good idea, I will start with some of my packages. =) Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From theo.england at skillsmatter.com Thu Jan 24 13:44:05 2013 From: theo.england at skillsmatter.com (Theo) Date: Thu, 24 Jan 2013 04:44:05 -0800 (PST) Subject: [Haskell-cafe] Video - Simon Marlow on High Performance Concurrency - Skills Matter's Haskell eXchange Message-ID: <60a092e0-0226-474a-a2b8-76efc7434150@googlegroups.com> Simon Marlow took the floor at the first annual Haskell eXchange last year to talk about high performance concurrency. Simon observes that the haskell community has been spending inordinate amounts of time designing beautiful programming models and APIs, whilst spending relatively less time building applications that solve real problems. In this talk Simon wants to start from an application that they want to build -- a simple concurrent chat server---and use that to inform some library design. Along the way we?ll learn useful techniques for building concurrent network applications, and show how the power of Software Transactional Memory can be brought to bear. Yet this application demonstrates some holes in the abstractions provided by Haskell as it stands, Simon shows a simple layer called ?async? that fills the gap and should be widely useful for concurrent programming. To watch the podcast in full follow this link - http://bit.ly/10Bzhr1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dhelta.diaz at gmail.com Thu Jan 24 15:31:10 2013 From: dhelta.diaz at gmail.com (=?UTF-8?Q?Daniel_D=C3=ADaz_Casanueva?=) Date: Thu, 24 Jan 2013 09:31:10 -0500 Subject: [Haskell-cafe] Data.Sequence and replicateM Message-ID: Hi Cafe, I was coding this morning when I suddenly found something that surprised me. It's been a short time since I am really caring about the performance of my programs. Before, I was just caring about their correctness. So I am trying different things and profiling to see differences. One difference I have found surprising is that the function f is MUCH faster and less space consuming than the function g: import Control.Monad import qualified Data.Sequence as Seq type Seq = Seq.Seq f :: Monad m => Int -> m a -> m (Seq a) f n = fmap Seq.fromList . replicateM n g :: Monad m => Int -> m a -> m (Seq a) g = Seq.replicateM Maybe is just in my test case, where the Int argument is big and the monadic action short, but it looks to me that Data.Sequence.replicateM can be faster than it is right now. Regards, Daniel D?az. -- E-mail sent by Daniel D?az Casanueva let f x = x in x -------------- next part -------------- An HTML attachment was scrubbed... URL: From briand at aracnet.com Thu Jan 24 16:40:19 2013 From: briand at aracnet.com (briand at aracnet.com) Date: Thu, 24 Jan 2013 07:40:19 -0800 Subject: [Haskell-cafe] hxt pickling question Message-ID: <20130124074019.571e99ce@windy.deldotd.com> Hi, Trying to understand how to write a document using a pickler but I can't make sense of the types. From the example: runX ( xunpickleDocument xpSeason [ withValidate no , withTrace 1 , withRemoveWS yes , withPreserveComment no ] "simple2.xml" >>> processSeason >>> xpickleDocument xpSeason [ withIndent yes ] "new-simple2.xml" ) So all I want to do is pickle a value directly instead of reading the value from a document. I expected to do something like: runX (someHXTPicklingFunction myValue >>> xpickleDocument ...) but I can't seem to figure out what someHXTPicklingFunction should be, it's certainly nothing obvious like pickleDoc, because that generates the wrong value. Seems like I probably have a much more fundamental problem in that I really don't understand how the arrow part of this little example really works, but I was kind of hoping that doing something "simple" like this might shed some light on that. And then was immediately stuck in type hell. Thanks, Brian From hesselink at gmail.com Thu Jan 24 17:05:15 2013 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 24 Jan 2013 17:05:15 +0100 Subject: [Haskell-cafe] hxt pickling question In-Reply-To: <20130124074019.571e99ce@windy.deldotd.com> References: <20130124074019.571e99ce@windy.deldotd.com> Message-ID: There's showPickled [0] and unpickleDoc [1], maybe those help? Erik [0] http://hackage.haskell.org/packages/archive/hxt/latest/doc/html/Text-XML-HXT-Arrow-Pickle-Xml.html#v:showPickled [1] http://hackage.haskell.org/packages/archive/hxt/latest/doc/html/Text-XML-HXT-Arrow-Pickle-Xml.html#v:unpickleDoc On Thu, Jan 24, 2013 at 4:40 PM, wrote: > Hi, > > Trying to understand how to write a document using a pickler but I can't make sense of the types. > > From the example: > > runX ( xunpickleDocument xpSeason > [ withValidate no > , withTrace 1 > , withRemoveWS yes > , withPreserveComment no > ] "simple2.xml" > >>> > processSeason > >>> > xpickleDocument xpSeason > [ withIndent yes > ] "new-simple2.xml" > ) > > So all I want to do is pickle a value directly instead of reading the value from a document. I expected to do something like: > > runX (someHXTPicklingFunction myValue > >>> > xpickleDocument ...) > > > but I can't seem to figure out what someHXTPicklingFunction should be, it's certainly nothing obvious like pickleDoc, because that generates the wrong value. > > Seems like I probably have a much more fundamental problem in that I really don't understand how the arrow part of this little example really works, but I was kind of hoping that doing something "simple" like this might shed some light on that. And then was immediately stuck in type hell. > > > Thanks, > > Brian > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gershomb at gmail.com Thu Jan 24 17:41:09 2013 From: gershomb at gmail.com (Gershom Bazerman) Date: Thu, 24 Jan 2013 11:41:09 -0500 Subject: [Haskell-cafe] Data.Sequence and replicateM In-Reply-To: References: Message-ID: <51016425.6080700@gmail.com> On 1/24/13 9:31 AM, Daniel D?az Casanueva wrote: > > import Control.Monad > import qualified Data.Sequence as Seq > > type Seq = Seq.Seq > > f :: Monad m => Int -> m a -> m (Seq a) > f n = fmap Seq.fromList . replicateM n > > g :: Monad m => Int -> m a -> m (Seq a) > g = Seq.replicateM > > Maybe is just in my test case, where the Int argument is big and the > monadic action short, but it looks to me that Data.Sequence.replicateM > can be faster than it is right now. Are you forcing the full sequence in both cases? In the former case, you'll get all the actions, but have a thunk containing the result of Seq.fromList. In the latter, you're performing the actions as you build the sequence, so the resultant sequence will be fully evaluated. I imagine that this is the reason that the former seems faster to you. --g -------------- next part -------------- An HTML attachment was scrubbed... URL: From dhelta.diaz at gmail.com Thu Jan 24 18:41:17 2013 From: dhelta.diaz at gmail.com (=?UTF-8?Q?Daniel_D=C3=ADaz_Casanueva?=) Date: Thu, 24 Jan 2013 12:41:17 -0500 Subject: [Haskell-cafe] Data.Sequence and replicateM In-Reply-To: <51016425.6080700@gmail.com> References: <51016425.6080700@gmail.com> Message-ID: Good point. However, I forced the result to evaluate using `deepseq` and I still got similar results. On Thu, Jan 24, 2013 at 11:41 AM, Gershom Bazerman wrote: > On 1/24/13 9:31 AM, Daniel D?az Casanueva wrote: > > > import Control.Monad > import qualified Data.Sequence as Seq > > type Seq = Seq.Seq > > f :: Monad m => Int -> m a -> m (Seq a) > f n = fmap Seq.fromList . replicateM n > > g :: Monad m => Int -> m a -> m (Seq a) > g = Seq.replicateM > > Maybe is just in my test case, where the Int argument is big and the > monadic action short, but it looks to me that Data.Sequence.replicateM can > be faster than it is right now. > > > Are you forcing the full sequence in both cases? In the former case, > you'll get all the actions, but have a thunk containing the result of > Seq.fromList. In the latter, you're performing the actions as you build the > sequence, so the resultant sequence will be fully evaluated. > > I imagine that this is the reason that the former seems faster to you. > > --g > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- E-mail sent by Daniel D?az Casanueva let f x = x in x -------------- next part -------------- An HTML attachment was scrubbed... URL: From uribraun at eecs.harvard.edu Thu Jan 24 22:14:53 2013 From: uribraun at eecs.harvard.edu (Uri Braun) Date: Thu, 24 Jan 2013 16:14:53 -0500 Subject: [Haskell-cafe] Manually instantiating Typeable w/DataKinds Message-ID: <006c01cdfa77$da510f10$8ef32d30$@eecs.harvard.edu> I've read the recent posting titled "Non-derivable Typeable" (http://www.mail-archive.com/haskell-cafe at haskell.org/msg103616.html) which explains that Typeable cannot be automatically derived for cases where the kind is constrained. I'm very impressed that a solution is imminent. In the interim, can somebody kindly suggest a workaround? I'm okay with a manual instance, but I'd appreciate some help as to how to write one. I'm looking for a Typeable instance for TaggedVar for the following example below (extracted from my code). Thank you in advance! +Uri {-# LANGUAGE DeriveDataTypeable, DataKinds, KindSignatures #-} module Example where import Data.Typeable data Tag = TagV | TagE | TagA | TagL deriving Typeable newtype TaggedVar (t :: Tag) = TaggedVar Int From briand at aracnet.com Fri Jan 25 05:19:20 2013 From: briand at aracnet.com (briand at aracnet.com) Date: Thu, 24 Jan 2013 20:19:20 -0800 Subject: [Haskell-cafe] hxt pickling question In-Reply-To: References: <20130124074019.571e99ce@windy.deldotd.com> Message-ID: <20130124201920.596cf706@windy.deldotd.com> On Thu, 24 Jan 2013 17:05:15 +0100 Erik Hesselink wrote: > There's showPickled [0] and unpickleDoc [1], maybe those help? > Thank you , they help a lot :-) I was stuck looking in Text.XML.HXT.Arrow.Pickle for the answer and got lost trying to decipher IOStateArrow s a XmlTree and runX. It's odd that there does not seem to be a way to use the example so that a tree can be written directly to a file. xpickleDocument :: PU a -> SysConfigList -> String -> IOStateArrow s a XmlTreeSource store an arbitray value in a persistent XML document Except there doesn't seem to be a way to pass that value into xpickleDocument without reading a document first using xunpickleDocument. Thanks again. Brian > Erik > > [0] http://hackage.haskell.org/packages/archive/hxt/latest/doc/html/Text-XML-HXT-Arrow-Pickle-Xml.html#v:showPickled > [1] http://hackage.haskell.org/packages/archive/hxt/latest/doc/html/Text-XML-HXT-Arrow-Pickle-Xml.html#v:unpickleDoc > > On Thu, Jan 24, 2013 at 4:40 PM, wrote: > > Hi, > > > > Trying to understand how to write a document using a pickler but I can't make sense of the types. > > > > From the example: > > > > runX ( xunpickleDocument xpSeason > > [ withValidate no > > , withTrace 1 > > , withRemoveWS yes > > , withPreserveComment no > > ] "simple2.xml" > > >>> > > processSeason > > >>> > > xpickleDocument xpSeason > > [ withIndent yes > > ] "new-simple2.xml" > > ) > > > > So all I want to do is pickle a value directly instead of reading the value from a document. I expected to do something like: > > > > runX (someHXTPicklingFunction myValue > > >>> > > xpickleDocument ...) > > > > > > but I can't seem to figure out what someHXTPicklingFunction should be, it's certainly nothing obvious like pickleDoc, because that generates the wrong value. > > > > Seems like I probably have a much more fundamental problem in that I really don't understand how the arrow part of this little example really works, but I was kind of hoping that doing something "simple" like this might shed some light on that. And then was immediately stuck in type hell. > > > > > > Thanks, > > > > Brian > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > From s9gf4ult at gmail.com Fri Jan 25 07:19:39 2013 From: s9gf4ult at gmail.com (s9gf4ult at gmail.com) Date: Fri, 25 Jan 2013 12:19:39 +0600 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? Message-ID: <1745863.rgDDbheD5J@localhost> All modern databases has field type NUMERIC(x, y) with arbitrary precision. I need to store financial data with absolute accuracy, and I decided to use Fixed. How can I store Fixed data type as NUMERIC ? I decided to use Snoyman's persistent, bit persistent can not use it from the box and there is a problem with custom field declaration. Here is the instance of PersistField for Fixed I wrote instance (HasResolution a) => PersistField (Fixed a) where toPersistValue a = PersistText $ T.pack $ show a -- fromPersistValue (PersistDouble d) = Right $ fromRational $ toRational d fromPersistValue (PersistText d) = case reads dpt of [(a, "")] -> Right a _ -> Left $ T.pack $ "Could not read value " ++ dpt ++ " as fixed value" where dpt = T.unpack d fromPersistValue a = Left $ T.append "Unexpected data value can not be converted to Fixed: " $ T.pack $ show a sqlType a = SqlOther $ T.pack $ "NUMERIC(" ++ (show l) ++ "," ++ (show p) ++ ")" where p = round $ (log $ fromIntegral $ resolution a) / (log 10) l = p + 15 -- FIXME: this is maybe not very good isNullable _ = False I did not found any proper PersistValue to convert into Fixed from. As well as converting Fixed to PersistValue is just a converting to string. Anyway the saving works properly, but thre reading does not - it just reads Doubles with rounding error. If you uncomment the commented string in instance you will see, that accuracy is not absolute. Here is test project to demonstrate the problem. https://github.com/s9gf4ult/xres If you launch main you will see that precission is not very good because of converting database value to Double and then converting to Fixed. How can i solve this with persistent or what other framework works well with NUMERIC database field type ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Fri Jan 25 07:40:18 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Fri, 25 Jan 2013 08:40:18 +0200 Subject: [Haskell-cafe] Manually instantiating Typeable w/DataKinds In-Reply-To: <006c01cdfa77$da510f10$8ef32d30$@eecs.harvard.edu> References: <006c01cdfa77$da510f10$8ef32d30$@eecs.harvard.edu> Message-ID: <20130125064018.GA15508@sniper> Hi Uri, Here's how it might look. {-# LANGUAGE DeriveDataTypeable, DataKinds, KindSignatures, ScopedTypeVariables #-} module Example where import Data.Typeable import Data.Proxy data Tag = TagV | TagE | TagA | TagL deriving Typeable class TypeableTag (t :: Tag) where tagRep :: Proxy t -> TypeRep instance TypeableTag TagV where tagRep _ = mkTyConApp (mkTyCon3 "mypkg" "Example" "'TagV") [] -- ... same for the other tags newtype TaggedVar (t :: Tag) = TaggedVar Int instance TypeableTag t => Typeable (TaggedVar t) where typeOf _ = mkTyConApp (mkTyCon3 "mkpkg" "Example" "TaggedVar") [tagRep (Proxy :: Proxy t)] Roman * Uri Braun [2013-01-24 16:14:53-0500] > I've read the recent posting titled "Non-derivable Typeable" > (http://www.mail-archive.com/haskell-cafe at haskell.org/msg103616.html) which > explains that Typeable cannot be automatically derived for cases where the > kind is constrained. > > I'm very impressed that a solution is imminent. In the interim, can > somebody kindly suggest a workaround? I'm okay with a manual instance, but > I'd appreciate some help as to how to write one. I'm looking for a Typeable > instance for TaggedVar for the following example below (extracted from my > code). > > Thank you in advance! > > +Uri > > {-# LANGUAGE DeriveDataTypeable, DataKinds, KindSignatures #-} > module Example where > > import Data.Typeable > > data Tag = TagV | TagE | TagA | TagL > deriving Typeable > > newtype TaggedVar (t :: Tag) = TaggedVar Int > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From michael at snoyman.com Fri Jan 25 11:32:43 2013 From: michael at snoyman.com (Michael Snoyman) Date: Fri, 25 Jan 2013 12:32:43 +0200 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: <1745863.rgDDbheD5J@localhost> References: <1745863.rgDDbheD5J@localhost> Message-ID: I can point you to the line of code causing you trouble[1]. The problem is, as you already pointed out, that we don't have a PersistValue constructor that fits this case correctly. I think the right solution is to go ahead and add such a constructor for the next release. I've opened a ticket on Github[2] to track this. By the way, not all databases supported by Persistent have the ability to represent NUMERIC with perfect precision. I'm fairly certain the SQLite will just cast to 8-byte reals, though it's possible that it will keep the data as strings in some circumstances. In the short term, you can probably get this to work today by turning your Fixed values into Integers (by multiplying by some power of 10) to marshaling to the database, and do the reverse when coming from the database. I haven't used this technique myself, but I think it should work. Michael [1] https://github.com/yesodweb/persistent/blob/master/persistent-postgresql/Database/Persist/Postgresql.hs#L271 [2] https://github.com/yesodweb/yesod/issues/493 On Fri, Jan 25, 2013 at 8:19 AM, wrote: > ** > > All modern databases has field type NUMERIC(x, y) with arbitrary precision. > > > > I need to store financial data with absolute accuracy, and I decided to > use Fixed. > > How can I store Fixed data type as NUMERIC ? I decided to use Snoyman's > persistent, bit persistent can not use it from the box and there is a > problem with custom field declaration. > > > > Here is the instance of PersistField for Fixed I wrote > > > > instance (HasResolution a) => PersistField (Fixed a) where > > toPersistValue a = PersistText $ T.pack $ show a > > -- fromPersistValue (PersistDouble d) = Right $ fromRational $ toRational d > > fromPersistValue (PersistText d) = case reads dpt of > > [(a, "")] -> Right a > > _ -> Left $ T.pack $ "Could not read value " ++ dpt ++ " as fixed value" > > where dpt = T.unpack d > > > > fromPersistValue a = Left $ T.append "Unexpected data value can not be > converted to Fixed: " $ T.pack $ show a > > > > sqlType a = SqlOther $ T.pack $ "NUMERIC(" ++ (show l) ++ "," ++ (show p) > ++ ")" > > where > > p = round $ (log $ fromIntegral $ resolution a) / (log 10) > > l = p + 15 -- FIXME: this is maybe not very good > > isNullable _ = False > > > > I did not found any proper PersistValue to convert into Fixed from. As > well as converting Fixed to PersistValue is just a converting to string. > Anyway the saving works properly, but thre reading does not - it just reads > Doubles with rounding error. > > > > If you uncomment the commented string in instance you will see, that > accuracy is not absolute. > > > > Here is test project to demonstrate the problem. > > > > https://github.com/s9gf4ult/xres > > > > If you launch main you will see that precission is not very good because > of converting database value to Double and then converting to Fixed. > > > > How can i solve this with persistent or what other framework works well > with NUMERIC database field type ? > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From horstmey at Mathematik.Uni-Marburg.de Fri Jan 25 13:23:10 2013 From: horstmey at Mathematik.Uni-Marburg.de (Thomas Horstmeyer) Date: Fri, 25 Jan 2013 13:23:10 +0100 Subject: [Haskell-cafe] Data.Sequence and replicateM In-Reply-To: References: Message-ID: <5102792E.40001@mathematik.uni-marburg.de> Hi, isn't the correct type context for f the following? f :: (Functor m, Monad m) => Int -> m a -> m (Seq a) So your f really is a kind of specialization of g. Could the reason for f performing better be list fusion? Anything happening inside Control.Monad.replicateM should be subject to it. Cheers, Thomas Am 24.01.2013 15:31, schrieb Daniel D?az Casanueva: > Hi Cafe, > > I was coding this morning when I suddenly found something that surprised > me. It's been a short time since I am really caring about the > performance of my programs. Before, I was just caring about their > correctness. So I am trying different things and profiling to see > differences. One difference I have found surprising is that the function > f is MUCH faster and less space consuming than the function g: > > import Control.Monad > import qualified Data.Sequence as Seq > > type Seq = Seq.Seq > > f :: Monad m => Int -> m a -> m (Seq a) > f n = fmap Seq.fromList . replicateM n > > g :: Monad m => Int -> m a -> m (Seq a) > g = Seq.replicateM > > Maybe is just in my test case, where the Int argument is big and the > monadic action short, but it looks to me that Data.Sequence.replicateM > can be faster than it is right now. > > Regards, > Daniel D?az. > > -- > E-mail sent by Daniel D?az Casanueva > > let f x = x in x > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ozgurakgun at gmail.com Fri Jan 25 15:15:29 2013 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Fri, 25 Jan 2013 14:15:29 +0000 Subject: [Haskell-cafe] cabal install choosing an older version Message-ID: Hi, I noticed a weird behaviour with cabal-install. When I run `cabal install hspec --dry-run -v` cabal-install correctly picks hspec-1.4.3 (the latest version). However, when I run `cabal install ansi-terminal hspec --dry-run -v`cabal-install tries to install hspec-0.3.0 for no apparent reason. This is with a clean user package db. Following is some info about my system. $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.6.1 $ cabal --version cabal-install version 1.16.0.2 using version 1.16.0.3 of the Cabal library $ ghc-pkg list --user $ cabal install hspec --dry-run -v Reading available packages... Choosing modular solver. Resolving dependencies... In order, the following would be installed: HUnit-1.2.5.1 (new package) ansi-terminal-0.5.5.1 (new package) hspec-expectations-0.3.0.3 (new package) random-1.0.1.1 (new package) QuickCheck-2.5.1.1 (new package) setenv-0.1.0 (new package) silently-1.2.4.1 (new package) transformers-0.3.0.0 (new package) hspec-1.4.3 (new package) $ cabal install ansi-terminal hspec --dry-run -v Reading available packages... Choosing modular solver. Resolving dependencies... In order, the following would be installed: HUnit-1.2.5.1 (new package) ansi-terminal-0.6 (new package) extensible-exceptions-0.1.1.4 (new package) random-1.0.1.1 (new package) QuickCheck-2.5 (new package) hspec-0.3.0 (new package) -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: From dhelta.diaz at gmail.com Fri Jan 25 15:36:30 2013 From: dhelta.diaz at gmail.com (=?UTF-8?Q?Daniel_D=C3=ADaz_Casanueva?=) Date: Fri, 25 Jan 2013 09:36:30 -0500 Subject: [Haskell-cafe] Data.Sequence and replicateM In-Reply-To: <5102792E.40001@mathematik.uni-marburg.de> References: <5102792E.40001@mathematik.uni-marburg.de> Message-ID: Yes, you're right about the type context. I always forget that Functor is not a superclass of Monad. Anyway, the `fmap` can be done only with `Monad` in the context. About the list fusion, I'm compiling with optimizations enabled (-O2), but I do not know how it works with fusions. Is it the optimization omitting the step of creating the list? How can I know it with certainty? On Fri, Jan 25, 2013 at 7:23 AM, Thomas Horstmeyer < horstmey at mathematik.uni-marburg.de> wrote: > Hi, > > isn't the correct type context for f the following? > > f :: (Functor m, Monad m) => Int -> m a -> m (Seq a) > > So your f really is a kind of specialization of g. > > Could the reason for f performing better be list fusion? Anything > happening inside Control.Monad.replicateM should be subject to it. > > Cheers, > Thomas > > > Am 24.01.2013 15:31, schrieb Daniel D?az Casanueva: > >> Hi Cafe, >> >> I was coding this morning when I suddenly found something that surprised >> me. It's been a short time since I am really caring about the >> performance of my programs. Before, I was just caring about their >> correctness. So I am trying different things and profiling to see >> differences. One difference I have found surprising is that the function >> f is MUCH faster and less space consuming than the function g: >> >> import Control.Monad >> import qualified Data.Sequence as Seq >> >> type Seq = Seq.Seq >> >> f :: Monad m => Int -> m a -> m (Seq a) >> f n = fmap Seq.fromList . replicateM n >> >> g :: Monad m => Int -> m a -> m (Seq a) >> g = Seq.replicateM >> >> Maybe is just in my test case, where the Int argument is big and the >> monadic action short, but it looks to me that Data.Sequence.replicateM >> can be faster than it is right now. >> >> Regards, >> Daniel D?az. >> >> -- >> E-mail sent by Daniel D?az Casanueva >> >> let f x = x in x >> >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> >> > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -- E-mail sent by Daniel D?az Casanueva let f x = x in x -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgurakgun at gmail.com Fri Jan 25 15:46:45 2013 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Fri, 25 Jan 2013 14:46:45 +0000 Subject: [Haskell-cafe] cabal install choosing an older version In-Reply-To: References: Message-ID: Aha! I think I know why this happens. The latest versions of ansi-terminal and hspec do not work together. Cabal picks the latest ansi-terminal (0.6) first, then the latest hspec that doesn't conflict with this choice is 0.3.0. I can confirm this by the following: $ cabal install hspec ansi-terminal --dry-run -v Reading available packages... Choosing modular solver. Resolving dependencies... In order, the following would be installed: HUnit-1.2.5.1 (new package) ansi-terminal-0.5.5.1 (new package) hspec-expectations-0.3.0.3 (new package) random-1.0.1.1 (new package) QuickCheck-2.5.1.1 (new package) setenv-0.1.0 (new package) silently-1.2.4.1 (new package) transformers-0.3.0.0 (new package) hspec-1.4.3 (new package) When hspec comes before ansi-terminal, the latest version for hspec is selected and an older version of ansi-terminal is used. Maybe cabal-install should backtrack more and pick a *more optimal *set of latest versions, I don't know. If this is desired, a proximity of the selected versions to the latest available versions might be a good measure. Best, Ozgur -------------- next part -------------- An HTML attachment was scrubbed... URL: From batterseapower at hotmail.com Fri Jan 25 16:58:17 2013 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Fri, 25 Jan 2013 15:58:17 +0000 Subject: [Haskell-cafe] cabal install choosing an older version In-Reply-To: References: Message-ID: On 25 January 2013 14:46, Ozgur Akgun wrote: > The latest versions of ansi-terminal and hspec do not work together. Cabal > picks the latest ansi-terminal (0.6) first, then the latest hspec that > doesn't conflict with this choice is 0.3.0. If this happens because the dependency bounds of ansi-terminal are too tight then please send me a patch. Cheers, Max From amy at nualeargais.ie Fri Jan 25 17:22:45 2013 From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=) Date: Fri, 25 Jan 2013 16:22:45 +0000 (UTC) Subject: [Haskell-cafe] ANN: gray-extended (tools for working with Gray codes) Message-ID: I'm happy to announce a new package called gray-extended http://hackage.haskell.org/package/gray-extended-1.2 https://github.com/mhwombat/gray-extended (github) ABOUT GRAY-EXTENDED: Gray codes satisfy the property that two successive values differ in only one digit. Usually the term \"Gray code\" refers to the Binary Reflected Gray code (BRGC), but non-binary Gray codes have also been discovered. From amy at nualeargais.ie Fri Jan 25 17:26:21 2013 From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=) Date: Fri, 25 Jan 2013 16:26:21 +0000 (UTC) Subject: [Haskell-cafe] ANNOUNCE: creatur (framework for artificial life) Message-ID: I'm happy to announce a new package called Cr?at?r (creatur) http://hackage.haskell.org/package/creatur https://github.com/mhwombat/creatur-examples/raw/master/Tutorial.pdf (tutorial) https://github.com/mhwombat/creatur (github) ABOUT CR?AT?R: Cr?at?r is a software framework for automating experiments with artificial life (ALife) or other evolutionary algorithms (EA). It provides a daemon which ensures that each agent gets its turn to use the CPU. You can use other applications on the computer at the same time without fear of interfering with experiments; they will run normally (although perhaps more slowly). Cr?at?r also provides a library of modules to help you implement your own ALife species. Even if you aren't using the Cr?at?r framework, you may find some of these modules useful. A tutorial on how to use Cr?at?r, including lots of examples, is available at https://github.com/mhwombat/creatur-examples/raw/master/Tutorial.pdf. Cr?at?r (pronounced kray-toor) is an irish word meaning animal, creature, or unfortunate person. From simon at banquise.net Fri Jan 25 17:48:33 2013 From: simon at banquise.net (Simon Marechal) Date: Fri, 25 Jan 2013 17:48:33 +0100 Subject: [Haskell-cafe] ANNOUNCE: hslogstash (library for working with Logstash and related tools) Message-ID: <5102B761.9070501@banquise.net> This is a library for sysadmins and/or tool writers. It provides proper types and correct serialization for Logstash messages, along with small utilities for working with ElasticSearch or Redis (using hedis). This library focus will be on safety (no messages lost). Right now, it can be used to: * send properly formated messages to Logstash * read Logstash messages from Redis or any socket * write Logstash messages to ElasticSearch or any socket This is the work of a sysadmin, thus very likely to be horrible to read. Suggestions are very welcome. From felipe.lessa at gmail.com Fri Jan 25 18:00:02 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Fri, 25 Jan 2013 15:00:02 -0200 Subject: [Haskell-cafe] ANNOUNCE: hslogstash (library for working with Logstash and related tools) In-Reply-To: <5102B761.9070501@banquise.net> References: <5102B761.9070501@banquise.net> Message-ID: For someone as lazy as myself: http://hackage.haskell.org/package/hslogstash https://github.com/bartavelle/hslogstash Cheers, On Fri, Jan 25, 2013 at 2:48 PM, Simon Marechal wrote: > This is a library for sysadmins and/or tool writers. It provides proper > types and correct serialization for Logstash messages, along with small > utilities for working with ElasticSearch or Redis (using hedis). This > library focus will be on safety (no messages lost). > > Right now, it can be used to: > * send properly formated messages to Logstash > * read Logstash messages from Redis or any socket > * write Logstash messages to ElasticSearch or any socket > > This is the work of a sysadmin, thus very likely to be horrible to read. > Suggestions are very welcome. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. From ozgurakgun at gmail.com Fri Jan 25 19:05:24 2013 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Fri, 25 Jan 2013 18:05:24 +0000 Subject: [Haskell-cafe] cabal install choosing an older version In-Reply-To: References: Message-ID: Hi Max, On 25 January 2013 15:58, Max Bolingbroke wrote: > > If this happens because the dependency bounds of ansi-terminal are too > tight then please send me a patch. No, actually it happens because hspec depends on ansi-terminal-0.5.*. I am cc'ing Simon Hengel, the maintainer of hspec so he is aware of this. Best, Ozgur -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.mvd at gmail.com Fri Jan 25 19:37:44 2013 From: petr.mvd at gmail.com (Petr P) Date: Fri, 25 Jan 2013 19:37:44 +0100 Subject: [Haskell-cafe] Data.Sequence and replicateM In-Reply-To: References: <5102792E.40001@mathematik.uni-marburg.de> Message-ID: 2013/1/25 Daniel D?az Casanueva > > Yes, you're right about the type context. I always forget that Functor is > not a superclass of Monad. Anyway, the `fmap` can be done only with `Monad` > in the context. > > Instead of adding `Functor m` constraint you could write just f n = liftM Seq.fromList . replicateM n Best regards, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon at joyful.com Fri Jan 25 20:06:50 2013 From: simon at joyful.com (Simon Michael) Date: Fri, 25 Jan 2013 11:06:50 -0800 Subject: [Haskell-cafe] why no replace function in our regular expression libs ? Message-ID: <1359140810.19051.140661182380321.06096039@webmail.messagingengine.com> People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? #haskell says: iirc its because that's a really mutatey operation in the underlying c libs should be simple enough to write a general purpose wrapper layer that uses captures to create the effect Secondly, as of today what do y'all do when you need that functionality ? -Simon From cgaebel at uwaterloo.ca Fri Jan 25 20:17:46 2013 From: cgaebel at uwaterloo.ca (Clark Gaebel) Date: Fri, 25 Jan 2013 14:17:46 -0500 Subject: [Haskell-cafe] why no replace function in our regular expression libs ? In-Reply-To: <1359140810.19051.140661182380321.06096039@webmail.messagingengine.com> References: <1359140810.19051.140661182380321.06096039@webmail.messagingengine.com> Message-ID: I've needed this recently, too. End result: I wrote an "Attoparsec.Parser Text", and ran the text through that. A regex would have been much nicer... - Clark On Fri, Jan 25, 2013 at 2:06 PM, Simon Michael wrote: > People have put a lot of work into regular expression libraries on > haskell. Yet it seems very few of them provide a replace/substitute > function - just regex-compat and regepr as far as I know. Why is that ? > #haskell says: > > iirc its because that's a really mutatey operation in the > underlying c libs > should be simple enough to write a general purpose wrapper layer > that uses captures to create the effect > > Secondly, as of today what do y'all do when you need that functionality > ? > > -Simon > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From s9gf4ult at gmail.com Fri Jan 25 21:01:59 2013 From: s9gf4ult at gmail.com (s9gf4ult at gmail.com) Date: Sat, 26 Jan 2013 02:01:59 +0600 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: References: <1745863.rgDDbheD5J@localhost> Message-ID: <1624745.uqaQUapyec@localhost> >>turning your Fixed values into Integers Thanks for that idea. -------------- next part -------------- An HTML attachment was scrubbed... URL: From s9gf4ult at gmail.com Fri Jan 25 21:18:02 2013 From: s9gf4ult at gmail.com (s9gf4ult at gmail.com) Date: Sat, 26 Jan 2013 02:18:02 +0600 Subject: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ? Message-ID: <1359174588.hlpHosRzO2@localhost> Hello, haskellers. I am trying to write some generic subtyping issue. Here upcast is always safe operation because of subtype is always behaves like the parrent type. downcast is not the safe becase of not every parrent type value can be converted to children type. Rangeable here is the typeclass of values in some range, so downcasting to Rang1 or Range2 or any other type, having instance for Rangeable can be done by checking if value is in proper range. The same for MultipleTo, downcasting can be done with checking if value is multiple to some value. {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies, FlexibleContexts, UndecidableInstances, OverlappingInstances, IncoherentInstances #-} class SubtypeOf a b | a -> b where upcast :: a -> b downcastSafe :: b -> Maybe a downcast :: b -> a downcast b = case downcastSafe b of Nothing -> error $ "can not downcast the value" Just a -> a class (Ord a) => Rangable t a | t -> a where lowLim :: t -> a highLim :: t -> a class Packable t a | t -> a where pack :: a -> t unpack :: t -> a class MultipleTo t a | t -> a where multiple :: t -> a instance (Num a, Ord a, Rangable range a, Packable range a) => SubtypeOf range a where upcast = unpack downcastSafe b | b >= (lowLim $ pb) && b <= (highLim $ pb) = Just $ pb | otherwise = Nothing where pb = pack b instance (Integral a, Packable range a, MultipleTo range a) => SubtypeOf range a where upcast = unpack downcastSafe b | b `mod` (multiple pb) == 0 = Just pb | otherwise = Nothing where pb = pack b newtype Range1 a = Range1 {unRange1 :: a} deriving Show instance (Num a, Ord a) => Rangable (Range1 a) a where lowLim _ = 0 highLim _ = 10 instance (Num a, Ord a) => Packable (Range1 a) a where pack = Range1 unpack = unRange1 newtype Range2 a = Range2 {unRange2 :: a} deriving Show instance (Num a, Ord a) => Rangable (Range2 a) a where lowLim _ = -10 highLim _ = 200 instance (Num a, Ord a) => Packable (Range2 a) a where pack = Range2 unpack = unRange2 but there is compilation error: Duplicate instance declarations: instance [incoherent] (Num a, Ord a, Rangable range a, Packable range a) => SubtypeOf range a -- Defined at ...:22:10 instance [incoherent] (Integral a, Packable range a, MultipleTo range a) => SubtypeOf range a -- Defined at ...:29:10 Failed, modules loaded: none. If I remove one of instances of SubtypeOf the program is compiling. How to write this instances properly, or to write proper type casting ? Thanks PS. My english is not very good, but I hope this is understandable. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Fri Jan 25 21:24:20 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 25 Jan 2013 15:24:20 -0500 Subject: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ? In-Reply-To: <1359174588.hlpHosRzO2@localhost> References: <1359174588.hlpHosRzO2@localhost> Message-ID: On Fri, Jan 25, 2013 at 3:18 PM, wrote: > Duplicate instance declarations: > > instance [incoherent] (Num a, Ord a, Rangable range a, > > Packable range a) => > > SubtypeOf range a > > -- Defined at ...:22:10 > > instance [incoherent] (Integral a, Packable range a, > > MultipleTo range a) => > > SubtypeOf range a > > -- Defined at ...:29:10 > > This would be correct. Constraints on an instance are applied *after* the instance is selected, so when Haskell is looking for an instance, these two are identical. This has the code smell of trying to use typeclasses for OOP. That won't work. (Yes, really.) -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From s9gf4ult at gmail.com Fri Jan 25 21:39:40 2013 From: s9gf4ult at gmail.com (s9gf4ult at gmail.com) Date: Sat, 26 Jan 2013 02:39:40 +0600 Subject: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ? In-Reply-To: References: <1359174588.hlpHosRzO2@localhost> Message-ID: <3063314.mL3bUc6uXO@localhost> > This has the code smell of trying to use typeclasses for OOP. That won't work. (Yes, really.) I am not trying to use OOP, I am just writing some typecasting at all. > This would be correct. Constraints on an instance are applied *after* the instance is selected, so when Haskell is looking for an instance, these two are identical. I didn't understand why these two instances are identical ? The constraints are different and OverlappingInstances should permit overlapping typeclasses in constraints and select more specific instance clause. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wren at freegeek.org Sat Jan 26 00:23:05 2013 From: wren at freegeek.org (wren ng thornton) Date: Fri, 25 Jan 2013 18:23:05 -0500 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: <20130124074045.63cf39dd@tritium.streitmacht.eu> References: <20130124074045.63cf39dd@tritium.streitmacht.eu> Message-ID: <510313D9.9000902@freegeek.org> On 1/24/13 1:40 AM, Ertugrul S?ylemez wrote: > David Thomas wrote: > >>> We could even set up NotOnHackage: a "package" repository just like >>> Hackage, except the packages are just documentation on why there is >>> no such package. Implementation-wise it's just a wiki; but the idea >>> is about how to organize the wiki. NotOnHackage should be organized >>> and searchable similar to Hackage itself, so that people can look >>> there when nothing looks promising on Hackage. >> >> Couldn't this be actually on hackage, so one search turns up what you >> want? > > Yes. There is no reason to put up a second Hackage for that one. > Without changing anything in the current system, packages can just > update their categories, so that they will be displayed below "Defunct" > or something like that. This is fine, as only the categories of the > latest version are significant. > > If you think this is a good idea, I will start with some of my > packages. =) We've had package deprecation for a while, so the big trick IMO is the documentation. Good descriptions of why the package is defunct and suggestions on how people can do things better. If we're going to do it on Hackage itself, I think the big question is one of style: should the documentation be all in the cabal file (i.e., on the package description page, with no modules in the package); or should we put the documentation into modules? -- Live well, ~wren From davidleothomas at gmail.com Sat Jan 26 00:32:22 2013 From: davidleothomas at gmail.com (David Thomas) Date: Fri, 25 Jan 2013 15:32:22 -0800 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: <510313D9.9000902@freegeek.org> References: <20130124074045.63cf39dd@tritium.streitmacht.eu> <510313D9.9000902@freegeek.org> Message-ID: I think it needs to be both places. I know when I'm searching, I often just go to google with "site:hackage.haskell.org inurl:latest" I would be likely to miss it if it were just in the cabal file (although in the modules it could be as simple as a note saying "this is defunct - view the main page for an explanation of why). Alternatively, if there is much reasoning specific to a particular module it could certainly go there, while the cabal gets the overview... On Fri, Jan 25, 2013 at 3:23 PM, wren ng thornton wrote: > On 1/24/13 1:40 AM, Ertugrul S?ylemez wrote: > >> David Thomas wrote: >> >> We could even set up NotOnHackage: a "package" repository just like >>>> Hackage, except the packages are just documentation on why there is >>>> no such package. Implementation-wise it's just a wiki; but the idea >>>> is about how to organize the wiki. NotOnHackage should be organized >>>> and searchable similar to Hackage itself, so that people can look >>>> there when nothing looks promising on Hackage. >>>> >>> >>> Couldn't this be actually on hackage, so one search turns up what you >>> want? >>> >> >> Yes. There is no reason to put up a second Hackage for that one. >> Without changing anything in the current system, packages can just >> update their categories, so that they will be displayed below "Defunct" >> or something like that. This is fine, as only the categories of the >> latest version are significant. >> >> If you think this is a good idea, I will start with some of my >> packages. =) >> > > We've had package deprecation for a while, so the big trick IMO is the > documentation. Good descriptions of why the package is defunct and > suggestions on how people can do things better. > > If we're going to do it on Hackage itself, I think the big question is one > of style: should the documentation be all in the cabal file (i.e., on the > package description page, with no modules in the package); or should we put > the documentation into modules? > > > -- > Live well, > ~wren > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Sat Jan 26 00:53:40 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Fri, 25 Jan 2013 18:53:40 -0500 Subject: [Haskell-cafe] why no replace function in our regular expression libs ? In-Reply-To: <1359140810.19051.140661182380321.06096039@webmail.messagingengine.com> References: <1359140810.19051.140661182380321.06096039@webmail.messagingengine.com> Message-ID: <51031B04.3050109@vex.net> On 13-01-25 02:06 PM, Simon Michael wrote: > People have put a lot of work into regular expression libraries on > haskell. Yet it seems very few of them provide a replace/substitute > function - just regex-compat and regepr as far as I know. Why is that ? [...] > Secondly, as of today what do y'all do when you need that functionality I can only speak for myself, why I do not miss regex substitution too much. Sometimes, regex substitution is exactly the solution, and I use it. But the whole job is easily done in a shell script, or even in an editor. So I don't use regex substitution in Haskell in this case. Sometimes, the substitution job is: transform this
<code>Monad</code> Tutorial ...
to this Monad Tutorial

Monad Tutorial

... In this job, if a regex solution exists, I don't want to know. I just use HXT or XSLT. Sometimes, regex substitution plus Haskell is exactly the solution. Then I use regex-compat. It works. One solution is enough. I don't need a hundred choices for regex, or a hundred choices for Int. From ok at cs.otago.ac.nz Sat Jan 26 03:01:01 2013 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Sat, 26 Jan 2013 15:01:01 +1300 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: References: <1745863.rgDDbheD5J@localhost> Message-ID: > By the way, not all databases supported by Persistent have the ability to > represent NUMERIC with perfect precision. I'm fairly certain the SQLite > will just cast to 8-byte reals, though it's possible that it will keep the > data as strings in some circumstances. According to the documentation, SQLite stores whatever you give it, paying very little heed to the declared type. If you get SQLite to *compare* two numbers, it will at that point *convert* them to doubles in order to carry out the comparison. This is quite separate from the question of what it can store. From radical at google.com Sat Jan 26 07:00:29 2013 From: radical at google.com (Alvaro Gutierrez) Date: Sat, 26 Jan 2013 01:00:29 -0500 Subject: [Haskell-cafe] ANN: monad-bool 0.1 In-Reply-To: References: <20130124074045.63cf39dd@tritium.streitmacht.eu> <510313D9.9000902@freegeek.org> Message-ID: A brief stylistic note: to me, defunct has a connotation similar to that of deprecated, just stronger; meaning, it implies something closer to "NoLongerOnHackage" rather than wren's more general "NotOnHackage." In this case, the distinction is moot, because the code did happen to exist on Hackage, but I imagine there are cases one might want to warn against without this condition being true. On Fri, Jan 25, 2013 at 6:32 PM, David Thomas wrote: > I think it needs to be both places. I know when I'm searching, I often > just go to google with "site:hackage.haskell.org inurl:latest" I would > be likely to miss it if it were just in the cabal file (although in the > modules it could be as simple as a note saying "this is defunct - view the > main page for an explanation of why). Alternatively, if there is much > reasoning specific to a particular module it could certainly go there, > while the cabal gets the overview... > > > On Fri, Jan 25, 2013 at 3:23 PM, wren ng thornton wrote: > >> On 1/24/13 1:40 AM, Ertugrul S?ylemez wrote: >> >>> David Thomas wrote: >>> >>> We could even set up NotOnHackage: a "package" repository just like >>>>> Hackage, except the packages are just documentation on why there is >>>>> no such package. Implementation-wise it's just a wiki; but the idea >>>>> is about how to organize the wiki. NotOnHackage should be organized >>>>> and searchable similar to Hackage itself, so that people can look >>>>> there when nothing looks promising on Hackage. >>>>> >>>> >>>> Couldn't this be actually on hackage, so one search turns up what you >>>> want? >>>> >>> >>> Yes. There is no reason to put up a second Hackage for that one. >>> Without changing anything in the current system, packages can just >>> update their categories, so that they will be displayed below "Defunct" >>> or something like that. This is fine, as only the categories of the >>> latest version are significant. >>> >>> If you think this is a good idea, I will start with some of my >>> packages. =) >>> >> >> We've had package deprecation for a while, so the big trick IMO is the >> documentation. Good descriptions of why the package is defunct and >> suggestions on how people can do things better. >> >> If we're going to do it on Hackage itself, I think the big question is >> one of style: should the documentation be all in the cabal file (i.e., on >> the package description page, with no modules in the package); or should we >> put the documentation into modules? >> >> >> -- >> Live well, >> ~wren >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From s9gf4ult at gmail.com Sat Jan 26 07:03:42 2013 From: s9gf4ult at gmail.com (s9gf4ult at gmail.com) Date: Sat, 26 Jan 2013 12:03:42 +0600 Subject: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ? In-Reply-To: <1359174588.hlpHosRzO2@localhost> References: <1359174588.hlpHosRzO2@localhost> Message-ID: <1925154.SGYH3JLzHb@localhost> http://ideone.com/v2CrAm I has posted to ideone to show what is wrong. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.solla at gmail.com Sat Jan 26 07:17:57 2013 From: alex.solla at gmail.com (Alexander Solla) Date: Fri, 25 Jan 2013 22:17:57 -0800 Subject: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ? In-Reply-To: <3063314.mL3bUc6uXO@localhost> References: <1359174588.hlpHosRzO2@localhost> <3063314.mL3bUc6uXO@localhost> Message-ID: On Fri, Jan 25, 2013 at 12:39 PM, wrote: > ** > > > This has the code smell of trying to use typeclasses for OOP. That > won't work. (Yes, really.) > > > > I am not trying to use OOP, I am just writing some typecasting at all. > > > > > This would be correct. Constraints on an instance are applied *after* > the instance is selected, so when Haskell is looking for an instance, these > two are identical. > > > > I didn't understand why these two instances are identical ? The > constraints are different and OverlappingInstances should permit > overlapping typeclasses in constraints and select more specific instance > clause. > They are identical because constraints don't "count" for deciding that a type is in a class. For the purposes of deciding if a type is in a class, instance Foo (Bar a) instance Fizz a => Foo (Bar a) instance Fuzz a => Foo (Bar a) are exactly the same, and all three are therefore overlapping instances. None is more specific, because they all refer to the same type -- (Bar a). Also, you can just use Typeable instead of that downcasting stuff. -------------- next part -------------- An HTML attachment was scrubbed... URL: From s9gf4ult at gmail.com Sat Jan 26 07:21:02 2013 From: s9gf4ult at gmail.com (s9gf4ult at gmail.com) Date: Sat, 26 Jan 2013 12:21:02 +0600 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: References: <1745863.rgDDbheD5J@localhost> Message-ID: <6151944.YT1pq8IXuI@localhost> > According to the documentation, SQLite stores whatever you give it, > paying very little heed to the declared type. If you get SQLite to > *compare* two numbers, it will at that point *convert* them to doubles > in order to carry out the comparison. This is quite separate from the > question of what it can store. CREATE TABLE t1(val); sqlite> insert into t1 values ('24.24242424') ...> ; sqlite> insert into t1 values ('24.24242423') ...> ; sqlite> select * from t1 order by val; 24.24242423 24.24242424 sqlite> select * from t1 order by val desc; 24.24242424 24.24242423 sqlite> select sum(val) from t1; 48.48484847 it seems Sqlite can work with arbitrary percission data, very good ! Persistent must have ability to store Fixed. From mle+hs at mega-nerd.com Sat Jan 26 09:24:33 2013 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 26 Jan 2013 19:24:33 +1100 Subject: [Haskell-cafe] Suggestiong for inter-thread communication Message-ID: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Hi all, I am in the process of writing a Haskell program consisting of two threads, one for performing a calculation and one for an Ncurses UI (haskell-ncurses). The calculation thread needs to feed a stream of numbers back to the UI thread (about 1 value per second) and the UI needs to take input from the user and will pass parameter changes to the calculation thread using an IORef and atomicModifyIORef. However, I'm not sure how to hande the UI thread. The UI thread would normally wait for Ncurses input using getEvent, but I need advice on how to the the data from the calculation thread. Any advice or things to try? Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From evohunz at gmail.com Sat Jan 26 10:46:04 2013 From: evohunz at gmail.com (Thiago Negri) Date: Sat, 26 Jan 2013 07:46:04 -0200 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Message-ID: Do you need advice on what? I didn't understand your last phrase. Em 26/01/2013 06:25, "Erik de Castro Lopo" escreveu: > Hi all, > > I am in the process of writing a Haskell program consisting of two > threads, one for performing a calculation and one for an Ncurses UI > (haskell-ncurses). > > The calculation thread needs to feed a stream of numbers back to the > UI thread (about 1 value per second) and the UI needs to take input > from the user and will pass parameter changes to the calculation > thread using an IORef and atomicModifyIORef. > > However, I'm not sure how to hande the UI thread. The UI thread would > normally wait for Ncurses input using getEvent, but I need advice on > how to the the data from the calculation thread. > > Any advice or things to try? > > Cheers, > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Sat Jan 26 10:56:26 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Sat, 26 Jan 2013 10:56:26 +0100 Subject: [Haskell-cafe] ANN: monad-bool 0.1 References: <20130124074045.63cf39dd@tritium.streitmacht.eu> <510313D9.9000902@freegeek.org> Message-ID: <20130126105626.3a78f9bb@tritium.streitmacht.eu> wren ng thornton wrote: > > Yes. There is no reason to put up a second Hackage for that one. > > Without changing anything in the current system, packages can just > > update their categories, so that they will be displayed below > > "Defunct" or something like that. This is fine, as only the > > categories of the latest version are significant. > > > > If you think this is a good idea, I will start with some of my > > packages. =) > > We've had package deprecation for a while, so the big trick IMO is the > documentation. Good descriptions of why the package is defunct and > suggestions on how people can do things better. > > If we're going to do it on Hackage itself, I think the big question is > one of style: should the documentation be all in the cabal file (i.e., > on the package description page, with no modules in the package); or > should we put the documentation into modules? I think the package should be included in full, and the package documentation should clarify why the package shouldn't be used. The idea is that people can still download the code and see how not to do it. It also helps to keep legacy code working, because "bad idea" doesn't necessarily mean, "you could die if you use this". You might go as far as implementing special support for this in the cabal-install tool in the form of a flag like --allow-defunct. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From tab at snarc.org Sat Jan 26 11:08:56 2013 From: tab at snarc.org (Vincent Hanquez) Date: Sat, 26 Jan 2013 11:08:56 +0100 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Message-ID: <20130126100855.GA24156@snarc.org> On Sat, Jan 26, 2013 at 07:46:04AM -0200, Thiago Negri wrote: > Do you need advice on what? I didn't understand your last phrase. IIUC, it has to do which how to interrupt a blocking call to ncurses event handling, from another thread (the calculation thread) to let the UI thread refresh the UI with something to display (the calculation). I've been confronted with the same problem in the past, and i haven't found a satisfactory solution with ncurses. Erik, I think the only way to do that with ncurses, is to wrap the ncurses getevent with a select loop on the terminal fd and an arbitrary fd to be able to "ping" the select loop for arbitrary processing. You can also replace the arbitrary fd with a SIGALARM to yourself which i believe would interrupt select too. I don't think there's any solution that integrate nicely with the haskell way, but i'ld be happy to be wrong on this. In my case, i switched to Vty which solved this problem, by allowing to send arbitrary strongly-typed event to widgets. -- Vincent From mle+hs at mega-nerd.com Sat Jan 26 11:28:34 2013 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 26 Jan 2013 21:28:34 +1100 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Message-ID: <20130126212834.e12246f7e15a965567b1f9c8@mega-nerd.com> Thiago Negri wrote: > Do you need advice on what? I didn't understand your last phrase. Well I have data from two sources, stdin and the calculation thread. If I was doing this in C, I'd probably use a pipe for the calculation data and then do select on the two file descriptors. There is a select package: http://hackage.haskell.org/package/select but I was wondering if there was a more idiomatic Haskell way of dealing with inputs from more than one source. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From es at ertes.de Sat Jan 26 11:46:21 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Sat, 26 Jan 2013 11:46:21 +0100 Subject: [Haskell-cafe] Suggestiong for inter-thread communication References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> <20130126212834.e12246f7e15a965567b1f9c8@mega-nerd.com> Message-ID: <20130126114621.058a01f9@tritium.streitmacht.eu> Erik de Castro Lopo wrote: > > Do you need advice on what? I didn't understand your last phrase. > > Well I have data from two sources, stdin and the calculation > thread. If I was doing this in C, I'd probably use a pipe for the > calculation data and then do select on the two file descriptors. > > There is a select package: > > http://hackage.haskell.org/package/select > > but I was wondering if there was a more idiomatic Haskell way of > dealing with inputs from more than one source. Of course. Threads communicate through MVars, Chans and other abstractions. If you have more complicated scenarios like one thread communicating with multiple other threads in a selective fashion you may also be interested in software transactional memory (STM). If you are using separate threads to perform calculations, you should make sure that you only pass fully evaluated values. In many cases it suffices to evaluate to WHNF, in which case you can simply write: putMVar var $! x This writes the WHNF of 'x' to the MVar 'var'. If the values you pass around are of more complicated data types with non-strict parts (like (Integer, Integer) instead of just Integer), you can also evaluate to NF: import Control.DeepSeq putMVar var $!! x Another option is go without concurrency entirely. Since this is about parallel calculations, I suppose that your computations are actually pure. Let me give you an example: let xs :: [Integer] xs = map (^1000000) [2..1000] mapM_ print xs To parallelize this you can simply use parallel strategies: import Control.Parallel.Strategies let xs :: [Integer] xs = parMap rseq (^1000000) [2..1000] mapM_ print xs This calculates the list values in parallel and is as simple as replacing "map" by "parMap rseq" or "parMap rdeepseq" (if the elements have non-strict parts like (Integer, Integer) instead of just Integer). Remember that for pure values you can always just say, "please evaluate this in parallel". No need at all to mess around with threads. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From petr.mvd at gmail.com Sat Jan 26 11:51:56 2013 From: petr.mvd at gmail.com (Petr P) Date: Sat, 26 Jan 2013 11:51:56 +0100 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Message-ID: Hi Erik, there seem to be several options. Tie simplest one is that you'll call getEvent with some reasonable timeout in a loop and check some communication channel an update from the calculation thread. Probably the correct way how to handle it involves three threads: (1) The computation thread writes its updates to a channel of type Either Event ComputationUpdate using Right. (2) Another thread calls getEvent repeatedly and writes received events to the channel using Left. (3) A consuming thread (the one for Ncurses UI) consumes the channel and reacts both to computation updates and Ncurses events. However, I'm not sure if Ncurses doesn't mind calling getEvent from a different thread than the one that updates UI. For the communication channel, I'd probably use TQueue (or TBQueue, if there is a risk of writing values too fast). Best regards, Petr Pudlak 2013/1/26 Erik de Castro Lopo > Hi all, > > I am in the process of writing a Haskell program consisting of two > threads, one for performing a calculation and one for an Ncurses UI > (haskell-ncurses). > > The calculation thread needs to feed a stream of numbers back to the > UI thread (about 1 value per second) and the UI needs to take input > from the user and will pass parameter changes to the calculation > thread using an IORef and atomicModifyIORef. > > However, I'm not sure how to hande the UI thread. The UI thread would > normally wait for Ncurses input using getEvent, but I need advice on > how to the the data from the calculation thread. > > Any advice or things to try? > > Cheers, > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jims at stuttard.org Sat Jan 26 14:47:25 2013 From: jims at stuttard.org (jims at stuttard.org) Date: Sat, 26 Jan 2013 06:47:25 -0700 Subject: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error Message-ID: <20130126064725.15843zl9s0j3avsd@stuttard.org> ghc doesn't seem to be unifying deriveJSON (String->String) parameter with id :: a -> a. examples/TemplateHaskell.hs:22:14: Couldn't match expected type `Data.Aeson.TH.Options' with actual type `a0 -> a0' In the first argument of `deriveJSON', namely `id' In the expression: deriveJSON id ''Coord ghc --make: /usr/hs/ghc/7.4.1/bin/ghc failure (return code=1) ghc-7.4.1 x86_64 Centos-6 [jim at localhost aeson]$ ghc-pkg list --package-conf=../cabal-dev/packages-7.4.1.conf ../cabal-dev/packages-7.4.1.conf HTTP-4000.2.6 aeson-0.6.1.0 attoparsec-0.10.3.0 attoparsec-conduit-0.5.0.3 base-unicode-symbols-0.2.2.4 blaze-builder-0.3.1.0 blaze-builder-conduit-0.5.0.3 case-insensitive-0.4.0.4 conduit-0.5.6 dlist-0.5 hashable-1.2.0.5 http-types-0.7.3.0.1 lifted-base-0.2.0.2 monad-control-0.3.1.4 nats-0.1 network-2.4.1.0 network-conduit-0.6.2.2 parsec-3.1.3 primitive-0.5.0.1 resourcet-0.4.4 semigroups-0.9 simple-sendfile-0.2.10 transformers-base-0.4.1 unix-compat-0.4.1.0 unordered-containers-0.2.3.0 vault-0.2.0.4 vector-0.10.0.1 void-0.5.11 wai-1.3.0.1 warp-1.3.7.1 From v.dijk.bas at gmail.com Sat Jan 26 15:20:16 2013 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Sat, 26 Jan 2013 15:20:16 +0100 Subject: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error In-Reply-To: <20130126064725.15843zl9s0j3avsd@stuttard.org> References: <20130126064725.15843zl9s0j3avsd@stuttard.org> Message-ID: On 26 January 2013 14:47, wrote: > ghc doesn't seem to be unifying deriveJSON (String->String) > parameter with id :: a -> a. It seems you're using aeson HEAD. Note that the deriveJSON from the released aeson-0.6.1.0 as the type: deriveJSON :: (String -> String) -> Name -> Q [Dec] But in aeson-HEAD it has the following type: deriveJSON :: Options -> Name -> Q [Dec] Cheers, Bas From v.dijk.bas at gmail.com Sat Jan 26 15:34:19 2013 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Sat, 26 Jan 2013 15:34:19 +0100 Subject: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error In-Reply-To: References: <20130126064725.15843zl9s0j3avsd@stuttard.org> Message-ID: On 26 January 2013 15:20, Bas van Dijk wrote: > But in aeson-HEAD it has the following type: > > deriveJSON :: Options -> Name -> Q [Dec] Note that I'm currently working on extending the encoding Options record: * I added a constructorNameModifier :: String -> String which is applied to constructor names and is handy for lower-casing them for example. * I extended the sumEncoding with a ObjectWithSingleField constructor which causes a constructor to be encoded to an object with a single field named after the constructor (modified by the constructorNameModifier) and the value will be the contents of the constructor. * I'm also modifying the GHC Generics code to take the encoding Options into account. This work is happening in my parameterize-generic-encoding-with-options branch: https://github.com/basvandijk/aeson/commits/parameterize-generic-encoding-with-options Bas From jims at stuttard.org Sat Jan 26 16:23:48 2013 From: jims at stuttard.org (jims at stuttard.org) Date: Sat, 26 Jan 2013 08:23:48 -0700 Subject: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error In-Reply-To: References: <20130126064725.15843zl9s0j3avsd@stuttard.org> Message-ID: <20130126082348.16856flqgicdj9qc@stuttard.org> Quoting Bas van Dijk : > On 26 January 2013 14:47, wrote: >> ghc doesn't seem to be unifying deriveJSON (String->String) >> parameter with id :: a -> a. > > It seems you're using aeson HEAD. Note that the deriveJSON from the > released aeson-0.6.1.0 as the type: Thanks for the instant help :) Now I know that versions numbers on github don't necessarily get bumped if there's a breaking change. I got confused when I found the hackage documentation was different . Cheers > deriveJSON :: (String -> String) -> Name -> Q [Dec] > > But in aeson-HEAD it has the following type: > > deriveJSON :: Options -> Name -> Q [Dec] > > Cheers, > > Bas > From jims at stuttard.org Sat Jan 26 16:40:54 2013 From: jims at stuttard.org (jims at stuttard.org) Date: Sat, 26 Jan 2013 08:40:54 -0700 Subject: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error In-Reply-To: References: <20130126064725.15843zl9s0j3avsd@stuttard.org> Message-ID: <20130126084054.12295bcrauf4i1om@stuttard.org> Quoting Bas van Dijk : > On 26 January 2013 15:20, Bas van Dijk wrote: >> But in aeson-HEAD it has the following type: >> >> deriveJSON :: Options -> Name -> Q [Dec] > Note that I'm currently working on extending the encoding Options record: > > * I added a constructorNameModifier :: String -> String which is > applied to constructor names and is handy for lower-casing them for > example. > > * I extended the sumEncoding with a ObjectWithSingleField constructor > which causes a constructor to be encoded to an object with a single > field named after the constructor (modified by the > constructorNameModifier) and the value will be the contents of the > constructor. > > * I'm also modifying the GHC Generics code to take the encoding > Options into account. > > This work is happening in my > parameterize-generic-encoding-with-options branch: Both hackage and your branch build TemplateHaskell.hs ok. I'll try and understand what you've done :) Cheers > https://github.com/basvandijk/aeson/commits/parameterize-generic-encoding-with-options > > Bas > From allbery.b at gmail.com Sat Jan 26 17:10:03 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 26 Jan 2013 11:10:03 -0500 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Message-ID: On Sat, Jan 26, 2013 at 5:51 AM, Petr P wrote: > However, I'm not sure if Ncurses doesn't mind calling getEvent from a > different thread than the one that updates UI. > I don't know if the Haskell bindings change this, but at the C level as long as automatic echo to a window is turned off, it should be safe to do reads from one thread and writes from another. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan at fluffynukeit.com Sat Jan 26 17:33:53 2013 From: dan at fluffynukeit.com (Daniel Austin) Date: Sat, 26 Jan 2013 11:33:53 -0500 Subject: [Haskell-cafe] Writing config files for configurator library Message-ID: Hello Haskellers, What is the typical way to write out configuration files for use by the configurator library? From asking around, seems like the library does not (obviously) support writing out config files to disc from scratch. What I want to do is write out a default config file to disc, or write out the configuration settings that a user selects. I want to avoid having the user edit the config files by hand in a text editor, as well as avoid rolling my own function to write it out if possible. Both of those solutions leave a sour taste in my mouth. Has there been any work toward this end? Thanks much, Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Sat Jan 26 18:16:19 2013 From: michael at snoyman.com (Michael Snoyman) Date: Sat, 26 Jan 2013 19:16:19 +0200 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: <6151944.YT1pq8IXuI@localhost> References: <1745863.rgDDbheD5J@localhost> <6151944.YT1pq8IXuI@localhost> Message-ID: Very nice to see, I'm happy to stand corrected here. We'll definitely get some support for fixed into the next major release. On Saturday, January 26, 2013, wrote: > > According to the documentation, SQLite stores whatever you give it, > > paying very little heed to the declared type. If you get SQLite to > > *compare* two numbers, it will at that point *convert* them to doubles > > in order to carry out the comparison. This is quite separate from the > > question of what it can store. > > CREATE TABLE t1(val); > sqlite> insert into t1 values ('24.24242424') > ...> ; > sqlite> insert into t1 values ('24.24242423') > ...> ; > sqlite> select * from t1 order by val; > 24.24242423 > 24.24242424 > sqlite> select * from t1 order by val desc; > 24.24242424 > 24.24242423 > sqlite> select sum(val) from t1; > 48.48484847 > > it seems Sqlite can work with arbitrary percission data, very good ! > Persistent must have ability to store Fixed. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Sat Jan 26 20:43:24 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Sat, 26 Jan 2013 17:43:24 -0200 Subject: [Haskell-cafe] Use forM_ with Maybe, it's Foldable! Message-ID: Hey, Just wanted to share this little insight I had that I don't think is a common idiom. Often times I need to define: whenJust :: Monad m => Maybe a -> (a -> m b) -> m () whenJust (Just x) f = f x whenJust Nothing _ = return () It always bugged me that you can't find this function anywhere. Actually, you can find it on at least a couple of packages [1], but you can't find it on a standard place. Or can you? A few days ago I decided to hoogle the type of whenJust [2] and what I discovered is that import Data.Foldable (forM_) whenJust = forM_ For example, instead of: mfoo <- doSomething case mfoo of Just foo -> ... Nothing -> return () You may just write: forM_ mfoo $ \foo -> ... There you go. I hope this is useful to someone =). Cheers, [1] http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=whenJust [2] http://www.haskell.org/hoogle/?hoogle=Maybe%20a%20-%3E%20(a%20-%3E%20m%20b)%20-%3E%20m%20() -- Felipe. From evohunz at gmail.com Sat Jan 26 21:34:16 2013 From: evohunz at gmail.com (Thiago Negri) Date: Sat, 26 Jan 2013 18:34:16 -0200 Subject: [Haskell-cafe] SDL and ALUT on Windows: "stdin Bad file descriptor" Message-ID: I'm trying SDL on Windows, and things are getting really weird. I can compile the code (links on the end). When I run it, if I try using `stdin` the program crashes with this message: : hGetLine: invalid argument (Bad file descriptor) Is it something to do with SDL itself? What am I doing wrong? :( Code: http://hpaste.org/81321 Cabal file: http://hpaste.org/81322 Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sat Jan 26 21:52:03 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 26 Jan 2013 15:52:03 -0500 Subject: [Haskell-cafe] SDL and ALUT on Windows: "stdin Bad file descriptor" In-Reply-To: References: Message-ID: On Sat, Jan 26, 2013 at 3:34 PM, Thiago Negri wrote: > I'm trying SDL on Windows, and things are getting really weird. > I can compile the code (links on the end). > When I run it, if I try using `stdin` the program crashes with this > message: > > : hGetLine: invalid argument (Bad file descriptor) > You haven't even touched SDL at that point in that source code. If I had to guess, something (possibly a linker option embedded in the SDL binding) is causing your program to be built as a Windows GUI (as opposed to Windows Console) so it has no stdin. I couldn't tell you much more than that, though; the ways of Windows development are foreign to me. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From sol at typeful.net Sat Jan 26 22:39:06 2013 From: sol at typeful.net (Simon Hengel) Date: Sat, 26 Jan 2013 22:39:06 +0100 Subject: [Haskell-cafe] cabal install choosing an older version In-Reply-To: References: Message-ID: <20130126213906.GA3618@x200> Hi Ozgur, I'm missing some context here, but I'll release an updated version of hspec ASAP ;) Cheers, Simon From petr.mvd at gmail.com Sat Jan 26 23:03:51 2013 From: petr.mvd at gmail.com (Petr P) Date: Sat, 26 Jan 2013 23:03:51 +0100 Subject: [Haskell-cafe] catamorphisms and attribute grammars Message-ID: Dear Haskellers, I read some stuff about attribute grammars recently [1] and how UUAGC [2] can be used for code generation. I felt like this should be possible inside Haskell too so I did some experiments and I realized that indeed catamorphisms can be represented in such a way that they can be combined together and all run in a single pass over a data structure. In fact, they form an applicative functor. [1] http://www.haskell.org/haskellwiki/Attribute_grammar [2] Utrecht University Attribute Grammar Compiler To give an example, let's say we want to compute the average value of a binary tree. If we compute a sum first and then count the elements, the whole tree is retained in memory (and moreover, deforestation won't happen). So it's desirable to compute both values at once during a single pass: -- Count nodes in a tree. count' :: (Num i) => CataBase (BinTree a) i count' = ... -- Sums all nodes in a tree. sum' :: (Num n) => CataBase (BinTree n) n sum' = ... -- Computes the average value of a tree. avg' :: (Fractional b) => CataBase (BinTree b) b avg' = (/) <$> sum' <*> count' Then we can compute the average in a single pass like runHylo avg' treeAnamorphism seed My experiments together with the example are available at https://github .com/ppetr/recursion-attributes I wonder, is there an existing library that expresses this idea? Best regards, Petr Pudlak -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Sun Jan 27 00:09:22 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Sat, 26 Jan 2013 21:09:22 -0200 Subject: [Haskell-cafe] Use forM_ with Maybe, it's Foldable! In-Reply-To: References: Message-ID: Herbert Valerio actually pointed out to me in PVT that funnily enough I've actually *forgotten* and *rediscovered* this idiom! =) http://www.haskell.org/pipermail/libraries/2011-November/017257.html Cheers! On Sat, Jan 26, 2013 at 5:43 PM, Felipe Almeida Lessa wrote: > Hey, > > Just wanted to share this little insight I had that I don't think is a > common idiom. Often times I need to define: > > whenJust :: Monad m => Maybe a -> (a -> m b) -> m () > whenJust (Just x) f = f x > whenJust Nothing _ = return () > > It always bugged me that you can't find this function anywhere. > Actually, you can find it on at least a couple of packages [1], but > you can't find it on a standard place. Or can you? > > A few days ago I decided to hoogle the type of whenJust [2] and what I > discovered is that > > import Data.Foldable (forM_) > whenJust = forM_ > > For example, instead of: > > mfoo <- doSomething > case mfoo of > Just foo -> ... > Nothing -> return () > > You may just write: > > forM_ mfoo $ \foo -> > ... > > There you go. I hope this is useful to someone =). > > Cheers, > > [1] http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=whenJust > [2] http://www.haskell.org/hoogle/?hoogle=Maybe%20a%20-%3E%20(a%20-%3E%20m%20b)%20-%3E%20m%20() > > -- > Felipe. -- Felipe. From hjgtuyl at chello.nl Sun Jan 27 00:17:45 2013 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sun, 27 Jan 2013 00:17:45 +0100 Subject: [Haskell-cafe] SDL and ALUT on Windows: "stdin Bad file descriptor" In-Reply-To: References: Message-ID: On Sat, 26 Jan 2013 21:52:03 +0100, Brandon Allbery wrote: > On Sat, Jan 26, 2013 at 3:34 PM, Thiago Negri wrote: > >> I'm trying SDL on Windows, and things are getting really weird. >> I can compile the code (links on the end). >> When I run it, if I try using `stdin` the program crashes with this >> message: >> >> : hGetLine: invalid argument (Bad file descriptor) >> > > You haven't even touched SDL at that point in that source code. > > If I had to guess, something (possibly a linker option embedded in the > SDL > binding) is causing your program to be built as a Windows GUI (as opposed > to Windows Console) so it has no stdin. I couldn't tell you much more > than > that, though; the ways of Windows development are foreign to me. > You probably used -optl-mwindows in the compile command, to prevent the DOS-shell appearing behind your window. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From roma at ro-che.info Sun Jan 27 01:20:25 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 27 Jan 2013 02:20:25 +0200 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: References: Message-ID: <20130127002025.GA4119@sniper> * Petr P [2013-01-26 23:03:51+0100] > Dear Haskellers, > > I read some stuff about attribute grammars recently [1] and how UUAGC [2] > can be used for code generation. I felt like this should be possible inside > Haskell too so I did some experiments and I realized that indeed > catamorphisms can be represented in such a way that they can be combined > together and all run in a single pass over a data structure. In fact, they > form an applicative functor. > > ... > > My experiments together with the example are available at https://github > .com/ppetr/recursion-attributes Very nice! This can be generalized to arbitrary arrows: {-# LANGUAGE ExistentialQuantification #-} import Prelude hiding (id) import Control.Arrow import Control.Applicative import Control.Category data F from to b c = forall d . F (from b d) (to d c) instance (Arrow from, Arrow to) => Functor (F from to b) where fmap f x = pure f <*> x instance (Arrow from, Arrow to) => Applicative (F from to b) where pure x = F (arr $ const x) id F from1 to1 <*> F from2 to2 = F (from1 &&& from2) (to1 *** to2 >>> arr (uncurry id)) Now your construction is a special case where 'from' is the category of f-algebras and 'to' is the usual (->) category. I wonder what's a categorical interpretation of F itself. Roman From evohunz at gmail.com Sun Jan 27 02:30:31 2013 From: evohunz at gmail.com (Thiago Negri) Date: Sat, 26 Jan 2013 23:30:31 -0200 Subject: [Haskell-cafe] SDL and ALUT on Windows: "stdin Bad file descriptor" In-Reply-To: References: Message-ID: I didn't use `-optl-mwindows`. I guess the dependency on SDL is doing this. Anyway, I was trying to print some debug messages to see what was going wrong. Replaces the debugs message with on-screen messages using `SDL-ttf` package. Thanks, Thiago. 2013/1/26 Henk-Jan van Tuyl > On Sat, 26 Jan 2013 21:52:03 +0100, Brandon Allbery > wrote: > > On Sat, Jan 26, 2013 at 3:34 PM, Thiago Negri wrote: >> >> I'm trying SDL on Windows, and things are getting really weird. >>> I can compile the code (links on the end). >>> When I run it, if I try using `stdin` the program crashes with this >>> message: >>> >>> : hGetLine: invalid argument (Bad file descriptor) >>> >>> >> You haven't even touched SDL at that point in that source code. >> >> If I had to guess, something (possibly a linker option embedded in the SDL >> binding) is causing your program to be built as a Windows GUI (as opposed >> to Windows Console) so it has no stdin. I couldn't tell you much more >> than >> that, though; the ways of Windows development are foreign to me. >> >> > You probably used -optl-mwindows in the compile command, to prevent the > DOS-shell appearing behind your window. > > Regards, > Henk-Jan van Tuyl > > > -- > http://Van.Tuyl.eu/ > http://members.chello.nl/**hjgtuyl/tourdemonad.html > Haskell programming > -- > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnw at fpcomplete.com Sun Jan 27 06:55:53 2013 From: johnw at fpcomplete.com (John Wiegley) Date: Sat, 26 Jan 2013 23:55:53 -0600 Subject: [Haskell-cafe] Use forM_ with Maybe, it's Foldable! In-Reply-To: (Felipe Almeida Lessa's message of "Sat, 26 Jan 2013 17:43:24 -0200") References: Message-ID: >>>>> Felipe Almeida Lessa writes: > A few days ago I decided to hoogle the type of whenJust [2] and what I > discovered is that > import Data.Foldable (forM_) > whenJust = forM_ You can also use "for_", if you want to use Applicative instead of Monad. -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net From alexander.vershilov at gmail.com Sun Jan 27 07:55:17 2013 From: alexander.vershilov at gmail.com (alexander.vershilov at gmail.com) Date: Sun, 27 Jan 2013 10:55:17 +0400 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: <6151944.YT1pq8IXuI@localhost> References: <1745863.rgDDbheD5J@localhost> <6151944.YT1pq8IXuI@localhost> Message-ID: <20130127065517.GA2412@localhost.gtn.ru> Sat, Jan 26, 2013 at 12:21:02PM +0600, s9gf4ult at gmail.com wrote > > According to the documentation, SQLite stores whatever you give it, > > paying very little heed to the declared type. If you get SQLite to > > *compare* two numbers, it will at that point *convert* them to doubles > > in order to carry out the comparison. This is quite separate from the > > question of what it can store. > > CREATE TABLE t1(val); > sqlite> insert into t1 values ('24.24242424') > ...> ; > sqlite> insert into t1 values ('24.24242423') > ...> ; > sqlite> select * from t1 order by val; > 24.24242423 > 24.24242424 > sqlite> select * from t1 order by val desc; > 24.24242424 > 24.24242423 > sqlite> select sum(val) from t1; > 48.48484847 > > it seems Sqlite can work with arbitrary percission data, very good ! > Persistent must have ability to store Fixed. > It's not correct. SQLlite stores any value, but it will use arithmetic operations only with double presicion: sqlite> select val from t1; 1 0.000001 0.00000001 0.0000000001 0.000000000001 0.00000000000001 0.0000000000000001 0.000000000000000001 0.00000000000000000001 0.0000000000000000000001 sqlite> select sum(val) from t1; 1.00000101010101 as you see it has 14 degree. Let's check another well known floating point problem: sqlilte> create table t2 ('val') sqlite> insert into t2 values ('0.7'); sqlite> update t2 set val = 11*val-7; t2 should remain a const sqlite> update t2 set val = 11*val-7; -- 4 times sqlite> select val from t2; 0.699999999989597 sqlite> update t2 set val = 11*val-7; -- 10 times mote sqlite> select val from t2; 0.430171514341321 As you see you have errors. So SQLlite doesn't support arbitrary presision values. As for me Persistent should at least support a Money type and use correct backend-specific type for them, either a native for big integer. -- Best regards Alexander Vershilov -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 490 bytes Desc: Digital signature URL: From chrisyco+haskell-cafe at gmail.com Sun Jan 27 08:20:07 2013 From: chrisyco+haskell-cafe at gmail.com (Chris Wong) Date: Sun, 27 Jan 2013 20:20:07 +1300 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: References: Message-ID: Hi Petr, Congratulations -- you've just implemented a Moore machine! [1] I posted something very much like this just last year [2]. It's a very common pattern in Haskell, forming the basis of coroutines and iteratees and many other things. Edward Kmett includes it in his machines package [3]. His variation, like mine, hides the state inside a closure, removing the need for existentials. pipes 2.0 contains one implemented as a free monad [4]. [1] http://en.wikipedia.org/wiki/Moore_machine [2] http://hackage.haskell.org/packages/archive/machines/0.2.3/doc/html/Data-Machine-Moore.html [3] http://www.haskell.org/pipermail/haskell-cafe/2012-May/101460.html [4] http://hackage.haskell.org/packages/archive/pipes/2.0.0/doc/html/Control-Pipe-Common.html Chris On Sun, Jan 27, 2013 at 11:03 AM, Petr P wrote: > Dear Haskellers, > > I read some stuff about attribute grammars recently [1] and how UUAGC [2] > can be used for code generation. I felt like this should be possible inside > Haskell too so I did some experiments and I realized that indeed > catamorphisms can be represented in such a way that they can be combined > together and all run in a single pass over a data structure. In fact, they > form an applicative functor. > > [1] http://www.haskell.org/haskellwiki/Attribute_grammar > [2] Utrecht University Attribute Grammar Compiler > > To give an example, let's say we want to compute the average value of a > binary tree. If we compute a sum first and then count the elements, the > whole tree is retained in memory (and moreover, deforestation won't happen). > So it's desirable to compute both values at once during a single pass: > > -- Count nodes in a tree. > count' :: (Num i) => CataBase (BinTree a) i > count' = ... > > -- Sums all nodes in a tree. > sum' :: (Num n) => CataBase (BinTree n) n > sum' = ... > > -- Computes the average value of a tree. > avg' :: (Fractional b) => CataBase (BinTree b) b > avg' = (/) <$> sum' <*> count' > > Then we can compute the average in a single pass like > > runHylo avg' treeAnamorphism seed > > My experiments together with the example are available at > https://github.com/ppetr/recursion-attributes > > I wonder, is there an existing library that expresses this idea? > > Best regards, > Petr Pudlak > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From roma at ro-che.info Sun Jan 27 08:49:01 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 27 Jan 2013 09:49:01 +0200 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: References: Message-ID: <20130127074901.GA6290@sniper> Hi Chris, While the two things solve similar problems and have other similarities, they are still quite different. It's hard to call Petr's type a machine ? there's no dynamics in it. It's just a pair of an f-algebra and finalizer. Values of your type return themselves ? it is exactly this recursion that makes them "machines". And the problem solved are different. Catamorphisms are not the same as folds in the sense of Data.Foldable. Folds get elements one at a time, while a catamorphism sees the structure of the tree. For instance, it is possible to write an evaluator for an expression AST using catamorphisms, but not using Moore machines[*], because you won't know what the operations are. [*] without linearizing the tree beforehand Roman * Chris Wong [2013-01-27 20:20:07+1300] > Hi Petr, > > Congratulations -- you've just implemented a Moore machine! [1] > > I posted something very much like this just last year [2]. It's a very > common pattern in Haskell, forming the basis of coroutines and > iteratees and many other things. > > Edward Kmett includes it in his machines package [3]. His variation, > like mine, hides the state inside a closure, removing the need for > existentials. pipes 2.0 contains one implemented as a free monad [4]. > > [1] http://en.wikipedia.org/wiki/Moore_machine > [2] http://hackage.haskell.org/packages/archive/machines/0.2.3/doc/html/Data-Machine-Moore.html > [3] http://www.haskell.org/pipermail/haskell-cafe/2012-May/101460.html > [4] http://hackage.haskell.org/packages/archive/pipes/2.0.0/doc/html/Control-Pipe-Common.html > > Chris > > On Sun, Jan 27, 2013 at 11:03 AM, Petr P wrote: > > Dear Haskellers, > > > > I read some stuff about attribute grammars recently [1] and how UUAGC [2] > > can be used for code generation. I felt like this should be possible inside > > Haskell too so I did some experiments and I realized that indeed > > catamorphisms can be represented in such a way that they can be combined > > together and all run in a single pass over a data structure. In fact, they > > form an applicative functor. > > > > [1] http://www.haskell.org/haskellwiki/Attribute_grammar > > [2] Utrecht University Attribute Grammar Compiler > > > > To give an example, let's say we want to compute the average value of a > > binary tree. If we compute a sum first and then count the elements, the > > whole tree is retained in memory (and moreover, deforestation won't happen). > > So it's desirable to compute both values at once during a single pass: > > > > -- Count nodes in a tree. > > count' :: (Num i) => CataBase (BinTree a) i > > count' = ... > > > > -- Sums all nodes in a tree. > > sum' :: (Num n) => CataBase (BinTree n) n > > sum' = ... > > > > -- Computes the average value of a tree. > > avg' :: (Fractional b) => CataBase (BinTree b) b > > avg' = (/) <$> sum' <*> count' > > > > Then we can compute the average in a single pass like > > > > runHylo avg' treeAnamorphism seed > > > > My experiments together with the example are available at > > https://github.com/ppetr/recursion-attributes > > > > I wonder, is there an existing library that expresses this idea? > > > > Best regards, > > Petr Pudlak > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From petr.mvd at gmail.com Sun Jan 27 09:40:31 2013 From: petr.mvd at gmail.com (Petr P) Date: Sun, 27 Jan 2013 09:40:31 +0100 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: References: Message-ID: Hi Chris, thanks for insightful links. At the first glance, I think the main difference is that machines and iteratees process streams of data, while catamorphisms work on general recursive data structures. (I used "count" + "sum" in the example, which could lead to the impression that it's list oriented.) However, it seems to me that there is some connection between cata/anamorphisms and free (co)monads generated by a functor. I'm just guessing - perhaps using such a monad in a monadic pipe would lead to a similar result? BTW, while it seems that using existentials in by Cata data type is natural, I'd like to know if I could do it without them. If you have any ideas, please let me know. Best regards, Petr PS: Is there actually anything left that ekmett hasn't implemented? 2013/1/27 Chris Wong > Hi Petr, > > Congratulations -- you've just implemented a Moore machine! [1] > > I posted something very much like this just last year [2]. It's a very > common pattern in Haskell, forming the basis of coroutines and > iteratees and many other things. > > Edward Kmett includes it in his machines package [3]. His variation, > like mine, hides the state inside a closure, removing the need for > existentials. pipes 2.0 contains one implemented as a free monad [4]. > > [1] http://en.wikipedia.org/wiki/Moore_machine > [2] > http://hackage.haskell.org/packages/archive/machines/0.2.3/doc/html/Data-Machine-Moore.html > [3] http://www.haskell.org/pipermail/haskell-cafe/2012-May/101460.html > [4] > http://hackage.haskell.org/packages/archive/pipes/2.0.0/doc/html/Control-Pipe-Common.html > > Chris > > On Sun, Jan 27, 2013 at 11:03 AM, Petr P wrote: > > Dear Haskellers, > > > > I read some stuff about attribute grammars recently [1] and how UUAGC [2] > > can be used for code generation. I felt like this should be possible > inside > > Haskell too so I did some experiments and I realized that indeed > > catamorphisms can be represented in such a way that they can be combined > > together and all run in a single pass over a data structure. In fact, > they > > form an applicative functor. > > > > [1] http://www.haskell.org/haskellwiki/Attribute_grammar > > [2] Utrecht University Attribute Grammar Compiler > > > > To give an example, let's say we want to compute the average value of a > > binary tree. If we compute a sum first and then count the elements, the > > whole tree is retained in memory (and moreover, deforestation won't > happen). > > So it's desirable to compute both values at once during a single pass: > > > > -- Count nodes in a tree. > > count' :: (Num i) => CataBase (BinTree a) i > > count' = ... > > > > -- Sums all nodes in a tree. > > sum' :: (Num n) => CataBase (BinTree n) n > > sum' = ... > > > > -- Computes the average value of a tree. > > avg' :: (Fractional b) => CataBase (BinTree b) b > > avg' = (/) <$> sum' <*> count' > > > > Then we can compute the average in a single pass like > > > > runHylo avg' treeAnamorphism seed > > > > My experiments together with the example are available at > > https://github.com/ppetr/recursion-attributes > > > > I wonder, is there an existing library that expresses this idea? > > > > Best regards, > > Petr Pudlak > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.mvd at gmail.com Sun Jan 27 09:58:32 2013 From: petr.mvd at gmail.com (Petr P) Date: Sun, 27 Jan 2013 09:58:32 +0100 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: <20130127002025.GA4119@sniper> References: <20130127002025.GA4119@sniper> Message-ID: Roman, this is interesting. Is this arrow generalization in some library already? And does it have a name? Best regards, Petr Pudlak 2013/1/27 Roman Cheplyaka > * Petr P [2013-01-26 23:03:51+0100] > > Dear Haskellers, > > > > I read some stuff about attribute grammars recently [1] and how UUAGC [2] > > can be used for code generation. I felt like this should be possible > inside > > Haskell too so I did some experiments and I realized that indeed > > catamorphisms can be represented in such a way that they can be combined > > together and all run in a single pass over a data structure. In fact, > they > > form an applicative functor. > > > > ... > > > > My experiments together with the example are available at https://github > > .com/ppetr/recursion-attributes > > Very nice! This can be generalized to arbitrary arrows: > > {-# LANGUAGE ExistentialQuantification #-} > > import Prelude hiding (id) > import Control.Arrow > import Control.Applicative > import Control.Category > > data F from to b c = forall d . F (from b d) (to d c) > > instance (Arrow from, Arrow to) => Functor (F from to b) where > fmap f x = pure f <*> x > > instance (Arrow from, Arrow to) => Applicative (F from to b) where > pure x = F (arr $ const x) id > F from1 to1 <*> F from2 to2 = > F (from1 &&& from2) (to1 *** to2 >>> arr (uncurry id)) > > Now your construction is a special case where 'from' is the category of > f-algebras and 'to' is the usual (->) category. > > I wonder what's a categorical interpretation of F itself. > > Roman > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cobbe at ccs.neu.edu Sun Jan 27 16:07:57 2013 From: cobbe at ccs.neu.edu (Richard Cobbe) Date: Sun, 27 Jan 2013 10:07:57 -0500 Subject: [Haskell-cafe] Where did the Cabal manual go? Message-ID: <20130127150757.GB389@weatherwax.local> I'm not able to access the cabal manual today: links to my local copy and links to the copy at haskell.org result in a 404. I'm running the Haskell Platform, 2012.4.0.0, 64-bit, OS X 10.8.2. On my first attempt this morning, I loaded file:///Library/Haskell/doc/start.html in my browser and clicked on the "Cabal" link. The browser can't find file:///Library/Haskell/doc/ghc-doc/Cabal/index.html, and indeed the directory /Library/Haskell/doc/ghc-doc/Cabal doesn't exist. Ok, I think, so my local copy's gotten corrupted. One "sudo /Library/Haskell/bin/uninstall-hs --remove thru 7.4.2" and reinstall later, I try again; no change. I also can't find any docs by doing find /Library/Haskell -iname \*cabal\* find /Library/Frameworks/GHC.framework -iname \*cabal\* either. I also get a 404 when I click on the "Cabal" link from . I can probably recover a copy from system backups, but what's going on? Richard From michael at snoyman.com Sun Jan 27 16:20:10 2013 From: michael at snoyman.com (Michael Snoyman) Date: Sun, 27 Jan 2013 17:20:10 +0200 Subject: [Haskell-cafe] How to store Fixed data type in the database with persistent ? In-Reply-To: <20130127065517.GA2412@localhost.gtn.ru> References: <1745863.rgDDbheD5J@localhost> <6151944.YT1pq8IXuI@localhost> <20130127065517.GA2412@localhost.gtn.ru> Message-ID: On Jan 27, 2013 8:46 AM, wrote: > > Sat, Jan 26, 2013 at 12:21:02PM +0600, s9gf4ult at gmail.com wrote > > > According to the documentation, SQLite stores whatever you give it, > > > paying very little heed to the declared type. If you get SQLite to > > > *compare* two numbers, it will at that point *convert* them to doubles > > > in order to carry out the comparison. This is quite separate from the > > > question of what it can store. > > > > CREATE TABLE t1(val); > > sqlite> insert into t1 values ('24.24242424') > > ...> ; > > sqlite> insert into t1 values ('24.24242423') > > ...> ; > > sqlite> select * from t1 order by val; > > 24.24242423 > > 24.24242424 > > sqlite> select * from t1 order by val desc; > > 24.24242424 > > 24.24242423 > > sqlite> select sum(val) from t1; > > 48.48484847 > > > > it seems Sqlite can work with arbitrary percission data, very good ! > > Persistent must have ability to store Fixed. > > > > It's not correct. SQLlite stores any value, but it will use arithmetic > operations only with double presicion: > > sqlite> select val from t1; > 1 > 0.000001 > 0.00000001 > 0.0000000001 > 0.000000000001 > 0.00000000000001 > 0.0000000000000001 > 0.000000000000000001 > 0.00000000000000000001 > 0.0000000000000000000001 > > sqlite> select sum(val) from t1; > 1.00000101010101 > > as you see it has 14 degree. > > Let's check another well known floating point problem: > > sqlilte> create table t2 ('val') > sqlite> insert into t2 values ('0.7'); > sqlite> update t2 set val = 11*val-7; > > t2 should remain a const > sqlite> update t2 set val = 11*val-7; -- 4 times > sqlite> select val from t2; > 0.699999999989597 > sqlite> update t2 set val = 11*val-7; -- 10 times mote > sqlite> select val from t2; > 0.430171514341321 > > As you see you have errors. So SQLlite doesn't support arbitrary > presision values. > > As for me Persistent should at least support a Money type and use > correct backend-specific type for them, either a native for big integer. Let me clarify a bit: 1. Persistent will currently allow you to create a `Money` datatype which internally stores as an integer. 2. What Persistent currently lacks is a PersistValue constructor for arbitrary-precision values. As a result, during marshaling, some data will be lost when converting from NUMERIC to Double. 3. The upcoming change we're discussing for Persistent would just be to add such a constructor. We could theoretically provide some extra PersistField instances as well, but that's not really what's being discussed. HTH, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Sun Jan 27 18:47:38 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Sun, 27 Jan 2013 15:47:38 -0200 Subject: [Haskell-cafe] Where did the Cabal manual go? In-Reply-To: <20130127150757.GB389@weatherwax.local> References: <20130127150757.GB389@weatherwax.local> Message-ID: Do you mean the Cabal User Guide? http://www.haskell.org/cabal/users-guide/ On Sun, Jan 27, 2013 at 1:07 PM, Richard Cobbe wrote: > I'm not able to access the cabal manual today: links to my local copy and > links to the copy at haskell.org result in a 404. > > I'm running the Haskell Platform, 2012.4.0.0, 64-bit, OS X 10.8.2. On my > first attempt this morning, I loaded file:///Library/Haskell/doc/start.html > in my browser and clicked on the "Cabal" link. The browser can't find > file:///Library/Haskell/doc/ghc-doc/Cabal/index.html, and indeed the > directory /Library/Haskell/doc/ghc-doc/Cabal doesn't exist. > > Ok, I think, so my local copy's gotten corrupted. One "sudo > /Library/Haskell/bin/uninstall-hs --remove thru 7.4.2" and reinstall later, > I try again; no change. I also can't find any docs by doing > find /Library/Haskell -iname \*cabal\* > find /Library/Frameworks/GHC.framework -iname \*cabal\* > either. > > I also get a 404 when I click on the "Cabal" link from > . > > I can probably recover a copy from system backups, but what's going on? > > Richard > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. From cobbe at ccs.neu.edu Sun Jan 27 19:48:06 2013 From: cobbe at ccs.neu.edu (Richard Cobbe) Date: Sun, 27 Jan 2013 13:48:06 -0500 Subject: [Haskell-cafe] Where did the Cabal manual go? In-Reply-To: References: <20130127150757.GB389@weatherwax.local> Message-ID: <20130127184806.GC389@weatherwax.local> On Sun, Jan 27, 2013 at 03:47:38PM -0200, Felipe Almeida Lessa wrote: > Do you mean the Cabal User Guide? > http://www.haskell.org/cabal/users-guide/ Yes, that's it, and I'm in the process of downloading a copy now (so I can work without a WiFi connection). I'm still curious about why there's a broken link on , and what on earth I did to delete the copy of the user's guide that used to be on my hard drive as part of the Haskell Platform installation (or, worse, what was silently done on my behalf). It's possible I missed a notification that this was happening, but I certainly don't remember seeing anything to that effect. Richard From cobbe at ccs.neu.edu Sun Jan 27 20:09:06 2013 From: cobbe at ccs.neu.edu (Richard Cobbe) Date: Sun, 27 Jan 2013 14:09:06 -0500 Subject: [Haskell-cafe] Where did the Cabal manual go? In-Reply-To: <20130127184806.GC389@weatherwax.local> References: <20130127150757.GB389@weatherwax.local> <20130127184806.GC389@weatherwax.local> Message-ID: <20130127190906.GB325@vimes.home> On Sun, Jan 27, 2013 at 01:48:06PM -0500, Richard Cobbe wrote: > On Sun, Jan 27, 2013 at 03:47:38PM -0200, Felipe Almeida Lessa wrote: > > Do you mean the Cabal User Guide? > > http://www.haskell.org/cabal/users-guide/ > > Yes, that's it, and I'm in the process of downloading a copy now (so I can > work without a WiFi connection). By the way, if the Cabal users guide is no longer to be packaged with the Haskell Platform, can I suggest adding a link to http://www.haskell.org/cabal that would allow folks to download a tgz with the HTML docs, much as is provided for Happy and Alex? As it is, one has to download 4 html files and a css file and hope that's everything. Richard From doaitse at swierstra.net Sun Jan 27 21:12:56 2013 From: doaitse at swierstra.net (Doaitse Swierstra) Date: Sun, 27 Jan 2013 21:12:56 +0100 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: References: Message-ID: <4C1179B8-3267-4C79-ACBF-215E522A35A3@swierstra.net> You have applied the so-called banana-split theorem, as described e.g. in http://www.cs.ox.ac.uk/jeremy.gibbons/publications/acmmpc-calcfp.pdf Indeed you are right in noticing the correspondence between AG's and catamorphims; actually I see AG's as a domain specific language for constructing algebras. Since we believe in embedded domain specific languages we have developed a library for constructing attribute grammars in Haskell, which is described in our ICFP paper: @inproceedings{1596586, Address = {New York, NY, USA}, Author = {Viera, Marcos and Swierstra, S. Doaitse and Swierstra, Wouter}, Booktitle = {ICFP '09: Proceedings of the 14th ACM SIGPLAN international conference on Functional programming}, Date-Added = {2009-10-05 22:06:26 +0200}, Date-Modified = {2009-10-05 22:06:26 +0200}, Doi = {http://doi.acm.org/10.1145/1596550.1596586}, Isbn = {978-1-60558-332-7}, Location = {Edinburgh, Scotland}, Pages = {245--256}, Publisher = {ACM}, Title = {Attribute grammars fly first-class: how to do aspect oriented programming in Haskell}, Year = {2009}} where you will find the problem you are solving done using the library. On March 8 2013 Marcos Viera hopes to defend his Ph.D. thesis at Utrecht University. His thesis contains the progress we have made in this area in recent years. You can find it at the bottom op the page; amongst others you can use the UUAGC nowadays to generate this code form uuagc input. http://www.cs.uu.nl/wiki/bin/view/Center/PhDs Doaitse Swierstra On Jan 26, 2013, at 23:03 , Petr P wrote: > Dear Haskellers, > > I read some stuff about attribute grammars recently [1] and how UUAGC [2] can be used for code generation. I felt like this should be possible inside Haskell too so I did some experiments and I realized that indeed catamorphisms can be represented in such a way that they can be combined together and all run in a single pass over a data structure. In fact, they form an applicative functor. > > [1] http://www.haskell.org/haskellwiki/Attribute_grammar > [2] Utrecht University Attribute Grammar Compiler > > To give an example, let's say we want to compute the average value of a binary tree. If we compute a sum first and then count the elements, the whole tree is retained in memory (and moreover, deforestation won't happen). So it's desirable to compute both values at once during a single pass: > > -- Count nodes in a tree. > count' :: (Num i) => CataBase (BinTree a) i > count' = ... > > -- Sums all nodes in a tree. > sum' :: (Num n) => CataBase (BinTree n) n > sum' = ... > > -- Computes the average value of a tree. > avg' :: (Fractional b) => CataBase (BinTree b) b > avg' = (/) <$> sum' <*> count' > > Then we can compute the average in a single pass like > > runHylo avg' treeAnamorphism seed > > My experiments together with the example are available at https://github.com/ppetr/recursion-attributes > > I wonder, is there an existing library that expresses this idea? > > Best regards, > Petr Pudlak > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Sun Jan 27 21:17:47 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 27 Jan 2013 22:17:47 +0200 Subject: [Haskell-cafe] GHC.Generics and newtypes Message-ID: <20130127201747.GA18547@sniper> Hi, Is it possible to generate different instances for newtypes and datatypes using GHC.Generics? Roman From jpm at cs.uu.nl Sun Jan 27 21:29:52 2013 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Sun, 27 Jan 2013 20:29:52 +0000 Subject: [Haskell-cafe] GHC.Generics and newtypes In-Reply-To: <20130127201747.GA18547@sniper> References: <20130127201747.GA18547@sniper> Message-ID: Hi Roman, Yes, the automatic derivation of Generic instances does not see through newtypes. Cheers, Pedro On Sun, Jan 27, 2013 at 8:17 PM, Roman Cheplyaka wrote: > Hi, > > Is it possible to generate different instances for newtypes and > datatypes using GHC.Generics? > > Roman > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Sun Jan 27 21:34:33 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 27 Jan 2013 22:34:33 +0200 Subject: [Haskell-cafe] GHC.Generics and newtypes In-Reply-To: References: <20130127201747.GA18547@sniper> Message-ID: <20130127203433.GA18746@sniper> Sorry, I wasn't clear. What I want is somehow to find out whether the type under consideration is declared using data or newtype. Is it possible? Roman * Jos? Pedro Magalh?es [2013-01-27 20:29:52+0000] > Hi Roman, > > Yes, the automatic derivation of Generic instances does not see through > newtypes. > > > Cheers, > Pedro > > On Sun, Jan 27, 2013 at 8:17 PM, Roman Cheplyaka wrote: > > > Hi, > > > > Is it possible to generate different instances for newtypes and > > datatypes using GHC.Generics? > > > > Roman > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jpm at cs.uu.nl Sun Jan 27 21:36:54 2013 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Sun, 27 Jan 2013 20:36:54 +0000 Subject: [Haskell-cafe] GHC.Generics and newtypes In-Reply-To: <20130127203433.GA18746@sniper> References: <20130127201747.GA18547@sniper> <20130127203433.GA18746@sniper> Message-ID: Ah, no. But that would be easy to add to the Datatype class, I think. Perhaps open a feature request? Cheers, Pedro On Sun, Jan 27, 2013 at 8:34 PM, Roman Cheplyaka wrote: > Sorry, I wasn't clear. What I want is somehow to find out whether the > type under consideration is declared using data or newtype. > > Is it possible? > > Roman > > * Jos? Pedro Magalh?es [2013-01-27 20:29:52+0000] > > Hi Roman, > > > > Yes, the automatic derivation of Generic instances does not see through > > newtypes. > > > > > > Cheers, > > Pedro > > > > On Sun, Jan 27, 2013 at 8:17 PM, Roman Cheplyaka > wrote: > > > > > Hi, > > > > > > Is it possible to generate different instances for newtypes and > > > datatypes using GHC.Generics? > > > > > > Roman > > > > > > _______________________________________________ > > > Haskell-Cafe mailing list > > > Haskell-Cafe at haskell.org > > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Sun Jan 27 21:39:44 2013 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 27 Jan 2013 22:39:44 +0200 Subject: [Haskell-cafe] GHC.Generics and newtypes In-Reply-To: References: <20130127201747.GA18547@sniper> <20130127203433.GA18746@sniper> Message-ID: <20130127203944.GA18889@sniper> Sure. Should it go to the GHC bug tracker? Roman * Jos? Pedro Magalh?es [2013-01-27 20:36:54+0000] > Ah, no. But that would be easy to add to the Datatype > class, > I think. Perhaps > open a feature request? > > > Cheers, > Pedro > > On Sun, Jan 27, 2013 at 8:34 PM, Roman Cheplyaka wrote: > > > Sorry, I wasn't clear. What I want is somehow to find out whether the > > type under consideration is declared using data or newtype. > > > > Is it possible? > > > > Roman > > > > * Jos? Pedro Magalh?es [2013-01-27 20:29:52+0000] > > > Hi Roman, > > > > > > Yes, the automatic derivation of Generic instances does not see through > > > newtypes. > > > > > > > > > Cheers, > > > Pedro > > > > > > On Sun, Jan 27, 2013 at 8:17 PM, Roman Cheplyaka > > wrote: > > > > > > > Hi, > > > > > > > > Is it possible to generate different instances for newtypes and > > > > datatypes using GHC.Generics? > > > > > > > > Roman > > > > > > > > _______________________________________________ > > > > Haskell-Cafe mailing list > > > > Haskell-Cafe at haskell.org > > > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > From tim at dockerz.net Mon Jan 28 01:23:52 2013 From: tim at dockerz.net (Tim Docker) Date: Mon, 28 Jan 2013 11:23:52 +1100 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> Message-ID: <5105C518.40609@dockerz.net> Hi Eric, In a previous project, I chose vty over ncurses: - you can write your own event loop, and hence handle different event sources. - more liberal license (BSD3 versus GPL) Tim On 26/01/13 19:24, Erik de Castro Lopo wrote: > Hi all, > > I am in the process of writing a Haskell program consisting of two > threads, one for performing a calculation and one for an Ncurses UI > (haskell-ncurses). > > The calculation thread needs to feed a stream of numbers back to the > UI thread (about 1 value per second) and the UI needs to take input > from the user and will pass parameter changes to the calculation > thread using an IORef and atomicModifyIORef. > > However, I'm not sure how to hande the UI thread. The UI thread would > normally wait for Ncurses input using getEvent, but I need advice on > how to the the data from the calculation thread. > > Any advice or things to try? > > Cheers, > Erik From hoerdegen at funktional.info Mon Jan 28 09:55:04 2013 From: hoerdegen at funktional.info (=?ISO-8859-15?Q?Heinrich_H=F6rdegen?=) Date: Mon, 28 Jan 2013 09:55:04 +0100 Subject: [Haskell-cafe] Munich Haskell Meeting Message-ID: <51063CE8.6080907@funktional.info> Dear Haskellers, our monthly get-togethers in Munich this year start on Thursday, 31ts of January at 19h30. Our meeting venue will be Cafe Puck once again. If you want to join, please go to http://www.haskell-munich.de/dates and click the button. Of course, you can also invite all those interested in functional programming. Have a successful week, Heinrich From jeanchristophe.mincke at gmail.com Mon Jan 28 10:23:53 2013 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Mon, 28 Jan 2013 10:23:53 +0100 Subject: [Haskell-cafe] Mac os x (Intel, 10.6.8) problem compiling yesod-core-1.1.7.1 Message-ID: Hello GHC version : 7.4.2 When I do a cabal-dev instal yesod-core, I get the following error: Loading package blaze-builder-conduit-0.5.0.3 ... linking ... done. Loading package hashable-1.2.0.5 ... linking ... ghc: lookupSymbol failed in resolveImports /Users/V3/windev/Haskell/Z/cabal-dev//lib/HShashable-1.2.0.5.o: unknown symbol `_hashable_siphash24_sse2' ghc: unable to load package `hashable-1.2.0.5' Has anyone encountered the same problem? Thank you J-C -------------- next part -------------- An HTML attachment was scrubbed... URL: From emax at chalmers.se Mon Jan 28 12:05:42 2013 From: emax at chalmers.se (Emil Axelsson) Date: Mon, 28 Jan 2013 12:05:42 +0100 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: References: Message-ID: <51065B86.5070400@chalmers.se> Patrick Bahr does something very similar in Modular Tree Automata [1], also noting the relation to attribute grammars. It's implemented in the compdata package [2]. [1] Patrick Bahr, Modular Tree Automata (MPC 2012), http://dx.doi.org/10.1007/978-3-642-31113-0_14 [2] http://hackage.haskell.org/package/compdata / Emil 2013-01-26 23:03, Petr P skrev: > Dear Haskellers, > > I read some stuff about attribute grammars recently [1] and how UUAGC > [2] can be used for code generation. I felt like this should be possible > inside Haskell too so I did some experiments and I realized that indeed > catamorphisms can be represented in such a way that they can be combined > together and all run in a single pass over a data structure. In fact, > they form an applicative functor. > > [1] http://www.haskell.org/haskellwiki/Attribute_grammar > [2] Utrecht University Attribute Grammar Compiler > > To give an example, let's say we want to compute the average value of a > binary tree. If we compute a sum first and then count the elements, the > whole tree is retained in memory (and moreover, deforestation won't > happen). So it's desirable to compute both values at once during a > single pass: > > -- Count nodes in a tree. > count' :: (Num i) => CataBase (BinTree a) i > count' = ... > > -- Sums all nodes in a tree. > sum' :: (Num n) => CataBase (BinTree n) n > sum' = ... > > -- Computes the average value of a tree. > avg' :: (Fractional b) => CataBase (BinTree b) b > avg' = (/) <$> sum' <*> count' > > Then we can compute the average in a single pass like > > runHylo avg' treeAnamorphism seed > > My experiments together with the example are available > at https://github.com/ppetr/recursion-attributes > > I wonder, is there an existing library that expresses this idea? > > Best regards, > Petr Pudlak > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mblazevic at stilo.com Mon Jan 28 17:27:25 2013 From: mblazevic at stilo.com (=?UTF-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Mon, 28 Jan 2013 11:27:25 -0500 Subject: [Haskell-cafe] Suggestiong for inter-thread communication In-Reply-To: <20130126212834.e12246f7e15a965567b1f9c8@mega-nerd.com> References: <20130126192433.faf9711076fb6e98312e4de6@mega-nerd.com> <20130126212834.e12246f7e15a965567b1f9c8@mega-nerd.com> Message-ID: <5106A6ED.5030309@stilo.com> On 13-01-26 05:28 AM, Erik de Castro Lopo wrote: > Thiago Negri wrote: > >> Do you need advice on what? I didn't understand your last phrase. > > Well I have data from two sources, stdin and the calculation > thread. If I was doing this in C, I'd probably use a pipe for the > calculation data and then do select on the two file descriptors. > > There is a select package: > > http://hackage.haskell.org/package/select > > but I was wondering if there was a more idiomatic Haskell way > of dealing with inputs from more than one source. There are list arrows, and also coroutines in many guises including pipes, conduits, and iteratees. These are all co-operative concurrency, however, and I can't tell if your problem requires pre-emptive threads. From johan.tibell at gmail.com Mon Jan 28 18:49:23 2013 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon, 28 Jan 2013 09:49:23 -0800 Subject: [Haskell-cafe] Mac os x (Intel, 10.6.8) problem compiling yesod-core-1.1.7.1 In-Reply-To: References: Message-ID: Adding Bryan, who wrote this code. On Mon, Jan 28, 2013 at 1:23 AM, jean-christophe mincke wrote: > Hello > > GHC version : 7.4.2 > > When I do a cabal-dev instal yesod-core, I get the following error: > > Loading package blaze-builder-conduit-0.5.0.3 ... linking ... done. > Loading package hashable-1.2.0.5 ... linking ... ghc: > lookupSymbol failed in resolveImports > /Users/V3/windev/Haskell/Z/cabal-dev//lib/HShashable-1.2.0.5.o: unknown > symbol `_hashable_siphash24_sse2' > ghc: unable to load package `hashable-1.2.0.5' > > Has anyone encountered the same problem? > > Thank you > > J-C > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From chris at cmears.id.au Tue Jan 29 00:38:55 2013 From: chris at cmears.id.au (Chris Mears) Date: Tue, 29 Jan 2013 10:38:55 +1100 Subject: [Haskell-cafe] Uniplate and rewriting with different types Message-ID: Hi all, I have a question about the Uniplate library, regarding rewriting with transformations that have different types. With the following type, and transformation functions: data Odd = OddOne Even | OddZero Even deriving (Data,Typeable,Show) data Even = EvenOne Odd | EvenZero Odd | Nil deriving (Data,Typeable,Show) t1,t2,t3 :: Even -> Maybe Even t1 (EvenOne (OddOne x)) = Just $ EvenOne (OddZero x) t1 x = Nothing t2 (EvenOne (OddZero x)) = Just $ EvenZero (OddOne x) t2 x = Nothing t3 (EvenZero (OddOne x)) = Just $ EvenZero (OddZero x) t3 x = Nothing it is easy to combine the transformations into a single transformation, because they all have the same type. The result can then be passed to the Uniplate's "rewriteBi" function: allts x = t1 x `mplus` t2 x `mplus` t3 x example = OddOne (EvenOne (OddOne (EvenOne (OddOne Nil)))) go = rewriteBi allts example But if one of the transformations has a different type, you can't do it this way. For instance, redefine t2 to have a different type: t2 :: Odd -> Maybe Odd t2 (OddZero (EvenOne x)) = Just $ OddZero (EvenZero x) t2 x = Nothing and you are stuck because the functions of different types can't be combined into a single transformation. My question is: is there a good way to combine the transformation functions if they have different types? I have come up with a possible solution (see below), but I am not sure that it is the right approach, and it is probably inefficient. Chris Mears {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ScopedTypeVariables #-} import Control.Monad import Control.Monad.State import Data.Generics import Data.Generics.Uniplate.Data data Odd = OddOne Even | OddZero Even deriving (Data,Typeable,Show) data Even = EvenOne Odd | EvenZero Odd | Nil deriving (Data,Typeable,Show) t1 (EvenOne (OddOne x)) = Just $ EvenOne (OddZero x) t1 x = Nothing t2 :: Odd -> Maybe Odd t2 (OddZero (EvenOne x)) = Just $ OddZero (EvenZero x) t2 x = Nothing t3 (EvenZero (OddOne x)) = Just $ EvenZero (OddZero x) t3 x = Nothing -- The transformers are wrapped in an existential type. data WrappedTransformer from = forall to. (Data to, Biplate from to) => WrappedTransformer (to -> Maybe to) -- Apply a single transformation, and return "Just x" if the -- transformation fired (where x is the result of the rewriting), and -- "Nothing" if no transformation fired. rewriteBiCheck :: Biplate from to => (to -> Maybe to) -> from -> Maybe from rewriteBiCheck f e = case runState (rewriteBiM check e) False of (e', True) -> Just e' (_, False) -> Nothing where check x = case f x of Nothing -> return Nothing Just y -> put True >> return (Just y) -- Apply a list of wrapped transformations until no more -- transformations can be applied. rewriteBiList :: forall from. [WrappedTransformer from] -> from -> from rewriteBiList transformers m = go transformers m where go :: [WrappedTransformer from] -> from -> from go [] m = m go ((WrappedTransformer t):ts) m = case rewriteBiCheck t m of Just m' -> go transformers m' Nothing -> go ts m -- Test case. example = OddOne (EvenOne (OddOne (EvenOne (OddOne Nil)))) go = rewriteBiList [ WrappedTransformer t1 , WrappedTransformer t2 , WrappedTransformer t3 ] example From artyom.kazak at gmail.com Tue Jan 29 01:27:41 2013 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Tue, 29 Jan 2013 03:27:41 +0300 Subject: [Haskell-cafe] quotRem and divMod Message-ID: Hi! I?ve always thought that `quotRem` is faster than `quot` + `rem`, since both `quot` and `rem` are just "wrappers" that compute both the quotient and the remainder and then just throw one out. However, today I looked into the implementation of `quotRem` for `Int32` and found out that it?s not true: quotRem x@(I32# x#) y@(I32# y#) | y == 0 = divZeroError | x == minBound && y == (-1) = overflowError | otherwise = (I32# (narrow32Int# (x# `quotInt#` y#)), I32# (narrow32Int# (x# `remInt#` y#))) Why? The `DIV` instruction computes both, doesn?t it? And yet it?s being performed twice here. Couldn?t one of the experts clarify this bit? From hutch-lists at recursive.ca Tue Jan 29 02:43:09 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Mon, 28 Jan 2013 20:43:09 -0500 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache Message-ID: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Hi, I'm relatively new to Haskell, and consider myself to be towards the beginner side of the scale. Nevertheless, I've got this Haskell program I've been working on that's sitting around 11k lines right now. The pattern has been to let it grow to then knock it back by 'refactoring' or whatever you want to call it? doing it right the second time maybe? or the third time. All I want to get across is that though I consider myself a Haskell beginner I've still managed to produce something that is actually quite complex and of reasonable size in about three months. I'm still getting caught by stuff that I should not be caught by. So. Today I thought it was about time to simplify how new 'things' of a certain kind are added to the system. These things are some a cross between an event and an assertion of a fact in a rule based system. There are many different kinds of these things. I already have more than a dozen commonplace ones, and I expect there's a much larger number of more specialized ones that a user will want to add on their own. While they start out quite differently, they end up satisfying a common interface and follow the identical three or four state lifecycle. This sounded like a type class to me, and in fact, easily implemented as such. Now, this is how I got caught: it seems to be impossible to have collections of things with a common type class if they have different types. How is it that I've written that many lines of code in Haskell and I'm just noticing this now? (If I wasn't so annoyed, I'd look for something clever to reflect how loc count obviously doesn't mean much? but clever seems to be beyond me today). Is this true? Are there any GHC extensions that will let me around this? The immediate problem is mapping an input to the system, some json message containing a reference to the 'thing' (like a key of some kind). I have to take that reference and find the thing and operate on it. All operations are easily accommodated by a type class. However, since I can't have a collection with mixed types even if the types satisfy a type class, I can't quite see how to actually store the things so I can find them. So there are a couple of obvious ways to handle this. I could use an ADT and a sum type of all the known kinds of thing, but I already know that this has to be extended and that's going to be problematic with users doing this on their own. And the type signatures look ugly. So I think that's not the best. I could use an ADT that contains functions that correspond to the functions of the type class, and that close over the 'thing' in question. I think this could be made to work, but I'm concerned with walking into more nasty surprises? If anyone is able to make sense of what I wrote and has any suggestions I'd really appreciate hearing them. Thanks, Bob From t at tmh.cc Tue Jan 29 03:17:12 2013 From: t at tmh.cc (Taylor Hedberg) Date: Mon, 28 Jan 2013 21:17:12 -0500 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache In-Reply-To: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> References: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Message-ID: <20130129021712.GC7905@euporie.thebe.ath.cx> If I understand your message well enough, I think you are looking for GHC's `ExistentialQuantification` extension. Building heterogeneous collections is a common example of what existential types are useful for. Take a look at this wiki page [1]; there is an example of how to accomplish this there, along with a handful of other techniques. [1] http://www.haskell.org/haskellwiki/Heterogenous_collections#Existential_types -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: From therealkludgy at gmail.com Tue Jan 29 03:35:13 2013 From: therealkludgy at gmail.com (Darren Grant) Date: Mon, 28 Jan 2013 18:35:13 -0800 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache In-Reply-To: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> References: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Message-ID: On Mon, Jan 28, 2013 at 5:43 PM, Bob Hutchison wrote: > > Now, this is how I got caught: it seems to be impossible to have > collections of things with a common type class if they have different > types. How is it that I've written that many lines of code in Haskell and > I'm just noticing this now? (If I wasn't so annoyed, I'd look for something > clever to reflect how loc count obviously doesn't mean much? but clever > seems to be beyond me today). > > Is this true? Are there any GHC extensions that will let me around this? > I just encountered this recently myself. There is a GADT extension [1][2] that may help. The greater abstraction appears to lie in existential types [3]. That being said, I'm a beginner as well and haven't yet used these extensions. So far I have found that my code is simplified by redefining heterogeneous types in terms of homogeneous functions. If I have a class that implements common methods, I will reorganize lists by common function types rather than by class. Cheers, Darren --- [1] http://www.haskell.org/haskellwiki/GADT [2] http://www.haskell.org/haskellwiki/GADTs_for_dummies [3] http://www.haskell.org/haskellwiki/Existential_type -------------- next part -------------- An HTML attachment was scrubbed... URL: From shachaf at gmail.com Tue Jan 29 07:09:37 2013 From: shachaf at gmail.com (Shachaf Ben-Kiki) Date: Mon, 28 Jan 2013 22:09:37 -0800 Subject: [Haskell-cafe] quotRem and divMod In-Reply-To: References: Message-ID: On Mon, Jan 28, 2013 at 4:27 PM, Artyom Kazak wrote: > Hi! > > I?ve always thought that `quotRem` is faster than `quot` + `rem`, since both > `quot` and `rem` are just "wrappers" that compute both the quotient and the > remainder and then just throw one out. However, today I looked into the > implementation of `quotRem` for `Int32` and found out that it?s not true: > > quotRem x@(I32# x#) y@(I32# y#) > | y == 0 = divZeroError > | x == minBound && y == (-1) = overflowError > | otherwise = (I32# (narrow32Int# (x# `quotInt#` > y#)), > I32# (narrow32Int# (x# `remInt#` > y#))) > > Why? The `DIV` instruction computes both, doesn?t it? And yet it?s being > performed twice here. Couldn?t one of the experts clarify this bit? > That code is from base 4.5. Here's base 4.6: quotRem x@(I32# x#) y@(I32# y#) | y == 0 = divZeroError -- Note [Order of tests] | y == (-1) && x == minBound = (overflowError, 0) | otherwise = case x# `quotRemInt#` y# of (# q, r #) -> (I32# (narrow32Int# q), I32# (narrow32Int# r)) So it looks like it was improved in GHC 7.6. In particular, by this commit: http://www.haskell.org/pipermail/cvs-libraries/2012-February/014880.html Shachaf From caseybasichis at gmail.com Tue Jan 29 08:21:19 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Mon, 28 Jan 2013 23:21:19 -0800 Subject: [Haskell-cafe] Most used functions in hackage Message-ID: Hi, I'm guessing this is a long shot, but Is there any link that counts the use of all functions in all packages in Hackage and lists them by frequency or by other stats? I'm still new to haskell but I've been working my way through tons and tons of tutorials and books. It would be very helpful to target in on the current reality of the most critical functions. Anything like this out there? Thanks, Casey -------------- next part -------------- An HTML attachment was scrubbed... URL: From akamaus at gmail.com Tue Jan 29 08:57:18 2013 From: akamaus at gmail.com (Dmitry Vyal) Date: Tue, 29 Jan 2013 11:57:18 +0400 Subject: [Haskell-cafe] Most used functions in hackage In-Reply-To: References: Message-ID: <510780DE.5060209@gmail.com> On 01/29/2013 11:21 AM, Casey Basichis wrote: > > Is there any link that counts the use of all functions in all packages > in Hackage and lists them by frequency or by other stats? > > I'm still new to haskell but I've been working my way through tons and > tons of tutorials and books. It would be very helpful to target in on > the current reality of the most critical functions. > Hello Casey, You can use Hoogle http://www.haskell.org/hoogle/ to get information about a particular function or to find a function by a part of it's signature. While it's helpful to carefully study some basic modules like Prelude function by function, I don't think it's a good approach in general. I suggest you to look for reviews of popular modules. Personally, I found "24 days of hackage" http://ocharles.org.uk/blog/ to be quite informative. I wouldn't argue it's a best source for a beginner, but at least it gives quite a broad perspective. Best regards, Dmitry From caseybasichis at gmail.com Tue Jan 29 09:23:34 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Tue, 29 Jan 2013 00:23:34 -0800 Subject: [Haskell-cafe] Most used functions in hackage In-Reply-To: <510780DE.5060209@gmail.com> References: <510780DE.5060209@gmail.com> Message-ID: Hi Dmitry, Thanks for the links. I've been through the 24 Days of Hackage, but I think its time to run through them again now that I'm a little more familiar with everything. Why do you think browsing function by function is a bad idea? It seems that knowing exactly what the most used functions are would be an extremely effective way of finding both which parts of the Prelude and Hackage are most broadly useful (instead of browsing them like a phonebook) and also finding support from the community as the most commonly used functions would likely be the easiest to find support for. I guess what I'm looking for doesn't exist, which is what it is. I'm just interested in why it's not an ideal way to take in Haskell, starting with the common and moving to the to rare. Thanks, Casey On Mon, Jan 28, 2013 at 11:57 PM, Dmitry Vyal wrote: > On 01/29/2013 11:21 AM, Casey Basichis wrote: > >> >> Is there any link that counts the use of all functions in all packages in >> Hackage and lists them by frequency or by other stats? >> >> I'm still new to haskell but I've been working my way through tons and >> tons of tutorials and books. It would be very helpful to target in on the >> current reality of the most critical functions. >> >> Hello Casey, > > You can use Hoogle http://www.haskell.org/hoogle/ to get information > about a particular function or to find a function by a part of it's > signature. > > While it's helpful to carefully study some basic modules like Prelude > function by function, I don't think it's a good approach in general. I > suggest you to look for reviews of popular modules. Personally, I found "24 > days of hackage" http://ocharles.org.uk/blog/ to be quite informative. I > wouldn't argue it's a best source for a beginner, but at least it gives > quite a broad perspective. > > Best regards, > Dmitry > > -- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis at gmail.com 310.387.7540 -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiish at gmail.com Tue Jan 29 10:25:49 2013 From: efiish at gmail.com (Junior White) Date: Tue, 29 Jan 2013 17:25:49 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different Message-ID: Hi Cafe, I have two programs for the same problem "Eight queens problem", the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. My two grograms only has little difference, but the performance, this is my solution: -- solution 1------------------------------------------------------------ queens1 :: Int -> [[Int]] queens1 n = map reverse $ queens' n where queens' 0 = [[]] queens' k = [q:qs | q <- [1..n], qs <- queens' (k-1), isSafe q qs] isSafe try qs = not (try `elem` qs || sameDiag try qs) sameDiag try qs = any (?(colDist, q) -> abs (try - q) == colDist) $ zip [1..] qs -- solution 2-------------------------------------------------------------- queens2 :: Int -> [[Int]] queens2 n = map reverse $ queens' n where queens' 0 = [[]] queens' k = [q:qs | qs <- queens' (k-1), q <- [1..n], isSafe q qs] isSafe try qs = not (try `elem` qs || sameDiag try qs) sameDiag try qs = any (?(colDist,q) -> abs (try - q) == colDist) $ zip [1..] qs the performance difference is: (set :set +s in ghci) *Main> length (queens1 8) 92 (287.85 secs, 66177031160 bytes) *Main> length (queens2 8) 92 (0.07 secs, 17047968 bytes) *Main> The only different in the two program is in the first is "q <- [1..n], qs <- queens' (k-1)," and the second is "qs <- queens' (k-1), q <- [1..n]". Does sequence in list comprehansion matter? And why? -------------- next part -------------- An HTML attachment was scrubbed... URL: From artyom.kazak at gmail.com Tue Jan 29 10:31:02 2013 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Tue, 29 Jan 2013 12:31:02 +0300 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: Junior White ?????(?) ? ????? ?????? Tue, 29 Jan 2013 12:25:49 +0300: > The only different in the two program is in the first is "q <- [1..n], qs > <- queens' (k-1)," and the second is "qs <- queens' (k-1), q <- [1..n]". In the first case `queens' (k-1)` is being recomputed for every q (that is, n times). Of course it would matter :) From efiish at gmail.com Tue Jan 29 10:40:08 2013 From: efiish at gmail.com (Junior White) Date: Tue, 29 Jan 2013 17:40:08 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: Hi Artyom, Thanks! But I don't understand why in the first case "queens' (k-1)" is being recomputed n times? On Tue, Jan 29, 2013 at 5:31 PM, Artyom Kazak wrote: > Junior White ?????(?) ? ????? ?????? Tue, 29 Jan 2013 > 12:25:49 +0300: > > > The only different in the two program is in the first is "q <- [1..n], qs >> <- queens' (k-1)," and the second is "qs <- queens' (k-1), q <- [1..n]". >> > > In the first case `queens' (k-1)` is being recomputed for every q (that > is, n times). Of course it would matter :) > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From artyom.kazak at gmail.com Tue Jan 29 10:48:31 2013 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Tue, 29 Jan 2013 12:48:31 +0300 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: Junior White ?????(?) ? ????? ?????? Tue, 29 Jan 2013 12:40:08 +0300: > Hi Artyom, > Thanks! But I don't understand why in the first case "queens' (k-1)" > is > being recomputed n times? Because your list comprehension is just a syntactic sugar for concatMap (\q -> concatMap (\qs -> if isSafe q qs then [q:qs] else []) (queens' (k-1))) [1..n] Here `queens' (k-1)` does not depend on `qs`, and therefore it *could* be floated out of the lambda: let queens = queens' (k-1) in concatMap (\q -> concatMap (\qs -> if isSafe q qs then [q:qs] else []) queens) [1..n] But it is an unsafe optimisation. Suppose that the `queens` list is very big. If we apply this optimisation, it will be retained in memory during the whole evaluation, which may be not desirable. That?s why GHC leaves this to you. From efiish at gmail.com Tue Jan 29 10:54:28 2013 From: efiish at gmail.com (Junior White) Date: Tue, 29 Jan 2013 17:54:28 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: Thanks again! I understand now. I'll be careful when the next time I use list comprehension. On Tue, Jan 29, 2013 at 5:48 PM, Artyom Kazak wrote: > Junior White ?????(?) ? ????? ?????? Tue, 29 Jan 2013 > 12:40:08 +0300: > > Hi Artyom, >> Thanks! But I don't understand why in the first case "queens' (k-1)" is >> being recomputed n times? >> > > Because your list comprehension is just a syntactic sugar for > > concatMap (\q -> > concatMap (\qs -> if isSafe q qs then [q:qs] else []) > (queens' (k-1))) > [1..n] > > Here `queens' (k-1)` does not depend on `qs`, and therefore it *could* be > floated out of the lambda: > > let queens = queens' (k-1) > in > concatMap (\q -> > concatMap (\qs -> if isSafe q qs then [q:qs] else []) > queens) > [1..n] > > But it is an unsafe optimisation. Suppose that the `queens` list is very > big. If we apply this optimisation, it will be retained in memory during > the whole evaluation, which may be not desirable. That's why GHC leaves > this to you. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiish at gmail.com Tue Jan 29 10:59:31 2013 From: efiish at gmail.com (Junior White) Date: Tue, 29 Jan 2013 17:59:31 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: So this is a problem in lazy evaluation language, it will not appear in python or erlang, am i right? On Tue, Jan 29, 2013 at 5:54 PM, Junior White wrote: > Thanks again! I understand now. I'll be careful when the next time I use > list comprehension. > > > On Tue, Jan 29, 2013 at 5:48 PM, Artyom Kazak wrote: > >> Junior White ?????(?) ? ????? ?????? Tue, 29 Jan 2013 >> 12:40:08 +0300: >> >> Hi Artyom, >>> Thanks! But I don't understand why in the first case "queens' (k-1)" >>> is >>> being recomputed n times? >>> >> >> Because your list comprehension is just a syntactic sugar for >> >> concatMap (\q -> >> concatMap (\qs -> if isSafe q qs then [q:qs] else []) >> (queens' (k-1))) >> [1..n] >> >> Here `queens' (k-1)` does not depend on `qs`, and therefore it *could* be >> floated out of the lambda: >> >> let queens = queens' (k-1) >> in >> concatMap (\q -> >> concatMap (\qs -> if isSafe q qs then [q:qs] else []) >> queens) >> [1..n] >> >> But it is an unsafe optimisation. Suppose that the `queens` list is very >> big. If we apply this optimisation, it will be retained in memory during >> the whole evaluation, which may be not desirable. That's why GHC leaves >> this to you. >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hjgtuyl at chello.nl Tue Jan 29 11:17:49 2013 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Tue, 29 Jan 2013 11:17:49 +0100 Subject: [Haskell-cafe] Most used functions in hackage In-Reply-To: References: <510780DE.5060209@gmail.com> Message-ID: On Tue, 29 Jan 2013 09:23:34 +0100, Casey Basichis wrote: > I guess what I'm looking for doesn't exist, which is what it is. I'm > just > interested in why it's not an ideal way to take in Haskell, starting with > the common and moving to the to rare. > It is worth while to study the Prelude functions: A Tour of the Haskell Prelude http://undergraduate.csse.uwa.edu.au/units/CITS1211/Documentation/tourofprelude.html and: A tour of the Haskell Monad functions http://members.chello.nl/hjgtuyl/tourdemonad.html Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From artyom.kazak at gmail.com Tue Jan 29 11:33:58 2013 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Tue, 29 Jan 2013 13:33:58 +0300 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: Junior White ?????(?) ? ????? ?????? Tue, 29 Jan 2013 12:59:31 +0300: > So this is a problem in lazy evaluation language, it will not appear in > python or erlang, am i right? Not quite. Compilers of imperative languages don?t perform CSE (common subexpression elimination) either; `queens' (k-1)` could have some side effects, after all, and performing a side effect only once instead of n times is a definite bug. From daniel.is.fischer at googlemail.com Tue Jan 29 12:39:37 2013 From: daniel.is.fischer at googlemail.com (Daniel Fischer) Date: Tue, 29 Jan 2013 12:39:37 +0100 Subject: [Haskell-cafe] quotRem and divMod In-Reply-To: References: Message-ID: <2168415.Q9FYo6iBum@linux-v7dw.site> On Tuesday 29 January 2013, 03:27:41, Artyom Kazak wrote: > Hi! > > I?ve always thought that `quotRem` is faster than `quot` + `rem`, since > both `quot` and `rem` are just "wrappers" that compute both the quotient > and the remainder and then just throw one out. However, today I looked > into the implementation of `quotRem` for `Int32` and found out that it?s > not true: > > quotRem x@(I32# x#) y@(I32# y#) > > | y == 0 = divZeroError > | x == minBound && y == (-1) = overflowError > | otherwise = (I32# (narrow32Int# (x# `quotInt#` > > y#)), > I32# (narrow32Int# (x# `remInt#` > y#))) > > Why? The `DIV` instruction computes both, doesn?t it? And yet it?s being > performed twice here. Couldn?t one of the experts clarify this bit? It's not necessarily performed twice. func a b = case a `quotRem` b of (q, r) -> q+r produces idivq 8(%rbp) movq %rax,%rbx movq $GHC.Int.I32#_con_info,-8(%r12) movslq %edx,%rax movslq %ebx,%rbx addq %rax,%rbx as the relevant part of the assembly, with only one idivq instruction. I don't know whether you can rely on the code generator emitting only one division instruction in all cases, but in simple cases, it does (on x86_64, at least). Cheers, Daniel From artyom.kazak at gmail.com Tue Jan 29 13:26:02 2013 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Tue, 29 Jan 2013 15:26:02 +0300 Subject: [Haskell-cafe] quotRem and divMod In-Reply-To: References: Message-ID: Shachaf Ben-Kiki ?????(?) ? ????? ?????? Tue, 29 Jan 2013 09:09:37 +0300: > That code is from base 4.5. Here's base 4.6: > > quotRem x@(I32# x#) y@(I32# y#) > | y == 0 = divZeroError > -- Note [Order of tests] > | y == (-1) && x == minBound = (overflowError, 0) > | otherwise = case x# `quotRemInt#` y# of > (# q, r #) -> > (I32# (narrow32Int# q), > I32# (narrow32Int# r)) > > So it looks like it was improved in GHC 7.6. In particular, by this > commit: > http://www.haskell.org/pipermail/cvs-libraries/2012-February/014880.html > > Shacha Well, I?m glad to know that it has been fixed in the newer GHC (I?m still on 7.4). Thanks! From ross at soi.city.ac.uk Tue Jan 29 16:23:43 2013 From: ross at soi.city.ac.uk (Ross Paterson) Date: Tue, 29 Jan 2013 15:23:43 +0000 Subject: [Haskell-cafe] catamorphisms and attribute grammars In-Reply-To: <20130127002025.GA4119@sniper> References: <20130127002025.GA4119@sniper> Message-ID: <20130129152343.GA26479@soi.city.ac.uk> On Sun, Jan 27, 2013 at 12:20:25AM +0000, Roman Cheplyaka wrote: > Very nice! This can be generalized to arbitrary arrows: > > {-# LANGUAGE ExistentialQuantification #-} > > import Prelude hiding (id) > import Control.Arrow > import Control.Applicative > import Control.Category > > data F from to b c = forall d . F (from b d) (to d c) > > instance (Arrow from, Arrow to) => Functor (F from to b) where > fmap f x = pure f <*> x > > instance (Arrow from, Arrow to) => Applicative (F from to b) where > pure x = F (arr $ const x) id > F from1 to1 <*> F from2 to2 = > F (from1 &&& from2) (to1 *** to2 >>> arr (uncurry id)) You only require that from b is Applicative, so that in turn can be generalized: data F g to c = forall d . F (g d) (to d c) instance (Applicative g, Arrow to) => Functor (F g to) where fmap f x = pure f <*> x instance (Applicative g, Arrow to) => Applicative (F g to) where pure x = F (pure x) id F from1 to1 <*> F from2 to2 = F ((,) <$> from1 <*> from2) (to1 *** to2 >>> arr (uncurry id)) > I wonder what's a categorical interpretation of F itself. It's a variety of left Kan extension (cf section 5 of "Constructing Applicative Functors" at MPC'2012). From qdunkan at gmail.com Tue Jan 29 21:11:31 2013 From: qdunkan at gmail.com (Evan Laforge) Date: Tue, 29 Jan 2013 12:11:31 -0800 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache In-Reply-To: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> References: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Message-ID: > Today I thought it was about time to simplify how new 'things' of a certain kind are added to the system. These things are some a cross between an event and an assertion of a fact in a rule based system. There are many different kinds of these things. I already have more than a dozen commonplace ones, and I expect there's a much larger number of more specialized ones that a user will want to add on their own. While they start out quite differently, they end up satisfying a common interface and follow the identical three or four state lifecycle. This sounded like a type class to me, and in fact, easily implemented as such. I hardly ever use typeclasses, I've never used existential types or GADTs, and it's worked fine for me for many years. Maybe just a difference in programming style, or the sorts of things I write, but implies at least that you can get very far not using any of that stuff. If each of your things have the same 3 or 4 states, can you make a state into a value, and compose them? E.g. 'thing1 = state1 <> state2 <> thing1state where thing1state = ...' and state1 and state2 are defined in a library. If you have lots of different ways to take A to B and want to let the caller configure it, then just pass an A->B function. If you want to configure an unpredictable subset of things, then maybe make a default record and pass 'default { aToB = customVersion }'. If each function depends on a configuration environment that you want to inherit from callers, then maybe put that record into a Reader. In my case, the main design decision winds up being the balance of data (i.e. records with values or functions) and code (i.e. functions that do parts of what you want and can be composed together in various ways). Code is extensible and flexible but can't be manipulated, data is inflexible (in that you have to hardcode some kind of "schema"), but that means you can write functions to transform it. From ndmitchell at gmail.com Tue Jan 29 22:00:13 2013 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue, 29 Jan 2013 21:00:13 +0000 Subject: [Haskell-cafe] Uniplate and rewriting with different types In-Reply-To: References: Message-ID: Hi Chris, > With the following type, and transformation functions: > > data Odd = OddOne Even | OddZero Even deriving (Data,Typeable,Show) > data Even = EvenOne Odd | EvenZero Odd | Nil deriving (Data,Typeable,Show) > > t1,t2,t3 :: Even -> Maybe Even > But if one of the transformations has a different type, you can't do > it this way. For instance, redefine t2 to have a different type: > > t2 :: Odd -> Maybe Odd > t2 (OddZero (EvenOne x)) = Just $ OddZero (EvenZero x) > t2 x = Nothing > > and you are stuck because the functions of different types can't be > combined into a single transformation. > > My question is: is there a good way to combine the transformation > functions if they have different types? Currently, no. Although there is something definitely related, with transformBis: http://hackage.haskell.org/packages/archive/uniplate/1.6.10/doc/html/Data-Generics-Uniplate-Data.html#v:transformBis That takes a list of transformation functions of different types and acts as though you did transform on each one in turn. You could certainly imagine adding rewriteBis in the same style, and with your version you almost have. The transformBis function is particularly efficient because it "knows" which traversals or parts of traversals can be fused without changing the semantics. rewriteBis could certainly do the same trick. If you provided a patch for rewriteBis I'd certainly apply it! Thanks, Neil From ganesh at earth.li Tue Jan 29 23:15:19 2013 From: ganesh at earth.li (Ganesh Sittampalam) Date: Tue, 29 Jan 2013 22:15:19 +0000 Subject: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package Message-ID: <510849F7.7020107@earth.li> Hi, tl;dr: I'm planning on removing the String instances from the HTTP package. This is likely to break code. Obviously it will involve a major version bump. The basic reason is that this instance is rather broken in itself. A String ought to represent Unicode data, but the HTTP wire format is bytes, and HTTP makes no attempt to handle encoding. This was discussed on the libraries@ list a while back, but I'm happy to discuss further if there's a general feeling that this is a bad thing to do: http://www.haskell.org/pipermail/libraries/2012-September/018426.html I will probably upload the new version in a week or two. Cheers, Ganesh From johan.tibell at gmail.com Tue Jan 29 23:46:17 2013 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue, 29 Jan 2013 14:46:17 -0800 Subject: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package In-Reply-To: <510849F7.7020107@earth.li> References: <510849F7.7020107@earth.li> Message-ID: On Tue, Jan 29, 2013 at 2:15 PM, Ganesh Sittampalam wrote: > tl;dr: I'm planning on removing the String instances from the HTTP > package. This is likely to break code. Obviously it will involve a major > version bump. > > The basic reason is that this instance is rather broken in itself. A > String ought to represent Unicode data, but the HTTP wire format is > bytes, and HTTP makes no attempt to handle encoding. > > This was discussed on the libraries@ list a while back, but I'm happy to > discuss further if there's a general feeling that this is a bad thing to do: > > http://www.haskell.org/pipermail/libraries/2012-September/018426.html > > I will probably upload the new version in a week or two. I think it's the right thing to do. Providing a little upgrade guide should help things to go smoother. From evohunz at gmail.com Tue Jan 29 23:59:14 2013 From: evohunz at gmail.com (Thiago Negri) Date: Tue, 29 Jan 2013 20:59:14 -0200 Subject: [Haskell-cafe] Handling exceptions or gracefully releasing resources Message-ID: `Control.Exception.bracket` is a nice function to acquire and release a resource in a small context. But, how should I handle resources that are hold for a long time? Should I put `Control.Exception.finally` on every single line of my finalizers? What exceptions may occur on an IO operation? Every IO function has the risk of throwing an exception? Thanks, Thiago. -------------- next part -------------- An HTML attachment was scrubbed... URL: From johan.tibell at gmail.com Wed Jan 30 00:26:57 2013 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue, 29 Jan 2013 15:26:57 -0800 Subject: [Haskell-cafe] Handling exceptions or gracefully releasing resources In-Reply-To: References: Message-ID: Hi, The pattern is essentially the same as in imperative languages; every allocation should involve a finally clause that deallocates the resource. On Tue, Jan 29, 2013 at 2:59 PM, Thiago Negri wrote: > Should I put `Control.Exception.finally` on every single line of my > finalizers? I'm not sure what you're asking here. If your finally clause tries to call close, you don't have to catch exceptions raise by close (what would you do with them anyway). From ok at cs.otago.ac.nz Wed Jan 30 01:20:10 2013 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed, 30 Jan 2013 13:20:10 +1300 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: On 29/01/2013, at 10:59 PM, Junior White wrote: > So this is a problem in lazy evaluation language, it will not appear in python or erlang, am i right? Wrong. Let's take Erlang: [f(X, Y) || X <- g(), Y <- h()] Does the order of the generators matter here? You _bet_ it does. First off, in all of these languages, it affects the order of the results. Let's take a toy case: g() -> [1,2]. h() -> [a,b]. % constants f(X, Y) -> {X,Y}. % a pair [f(X, Y) || X <- g(), Y <- h()] yields [{1,a},{1,b},{2,a},{2,b}] [f(X, Y) || Y <- h(), X <- g()] yields [{1,a},{2,a},{1,b},{2,b}] Now let's change it by giving g/0 and h/0 (benign) side effects. g() -> io:write('g called'), io:nl(), [1,2]. h() -> io:write('h called'), io:nl(), [a,b]. Generating X before Y yields 'g called' 'h called' 'h called' [{1,a},{1,b},{2,a},{2,b}] Generating Y before X yields 'h called' 'g called' 'g called' [{1,a},{2,a},{1,b},{2,b}] If a function call may yield side effects, then the compiler must not re-order or coalesce calls to that function. This applies to both Erlang and Python (and to SETL, which had set and tuple comprehensions before Erlang, Python, or Haskell were conceived). From wren at freegeek.org Wed Jan 30 06:56:10 2013 From: wren at freegeek.org (wren ng thornton) Date: Wed, 30 Jan 2013 00:56:10 -0500 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: <5108B5FA.9030703@freegeek.org> On 1/29/13 4:25 AM, Junior White wrote: > Hi Cafe, > I have two programs for the same problem "Eight queens problem", > the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. > My two grograms only has little difference, but the performance, this is > my solution: The difference is what's called "dynamic programming" (an utterly non-intuitive an un-insightful name). When we have the program: [ f x xs | xs <- g, x <- h ] we're saying, first get me a partial solution (xs), and then try every possible way of extending that to a larger solution (x). It should be obvious from this description that the computation of each partial solution xs will be shared among all candidates x, but that the computation of x will not be shared between each xs. On the other hand, when we have the program: [ f x xs | x <- h, xs <- g ] we're saying, first get me all ways to start a solution (x), and then try to solve the rest of the problem (xs). It should be obvious from this description that the computation of each x will be shared, but the computation of each xs will not. Imperatively, this is exactly the same distinction as between the following programs: for xs in g: for x in h: yield f(x,xs) for x in h: for xs in g: yield f(x,xs) This difference in sharing can, as you've seen, cause huge differences in runtime. Usually it's the difference between a polytime algorithm and some exptime algorithm. To see why, just think about the call graph. It may be more helpful here to think about something like Fibbonaci numbers. In the memoizing version, you're storing the work from solving smaller problems and sharing that among the different ways of extending the solution; whereas in the naive version, you're recomputing the same thing over and over. The call graph for the former is a DAG (or more generally, a packed forest) whereas the call graph for the latter is the tree you get by unfurling all the shared structure in the DAG. This distinction has nothing whatsoever to do with Haskell, and has everything to do with Intro Algorithms. Loop ordering matters in every language with loops, from Haskell to C to Python to Prolog. -- Live well, ~wren From ganesh at earth.li Wed Jan 30 08:00:37 2013 From: ganesh at earth.li (Ganesh Sittampalam) Date: Wed, 30 Jan 2013 07:00:37 +0000 Subject: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package In-Reply-To: References: <510849F7.7020107@earth.li> Message-ID: <5108C515.9060402@earth.li> On 29/01/2013 22:46, Johan Tibell wrote: > On Tue, Jan 29, 2013 at 2:15 PM, Ganesh Sittampalam wrote: >> tl;dr: I'm planning on removing the String instances from the HTTP >> package. This is likely to break code. Obviously it will involve a major >> version bump. > > I think it's the right thing to do. Providing a little upgrade guide > should help things to go smoother. One obvious cheap-and-dirty migration is via a newtype wrapper for String that embeds the old broken behaviour (char8 encoding). Perhaps the package should provide that? (with appropriate warnings etc) Ganesh From alfredo.dinapoli at gmail.com Wed Jan 30 09:01:34 2013 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Wed, 30 Jan 2013 08:01:34 +0000 Subject: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package In-Reply-To: <5108C515.9060402@earth.li> References: <510849F7.7020107@earth.li> <5108C515.9060402@earth.li> Message-ID: Maybe (just my 2 cents!) since you are going to broke the API anyway, go for it and seize the occasion to really clean up :) Obviously I'm saying this from a non-http-user point of view, maybe if I had some code in production affected by this, my suggestion would have been different :P Regards, A. On 30 January 2013 07:00, Ganesh Sittampalam wrote: > On 29/01/2013 22:46, Johan Tibell wrote: > > On Tue, Jan 29, 2013 at 2:15 PM, Ganesh Sittampalam > wrote: > >> tl;dr: I'm planning on removing the String instances from the HTTP > >> package. This is likely to break code. Obviously it will involve a major > >> version bump. > > > > I think it's the right thing to do. Providing a little upgrade guide > > should help things to go smoother. > > One obvious cheap-and-dirty migration is via a newtype wrapper for > String that embeds the old broken behaviour (char8 encoding). Perhaps > the package should provide that? (with appropriate warnings etc) > > Ganesh > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Wed Jan 30 09:12:14 2013 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Wed, 30 Jan 2013 21:12:14 +1300 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: <5108B5FA.9030703@freegeek.org> References: <5108B5FA.9030703@freegeek.org> Message-ID: <00248cd3a668ecc447353c370254e0ae.squirrel@chasm.otago.ac.nz> > The difference is what's called "dynamic programming" (an utterly > non-intuitive and un-insightful name). It was meant to be. The name was chosen to be truthful while not revealing too much to a US Secretary of Defense of whom Bellman wrote: "His face would suffuse, he would turn red, and he would get violent if people used the term, research, in his presence. You can imagine how he felt, then, about the term, mathematical." (http://en.wikipedia.org/wiki/Dynamic_programming) Every time I try to imagine this guy having Haskell explained to him my brain refuses to co-operate. The word "programming" here is used in the same sense as in "linear programming" and "quadratic programming", that is, "optimisation". "Dynamic" does hint at the multistage decision process idea involved. From tim at dockerz.net Wed Jan 30 10:23:33 2013 From: tim at dockerz.net (Tim Docker) Date: Wed, 30 Jan 2013 20:23:33 +1100 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache In-Reply-To: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> References: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Message-ID: On 29/01/2013, at 12:43 PM, Bob Hutchison wrote: > > The immediate problem is mapping an input to the system, some json message containing a reference to the 'thing' (like a key of some kind). I have to take that reference and find the thing and operate on it. All operations are easily accommodated by a type class. However, since I can't have a collection with mixed types even if the types satisfy a type class, I can't quite see how to actually store the things so I can find them. > > So there are a couple of obvious ways to handle this. > > I could use an ADT and a sum type of all the known kinds of thing, but I already know that this has to be extended and that's going to be problematic with users doing this on their own. And the type signatures look ugly. So I think that's not the best. > > I could use an ADT that contains functions that correspond to the functions of the type class, and that close over the 'thing' in question. I think this could be made to work, but I'm concerned with walking into more nasty surprises? > My advice is to go for the latter option. I'm not sure what nasty surprises you are expecting, but this "record of functions" approach is the one that I normally take when I am building a system that needs new types added without requiring global changes. I know that existentials and GADTs are possible solutions, but I've not needed the extra complexity here. Cheers, Tim From doaitse at swierstra.net Wed Jan 30 10:51:41 2013 From: doaitse at swierstra.net (Doaitse Swierstra) Date: Wed, 30 Jan 2013 10:51:41 +0100 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: Message-ID: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> From the conclusion that both programs compute the same result it can be concluded that the fact that you have made use of a list comprehension has forced you to make a choice which should not matter, i.e. the order in which to place the generators. This should be apparent from your code. My approach is such a situation is to "define your own generator" (assuming here that isSafe needs both its parameters): pl `x` ql = [ (p,q) | p <-pl, q <- ql] queens3 n = map reverse $ queens' n where queens' 0 = [[]] queens' k = [q:qs | (qs, q) <- queens' (k-1) `x` [1..n], isSafe q qs] isSafe try qs = not (try `elem` qs || sameDiag try qs) sameDiag try qs = any (\(colDist,q) -> abs (try - q) == colDist) $ zip [1..] qs Of course you can make more refined versions of `x`, which perform all kinds of fair enumeration, but that is not the main point here. It is the fact that the parameters to `x` are only evaluated once which matters here. Doaitse On Jan 29, 2013, at 10:25 , Junior White wrote: > Hi Cafe, > I have two programs for the same problem "Eight queens problem", > the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. > My two grograms only has little difference, but the performance, this is my solution: > > -- solution 1------------------------------------------------------------ > queens1 :: Int -> [[Int]] > queens1 n = map reverse $ queens' n > where queens' 0 = [[]] > queens' k = [q:qs | q <- [1..n], qs <- queens' (k-1), isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > sameDiag try qs = any (?(colDist, q) -> abs (try - q) == colDist) $ zip [1..] qs > > -- solution 2-------------------------------------------------------------- > queens2 :: Int -> [[Int]] > queens2 n = map reverse $ queens' n > where queens' 0 = [[]] > queens' k = [q:qs | qs <- queens' (k-1), q <- [1..n], isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > sameDiag try qs = any (?(colDist,q) -> abs (try - q) == colDist) $ zip [1..] qs > > the performance difference is: (set :set +s in ghci) > *Main> length (queens1 8) > 92 > (287.85 secs, 66177031160 bytes) > *Main> length (queens2 8) > 92 > (0.07 secs, 17047968 bytes) > *Main> > > The only different in the two program is in the first is "q <- [1..n], qs <- queens' (k-1)," and the second is "qs <- queens' (k-1), q <- [1..n]". > > Does sequence in list comprehansion matter? And why? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From arkeet at gmail.com Wed Jan 30 12:54:11 2013 From: arkeet at gmail.com (Adrian Keet) Date: Wed, 30 Jan 2013 03:54:11 -0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> References: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> Message-ID: <510909E3.10003@gmail.com> The whole point here is to evaluate both lists inside the list comprehension only once. There is a very simple way to accomplish this: [q:qs | let qss = queens' (k-1), q <- [1..n], qs <- qss] Here, queens' (k-1) is only evaluated once, and is shared for all q. (Note: If queens' (k-1) is polymorphic (which it is) and you use -XNoMonomorphismRestriction, then you better add a type annotation to qss to ensure sharing.) Adrian On 2013/01/30 1:51, Doaitse Swierstra wrote: > From the conclusion that both programs compute the same result it can > be concluded that the fact that you have made use of a list > comprehension has forced you to make a choice which should not > matter, i.e. the order in which to place the generators. This should > be apparent from your code. > > My approach is such a situation is to "define your own generator" > (assuming here that isSafe needs both its parameters): > > pl `x` ql = [ (p,q) | p <-pl, q <- ql] > > queens3 n = map reverse $ queens' n > where queens' 0 = [[]] > queens' k = [q:qs | (qs, q) <- queens' (k-1) `x` > [1..n], isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > sameDiag try qs = any (\(colDist,q) -> abs (try - q) == > colDist) $ zip [1..] qs > > Of course you can make more refined versions of `x`, which perform all > kinds of fair enumeration, but that is not the main point here. It is > the fact that the parameters to `x` are only evaluated once which > matters here. > > Doaitse > > On Jan 29, 2013, at 10:25 , Junior White > wrote: > >> Hi Cafe, >> I have two programs for the same problem "Eight queens problem", >> the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. >> My two grograms only has little difference, but the performance, >> this is my solution: >> >> -- solution 1------------------------------------------------------------ >> queens1 :: Int -> [[Int]] >> queens1 n = map reverse $ queens' n >> where queens' 0 = [[]] >> queens' k = [q:qs | q <- [1..n], qs <- queens' (k-1), >> isSafe q qs] >> isSafe try qs = not (try `elem` qs || sameDiag try qs) >> sameDiag try qs = any (?(colDist, q) -> abs (try - q) == >> colDist) $ zip [1..] qs >> >> -- solution >> 2-------------------------------------------------------------- >> queens2 :: Int -> [[Int]] >> queens2 n = map reverse $ queens' n >> where queens' 0 = [[]] >> queens' k = [q:qs | qs <- queens' (k-1), q <- [1..n], >> isSafe q qs] >> isSafe try qs = not (try `elem` qs || sameDiag try qs) >> sameDiag try qs = any (?(colDist,q) -> abs (try - q) == >> colDist) $ zip [1..] qs >> >> the performance difference is: (set :set +s in ghci) >> *Main> length (queens1 8) >> 92 >> (287.85 secs, 66177031160 bytes) >> *Main> length (queens2 8) >> 92 >> (0.07 secs, 17047968 bytes) >> *Main> >> >> The only different in the two program is in the first is "q <- >> [1..n], qs <- queens' (k-1)," and the second is "qs <- queens' (k-1), >> q <- [1..n]". >> >> Does sequence in list comprehansion matter? And why? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiish at gmail.com Wed Jan 30 13:02:15 2013 From: efiish at gmail.com (Junior White) Date: Wed, 30 Jan 2013 20:02:15 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> References: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> Message-ID: On Wed, Jan 30, 2013 at 5:51 PM, Doaitse Swierstra wrote: > From the conclusion that both programs compute the same result it can be > concluded that the fact that you have made use of a list comprehension has > forced you to make a choice which should not matter, i.e. the order in > which to place the generators. This should be apparent from your code. > > My approach is such a situation is to "define your own generator" > (assuming here that isSafe needs both its parameters): > > pl `x` ql = [ (p,q) | p <-pl, q <- ql] > > queens3 n = map reverse $ queens' n > where queens' 0 = [[]] > > queens' k = [q:qs | (qs, q) <- queens' (k-1) `x` [1..n], > isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > > sameDiag try qs = any (\(colDist,q) -> abs (try - q) == colDist) > $ zip [1..] qs > > Of course you can make more refined versions of `x`, which perform all > kinds of fair enumeration, but that is not the main point here. It is the > fact that the parameters to `x` are only evaluated once which matters here. > Thanks for your reply! I must learn more to fully understand what's going on inside the list comprehension. But when I frist learn Haskell, it says sequence doesn't matter, but now it is a big matter, can compiler do some thing for us? I think this behavior is not friendly to newbies like me, I will take a very long time to work through it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiish at gmail.com Wed Jan 30 13:05:44 2013 From: efiish at gmail.com (Junior White) Date: Wed, 30 Jan 2013 20:05:44 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: <510909E3.10003@gmail.com> References: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> <510909E3.10003@gmail.com> Message-ID: Thinks! I think compiler should do this for us, isn't it? On Wed, Jan 30, 2013 at 7:54 PM, Adrian Keet wrote: > The whole point here is to evaluate both lists inside the list > comprehension only once. There is a very simple way to accomplish this: > > [q:qs | let qss = queens' (k-1), q <- [1..n], qs <- qss] > > Here, queens' (k-1) is only evaluated once, and is shared for all q. > > (Note: If queens' (k-1) is polymorphic (which it is) and you use > -XNoMonomorphismRestriction, then you better add a type annotation to qss > to ensure sharing.) > > Adrian > > > On 2013/01/30 1:51, Doaitse Swierstra wrote: > > From the conclusion that both programs compute the same result it can be > concluded that the fact that you have made use of a list comprehension has > forced you to make a choice which should not matter, i.e. the order in > which to place the generators. This should be apparent from your code. > > My approach is such a situation is to "define your own generator" > (assuming here that isSafe needs both its parameters): > > pl `x` ql = [ (p,q) | p <-pl, q <- ql] > > queens3 n = map reverse $ queens' n > where queens' 0 = [[]] > > queens' k = [q:qs | (qs, q) <- queens' (k-1) `x` [1..n], > isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > > sameDiag try qs = any (\(colDist,q) -> abs (try - q) == colDist) > $ zip [1..] qs > > Of course you can make more refined versions of `x`, which perform all > kinds of fair enumeration, but that is not the main point here. It is the > fact that the parameters to `x` are only evaluated once which matters here. > > Doaitse > > On Jan 29, 2013, at 10:25 , Junior White wrote: > > Hi Cafe, > I have two programs for the same problem "Eight queens problem", > the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. > My two grograms only has little difference, but the performance, this > is my solution: > > -- solution 1------------------------------------------------------------ > queens1 :: Int -> [[Int]] > > queens1 n = map reverse $ queens' n > > where queens' 0 = [[]] > > queens' k = [q:qs | q <- [1..n], qs <- queens' (k-1), > isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > > sameDiag try qs = any (?(colDist, q) -> abs (try - q) == > colDist) $ zip [1..] qs > > -- solution > 2-------------------------------------------------------------- > queens2 :: Int -> [[Int]] > > queens2 n = map reverse $ queens' n > > where queens' 0 = [[]] > > queens' k = [q:qs | qs <- queens' (k-1), q <- [1..n], > isSafe q qs] > isSafe try qs = not (try `elem` qs || sameDiag try qs) > > sameDiag try qs = any (?(colDist,q) -> abs (try - q) == colDist) > $ zip [1..] qs > > the performance difference is: (set :set +s in ghci) > *Main> length (queens1 8) > 92 > (287.85 secs, 66177031160 bytes) > *Main> length (queens2 8) > 92 > (0.07 secs, 17047968 bytes) > *Main> > > The only different in the two program is in the first is "q <- [1..n], > qs <- queens' (k-1)," and the second is "qs <- queens' (k-1), q <- [1..n]". > > Does sequence in list comprehansion matter? And why? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > _______________________________________________ > Haskell-Cafe mailing listHaskell-Cafe at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jan.stolarek at p.lodz.pl Wed Jan 30 13:21:18 2013 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Wed, 30 Jan 2013 13:21:18 +0100 Subject: [Haskell-cafe] Monadic parser vs. combinator parser Message-ID: <201301301321.18592.jan.stolarek@p.lodz.pl> I will be writing a parser in Haskell and I wonder how to approach the problem. My first thought was to use monadic parser, e.g. like the one described by Hutton and Meijer in "Monadic Parsing in Haskell" functional pearl. But then I stumbled upon this: https://github.com/alephnullplex/cradle/tree/master/code/src/Lbach/Parser Monadic parser seems extremely verbose and not very straightforward compared to this one. I started to wonder whether I should use monadic parser for the sake of it being monadic or should I just go with the combinator approach? Any thoughts will be appreciated before I shoot myself in the foot :) Janek From es at ertes.de Wed Jan 30 13:38:47 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Wed, 30 Jan 2013 13:38:47 +0100 Subject: [Haskell-cafe] Monadic parser vs. combinator parser References: <201301301321.18592.jan.stolarek@p.lodz.pl> Message-ID: <20130130133847.0420ab87@tritium.streitmacht.eu> Jan Stolarek wrote: > I will be writing a parser in Haskell and I wonder how to approach the > problem. My first thought was to use monadic parser, e.g. like the one > described by Hutton and Meijer in "Monadic Parsing in Haskell" > functional pearl. But then I stumbled upon this: > > https://github.com/alephnullplex/cradle/tree/master/code/src/Lbach/Parser > > Monadic parser seems extremely verbose and not very straightforward > compared to this one. I started to wonder whether I should use monadic > parser for the sake of it being monadic or should I just go with the > combinator approach? Any thoughts will be appreciated before I shoot > myself in the foot :) A monadic parser /is/ a combinator parser. The code you linked just doesn't go as far as wrapping it up with a newtype and providing a monad instance. Monadic parsers aren't verbose, because there is the applicative style. Let's rewrite this noisy example (assuming automatic backtracking): inParens c = do char '(' x <- c char ')' return x All monads are also applicative functors, which means that you can use applicative style to write this one more nicely: inParens c = char '(' *> c <* char ')' If your parser is also an IsString you could even write: inParens c = "(" *> c <* ")" If that's not nice and concise I don't know what is. =) Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From felipe.lessa at gmail.com Wed Jan 30 13:47:34 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Wed, 30 Jan 2013 10:47:34 -0200 Subject: [Haskell-cafe] Handling exceptions or gracefully releasing resources In-Reply-To: References: Message-ID: Everything that Johan Tibell said + you may be interested in the resourcet package [1] (which is used by conduit to handle resources). Cheers, [1] http://hackage.haskell.org/package/resourcet On Tue, Jan 29, 2013 at 8:59 PM, Thiago Negri wrote: > `Control.Exception.bracket` is a nice function to acquire and release a > resource in a small context. > > But, how should I handle resources that are hold for a long time? > > Should I put `Control.Exception.finally` on every single line of my > finalizers? > What exceptions may occur on an IO operation? > Every IO function has the risk of throwing an exception? > > Thanks, > Thiago. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Felipe. From evohunz at gmail.com Wed Jan 30 14:15:53 2013 From: evohunz at gmail.com (Thiago Negri) Date: Wed, 30 Jan 2013 11:15:53 -0200 Subject: [Haskell-cafe] Handling exceptions or gracefully releasing resources In-Reply-To: References: Message-ID: Felipe, I'm trying to use your Hipmunk package. :) The resources I need to keep around are the objects used for the simulation. Do you recomend using "resourcet" to handle this or something else? Thanks. 2013/1/30 Felipe Almeida Lessa > Everything that Johan Tibell said + you may be interested in the > resourcet package [1] (which is used by conduit to handle resources). > > Cheers, > > [1] http://hackage.haskell.org/package/resourcet > > On Tue, Jan 29, 2013 at 8:59 PM, Thiago Negri wrote: > > `Control.Exception.bracket` is a nice function to acquire and release a > > resource in a small context. > > > > But, how should I handle resources that are hold for a long time? > > > > Should I put `Control.Exception.finally` on every single line of my > > finalizers? > > What exceptions may occur on an IO operation? > > Every IO function has the risk of throwing an exception? > > > > Thanks, > > Thiago. > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Felipe. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Wed Jan 30 14:52:58 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Wed, 30 Jan 2013 11:52:58 -0200 Subject: [Haskell-cafe] Handling exceptions or gracefully releasing resources In-Reply-To: References: Message-ID: AFAIR, the only object that you need to be careful with is the Space [1], everything else is garbage collected. You could put the Space in a ResourceT, but only if it ran on its own thread (as soon as a block of ResourceT finishes, everything is deallocated, so you wouldn't be able to follow the approach taken by HipmunkPlayground). Cheers, [1] http://hackage.haskell.org/packages/archive/Hipmunk/5.2.0.10/doc/html/Physics-Hipmunk-Space.html#v:freeSpace On Wed, Jan 30, 2013 at 11:15 AM, Thiago Negri wrote: > Felipe, I'm trying to use your Hipmunk package. :) > The resources I need to keep around are the objects used for the simulation. > Do you recomend using "resourcet" to handle this or something else? > > Thanks. > > > 2013/1/30 Felipe Almeida Lessa >> >> Everything that Johan Tibell said + you may be interested in the >> resourcet package [1] (which is used by conduit to handle resources). >> >> Cheers, >> >> [1] http://hackage.haskell.org/package/resourcet >> >> On Tue, Jan 29, 2013 at 8:59 PM, Thiago Negri wrote: >> > `Control.Exception.bracket` is a nice function to acquire and release a >> > resource in a small context. >> > >> > But, how should I handle resources that are hold for a long time? >> > >> > Should I put `Control.Exception.finally` on every single line of my >> > finalizers? >> > What exceptions may occur on an IO operation? >> > Every IO function has the risk of throwing an exception? >> > >> > Thanks, >> > Thiago. >> > >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> >> >> -- >> Felipe. > > -- Felipe. From guillaumh at gmail.com Wed Jan 30 15:47:31 2013 From: guillaumh at gmail.com (Guillaume Hoffmann) Date: Wed, 30 Jan 2013 15:47:31 +0100 Subject: [Haskell-cafe] Darcs Hacking Sprint #8 (February 15-17, Paris) Message-ID: Dear hackers, the Darcs project is glad to announce that the next Hacking Sprint will take place in Paris on February 15-17, at the IRILL (near Place d'Italie). Please check out the details at: http://darcs.net/Sprints/2013-02 Here are three things to know 1. Everybody is welcome to join us. We'd love to have you, whatever your Haskell or Darcs hacking experience. Also, if you've got a wacky idea for the future of version control, or a cool use for the Darcs library, you should join us too :-) 2. Please let us know if you're attending. Just add your name to http://wiki.darcs.net/Sprints/2013-02 and you're good to go. You can also send us an email. 3. We can reimburse travel costs (within reason!). Let us know if you'd like a reimbursement, and save your receipts. Many thanks to everybody who participated in our fundraising drives or who gave money on the side. Thanks also to the Software Freedom Conservancy for making fundraising and reimbursements so painless! If you can't join us in person, but you'd like to cheer us on, say hello at http://darcs.net/Donations ! Looking forward to seeing you! Guillaume From allbery.b at gmail.com Wed Jan 30 16:07:44 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 30 Jan 2013 10:07:44 -0500 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> Message-ID: On Wed, Jan 30, 2013 at 7:02 AM, Junior White wrote: > Thanks for your reply! I must learn more to fully understand what's going > on inside the list comprehension. > But when I frist learn Haskell, it says sequence doesn't matter, but now > it is a big matter, can compiler do some thing for us? I think this > behavior is not friendly to newbies like me, I will take a very long time > to work through it. > No, the compiler can't help you here. The compiler is not an oracle; even if it could invert your calculation (effectively swapping the loops around), it can't know which one is more appropriate. As to sequences: sequence doesn't matter indeed; data dependencies matter, and loop ordering imposes a data dependency because loops in Haskell are encoded as data structures (lists). -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Wed Jan 30 17:41:14 2013 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 30 Jan 2013 22:11:14 +0530 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> Message-ID: On Wed, Jan 30, 2013 at 5:32 PM, Junior White wrote: > > > Thanks for your reply! I must learn more to fully understand what's going > on inside the list comprehension. > But when I frist learn Haskell, it says sequence doesn't matter, but now > it is a big matter, can compiler do some thing for us? I think this > behavior is not friendly to newbies like me, I will take a very long time > to work through it. > Good point. Being a programmer means having to juggle many hats -- two important ones being the mathematician-hat and the machine-hat, also called declaration and 'imperation' Get only the first and your programs will run very inefficiently. Get only the second and your program will have bugs. Specifically in the case of list comprehensions the newbie needs - to practice thinking of the comprehension like a set comprehension and ignoring computation sequences - to practice thinking of comprehension in terms of map/filter etc ie operationally Both views are needed. Rusi -- http://www.the-magus.in http://blog.languager.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen.tetley at gmail.com Wed Jan 30 18:51:03 2013 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed, 30 Jan 2013 17:51:03 +0000 Subject: [Haskell-cafe] Monadic parser vs. combinator parser In-Reply-To: <20130130133847.0420ab87@tritium.streitmacht.eu> References: <201301301321.18592.jan.stolarek@p.lodz.pl> <20130130133847.0420ab87@tritium.streitmacht.eu> Message-ID: On 30 January 2013 12:38, Ertugrul S?ylemez wrote: > > A monadic parser /is/ a combinator parser. The code you linked just > doesn't go as far as wrapping it up with a newtype and providing a monad > instance. Further, (+>) in the linked example is monadic bind and `result` is `return`. The code looks more succinct than early Parser combinator libraries (like Hutton / Meijer) because it defines quite a few more combinators. Equivalents are available if you use say Parsec plus the usual applicative combinators. From ganesh at earth.li Wed Jan 30 20:12:19 2013 From: ganesh at earth.li (Ganesh Sittampalam) Date: Wed, 30 Jan 2013 19:12:19 +0000 Subject: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package In-Reply-To: References: <510849F7.7020107@earth.li> <5108C515.9060402@earth.li> Message-ID: <51097093.5090605@earth.li> Unfortunately I lack the time for a wholesale cleanup. If others have proposals and are willing to supply the patches that's a different matter! On 30/01/2013 08:01, Alfredo Di Napoli wrote: > Maybe (just my 2 cents!) since you are going to broke the API anyway, go > for it > and seize the occasion to really clean up :) > Obviously I'm saying this from a non-http-user point of view, maybe if I had > some code in production affected by this, my suggestion would have been > different :P > > Regards, > A. > > On 30 January 2013 07:00, Ganesh Sittampalam > wrote: > > On 29/01/2013 22:46, Johan Tibell wrote: > > On Tue, Jan 29, 2013 at 2:15 PM, Ganesh Sittampalam > > wrote: > >> tl;dr: I'm planning on removing the String instances from the HTTP > >> package. This is likely to break code. Obviously it will involve > a major > >> version bump. > > > > I think it's the right thing to do. Providing a little upgrade guide > > should help things to go smoother. > > One obvious cheap-and-dirty migration is via a newtype wrapper for > String that embeds the old broken behaviour (char8 encoding). Perhaps > the package should provide that? (with appropriate warnings etc) > > Ganesh > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ezyang at MIT.EDU Wed Jan 30 20:27:32 2013 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed, 30 Jan 2013 11:27:32 -0800 Subject: [Haskell-cafe] Ticking time bomb Message-ID: <1359574031-sup-1195@javelin> https://status.heroku.com/incidents/489 Unsigned Hackage packages are a ticking time bomb. Cheers, Edward From mail at nh2.me Wed Jan 30 20:44:27 2013 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Wed, 30 Jan 2013 19:44:27 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359574031-sup-1195@javelin> References: <1359574031-sup-1195@javelin> Message-ID: <5109781B.8010304@nh2.me> As long as we upload packages via plain HTTP, signing won't help though. On Wed 30 Jan 2013 19:27:32 GMT, Edward Z. Yang wrote: > https://status.heroku.com/incidents/489 > > Unsigned Hackage packages are a ticking time bomb. > > Cheers, > Edward > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ezyang at MIT.EDU Wed Jan 30 20:47:00 2013 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed, 30 Jan 2013 11:47:00 -0800 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <5109781B.8010304@nh2.me> References: <1359574031-sup-1195@javelin> <5109781B.8010304@nh2.me> Message-ID: <1359575164-sup-2642@javelin> > As long as we upload packages via plain HTTP, signing won't help though. I don't think that's true? If the package is tampered with, then the signature will be invalid; if the signature is also forged, then the private key is compromised and we can blacklist it. We care only about integrity, not secrecy. Edward From bob at redivi.com Wed Jan 30 20:58:09 2013 From: bob at redivi.com (Bob Ippolito) Date: Wed, 30 Jan 2013 11:58:09 -0800 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <5109781B.8010304@nh2.me> References: <1359574031-sup-1195@javelin> <5109781B.8010304@nh2.me> Message-ID: HTTPS doesn't really change anything if the server is compromised, it only prevents bad things from happening in transit. Sign the packages with GPG (or equivalent) before upload. The server never sees the package author's private key, only the public key. Server and/or client can warn or fail if the public key doesn't match their previous credentials or the signature verification fails. On Wed, Jan 30, 2013 at 11:44 AM, Niklas Hamb?chen wrote: > As long as we upload packages via plain HTTP, signing won't help though. > > On Wed 30 Jan 2013 19:27:32 GMT, Edward Z. Yang wrote: > > https://status.heroku.com/incidents/489 > > > > Unsigned Hackage packages are a ticking time bomb. > > > > Cheers, > > Edward > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nomeata at debian.org Wed Jan 30 21:59:48 2013 From: nomeata at debian.org (Joachim Breitner) Date: Wed, 30 Jan 2013 21:59:48 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359574031-sup-1195@javelin> References: <1359574031-sup-1195@javelin> Message-ID: <1359579588.5131.4.camel@kirk> Hi, Am Mittwoch, den 30.01.2013, 11:27 -0800 schrieb Edward Z. Yang: > https://status.heroku.com/incidents/489 > > Unsigned Hackage packages are a ticking time bomb. another reason why Cabal is no package manager?. (Ok, I admit that I don?t review every line of diff between the Haskell packages I uploads. But thanks to http://hdiff.luite.com/ I at least glance over them most of the time ? a hurdle that malicious code would have to take. And once a package has entered a distribution like Debian (which it only can with a valid cryptographic signatures), checksums and signatures are used in many places to (mostly) guarantee that the package reaches the user unmodified.) Greetings, Joachim ? http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-me-cabal-is-not-a-package-manager/ -- Joachim "nomeata" Breitner Debian Developer nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata -------------- 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: From arnaud.oqube at gmail.com Wed Jan 30 22:29:23 2013 From: arnaud.oqube at gmail.com (Arnaud Bailly) Date: Wed, 30 Jan 2013 22:29:23 +0100 Subject: [Haskell-cafe] Package conflicts using cabal-dev Message-ID: Hello, I am running into a strange issue that reminds me of Java's classloader black magic havoc :-) My code compiles fine using cabal-dev install, but when I try to compile an individual file with ghc, I got the following error: $ ghc -package-conf cabal-dev/packages-7.4.1.conf YakGraph.hs [1 of 1] Compiling YakGraph ( YakGraph.hs, YakGraph.o ) YakGraph.hs:13:30: Couldn't match expected type `Data.Text.Lazy.Internal.Text' with actual type `text-0.11.2.0:Data.Text.Lazy.Internal.Text' In the first argument of `unpack', namely `s' In the expression: unpack s In an equation for `fromGraphId': fromGraphId (Str s) = unpack s YakGraph.hs:24:57: Couldn't match expected type `Data.Text.Lazy.Internal.Text' with actual type `text-0.11.2.0:Data.Text.Lazy.Internal.Text' In the first argument of `unpack', namely `name' In the expression: unpack name In a case alternative: (Just (Str name)) : _ -> unpack name The code leading to this error is here: https://gist.github.com/4677191 Any insights on this would be appreciated. Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Wed Jan 30 23:31:51 2013 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Wed, 30 Jan 2013 20:31:51 -0200 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359579588.5131.4.camel@kirk> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> Message-ID: IMHO Hackage and Cabal should support package signing even if they aren't package managers. On Wed, Jan 30, 2013 at 6:59 PM, Joachim Breitner wrote: > Hi, > > Am Mittwoch, den 30.01.2013, 11:27 -0800 schrieb Edward Z. Yang: >> https://status.heroku.com/incidents/489 >> >> Unsigned Hackage packages are a ticking time bomb. > > another reason why Cabal is no package manager?. > > (Ok, I admit that I don?t review every line of diff between the Haskell > packages I uploads. But thanks to http://hdiff.luite.com/ I at least > glance over them most of the time ? a hurdle that malicious code would > have to take. And once a package has entered a distribution like Debian > (which it only can with a valid cryptographic signatures), checksums and > signatures are used in many places to (mostly) guarantee that the > package reaches the user unmodified.) > > Greetings, > Joachim > > ? http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-me-cabal-is-not-a-package-manager/ > > -- > Joachim "nomeata" Breitner > Debian Developer > nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C > JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Felipe. From daniel.is.fischer at googlemail.com Wed Jan 30 23:40:20 2013 From: daniel.is.fischer at googlemail.com (Daniel Fischer) Date: Wed, 30 Jan 2013 23:40:20 +0100 Subject: [Haskell-cafe] Package conflicts using cabal-dev In-Reply-To: References: Message-ID: <18135774.oWG5nK6Icc@linux-v7dw.site> On Wednesday 30 January 2013, 22:29:23, Arnaud Bailly wrote: YakGraph.hs:13:30: Couldn't match expected type `Data.Text.Lazy.Internal.Text' with actual type `text-0.11.2.0:Data.Text.Lazy.Internal.Text' one package (at least) you use - probably graphviz - was compiled with a version of `text` that is not the newest you have installed. GHC selects the newest installed version of a package by default, cabal and cabal-dev select the version that the other used packages require. Add a -package text-0.11.2.0 flag to the command line. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ezyang at MIT.EDU Wed Jan 30 23:43:42 2013 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed, 30 Jan 2013 14:43:42 -0800 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359579588.5131.4.camel@kirk> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> Message-ID: <1359585638-sup-7671@javelin> Excerpts from Joachim Breitner's message of Wed Jan 30 12:59:48 -0800 2013: > another reason why Cabal is no package manager?. Based on the linked post, it seems that you are arguing that cabal-install is not a package manager, and thus it is not necessary for it to duplicate the work that real package managers e.g. Debian or Ubuntu put into vetting, signing and releasing software. (Though I am not sure, so please correct me if I am wrong.) This argument seems specious. Whether or not cabal-install is or not intended to be a package manager, users expect it to act like one (as users expect rubygems to be a package manager), and, at the end of the day, that is what matters. Edward From Ramana.Kumar at cl.cam.ac.uk Wed Jan 30 23:46:26 2013 From: Ramana.Kumar at cl.cam.ac.uk (Ramana Kumar) Date: Wed, 30 Jan 2013 22:46:26 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359585638-sup-7671@javelin> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> Message-ID: On Wed, Jan 30, 2013 at 10:43 PM, Edward Z. Yang wrote: > This argument seems specious. Whether or not cabal-install is or not > intended to be a package manager, users expect it to act like one (as > users expect rubygems to be a package manager), and, at the end of the > day, that is what matters. > But playing along with their delusion might make it harder to change their minds. > > Edward > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at nh2.me Wed Jan 30 23:48:20 2013 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Wed, 30 Jan 2013 22:48:20 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359575164-sup-2642@javelin> References: <1359574031-sup-1195@javelin> <5109781B.8010304@nh2.me> <1359575164-sup-2642@javelin> Message-ID: <5109A334.9030209@nh2.me> You are right, I skipped over that this was actually a server-side exploit - sure, end-to-end signing will help here. On 30/01/13 19:47, Edward Z. Yang wrote: >> As long as we upload packages via plain HTTP, signing won't help though. From ezyang at MIT.EDU Wed Jan 30 23:48:27 2013 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed, 30 Jan 2013 14:48:27 -0800 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> Message-ID: <1359586077-sup-6738@javelin> Excerpts from Ramana Kumar's message of Wed Jan 30 14:46:26 -0800 2013: > > This argument seems specious. Whether or not cabal-install is or not > > intended to be a package manager, users expect it to act like one (as > > users expect rubygems to be a package manager), and, at the end of the > > day, that is what matters. > > > > But playing along with their delusion might make it harder to change their > minds. Looking at the library ecosystems of the most popular programming languages, I think this ship has already sailed. Edward From Ramana.Kumar at cl.cam.ac.uk Wed Jan 30 23:54:23 2013 From: Ramana.Kumar at cl.cam.ac.uk (Ramana Kumar) Date: Wed, 30 Jan 2013 22:54:23 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359586077-sup-6738@javelin> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> Message-ID: On Wed, Jan 30, 2013 at 10:48 PM, Edward Z. Yang wrote: > Excerpts from Ramana Kumar's message of Wed Jan 30 14:46:26 -0800 2013: > > > This argument seems specious. Whether or not cabal-install is or not > > > intended to be a package manager, users expect it to act like one (as > > > users expect rubygems to be a package manager), and, at the end of the > > > day, that is what matters. > > > > > > > But playing along with their delusion might make it harder to change > their > > minds. > > Looking at the library ecosystems of the most popular programming > languages, > I think this ship has already sailed. > I was talking only about Haskell and cabal. There is a viable alternative to using cabal as a package manager on Arch Linux (the Arch-Haskell package repositories). There is also the Stackage project that might make this possible on more distributions with real package managers. But if you keep calling cabal a package manager, eventually you'll have to write the patches to make it one. > > Edward > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nomeata at debian.org Wed Jan 30 23:57:28 2013 From: nomeata at debian.org (Joachim Breitner) Date: Wed, 30 Jan 2013 23:57:28 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359585638-sup-7671@javelin> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> Message-ID: <1359586648.7665.4.camel@kirk> Hi, Am Mittwoch, den 30.01.2013, 14:43 -0800 schrieb Edward Z. Yang: > Excerpts from Joachim Breitner's message of Wed Jan 30 12:59:48 -0800 2013: > > another reason why Cabal is no package manager?. > > Based on the linked post, it seems that you are arguing that cabal-install is > not a package manager, and thus it is not necessary for it to duplicate > the work that real package managers e.g. Debian or Ubuntu put into > vetting, signing and releasing software. (Though I am not sure, so please > correct me if I am wrong.) I?m not against cryptographically signed packages on hackage. In fact, I would whole-heatedly appreciate it, as it would make my work as a package maintainer easier. I was taking the opportunity to point out an advantage of established package management systems, to shamelessly advertise my work there, as not everyone sees distro-packaged libraries as a useful thing. Greetings, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata -------------- 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: From ezyang at MIT.EDU Thu Jan 31 00:07:09 2013 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed, 30 Jan 2013 15:07:09 -0800 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359586648.7665.4.camel@kirk> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586648.7665.4.camel@kirk> Message-ID: <1359586786-sup-5614@javelin> Excerpts from Joachim Breitner's message of Wed Jan 30 14:57:28 -0800 2013: > I?m not against cryptographically signed packages on hackage. In fact, I > would whole-heatedly appreciate it, as it would make my work as a > package maintainer easier. > > I was taking the opportunity to point out an advantage of established > package management systems, to shamelessly advertise my work there, as > not everyone sees distro-packaged libraries as a useful thing. Yes. In fact, I am a sysadmin for a large shared hosting environment, and the fact that programming language libraries tend not to be distro-packaged is an endless headache for us. We would like it if everything were just packaged properly! On the other hand, working in these circumstances has made me realize that there is a huge tension between the goals of package library authors and distribution managers (a package library author is desires ease of installation of their packages, keeping everyone up-to-date as possible and tends to be selfish when it comes to the rest of the ecosystem, whereas the distribution manager values stability, security, and global consistency of the ecosystem.) So there is a lot of work to be done here. Nevertheless, I believe we are in violent agreement that cryptographically signed Hackage packages should happen as soon as possible! Edward From trebla at vex.net Thu Jan 31 02:19:26 2013 From: trebla at vex.net (Albert Y. C. Lai) Date: Wed, 30 Jan 2013 20:19:26 -0500 Subject: [Haskell-cafe] TIPS: To Insure Package Sanity Message-ID: <5109C69E.7030003@vex.net> If you possess multiple instances (may be different versions, may be same version different builds) of a package, life can be hard and confusing. The problems are explained in my http://www.vex.net/~trebla/haskell/sicp.xhtml and faced by many people regularly. (Just read this mailing list.) cabal-install has a mechanism for not adding more instances. It is available since version 0.14.0, or earlier. It is just little known. It is also a bit manual. You have to give 1 instruction for each package. If you want to say it for n packages, you have to give n instructions. Also, if you give such an instruction for a package you do not already have, there is a problem: now you can't install that package. To insure package sanity, add these lines to your $HOME/.cabal/config, one line per package you want to protect. (Cannot merge into one line.) constraint: array installed constraint: bytestring installed constraint: Cabal installed constraint: containers installed ... Generally, do it for every package that comes with GHC, and every package that comes with the Haskell Platform if you have it, plus every package that you want stable. (You may omit packages that cannot possibly be on hackage, e.g., integer-gmp.) Remember to revise those lines whenever you switch GHC versions or Haskell Platform versions, since their package lists change. Alternatively, if you want even more manual work (in exchange for more fine-tuning perhaps?): every time you use "cabal install": cabal install --constraint="array installed" --constraint="bytestring installed" --constraint="Cabal installed" --constraint="containers installed" ... From dstcruz at gmail.com Thu Jan 31 03:39:54 2013 From: dstcruz at gmail.com (Daniel Santa Cruz) Date: Wed, 30 Jan 2013 21:39:54 -0500 Subject: [Haskell-cafe] Haskell Weekly News: Issue 256 Message-ID: Welcome to issue 256 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the weeks of January 20 to 26, 2013. Quotes of the Week * elliott: cmccann: unfortunately it is too perfect an abstraction to be useful. * SamanthaD: shachaf: you're one of those dirty imperative communists who want the state to dictate everything! * monochrom: I refuse camel case and mark zuckerberg. same level. not negotiable. * mauke: a newtype is like an existing type but wearing glasses and a fake mustache and a sign saying "you've never seen me before" Top Reddit Stories * Taking magic out of GHC or: Tracing compilation by transformation (intro to Core transformations, inlining,.. Domain: ics.p.lodz.pl, Score: 59, Comments: 2 On Reddit: [1] http://goo.gl/lJmsb Original: [2] http://goo.gl/IbJ5O * Introduction to Haskell IO Domain: haskellforall.com, Score: 57, Comments: 26 On Reddit: [3] http://goo.gl/fPky4 Original: [4] http://goo.gl/Xymbr * The longest type signature I have ever seen (package Nussinov78) Domain: i.imgur.com, Score: 48, Comments: 26 On Reddit: [5] http://goo.gl/ePwNs Original: [6] http://goo.gl/B74yW * There is now a patch for the GHC runtime system which implements a scheduler which can handle threads with priorities. Domain: hackage.haskell.org, Score: 47, Comments: 12 On Reddit: [7] http://goo.gl/22XgH Original: [8] http://goo.gl/8iC8w * Success story: novice haskeller moves console cursor with ?netwire? FRP library Domain: danbst.wordpress.com, Score: 43, Comments: 8 On Reddit: [9] http://goo.gl/dm8ga Original: [10] http://goo.gl/Ue7pK * Haskell as pseudo code Domain: arxiv.org, Score: 33, Comments: 2 On Reddit: [11] http://goo.gl/JL8Mf Original: [12] http://goo.gl/5D4zV * Generalizing do notation Domain: self.haskell, Score: 28, Comments: 19 On Reddit: [13] http://goo.gl/teYAD Original: [14] http://goo.gl/teYAD * Tutorial: Up-front Unit Testing in Haskell Domain: github.com, Score: 26, Comments: 21 On Reddit: [15] http://goo.gl/kjzYJ Original: [16] http://goo.gl/oB2jg * The Design of a Practical Proof Checker for a Lazy Functional Language [PDF] Domain: people.cs.missouri.edu, Score: 26, Comments: On Reddit: [17] http://goo.gl/sj5Aj Original: [18] http://goo.gl/eEUOj * Introduction to Haskell, Lecture 2 is Live Domain: shuklan.com, Score: 24, Comments: 4 On Reddit: [19] http://goo.gl/1nUVv Original: [20] http://goo.gl/rCbfx * Hugs in your browser Domain: tryhaskell.org, Score: 24, Comments: 21 On Reddit: [21] http://goo.gl/zNtex Original: [22] http://goo.gl/wMPPW * Free functors - the reason Free and operational are not equivalent Domain: self.haskell, Score: 24, Comments: 12 On Reddit: [23] http://goo.gl/E7qe7 Original: [24] http://goo.gl/E7qe7 * Scribbling, smudging and smearing with Haskell Domain: self.haskell, Score: 22, Comments: 108 On Reddit: [25] http://goo.gl/KBw0V Original: [26] http://goo.gl/KBw0V * Touch and Keyboard API (announcing Elm 0.7.1) Domain: elm-lang.org, Score: 20, Comments: 3 On Reddit: [27] http://goo.gl/OhFaH Original: [28] http://goo.gl/rV9bU * (re)implementing the generalised Functor strength function using lenses. Domain: statusfailed.com, Score: 20, Comments: 3 On Reddit: [29] http://goo.gl/gEYHr Original: [30] http://goo.gl/TDX2A Top StackOverflow Questions * Can using UndecidableInstances pragma locally have global consequences on compilation termination? votes: 20, answers: 1 Read on SO: [31] http://goo.gl/PcQF1 * Why doesn't GHC Haskell support overloaded record parameter names? votes: 14, answers: 1 Read on SO: [32] http://goo.gl/BJ71T * How much does it cost for Haskell FFI to go into C and back? votes: 14, answers: 2 Read on SO: [33] http://goo.gl/kUCKn * Compile unsafe Haskell votes: 13, answers: 1 Read on SO: [34] http://goo.gl/nGaCX * Why GADT/existential data constructors cannot be used in lazy patterns? votes: 12, answers: 2 Read on SO: [35] http://goo.gl/zhpCh * Correct design for Haskell exception handling votes: 11, answers: 2 Read on SO: [36] http://goo.gl/zeWoH * How to use phase control of inlining in haskell? votes: 10, answers: 0 Read on SO: [37] http://goo.gl/dyuGI * Looking for resources that help testing a Haskell implementation for standard conformance votes: 9, answers: 1 Read on SO: [38] http://goo.gl/DL7vY * Generate a C struct based on a complex Haskell type votes: 8, answers: 1 Read on SO: [39] http://goo.gl/7E8OT * How to structure a Haskell project? votes: 7, answers: 1 Read on SO: [40] http://goo.gl/J4GuA * Difference between two functions creating a singleton list votes: 7, answers: 3 Read on SO: [41] http://goo.gl/ZXzw0 Until next time, Daniel Santa Cruz References 1. http://ics.p.lodz.pl/~stolarek/blog/2013/01/taking-magic-out-of-ghc-or-tracing-compilation-by-transformation/ 2. http://www.reddit.com/r/haskell/comments/17bu54/taking_magic_out_of_ghc_or_tracing_compilation_by/ 3. http://www.haskellforall.com/2013/01/introduction-to-haskell-io.html 4. http://www.reddit.com/r/haskell/comments/17712e/introduction_to_haskell_io/ 5. http://i.imgur.com/Zv9JH9A.png 6. http://www.reddit.com/r/haskell/comments/178jwh/the_longest_type_signature_i_have_ever_seen/ 7. http://hackage.haskell.org/trac/ghc/ticket/7606 8. http://www.reddit.com/r/haskell/comments/1725g0/there_is_now_a_patch_for_the_ghc_runtime_system/ 9. http://danbst.wordpress.com/2013/01/23/novice-netwire-user/ 10. http://www.reddit.com/r/haskell/comments/173cxi/success_story_novice_haskeller_moves_console/ 11. http://arxiv.org/abs/1301.5076 12. http://www.reddit.com/r/haskell/comments/176xk0/haskell_as_pseudo_code/ 13. http://www.reddit.com/r/haskell/comments/16zrsp/generalizing_do_notation/ 14. http://www.reddit.com/r/haskell/comments/16zrsp/generalizing_do_notation/ 15. https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/en/tutorial.md 16. http://www.reddit.com/r/haskell/comments/1750i9/tutorial_upfront_unit_testing_in_haskell/ 17. http://people.cs.missouri.edu/~harrisonwl/papers/tfp2012.pdf 18. http://www.reddit.com/r/haskell/comments/179367/the_design_of_a_practical_proof_checker_for_a/ 19. http://shuklan.com/haskell 20. http://www.reddit.com/r/haskell/comments/172h5q/introduction_to_haskell_lecture_2_is_live/ 21. http://tryhaskell.org/hugs/ 22. http://www.reddit.com/r/haskell/comments/177a56/hugs_in_your_browser/ 23. http://www.reddit.com/r/haskell/comments/17a33g/free_functors_the_reason_free_and_operational_are/ 24. http://www.reddit.com/r/haskell/comments/17a33g/free_functors_the_reason_free_and_operational_are/ 25. http://www.reddit.com/r/haskell/comments/175mxw/scribbling_smudging_and_smearing_with_haskell/ 26. http://www.reddit.com/r/haskell/comments/175mxw/scribbling_smudging_and_smearing_with_haskell/ 27. http://elm-lang.org/blog/announce/version-0.7.1.elm 28. http://www.reddit.com/r/haskell/comments/179nwl/touch_and_keyboard_api_announcing_elm_071/ 29. http://statusfailed.com/blog/2013/01/26/haskells-strength-generalising-with-lenses.html 30. http://www.reddit.com/r/haskell/comments/17b5ak/reimplementing_the_generalised_functor_strength/ 31. http://stackoverflow.com/questions/14476230/can-using-undecidableinstances-pragma-locally-have-global-consequences-on-compil 32. http://stackoverflow.com/questions/14422169/why-doesnt-ghc-haskell-support-overloaded-record-parameter-names 33. http://stackoverflow.com/questions/14519905/how-much-does-it-cost-for-haskell-ffi-to-go-into-c-and-back 34. http://stackoverflow.com/questions/14429966/compile-unsafe-haskell 35. http://stackoverflow.com/questions/14538255/why-gadt-existential-data-constructors-cannot-be-used-in-lazy-patterns 36. http://stackoverflow.com/questions/14538294/correct-design-for-haskell-exception-handling 37. http://stackoverflow.com/questions/14446368/how-to-use-phase-control-of-inlining-in-haskell 38. http://stackoverflow.com/questions/14484569/looking-for-resources-that-help-testing-a-haskell-implementation-for-standard-co 39. http://stackoverflow.com/questions/14500582/generate-a-c-struct-based-on-a-complex-haskell-type 40. http://stackoverflow.com/questions/14421178/how-to-structure-a-haskell-project 41. http://stackoverflow.com/questions/14530555/difference-between-two-functions-creating-a-singleton-list 42. https://plus.google.com/105107667630152149014/about -------------- next part -------------- An HTML attachment was scrubbed... URL: From caseybasichis at gmail.com Thu Jan 31 06:41:48 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Wed, 30 Jan 2013 21:41:48 -0800 Subject: [Haskell-cafe] FFI - Approaches to C/C++ Message-ID: Hi, I'm working on a project in Haskell and C++ where the former is the brains and the latter is for UI, interaction etc. I've read this http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/ and a number of other haskell posts suggesting the OOP is not the way to go. Without trying to emulate functional programming through templates or boost::phoenix, what approaches do you all favor when designing parts of an application in C++? Patterns to embrace or avoid? Should I just use functions and handle things with name spaces? I was thinking about handling the callbacks with boosts signals and slots 2 I know this is not entirely haskell centric, but it is a question for haskell users. Thanks, Casey -- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis at gmail.com 310.387.7540 -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiish at gmail.com Thu Jan 31 06:59:10 2013 From: efiish at gmail.com (Junior White) Date: Thu, 31 Jan 2013 13:59:10 +0800 Subject: [Haskell-cafe] list comprehansion performance has hug different In-Reply-To: References: <754643DB-A73B-47FC-9BB9-9F0BFB792482@swierstra.net> Message-ID: Thank you everyone! I like Haskell because the following two reasons: 1. It is beautifully 2. There are many great guys like you here. I will work harder on it, and forgive me for my broken English. On Thu, Jan 31, 2013 at 12:41 AM, Rustom Mody wrote: > > > On Wed, Jan 30, 2013 at 5:32 PM, Junior White wrote: > >> >> >> Thanks for your reply! I must learn more to fully understand what's >> going on inside the list comprehension. >> But when I frist learn Haskell, it says sequence doesn't matter, but now >> it is a big matter, can compiler do some thing for us? I think this >> behavior is not friendly to newbies like me, I will take a very long time >> to work through it. >> > > Good point. Being a programmer means having to juggle many hats -- two > important ones being the mathematician-hat and the machine-hat, also called > declaration and 'imperation' Get only the first and your programs will run > very inefficiently. Get only the second and your program will have bugs. > > Specifically in the case of list comprehensions the newbie needs > - to practice thinking of the comprehension like a set comprehension and > ignoring computation sequences > - to practice thinking of comprehension in terms of map/filter etc ie > operationally > > Both views are needed. > Rusi > -- > http://www.the-magus.in > http://blog.languager.org > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Thu Jan 31 07:27:54 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 07:27:54 +0100 Subject: [Haskell-cafe] Ticking time bomb References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> Message-ID: <20130131072754.23345dad@tritium.streitmacht.eu> Ramana Kumar wrote: > But if you keep calling cabal a package manager, eventually you'll > have to write the patches to make it one. The combination of Cabal, cabal-install and Hackage is a package distribution system. As such, it needs the necessary cryptographic support. I don't view them as a package management system. What's important is that many programmers blindly trust the code they download, install and run from Hackage. Yes, it's a bad habit, but seriously, that's the alternative? Distributions are often some linear combination of outdated and broken with coefficients near 1. Let me restate the important fact with more emphasis: People are using Hackage! In any case there is no valid excuse for the lack of crypto. It's too easy to attack Hackage, so we need some crypto regardless of what we interpret it as. My proposal is: 1. Build the necessary machinery into Cabal to allow signing keys and packages and verifying the signatures, ideally through GnuPG. Cabal would benefit from that even without cabal-install and Hackage. 2. Update Hackage to allow uploading signatures along with packages. 3. Update cabal-install to allow signing packages and optionally checking the signatures. Do not allow signature chains. Do not support CAs for now. Have a database of trusted keys. Could be a directory below ~/.cabal with keys as files. More detailed (skip to next step, if you're not going to implement this): Before installing anything, build a map from maintainers from whom we would be installing packages to the packages they maintain. Maintainers are identified by their keys, not their usernames. If any of the keys is not trusted yet, then print this list as readable as possible. Use colors, etc. Hypothetical example: % cabal install diagrams Resolving dependencies... The following maintainers are untrusted: Diagrams Project <... at ...> [ABCD1234]: FP: 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 monoid-extras-0.2.2.2 dual-tree-0.1.0.1 diagrams-core-0.6.0.1 diagrams-lib-0.6.0.1 diagrams-svg-0.6.0.1 diagrams-contrib-0.6.0.1 diagrams-0.6 Trust them (?/y/n/t)? ? y: yes n: no (default) t: temporarily Trust them (?/y/n/t)? y Adding to trust db: Diagrams Project <... at ...> [ABCD1234] [install] Cabal should ignore the "Maintainer" field in the Cabal file. Only the signature counts here. Cabal must report a changed maintainer: % cabal install diagrams Resolving dependencies... WARNING: Package 'diagrams-core' has changed maintainer. [old key info] [new key info] Install anyway (y/n)? y The following maintainers are untrusted: [...] 4. Announce the change and urge maintainers to update their packages to include signatures. 5. Wait a few weeks. 6. Make signature verification the default in cabal-install. 7. Optionally implement CA support and establish a CA outside and offsite of Hackage. Someone with a good understanding of server security and cryptography should do that. They could be added to ~/.cabal/config to make package installations easier. Steps 1..6 should be done with high priority, otherwise they will never be finished. Step 7 is optional. If you're indeed considering this, I'm happy to turn this into a set of bug tracker issues and possibly help with the development. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From efiish at gmail.com Thu Jan 31 07:31:02 2013 From: efiish at gmail.com (Junior White) Date: Thu, 31 Jan 2013 14:31:02 +0800 Subject: [Haskell-cafe] linking errors while compile hugs98 in macos Message-ID: Hi Cafe, I downloaded the latest hugs98 source package, unzip and build, I get the following link errors. It seems many symbols are not defined, am I missing same depending libraries? This is my machine info: ? hugs98-plus-Sep2006 git:(master) ? uname -a Darwin lan-seimatoMacBook-Air.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64 ================================ Preprocessing Network/Hackage/Version Undefined symbols for architecture x86_64: "_environ", referenced from: ___hscore_environ in ccuTP291.o (maybe you meant: ___hscore_environ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status runhugs: Error occurred ERROR "libraries/bootlib/Foreign/C/Error.hs" - Error while running compilation command 'gcc -DNDEBUG=1 -g -no-cpp-precomp -flat_namespace -shared -fPIC -D__HUGS__ "-Ihugsdir/include" -o "libraries/bootlib/Foreign/C/Error.so" "libraries/bootlib/Foreign/C/Error.c" -Ipackages/base/include -Ighc/includes packages/base/cbits/PrelIOUtils.c' Undefined symbols for architecture x86_64: "_environ", referenced from: ___hscore_environ in ccYZo1zT.o (maybe you meant: ___hscore_environ) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status runhugs: Error occurred ERROR "libraries/bootlib/Foreign/Marshal/Alloc.hs" - Error while running compilation command 'gcc -DNDEBUG=1 -g -no-cpp-precomp -flat_namespace -shared -fPIC -D__HUGS__ "-Ihugsdir/include" -o "libraries/bootlib/Foreign/Marshal/Alloc.so" "libraries/bootlib/Foreign/Marshal/Alloc.c" -Ipackages/base/include -Ighc/includes packages/base/cbits/PrelIOUtils.c packages/base/cbits/dirUtils.c packages/base/cbits/consUtils.c' -------------- next part -------------- An HTML attachment was scrubbed... URL: From es at ertes.de Thu Jan 31 07:32:27 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 07:32:27 +0100 Subject: [Haskell-cafe] FFI - Approaches to C/C++ References: Message-ID: <20130131073227.47a241a7@tritium.streitmacht.eu> Casey Basichis wrote: > I'm working on a project in Haskell and C++ where the former is the > brains and the latter is for UI, interaction etc. That's a rather odd choice. Not exactly answering your question, but questioning your project decisions, why would you do UI and interaction in C++? You have the necessary Haskell bindings and libraries to write everything cleanly in Haskell. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From caseybasichis at gmail.com Thu Jan 31 08:08:39 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Wed, 30 Jan 2013 23:08:39 -0800 Subject: [Haskell-cafe] FFI - Approaches to C/C++ Message-ID: Hi Ertugrul, I'm not entirely sure what you mean. I'm intending on using Ogre for GUI - for which there is the Hogre bindings, but after emailing the DEV about it, I didn't get the impression from his advice that I should be using it for production code. Here is what he suggested: "It depends, really. Hogre is good for running Ogre from within Haskell, but it has its limitations. The number one thing people have been struggling with is handling input with hogre - there's Hois (Haskell wrapper for OIS) but it's not perfect (it misses input events), and the other option is having to write some C++ glue. Hogre is a solid proof of concept and you can do some demos with it, but if you're e.g. writing a game it might be a bit of a struggle. In the end it's about how much you value being able to write code in Haskell (or how allergic to C++ you are)." I'm on iOS so I imagine those difficulties are compounded. I am using several other C++ libraries for which there are no existing bindings and no Haskell alternative packages that are even remotely close. Are you suggesting it would be better to write all my own FFI bindings for all the needed libraries? Everything I read suggests that Haskells strengths are in transformation and that interaction is not its strong suit. I am interested in your thoughts and I am open to whatever, but you are the first to suggest that the mix is a bad idea. Thanks, Casey >>* I'm working on a project in Haskell and C++ where the former is the*>>* brains and the latter is for UI, interaction etc.* >That's a rather odd choice. Not exactly answering your question, but >questioning your project decisions, why would you do UI and interaction >in C++? You have the necessary Haskell bindings and libraries to write >everything cleanly in Haskell. > > >Greets, >Ertugrul -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Thu Jan 31 08:49:32 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Thu, 31 Jan 2013 08:49:32 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359574031-sup-1195@javelin> References: <1359574031-sup-1195@javelin> Message-ID: Not to downplay the significance of this issue, but a primary issue, much more important is to secure ghc, base, cabal-install, and the build process for these. The development process needs to be robust. That process should include signing commits by *two developers*. This is really not a lot of work as a code-review is already done, but more significantly helps fend off a lot of compromised repository issues. There are just a few simple rules to follow: Review the commit on your own equipment, and sign it. That way an attacker will have to compromise two physically different repositories. .http://mikegerwitz.com/docs/git-horror-story.html This is a change that doesn't need any new development, just a procedure change. Wrt Hackage, simply signing packages is going to improve things, but what would be way more awesome would be to have multiple people sign off on the difference between two releases. What I mean is that whenever somebody reviews a new release of some package (the diff from a previous release), the work they did should ideally be represented as a signature on that release, or the "commit" that is the diff between the two releases. Git can handle this sort of trust issues, but a simple signature scheme will not. Now if a large security-conscious corporation starts using packages from Hackage, they will already have a security team that does code reviews. With a simple signature scheme, the output from their security team will not be possible to use on Hackage. I for one would be much more likely to trust packages signed by the signature by someone who has found numerous security flaws in various packages on Hackage, than some random developer. One signature might mean "this is my release, if you trust my machine,repository, +++". Another signature might mean "the security team of X Corp has done a security review at level Y. This is cleared for production use.". Simply supporting the first signature is no good. So if we really want to fix this, I suggest moving a large part of the trust infrastructure off of hackage and into git or similar systems that have better support for dealing with trust. Alexander On Wed, Jan 30, 2013 at 8:27 PM, Edward Z. Yang wrote: > https://status.heroku.com/incidents/489 > > Unsigned Hackage packages are a ticking time bomb. > > Cheers, > Edward > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From akamaus at gmail.com Thu Jan 31 08:50:09 2013 From: akamaus at gmail.com (Dmitry Vyal) Date: Thu, 31 Jan 2013 11:50:09 +0400 Subject: [Haskell-cafe] Most used functions in hackage In-Reply-To: References: <510780DE.5060209@gmail.com> Message-ID: <510A2231.9090202@gmail.com> On 01/29/2013 12:23 PM, Casey Basichis wrote: > > Why do you think browsing function by function is a bad idea? It > seems that knowing exactly what the most used functions are would be > an extremely effective way of finding both which parts of the Prelude > and Hackage are most broadly useful (instead of browsing them like a > phonebook) and also finding support from the community as the most > commonly used functions would likely be the easiest to find support for. > Well, I think the popularity is best measured on the level of packages, not separate functions. And I've seen quite a few ratings of most popular packages in the past. For example: http://corp.galois.com/blog/2009/3/23/one-million-haskell-downloads.html http://haskellwebnews.wordpress.com/2011/03/16/hackage-stats-the-past-year/ I guess Google can suggest much more. There is one thing you should keep in mind while looking at such charts. Authors measure number of downloads. Most of them are results of cabal-install fetching dependencies, not of the deliberate decision of a programmer to use the package. From tab at snarc.org Thu Jan 31 09:11:02 2013 From: tab at snarc.org (Vincent Hanquez) Date: Thu, 31 Jan 2013 08:11:02 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359574031-sup-1195@javelin> References: <1359574031-sup-1195@javelin> Message-ID: <510A2716.1030302@snarc.org> On 01/30/2013 07:27 PM, Edward Z. Yang wrote: > https://status.heroku.com/incidents/489 > > Unsigned Hackage packages are a ticking time bomb. > I agree this is terrible, I've started working on this, but this is quite a bit of work and other priorities always pop up. https://github.com/vincenthz/cabal https://github.com/vincenthz/cabal-signature My current implementation generate a manifest during sdist'ing in cabal, and have cabal-signature called by cabal on the manifest to create a manifest.sign. The main issue i'm facing is how to create a Web of Trust for doing all the public verification bits. -- Vincent From tab at snarc.org Thu Jan 31 09:15:39 2013 From: tab at snarc.org (Vincent Hanquez) Date: Thu, 31 Jan 2013 08:15:39 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <5109A334.9030209@nh2.me> References: <1359574031-sup-1195@javelin> <5109781B.8010304@nh2.me> <1359575164-sup-2642@javelin> <5109A334.9030209@nh2.me> Message-ID: <510A282B.6010802@snarc.org> On 01/30/2013 10:48 PM, Niklas Hamb?chen wrote: > You are right, I skipped over that this was actually a server-side > exploit - sure, end-to-end signing will help here. > it helps also in the HTTP case; a MiTM wouldn't be able to change the package without knowing the private key. more to the point it also help the case with hackage mirrors (or a corrupt hackage admin). -- Vincent From ketil at malde.org Thu Jan 31 09:16:03 2013 From: ketil at malde.org (Ketil Malde) Date: Thu, 31 Jan 2013 09:16:03 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <20130131072754.23345dad@tritium.streitmacht.eu> References: <1359574031-sup-1195@javelin>, <1359579588.5131.4.camel@kirk>, <1359585638-sup-7671@javelin>, , <1359586077-sup-6738@javelin>, , <20130131072754.23345dad@tritium.streitmacht.eu> Message-ID: <8738xh3gzp.fsf@nmd999X.imr.no> Ertugrul S?ylemez writes: > People are using Hackage! +1. And I keep telling people to use it. Sure, it'd be better if they used .debs, .rpms, or whatever goes on Mac and Windows. But that would mean I would need to build those packages, including maintaining systems with the respective OSes. I haven't even managed to do it for the systems I do use. The most simple and obvious threat is here that some random evil person gets a Hackage account, uploads a new version of a common package with a trojan, and waits for unsuspecting users to download and install it. > My proposal is: > > 1. Build the necessary machinery into Cabal to allow signing [...] *MY* proposal is that: 0. Hackage sends an email to the previous uploader whenever a new version of a package is uploaded by somebody else. At least that way, I would be notified if it happened to my packages, and I would be able to check up on the situation, and rectify it. This is not to say that cryptographic signing is the wrong thing to do, but a very simple thing like this, which would probably take all of five minutes to implement, would reduce risk by a substantial amount. -k -- If I haven't seen further, it is by standing in the footprints of giants From nomeata at debian.org Thu Jan 31 09:22:18 2013 From: nomeata at debian.org (Joachim Breitner) Date: Thu, 31 Jan 2013 09:22:18 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359586786-sup-5614@javelin> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586648.7665.4.camel@kirk> <1359586786-sup-5614@javelin> Message-ID: <1359620538.4356.1.camel@kirk> Hi, Am Mittwoch, den 30.01.2013, 15:07 -0800 schrieb Edward Z. Yang: > Nevertheless, I believe we are in violent agreement that > cryptographically signed Hackage packages should happen as soon as > possible! I don?t think we need hackage support here. Just add a "MD5-Sum:" field to the .cabal file specifying the checksum of the resulting tarball, and everyone can just check it after downloading. At least with MD5 and modern computers, this should be possible by now or soon. (SCNR) Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata -------------- 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: From tab at snarc.org Thu Jan 31 09:26:37 2013 From: tab at snarc.org (Vincent Hanquez) Date: Thu, 31 Jan 2013 08:26:37 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <20130131072754.23345dad@tritium.streitmacht.eu> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> Message-ID: <510A2ABD.4060702@snarc.org> On 01/31/2013 06:27 AM, Ertugrul S?ylemez wrote: > In any case there is no valid excuse for the lack of crypto. It's too > easy to attack Hackage, so we need some crypto regardless of what we > interpret it as. > > My proposal is: > > 1. Build the necessary machinery into Cabal to allow signing keys and > packages and verifying the signatures, ideally through GnuPG. > Cabal would benefit from that even without cabal-install and > Hackage. Seems there's lots of suggestion of using gnupg, which is a perfectly valid answer if cabal was unix only, but i'm not sure it's a valid option considering windows. Sure you can install gnupg somehow, but sounds to me it's going the same problem as gtk2hs on windows. One better way, would be to tap in the 2, work in progress, gnupg haskell replacement: http://hackage.haskell.org/package/openpgp http://hackage.haskell.org/package/hOpenPGP AFAIK, both packages are not yet handling anything related to WoT, but just do the signing/verification (which is same status as my ad-hoc experiment) -- Vincent From es at ertes.de Thu Jan 31 09:23:56 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 09:23:56 +0100 Subject: [Haskell-cafe] FFI - Approaches to C/C++ In-Reply-To: References: Message-ID: <20130131092356.57582338@tritium.streitmacht.eu> Casey Basichis wrote: > I'm not entirely sure what you mean. > > I'm intending on using Ogre for GUI - for which there is the Hogre > bindings, but after emailing the DEV about it, I didn't get the > impression from his advice that I should be using it for production > code. Here is what he suggested: > > "It depends, really. Hogre is good for running Ogre from within > Haskell, but it has its limitations. The number one thing people have > been struggling with is handling input with hogre - there's Hois > (Haskell wrapper for OIS) but it's not perfect (it misses input > events), and the other option is having to write some C++ glue. Hogre > is a solid proof of concept and you can do some demos with it, but if > you're e.g. writing a game it might be a bit of a struggle. In the end > it's about how much you value being able to write code in Haskell (or > how allergic to C++ you are)." > > I'm on iOS so I imagine those difficulties are compounded. > > I am using several other C++ libraries for which there are no existing > bindings and no Haskell alternative packages that are even remotely > close. > > Are you suggesting it would be better to write all my own FFI bindings > for all the needed libraries? That's not what I'm suggesting. It was just too little information to properly judge the difficulty of doing everything in Haskell. Binding to Ogre (or C++ in general) is indeed difficult. If Hogre doesn't work or is too limited, your best option might be to write a C wrapper around the Hogre functionality you need. Another option is to use SDL/OpenGL directly, which may be easier or harder depending on your application. However, if you can build the bridge between your rendering library and Haskell, then Haskell is certainly the better choice. > Everything I read suggests that Haskells strengths are in > transformation and that interaction is not its strong suit. > > I am interested in your thoughts and I am open to whatever, but you > are the first to suggest that the mix is a bad idea. That used to be true, but the reason has nothing to do with the language. The problem was that the libraries weren't there. Nowadays you can write all sorts of interactive applications in Haskell, including GUIs, TUIs, games, simulations and web applications. However, I've long been waiting for useful bindings to Ogre or Irrlicht, but I'm afraid that it's not going to happen any time soon. Ultimately it's your choice. Let me summarize the possiblities: * C wrapper around Ogre. Easy integration, but need to write the rendering code in C/C++. * Full FFI bindings to Ogre. Difficult integration, but you can write your rendering code in Haskell. * Partial FFI bindings to Ogre. Integration may be somewhat easy, if you do the initialization in Haskell and the actual rendering in C/C++. However, this again requires to write the rendering in C/C++. * Using SDL/OpenGL directly: Everything available for Haskell. May be difficult, because you need to write OpenGL code. I hope, this helps. Greets, Ertugrul -- Key-ID: E5DD8D11 "Ertugrul Soeylemez " FPrint: BD28 3E3F BE63 BADD 4157 9134 D56A 37FA E5DD 8D11 Keysrv: hkp://subkeys.pgp.net/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From tab at snarc.org Thu Jan 31 09:35:43 2013 From: tab at snarc.org (Vincent Hanquez) Date: Thu, 31 Jan 2013 08:35:43 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <8738xh3gzp.fsf@nmd999X.imr.no> References: <1359574031-sup-1195@javelin>, <1359579588.5131.4.camel@kirk>, <1359585638-sup-7671@javelin>, , <1359586077-sup-6738@javelin>, , <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> Message-ID: <510A2CDF.3070902@snarc.org> On 01/31/2013 08:16 AM, Ketil Malde wrote: > *MY* proposal is that: > > 0. Hackage sends an email to the previous uploader whenever a new > version of a package is uploaded by somebody else. > > At least that way, I would be notified if it happened to my packages, > and I would be able to check up on the situation, and rectify it. > you wouldn't in real cases, it just fix the most obvious and simple attack vector. but consider: * someone intercepting your upload http stream, and replacing dynamically your package. * someone gaining malicious access to hackage and planting stuff inside packages. * a rogue hackage admin. * a rogue hackage mirror admin. it's obviously less easy than just creating an account and uploading things on top of other packages, but i don't think we should feel safe if the previous maintainer received an email about the change. For example, previous maintainer might be away from email for a long time potentially leaving a trojan version for days/weeks, or changed email address.. -- Vincent From donn at avvanta.com Thu Jan 31 09:36:06 2013 From: donn at avvanta.com (Donn Cave) Date: Thu, 31 Jan 2013 00:36:06 -0800 (PST) Subject: [Haskell-cafe] FFI - Approaches to C/C++ In-Reply-To: References: Message-ID: <20130131083606.C0612276C41@mail.avvanta.com> Quoth Casey Basichis , ... > I am using several other C++ libraries for which there are no existing > bindings and no Haskell alternative packages that are even remotely > close. > > Are you suggesting it would be better to write all my own FFI bindings > for all the needed libraries? > > Everything I read suggests that Haskells strengths are in > transformation and that interaction is not its strong suit. I've done it, for my own amusement - wrapped a C++ graphics toolkit and used it to write a couple small applications. Most of us would probably object to your transformation/interaction evaluation as presented above ... but it depends on your motivations. In my case, I simply wanted to use Haskell, and in fact I started with a model like yours where the UI was simply written in C++. There were some very cumbersome things about that arrangement though, so I was happy to integrate Haskell into the UI as soon as it became possible. On the other hand ... I'd be lying if I said the Haskell code is "cleaner", or really advantageous in any compelling way if we're just talking about the UI. It has its moments - Haskell is always going to pull a few things off pretty well, in a UI or whatever - but of course, this particular UI API is specifically more suited to C++, than Haskell. So given that one can write good, clean code in C++, too, the question is whether Haskell is so vastly advantageous for such applications that it compensates for the sketchy binding. It isn't, I think. Whereupon we come to your original question. Personally, I would just work with the model that's natural to your API. If it's a C++ OO 3D graphics library, then go OO, for the very same reasons discussed above. FP may in principle have all the virtues mentioned in that article, and it's good to be on the lookout for ways you can deploy some of that in a C++ program, but when it comes time to use that OO API, it's what you've got. Donn From es at ertes.de Thu Jan 31 09:38:11 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 09:38:11 +0100 Subject: [Haskell-cafe] Ticking time bomb References: <1359574031-sup-1195@javelin> <510A2716.1030302@snarc.org> Message-ID: <20130131093811.25f6f6c9@tritium.streitmacht.eu> Vincent Hanquez wrote: > I agree this is terrible, I've started working on this, but this is > quite a bit of work and other priorities always pop up. > > https://github.com/vincenthz/cabal > https://github.com/vincenthz/cabal-signature > > My current implementation generate a manifest during sdist'ing in > cabal, and have cabal-signature called by cabal on the manifest to > create a manifest.sign. > > The main issue i'm facing is how to create a Web of Trust for doing > all the public verification bits. You don't need it yet. See my other post. Once the basic infrastructure for signatures is established, you can allow the user to have a set of trusted keys. The idea is that users can ask for keys and/or import keys from key servers. In the worst case they accept keys when installing a package. Once you have such a trust database you can allow users to select, whether a key is to be trusted for signing other keys. Then you have basically everything to establish both hierarchial trust relationships (like CAs) and webs of trust. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From es at ertes.de Thu Jan 31 09:42:17 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 09:42:17 +0100 Subject: [Haskell-cafe] Ticking time bomb References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> Message-ID: <20130131094217.37bb87a2@tritium.streitmacht.eu> Vincent Hanquez wrote: > For example, previous maintainer might be away from email for a long > time potentially leaving a trojan version for days/weeks, or changed > email address.. And that may even be more harmful, because an insecure system with a false sense of security is worse than an insecure system alone. Let's do it properly. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From caseybasichis at gmail.com Thu Jan 31 09:51:41 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Thu, 31 Jan 2013 00:51:41 -0800 Subject: [Haskell-cafe] (no subject) Message-ID: Hi Ertugrul, Thank you for the detailed reply. From what you wrote, partial FFI still seems like the way to go. Unfortunately Ogre isn't the only large library I'm using, so "difficult" several times over sounds like a good way to handicap the project early on. I'm perfectly happy to use Haskell for the strengths that will most benefit my project. I can always go back and try to bring the C++ specific parts into the fold once a prototype is up and running. As it seems there is a great deal of c/c++ to do either way, I would really appreciate so thoughts towards my original question. What practices in C++ are preferred by Haskell users, in the know, for the parts of the app that will not be pure Haskell? Should I be looking to avoid OOP? Dependency Injection? I wont reiterate all the facets of the first post, but it would help me immensely to zero in on a few patterns and strategies that can minimized the damage I inflict in c++ land. Thanks, Casey p.s. With "That used to be true, but the reason has nothing to do with the language. The problem was that the libraries weren't there." What do you mean? Which packages should I be looking at? I am on iOS like I said, its a stage 1 GHC compiler so I don't have access to GHCI or template haskell. >Casey Basichis wrote: > >> I'm not entirely sure what you mean. >> >> I'm intending on using Ogre for GUI - for which there is the Hogre >> bindings, but after emailing the DEV about it, I didn't get the >> impression from his advice that I should be using it for production >> code. Here is what he suggested: >> >> "It depends, really. Hogre is good for running Ogre from within >> Haskell, but it has its limitations. The number one thing people have >> been struggling with is handling input with hogre - there's Hois >> (Haskell wrapper for OIS) but it's not perfect (it misses input >> events), and the other option is having to write some C++ glue. Hogre >> is a solid proof of concept and you can do some demos with it, but if >> you're e.g. writing a game it might be a bit of a struggle. In the end >> it's about how much you value being able to write code in Haskell (or >> how allergic to C++ you are)." >> >> I'm on iOS so I imagine those difficulties are compounded. >> >> I am using several other C++ libraries for which there are no existing >> bindings and no Haskell alternative packages that are even remotely >> close. >> >> Are you suggesting it would be better to write all my own FFI bindings >> for all the needed libraries? > >That's not what I'm suggesting. It was just too little information to >properly judge the difficulty of doing everything in Haskell. > >Binding to Ogre (or C++ in general) is indeed difficult. If Hogre >doesn't work or is too limited, your best option might be to write a C >wrapper around the Hogre functionality you need. Another option is to >use SDL/OpenGL directly, which may be easier or harder depending on your >application. > >However, if you can build the bridge between your rendering library and >Haskell, then Haskell is certainly the better choice. > > >> Everything I read suggests that Haskells strengths are in >> transformation and that interaction is not its strong suit. >> >> I am interested in your thoughts and I am open to whatever, but you >> are the first to suggest that the mix is a bad idea. > >That used to be true, but the reason has nothing to do with the >language. The problem was that the libraries weren't there. Nowadays >you can write all sorts of interactive applications in Haskell, >including GUIs, TUIs, games, simulations and web applications. However, >I've long been waiting for useful bindings to Ogre or Irrlicht, but I'm >afraid that it's not going to happen any time soon. > >Ultimately it's your choice. Let me summarize the possiblities: > > * C wrapper around Ogre. Easy integration, but need to write the > rendering code in C/C++. > > * Full FFI bindings to Ogre. Difficult integration, but you can write > your rendering code in Haskell. > > * Partial FFI bindings to Ogre. Integration may be somewhat easy, if > you do the initialization in Haskell and the actual rendering in > C/C++. However, this again requires to write the rendering in > C/C++. > > * Using SDL/OpenGL directly: Everything available for Haskell. May > be difficult, because you need to write OpenGL code. > >I hope, this helps. > > >Greets, >Ertugrul -------------- next part -------------- An HTML attachment was scrubbed... URL: From caseybasichis at gmail.com Thu Jan 31 09:53:45 2013 From: caseybasichis at gmail.com (Casey Basichis) Date: Thu, 31 Jan 2013 00:53:45 -0800 Subject: [Haskell-cafe] FFI - Approaches to C/C++ Message-ID: Hi Ertugrul, Thank you for the detailed reply. From what you wrote, partial FFI still seems like the way to go. Unfortunately Ogre isn't the only large library I'm using, so "difficult" several times over sounds like a good way to handicap the project early on. I'm perfectly happy to use Haskell for the strengths that will most benefit my project. I can always go back and try to bring the C++ specific parts into the fold once a prototype is up and running. As it seems there is a great deal of c/c++ to do either way, I would really appreciate so thoughts towards my original question. What practices in C++ are preferred by Haskell users, in the know, for the parts of the app that will not be pure Haskell? Should I be looking to avoid OOP? Dependency Injection? I wont reiterate all the facets of the first post, but it would help me immensely to zero in on a few patterns and strategies that can minimized the damage I inflict in c++ land. Thanks, Casey p.s. With "That used to be true, but the reason has nothing to do with the language. The problem was that the libraries weren't there." What do you mean? Which packages should I be looking at? I am on iOS like I said, its a stage 1 GHC compiler so I don't have access to GHCI or template haskell. >Casey Basichis wrote: > >> I'm not entirely sure what you mean. >> >> I'm intending on using Ogre for GUI - for which there is the Hogre >> bindings, but after emailing the DEV about it, I didn't get the >> impression from his advice that I should be using it for production >> code. Here is what he suggested: >> >> "It depends, really. Hogre is good for running Ogre from within >> Haskell, but it has its limitations. The number one thing people have >> been struggling with is handling input with hogre - there's Hois >> (Haskell wrapper for OIS) but it's not perfect (it misses input >> events), and the other option is having to write some C++ glue. Hogre >> is a solid proof of concept and you can do some demos with it, but if >> you're e.g. writing a game it might be a bit of a struggle. In the end >> it's about how much you value being able to write code in Haskell (or >> how allergic to C++ you are)." >> >> I'm on iOS so I imagine those difficulties are compounded. >> >> I am using several other C++ libraries for which there are no existing >> bindings and no Haskell alternative packages that are even remotely >> close. >> >> Are you suggesting it would be better to write all my own FFI bindings >> for all the needed libraries? > >That's not what I'm suggesting. It was just too little information to >properly judge the difficulty of doing everything in Haskell. > >Binding to Ogre (or C++ in general) is indeed difficult. If Hogre >doesn't work or is too limited, your best option might be to write a C >wrapper around the Hogre functionality you need. Another option is to >use SDL/OpenGL directly, which may be easier or harder depending on your >application. > >However, if you can build the bridge between your rendering library and >Haskell, then Haskell is certainly the better choice. > > >> Everything I read suggests that Haskells strengths are in >> transformation and that interaction is not its strong suit. >> >> I am interested in your thoughts and I am open to whatever, but you >> are the first to suggest that the mix is a bad idea. > >That used to be true, but the reason has nothing to do with the >language. The problem was that the libraries weren't there. Nowadays >you can write all sorts of interactive applications in Haskell, >including GUIs, TUIs, games, simulations and web applications. However, >I've long been waiting for useful bindings to Ogre or Irrlicht, but I'm >afraid that it's not going to happen any time soon. > >Ultimately it's your choice. Let me summarize the possiblities: > > * C wrapper around Ogre. Easy integration, but need to write the > rendering code in C/C++. > > * Full FFI bindings to Ogre. Difficult integration, but you can write > your rendering code in Haskell. > > * Partial FFI bindings to Ogre. Integration may be somewhat easy, if > you do the initialization in Haskell and the actual rendering in > C/C++. However, this again requires to write the rendering in > C/C++. > > * Using SDL/OpenGL directly: Everything available for Haskell. May > be difficult, because you need to write OpenGL code. > >I hope, this helps. > > >Greets, >Ertugrul -- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis at gmail.com 310.387.7540 -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Thu Jan 31 09:54:42 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Thu, 31 Jan 2013 09:54:42 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <510A2ABD.4060702@snarc.org> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <510A2ABD.4060702@snarc.org> Message-ID: On Thu, Jan 31, 2013 at 9:26 AM, Vincent Hanquez wrote: > On 01/31/2013 06:27 AM, Ertugrul S?ylemez wrote: > >> In any case there is no valid excuse for the lack of crypto. It's too >> easy to attack Hackage, so we need some crypto regardless of what we >> interpret it as. >> >> My proposal is: >> >> 1. Build the necessary machinery into Cabal to allow signing keys and >> packages and verifying the signatures, ideally through GnuPG. >> Cabal would benefit from that even without cabal-install and >> Hackage. >> > > Seems there's lots of suggestion of using gnupg, which is a perfectly > valid answer if cabal was unix only, but i'm not sure it's a valid option > considering windows. Sure you can install gnupg somehow, but sounds to me > it's going the same problem as gtk2hs on windows. > > One better way, would be to tap in the 2, work in progress, gnupg haskell > replacement: > > http://hackage.haskell.org/**package/openpgp > http://hackage.haskell.org/**package/hOpenPGP > > AFAIK, both packages are not yet handling anything related to WoT, but > just do the signing/verification (which is same status as my ad-hoc > experiment) > > In this case I think this is the wrong approach. There must be at least one way to work within a trust model that is not fragile. Whether this is fully supported on all platforms is actually not very important. I have pointed out why simply signing packages is fragile and how git is better suited for this task. We are not going to reimplement all the good infrastructure that already exists (gpg, git), so making that a requirement is not a good idea IMO. Basic verification of signatures should work on Windows, I agree. But the underlying WoT should be a little bit more sophisticated. This means it has to be based on standard tools, or it will never happen. Alexander > > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Ramana.Kumar at cl.cam.ac.uk Thu Jan 31 10:12:12 2013 From: Ramana.Kumar at cl.cam.ac.uk (Ramana Kumar) Date: Thu, 31 Jan 2013 09:12:12 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <8738xh3gzp.fsf@nmd999X.imr.no> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> Message-ID: On Thu, Jan 31, 2013 at 8:16 AM, Ketil Malde wrote: > > Ertugrul S?ylemez writes: > > > People are using Hackage! > > +1. And I keep telling people to use it. Sure, it'd be better if they > used .debs, .rpms, or whatever goes on Mac and Windows. But that would > mean I would need to build those packages, including maintaining systems > with the respective OSes. I haven't even managed to do it for the > systems I do use. > Some people seem to have been confused that by suggesting that cabal is not a package manager, I was suggesting not to use Hackage or cabal at all, or not to bother signing packages. To be clear, I am for the following: - Using Hackage (for storing packages, searching online, downloading to create OS packages) - Using cabal (as a package developer, for testing/creating/uploading packages) - Signing packages on Hackage - this is important for security, and I don't want to detract further from the discussion about how to do it. What I am against is: - Using cabal to "install" packages and generally as a package manager (e.g. try to use it to delete or upgrade packages). This often ends in tears, because that is not cabal's job and it doesn't do it well! Rather, you should help whoever is making packages for your OS (or start doing this) by packaging the existing "cabal packages" on Hackage as proper OS packages suitable for install/upgrade/remove etc. This can be largely automated, and the main headaches come from dependency issues, which are a separate problem on Hackage (and which Stackage is aiming to alleviate). -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Thu Jan 31 10:28:49 2013 From: mail at joachim-breitner.de (Joachim Breitner) Date: Thu, 31 Jan 2013 10:28:49 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <20130131094217.37bb87a2@tritium.streitmacht.eu> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> <20130131094217.37bb87a2@tritium.streitmacht.eu> Message-ID: <1359624529.4356.15.camel@kirk> Hi, Am Donnerstag, den 31.01.2013, 09:42 +0100 schrieb Ertugrul S?ylemez: > And that may even be more harmful, because an insecure system with a > false sense of security is worse than an insecure system alone. > > Let's do it properly. but don?t overengineer it either. Simply adding to hackage the possibility to store a .asc file next to the tar.gz file that contains the cryptographic signature would be a great start, and allow us to develop a WoT model later on. (I try to resist from wondering whether this could go into hackage1 or only hackage2, and in the latter case, whether that means that we actually have the time to overengineer the system.) In fact, a lot would already be gained by a simple ?warn if foo-2.0 is signed with a different key than the version of foo already installed? on cabal-install and people having a closer look at uploads from different people. Not much infrastructure needed there. Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- 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: From jan.stolarek at p.lodz.pl Thu Jan 31 10:47:12 2013 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Thu, 31 Jan 2013 10:47:12 +0100 Subject: [Haskell-cafe] Monadic parser vs. combinator parser In-Reply-To: References: <201301301321.18592.jan.stolarek@p.lodz.pl> <20130130133847.0420ab87@tritium.streitmacht.eu> Message-ID: <201301311047.12785.jan.stolarek@p.lodz.pl> Thanks for replies guys. I indeed didn't notice that there are monads and applicatives used in this parser. My thought that monadic parsers are more verbose came from Hutton's paper where the code is definitely less readable than in example I provided. There is one more thing that bothers me. It is easy to write a parser that returns Nothing when parsing fails. But I can't figure out a way to add meaningful error messages so that the user knows where did the parsing fail. I experimented with using Either so that I can use Left to pass error messages but this turned out to be inflexible and clutered the code. I will be greatful for any ideas. Janek From simon at banquise.net Thu Jan 31 10:48:16 2013 From: simon at banquise.net (Simon Marechal) Date: Thu, 31 Jan 2013 10:48:16 +0100 Subject: [Haskell-cafe] "branching" conduits Message-ID: <510A3DE0.8010708@banquise.net> Hello, I have found the Conduit abstraction to be very well suited to a set of problems I am facing. I am however wondering how to implement "branching" conduits, and even conduit pools. I am currently in the process of rewriting parts (the simple parts) of the Logstash tool. There is a sample program that I use here: https://github.com/bartavelle/hslogstash/blob/deprecateUtils/examples/RedisToElasticsearch.hs As it can be seen, it uses a "Redis" source, a conduit that decodes the JSON ByteString into a LogstashMessage, a conduit that stores it into Elasticsearch and outputs the result of that action as an Either, and finally a sink that prints the errors. My problem is that I would like more complex behaviour. For example, I would like to route messages to another server instead of putting them into Elasticsearch when the LogstashMessage has some tag set. But this is just an example, and it is probable I will want much more complex behavior soon. I am not sure how to proceed from here, but have the following ideas: * investigate how the Conduits are made internally to see if I can create a operator similar to $$, but that would have a signature like: Source m (Either a b) -> Sink a m r -> Sink b m r and would do the branching in a binary fashion. I am not sure this is even possible. * create a "mvars" connectors constructor, which might have a signature like this: Int -- ^ branch count (LogstashMessage -> Int) -- ^ branching function (Sink LogstashMessage m (), [Source m LogstashMessage]) -- ^ a suitable sink, several sources for the other conduits it would internally create a MVar (Maybe LogstashMessage) for each branch, and put putMVar accordingly to the branching function. When the Conduit is destroyed, it will putMVar Nothing in all MVars. the sources would takeMVar, check if it is Nothing, or just proceed as expected. The MVar should guarantee the constant space property, but there is the risk of inter branch blocking when one of the branches is significantly slower than the others. It doesn't really matter to me anyway. And all the branch Sinks would have to have some synchronization mechanism so that the main thread waits for them (as they are going to be launched by a forkIO). This is the simplest scheme I have thought of, and it is probably not a very good one. I am very interested in suggestions here. From es at ertes.de Thu Jan 31 11:06:32 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 11:06:32 +0100 Subject: [Haskell-cafe] Ticking time bomb References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> <20130131094217.37bb87a2@tritium.streitmacht.eu> <1359624529.4356.15.camel@kirk> Message-ID: <20130131110632.30bf003f@tritium.streitmacht.eu> Joachim Breitner wrote: > > And that may even be more harmful, because an insecure system with a > > false sense of security is worse than an insecure system alone. > > > > Let's do it properly. > > but don?t overengineer it either. Simply adding to hackage the > possibility to store a .asc file next to the tar.gz file that contains > the cryptographic signature would be a great start, and allow us to > develop a WoT model later on. > > (I try to resist from wondering whether this could go into hackage1 or > only hackage2, and in the latter case, whether that means that we > actually have the time to overengineer the system.) > > In fact, a lot would already be gained by a simple ?warn if foo-2.0 is > signed with a different key than the version of foo already installed? > on cabal-install and people having a closer look at uploads from > different people. Not much infrastructure needed there. That was exactly my suggestion actually. It requires the ability to make and check signatures. The making can be done with external tools like GnuPG, but the checking has to be done by cabal-install. To detect changed keys there also needs to be a trust database, which can be a simple directory in ~/.cabal/ where files are named after the fingerprint of the key it contains. The most important part is a sensible user interface. The whole process should be invisible to the user, until there is a signature error. The first installation of a package will actually generate a handful of signature errors, because the keys are not known yet. This shouldn't be too hard to implement and requires only a small change to Hackage and cabal-install's upload command to begin. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From es at ertes.de Thu Jan 31 11:07:32 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 11:07:32 +0100 Subject: [Haskell-cafe] Monadic parser vs. combinator parser In-Reply-To: <201301311047.12785.jan.stolarek@p.lodz.pl> References: <201301301321.18592.jan.stolarek@p.lodz.pl> <20130130133847.0420ab87@tritium.streitmacht.eu> <201301311047.12785.jan.stolarek@p.lodz.pl> Message-ID: <20130131110732.3eea8772@tritium.streitmacht.eu> Jan Stolarek wrote: > Thanks for replies guys. I indeed didn't notice that there are monads > and applicatives used in this parser. My thought that monadic parsers > are more verbose came from Hutton's paper where the code is definitely > less readable than in example I provided. > > There is one more thing that bothers me. It is easy to write a parser > that returns Nothing when parsing fails. But I can't figure out a way > to add meaningful error messages so that the user knows where did the > parsing fail. I experimented with using Either so that I can use Left > to pass error messages but this turned out to be inflexible and > clutered the code. I will be greatful for any ideas. Remember that 'Either e' is also a monad. =) Greets, Ertugrul -- Key-ID: E5DD8D11 "Ertugrul Soeylemez " FPrint: BD28 3E3F BE63 BADD 4157 9134 D56A 37FA E5DD 8D11 Keysrv: hkp://subkeys.pgp.net/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From leather at cs.uu.nl Thu Jan 31 11:36:52 2013 From: leather at cs.uu.nl (Sean Leather) Date: Thu, 31 Jan 2013 11:36:52 +0100 Subject: [Haskell-cafe] Monadic parser vs. combinator parser In-Reply-To: <201301301321.18592.jan.stolarek@p.lodz.pl> References: <201301301321.18592.jan.stolarek@p.lodz.pl> Message-ID: On Wed, Jan 30, 2013 at 1:21 PM, Jan Stolarek wrote: > I will be writing a parser in Haskell and I wonder how to approach the > problem. Utrecht University has a course that covers this, among other things. You might find the slides and lecture notes useful: http://www.cs.uu.nl/wiki/TC/CourseMaterials Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From tab at snarc.org Thu Jan 31 11:40:35 2013 From: tab at snarc.org (Vincent Hanquez) Date: Thu, 31 Jan 2013 10:40:35 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <20130131110632.30bf003f@tritium.streitmacht.eu> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> <20130131094217.37bb87a2@tritium.streitmacht.eu> <1359624529.4356.15.camel@kirk> <20130131110632.30bf003f@tritium.streitmacht.eu> Message-ID: <510A4A23.4090909@snarc.org> On 01/31/2013 10:06 AM, Ertugrul S?ylemez wrote: > Joachim Breitner wrote: > >>> And that may even be more harmful, because an insecure system with a >>> false sense of security is worse than an insecure system alone. >>> >>> Let's do it properly. >> but don?t overengineer it either. Simply adding to hackage the >> possibility to store a .asc file next to the tar.gz file that contains >> the cryptographic signature would be a great start, and allow us to >> develop a WoT model later on. >> >> (I try to resist from wondering whether this could go into hackage1 or >> only hackage2, and in the latter case, whether that means that we >> actually have the time to overengineer the system.) >> >> In fact, a lot would already be gained by a simple ?warn if foo-2.0 is >> signed with a different key than the version of foo already installed? >> on cabal-install and people having a closer look at uploads from >> different people. Not much infrastructure needed there. > That was exactly my suggestion actually. It requires the ability to > make and check signatures. The making can be done with external tools > like GnuPG, but the checking has to be done by cabal-install. To detect > changed keys there also needs to be a trust database, which can be a > simple directory in ~/.cabal/ where files are named after the > fingerprint of the key it contains. > > The most important part is a sensible user interface. The whole process > should be invisible to the user, until there is a signature error. The > first installation of a package will actually generate a handful of > signature errors, because the keys are not known yet. > > This shouldn't be too hard to implement and requires only a small change > to Hackage and cabal-install's upload command to begin. That's not a proper solution, and definitively in the warm fuzzy feeling department. What if you install a package for the first time and this package has just been re-uploaded maliciously with a different key and a payload ? What if you're relying on hackage mirrors, what stop this mirror to regenerate all signatures with a new key ? It also make maintainers change difficult, and doing genuine non-maintainer upload. -- Vincent From alexander.kjeldaas at gmail.com Thu Jan 31 11:41:55 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Thu, 31 Jan 2013 11:41:55 +0100 Subject: [Haskell-cafe] FFI - Approaches to C/C++ In-Reply-To: References: Message-ID: From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID: software) results. This is not what normal Haskell bindings look like though: 1. Create an interface over the Haskell RTS if you are going to use any of it from C++, and use dependency injection to choose between mock and real implementations. 2. Create a mock implementation of the Haskell side if it is accessed from C++. 3. Create comprehensive C++ only tests (using mock Haskell) that runs cleanly through valgrind. 4. Create as small an interface between C++ and Haskell as possible. 5. If you have a wide API that has little performance implications between Haskell and C++, consider not using the FFI directly, but a higher-level abstraction such as protocol buffers for this part of your API. Alexander On Thu, Jan 31, 2013 at 9:53 AM, Casey Basichis wrote: > Hi Ertugrul, > > Thank you for the detailed reply. From what you wrote, partial FFI still > seems like the way to go. > > Unfortunately Ogre isn't the only large library I'm using, so "difficult" > several times over sounds like a good way to handicap the project early on. > > I'm perfectly happy to use Haskell for the strengths that will most > benefit my project. I can always go back and try to bring the C++ specific > parts into the fold once a prototype is up and running. > > As it seems there is a great deal of c/c++ to do either way, I would > really appreciate so thoughts towards my original question. > > What practices in C++ are preferred by Haskell users, in the know, for the > parts of the app that will not be pure Haskell? > > Should I be looking to avoid OOP? Dependency Injection? I wont reiterate > all the facets of the first post, but it would help me immensely to zero in > on a few patterns and strategies that can minimized the damage I inflict in > c++ land. > > Thanks, > Casey > > p.s. > > With > > "That used to be true, but the reason has nothing to do with the language. > The problem was that the libraries weren't there." > > What do you mean? Which packages should I be looking at? I am on iOS like > I said, its a stage 1 GHC compiler so I don't have access to GHCI or > template haskell. > > > >Casey Basichis wrote: > > > >> I'm not entirely sure what you mean. > >> > >> I'm intending on using Ogre for GUI - for which there is the Hogre > >> bindings, but after emailing the DEV about it, I didn't get the > >> impression from his advice that I should be using it for production > >> code. Here is what he suggested: > >> > >> "It depends, really. Hogre is good for running Ogre from within > >> Haskell, but it has its limitations. The number one thing people have > >> been struggling with is handling input with hogre - there's Hois > >> (Haskell wrapper for OIS) but it's not perfect (it misses input > >> events), and the other option is having to write some C++ glue. Hogre > >> is a solid proof of concept and you can do some demos with it, but if > >> you're e.g. writing a game it might be a bit of a struggle. In the end > >> it's about how much you value being able to write code in Haskell (or > >> how allergic to C++ you are)." > >> > >> I'm on iOS so I imagine those difficulties are compounded. > >> > >> I am using several other C++ libraries for which there are no existing > >> bindings and no Haskell alternative packages that are even remotely > >> close. > >> > >> Are you suggesting it would be better to write all my own FFI bindings > >> for all the needed libraries? > > > >That's not what I'm suggesting. It was just too little information to > >properly judge the difficulty of doing everything in Haskell. > > > >Binding to Ogre (or C++ in general) is indeed difficult. If Hogre > >doesn't work or is too limited, your best option might be to write a C > >wrapper around the Hogre functionality you need. Another option is to > >use SDL/OpenGL directly, which may be easier or harder depending on your > >application. > > > >However, if you can build the bridge between your rendering library and > >Haskell, then Haskell is certainly the better choice. > > > > > >> Everything I read suggests that Haskells strengths are in > >> transformation and that interaction is not its strong suit. > >> > >> I am interested in your thoughts and I am open to whatever, but you > >> are the first to suggest that the mix is a bad idea. > > > >That used to be true, but the reason has nothing to do with the > >language. The problem was that the libraries weren't there. Nowadays > >you can write all sorts of interactive applications in Haskell, > >including GUIs, TUIs, games, simulations and web applications. However, > >I've long been waiting for useful bindings to Ogre or Irrlicht, but I'm > >afraid that it's not going to happen any time soon. > > > >Ultimately it's your choice. Let me summarize the possiblities: > > > > * C wrapper around Ogre. Easy integration, but need to write the > > rendering code in C/C++. > > > > * Full FFI bindings to Ogre. Difficult integration, but you can write > > your rendering code in Haskell. > > > > * Partial FFI bindings to Ogre. Integration may be somewhat easy, if > > you do the initialization in Haskell and the actual rendering in > > C/C++. However, this again requires to write the rendering in > > C/C++. > > > > * Using SDL/OpenGL directly: Everything available for Haskell. May > > be difficult, because you need to write OpenGL code. > > > >I hope, this helps. > > > > > >Greets, > >Ertugrul > > > > -- > > Casey James Basichis > Composer - Cartoon Network > http://www.caseyjamesbasichis.com > caseybasichis at gmail.com > 310.387.7540 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > --14dae93403ebb434de04d49347cd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

From my experience, these things are needed= to get solid (i.e. not flaky software) results.
This is no= t what normal Haskell bindings look like though:

1. Create an interface over the Haskell RTS if you are going to = use any of it from C++, and use dependency injection to choose between mock= and real implementations.
2. Create a mock implementation = of the Haskell side if it is accessed from C++.
3. Create comprehensive C++ only tests (using mock Haskell= ) that runs cleanly through valgrind.
4. Create as small an= interface between C++ and Haskell as possible.
5. If you h= ave a wide API that has little performance implications between Haskell and= C++, consider not using the FFI directly, but a higher-level abstraction s= uch as protocol buffers for this part of your API.

Alexander

<= div class=3D"gmail_extra">

On Thu, Jan 31= , 2013 at 9:53 AM, Casey Basichis <caseybasichis at gmail.com> wrote:
Hi Ertugrul,

Thank you for the det= ailed reply. =C2=A0From what you wrote, partial FFI still seems like the wa= y to go.

Unfortunately Ogre isn't the only large library I&#= 39;m using, so "difficult" several times over sounds like a good = way to handicap the project early on.

I'm perfectly happy to use Haskell for the strength= s that will most benefit my project. =C2=A0I can always go back and try to = bring the C++ specific parts into the fold once a prototype is up and runni= ng.

As it seems there is a great deal of c/c++ to do either= way, I would really appreciate so thoughts towards my original question.

What practices in C++ are preferred by Haskell user= s, in the know, for the parts of the app that will not be pure Haskell?

Should I be looking to avoid OOP? =C2=A0Dependency Inje= ction? I wont reiterate all the facets of the first post, but it would help= me immensely to zero in on a few patterns and strategies that can minimize= d the damage I inflict in c++ land.

Thanks,
Casey

p.s.

With

&qu= ot;That used to be true, but the reason has nothing to do with the language= . =C2=A0The problem was that the libraries weren't there."

What do you mean? Which packages should I be look= ing at? =C2=A0I am on iOS like I said, its a stage 1 GHC compiler so I don&= #39;t have access to GHCI or template haskell.
=

>Casey Basichis <caseybasichis at=C2=A0gmail.com> wrote:
>
&g= t;> I'm not entirely sure what you mean.
>>
>> I'm intending on using Ogre for GUI - for which there is the= Hogre
>> bindings, but after emailing the DEV about it, I didn't g= et the
>> impression from his advice that I should be using= it for production
>> code. =C2=A0Here is what he suggested= :
>>
>> "It depends, really. Hogre is good fo= r running Ogre from within
>> Haskell, but it has its limit= ations. The number one thing people have
>> been struggling= with is handling input with hogre - there's Hois
>> (Haskell wrapper for OIS) but it's not perfect (it misses= input
>> events), and the other option is having to write = some C++ glue. Hogre
>> is a solid proof of concept and you= can do some demos with it, but if
>> you're e.g. writing a game it might be a bit of a struggl= e. In the end
>> it's about how much you value being ab= le to write code in Haskell (or
>> how allergic to C++ you = are)."
>>
>> I'm on iOS so I imagine those difficul= ties are compounded.
>>
&= gt;> I am using several other C++ libraries for which there are no exist= ing
>> bindings and no Haskell alternative packages that are even re= motely
>> close.
>>
>> Are you suggesti= ng it would be better to write all my own FFI bindings
>> f= or all the needed libraries?
>
>That's not what I'm suggesting. =C2=A0It was just too litt= le information to
>properly judge the difficulty of doing everything in Haskell.
>
>Binding to Ogre (or C++ in general) is indeed diff= icult. =C2=A0If Hogre
>doesn't work or is too limited, you= r best option might be to write a C
>wrapper around the Hogre functionality you need. =C2=A0Another opt= ion is to
>use SDL/OpenGL directly, which may be easier or har= der depending on your
>application.
>
&= gt;However, if you can build the bridge between your rendering library and<= /div>
>Haskell, then Haskell is certainly the better choice.
&g= t;
>
>> Everything I r= ead suggests that Haskells strengths are in
>> transformati= on and that interaction is not its strong suit.
>>
>> I am interested in= your thoughts and I am open to whatever, but you
>> are th= e first to suggest that the mix is a bad idea.
>
>That used to be true, but the reason has nothing to do with the
>language. =C2=A0The problem was that the libraries weren't the= re. =C2=A0Nowadays
>you can write all sorts of interactive app= lications in Haskell,
>including GUIs, TUIs, games, simulation= s and web applications. =C2=A0However,
>I've long been waiting for useful bindings to Ogre or Irrlicht= , but I'm
>afraid that it's not going to happen any ti= me soon.
>
>Ultimately it's your choice. =C2= =A0Let me summarize the possiblities:
>
> =C2=A0* C wrapper around Ogre. =C2=A0Easy integrat= ion, but need to write the
> =C2=A0 =C2=A0rendering code in C/= C++.
>
> =C2=A0* Full FFI bindings to Ogre. =C2= =A0Difficult integration, but you can write
> =C2=A0 =C2=A0your rendering code in Haskell.
>
=
> =C2=A0* Partial FFI bindings to Ogre. =C2=A0Integration may be so= mewhat easy, if
> =C2=A0 =C2=A0you do the initialization in Ha= skell and the actual rendering in
> =C2=A0 =C2=A0C/C++. =C2=A0However, this again requires to write t= he rendering in
> =C2=A0 =C2=A0C/C++.
>
> =C2=A0* Using SDL/OpenGL directly: =C2=A0Everything available for Has= kell. =C2=A0May
> =C2=A0 =C2=A0be difficult, because you need = to write OpenGL code.
>
>I hope, this helps.
>
>
>Greets,
>Ertugrul



--=C2=A0

Casey James Basi= chis
Composer - Cartoon Network
http://www= .caseyjamesbasichis.com
caseybasichis at gmail.com
310.387.7540

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe


--14dae93403ebb434de04d49347cd-- From tab at snarc.org Thu Jan 31 11:48:34 2013 From: tab at snarc.org (Vincent Hanquez) Date: Thu, 31 Jan 2013 10:48:34 +0000 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <510A2ABD.4060702@snarc.org> Message-ID: <510A4C02.1090803@snarc.org> On 01/31/2013 08:54 AM, Alexander Kjeldaas wrote: > On Thu, Jan 31, 2013 at 9:26 AM, Vincent Hanquez wrote: > >> On 01/31/2013 06:27 AM, Ertugrul S?ylemez wrote: >> >>> In any case there is no valid excuse for the lack of crypto. It's too >>> easy to attack Hackage, so we need some crypto regardless of what we >>> interpret it as. >>> >>> My proposal is: >>> >>> 1. Build the necessary machinery into Cabal to allow signing keys and >>> packages and verifying the signatures, ideally through GnuPG. >>> Cabal would benefit from that even without cabal-install and >>> Hackage. >>> >> Seems there's lots of suggestion of using gnupg, which is a perfectly >> valid answer if cabal was unix only, but i'm not sure it's a valid option >> considering windows. Sure you can install gnupg somehow, but sounds to me >> it's going the same problem as gtk2hs on windows. >> >> One better way, would be to tap in the 2, work in progress, gnupg haskell >> replacement: >> >> http://hackage.haskell.org/**package/openpgp >> http://hackage.haskell.org/**package/hOpenPGP >> >> AFAIK, both packages are not yet handling anything related to WoT, but >> just do the signing/verification (which is same status as my ad-hoc >> experiment) >> >> > In this case I think this is the wrong approach. There must be at least > one way to work within a trust model that is not fragile. Whether this is > fully supported on all platforms is actually not very important. > > I have pointed out why simply signing packages is fragile and how git is > better suited for this task. We are not going to reimplement all the good > infrastructure that already exists (gpg, git), so making that a requirement > is not a good idea IMO. > > Basic verification of signatures should work on Windows, I agree. But the > underlying WoT should be a little bit more sophisticated. This means it > has to be based on standard tools, or it will never happen. > I think you misunderstood me. Having a fully working pgp package, means you have full control of the pgp stack, you don't rely on hard-to-get out tools, and it can be integrated with cabal directly for a full WoT experience. Also git doesn't solve the hackage problem, there's not necessarily a one-to-one mapping between packages and their repositories. -- Vincent From es at ertes.de Thu Jan 31 11:51:06 2013 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 31 Jan 2013 11:51:06 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <510A4A23.4090909@snarc.org> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> <20130131094217.37bb87a2@tritium.streitmacht.eu> <1359624529.4356.15.camel@kirk> <20130131110632.30bf003f@tritium.streitmacht.eu> <510A4A23.4090909@snarc.org> Message-ID: <20130131115106.56c12b25@tritium.streitmacht.eu> Vincent Hanquez wrote: > > That was exactly my suggestion actually. It requires the ability to > > make and check signatures. The making can be done with external > > tools like GnuPG, but the checking has to be done by cabal-install. > > To detect changed keys there also needs to be a trust database, > > which can be a simple directory in ~/.cabal/ where files are named > > after the fingerprint of the key it contains. > > > > The most important part is a sensible user interface. The whole > > process should be invisible to the user, until there is a signature > > error. The first installation of a package will actually generate a > > handful of signature errors, because the keys are not known yet. > > > > This shouldn't be too hard to implement and requires only a small > > change to Hackage and cabal-install's upload command to begin. > > That's not a proper solution, and definitively in the warm fuzzy > feeling department. > > What if you install a package for the first time and this package has > just been re-uploaded maliciously with a different key and a payload ? > What if you're relying on hackage mirrors, what stop this mirror to > regenerate all signatures with a new key ? > > It also make maintainers change difficult, and doing genuine > non-maintainer upload. See the last point of my post. The last step is to implement proper web of trust functionality, so that some keys can be declared to be signing keys. Then a set of trusted keys can be shipped together with cabal-install. That step is optional, because at least now I can fetch developer keys by other means like a key server. According to my solution Cabal warns for new and changed keys and asks whether to trust them showing a fingerprint. Greets, Ertugrul -- Key-ID: E5DD8D11 "Ertugrul Soeylemez " FPrint: BD28 3E3F BE63 BADD 4157 9134 D56A 37FA E5DD 8D11 Keysrv: hkp://subkeys.pgp.net/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From wbigger at gmail.com Thu Jan 31 12:02:12 2013 From: wbigger at gmail.com (claudio) Date: Thu, 31 Jan 2013 12:02:12 +0100 Subject: [Haskell-cafe] Teaching haskell and fuzzy logic to high school students Message-ID: I'm an Italian IT teacher and I would like to introduce functional programming using haskell. As classroom activity, I would like to build-up a simple fuzzy inference engine. Does anyone know if someone has experience in teaching haskell to high school students or something has already been done with fuzzy logic and haskell? I found only this page: http://www.haskell.org/haskellwiki/AI/Logic/Fuzzy with some information and a link to a pubblication (with fee, I didn't download yet). Thanks Claudio -------------- next part -------------- An HTML attachment was scrubbed... URL: From twanvl at gmail.com Thu Jan 31 12:02:51 2013 From: twanvl at gmail.com (Twan van Laarhoven) Date: Thu, 31 Jan 2013 12:02:51 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <8738xh3gzp.fsf@nmd999X.imr.no> References: <1359574031-sup-1195@javelin>, <1359579588.5131.4.camel@kirk>, <1359585638-sup-7671@javelin>, , <1359586077-sup-6738@javelin>, , <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> Message-ID: <510A4F5B.9080001@gmail.com> On 31/01/13 09:16, Ketil Malde wrote: > *MY* proposal is that: > > 0. Hackage sends an email to the previous uploader whenever a new > version of a package is uploaded by somebody else. > > At least that way, I would be notified if it happened to my packages, > and I would be able to check up on the situation, and rectify it. > > This is not to say that cryptographic signing is the wrong thing to do, > but a very simple thing like this, which would probably take all of five > minutes to implement, would reduce risk by a substantial amount. That is an excellent idea, and it should be very simple to add. Of course it doesn't stop all attacks, but it does stop the most obvious one. And it might also prevent some honest mistakes or errors in communication where someone uploads a forked package without permission. Twan From gtener at gmail.com Thu Jan 31 12:08:57 2013 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Thu, 31 Jan 2013 12:08:57 +0100 Subject: [Haskell-cafe] Teaching haskell and fuzzy logic to high school students In-Reply-To: References: Message-ID: You can get the paper here for free: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.40.1464 On Thu, Jan 31, 2013 at 12:02 PM, claudio wrote: > I'm an Italian IT teacher and I would like to introduce functional > programming using haskell. > > As classroom activity, I would like to build-up a simple fuzzy inference > engine. > > Does anyone know if someone has experience in teaching haskell to high > school students or something has already been done with fuzzy logic and > haskell? > > I found only this page: > http://www.haskell.org/haskellwiki/AI/Logic/Fuzzy > with some information and a link to a pubblication (with fee, I didn't > download yet). > > Thanks > Claudio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.kjeldaas at gmail.com Thu Jan 31 12:32:52 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Thu, 31 Jan 2013 12:32:52 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <510A4C02.1090803@snarc.org> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <510A2ABD.4060702@snarc.org> <510A4C02.1090803@snarc.org> Message-ID: On Thu, Jan 31, 2013 at 11:48 AM, Vincent Hanquez wrote: > On 01/31/2013 08:54 AM, Alexander Kjeldaas wrote: > >> On Thu, Jan 31, 2013 at 9:26 AM, Vincent Hanquez wrote: >> >> On 01/31/2013 06:27 AM, Ertugrul S?ylemez wrote: >>> >>> In any case there is no valid excuse for the lack of crypto. It's too >>>> easy to attack Hackage, so we need some crypto regardless of what we >>>> interpret it as. >>>> >>>> My proposal is: >>>> >>>> 1. Build the necessary machinery into Cabal to allow signing keys >>>> and >>>> packages and verifying the signatures, ideally through GnuPG. >>>> Cabal would benefit from that even without cabal-install and >>>> Hackage. >>>> >>>> Seems there's lots of suggestion of using gnupg, which is a perfectly >>> valid answer if cabal was unix only, but i'm not sure it's a valid option >>> considering windows. Sure you can install gnupg somehow, but sounds to me >>> it's going the same problem as gtk2hs on windows. >>> >>> One better way, would be to tap in the 2, work in progress, gnupg haskell >>> replacement: >>> >>> http://hackage.haskell.org/****package/openpgp >>> >>> > >>> http://hackage.haskell.org/****package/hOpenPGP >>> >>> > >>> >>> >>> AFAIK, both packages are not yet handling anything related to WoT, but >>> just do the signing/verification (which is same status as my ad-hoc >>> experiment) >>> >>> >>> In this case I think this is the wrong approach. There must be at least >> one way to work within a trust model that is not fragile. Whether this is >> fully supported on all platforms is actually not very important. >> >> I have pointed out why simply signing packages is fragile and how git is >> better suited for this task. We are not going to reimplement all the good >> infrastructure that already exists (gpg, git), so making that a >> requirement >> is not a good idea IMO. >> >> Basic verification of signatures should work on Windows, I agree. But the >> underlying WoT should be a little bit more sophisticated. This means it >> has to be based on standard tools, or it will never happen. >> >> I think you misunderstood me. > > Having a fully working pgp package, means you have full control of the pgp > stack, you don't rely on hard-to-get out tools, and it can be integrated > with cabal directly for a full WoT experience. > > Also git doesn't solve the hackage problem, there's not necessarily a > one-to-one mapping between packages and their repositories. > > Regarding git, I don't see anyone even suggesting that hackage should support multiple 'signed-off-by's, signing diffs between packages, and signing releases. I don't see anyone supporting 3rd-parties signing packages at will. All of this is significant engineering effort that just won't happen. And even if it does, it still doesn't solve the problem, because all of the above is required to protect our base ghc, cabal-install tools anyways. If cabal-install is hacked, hackage is hacked. And even when all of this is done, a design where there is a set of trusted developers is flawed. The set of trusted developers will increase over time, and there will be the need to restrict which developers can release which package. How do you protect that information, which keys can sign which packages? That information must itself be signed off by someone. If not, ouch some obscure developer in the trusted set hijacked an important package because he was owned. That signing in itself *requires* either consensus or a trusted third party. Consensus is a superior method and IMO required. Actually, all modifications to important packages requires consensus by at least two developers to avoid the threat posed by "owned" developers. So although it is not a waste of time to "secure" hackage, it is always going to be slightly fragile as long as ghc is fragile for example, and it just isn't ever going to *really* solve the problem. Git has the ability to solve all of this. So a better use of resources IMO is to skip securing hackage by own means, but to standardize on using git as the infrastructure for securing hackage. Then the same infrastructure that should secure ghc should secure hackage. To explain this in concrete terms, to do this, all that is needed is *something like* the following: 1. Each package on hackage gets its own repository (say on github or similar). (I've actually put all of hackage in a single git repository - it works fine, so there are no relevant size problems) 2. Uploads to hackage either happen through commits to the git repository, or an old-style upload to hackage automatically creates a new anonymous branch in the git repository. 3. The git repository is authorative. Signing releases, code reviews etc. all happens through the git repositories. This gives us all the flexibility of a git-style trust model. 4. If a package already has a git repository, that repository can be used instead of the 'hackage' one. 5. Who owns which package names can be held in a separate meta-tree git repository, and can have consensus requirements on commits. 6. This special meta-tree can also contain suggested verification keys for commits to the other hackage git trees. It can even contain keys that protect Haskell namespaces in general, so that no hackage package can overwrite a protected Haskell namespace. 7. As backward compatibility, the meta-tree can sign simple hashes of already existing packages on hackage. I'll just note that none of the above requires any changes to Hackage at all. That is the modification story. On the verification side there are multiple options: 1. There could be some git magic script that downloads the signed git tag objects only (small data set). Then another script would generate a git-compatible SHA1 of the extracted tarball, given that the tarball was fetched from hackage. 2. Or cabal-install could fetch directly from git repositories and use standard git verification. 3. Or a trusted machine creates tarballs from the git repositories, signs them and uploads them to hackage. At the same time, a set of distrustful machines do the same thing by running cron-jobs that check the trusted machine. This is slightly fragile, but would "mostly work". Alexander > -- > Vincent > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ketil at malde.org Thu Jan 31 12:34:07 2013 From: ketil at malde.org (Ketil Malde) Date: Thu, 31 Jan 2013 12:34:07 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <510A2CDF.3070902@snarc.org> References: <1359574031-sup-1195@javelin>, <8738xh3gzp.fsf@nmd999X.imr.no>, <510A2CDF.3070902@snarc.org> Message-ID: <87wqut1t8w.fsf@nmd999X.imr.no> Vincent Hanquez writes: > On 01/31/2013 08:16 AM, Ketil Malde wrote: >> At least that way, I would be notified if it happened to my packages, >> and I would be able to check up on the situation, and rectify it. > you wouldn't in real cases, I wouldn't what? Be notified? Rectify it? > it just fix the most obvious and simple attack vector. > but consider: Ah, those _real_ cases. Fine, let's see what you got. > * someone intercepting your upload http stream, and replacing > dynamically your package. > * someone gaining malicious access to hackage and planting stuff inside > packages. > * a rogue hackage admin. > * a rogue hackage mirror admin. How often do these things happen, I wonder? I guess a bit more rarely than malware taking control of people's computers, which would simply allow people access to upload passwords _and_ signing keys. So much for that perfect security scheme, huh? Anyway: I don't want to sound negative here, so as a constructive proposal, please replace one of my packages on Hackage, making use of one of those techniques. No hurry, I'll wait. We have this discussion every now and then, and in spite of grand schemes of crypto and signing and whatnot, we _still_ have security holes you could drive a truck through. Why not at least do _something_ to fix that, before we return to the more _interesting_ pursuit of the Perfect Security Scheme? -k -- If I haven't seen further, it is by standing in the footprints of giants From alexander.kjeldaas at gmail.com Thu Jan 31 12:42:53 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Thu, 31 Jan 2013 12:42:53 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <510A4A23.4090909@snarc.org> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> <20130131094217.37bb87a2@tritium.streitmacht.eu> <1359624529.4356.15.camel@kirk> <20130131110632.30bf003f@tritium.streitmacht.eu> <510A4A23.4090909@snarc.org> Message-ID: On Thu, Jan 31, 2013 at 11:40 AM, Vincent Hanquez wrote: > On 01/31/2013 10:06 AM, Ertugrul S?ylemez wrote: > >> Joachim Breitner wrote: >> >> And that may even be more harmful, because an insecure system with a >>>> false sense of security is worse than an insecure system alone. >>>> >>>> Let's do it properly. >>>> >>> but don?t overengineer it either. Simply adding to hackage the >>> possibility to store a .asc file next to the tar.gz file that contains >>> the cryptographic signature would be a great start, and allow us to >>> develop a WoT model later on. >>> >>> (I try to resist from wondering whether this could go into hackage1 or >>> only hackage2, and in the latter case, whether that means that we >>> actually have the time to overengineer the system.) >>> >>> In fact, a lot would already be gained by a simple ?warn if foo-2.0 is >>> signed with a different key than the version of foo already installed? >>> on cabal-install and people having a closer look at uploads from >>> different people. Not much infrastructure needed there. >>> >> That was exactly my suggestion actually. It requires the ability to >> make and check signatures. The making can be done with external tools >> like GnuPG, but the checking has to be done by cabal-install. To detect >> changed keys there also needs to be a trust database, which can be a >> simple directory in ~/.cabal/ where files are named after the >> fingerprint of the key it contains. >> >> The most important part is a sensible user interface. The whole process >> should be invisible to the user, until there is a signature error. The >> first installation of a package will actually generate a handful of >> signature errors, because the keys are not known yet. >> >> This shouldn't be too hard to implement and requires only a small change >> to Hackage and cabal-install's upload command to begin. >> > > That's not a proper solution, and definitively in the warm fuzzy feeling > department. > > What if you install a package for the first time and this package has just > been re-uploaded maliciously with a different key and a payload ? > What if you're relying on hackage mirrors, what stop this mirror to > regenerate all signatures with a new key ? > > It also make maintainers change difficult, and doing genuine > non-maintainer upload. > > It is still useful to protect "most users" and detect malicious code "really quickly". Someone will always have the package installed and will notice, so the intruder will only be able to do very targeted attacks. Basically this creates at chain of trust for each package. What I think you want is a chain of trust between packages. Alexander > > -- > Vincent > > ______________________________**_________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/**mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ketil at malde.org Thu Jan 31 12:53:00 2013 From: ketil at malde.org (Ketil Malde) Date: Thu, 31 Jan 2013 12:53:00 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <20130131094217.37bb87a2@tritium.streitmacht.eu> References: <1359574031-sup-1195@javelin>, <1359579588.5131.4.camel@kirk>, <1359585638-sup-7671@javelin>, , <1359586077-sup-6738@javelin>, , <20130131072754.23345dad@tritium.streitmacht.eu>, <8738xh3gzp.fsf@nmd999X.imr.no>, <510A2CDF.3070902@snarc.org>, <20130131094217.37bb87a2@tritium.streitmacht.eu> Message-ID: <87vcad1sdf.fsf@nmd999X.imr.no> Ertugrul S?ylemez writes: > And that may even be more harmful, because an insecure system with a > false sense of security is worse than an insecure system alone. Yes. As is clear to all, the current low level of security means that nobody are _actually_ downloading stuff of Hackage, thank God. Hackage just exists for...well, I forget, but certainly not to distribute software. Right. Sarcasm aside, to some extent, this is true. I used to have a cron job 'cabal install'ing my packages off Hackage to ensure that they would compile with the current offering of their dependencies. But I decided it was way too risky, and don't do it anymore. > Let's do it properly. You mean like how it was decisively dealt with when this was discussed in 2008? https://github.com/haskell/cabal/issues/207 Or maybe more the way it was firmly handled when it was brought up again in 2010? http://www.haskell.org/pipermail/haskell-cafe/2010-December/087050.html This looks increasingly like that time of year when the problem is pointed out, the crypto geeks get together to construct the Optimal Solution, and then everybody lose interest and move on to greener pastures for a while. Well, I don't think the perfect solution exists, and even if it could be identified, it might not be implemented, and even if were implemented, it might not be used. We've just been incredibly lucky that nothing really bad has happened so far. Let's hope it lasts. -k -- If I haven't seen further, it is by standing in the footprints of giants From alexander.kjeldaas at gmail.com Thu Jan 31 13:28:05 2013 From: alexander.kjeldaas at gmail.com (Alexander Kjeldaas) Date: Thu, 31 Jan 2013 13:28:05 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <87vcad1sdf.fsf@nmd999X.imr.no> References: <1359574031-sup-1195@javelin> <1359579588.5131.4.camel@kirk> <1359585638-sup-7671@javelin> <1359586077-sup-6738@javelin> <20130131072754.23345dad@tritium.streitmacht.eu> <8738xh3gzp.fsf@nmd999X.imr.no> <510A2CDF.3070902@snarc.org> <20130131094217.37bb87a2@tritium.streitmacht.eu> <87vcad1sdf.fsf@nmd999X.imr.no> Message-ID: On Thu, Jan 31, 2013 at 12:53 PM, Ketil Malde wrote: > > Ertugrul S?ylemez writes: > > > And that may even be more harmful, because an insecure system with a > > false sense of security is worse than an insecure system alone. > > Yes. As is clear to all, the current low level of security means that > nobody are _actually_ downloading stuff of Hackage, thank God. Hackage > just exists for...well, I forget, but certainly not to distribute > software. Right. > > Sarcasm aside, to some extent, this is true. I used to have a cron job > 'cabal install'ing my packages off Hackage to ensure that they would > compile with the current offering of their dependencies. But I decided > it was way too risky, and don't do it anymore. > > > Let's do it properly. > > You mean like how it was decisively dealt with when this was discussed > in 2008? > > https://github.com/haskell/cabal/issues/207 > > Or maybe more the way it was firmly handled when it was brought up again > in 2010? > > http://www.haskell.org/pipermail/haskell-cafe/2010-December/087050.html > > This looks increasingly like that time of year when the problem is > pointed out, the crypto geeks get together to construct the Optimal > Solution, and then everybody lose interest and move on to greener > pastures for a while. Well, I don't think the perfect solution exists, > and even if > it could be identified, it might not be implemented, and even if > were implemented, it might not be used. > > Hehe.. hard to argue against history! :-) Alexander > We've just been incredibly lucky that nothing really bad has happened so > far. Let's hope it lasts. > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Thu Jan 31 13:32:36 2013 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 31 Jan 2013 18:02:36 +0530 Subject: [Haskell-cafe] FFI - Approaches to C/C++ In-Reply-To: References: Message-ID: On Thu, Jan 31, 2013 at 11:11 AM, Casey Basichis wrote: > Hi, > > I'm working on a project in Haskell and C++ where the former is the brains > and the latter is for UI, interaction etc. > > I've read this > http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/ and > a number of other haskell posts suggesting the OOP is not the way to go. > > Without trying to emulate functional programming through templates or > boost::phoenix, what approaches do you all favor when designing parts of an > application in C++? Patterns to embrace or avoid? > > Should I just use functions and handle things with name spaces? I was > thinking about handling the callbacks with boosts signals and slots 2 > > I know this is not entirely haskell centric, but it is a question for > haskell users. > > Thanks, > Casey > And then I'm on iOS so I imagine those difficulties are compounded. > > If you can tolerate the view that Haskell is more of an ideology than a technology, and are willing to explore areas that are technologically disparate but conceptually similar to Haskell maybe you should look at ocaml: http://web.yl.is.s.u-tokyo.ac.jp/~tosh/ocaml-on-iphone/index.html http://psellos.com/ocaml/compile-to-iphone.html Rusi -- http://www.the-magus.in http://blog.languager.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Thu Jan 31 13:50:04 2013 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 31 Jan 2013 14:50:04 +0200 Subject: [Haskell-cafe] "branching" conduits In-Reply-To: <510A3DE0.8010708@banquise.net> References: <510A3DE0.8010708@banquise.net> Message-ID: On Thu, Jan 31, 2013 at 11:48 AM, Simon Marechal wrote: > Hello, > > I have found the Conduit abstraction to be very well suited to a > set of > problems I am facing. I am however wondering how to implement > "branching" conduits, and even conduit pools. > > I am currently in the process of rewriting parts (the simple > parts) of > the Logstash tool. There is a sample program that I use here: > > > https://github.com/bartavelle/hslogstash/blob/deprecateUtils/examples/RedisToElasticsearch.hs > > As it can be seen, it uses a "Redis" source, a conduit that > decodes the > JSON ByteString into a LogstashMessage, a conduit that stores it into > Elasticsearch and outputs the result of that action as an Either, and > finally a sink that prints the errors. > > My problem is that I would like more complex behaviour. For > example, I > would like to route messages to another server instead of putting them > into Elasticsearch when the LogstashMessage has some tag set. But this > is just an example, and it is probable I will want much more complex > behavior soon. > > I am not sure how to proceed from here, but have the following > ideas: > > * investigate how the Conduits are made internally to see if I can > create a operator similar to $$, but that would have a signature like: > Source m (Either a b) -> Sink a m r -> Sink b m r > and would do the branching in a binary fashion. I am not sure this is > even possible. > > * create a "mvars" connectors constructor, which might have a signature > like this: > > Int -- ^ branch count > (LogstashMessage -> Int) -- ^ branching function > (Sink LogstashMessage m (), [Source m LogstashMessage]) > -- ^ a suitable sink, several sources for the other conduits > > it would internally create a MVar (Maybe LogstashMessage) for each > branch, and put putMVar accordingly to the branching function. When the > Conduit is destroyed, it will putMVar Nothing in all MVars. > the sources would takeMVar, check if it is Nothing, or just proceed as > expected. > > The MVar should guarantee the constant space property, but there is the > risk of inter branch blocking when one of the branches is significantly > slower than the others. It doesn't really matter to me anyway. And all > the branch Sinks would have to have some synchronization mechanism so > that the main thread waits for them (as they are going to be launched by > a forkIO). > > > > This is the simplest scheme I have thought of, and it is probably not > a very good one. I am very interested in suggestions here. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Hi Simon, For your first approach, I think what you're looking to do is combine two Sinks together, something like: combine :: Monad m => Sink i1 m r1 -> Sink i2 m r2 -> Sink (Either i1 i2) m (r1, r2) Then you'd be able to use the standard $$ and =$ operators on it. I've put up an example implementation here[1]. The majority of the code is simple pattern matching on the different possible combination, but some things to point out: * To simplify, we start off with a call to injectLeftovers. This means that we can entirely ignore the Leftover constructor in the main function. * Since a Sink will never yield values, we can also ignore the HaveOutput constructor. * As soon as either of the Sinks terminates, we terminate the other one as well and return the results. You can also consider going the mutable container route if you like. Instead of creating a lot of stuff from scratch with MVars, you could use stm-conduit[2]. In fact, that package already contains some kind of merging behavior for sources, it might make sense to ask the author about including unmerging behavior for Sinks. Michael [1] https://gist.github.com/4682609 [2] http://hackage.haskell.org/package/stm-conduit -------------- next part -------------- An HTML attachment was scrubbed... URL: From jan.stolarek at p.lodz.pl Thu Jan 31 14:17:07 2013 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Thu, 31 Jan 2013 14:17:07 +0100 Subject: [Haskell-cafe] Monadic parser vs. combinator parser In-Reply-To: <20130131110732.3eea8772@tritium.streitmacht.eu> References: <201301301321.18592.jan.stolarek@p.lodz.pl> <201301311047.12785.jan.stolarek@p.lodz.pl> <20130131110732.3eea8772@tritium.streitmacht.eu> Message-ID: <201301311417.07409.jan.stolarek@p.lodz.pl> Dnia czwartek, 31 stycznia 2013, Ertugrul S?ylemez napisa?: > Remember that 'Either e' is also a monad. =) I remember - this makes the change from Maybe to Either very easy :) Still I found that adding error message to every combinator and function ads a lot of boilerplate. Also, I experince problem with granularity of the messages, e.g. a message like "digit expected" is too low-level not helpful without telling user that the problem was in the incorect date format. Janek From simon at banquise.net Thu Jan 31 14:24:10 2013 From: simon at banquise.net (Simon Marechal) Date: Thu, 31 Jan 2013 14:24:10 +0100 Subject: [Haskell-cafe] "branching" conduits In-Reply-To: References: <510A3DE0.8010708@banquise.net> Message-ID: <510A707A.9030804@banquise.net> On 31/01/2013 13:50, Michael Snoyman wrote: > * To simplify, we start off with a call to injectLeftovers. This means > that we can entirely ignore the Leftover constructor in the main function. > * Since a Sink will never yield values, we can also ignore the > HaveOutput constructor. > * As soon as either of the Sinks terminates, we terminate the other one > as well and return the results. Your gist is extremely informative to me. I figured it would be something along these lines, but was very scared to try it myself. I have however realized that my first use case doesn't cover my need, as I will want to feed an arbitrary set of sinks with any value ... I started coding right after I sent that mail and wrote this: https://github.com/bartavelle/hslogstash/blob/master/Data/Conduit/Branching.hs It is not very elegant as the "branching" functions outputs [Int]. I haven't tested it yet, but it should branch with any number of sinks. Another point that might (or might not) be of interest is the distribution of distinct branches on separate threads. > You can also consider going the mutable container route if you like. > Instead of creating a lot of stuff from scratch with MVars, you could > use stm-conduit[2]. In fact, that package already contains some kind of > merging behavior for sources, it might make sense to ask the author > about including unmerging behavior for Sinks. I did not think of bounded channels. They are a indeed a better match than MVars ! I can see it uses resourceForkIO, which I believe is OK for sources that will be used in your 'main' thread. But for multiple Sinks, you need a way to wait for the all Sinks to terminate. I used stuff from Control.Concurrent.ParallelIO, but I am not sure it is ideal. From dmitry.kulagin at gmail.com Thu Jan 31 15:06:15 2013 From: dmitry.kulagin at gmail.com (Dmitry Kulagin) Date: Thu, 31 Jan 2013 18:06:15 +0400 Subject: [Haskell-cafe] why GHC cannot infer type in this case? Message-ID: Hi Cafe, I try to implement little typed DSL with functions, but there is a problem: compiler is unable to infer type for my "functions". It seems that context is clear, but still GHC complains "Could not deduce...". It is sad because without type inference the DSL will be very difficult to use. Could someone explain me why this happens and how it can be avoided? I use GHC 7.4.2 I tried to distill the code to show the problem (and full error message below it). Thank you! Dmitry {-# LANGUAGE GADTs, KindSignatures, DataKinds #-} module TestExp where -- Sequence of DSL's types to represent type of tuple data TSeq where TSeqEmpty :: TSeq TSeqCons :: TypeExp -> TSeq -> TSeq -- All types allowed in DSL data TypeExp where -- Primitive type TInt16 :: TypeExp -- Function type is built from types of arguments (TSeq) and type of result TFun :: TSeq -> TypeExp -> TypeExp -- Sequence of expressions to represent tuple data Seq (t :: TSeq) where SeqEmpty :: Seq TSeqEmpty SeqCons :: Exp w -> Seq v -> Seq (TSeqCons w v) data Exp (r :: TypeExp) where Decl :: (Seq args -> Exp r) -> Exp (TFun args r) Call :: Exp (TFun args r) -> Seq args -> Exp r Int16 :: Int -> Exp TInt16 Add :: Exp TInt16 -> Exp TInt16 -> Exp TInt16 -- Assumed semantics: fun x = x + 2 -- The following line must be uncommented to compile without errors -- fun :: Exp (TFun (TSeqCons TInt16 TSeqEmpty) TInt16) fun = Decl $ \(SeqCons x SeqEmpty) -> Add (Int16 2) x -- eval (Int16 x) = x -- eval (Call (Decl f) seq) = eval (f seq) -- eval (Add x y) = eval x + eval y -- test = eval $ Call fun (SeqCons (Int16 3) SeqEmpty) ----------------- There is full error message: ---------------------------- TestExp.hs:30:53: Could not deduce (w ~ 'TInt16) from the context (args ~ TSeqCons w v) bound by a pattern with constructor SeqCons :: forall (w :: TypeExp) (v :: TSeq). Exp w -> Seq v -> Seq (TSeqCons w v), in a lambda abstraction at TestExp.hs:30:16-33 or from (v ~ 'TSeqEmpty) bound by a pattern with constructor SeqEmpty :: Seq 'TSeqEmpty, in a lambda abstraction at TestExp.hs:30:26-33 `w' is a rigid type variable bound by a pattern with constructor SeqCons :: forall (w :: TypeExp) (v :: TSeq). Exp w -> Seq v -> Seq (TSeqCons w v), in a lambda abstraction at TestExp.hs:30:16 Expected type: Exp 'TInt16 Actual type: Exp w In the second argument of `Add', namely `x' In the expression: Add (Int16 2) x -------------- next part -------------- An HTML attachment was scrubbed... URL: From althainz at gmail.com Thu Jan 31 15:09:03 2013 From: althainz at gmail.com (Peter Althainz) Date: Thu, 31 Jan 2013 15:09:03 +0100 Subject: [Haskell-cafe] Announcement - Haskell User Group Frankfurt Message-ID: <510A7AFF.9050207@googlemail.com> Dear Haskellers, for all who are located near Frankfurt, there is a new Meetup kicked off: http://www.meetup.com/Frankfurt-Haskell-User-Group regards Peter Althainz From simon at banquise.net Thu Jan 31 16:12:06 2013 From: simon at banquise.net (Simon Marechal) Date: Thu, 31 Jan 2013 16:12:06 +0100 Subject: [Haskell-cafe] Yet another Conduit question Message-ID: <510A89C6.9080900@banquise.net> I am working with bulk sources and sinks, that is with a type like: Source m [a] Sink [a] m () The problem is that I would like to work on individual values in my conduit. I can have this: concat :: (Monad m) => Conduit [a] m a concat = awaitForever (mapM_ yield) But how can I do it the other way around ? I suppose it involves pattern matching on the different states my conduit might me in. But is that even possible to do it in a "non blocking" way, that is catenate data while there is something to read (up to a certain threshold), and send it as soon as there is nothing left to read ? Or doesn't that make any sense in the context of Conduits (in the sense that this conduit will be recheck for input before the upstream conduits will have a chance to operate) ? Another approach would be to have a map equivalent: conduitMap :: Conduit i m o -> Conduit [i] m [o] But I am not sure how to do this either ... From andres at well-typed.com Thu Jan 31 16:27:01 2013 From: andres at well-typed.com (=?ISO-8859-1?Q?Andres_L=F6h?=) Date: Thu, 31 Jan 2013 16:27:01 +0100 Subject: [Haskell-cafe] why GHC cannot infer type in this case? In-Reply-To: References: Message-ID: Hi Dmitry. > I try to implement little typed DSL with functions, but there is a problem: > compiler is unable to infer type for my "functions". It seems that context > is clear, but still GHC complains "Could not deduce...". > It is sad because without type inference the DSL will be very difficult to > use. > > Could someone explain me why this happens and how it can be avoided? Pattern matches on GADT generally require type information. Type inference in such a case is tricky. GADTs are so powerful that in many cases, there's no unique best type to infer. As a contrived example, consider this datatype and function: > data X :: * -> * where > C :: Int -> X Int > D :: X a > > f (C n) = [n] > f D = [] What should GHC infer for f? Both > f :: X a -> [Int] > f :: X a -> [a] are reasonable choices, but without further information about the context, it's impossible to say which one of the two is better. It is theoretically possible to be more clever than GHC is and infer the types of GADT pattern matches in some cases. However, it is (A) a lot of work to implement and maintain that cleverness, and (B) it is then very difficult to describe when exactly a type signature is required and when it isn't. So GHC adopts the simpler approach and requires type information for all GADT pattern matches, which is a simple and predictable rule. How to prevent such errors in general is difficult to say. In your particular case, there might be an option, though. If you additionally use TypeFamilies and FlexibleInstances, you can define: > class MkDecl d where > type MkDeclSeq d :: TSeq > type MkDeclRes d :: TypeExp > decl' :: d -> Seq (MkDeclSeq d) -> Exp (MkDeclRes d) > > instance MkDecl (Exp r) where > type MkDeclSeq (Exp r) = TSeqEmpty > type MkDeclRes (Exp r) = r > decl' e = \ SeqEmpty -> e > > instance MkDecl d => MkDecl (Exp w -> d) where > type MkDeclSeq (Exp w -> d) = TSeqCons w (MkDeclSeq d) > type MkDeclRes (Exp w -> d) = MkDeclRes d > decl' f = \ (SeqCons x xs) -> decl' (f x) xs > > decl :: MkDecl d => d -> Exp (TFun (MkDeclSeq d) (MkDeclRes d)) > decl d = Decl (decl' d) > > fun = decl $ \ x -> Add (Int16 2) x The idea here is to avoid pattern matching on the GADT, and instead use an ordinary Haskell function as an argument to the "decl" smart constructor. We use the type class and two type families to pack that function (with as many arguments as it has) into the type-level list and wrap it all up in the original "Decl". This works because on the outside, no GADT pattern matches are involved, and within the type class instances, the necessary type information is present. This is certainly harder to understand than your original version. On the other hand, it's actually easier to use. (It's entirely possible that my code can be simplified further. I haven't thought about this for very long ...) Cheers, Andres -- Andres L?h, Haskell Consultant Well-Typed LLP, http://www.well-typed.com From alexander.vershilov at gmail.com Thu Jan 31 17:31:20 2013 From: alexander.vershilov at gmail.com (Alexander V Vershilov) Date: Thu, 31 Jan 2013 20:31:20 +0400 Subject: [Haskell-cafe] "branching" conduits In-Reply-To: <510A707A.9030804@banquise.net> References: <510A3DE0.8010708@banquise.net> <510A707A.9030804@banquise.net> Message-ID: Hello, Simon. On 31 January 2013 17:24, Simon Marechal wrote: > On 31/01/2013 13:50, Michael Snoyman wrote: >> * To simplify, we start off with a call to injectLeftovers. This means >> that we can entirely ignore the Leftover constructor in the main function. >> * Since a Sink will never yield values, we can also ignore the >> HaveOutput constructor. >> * As soon as either of the Sinks terminates, we terminate the other one >> as well and return the results. > > Your gist is extremely informative to me. I figured it would be > something along these lines, but was very scared to try it myself. I > have however realized that my first use case doesn't cover my need, as I > will want to feed an arbitrary set of sinks with any value ... > > I started coding right after I sent that mail and wrote this: > https://github.com/bartavelle/hslogstash/blob/master/Data/Conduit/Branching.hs > > It is not very elegant as the "branching" functions outputs [Int]. > > I haven't tested it yet, but it should branch with any number of sinks. > Another point that might (or might not) be of interest is the > distribution of distinct branches on separate threads. > >> You can also consider going the mutable container route if you like. >> Instead of creating a lot of stuff from scratch with MVars, you could >> use stm-conduit[2]. In fact, that package already contains some kind of >> merging behavior for sources, it might make sense to ask the author >> about including unmerging behavior for Sinks. > > I did not think of bounded channels. They are a indeed a better match > than MVars ! > > I can see it uses resourceForkIO, which I believe is OK for sources that > will be used in your 'main' thread. But for multiple Sinks, you need a > way to wait for the all Sinks to terminate. I used stuff from > Control.Concurrent.ParallelIO, but I am not sure it is ideal. > Sorry I've sent my first email of the list, and have no copy to resend it. If you will use stm-conduit you can meet next troubles: 1). early close: if you'll use modern conduit API (yield, await), then try to use $$ on sinkT?Chan very accurate as it will close Channel and so receiver will be also closed. 2). late close: if you'll use resourceForkIO you channel may leave to long, hovewer in much cases you'll be save with forkIO, unless you share resources that was allocated with resourcet. 3). pipeline notifying: if you'll map you branches to different threads you'll need a way to notify that branch is closed (closing channels will be good, but you'll need an additional steps to check if they were closed and either close all pipeline or just forgot this channel). On the other hand you can use one pipeline (and thread) for every branch, then you need approach that was shown in Michael's gist. Run each downstream pipe, and save a result, possibly modifying a list. I'll paste concept that I mailed to you here hovewer in may be not accurate: branch :: [a -> m ()] -- it's better to place sink here branch fs = do chs <- mapM (\f -> (,) f <$> newTBMChanIO) fs bracket (mapM (\(f,ch) -> forkIO $ sourceTBMChan ch $$ f) chs) (mapM_ killThread) (\_ -> do x <- await mapM_ (flip writeTBMChan x . snd) chs) as an additional step you can call isTBMChanClosed on channel to check if branch is still alive and filter channel if so. (Previous version contained a filter function that allowes to send value to branches that needs it, hovewer it's less composable) also you may like iochan-conduit package [1], it can give a better results in some cases hovewer, stm-channels is much more general. [1] https://github.com/qnikst/iochan-conduit -- Alexander Vershilov From dmitry.kulagin at gmail.com Thu Jan 31 17:52:58 2013 From: dmitry.kulagin at gmail.com (Dmitry Kulagin) Date: Thu, 31 Jan 2013 20:52:58 +0400 Subject: [Haskell-cafe] why GHC cannot infer type in this case? In-Reply-To: References: Message-ID: Andres, thank you! Your response is really helpful. I will try to adopt your suggestion. Thank again! Dmitry On Thu, Jan 31, 2013 at 7:27 PM, Andres L?h wrote: > Hi Dmitry. > > > I try to implement little typed DSL with functions, but there is a > problem: > > compiler is unable to infer type for my "functions". It seems that > context > > is clear, but still GHC complains "Could not deduce...". > > It is sad because without type inference the DSL will be very difficult > to > > use. > > > > Could someone explain me why this happens and how it can be avoided? > > Pattern matches on GADT generally require type information. Type > inference in such a case is tricky. GADTs are so powerful that in many > cases, there's no unique best type to infer. > > As a contrived example, consider this datatype and function: > > > data X :: * -> * where > > C :: Int -> X Int > > D :: X a > > > > f (C n) = [n] > > f D = [] > > What should GHC infer for f? Both > > > f :: X a -> [Int] > > f :: X a -> [a] > > are reasonable choices, but without further information about the > context, it's impossible to say which one of the two is better. > > It is theoretically possible to be more clever than GHC is and infer > the types of GADT pattern matches in some cases. However, it is (A) a > lot of work to implement and maintain that cleverness, and (B) it is > then very difficult to describe when exactly a type signature is > required and when it isn't. So GHC adopts the simpler approach and > requires type information for all GADT pattern matches, which is a > simple and predictable rule. > > How to prevent such errors in general is difficult to say. In your > particular case, there might be an option, though. If you additionally > use TypeFamilies and FlexibleInstances, you can define: > > > class MkDecl d where > > type MkDeclSeq d :: TSeq > > type MkDeclRes d :: TypeExp > > decl' :: d -> Seq (MkDeclSeq d) -> Exp (MkDeclRes d) > > > > instance MkDecl (Exp r) where > > type MkDeclSeq (Exp r) = TSeqEmpty > > type MkDeclRes (Exp r) = r > > decl' e = \ SeqEmpty -> e > > > > instance MkDecl d => MkDecl (Exp w -> d) where > > type MkDeclSeq (Exp w -> d) = TSeqCons w (MkDeclSeq d) > > type MkDeclRes (Exp w -> d) = MkDeclRes d > > decl' f = \ (SeqCons x xs) -> decl' (f x) xs > > > > decl :: MkDecl d => d -> Exp (TFun (MkDeclSeq d) (MkDeclRes d)) > > decl d = Decl (decl' d) > > > > fun = decl $ \ x -> Add (Int16 2) x > > The idea here is to avoid pattern matching on the GADT, and instead > use an ordinary Haskell function as an argument to the "decl" smart > constructor. We use the type class and two type families to pack that > function (with as many arguments as it has) into the type-level list > and wrap it all up in the original "Decl". This works because on the > outside, no GADT pattern matches are involved, and within the type > class instances, the necessary type information is present. > > This is certainly harder to understand than your original version. On > the other hand, it's actually easier to use. > > (It's entirely possible that my code can be simplified further. I > haven't thought about this for very long ...) > > Cheers, > Andres > > -- > Andres L?h, Haskell Consultant > Well-Typed LLP, http://www.well-typed.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From golas at zib.de Thu Jan 31 18:17:01 2013 From: golas at zib.de (Ulrike Golas) Date: Thu, 31 Jan 2013 18:17:01 +0100 Subject: [Haskell-cafe] Call for Participation - ACCAT 2013 References: Message-ID: <30CC0BA6-9739-45FD-A667-06E0CF77CE3C@zib.de> [We apologize if you receive multiple copies of this message.] CALL FOR PARTICIPATION ========== 8th International Workshop on Applied and Computational Category Theory ACCAT 2013 http://accat2013.zib.de/ Satellite Event of ETAPS 2013, Rome, March 17 2013 ========== Scope ===== Since the 1960s, the use of category theory in computer science has been a fruitful one, including applications to different areas such as automata theory, algebraic specification, and programming languages, among others. In recent years, techniques and methods from CT have been adopted as a standard research tool, and considered as such in different venues around the world. The ACCAT workshop on "Applied and Computational Category Theory" has been one of these venues. Since its inception in 2006, ACCAT provided a forum where invited contributors presented their own research on different facets of category theory applied to computer science. Following the tradition, the program of this year edition will include eight invited talks by top researchers in the area: Samson Abramsky Robin B. Cockett Barbara Koenig Ugo Montanari Till Mossakowski Dusko Pavlovic Andrzej Tarlecki Glynn Winskel Despite ACCAT's success, we believe that the current formula of the workshop should be deeply revised. Indeed, we believe that a fully fledged conference is missing where all kinds of applications of category theory to computer science can be presented (like the former CTCS conference, which somehow ended in 2006). Therefore, after the presentations, the workshop will end up with a general discussion among the invited speakers and the attendees. We hope that the outcome of the discussion could be a decision whether to push for such high-level workshop/conference on the application of category theory to computer science, or at least to verify the viability of a further meeting focusing on this issue. For more information, please contact Fabio Gadducci (gadducci at di.unipi.it) or Ulrike Golas (golas at zib.de). -- Dr. Ulrike Golas Konrad-Zuse-Zentrum f?r Informationstechnik Berlin Takustr. 7, 14195 Berlin, Germany Tel. +49 30 84185 - 318 golas at zib.de -- www.zib.de/golas -------------- next part -------------- An HTML attachment was scrubbed... URL: From spam at scientician.net Thu Jan 31 18:40:10 2013 From: spam at scientician.net (Bardur Arantsson) Date: Thu, 31 Jan 2013 18:40:10 +0100 Subject: [Haskell-cafe] Ticking time bomb In-Reply-To: <1359574031-sup-1195@javelin> References: <1359574031-sup-1195@javelin> Message-ID: On 01/30/2013 08:27 PM, Edward Z. Yang wrote: > https://status.heroku.com/incidents/489 > > Unsigned Hackage packages are a ticking time bomb. > Somewhere else that shall not be mentioned, someone posted this link which points to an interesting solution to this problem: http://www.futurealoof.com/posts/nodemodules-in-git.html It requies a little basic knowledge of the Node Package Manager to understand. Here's a little summary that should it easier to understand for people who are not familiar with NodeJS: The Node Package Manager (npm) is the Node JS equivalent of cabal-install(*). When you install a module (think Haskell package off Hackage) using "npm", it installs into a directory called "node_modules" in the project's directory instead of installing into a global name space. When a NodeJS program imports a required module, it is first looked up in the "node_modules" directory _before_ looking in the global package database. Since modules *are* their source, you can check all of this into the revision control system of your choice. It seems to me that "cabal install" could do something very similar to solve many of the "cabal hell" and potential security issues when users blindly do "cabal install". (*) Yeah, yeah, not a package manager. In practice it's being used as one, so... From allbery.b at gmail.com Thu Jan 31 18:42:35 2013 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 31 Jan 2013 12:42:35 -0500 Subject: [Haskell-cafe] linking errors while compile hugs98 in macos In-Reply-To: References: Message-ID: On Thu, Jan 31, 2013 at 1:31 AM, Junior White wrote: > Hi Cafe, > I downloaded the latest hugs98 source package, unzip and build, I get > the following link errors. It seems many symbols are not defined, am I > missing same depending libraries? > I don't think anyone is maintaining hugs any more. > Undefined symbols for architecture x86_64: > "_environ", referenced from: > ___hscore_environ in ccuTP291.o > (maybe you meant: ___hscore_environ) > "environ" is a legacy pre-standards interface to the process environment and has been deprecated for a long time; it looks like Mountain Lion no longer exports it at all. More proof that hugs is moribund, if it's still using those ancient interfaces. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From hutch-lists at recursive.ca Thu Jan 31 22:19:41 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Thu, 31 Jan 2013 16:19:41 -0500 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache In-Reply-To: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> References: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Message-ID: Thanks everyone, I very much appreciate your help, and I think it did help. I've spent the last few days implementing a substantial chunk of my system using each of two different techniques. I've ended up going with and ADT containing functions closed over the 'thing'. This seems to be the consensus advice. For the record there was a perfectly viable alternative approach based on existential types (http://www.haskell.org/haskellwiki/Heterogenous_collections#Existential_types, thank Taylor, I'd read that and it didn't register? sigh). From what I could tell from trying them there's not a lot to choose between the two techniques, some small advantages for each. The existential types technique (despite criticism as an anti-patternhttps://lukepalmer.wordpress.com/2010/01/24/haskell-antipattern-existential-typeclass/, thanks Petr) is surprisingly to my taste? what can I say? I ended up going with the ADT because I can shove some additional stuff in it, and since there's still a large exploratory aspect to the project this might matter. Thanks again, Bob From hutch-lists at recursive.ca Thu Jan 31 22:22:14 2013 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Thu, 31 Jan 2013 16:22:14 -0500 Subject: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache In-Reply-To: References: <1734C212-50C4-457F-AAAE-7FE29B686BC6@recursive.ca> Message-ID: for your convenience, the correct link: https://lukepalmer.wordpress.com/2010/01/24/haskell-antipattern-existential-typeclass/ From wren at freegeek.org Thu Jan 31 23:38:40 2013 From: wren at freegeek.org (wren ng thornton) Date: Thu, 31 Jan 2013 17:38:40 -0500 Subject: [Haskell-cafe] Monadic parser vs. combinator parser In-Reply-To: <201301301321.18592.jan.stolarek@p.lodz.pl> References: <201301301321.18592.jan.stolarek@p.lodz.pl> Message-ID: <510AF270.6030003@freegeek.org> On 1/30/13 7:21 AM, Jan Stolarek wrote: > I will be writing a parser in Haskell and I wonder how to approach the problem. My first thought > was to use monadic parser, e.g. like the one described by Hutton and Meijer in "Monadic Parsing > in Haskell" functional pearl. But then I stumbled upon this: > > https://github.com/alephnullplex/cradle/tree/master/code/src/Lbach/Parser > > Monadic parser seems extremely verbose and not very straightforward compared to this one. Psst, result :: a -> Parser a (+>) :: Parser a -> (a -> Parser b) -> Parser b cf. return :: Monad parser => a -> parser a (>>=) :: Monad parser => parser a -> (a -> parser b) -> parser b You just lose the nice do-notation is all. -- Live well, ~wren From hjgtuyl at chello.nl Thu Jan 31 23:52:42 2013 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu, 31 Jan 2013 23:52:42 +0100 Subject: [Haskell-cafe] Teaching haskell and fuzzy logic to high school students In-Reply-To: References: Message-ID: On Thu, 31 Jan 2013 12:02:12 +0100, claudio wrote: > I found only this page: > http://www.haskell.org/haskellwiki/AI/Logic/Fuzzy > with some information and a link to a pubblication (with fee, I didn't > download yet). I have updated this page, the link now points to a page with free download Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID:
> cabal update
> cabal install cabal-install
> cabal install cabal-dev

The last command fails with:

Resolving dependencies...
In order, the following would be installed:
tar-0.3.2.0 (new package)
transformers-0.2.2.0 (new version)
mtl-2.0.1.0 (new version)
parsec-3.1.3 (reinstall) changes: mtl-2.1.2 -> 2.0.1.0
network-2.3.2.0 (new version)
HTTP-4000.2.8 (new version)
cabal-dev-0.9.1 (new package)
cabal: The following packages are likely to be broken by the reinstalls: network-2.3.1.0
haskell-platform-2012.4.0.0
cgi-3001.1.7.4
HTTP-4000.2.5
Use --force-reinstalls if you want to install anyway.


I *think* the problem is that cabal-dev has these dependencies:

=A0 =A0 =A0 mtl >=3D 1.1 && < 2.1,
=A0 =A0 =A0 transformers >=3D 0.2 && < 0.3,

where the latest version of mtl and transformers are 2.1.2 and 0.3 respecti= vely. At least, if I download the latest cabal-dev package and relax those = upper bounds I can get it to install.

The irony is, of course, that I'm trying to install cabal-dev to get me= out of a totally unrelated dependencies hole!

What should I do now?

Cheers,

--
David Turner
Senior Consultant
Tracsis PLC

Tracsis PLC is a company registered in
England and Wales with number 5019106.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@= haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



-- JP Moresmau
http://jpmores= mau.blogspot.com/ --14dae9340ed3f8497804d584eba9-- From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID:
> cabal update
> cabal install cabal-install
> cabal install cabal-dev

The last command fails with:

Resolving dependencies...
In order, the following would be installed:
tar-0.3.2.0 (new package)
transformers-0.2.2.0 (new version)
mtl-2.0.1.0 (new version)
parsec-3.1.3 (reinstall) changes: mtl-2.1.2 -> 2.0.1.0
network-2.3.2.0 (new version)
HTTP-4000.2.8 (new version)
cabal-dev-0.9.1 (new package)
cabal: The following packages are likely to be broken by the reinstalls: network-2.3.1.0
haskell-platform-2012.4.0.0
cgi-3001.1.7.4
HTTP-4000.2.5
Use --force-reinstalls if you want to install anyway.


I *think* the problem is that cabal-dev has these dependencies:

=C2=A0 =C2=A0 =C2=A0 mtl >=3D 1.1 && < 2.1,
=C2=A0 =C2=A0 =C2=A0 transformers >=3D 0.2 && < 0.3,

where the latest version of mtl and transformers are 2.1.2 and 0.3 respecti= vely. At least, if I download the latest cabal-dev package and relax those = upper bounds I can get it to install.

The irony is, of course, that I'm trying to install cabal-dev to get me= out of a totally unrelated dependencies hole!

What should I do now?

Cheers,

--
David Turner
Senior Consultant
Tracsis PLC

Tracsis PLC is a company registered in
England and Wales with number 5019106.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@= haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

--20cf303b42e162250904d584ed75-- From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID: installation, it would be better to do a fresh install using the bootstrapped GHC you can find on the website. Roughly I have done this way (on my Mac and on My EC2 instance): (inside a ghc bootstrapped folder) ./configure --prefix=~/Library/Haskell/ghc-xxx (where xxx is the version) make install (then inside ~/Library/Haskell) ln -s ghc-xxx current ln -s current/bin bin This way my current GHC is pointing to current inside ~/Library/Haskell/current and my bin are updated accordingly (make sure to add /bin to your $PATH!). Then you install cabal-install and you are pretty much sorted. The advantage of this approach is that you have the control over the installation process, but other suggestion (like Alp's one) are pretty good too. Mostly depends on what you think will work best for you :) A. On 11 March 2013 11:33, Alp Mestanogullari wrote: > I don't think so. However, you can install the OS X binaries for ghc 7.6.2 > and make that sit just next to your Haskell Platform install. You can even > use your existing cabal-install to install packages for the freshly > installed ghc by doing 'cabal install foo --with-ghc=/path/to/ghc'. Just > watch which ghc does become the default (it's a matter of replacing a > symlink) and that it satisfies you. > > > On Thu, Mar 7, 2013 at 10:50 PM, Graham Klyne wrote: > >> Hi, >> >> I have Haskell Platform with GHC[i] 7.4.2 installed on a MacOS system. >> There's a problem with the handling of certain Markdown constructs in >> literate Haskell (lines starting with '#') that I understand is fixed in >> 7.6.2. >> >> Therefore, I'd like to be able to update my GHC installation to 7.6.2. >> But I haven't yet been able to find any instructions about how to upgrade >> an existing GHC installation. Am I missing something? >> >> #g >> -- >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > > > > -- > Alp Mestanogullari > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > --14dae9cc9c562f442304d7df1463 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID: ation, it would be better to do a fresh install using the bootstrapped GHC = you can find on the website. Roughly I have done this way (on my Mac and on= My EC2 instance):

(inside a ghc bootstrapped folder)
./configure --p= refix=3D~/Library/Haskell/ghc-xxx (where xxx is the version)
make= install

(then inside ~/Library/Haskell)
ln -s ghc-xxx current
ln -s current/bin bin

<= div>This way my current GHC is pointing to current inside ~/Library/Haskell= /current and my bin are updated accordingly (make sure to add /bin to your = $PATH!). Then you install cabal-install and you are pretty much sorted. The= advantage of this approach is that you have the control over the installat= ion process, but other suggestion (like Alp's one) are pretty good too.= Mostly depends on what you think will work best for you :)

A.

On 11 March 2013 1= 1:33, Alp Mestanogullari <alpmestan at gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
I don't think so. However, you can install the OS X bi= naries for ghc 7.6.2 and make that sit just next to your Haskell Platform i= nstall. You can even use your existing cabal-install to install packages fo= r the freshly installed ghc by doing 'cabal install foo --with-ghc=3D/p= ath/to/ghc'. Just watch which ghc does become the default (it's a m= atter of replacing a symlink) and that it satisfies you.


On Thu, Mar 7, 2013 at 10:50 PM, Graham Klyne &= lt;GK at ninebynine.org= > wrote:
Hi,

I have Haskell Platform with GHC[i] 7.4.2 installed on a MacOS system. =C2= =A0There's a problem with the handling of certain Markdown constructs i= n literate Haskell (lines starting with '#') that I understand is f= ixed in 7.6.2.

Therefore, I'd like to be able to update my GHC installation to 7.6.2. = =C2=A0But I haven't yet been able to find any instructions about how to= upgrade an existing GHC installation. =C2=A0Am I missing something?

#g
--

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@= haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



--
Alp Mestanogullari

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe


--14dae9cc9c562f442304d7df1463-- From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID: > One compelling use of such type functions is to make type > coercions implicit, especially in arithmetic. Suppose we want to be able to > write add a b to add two numeric values a and b even if one is an Integer > and the other is a Double (without writing fromIntegral explicitly). And then an Add class is defined which can dispatch at the type-level to appropriate functions which resolve two types into one, with a catch-all case for Num. Has anyone put this into a package, for all common arithmetic operations? I would use it. Doing arithmetic stuff in Haskell always feels labored because of having constantly convert between number types. From bogus@does.not.exist.com Thu Jan 10 18:17:16 2013 From: bogus@does.not.exist.com () Date: Thu, 10 Jan 2013 17:17:16 -0000 Subject: No subject Message-ID:
> One compelling use of such type functions is to make type
> coercions implicit, especially in arithmetic. Suppose we want to be ab= le to
> write add a b to add two numeric values a and b even if one is an Inte= ger
> and the other is a Double (without writing fromIntegral explicitly).
And then an Add class is defined which can dispatch at the type-level
to appropriate functions which resolve two types into one, with a
catch-all case for Num.

Has anyone put this into a package, for all common arithmetic
operations? I would use it. Doing arithmetic stuff in Haskell always
feels labored because of having constantly convert between number
types.

I prefer the current way (which = is interestingly what Go chose as well). With implicit casts it's easy = to shoot yourself in the foot e.g. when doing bit-twiddling. These two are = different

f :: Word8 -> Int -> Word32
f w8 n =3D = fromIntegral (w8 `shiftL` n)

f' :: Word8 = -> Int -> Word32
f' w8 n =3D (fromIntegral w8) `shiftL`= n

--485b397dd69791415b04d84f24f8--