{"action":"created","comment":{"url":"https://api.github.com/repos/purescript/purescript-refs/pulls/comments/72907221","id":72907221,"diff_hunk":"@@ -1,35 +1,41 @@\n--- | This module defines an effect and actions for working with\n--- | global mutable variables.\n+-- | This module defines an effect and actions for working with global mutable\n+-- | variables.\n -- |\n--- | _Note_: The `Control.Monad.ST` provides a _safe_ alternative\n--- | to global mutable variables when mutation is restricted to a\n--- | local scope.\n+-- | _Note_: The `Control.Monad.ST` provides a _safe_ alternative to global\n+-- | mutable variables when mutation is restricted to a local scope.\n module Control.Monad.Eff.Ref where\n \n-import Prelude (Unit, unit)\n-import Control.Monad.Eff (Eff())\n+import Prelude ((<$>), bind, pure)\n+import Control.Monad.Eff (Eff)\n \n -- | The effect associated with the use of global mutable variables.\n foreign import data REF :: !\n \n--- | A value of type `Ref a` represents a mutable reference\n--- | which holds a value of type `a`.\n+-- | A value of type `Ref a` represents a mutable reference which holds a value\n+-- | of type `a`.\n foreign import data Ref :: * -> *\n \n -- | Create a new mutable reference containing the specified value.\n foreign import newRef :: forall s r. s -> Eff (ref :: REF | r) (Ref s)\n \n--- | Read the current value of a mutable reference\n+-- | Read the current value of a mutable reference.\n foreign import readRef :: forall s r. Ref s -> Eff (ref :: REF | r) s\n \n--- | Update the value of a mutable reference by applying a function\n--- | to the current value.\n-foreign import modifyRef' :: forall s b r. Ref s -> (s -> { state :: s, value :: b }) -> Eff (ref :: REF | r) b\n+-- | A function passed to `modifyRef'`.\n+type ModifyState s b = s -> { newValue :: s, returnValue :: b }\n \n--- | Update the value of a mutable reference by applying a function\n--- | to the current value.\n-modifyRef :: forall s r. Ref s -> (s -> s) -> Eff (ref :: REF | r) Unit\n-modifyRef ref f = modifyRef' ref (\\s -> { state: f s, value: unit })\n+-- | Update the value of a mutable reference by applying a function to the\n+-- | current value that yields the new value and a separate return value.\n+-- | Basically shorthand for `readRef` before `modifyRef`.\n+modifyRef' :: forall s b r. Ref s -> ModifyState s b -> Eff (ref :: REF | r) b\n+modifyRef' ref f = do\n+  { newValue, returnValue } <- f <$> readRef ref","path":"src/Control/Monad/Eff/Ref.purs","position":49,"original_position":49,"commit_id":"fb0a87370ff0fd38a3f4d617f2386dab0c10797f","original_commit_id":"fb0a87370ff0fd38a3f4d617f2386dab0c10797f","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":"Nitpick: I would just use a `let` here, rather than `<$>`, so we'd get inlining for `Eff` to produce a nice sequential definition instead of incurring the cost of the call to `map`.","created_at":"2016-07-31T17:03:06Z","updated_at":"2016-07-31T17:03:06Z","html_url":"https://github.com/purescript/purescript-refs/pull/11#discussion_r72907221","pull_request_url":"https://api.github.com/repos/purescript/purescript-refs/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/purescript/purescript-refs/pulls/comments/72907221"},"html":{"href":"https://github.com/purescript/purescript-refs/pull/11#discussion_r72907221"},"pull_request":{"href":"https://api.github.com/repos/purescript/purescript-refs/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/purescript/purescript-refs/pulls/11","id":79470247,"html_url":"https://github.com/purescript/purescript-refs/pull/11","diff_url":"https://github.com/purescript/purescript-refs/pull/11.diff","patch_url":"https://github.com/purescript/purescript-refs/pull/11.patch","issue_url":"https://api.github.com/repos/purescript/purescript-refs/issues/11","number":11,"state":"open","locked":false,"title":"Change writeRef and modifyRef to return value","user":{"login":"texastoland","id":48431,"avatar_url":"https://avatars.githubusercontent.com/u/48431?v=3","gravatar_id":"","url":"https://api.github.com/users/texastoland","html_url":"https://github.com/texastoland","followers_url":"https://api.github.com/users/texastoland/followers","following_url":"https://api.github.com/users/texastoland/following{/other_user}","gists_url":"https://api.github.com/users/texastoland/gists{/gist_id}","starred_url":"https://api.github.com/users/texastoland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/texastoland/subscriptions","organizations_url":"https://api.github.com/users/texastoland/orgs","repos_url":"https://api.github.com/users/texastoland/repos","events_url":"https://api.github.com/users/texastoland/events{/privacy}","received_events_url":"https://api.github.com/users/texastoland/received_events","type":"User","site_admin":false},"body":"Fix #9.","created_at":"2016-07-30T22:56:25Z","updated_at":"2016-07-31T17:03:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2cb5aa32ca3aa94926a7aa0cf0cad8317ad52238","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/purescript/purescript-refs/pulls/11/commits","review_comments_url":"https://api.github.com/repos/purescript/purescript-refs/pulls/11/comments","review_comment_url":"https://api.github.com/repos/purescript/purescript-refs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/purescript/purescript-refs/issues/11/comments","statuses_url":"https://api.github.com/repos/purescript/purescript-refs/statuses/fb0a87370ff0fd38a3f4d617f2386dab0c10797f","head":{"label":"texastoland:return-on-write","ref":"return-on-write","sha":"fb0a87370ff0fd38a3f4d617f2386dab0c10797f","user":{"login":"texastoland","id":48431,"avatar_url":"https://avatars.githubusercontent.com/u/48431?v=3","gravatar_id":"","url":"https://api.github.com/users/texastoland","html_url":"https://github.com/texastoland","followers_url":"https://api.github.com/users/texastoland/followers","following_url":"https://api.github.com/users/texastoland/following{/other_user}","gists_url":"https://api.github.com/users/texastoland/gists{/gist_id}","starred_url":"https://api.github.com/users/texastoland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/texastoland/subscriptions","organizations_url":"https://api.github.com/users/texastoland/orgs","repos_url":"https://api.github.com/users/texastoland/repos","events_url":"https://api.github.com/users/texastoland/events{/privacy}","received_events_url":"https://api.github.com/users/texastoland/received_events","type":"User","site_admin":false},"repo":{"id":64520779,"name":"purescript-refs","full_name":"texastoland/purescript-refs","owner":{"login":"texastoland","id":48431,"avatar_url":"https://avatars.githubusercontent.com/u/48431?v=3","gravatar_id":"","url":"https://api.github.com/users/texastoland","html_url":"https://github.com/texastoland","followers_url":"https://api.github.com/users/texastoland/followers","following_url":"https://api.github.com/users/texastoland/following{/other_user}","gists_url":"https://api.github.com/users/texastoland/gists{/gist_id}","starred_url":"https://api.github.com/users/texastoland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/texastoland/subscriptions","organizations_url":"https://api.github.com/users/texastoland/orgs","repos_url":"https://api.github.com/users/texastoland/repos","events_url":"https://api.github.com/users/texastoland/events{/privacy}","received_events_url":"https://api.github.com/users/texastoland/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/texastoland/purescript-refs","description":"Mutable value references","fork":true,"url":"https://api.github.com/repos/texastoland/purescript-refs","forks_url":"https://api.github.com/repos/texastoland/purescript-refs/forks","keys_url":"https://api.github.com/repos/texastoland/purescript-refs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/texastoland/purescript-refs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/texastoland/purescript-refs/teams","hooks_url":"https://api.github.com/repos/texastoland/purescript-refs/hooks","issue_events_url":"https://api.github.com/repos/texastoland/purescript-refs/issues/events{/number}","events_url":"https://api.github.com/repos/texastoland/purescript-refs/events","assignees_url":"https://api.github.com/repos/texastoland/purescript-refs/assignees{/user}","branches_url":"https://api.github.com/repos/texastoland/purescript-refs/branches{/branch}","tags_url":"https://api.github.com/repos/texastoland/purescript-refs/tags","blobs_url":"https://api.github.com/repos/texastoland/purescript-refs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/texastoland/purescript-refs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/texastoland/purescript-refs/git/refs{/sha}","trees_url":"https://api.github.com/repos/texastoland/purescript-refs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/texastoland/purescript-refs/statuses/{sha}","languages_url":"https://api.github.com/repos/texastoland/purescript-refs/languages","stargazers_url":"https://api.github.com/repos/texastoland/purescript-refs/stargazers","contributors_url":"https://api.github.com/repos/texastoland/purescript-refs/contributors","subscribers_url":"https://api.github.com/repos/texastoland/purescript-refs/subscribers","subscription_url":"https://api.github.com/repos/texastoland/purescript-refs/subscription","commits_url":"https://api.github.com/repos/texastoland/purescript-refs/commits{/sha}","git_commits_url":"https://api.github.com/repos/texastoland/purescript-refs/git/commits{/sha}","comments_url":"https://api.github.com/repos/texastoland/purescript-refs/comments{/number}","issue_comment_url":"https://api.github.com/repos/texastoland/purescript-refs/issues/comments{/number}","contents_url":"https://api.github.com/repos/texastoland/purescript-refs/contents/{+path}","compare_url":"https://api.github.com/repos/texastoland/purescript-refs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/texastoland/purescript-refs/merges","archive_url":"https://api.github.com/repos/texastoland/purescript-refs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/texastoland/purescript-refs/downloads","issues_url":"https://api.github.com/repos/texastoland/purescript-refs/issues{/number}","pulls_url":"https://api.github.com/repos/texastoland/purescript-refs/pulls{/number}","milestones_url":"https://api.github.com/repos/texastoland/purescript-refs/milestones{/number}","notifications_url":"https://api.github.com/repos/texastoland/purescript-refs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/texastoland/purescript-refs/labels{/name}","releases_url":"https://api.github.com/repos/texastoland/purescript-refs/releases{/id}","deployments_url":"https://api.github.com/repos/texastoland/purescript-refs/deployments","created_at":"2016-07-30T01:56:57Z","updated_at":"2016-07-30T01:56:58Z","pushed_at":"2016-07-31T14:58:28Z","git_url":"git://github.com/texastoland/purescript-refs.git","ssh_url":"git@github.com:texastoland/purescript-refs.git","clone_url":"https://github.com/texastoland/purescript-refs.git","svn_url":"https://github.com/texastoland/purescript-refs","homepage":null,"size":27,"stargazers_count":0,"watchers_count":0,"language":"PureScript","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":"59fcc2dc883efbacff240e3495a763087450b975","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":17922338,"name":"purescript-refs","full_name":"purescript/purescript-refs","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-refs","description":"Mutable value references","fork":false,"url":"https://api.github.com/repos/purescript/purescript-refs","forks_url":"https://api.github.com/repos/purescript/purescript-refs/forks","keys_url":"https://api.github.com/repos/purescript/purescript-refs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/purescript/purescript-refs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/purescript/purescript-refs/teams","hooks_url":"https://api.github.com/repos/purescript/purescript-refs/hooks","issue_events_url":"https://api.github.com/repos/purescript/purescript-refs/issues/events{/number}","events_url":"https://api.github.com/repos/purescript/purescript-refs/events","assignees_url":"https://api.github.com/repos/purescript/purescript-refs/assignees{/user}","branches_url":"https://api.github.com/repos/purescript/purescript-refs/branches{/branch}","tags_url":"https://api.github.com/repos/purescript/purescript-refs/tags","blobs_url":"https://api.github.com/repos/purescript/purescript-refs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/purescript/purescript-refs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/purescript/purescript-refs/git/refs{/sha}","trees_url":"https://api.github.com/repos/purescript/purescript-refs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/purescript/purescript-refs/statuses/{sha}","languages_url":"https://api.github.com/repos/purescript/purescript-refs/languages","stargazers_url":"https://api.github.com/repos/purescript/purescript-refs/stargazers","contributors_url":"https://api.github.com/repos/purescript/purescript-refs/contributors","subscribers_url":"https://api.github.com/repos/purescript/purescript-refs/subscribers","subscription_url":"https://api.github.com/repos/purescript/purescript-refs/subscription","commits_url":"https://api.github.com/repos/purescript/purescript-refs/commits{/sha}","git_commits_url":"https://api.github.com/repos/purescript/purescript-refs/git/commits{/sha}","comments_url":"https://api.github.com/repos/purescript/purescript-refs/comments{/number}","issue_comment_url":"https://api.github.com/repos/purescript/purescript-refs/issues/comments{/number}","contents_url":"https://api.github.com/repos/purescript/purescript-refs/contents/{+path}","compare_url":"https://api.github.com/repos/purescript/purescript-refs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/purescript/purescript-refs/merges","archive_url":"https://api.github.com/repos/purescript/purescript-refs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/purescript/purescript-refs/downloads","issues_url":"https://api.github.com/repos/purescript/purescript-refs/issues{/number}","pulls_url":"https://api.github.com/repos/purescript/purescript-refs/pulls{/number}","milestones_url":"https://api.github.com/repos/purescript/purescript-refs/milestones{/number}","notifications_url":"https://api.github.com/repos/purescript/purescript-refs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/purescript/purescript-refs/labels{/name}","releases_url":"https://api.github.com/repos/purescript/purescript-refs/releases{/id}","deployments_url":"https://api.github.com/repos/purescript/purescript-refs/deployments","created_at":"2014-03-19T22:12:38Z","updated_at":"2016-07-26T01:19:09Z","pushed_at":"2016-07-31T14:54:52Z","git_url":"git://github.com/purescript/purescript-refs.git","ssh_url":"git@github.com:purescript/purescript-refs.git","clone_url":"https://github.com/purescript/purescript-refs.git","svn_url":"https://github.com/purescript/purescript-refs","homepage":null,"size":24,"stargazers_count":6,"watchers_count":6,"language":"PureScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/purescript/purescript-refs/pulls/11"},"html":{"href":"https://github.com/purescript/purescript-refs/pull/11"},"issue":{"href":"https://api.github.com/repos/purescript/purescript-refs/issues/11"},"comments":{"href":"https://api.github.com/repos/purescript/purescript-refs/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/purescript/purescript-refs/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/purescript/purescript-refs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/purescript/purescript-refs/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/purescript/purescript-refs/statuses/fb0a87370ff0fd38a3f4d617f2386dab0c10797f"}}}}
{"actor":{"display_login":"paf31"}}