{"action":"created","comment":{"url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/comments/220608903","pull_request_review_id":159054896,"id":220608903,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMDYwODkwMw==","diff_hunk":"@@ -0,0 +1,53 @@\n+{-# LANGUAGE ConstraintKinds  #-}\n+{-# LANGUAGE FlexibleContexts #-}\n+\n+module Language.Plutus.CoreToPLC.Types where\n+\n+import           Language.Plutus.CoreToPLC.Error\n+\n+import qualified Language.PlutusCore             as PLC\n+import           Language.PlutusCore.Quote\n+\n+import qualified GhcPlugins                      as GHC\n+\n+import           Control.Monad.Except\n+import           Control.Monad.Reader\n+import           Control.Monad.State\n+\n+import qualified Data.List.NonEmpty              as NE\n+import qualified Data.Map                        as Map\n+import qualified Data.Text                       as T\n+\n+type PLCExpr = PLC.Term PLC.TyName PLC.Name ()\n+type PLCType = PLC.Type PLC.TyName ()\n+\n+type ConvError = WithContext T.Text (Error ())\n+\n+type PrimTerms = Map.Map GHC.Name (Quote PLCExpr)\n+type PrimTypes = Map.Map GHC.Name (Quote PLCType)\n+\n+newtype ConversionOptions = ConversionOptions { coCheckValueRestriction :: Bool }\n+\n+type ConvertingContext = (ConversionOptions, GHC.DynFlags, PrimTerms, PrimTypes, ScopeStack)\n+\n+data EvalState a = Done | InProgress a\n+type TypeDefs = Map.Map GHC.Name (EvalState (PLC.TyName ()))\n+newtype ConvertingState = ConvertingState { csTypeDefs :: TypeDefs }\n+\n+-- See Note [Scopes]\n+type Converting m = (Monad m, MonadError ConvError m, MonadQuote m, MonadReader ConvertingContext m, MonadState ConvertingState m)\n+\n+{- Note [Scopes]\n+We need a notion of scope, because we have to make sure that if we convert a GHC\n+Var into a variable, then we always convert it into the same variable, while also making\n+sure that if we encounter multiple things with the same name we produce fresh variables\n+appropriately.","path":"core-to-plc/src/Language/Plutus/CoreToPLC/Types.hs","position":44,"original_position":44,"commit_id":"67de4010cf4acc8349ca146136f6673b2f4f96d6","original_commit_id":"67de4010cf4acc8349ca146136f6673b2f4f96d6","user":{"login":"michaelpj","id":1699466,"node_id":"MDQ6VXNlcjE2OTk0NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/1699466?v=4","gravatar_id":"","url":"https://api.github.com/users/michaelpj","html_url":"https://github.com/michaelpj","followers_url":"https://api.github.com/users/michaelpj/followers","following_url":"https://api.github.com/users/michaelpj/following{/other_user}","gists_url":"https://api.github.com/users/michaelpj/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelpj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelpj/subscriptions","organizations_url":"https://api.github.com/users/michaelpj/orgs","repos_url":"https://api.github.com/users/michaelpj/repos","events_url":"https://api.github.com/users/michaelpj/events{/privacy}","received_events_url":"https://api.github.com/users/michaelpj/received_events","type":"User","site_admin":false},"body":"We do have GHC uniques, but we'd need to map them into our uniques, which is tricky, or just treat them as part of the name, which is ugly.\r\n\r\nIt's easy enough to carry scopes, it makes me more sure that it's correct without having to worry about the global uniqueness property, and it gives us better names.","created_at":"2018-09-26T15:19:07Z","updated_at":"2018-09-26T15:19:07Z","html_url":"https://github.com/input-output-hk/plutus-prototype/pull/143#discussion_r220608903","pull_request_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/comments/220608903"},"html":{"href":"https://github.com/input-output-hk/plutus-prototype/pull/143#discussion_r220608903"},"pull_request":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143"}},"in_reply_to_id":220541072},"pull_request":{"url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143","id":218085307,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4MDg1MzA3","html_url":"https://github.com/input-output-hk/plutus-prototype/pull/143","diff_url":"https://github.com/input-output-hk/plutus-prototype/pull/143.diff","patch_url":"https://github.com/input-output-hk/plutus-prototype/pull/143.patch","issue_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues/143","number":143,"state":"open","locked":false,"title":"core-to-plc: handle self-recursive types","user":{"login":"michaelpj","id":1699466,"node_id":"MDQ6VXNlcjE2OTk0NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/1699466?v=4","gravatar_id":"","url":"https://api.github.com/users/michaelpj","html_url":"https://github.com/michaelpj","followers_url":"https://api.github.com/users/michaelpj/followers","following_url":"https://api.github.com/users/michaelpj/following{/other_user}","gists_url":"https://api.github.com/users/michaelpj/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelpj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelpj/subscriptions","organizations_url":"https://api.github.com/users/michaelpj/orgs","repos_url":"https://api.github.com/users/michaelpj/repos","events_url":"https://api.github.com/users/michaelpj/events{/privacy}","received_events_url":"https://api.github.com/users/michaelpj/received_events","type":"User","site_admin":false},"body":"This means we can handle lists at last! You can't write many useful functions on them since we don't have recursive functions yet, but still, progress. (And I show that we can do perfect binary trees, too.)\r\n\r\nThere are some wrinkles:\r\n- I had to turn the value restriction check off in some cases, because checking that a term is a value also currently checks if it has normalized types in it, which we don't. This won't be a problem soon, I hope!\r\n- Getting type dependency information out of GHC is a pain. I could do this case, but I'm not sure how I'm going to do mutually-recursive types...\r\n- We rely on doing fixpoints-outside-lambdas, so translation is uniform and it's easy to get the pattern functor of a type - just strip off the fixpoint (*and* any type applciations - since it might appear in an elimination context).\r\n- We just check whether things are recursive over and over again. I should start caching this stuff at some point.\r\n\r\nThere is a bunch of churn in the tests because we generate a few more names every time we see a type, so things get higher uniques.","created_at":"2018-09-25T19:00:30Z","updated_at":"2018-09-26T15:19:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f452bca5fe8eca9b0dba0da12ae8ec7acf85160","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mchakravarty","id":709989,"node_id":"MDQ6VXNlcjcwOTk4OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/709989?v=4","gravatar_id":"","url":"https://api.github.com/users/mchakravarty","html_url":"https://github.com/mchakravarty","followers_url":"https://api.github.com/users/mchakravarty/followers","following_url":"https://api.github.com/users/mchakravarty/following{/other_user}","gists_url":"https://api.github.com/users/mchakravarty/gists{/gist_id}","starred_url":"https://api.github.com/users/mchakravarty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchakravarty/subscriptions","organizations_url":"https://api.github.com/users/mchakravarty/orgs","repos_url":"https://api.github.com/users/mchakravarty/repos","events_url":"https://api.github.com/users/mchakravarty/events{/privacy}","received_events_url":"https://api.github.com/users/mchakravarty/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143/commits","review_comments_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143/comments","review_comment_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/comments{/number}","comments_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues/143/comments","statuses_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/statuses/67de4010cf4acc8349ca146136f6673b2f4f96d6","head":{"label":"michaelpj:imp/self-recursive-types","ref":"imp/self-recursive-types","sha":"67de4010cf4acc8349ca146136f6673b2f4f96d6","user":{"login":"michaelpj","id":1699466,"node_id":"MDQ6VXNlcjE2OTk0NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/1699466?v=4","gravatar_id":"","url":"https://api.github.com/users/michaelpj","html_url":"https://github.com/michaelpj","followers_url":"https://api.github.com/users/michaelpj/followers","following_url":"https://api.github.com/users/michaelpj/following{/other_user}","gists_url":"https://api.github.com/users/michaelpj/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelpj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelpj/subscriptions","organizations_url":"https://api.github.com/users/michaelpj/orgs","repos_url":"https://api.github.com/users/michaelpj/repos","events_url":"https://api.github.com/users/michaelpj/events{/privacy}","received_events_url":"https://api.github.com/users/michaelpj/received_events","type":"User","site_admin":false},"repo":{"id":141337224,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEzMzcyMjQ=","name":"plutus-prototype","full_name":"michaelpj/plutus-prototype","private":false,"owner":{"login":"michaelpj","id":1699466,"node_id":"MDQ6VXNlcjE2OTk0NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/1699466?v=4","gravatar_id":"","url":"https://api.github.com/users/michaelpj","html_url":"https://github.com/michaelpj","followers_url":"https://api.github.com/users/michaelpj/followers","following_url":"https://api.github.com/users/michaelpj/following{/other_user}","gists_url":"https://api.github.com/users/michaelpj/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelpj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelpj/subscriptions","organizations_url":"https://api.github.com/users/michaelpj/orgs","repos_url":"https://api.github.com/users/michaelpj/repos","events_url":"https://api.github.com/users/michaelpj/events{/privacy}","received_events_url":"https://api.github.com/users/michaelpj/received_events","type":"User","site_admin":false},"html_url":"https://github.com/michaelpj/plutus-prototype","description":null,"fork":true,"url":"https://api.github.com/repos/michaelpj/plutus-prototype","forks_url":"https://api.github.com/repos/michaelpj/plutus-prototype/forks","keys_url":"https://api.github.com/repos/michaelpj/plutus-prototype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaelpj/plutus-prototype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaelpj/plutus-prototype/teams","hooks_url":"https://api.github.com/repos/michaelpj/plutus-prototype/hooks","issue_events_url":"https://api.github.com/repos/michaelpj/plutus-prototype/issues/events{/number}","events_url":"https://api.github.com/repos/michaelpj/plutus-prototype/events","assignees_url":"https://api.github.com/repos/michaelpj/plutus-prototype/assignees{/user}","branches_url":"https://api.github.com/repos/michaelpj/plutus-prototype/branches{/branch}","tags_url":"https://api.github.com/repos/michaelpj/plutus-prototype/tags","blobs_url":"https://api.github.com/repos/michaelpj/plutus-prototype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaelpj/plutus-prototype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaelpj/plutus-prototype/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaelpj/plutus-prototype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaelpj/plutus-prototype/statuses/{sha}","languages_url":"https://api.github.com/repos/michaelpj/plutus-prototype/languages","stargazers_url":"https://api.github.com/repos/michaelpj/plutus-prototype/stargazers","contributors_url":"https://api.github.com/repos/michaelpj/plutus-prototype/contributors","subscribers_url":"https://api.github.com/repos/michaelpj/plutus-prototype/subscribers","subscription_url":"https://api.github.com/repos/michaelpj/plutus-prototype/subscription","commits_url":"https://api.github.com/repos/michaelpj/plutus-prototype/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaelpj/plutus-prototype/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaelpj/plutus-prototype/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaelpj/plutus-prototype/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaelpj/plutus-prototype/contents/{+path}","compare_url":"https://api.github.com/repos/michaelpj/plutus-prototype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaelpj/plutus-prototype/merges","archive_url":"https://api.github.com/repos/michaelpj/plutus-prototype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaelpj/plutus-prototype/downloads","issues_url":"https://api.github.com/repos/michaelpj/plutus-prototype/issues{/number}","pulls_url":"https://api.github.com/repos/michaelpj/plutus-prototype/pulls{/number}","milestones_url":"https://api.github.com/repos/michaelpj/plutus-prototype/milestones{/number}","notifications_url":"https://api.github.com/repos/michaelpj/plutus-prototype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaelpj/plutus-prototype/labels{/name}","releases_url":"https://api.github.com/repos/michaelpj/plutus-prototype/releases{/id}","deployments_url":"https://api.github.com/repos/michaelpj/plutus-prototype/deployments","created_at":"2018-07-17T19:57:14Z","updated_at":"2018-07-17T19:57:16Z","pushed_at":"2018-09-26T11:50:06Z","git_url":"git://github.com/michaelpj/plutus-prototype.git","ssh_url":"git@github.com:michaelpj/plutus-prototype.git","clone_url":"https://github.com/michaelpj/plutus-prototype.git","svn_url":"https://github.com/michaelpj/plutus-prototype","homepage":null,"size":8007,"stargazers_count":0,"watchers_count":0,"language":"Nix","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"input-output-hk:master","ref":"master","sha":"45e3a40fdb9bf4c1433b6be2005560989a45f691","user":{"login":"input-output-hk","id":12909177,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTA5MTc3","avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"repo":{"id":73861563,"node_id":"MDEwOlJlcG9zaXRvcnk3Mzg2MTU2Mw==","name":"plutus-prototype","full_name":"input-output-hk/plutus-prototype","private":false,"owner":{"login":"input-output-hk","id":12909177,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTA5MTc3","avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/input-output-hk/plutus-prototype","description":"The Plutus language reference implementation and tools","fork":false,"url":"https://api.github.com/repos/input-output-hk/plutus-prototype","forks_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/forks","keys_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/teams","hooks_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/hooks","issue_events_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues/events{/number}","events_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/events","assignees_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/assignees{/user}","branches_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/branches{/branch}","tags_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/tags","blobs_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/git/refs{/sha}","trees_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/statuses/{sha}","languages_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/languages","stargazers_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/stargazers","contributors_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/contributors","subscribers_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/subscribers","subscription_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/subscription","commits_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/commits{/sha}","git_commits_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/git/commits{/sha}","comments_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/comments{/number}","issue_comment_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues/comments{/number}","contents_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/contents/{+path}","compare_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/merges","archive_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/downloads","issues_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues{/number}","pulls_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls{/number}","milestones_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/milestones{/number}","notifications_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/labels{/name}","releases_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/releases{/id}","deployments_url":"https://api.github.com/repos/input-output-hk/plutus-prototype/deployments","created_at":"2016-11-15T22:38:43Z","updated_at":"2018-09-26T14:58:57Z","pushed_at":"2018-09-26T14:58:55Z","git_url":"git://github.com/input-output-hk/plutus-prototype.git","ssh_url":"git@github.com:input-output-hk/plutus-prototype.git","clone_url":"https://github.com/input-output-hk/plutus-prototype.git","svn_url":"https://github.com/input-output-hk/plutus-prototype","homepage":"","size":7963,"stargazers_count":131,"watchers_count":131,"language":"Haskell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":23,"open_issues":11,"watchers":131,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143"},"html":{"href":"https://github.com/input-output-hk/plutus-prototype/pull/143"},"issue":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues/143"},"comments":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/issues/143/comments"},"review_comments":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143/comments"},"review_comment":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/pulls/143/commits"},"statuses":{"href":"https://api.github.com/repos/input-output-hk/plutus-prototype/statuses/67de4010cf4acc8349ca146136f6673b2f4f96d6"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"michaelpj"}}