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><eyebloom></td><td>Instead of f x y z you could write f _ _ z</td></tr>
<tr valign="top"><td>00:31:24</td><td><rasfar></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><rasfar></td><td>underscores and all...</td></tr>
<tr valign="top"><td>00:31:45</td><td><eyebloom></td><td>You know what they say about great minds.</td></tr>
<tr valign="top"><td>00:32:17</td><td><rasfar></td><td>maybe we'll find out whether there's any need.</td></tr>
<tr valign="top"><td>00:33:44</td><td><rasfar></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><eyebloom></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><eyebloom></td><td>message me if you start working on this.</td></tr>
<tr valign="top"><td>00:40:26</td><td><rasfar></td><td>fair enough! «email sent»</td></tr>
</table><br /><table>
<tr valign="top"><td>00:31:12</td><td><quintessence></td><td>:t flip</td></tr>
<tr valign="top"><td>00:31:13</td><td><lambdabot></td><td>forall (f :: * -> *) a b. (Functor f) => f (a -> b) -> a -> f b</td></tr>
<tr valign="top"><td>00:32:13</td><td><cmccann></td><td>:t flip . fmap flip</td></tr>
<tr valign="top"><td>00:32:14</td><td><lambdabot></td><td>forall (f :: * -> *) a (f1 :: * -> *) b. (Functor f, Functor f1) => f (f1 (a -> b)) -> a -> f (f1 b)</td></tr>
<tr valign="top"><td>00:32:24</td><td><cmccann></td><td>:t flip . fmap Prelude.flip</td></tr>
<tr valign="top"><td>00:32:28</td><td><lambdabot></td><td>forall (f :: * -> *) a a1 c. (Functor f) => f (a1 -> a -> c) -> a -> f (a1 -> c)</td></tr>
<tr valign="top"><td>00:32:29</td><td><cmccann></td><td>argh</td></tr>
<tr valign="top"><td>00:32:34</td><td><cmccann></td><td>:t flip <<< fmap Prelude.flip</td></tr>
<tr valign="top"><td>00:32:35</td><td><lambdabot></td><td>forall (f :: * -> *) a a1 c. (Functor f) => f (a1 -> a -> c) -> a -> f (a1 -> c)</td></tr>
<tr valign="top"><td>00:32:44</td><td><cmccann></td><td>:t Prelude.flip <<< fmap Prelude.flip</td></tr>
<tr valign="top"><td>00:32:45</td><td><lambdabot></td><td>forall a b a1 c. (a -> a1 -> b -> c) -> b -> a -> a1 -> c</td></tr>
<tr valign="top"><td>00:32:56</td><td><cmccann></td><td>:t Prelude.flip <<< fmap Prelude.flip <<< fmap (fmap Prelude.flip)</td></tr>
<tr valign="top"><td>00:32:56</td><td><lambdabot></td><td>forall a b a1 a2 c. (a -> a1 -> a2 -> b -> c) -> b -> a -> a1 -> a2 -> 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><shachaf></td><td>(\x y -> f x y z)</td></tr>
<tr valign="top"><td>00:32:15</td><td><dolio></td><td>Vetoed.</td></tr>
<tr valign="top"><td>00:32:18</td><td><mzero></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><shachaf></td><td>I second dolio's veto.</td></tr>
<tr valign="top"><td>00:33:44</td><td><mzero></td><td>if you want more, it is idiomatic to use a lambda, which is generally easier than all this flipyness: (\a b -> fixMyThirdArg a b 42)</td></tr>
<tr valign="top"><td>00:34:13</td><td><tikhonjelvis></td><td>flipyness is a good word</td></tr>
<tr valign="top"><td>00:34:22</td><td><mzero></td><td>:-)</td></tr>
<tr valign="top"><td>00:34:24</td><td><eyebloom></td><td>truthiness</td></tr>
<tr valign="top"><td>00:45:43</td><td><mzero></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><mzero></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><mzero></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><shachaf></td><td>The obvious solution is to replace every _ with (\x->x).</td></tr>
<tr valign="top"><td>00:46:15</td><td><shachaf></td><td>{-# LANGUAGE CPP #-} #define _ (\x->x)</td></tr>
</table><br /><table>
<tr valign="top"><td>00:36:42</td><td><nand`></td><td>let apFst = id; apSnd = flip; alThd f c = \a b -> f a b c; ...</td></tr>
<tr valign="top"><td>00:36:52</td><td><nand`></td><td>foo `apThd` 42</td></tr>
</table><br /><table>
<tr valign="top"><td>00:38:19</td><td><dolio></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><dolio></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><quintessence></td><td>scala?</td></tr>
<tr valign="top"><td>00:38:52</td><td><dolio></td><td>Yes.</td></tr>
<tr valign="top"><td>00:38:51</td><td><glguy_></td><td>Unclear code? Yup, Haskell already supports that</td></tr>
<tr valign="top"><td>00:39:09</td><td><eyebloom></td><td>:) so does every language.</td></tr>
<tr valign="top"><td>00:39:44</td><td><quintessence></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><dolio></td><td>foo (g _) =?= foo $ g _</td></tr>
<tr valign="top"><td>00:40:58</td><td><glguy_></td><td>Factor supports that as a library</td></tr>
<tr valign="top"><td>00:41:06</td><td><quintessence></td><td>Something like (\-> f _ 10 _) would be a little less ambiguous</td></tr>
<tr valign="top"><td>00:41:26</td><td><rwbarton></td><td>Mathematica has this goofy Foo[a, #, c] & syntax</td></tr>
<tr valign="top"><td>00:42:39</td><td><rwbarton></td><td>where & is like quintessence's \-> but in postfix form</td></tr>
<tr valign="top"><td>00:44:27</td><td><dolio></td><td>Matter of fact, what does "map (foo (g _) x) (h _)" mean?</td></tr>
<tr valign="top"><td>00:45:29</td><td><nand`></td><td>\a b -> map (foo (g a) x) (h b) maybe?</td></tr>
<tr valign="top"><td>00:45:48</td><td><shachaf></td><td>How do you figure out where to put the lambda?</td></tr>
<tr valign="top"><td>00:45:55</td><td><nand`></td><td>I didn't. I took a wild guess</td></tr>
<tr valign="top"><td>00:46:01</td><td><nand`></td><td>that's the problem</td></tr>
</table><br /><table>
<tr valign="top"><td>00:46:16</td><td><dolio></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><rwbarton></td><td>could you show the actual equivalent Scala code?</td></tr>
<tr valign="top"><td>00:46:56</td><td><dolio></td><td>h(_).map(foo(g(_))(x))</td></tr>
<tr valign="top"><td>00:47:21</td><td><glguy_></td><td>it burns us!</td></tr>
<tr valign="top"><td>00:47:27</td><td><dolio></td><td>Drink that in.</td></tr>
<tr valign="top"><td>00:47:30</td><td><nyingen></td><td>urk</td></tr>
<tr valign="top"><td>00:48:06</td><td><dolio></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><dolio></td><td>because often times foo(g) would be illegal.</td></tr>
<tr valign="top"><td>00:48:31</td><td><dolio></td><td>So you're stuck with foo(g(_)) or foo(g _)</td></tr>
<tr valign="top"><td>00:49:12</td><td><dolio></td><td>Anyhow it means: a => h(a).map(foo(b => g(b))(x))</td></tr>
<tr valign="top"><td>00:49:52</td><td><dolio></td><td>Or if you kept it as: map(foo(g(_))(x))(h(_)), it'd be: map(foo(a => g(a))(x)(b => h(b)), I believe.</td></tr>
<tr valign="top"><td>00:49:53</td><td><rwbarton></td><td>is that a => (h(a).map(foo(b => g(b))(x))) ?</td></tr>
<tr valign="top"><td>00:50:18</td><td><dolio></td><td>Yes. x => e is a lambda expression in Scala.</td></tr>
</table><br /><table>
<tr valign="top"><td>00:48:52</td><td><quintessence></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><nand`></td><td>\ -> (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><nand`></td><td>but then you run into situations such as nesting those</td></tr>
<tr valign="top"><td>00:52:49</td><td><nand`></td><td>(\a -> f _ 42 _ a) could be assumed equivalent to (\a b c -> f b 42 c a)</td></tr>
</table>
</html>