packages feed

freesect-0.0.5: Doc/irc.html

<html>
<head>
</style>
</head>
Feb. 22, 2012 -- some omissions and contractions of the literal logs.<br /><br />
<table>
<tr valign="top"><td>00:30:40</td><td>&lt;eyebloom&gt;</td><td>Instead of f x y z you could write f _ _ z</td></tr>
<tr valign="top"><td>00:31:24</td><td>&lt;rasfar&gt;</td><td>eyebloom, this is amazing, you have hit upon the language extension I just started implementing an hour ago</td></tr>
<tr valign="top"><td>00:31:45</td><td>&lt;rasfar&gt;</td><td>underscores and all...</td></tr>
<tr valign="top"><td>00:31:45</td><td>&lt;eyebloom&gt;</td><td>You know what they say about great minds.</td></tr>
<tr valign="top"><td>00:32:17</td><td>&lt;rasfar&gt;</td><td>maybe we'll find out whether there's any need.</td></tr>
<tr valign="top"><td>00:33:44</td><td>&lt;rasfar&gt;</td><td>i was just looking to see if such an extension already exists, but it appears not (so far)</td></tr>
<tr valign="top"><td>00:37:51</td><td>&lt;eyebloom&gt;</td><td>As syntactic sugar it would be a lot cleaner looking then a lambda a flip or even an explicit infix.</td></tr>
<tr valign="top"><td>00:40:16</td><td>&lt;eyebloom&gt;</td><td>message me if you start working on this.</td></tr>
<tr valign="top"><td>00:40:26</td><td>&lt;rasfar&gt;</td><td>fair enough!  &laquo;email sent&raquo;</td></tr>
</table><br /><table>

