{"action":"created","comment":{"url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments/52837151","id":52837151,"diff_hunk":"@@ -203,16 +203,46 @@ trait SetLib extends Library {\n     setTyper(partialTyper { case List(s1, _) => s1 }),\n     setUntyper(t => success(t :: Type.Top :: Nil)))\n \n+  // TODO: Handle “normal” functions without creating Funcs. They should be in\n+  //       a separate functor and inlined prior to getting this far. It will\n+  //       also allow us to make simplification non-Corecursive and ∴ operate\n+  //       on Cofree.\n   val In = Mapping(\n     \"(in)\",\n     \"Determines whether a value is in a given set.\",\n     Type.Bool, Type.Top :: Type.AnySet :: Nil,\n-    noSimplification,\n+    new Func.Simplifier {\n+      def apply[T[_[_]]: Recursive](orig: LogicalPlan[T[LogicalPlan]])(implicit T: Corecursive[T]) =\n+        orig match {\n+          case InvokeF(_, List(item, set)) => set.project match {\n+            case ConstantF(Data.Set(_)) => Within(item, T.embed(StructuralLib.UnshiftArray(set))).some\n+            case ConstantF(_)           => RelationsLib.Eq(item, set).some\n+            case _                      => None\n+          }\n+          case _ => None\n+        }\n+    },\n     partialTyper {\n       case List(_,             Type.Const(Data.Set(Nil))) =>\n         Type.Const(Data.Bool(false))\n       case List(Type.Const(x), Type.Const(Data.Set(set))) =>\n         Type.Const(Data.Bool(set.contains(x)))\n+      case List(Type.Const(x), Type.Const(y))             =>\n+        Type.Const(Data.Bool(x == y))\n+      case List(_,             _)                         => Type.Bool\n+    },\n+    basicUntyper)\n+\n+  val Within = Mapping(\n+    \"within\",\n+    \"Determines whether a value is in a given array.\",\n+    Type.Bool, Type.Top :: Type.AnyArray :: Nil,\n+    noSimplification,\n+    partialTyper {\n+      case List(_,             Type.Const(Data.Arr(Nil))) =>\n+        Type.Const(Data.Bool(false))","path":"core/src/main/scala/quasar/std/set.scala","position":78,"original_position":78,"commit_id":"7a417e76e6b64f973da7c2842b00b59c9d3b39de","original_commit_id":"7a417e76e6b64f973da7c2842b00b59c9d3b39de","user":{"login":"jedesah","id":1780116,"avatar_url":"https://avatars.githubusercontent.com/u/1780116?v=3","gravatar_id":"","url":"https://api.github.com/users/jedesah","html_url":"https://github.com/jedesah","followers_url":"https://api.github.com/users/jedesah/followers","following_url":"https://api.github.com/users/jedesah/following{/other_user}","gists_url":"https://api.github.com/users/jedesah/gists{/gist_id}","starred_url":"https://api.github.com/users/jedesah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedesah/subscriptions","organizations_url":"https://api.github.com/users/jedesah/orgs","repos_url":"https://api.github.com/users/jedesah/repos","events_url":"https://api.github.com/users/jedesah/events{/privacy}","received_events_url":"https://api.github.com/users/jedesah/received_events","type":"User","site_admin":false},"body":"Oh man, this is the exact same logic as `IN`, I wonder if there might be a way define the logic once and reuse it for `IN` and `WITHIN`. I kind of wonder why we need `IN` in the first place, seems like it would be nice to have `IN` work on both arrays and sets. Maybe this is explained in the spec for this ticket which I have reason to believe is incorrect in the PR description.","created_at":"2016-02-14T03:06:19Z","updated_at":"2016-02-14T03:06:19Z","html_url":"https://github.com/quasar-analytics/quasar/pull/1085#discussion_r52837151","pull_request_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085","_links":{"self":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments/52837151"},"html":{"href":"https://github.com/quasar-analytics/quasar/pull/1085#discussion_r52837151"},"pull_request":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085"}}},"pull_request":{"url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085","id":58931861,"html_url":"https://github.com/quasar-analytics/quasar/pull/1085","diff_url":"https://github.com/quasar-analytics/quasar/pull/1085.diff","patch_url":"https://github.com/quasar-analytics/quasar/pull/1085.patch","issue_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/1085","number":1085,"state":"open","locked":false,"title":"Fix handling of `IN` for single-element sets.","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"body":"SD-1344 #done\r\n\r\nIn SQL²/MRA,  a value and a single-element set have the same\r\nsemantics. This makes that happen for the `IN` operator, which has been\r\na long-standing problem for the frontend.","created_at":"2016-02-10T18:24:57Z","updated_at":"2016-02-14T03:06:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d944239b14a79b8984ef4e71528f891ae1ff766","assignee":{"login":"jedesah","id":1780116,"avatar_url":"https://avatars.githubusercontent.com/u/1780116?v=3","gravatar_id":"","url":"https://api.github.com/users/jedesah","html_url":"https://github.com/jedesah","followers_url":"https://api.github.com/users/jedesah/followers","following_url":"https://api.github.com/users/jedesah/following{/other_user}","gists_url":"https://api.github.com/users/jedesah/gists{/gist_id}","starred_url":"https://api.github.com/users/jedesah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedesah/subscriptions","organizations_url":"https://api.github.com/users/jedesah/orgs","repos_url":"https://api.github.com/users/jedesah/repos","events_url":"https://api.github.com/users/jedesah/events{/privacy}","received_events_url":"https://api.github.com/users/jedesah/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085/commits","review_comments_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085/comments","review_comment_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/1085/comments","statuses_url":"https://api.github.com/repos/quasar-analytics/quasar/statuses/7a417e76e6b64f973da7c2842b00b59c9d3b39de","head":{"label":"sellout:SD-1344-single-element-set","ref":"SD-1344-single-element-set","sha":"7a417e76e6b64f973da7c2842b00b59c9d3b39de","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"repo":{"id":21178230,"name":"quasar","full_name":"sellout/quasar","owner":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sellout/quasar","description":"The engine for SlamData","fork":true,"url":"https://api.github.com/repos/sellout/quasar","forks_url":"https://api.github.com/repos/sellout/quasar/forks","keys_url":"https://api.github.com/repos/sellout/quasar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sellout/quasar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sellout/quasar/teams","hooks_url":"https://api.github.com/repos/sellout/quasar/hooks","issue_events_url":"https://api.github.com/repos/sellout/quasar/issues/events{/number}","events_url":"https://api.github.com/repos/sellout/quasar/events","assignees_url":"https://api.github.com/repos/sellout/quasar/assignees{/user}","branches_url":"https://api.github.com/repos/sellout/quasar/branches{/branch}","tags_url":"https://api.github.com/repos/sellout/quasar/tags","blobs_url":"https://api.github.com/repos/sellout/quasar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sellout/quasar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sellout/quasar/git/refs{/sha}","trees_url":"https://api.github.com/repos/sellout/quasar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sellout/quasar/statuses/{sha}","languages_url":"https://api.github.com/repos/sellout/quasar/languages","stargazers_url":"https://api.github.com/repos/sellout/quasar/stargazers","contributors_url":"https://api.github.com/repos/sellout/quasar/contributors","subscribers_url":"https://api.github.com/repos/sellout/quasar/subscribers","subscription_url":"https://api.github.com/repos/sellout/quasar/subscription","commits_url":"https://api.github.com/repos/sellout/quasar/commits{/sha}","git_commits_url":"https://api.github.com/repos/sellout/quasar/git/commits{/sha}","comments_url":"https://api.github.com/repos/sellout/quasar/comments{/number}","issue_comment_url":"https://api.github.com/repos/sellout/quasar/issues/comments{/number}","contents_url":"https://api.github.com/repos/sellout/quasar/contents/{+path}","compare_url":"https://api.github.com/repos/sellout/quasar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sellout/quasar/merges","archive_url":"https://api.github.com/repos/sellout/quasar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sellout/quasar/downloads","issues_url":"https://api.github.com/repos/sellout/quasar/issues{/number}","pulls_url":"https://api.github.com/repos/sellout/quasar/pulls{/number}","milestones_url":"https://api.github.com/repos/sellout/quasar/milestones{/number}","notifications_url":"https://api.github.com/repos/sellout/quasar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sellout/quasar/labels{/name}","releases_url":"https://api.github.com/repos/sellout/quasar/releases{/id}","deployments_url":"https://api.github.com/repos/sellout/quasar/deployments","created_at":"2014-06-24T19:38:07Z","updated_at":"2016-01-08T04:24:08Z","pushed_at":"2016-02-13T18:35:50Z","git_url":"git://github.com/sellout/quasar.git","ssh_url":"git@github.com:sellout/quasar.git","clone_url":"https://github.com/sellout/quasar.git","svn_url":"https://github.com/sellout/quasar","homepage":null,"size":9324,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"quasar-analytics:master","ref":"master","sha":"3939397264729b95e7271183a6cd6003a06f4fdc","user":{"login":"quasar-analytics","id":15095906,"avatar_url":"https://avatars.githubusercontent.com/u/15095906?v=3","gravatar_id":"","url":"https://api.github.com/users/quasar-analytics","html_url":"https://github.com/quasar-analytics","followers_url":"https://api.github.com/users/quasar-analytics/followers","following_url":"https://api.github.com/users/quasar-analytics/following{/other_user}","gists_url":"https://api.github.com/users/quasar-analytics/gists{/gist_id}","starred_url":"https://api.github.com/users/quasar-analytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quasar-analytics/subscriptions","organizations_url":"https://api.github.com/users/quasar-analytics/orgs","repos_url":"https://api.github.com/users/quasar-analytics/repos","events_url":"https://api.github.com/users/quasar-analytics/events{/privacy}","received_events_url":"https://api.github.com/users/quasar-analytics/received_events","type":"Organization","site_admin":false},"repo":{"id":16515058,"name":"quasar","full_name":"quasar-analytics/quasar","owner":{"login":"quasar-analytics","id":15095906,"avatar_url":"https://avatars.githubusercontent.com/u/15095906?v=3","gravatar_id":"","url":"https://api.github.com/users/quasar-analytics","html_url":"https://github.com/quasar-analytics","followers_url":"https://api.github.com/users/quasar-analytics/followers","following_url":"https://api.github.com/users/quasar-analytics/following{/other_user}","gists_url":"https://api.github.com/users/quasar-analytics/gists{/gist_id}","starred_url":"https://api.github.com/users/quasar-analytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quasar-analytics/subscriptions","organizations_url":"https://api.github.com/users/quasar-analytics/orgs","repos_url":"https://api.github.com/users/quasar-analytics/repos","events_url":"https://api.github.com/users/quasar-analytics/events{/privacy}","received_events_url":"https://api.github.com/users/quasar-analytics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quasar-analytics/quasar","description":"A NoSQL analytics engine that embraces post-relational analytics and pushes computation to the data.","fork":false,"url":"https://api.github.com/repos/quasar-analytics/quasar","forks_url":"https://api.github.com/repos/quasar-analytics/quasar/forks","keys_url":"https://api.github.com/repos/quasar-analytics/quasar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quasar-analytics/quasar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quasar-analytics/quasar/teams","hooks_url":"https://api.github.com/repos/quasar-analytics/quasar/hooks","issue_events_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/events{/number}","events_url":"https://api.github.com/repos/quasar-analytics/quasar/events","assignees_url":"https://api.github.com/repos/quasar-analytics/quasar/assignees{/user}","branches_url":"https://api.github.com/repos/quasar-analytics/quasar/branches{/branch}","tags_url":"https://api.github.com/repos/quasar-analytics/quasar/tags","blobs_url":"https://api.github.com/repos/quasar-analytics/quasar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quasar-analytics/quasar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quasar-analytics/quasar/git/refs{/sha}","trees_url":"https://api.github.com/repos/quasar-analytics/quasar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quasar-analytics/quasar/statuses/{sha}","languages_url":"https://api.github.com/repos/quasar-analytics/quasar/languages","stargazers_url":"https://api.github.com/repos/quasar-analytics/quasar/stargazers","contributors_url":"https://api.github.com/repos/quasar-analytics/quasar/contributors","subscribers_url":"https://api.github.com/repos/quasar-analytics/quasar/subscribers","subscription_url":"https://api.github.com/repos/quasar-analytics/quasar/subscription","commits_url":"https://api.github.com/repos/quasar-analytics/quasar/commits{/sha}","git_commits_url":"https://api.github.com/repos/quasar-analytics/quasar/git/commits{/sha}","comments_url":"https://api.github.com/repos/quasar-analytics/quasar/comments{/number}","issue_comment_url":"https://api.github.com/repos/quasar-analytics/quasar/issues/comments{/number}","contents_url":"https://api.github.com/repos/quasar-analytics/quasar/contents/{+path}","compare_url":"https://api.github.com/repos/quasar-analytics/quasar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quasar-analytics/quasar/merges","archive_url":"https://api.github.com/repos/quasar-analytics/quasar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quasar-analytics/quasar/downloads","issues_url":"https://api.github.com/repos/quasar-analytics/quasar/issues{/number}","pulls_url":"https://api.github.com/repos/quasar-analytics/quasar/pulls{/number}","milestones_url":"https://api.github.com/repos/quasar-analytics/quasar/milestones{/number}","notifications_url":"https://api.github.com/repos/quasar-analytics/quasar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quasar-analytics/quasar/labels{/name}","releases_url":"https://api.github.com/repos/quasar-analytics/quasar/releases{/id}","deployments_url":"https://api.github.com/repos/quasar-analytics/quasar/deployments","created_at":"2014-02-04T15:01:27Z","updated_at":"2016-02-08T22:12:21Z","pushed_at":"2016-02-13T18:36:41Z","git_url":"git://github.com/quasar-analytics/quasar.git","ssh_url":"git@github.com:quasar-analytics/quasar.git","clone_url":"https://github.com/quasar-analytics/quasar.git","svn_url":"https://github.com/quasar-analytics/quasar","homepage":"http://quasar-analytics.org","size":9598,"stargazers_count":211,"watchers_count":211,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":4,"forks":35,"open_issues":4,"watchers":211,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085"},"html":{"href":"https://github.com/quasar-analytics/quasar/pull/1085"},"issue":{"href":"https://api.github.com/repos/quasar-analytics/quasar/issues/1085"},"comments":{"href":"https://api.github.com/repos/quasar-analytics/quasar/issues/1085/comments"},"review_comments":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085/comments"},"review_comment":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quasar-analytics/quasar/pulls/1085/commits"},"statuses":{"href":"https://api.github.com/repos/quasar-analytics/quasar/statuses/7a417e76e6b64f973da7c2842b00b59c9d3b39de"}}}}