{"action":"created","comment":{"url":"https://api.github.com/repos/purescript/purescript/pulls/comments/89935300","pull_request_review_id":10463055,"id":89935300,"diff_hunk":"@@ -155,18 +155,28 @@ checkDuplicateTypeArguments args = for_ firstDup $ \\dup ->\n   firstDup = listToMaybe $ args \\\\ nub args\n \n checkTypeClassInstance\n-  :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)\n-  => ModuleName\n+  :: (MonadState CheckState m, MonadError MultipleErrors m)\n+  => TypeClassData\n+  -> Int -- type argument index\n   -> Type\n   -> m ()\n-checkTypeClassInstance _ (TypeVar _) = return ()\n-checkTypeClassInstance _ (TypeLevelString _) = return ()\n-checkTypeClassInstance _ (TypeConstructor ctor) = do\n-  env <- getEnv\n-  when (ctor `M.member` typeSynonyms env) . throwError . errorMessage $ TypeSynonymInstance\n-  return ()\n-checkTypeClassInstance m (TypeApp t1 t2) = checkTypeClassInstance m t1 >> checkTypeClassInstance m t2\n-checkTypeClassInstance _ ty = throwError . errorMessage $ InvalidInstanceHead ty\n+checkTypeClassInstance cls i = check where\n+  -- is this argument fully determined via fundeps\n+  isFunDepDetermined = (Any False, Any True) == foldMap determining (typeClassDependencies cls)\n+    where determining fd = (Any (i `elem` fdDeterminers fd),\n+                            Any (i `elem` fdDetermined fd))","path":"src/Language/PureScript/TypeChecker.hs","position":32,"original_position":32,"commit_id":"3c964e2beb892805ac24b65e60a55eb6e6c7b1cc","original_commit_id":"3c964e2beb892805ac24b65e60a55eb6e6c7b1cc","user":{"login":"paf31","id":630306,"avatar_url":"https://avatars.githubusercontent.com/u/630306?v=3","gravatar_id":"","url":"https://api.github.com/users/paf31","html_url":"https://github.com/paf31","followers_url":"https://api.github.com/users/paf31/followers","following_url":"https://api.github.com/users/paf31/following{/other_user}","gists_url":"https://api.github.com/users/paf31/gists{/gist_id}","starred_url":"https://api.github.com/users/paf31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paf31/subscriptions","organizations_url":"https://api.github.com/users/paf31/orgs","repos_url":"https://api.github.com/users/paf31/repos","events_url":"https://api.github.com/users/paf31/events{/privacy}","received_events_url":"https://api.github.com/users/paf31/received_events","type":"User","site_admin":false},"body":"Well let's write out explicitly what we want.\r\n\r\nWe want to prevent the user from casing on types in rows (i.e. labels in rows shouldn't determine behavior).\r\n\r\nSo we can't have two _different_ instances with different rows in some type argument and every other type argument the same. \r\n\r\nOne way to achieve that with a single functional dependency (e.g. `MonadState`, where `m -> s`) is to say that we have a functional relationship on type arguments (`m` determines `s`), so changing the result of the function forces the argument to change (if `s` differs, `m` must differ too). If the input types are the same but the outputs differ, that will lead to overlap.\r\n\r\nIn general, there must be some type argument which is forced to differ between the two instances. We can find the set of such type arguments by following functional dependencies backwards, but I think to do this properly we need a full (static) overlap check, which is why I suggest limiting things to a single functional dependency for now.","created_at":"2016-11-29T03:28:52Z","updated_at":"2016-11-29T03:28:52Z","html_url":"https://github.com/purescript/purescript/pull/2451#discussion_r89935300","pull_request_url":"https://api.github.com/repos/purescript/purescript/pulls/2451","_links":{"self":{"href":"https://api.github.com/repos/purescript/purescript/pulls/comments/89935300"},"html":{"href":"https://github.com/purescript/purescript/pull/2451#discussion_r89935300"},"pull_request":{"href":"https://api.github.com/repos/purescript/purescript/pulls/2451"}}},"pull_request":{"url":"https://api.github.com/repos/purescript/purescript/pulls/2451","id":95373975,"html_url":"https://github.com/purescript/purescript/pull/2451","diff_url":"https://github.com/purescript/purescript/pull/2451.diff","patch_url":"https://github.com/purescript/purescript/pull/2451.patch","issue_url":"https://api.github.com/repos/purescript/purescript/issues/2451","number":2451,"state":"open","locked":false,"title":"Add support for rows in instance head under fundeps","user":{"login":"LiamGoodacre","id":1189645,"avatar_url":"https://avatars.githubusercontent.com/u/1189645?v=3","gravatar_id":"","url":"https://api.github.com/users/LiamGoodacre","html_url":"https://github.com/LiamGoodacre","followers_url":"https://api.github.com/users/LiamGoodacre/followers","following_url":"https://api.github.com/users/LiamGoodacre/following{/other_user}","gists_url":"https://api.github.com/users/LiamGoodacre/gists{/gist_id}","starred_url":"https://api.github.com/users/LiamGoodacre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiamGoodacre/subscriptions","organizations_url":"https://api.github.com/users/LiamGoodacre/orgs","repos_url":"https://api.github.com/users/LiamGoodacre/repos","events_url":"https://api.github.com/users/LiamGoodacre/events{/privacy}","received_events_url":"https://api.github.com/users/LiamGoodacre/received_events","type":"User","site_admin":false},"body":"For #2376 ","created_at":"2016-11-26T15:11:05Z","updated_at":"2016-11-29T03:28:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a0f1c33184f414501b9fb5983d8034696406251","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/purescript/purescript/pulls/2451/commits","review_comments_url":"https://api.github.com/repos/purescript/purescript/pulls/2451/comments","review_comment_url":"https://api.github.com/repos/purescript/purescript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/purescript/purescript/issues/2451/comments","statuses_url":"https://api.github.com/repos/purescript/purescript/statuses/3c964e2beb892805ac24b65e60a55eb6e6c7b1cc","head":{"label":"LiamGoodacre:feature/instance-head-rows","ref":"feature/instance-head-rows","sha":"3c964e2beb892805ac24b65e60a55eb6e6c7b1cc","user":{"login":"LiamGoodacre","id":1189645,"avatar_url":"https://avatars.githubusercontent.com/u/1189645?v=3","gravatar_id":"","url":"https://api.github.com/users/LiamGoodacre","html_url":"https://github.com/LiamGoodacre","followers_url":"https://api.github.com/users/LiamGoodacre/followers","following_url":"https://api.github.com/users/LiamGoodacre/following{/other_user}","gists_url":"https://api.github.com/users/LiamGoodacre/gists{/gist_id}","starred_url":"https://api.github.com/users/LiamGoodacre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiamGoodacre/subscriptions","organizations_url":"https://api.github.com/users/LiamGoodacre/orgs","repos_url":"https://api.github.com/users/LiamGoodacre/repos","events_url":"https://api.github.com/users/LiamGoodacre/events{/privacy}","received_events_url":"https://api.github.com/users/LiamGoodacre/received_events","type":"User","site_admin":false},"repo":{"id":54824356,"name":"purescript","full_name":"LiamGoodacre/purescript","owner":{"login":"LiamGoodacre","id":1189645,"avatar_url":"https://avatars.githubusercontent.com/u/1189645?v=3","gravatar_id":"","url":"https://api.github.com/users/LiamGoodacre","html_url":"https://github.com/LiamGoodacre","followers_url":"https://api.github.com/users/LiamGoodacre/followers","following_url":"https://api.github.com/users/LiamGoodacre/following{/other_user}","gists_url":"https://api.github.com/users/LiamGoodacre/gists{/gist_id}","starred_url":"https://api.github.com/users/LiamGoodacre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiamGoodacre/subscriptions","organizations_url":"https://api.github.com/users/LiamGoodacre/orgs","repos_url":"https://api.github.com/users/LiamGoodacre/repos","events_url":"https://api.github.com/users/LiamGoodacre/events{/privacy}","received_events_url":"https://api.github.com/users/LiamGoodacre/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LiamGoodacre/purescript","description":"A small strongly typed language that compiles to Javascript","fork":true,"url":"https://api.github.com/repos/LiamGoodacre/purescript","forks_url":"https://api.github.com/repos/LiamGoodacre/purescript/forks","keys_url":"https://api.github.com/repos/LiamGoodacre/purescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LiamGoodacre/purescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LiamGoodacre/purescript/teams","hooks_url":"https://api.github.com/repos/LiamGoodacre/purescript/hooks","issue_events_url":"https://api.github.com/repos/LiamGoodacre/purescript/issues/events{/number}","events_url":"https://api.github.com/repos/LiamGoodacre/purescript/events","assignees_url":"https://api.github.com/repos/LiamGoodacre/purescript/assignees{/user}","branches_url":"https://api.github.com/repos/LiamGoodacre/purescript/branches{/branch}","tags_url":"https://api.github.com/repos/LiamGoodacre/purescript/tags","blobs_url":"https://api.github.com/repos/LiamGoodacre/purescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LiamGoodacre/purescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LiamGoodacre/purescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/LiamGoodacre/purescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LiamGoodacre/purescript/statuses/{sha}","languages_url":"https://api.github.com/repos/LiamGoodacre/purescript/languages","stargazers_url":"https://api.github.com/repos/LiamGoodacre/purescript/stargazers","contributors_url":"https://api.github.com/repos/LiamGoodacre/purescript/contributors","subscribers_url":"https://api.github.com/repos/LiamGoodacre/purescript/subscribers","subscription_url":"https://api.github.com/repos/LiamGoodacre/purescript/subscription","commits_url":"https://api.github.com/repos/LiamGoodacre/purescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/LiamGoodacre/purescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/LiamGoodacre/purescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/LiamGoodacre/purescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/LiamGoodacre/purescript/contents/{+path}","compare_url":"https://api.github.com/repos/LiamGoodacre/purescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LiamGoodacre/purescript/merges","archive_url":"https://api.github.com/repos/LiamGoodacre/purescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LiamGoodacre/purescript/downloads","issues_url":"https://api.github.com/repos/LiamGoodacre/purescript/issues{/number}","pulls_url":"https://api.github.com/repos/LiamGoodacre/purescript/pulls{/number}","milestones_url":"https://api.github.com/repos/LiamGoodacre/purescript/milestones{/number}","notifications_url":"https://api.github.com/repos/LiamGoodacre/purescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LiamGoodacre/purescript/labels{/name}","releases_url":"https://api.github.com/repos/LiamGoodacre/purescript/releases{/id}","deployments_url":"https://api.github.com/repos/LiamGoodacre/purescript/deployments","created_at":"2016-03-27T11:00:00Z","updated_at":"2016-03-27T11:00:01Z","pushed_at":"2016-11-28T23:35:03Z","git_url":"git://github.com/LiamGoodacre/purescript.git","ssh_url":"git@github.com:LiamGoodacre/purescript.git","clone_url":"https://github.com/LiamGoodacre/purescript.git","svn_url":"https://github.com/LiamGoodacre/purescript","homepage":"http://purescript.org","size":7945,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"purescript:master","ref":"master","sha":"8c324a0c0548ae8db3cf215fbf9bfe137994b131","user":{"login":"purescript","id":6556677,"avatar_url":"https://avatars.githubusercontent.com/u/6556677?v=3","gravatar_id":"","url":"https://api.github.com/users/purescript","html_url":"https://github.com/purescript","followers_url":"https://api.github.com/users/purescript/followers","following_url":"https://api.github.com/users/purescript/following{/other_user}","gists_url":"https://api.github.com/users/purescript/gists{/gist_id}","starred_url":"https://api.github.com/users/purescript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purescript/subscriptions","organizations_url":"https://api.github.com/users/purescript/orgs","repos_url":"https://api.github.com/users/purescript/repos","events_url":"https://api.github.com/users/purescript/events{/privacy}","received_events_url":"https://api.github.com/users/purescript/received_events","type":"Organization","site_admin":false},"repo":{"id":13206906,"name":"purescript","full_name":"purescript/purescript","owner":{"login":"purescript","id":6556677,"avatar_url":"https://avatars.githubusercontent.com/u/6556677?v=3","gravatar_id":"","url":"https://api.github.com/users/purescript","html_url":"https://github.com/purescript","followers_url":"https://api.github.com/users/purescript/followers","following_url":"https://api.github.com/users/purescript/following{/other_user}","gists_url":"https://api.github.com/users/purescript/gists{/gist_id}","starred_url":"https://api.github.com/users/purescript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purescript/subscriptions","organizations_url":"https://api.github.com/users/purescript/orgs","repos_url":"https://api.github.com/users/purescript/repos","events_url":"https://api.github.com/users/purescript/events{/privacy}","received_events_url":"https://api.github.com/users/purescript/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/purescript/purescript","description":"A small strongly typed language that compiles to Javascript","fork":false,"url":"https://api.github.com/repos/purescript/purescript","forks_url":"https://api.github.com/repos/purescript/purescript/forks","keys_url":"https://api.github.com/repos/purescript/purescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/purescript/purescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/purescript/purescript/teams","hooks_url":"https://api.github.com/repos/purescript/purescript/hooks","issue_events_url":"https://api.github.com/repos/purescript/purescript/issues/events{/number}","events_url":"https://api.github.com/repos/purescript/purescript/events","assignees_url":"https://api.github.com/repos/purescript/purescript/assignees{/user}","branches_url":"https://api.github.com/repos/purescript/purescript/branches{/branch}","tags_url":"https://api.github.com/repos/purescript/purescript/tags","blobs_url":"https://api.github.com/repos/purescript/purescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/purescript/purescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/purescript/purescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/purescript/purescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/purescript/purescript/statuses/{sha}","languages_url":"https://api.github.com/repos/purescript/purescript/languages","stargazers_url":"https://api.github.com/repos/purescript/purescript/stargazers","contributors_url":"https://api.github.com/repos/purescript/purescript/contributors","subscribers_url":"https://api.github.com/repos/purescript/purescript/subscribers","subscription_url":"https://api.github.com/repos/purescript/purescript/subscription","commits_url":"https://api.github.com/repos/purescript/purescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/purescript/purescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/purescript/purescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/purescript/purescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/purescript/purescript/contents/{+path}","compare_url":"https://api.github.com/repos/purescript/purescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/purescript/purescript/merges","archive_url":"https://api.github.com/repos/purescript/purescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/purescript/purescript/downloads","issues_url":"https://api.github.com/repos/purescript/purescript/issues{/number}","pulls_url":"https://api.github.com/repos/purescript/purescript/pulls{/number}","milestones_url":"https://api.github.com/repos/purescript/purescript/milestones{/number}","notifications_url":"https://api.github.com/repos/purescript/purescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/purescript/purescript/labels{/name}","releases_url":"https://api.github.com/repos/purescript/purescript/releases{/id}","deployments_url":"https://api.github.com/repos/purescript/purescript/deployments","created_at":"2013-09-30T05:29:23Z","updated_at":"2016-11-29T02:46:46Z","pushed_at":"2016-11-29T03:00:48Z","git_url":"git://github.com/purescript/purescript.git","ssh_url":"git@github.com:purescript/purescript.git","clone_url":"https://github.com/purescript/purescript.git","svn_url":"https://github.com/purescript/purescript","homepage":"http://purescript.org","size":11116,"stargazers_count":3057,"watchers_count":3057,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":254,"mirror_url":null,"open_issues_count":159,"forks":254,"open_issues":159,"watchers":3057,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/purescript/purescript/pulls/2451"},"html":{"href":"https://github.com/purescript/purescript/pull/2451"},"issue":{"href":"https://api.github.com/repos/purescript/purescript/issues/2451"},"comments":{"href":"https://api.github.com/repos/purescript/purescript/issues/2451/comments"},"review_comments":{"href":"https://api.github.com/repos/purescript/purescript/pulls/2451/comments"},"review_comment":{"href":"https://api.github.com/repos/purescript/purescript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/purescript/purescript/pulls/2451/commits"},"statuses":{"href":"https://api.github.com/repos/purescript/purescript/statuses/3c964e2beb892805ac24b65e60a55eb6e6c7b1cc"}}}}
{"actor":{"display_login":"paf31"}}