<tr valign="top"><td>00:31:12</td><td>&lt;quintessence&gt;</td><td>:t flip</td></tr>
<tr valign="top"><td>00:31:13</td><td>&lt;lambdabot&gt;</td><td>forall (f :: * -&gt; *) a b. (Functor f) =&gt; f (a -&gt; b) -&gt; a -&gt; f b</td></tr>
<tr valign="top"><td>00:32:13</td><td>&lt;cmccann&gt;</td><td>:t flip . fmap flip</td></tr>
<tr valign="top"><td>00:32:14</td><td>&lt;lambdabot&gt;</td><td>forall (f :: * -&gt; *) a (f1 :: * -&gt; *) b. (Functor f, Functor f1) =&gt; f (f1 (a -&gt; b)) -&gt; a -&gt; f (f1 b)</td></tr>
<tr valign="top"><td>00:32:24</td><td>&lt;cmccann&gt;</td><td>:t flip . fmap Prelude.flip</td></tr>
<tr valign="top"><td>00:32:28</td><td>&lt;lambdabot&gt;</td><td>forall (f :: * -&gt; *) a a1 c. (Functor f) =&gt; f (a1 -&gt; a -&gt; c) -&gt; a -&gt; f (a1 -&gt; c)</td></tr>
<tr valign="top"><td>00:32:29</td><td>&lt;cmccann&gt;</td><td>argh</td></tr>
<tr valign="top"><td>00:32:34</td><td>&lt;cmccann&gt;</td><td>:t flip &lt;&lt;&lt; fmap Prelude.flip</td></tr>
<tr valign="top"><td>00:32:35</td><td>&lt;lambdabot&gt;</td><td>forall (f :: * -&gt; *) a a1 c. (Functor f) =&gt; f (a1 -&gt; a -&gt; c) -&gt; a -&gt; f (a1 -&gt; c)</td></tr>
<tr valign="top"><td>00:32:44</td><td>&lt;cmccann&gt;</td><td>:t Prelude.flip &lt;&lt;&lt; fmap Prelude.flip</td></tr>
<tr valign="top"><td>00:32:45</td><td>&lt;lambdabot&gt;</td><td>forall a b a1 c. (a -&gt; a1 -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; a1 -&gt; c</td></tr>
<tr valign="top"><td>00:32:56</td><td>&lt;cmccann&gt;</td><td>:t Prelude.flip &lt;&lt;&lt; fmap Prelude.flip &lt;&lt;&lt; fmap (fmap Prelude.flip)</td></tr>
<tr valign="top"><td>00:32:56</td><td>&lt;lambdabot&gt;</td><td>forall a b a1 a2 c. (a -&gt; a1 -&gt; a2 -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; a1 -&gt; a2 -&gt; c</td></tr>
<tr valign="top"><td>00:33:32</td><td>*</td><td>cmccann has a type-hackery generalized flip that does the kind of argument rotation as the above functions</td></tr>
</table><br /><table>

<tr valign="top"><td>00:31:15</td><td>&lt;shachaf&gt;</td><td>(\x y -&gt; f x y z)</td></tr>
<tr valign="top"><td>00:32:15</td><td>&lt;dolio&gt;</td><td>Vetoed.</td></tr>
<tr valign="top"><td>00:32:18</td><td>&lt;mzero&gt;</td><td>if the function takes two arguments, say foo a b    and you want to apply the b (leaving a function that takes a)  then idiomatic Haskell is to write    (`foo` 7)</td></tr>
<tr valign="top"><td>00:32:30</td><td>&lt;shachaf&gt;</td><td>I second dolio's veto.</td></tr>
<tr valign="top"><td>00:33:44</td><td>&lt;mzero&gt;</td><td>if you want more, it is idiomatic to use a lambda, which is generally easier than all this flipyness:   (\a b -&gt; fixMyThirdArg a b 42)</td></tr>
<tr valign="top"><td>00:34:13</td><td>&lt;tikhonjelvis&gt;</td><td>flipyness is a good word</td></tr>
<tr valign="top"><td>00:34:22</td><td>&lt;mzero&gt;</td><td>:-)</td></tr>
<tr valign="top"><td>00:34:24</td><td>&lt;eyebloom&gt;</td><td>truthiness</td></tr>
<tr valign="top"><td>00:45:43</td><td>&lt;mzero&gt;</td><td>gosh - I think the rarity of needing to partially apply a function to some argument than the first or second is such that it isn't worth complicating the language at all</td></tr>
<tr valign="top"><td>00:45:55</td><td>&lt;mzero&gt;</td><td>practically, this just doesn't come up in my code base that often</td></tr>
<tr valign="top"><td>00:47:53</td><td>&lt;mzero&gt;</td><td>wow - all this to avoid computer science's smallest lambda syntax? rlly?</td></tr>
</table><br /><table>

<tr valign="top"><td>00:46:01</td><td>&lt;shachaf&gt;</td><td>The obvious solution is to replace every _ with (\x-&gt;x).</td></tr>
<tr valign="top"><td>00:46:15</td><td>&lt;shachaf&gt;</td><td>{-# LANGUAGE CPP #-} #define _ (\x-&gt;x)</td></tr>
</table><br /><table>

<tr valign="top"><td>00:36:42</td><td>&lt;nand`&gt;</td><td>let apFst = id; apSnd = flip; alThd f c = \a b -&gt; f a b c; ...</td></tr>
<tr valign="top"><td>00:36:52</td><td>&lt;nand`&gt;</td><td>foo `apThd` 42</td></tr>
</table><br /><table>

<tr valign="top"><td>00:38:19</td><td>&lt;dolio&gt;</td><td>I've used languages with it, and it leads to people writing unclear code.</td></tr>
<tr valign="top"><td>00:38:43</td><td>&lt;dolio&gt;</td><td>map (foo (g _) x) (h _)</td></tr>
<tr valign="top"><td>00:38:45</td><td>*</td><td>rasfar attends to dolio carefully...</td></tr>
<tr valign="top"><td>00:38:47</td><td>&lt;quintessence&gt;</td><td>scala?</td></tr>
<tr valign="top"><td>00:38:52</td><td>&lt;dolio&gt;</td><td>Yes.</td></tr>
<tr valign="top"><td>00:38:51</td><td>&lt;glguy_&gt;</td><td>Unclear code? Yup, Haskell already supports that</td></tr>
<tr valign="top"><td>00:39:09</td><td>&lt;eyebloom&gt;</td><td>:) so does every language.</td></tr>
<tr valign="top"><td>00:39:44</td><td>&lt;quintessence&gt;</td><td>I think the problem in scala is more that it's hard to see the scope of the (implicit) lambda</td></tr>
<tr valign="top"><td>00:40:22</td><td>&lt;dolio&gt;</td><td>foo (g _) =?= foo $ g _</td></tr>
<tr valign="top"><td>00:40:58</td><td>&lt;glguy_&gt;</td><td>Factor supports that as a library</td></tr>
<tr valign="top"><td>00:41:06</td><td>&lt;quintessence&gt;</td><td>Something like (\-&gt; f _ 10 _) would be a little less ambiguous</td></tr>
<tr valign="top"><td>00:41:26</td><td>&lt;rwbarton&gt;</td><td>Mathematica has this goofy Foo[a, #, c] &amp; syntax</td></tr>
<tr valign="top"><td>00:42:39</td><td>&lt;rwbarton&gt;</td><td>where &amp; is like quintessence's \-&gt; but in postfix form</td></tr>
<tr valign="top"><td>00:44:27</td><td>&lt;dolio&gt;</td><td>Matter of fact, what does "map (foo (g _) x) (h _)" mean?</td></tr>
<tr valign="top"><td>00:45:29</td><td>&lt;nand`&gt;</td><td>\a b -&gt; map (foo (g a) x) (h b) maybe?</td></tr>
<tr valign="top"><td>00:45:48</td><td>&lt;shachaf&gt;</td><td>How do you figure out where to put the lambda?</td></tr>
<tr valign="top"><td>00:45:55</td><td>&lt;nand`&gt;</td><td>I didn't. I took a wild guess</td></tr>
<tr valign="top"><td>00:46:01</td><td>&lt;nand`&gt;</td><td>that's the problem</td></tr>
</table><br /><table>

<tr valign="top"><td>00:46:16</td><td>&lt;dolio&gt;</td><td>nand`: I can tell you, that's not what the equivalent Scala code means.</td></tr>
<tr valign="top"><td>00:46:30</td><td>&lt;rwbarton&gt;</td><td>could you show the actual equivalent Scala code?</td></tr>
<tr valign="top"><td>00:46:56</td><td>&lt;dolio&gt;</td><td>h(_).map(foo(g(_))(x))</td></tr>
<tr valign="top"><td>00:47:21</td><td>&lt;glguy_&gt;</td><td>it burns us!</td></tr>
<tr valign="top"><td>00:47:27</td><td>&lt;dolio&gt;</td><td>Drink that in.</td></tr>
<tr valign="top"><td>00:47:30</td><td>&lt;nyingen&gt;</td><td>urk</td></tr>
<tr valign="top"><td>00:48:06</td><td>&lt;dolio&gt;</td><td>The foo(g(_)) is something you'd actually use in scala, too.</td></tr>
<tr valign="top"><td>00:48:18</td><td>&lt;dolio&gt;</td><td>because often times foo(g) would be illegal.</td></tr>
<tr valign="top"><td>00:48:31</td><td>&lt;dolio&gt;</td><td>So you're stuck with foo(g(_)) or foo(g _)</td></tr>
<tr valign="top"><td>00:49:12</td><td>&lt;dolio&gt;</td><td>Anyhow it means: a =&gt; h(a).map(foo(b =&gt; g(b))(x))</td></tr>
<tr valign="top"><td>00:49:52</td><td>&lt;dolio&gt;</td><td>Or if you kept it as: map(foo(g(_))(x))(h(_)), it'd be: map(foo(a =&gt; g(a))(x)(b =&gt; h(b)), I believe.</td></tr>
<tr valign="top"><td>00:49:53</td><td>&lt;rwbarton&gt;</td><td>is that a =&gt; (h(a).map(foo(b =&gt; g(b))(x))) ?</td></tr>
<tr valign="top"><td>00:50:18</td><td>&lt;dolio&gt;</td><td>Yes. x =&gt; e is a lambda expression in Scala.</td></tr>
</table><br /><table>

<tr valign="top"><td>00:48:52</td><td>&lt;quintessence&gt;</td><td>I think avoiding the names is the win and avoiding the lambda is the problem</td></tr>
</table><br /><table>

<tr valign="top"><td>00:50:30</td><td>&lt;nand`&gt;</td><td>\ -&gt; (or more generally, replacing any distinct instance of _ in the right hand side of a lambda by a new identifier which would be appended to the left hand side of the nearest lambda) might work to save you a few keystrokes;</td></tr>
<tr valign="top"><td>00:50:37</td><td>&lt;nand`&gt;</td><td>but then you run into situations such as nesting those</td></tr>
<tr valign="top"><td>00:52:49</td><td>&lt;nand`&gt;</td><td>(\a -&gt; f _ 42 _ a) could be assumed equivalent to (\a b c -&gt; f b 42 c a)</td></tr>
</table>
</html>