Feb. 22, 2012 -- some omissions and contractions of the literal logs.
00:30:40 | <eyebloom> | Instead of f x y z you could write f _ _ z |
00:31:24 | <rasfar> | eyebloom, this is amazing, you have hit upon the language extension I just started implementing an hour ago |
00:31:45 | <rasfar> | underscores and all... |
00:31:45 | <eyebloom> | You know what they say about great minds. |
00:32:17 | <rasfar> | maybe we'll find out whether there's any need. |
00:33:44 | <rasfar> | i was just looking to see if such an extension already exists, but it appears not (so far) |
00:37:51 | <eyebloom> | As syntactic sugar it would be a lot cleaner looking then a lambda a flip or even an explicit infix. |
00:40:16 | <eyebloom> | message me if you start working on this. |
00:40:26 | <rasfar> | fair enough! «email sent» |
00:31:12 | <quintessence> | :t flip |
00:31:13 | <lambdabot> | forall (f :: * -> *) a b. (Functor f) => f (a -> b) -> a -> f b |
00:32:13 | <cmccann> | :t flip . fmap flip |
00:32:14 | <lambdabot> | forall (f :: * -> *) a (f1 :: * -> *) b. (Functor f, Functor f1) => f (f1 (a -> b)) -> a -> f (f1 b) |
00:32:24 | <cmccann> | :t flip . fmap Prelude.flip |
00:32:28 | <lambdabot> | forall (f :: * -> *) a a1 c. (Functor f) => f (a1 -> a -> c) -> a -> f (a1 -> c) |
00:32:29 | <cmccann> | argh |
00:32:34 | <cmccann> | :t flip <<< fmap Prelude.flip |
00:32:35 | <lambdabot> | forall (f :: * -> *) a a1 c. (Functor f) => f (a1 -> a -> c) -> a -> f (a1 -> c) |
00:32:44 | <cmccann> | :t Prelude.flip <<< fmap Prelude.flip |
00:32:45 | <lambdabot> | forall a b a1 c. (a -> a1 -> b -> c) -> b -> a -> a1 -> c |
00:32:56 | <cmccann> | :t Prelude.flip <<< fmap Prelude.flip <<< fmap (fmap Prelude.flip) |
00:32:56 | <lambdabot> | forall a b a1 a2 c. (a -> a1 -> a2 -> b -> c) -> b -> a -> a1 -> a2 -> c |
00:33:32 | * | cmccann has a type-hackery generalized flip that does the kind of argument rotation as the above functions |
00:38:19 | <dolio> | I've used languages with it, and it leads to people writing unclear code. |
00:38:43 | <dolio> | map (foo (g _) x) (h _) |
00:38:45 | * | rasfar attends to dolio carefully... |
00:38:47 | <quintessence> | scala? |
00:38:52 | <dolio> | Yes. |
00:38:51 | <glguy_> | Unclear code? Yup, Haskell already supports that |
00:39:09 | <eyebloom> | :) so does every language. |
00:39:44 | <quintessence> | I think the problem in scala is more that it's hard to see the scope of the (implicit) lambda |
00:40:22 | <dolio> | foo (g _) =?= foo $ g _ |
00:40:58 | <glguy_> | Factor supports that as a library |
00:41:06 | <quintessence> | Something like (\-> f _ 10 _) would be a little less ambiguous |
00:41:26 | <rwbarton> | Mathematica has this goofy Foo[a, #, c] & syntax |
00:42:39 | <rwbarton> | where & is like quintessence's \-> but in postfix form |
00:44:27 | <dolio> | Matter of fact, what does "map (foo (g _) x) (h _)" mean? |
00:45:29 | <nand`> | \a b -> map (foo (g a) x) (h b) maybe? |
00:45:48 | <shachaf> | How do you figure out where to put the lambda? |
00:45:55 | <nand`> | I didn't. I took a wild guess |
00:46:01 | <nand`> | that's the problem |
00:46:16 | <dolio> | nand`: I can tell you, that's not what the equivalent Scala code means. |
00:46:30 | <rwbarton> | could you show the actual equivalent Scala code? |
00:46:56 | <dolio> | h(_).map(foo(g(_))(x)) |
00:47:21 | <glguy_> | it burns us! |
00:47:27 | <dolio> | Drink that in. |
00:47:30 | <nyingen> | urk |
00:48:06 | <dolio> | The foo(g(_)) is something you'd actually use in scala, too. |
00:48:18 | <dolio> | because often times foo(g) would be illegal. |
00:48:31 | <dolio> | So you're stuck with foo(g(_)) or foo(g _) |
00:49:12 | <dolio> | Anyhow it means: a => h(a).map(foo(b => g(b))(x)) |
00:49:52 | <dolio> | 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. |
00:49:53 | <rwbarton> | is that a => (h(a).map(foo(b => g(b))(x))) ? |
00:50:18 | <dolio> | Yes. x => e is a lambda expression in Scala. |