{"action":"created","comment":{"url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/comments/55147785","id":55147785,"diff_hunk":"@@ -54,39 +54,47 @@ server ior = getAllVehicles\n     -- curl http://localhost:8081/vehicles/all\n \n     getVehicleById :: Int -> EitherT ServantErr IO Vehicle\n-    getVehicleById = getByIdHelper id\n+    getVehicleById i = do tbl <- liftIO (readIORef ior)\n+                          maybe notFound return (IM.lookup i tbl)\n     -- curl http://localhost:8081/vehicles/0\n \n-    getByIdHelper f i = maybe oops (return . f) . IM.lookup i =<< liftIO (readIORef ior)\n-    oops              = left err404 { errBody = \"Vehicle ID not found.\" }\n+    notFound :: EitherT ServantErr IO a\n+    notFound = left err404 { errBody = \"Vehicle ID not found.\" }\n \n     postVehicle :: Vehicle -> EitherT ServantErr IO Vehicle\n-    postVehicle v = liftIO . atomicModifyIORef ior $ f\n+    postVehicle v = liftIO $ atomicModifyIORef ior insert\n       where\n-        f tbl = let newId = head . ([0..] \\\\) . IM.keys $ tbl\n-                    v'    = v { dbId = Just newId }\n-                in (IM.insert newId v' tbl, v')\n-    -- echo '{\"color\":\"red\",\"year\":2013,\"model\":\"Void\",\"issues\":[{\"issueType\":\"Electrical\",\"priority\":\"High\"}],\"vin\":\"vin x\"}' | curl -X POST -d @- http://localhost:8081/vehicles --header \"Content-Type:application/json\"\n+        insert :: IM.IntMap Vehicle -> (IM.IntMap Vehicle, Vehicle)\n+        insert tbl = let newUniqueId = head . ([0..] \\\\) $ IM.keys tbl\n+                         updatedTbl = IM.insert newUniqueId v tbl\n+                     in (updatedTbl, v)\n+    -- echo '{\"year\":2013,\"model\":\"Void\",\"issues\":[{\"issueType\":\"Electrical\",\"priority\":\"High\"}],\"vin\":\"vin x\"}' | curl -X POST -d @- http://localhost:8081/vehicles --header \"Content-Type:application/json\"\n \n     putVehicle :: Int -> Vehicle -> EitherT ServantErr IO Vehicle\n     putVehicle i v = putHelper f\n       where\n-        f tbl = maybe (tbl, Nothing) (const found) . IM.lookup i $ tbl\n-          where\n-            found = let v' = v { dbId = Just i }\n-                    in (IM.insert i v' tbl, Just v')\n-    -- echo '{\"color\":\"grey\",\"year\":2012,\"model\":\"Iterate\",\"issues\":[{\"issueType\":\"Exhaust\",\"priority\":\"Low\"}],\"vin\":\"vin y\"}' | curl -X PUT -d @- http://localhost:8081/vehicles/0 --header \"Content-Type:application/json\"\n+        f :: IM.IntMap Vehicle -> (IM.IntMap Vehicle, Maybe Vehicle)\n+        f tbl = if IM.member i tbl\n+                then let updatedTbl = IM.insert i v tbl","path":"src/InMemoryDb.hs","position":null,"original_position":53,"commit_id":"79bbee0808990f0c65afadb512f36f67cac4ba99","original_commit_id":"d430e69ddbcbd04664f9bf09352be61f751f8e7d","user":{"login":"mchowning","id":4656348,"avatar_url":"https://avatars.githubusercontent.com/u/4656348?v=3","gravatar_id":"","url":"https://api.github.com/users/mchowning","html_url":"https://github.com/mchowning","followers_url":"https://api.github.com/users/mchowning/followers","following_url":"https://api.github.com/users/mchowning/following{/other_user}","gists_url":"https://api.github.com/users/mchowning/gists{/gist_id}","starred_url":"https://api.github.com/users/mchowning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchowning/subscriptions","organizations_url":"https://api.github.com/users/mchowning/orgs","repos_url":"https://api.github.com/users/mchowning/repos","events_url":"https://api.github.com/users/mchowning/events{/privacy}","received_events_url":"https://api.github.com/users/mchowning/received_events","type":"User","site_admin":false},"body":"I went ahead and switched all the ```updatedTbl``` to ```tbl'```.  After thinking about it some more, I think that makes sense. ","created_at":"2016-03-06T20:43:58Z","updated_at":"2016-03-06T20:43:58Z","html_url":"https://github.com/jasonstolaruk/servant-back-end/pull/1#discussion_r55147785","pull_request_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/comments/55147785"},"html":{"href":"https://github.com/jasonstolaruk/servant-back-end/pull/1#discussion_r55147785"},"pull_request":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1","id":59315466,"html_url":"https://github.com/jasonstolaruk/servant-back-end/pull/1","diff_url":"https://github.com/jasonstolaruk/servant-back-end/pull/1.diff","patch_url":"https://github.com/jasonstolaruk/servant-back-end/pull/1.patch","issue_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues/1","number":1,"state":"open","locked":false,"title":"Possible simplifications to servant example","user":{"login":"mchowning","id":4656348,"avatar_url":"https://avatars.githubusercontent.com/u/4656348?v=3","gravatar_id":"","url":"https://api.github.com/users/mchowning","html_url":"https://github.com/mchowning","followers_url":"https://api.github.com/users/mchowning/followers","following_url":"https://api.github.com/users/mchowning/following{/other_user}","gists_url":"https://api.github.com/users/mchowning/gists{/gist_id}","starred_url":"https://api.github.com/users/mchowning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchowning/subscriptions","organizations_url":"https://api.github.com/users/mchowning/orgs","repos_url":"https://api.github.com/users/mchowning/repos","events_url":"https://api.github.com/users/mchowning/events{/privacy}","received_events_url":"https://api.github.com/users/mchowning/received_events","type":"User","site_admin":false},"body":"Took a shot at seeing how much I could trim down Main.hs to make it show as little beyond servant as possible for demonstrative purposes.  This probably wouldn't be good finished code for us to use, but I think that something along these lines could be good to use to show what servant alone, divorced from any persistence concerns, looks like.  Then made similar changes to InMemoryDb in an effort to make comparing Main.hs and InMemoryDb.hs more straightforward.","created_at":"2016-02-15T02:35:03Z","updated_at":"2016-03-06T20:43:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5427936cdd4b35acd986d113c8c926b9e513ff2d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1/commits","review_comments_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1/comments","review_comment_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues/1/comments","statuses_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/statuses/79bbee0808990f0c65afadb512f36f67cac4ba99","head":{"label":"mchowning:bare-bones-servant-example","ref":"bare-bones-servant-example","sha":"79bbee0808990f0c65afadb512f36f67cac4ba99","user":{"login":"mchowning","id":4656348,"avatar_url":"https://avatars.githubusercontent.com/u/4656348?v=3","gravatar_id":"","url":"https://api.github.com/users/mchowning","html_url":"https://github.com/mchowning","followers_url":"https://api.github.com/users/mchowning/followers","following_url":"https://api.github.com/users/mchowning/following{/other_user}","gists_url":"https://api.github.com/users/mchowning/gists{/gist_id}","starred_url":"https://api.github.com/users/mchowning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchowning/subscriptions","organizations_url":"https://api.github.com/users/mchowning/orgs","repos_url":"https://api.github.com/users/mchowning/repos","events_url":"https://api.github.com/users/mchowning/events{/privacy}","received_events_url":"https://api.github.com/users/mchowning/received_events","type":"User","site_admin":false},"repo":{"id":51675671,"name":"servant-back-end","full_name":"mchowning/servant-back-end","owner":{"login":"mchowning","id":4656348,"avatar_url":"https://avatars.githubusercontent.com/u/4656348?v=3","gravatar_id":"","url":"https://api.github.com/users/mchowning","html_url":"https://github.com/mchowning","followers_url":"https://api.github.com/users/mchowning/followers","following_url":"https://api.github.com/users/mchowning/following{/other_user}","gists_url":"https://api.github.com/users/mchowning/gists{/gist_id}","starred_url":"https://api.github.com/users/mchowning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchowning/subscriptions","organizations_url":"https://api.github.com/users/mchowning/orgs","repos_url":"https://api.github.com/users/mchowning/repos","events_url":"https://api.github.com/users/mchowning/events{/privacy}","received_events_url":"https://api.github.com/users/mchowning/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mchowning/servant-back-end","description":"Demo of an automotive back end using servant.","fork":true,"url":"https://api.github.com/repos/mchowning/servant-back-end","forks_url":"https://api.github.com/repos/mchowning/servant-back-end/forks","keys_url":"https://api.github.com/repos/mchowning/servant-back-end/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mchowning/servant-back-end/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mchowning/servant-back-end/teams","hooks_url":"https://api.github.com/repos/mchowning/servant-back-end/hooks","issue_events_url":"https://api.github.com/repos/mchowning/servant-back-end/issues/events{/number}","events_url":"https://api.github.com/repos/mchowning/servant-back-end/events","assignees_url":"https://api.github.com/repos/mchowning/servant-back-end/assignees{/user}","branches_url":"https://api.github.com/repos/mchowning/servant-back-end/branches{/branch}","tags_url":"https://api.github.com/repos/mchowning/servant-back-end/tags","blobs_url":"https://api.github.com/repos/mchowning/servant-back-end/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mchowning/servant-back-end/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mchowning/servant-back-end/git/refs{/sha}","trees_url":"https://api.github.com/repos/mchowning/servant-back-end/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mchowning/servant-back-end/statuses/{sha}","languages_url":"https://api.github.com/repos/mchowning/servant-back-end/languages","stargazers_url":"https://api.github.com/repos/mchowning/servant-back-end/stargazers","contributors_url":"https://api.github.com/repos/mchowning/servant-back-end/contributors","subscribers_url":"https://api.github.com/repos/mchowning/servant-back-end/subscribers","subscription_url":"https://api.github.com/repos/mchowning/servant-back-end/subscription","commits_url":"https://api.github.com/repos/mchowning/servant-back-end/commits{/sha}","git_commits_url":"https://api.github.com/repos/mchowning/servant-back-end/git/commits{/sha}","comments_url":"https://api.github.com/repos/mchowning/servant-back-end/comments{/number}","issue_comment_url":"https://api.github.com/repos/mchowning/servant-back-end/issues/comments{/number}","contents_url":"https://api.github.com/repos/mchowning/servant-back-end/contents/{+path}","compare_url":"https://api.github.com/repos/mchowning/servant-back-end/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mchowning/servant-back-end/merges","archive_url":"https://api.github.com/repos/mchowning/servant-back-end/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mchowning/servant-back-end/downloads","issues_url":"https://api.github.com/repos/mchowning/servant-back-end/issues{/number}","pulls_url":"https://api.github.com/repos/mchowning/servant-back-end/pulls{/number}","milestones_url":"https://api.github.com/repos/mchowning/servant-back-end/milestones{/number}","notifications_url":"https://api.github.com/repos/mchowning/servant-back-end/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mchowning/servant-back-end/labels{/name}","releases_url":"https://api.github.com/repos/mchowning/servant-back-end/releases{/id}","deployments_url":"https://api.github.com/repos/mchowning/servant-back-end/deployments","created_at":"2016-02-14T02:13:19Z","updated_at":"2016-02-14T02:13:21Z","pushed_at":"2016-03-06T20:40:17Z","git_url":"git://github.com/mchowning/servant-back-end.git","ssh_url":"git@github.com:mchowning/servant-back-end.git","clone_url":"https://github.com/mchowning/servant-back-end.git","svn_url":"https://github.com/mchowning/servant-back-end","homepage":"","size":20,"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":"jasonstolaruk:master","ref":"master","sha":"b2326892572102d4d3aba57fe39e1894ab09f881","user":{"login":"jasonstolaruk","id":2731239,"avatar_url":"https://avatars.githubusercontent.com/u/2731239?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonstolaruk","html_url":"https://github.com/jasonstolaruk","followers_url":"https://api.github.com/users/jasonstolaruk/followers","following_url":"https://api.github.com/users/jasonstolaruk/following{/other_user}","gists_url":"https://api.github.com/users/jasonstolaruk/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonstolaruk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonstolaruk/subscriptions","organizations_url":"https://api.github.com/users/jasonstolaruk/orgs","repos_url":"https://api.github.com/users/jasonstolaruk/repos","events_url":"https://api.github.com/users/jasonstolaruk/events{/privacy}","received_events_url":"https://api.github.com/users/jasonstolaruk/received_events","type":"User","site_admin":false},"repo":{"id":47434441,"name":"servant-back-end","full_name":"jasonstolaruk/servant-back-end","owner":{"login":"jasonstolaruk","id":2731239,"avatar_url":"https://avatars.githubusercontent.com/u/2731239?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonstolaruk","html_url":"https://github.com/jasonstolaruk","followers_url":"https://api.github.com/users/jasonstolaruk/followers","following_url":"https://api.github.com/users/jasonstolaruk/following{/other_user}","gists_url":"https://api.github.com/users/jasonstolaruk/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonstolaruk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonstolaruk/subscriptions","organizations_url":"https://api.github.com/users/jasonstolaruk/orgs","repos_url":"https://api.github.com/users/jasonstolaruk/repos","events_url":"https://api.github.com/users/jasonstolaruk/events{/privacy}","received_events_url":"https://api.github.com/users/jasonstolaruk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jasonstolaruk/servant-back-end","description":"Demo of an automotive back end using servant.","fork":false,"url":"https://api.github.com/repos/jasonstolaruk/servant-back-end","forks_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/forks","keys_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/teams","hooks_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/hooks","issue_events_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues/events{/number}","events_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/events","assignees_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/assignees{/user}","branches_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/branches{/branch}","tags_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/tags","blobs_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/git/refs{/sha}","trees_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/statuses/{sha}","languages_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/languages","stargazers_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/stargazers","contributors_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/contributors","subscribers_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/subscribers","subscription_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/subscription","commits_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/commits{/sha}","git_commits_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/git/commits{/sha}","comments_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/comments{/number}","issue_comment_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues/comments{/number}","contents_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/contents/{+path}","compare_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/merges","archive_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/downloads","issues_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues{/number}","pulls_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls{/number}","milestones_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/milestones{/number}","notifications_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/labels{/name}","releases_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/releases{/id}","deployments_url":"https://api.github.com/repos/jasonstolaruk/servant-back-end/deployments","created_at":"2015-12-04T23:44:29Z","updated_at":"2016-02-10T06:31:00Z","pushed_at":"2016-03-06T20:40:18Z","git_url":"git://github.com/jasonstolaruk/servant-back-end.git","ssh_url":"git@github.com:jasonstolaruk/servant-back-end.git","clone_url":"https://github.com/jasonstolaruk/servant-back-end.git","svn_url":"https://github.com/jasonstolaruk/servant-back-end","homepage":"","size":13,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1"},"html":{"href":"https://github.com/jasonstolaruk/servant-back-end/pull/1"},"issue":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues/1"},"comments":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/jasonstolaruk/servant-back-end/statuses/79bbee0808990f0c65afadb512f36f67cac4ba99"}}}}