{"action":"created","issue":{"url":"https://api.github.com/repos/non/cats/issues/167","labels_url":"https://api.github.com/repos/non/cats/issues/167/labels{/name}","comments_url":"https://api.github.com/repos/non/cats/issues/167/comments","events_url":"https://api.github.com/repos/non/cats/issues/167/events","html_url":"https://github.com/non/cats/issues/167","id":57166574,"number":167,"title":"Apply.applyN and Apply.mapN evaluate arguments in reverse","user":{"login":"ceedubs","id":977929,"avatar_url":"https://avatars.githubusercontent.com/u/977929?v=3","gravatar_id":"","url":"https://api.github.com/users/ceedubs","html_url":"https://github.com/ceedubs","followers_url":"https://api.github.com/users/ceedubs/followers","following_url":"https://api.github.com/users/ceedubs/following{/other_user}","gists_url":"https://api.github.com/users/ceedubs/gists{/gist_id}","starred_url":"https://api.github.com/users/ceedubs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceedubs/subscriptions","organizations_url":"https://api.github.com/users/ceedubs/orgs","repos_url":"https://api.github.com/users/ceedubs/repos","events_url":"https://api.github.com/users/ceedubs/events{/privacy}","received_events_url":"https://api.github.com/users/ceedubs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-02-10T12:09:45Z","updated_at":"2015-02-24T14:44:05Z","closed_at":null,"body":"Example:\r\n\r\n```scala\r\nscala> import cats._, cats.std.implicits._\r\nimport cats._\r\nimport cats.std.implicits._\r\n\r\nscala> Apply[Function0].map2(() => { println(\"1\"); 1 }, () => { println(\"2\"); 2 })(_ :: _ :: Nil)()\r\n2\r\n1\r\nres0: List[Int] = List(1, 2)\r\n\r\nscala> Apply[Function0].apply2(() => { println(\"1\"); 1 }, () => { println(\"2\"); 2 })(() => _ :: _ :: Nil)()\r\n2\r\n1\r\nres1: List[Int] = List(1, 2)\r\n```\r\n\r\nI would expect the \"1\" to print before the \"2\" in both cases. I suppose it is arbitrary and that as long as we are consistent, we could maybe keep it the way it is, but it does seem counterintuitive.\r\n\r\nI believe that this was probably the reason that #142 existed in the first place. @non ended up changing Lists's `traverse` implementation, but I think changing the implementation of `map2` would have been an alternative solution.\r\n\r\nWhat Cats is currently doing is the opposite of scalaz. My confusion in https://github.com/non/cats/pull/142#issuecomment-73452302 was because I had naively copied the Cats `traverse` implementation for `List` into scalaz changing `map2` to `apply2` not realizing the differences in semantics. I believe the current Cats implementation also does opposite of what Haskell does.\r\n\r\nI propose changing this to an evaluation order that matches the order of the arguments (and the scalaz precedent). Does anybody have a reason not to?\r\n\r\nThis could be done by changing the definition of `apply2` to:\r\n```scala\r\napply(fb)(apply(fa)(map(f)(f => (a: A) => (b: B) => f(a, b))))\r\n```\r\n\r\nSimilar changes would need to be made to `map2`, List's `traverse` implementation, and perhaps some other places."},"comment":{"url":"https://api.github.com/repos/non/cats/issues/comments/75768529","html_url":"https://github.com/non/cats/issues/167#issuecomment-75768529","issue_url":"https://api.github.com/repos/non/cats/issues/167","id":75768529,"user":{"login":"refried","id":538571,"avatar_url":"https://avatars.githubusercontent.com/u/538571?v=3","gravatar_id":"","url":"https://api.github.com/users/refried","html_url":"https://github.com/refried","followers_url":"https://api.github.com/users/refried/followers","following_url":"https://api.github.com/users/refried/following{/other_user}","gists_url":"https://api.github.com/users/refried/gists{/gist_id}","starred_url":"https://api.github.com/users/refried/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/refried/subscriptions","organizations_url":"https://api.github.com/users/refried/orgs","repos_url":"https://api.github.com/users/refried/repos","events_url":"https://api.github.com/users/refried/events{/privacy}","received_events_url":"https://api.github.com/users/refried/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T14:44:05Z","updated_at":"2015-02-24T14:44:05Z","body":"Never thought I'd be saying github is too slow compared to IRC!\r\n\r\nHmm what about the rule of thumb \"if your container supports sequencing, then use flatMap for its traverse\"?  List and IO and Task all can.  Granted, I still haven't had coffee and I don't completely know what I'm talking about and I'm not at a compiler, but I will try to play with an example later to see if I can unconvince myself.\r\n(I'm going to wait on the \"it does\" until I can write/paste some code.)"}}