tag:blogger.com,1999:blog-11295132.post4790015581908022633..comments2014-09-28T07:09:30.029-07:00Comments on A Neighborhood of Infinity: Purely functional recursive types in Haskell and PythonDan Piponihttps://plus.google.com/107913314994758123748noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-11295132.post-23273908266062087442011-05-31T23:24:52.841-07:002011-05-31T23:24:52.841-07:00Thanks for this post, it helped me to understandin...Thanks for this post, it helped me to understanding the Empty/Cons referred to in this recent post<br /><br />http://apocalisp.wordpress.com/2011/05/30/imperative-vs-functional-programming/<br /><br />I'm wondering if the more complex example with the Expr AST is missing something since it still uses the algebraic type. i.e. it isn't represented simply by an encoding of functions.Steven Shawhttp://www.blogger.com/profile/06340403723350864929noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-31789720889703578872010-07-19T18:32:55.805-07:002010-07-19T18:32:55.805-07:00Any chance you might be able to put in an entry fo...Any chance you might be able to put in an entry for http://rosettacode.org/wiki/Pattern_matching; and http://rosettacode.org/wiki/Proof? Maybe basing it on what has been done for Tcl/Haskel?<br /><br />It would be appreciated.<br /><br />Thanks.Paddy3118http://www.blogger.com/profile/06899509753521482267noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-16669566321415268092009-11-29T19:06:39.191-08:002009-11-29T19:06:39.191-08:00sigfpe--
Aaaugh, scary but interesting post! How...sigfpe--<br /><br />Aaaugh, scary but interesting post! However, the problem discussed there<br />* isn't with lambdas per se,<br />* it's with a closure (lambda <i>or</i> def) referring to loop variables in the enclosing function<br />* so doing the closure with def doesn't change that situation<br />* anyway it doesn't come up in your situation (referring to the enclosing function's parameters)<br /><br />My sense even after that post is that Python's closures are about as pure or impure as Scheme's (unless you think of the tail-call memory leak as impurity).<br /><br />Apply paranoias sparingly!FutureNerdhttp://www.blogger.com/profile/17103481765366134475noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-65178989035343685902009-11-29T14:36:26.959-08:002009-11-29T14:36:26.959-08:00FutureNerd,
Can't remember why I didn't u...FutureNerd,<br /><br />Can't remember why I didn't use lambdas. Probably the sort of paranoia expressed here: http://math.andrej.com/2009/04/09/pythons-lambda-is-broken/sigfpehttp://www.blogger.com/profile/08096190433222340957noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-9578664502445271302009-11-29T13:48:43.700-08:002009-11-29T13:48:43.700-08:00"""
(I'm leaving a comment, heh..."""<br />(I'm leaving a <i>comment,</i> heh.)<br /><br />I thought a couple of your examples would have been clearer by first saying<br /><br />"""<br />def plus(a,b):<br />____return a+b<br />"""<br /><br />(Wanting Python to have a syntax for that is the kind of pressure that created C++!)<br /><br />Funny omission...<br /><br /><i>...each constructor is replaced with the appropriate function. Here's an example:<br /><br />Now consider a simple expression type in Haskell:</i><br /><br />...as in, "Wanna see me do it again?" or, "Yes, in Python it's that simple!" I do get the idea, though.<br /><br />Is there an efficiency, readability or code style reason why you use internal defs with just a return line, instead of lambdas? I.e., (why) do you prefer<br /><br />"""<i><br />def cons(h,t):<br />____def _cons(a,b):<br />________return a(h,t(a,b))<br />____return _cons</i><br />"""<br /><br />to<br /><br />"""<br />def cons(h,t):<br />____return lambda a,b: a(h,t(a,b))<br />"""<br />?<br /><br />I wonder whether there's a compiler somewhere that recognizes nested lambdas as conses or sequential arrays (I infer that Haskell doesn't?).<br /><br />Interesting stuff, I got here from your "Programming with impossible functions."<br />"""FutureNerdhttp://www.blogger.com/profile/17103481765366134475noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-26289107568096514982009-11-29T01:53:17.187-08:002009-11-29T01:53:17.187-08:00Minor typo: "Evaluating X, 2 and X+2 at X=2:&...Minor typo: "Evaluating X, 2 and X+2 at X=2:" should be "Evaluating X, 2 and X+2 at X=3".<br /><br />Thanks for the post, I enjoyed it very much.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11295132.post-3937363794144534642008-02-11T00:55:00.000-08:002008-02-11T00:55:00.000-08:00You say that "Wadler's paper also describes a dual...You say that "Wadler's paper also describes a dual version of this for codata such as streams. But as far as I understand it's not very interesting." I disagree; I think the dual is very interesting! Whereas the inductive version captures <I>algebraic datatypes</I> as purely functional recursive types, the coinductive version captures <I>abstract datatypes</I>. I exploit this in my paper <A HREF="http://web.comlab.ox.ac.uk/jeremy.gibbons/publications/#adt" REL="nofollow"><I>Unfolding Abstract Datatypes</I></A>. (I'd explain here, but the margin is too narrow.)Jeremy Gibbonshttp://web.comlab.ox.ac.uk/jeremy.gibbons/noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-54043158020011853432008-02-06T18:14:00.000-08:002008-02-06T18:14:00.000-08:00One quick point. If you want to test for an empty ...One quick point. If you want to test for an empty list, it is better to do:<BR/><BR/>if not l:<BR/><BR/>instead of<BR/><BR/>if l==[]:Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11295132.post-85781908779174644522008-02-04T16:31:00.000-08:002008-02-04T16:31:00.000-08:00單中杰,In your paper I read> This representation is a...單中杰,<BR/><BR/>In your paper I read<BR/><BR/>> This representation is almost the same as in §1.1, only written with lowercase identifiers.<BR/><BR/>At one point I started writing exactly the same sentence when composing my blog post. I'll have to read the rest of that paper, it seems interesting.sigfpehttp://www.blogger.com/profile/08096190433222340957noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-41814965184271621102008-02-04T16:20:00.000-08:002008-02-04T16:20:00.000-08:00Mikael,Well there's already a nice description in ...Mikael,<BR/><BR/>Well there's already a nice description in terms of initial F-algebras but I think I see what you mean.sigfpehttp://www.blogger.com/profile/08096190433222340957noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-52820667458106713072008-02-03T01:39:00.000-08:002008-02-03T01:39:00.000-08:00Now I -really- want to see (or write) a discussion...Now I -really- want to see (or write) a discussion of recursive data types and generalized folds in the language of operads! What you said a generalized fold is looks to me very much like the construction of a free operads on a set of operations. (and/or possibly representations of such)Mikaelhttp://www.blogger.com/profile/00008302080954798496noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-46586162824796042942008-02-02T15:58:00.000-08:002008-02-02T15:58:00.000-08:00Good post. I think what's missing is a discussion ...Good post. I think what's missing is a discussion of the connection with lambda calculus, since all you're really describing is a couple of implementations in concrete languages of standard l-c types.suppressingfirehttp://suppressingfire.livejournal.com/noreply@blogger.comtag:blogger.com,1999:blog-11295132.post-60999842675840656762008-02-02T14:13:00.000-08:002008-02-02T14:13:00.000-08:00Indeed, "many things you might naturally want to d...Indeed, "many things you might naturally want to do with an Expr are particularly easy to write using" efold, and it may even be more efficient because you can eliminate tagging overhead. <A HREF="http://okmij.org/ftp/Computation/tagless-typed.html" REL="nofollow">Jacques Carette, Oleg Kiselyov, and I have been writing partial evaluators, CPS transformers, and other interpreters in this way, to good effect.</A>單中杰http://www.blogger.com/profile/08491317087691022866noreply@blogger.com