{"action":"created","comment":{"url":"https://api.github.com/repos/harrygr/catling/pulls/comments/157169808","pull_request_review_id":83770652,"id":157169808,"diff_hunk":"@@ -0,0 +1,90 @@\n+import { Reader } from './reader'\n+\n+describe('Reader', () => {\n+\n+  type Cat = {\n+    name: string,\n+    favoriteFood: string,\n+  }\n+\n+  const garfield = {\n+    name: 'Garfield',\n+    favoriteFood: 'Lasagna',\n+  }\n+\n+  const catName: Reader<Cat, string> = Reader(cat => cat.name)\n+  const greetCat: Reader<Cat, string> = catName.map(name => `Hello ${name}`)\n+  const isGarfield: Reader<Cat, boolean> = catName.map(name => name === 'Garfield')\n+  const catFavoriteFood: Reader<Cat, string> = catName.flatMap(name => Reader(cat => `${name}'s food is ${cat.favoriteFood}`))\n+\n+  it('executes run with a single reader', () => {\n+    expect(catName.run(garfield)).toBe('Garfield')\n+  })\n+\n+  it('executes with a double reader using intermediate map', () => {\n+    expect(greetCat.run(garfield)).toBe('Hello Garfield')\n+  })\n+\n+  it('executes with a double reader using intermediate map and different types', () => {\n+    expect(isGarfield.run(garfield)).toBe(true)\n+  })\n+\n+  it('has a flatmap method', () => {\n+    expect(catFavoriteFood.run(garfield)).toBe('Garfield\\'s food is Lasagna')\n+  })\n+})\n+\n+describe('Reader example', () => {\n+\n+  type TimeOfDay = 'morning' | 'afternoon' | 'evening' | 'night'\n+  type Language = 'english' | 'portuguese'\n+  type User = {\n+    name: string,\n+    language: Language\n+  }\n+\n+  const englishGreetings: Record<TimeOfDay, string> = {\n+    morning: 'Good morning',\n+    afternoon: 'Good afternoon',\n+    evening: 'Good evening',\n+    night: 'Good night',\n+  }\n+\n+  const portugueseGreetings: Record<TimeOfDay, string> = {\n+    morning: 'Bom dia',\n+    afternoon: 'Boa tarde',\n+    evening: 'Boa tarde',\n+    night: 'Boa noite',\n+  }\n+\n+  const greetingNameInLanguage = function(timeOfDay: TimeOfDay): Reader<User, string> {","path":"src/reader.spec.ts","position":60,"original_position":60,"commit_id":"5e93802ec5224d53ebb35fc560830435df359380","original_commit_id":"5e93802ec5224d53ebb35fc560830435df359380","user":{"login":"harrygr","id":5128200,"avatar_url":"https://avatars1.githubusercontent.com/u/5128200?v=4","gravatar_id":"","url":"https://api.github.com/users/harrygr","html_url":"https://github.com/harrygr","followers_url":"https://api.github.com/users/harrygr/followers","following_url":"https://api.github.com/users/harrygr/following{/other_user}","gists_url":"https://api.github.com/users/harrygr/gists{/gist_id}","starred_url":"https://api.github.com/users/harrygr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrygr/subscriptions","organizations_url":"https://api.github.com/users/harrygr/orgs","repos_url":"https://api.github.com/users/harrygr/repos","events_url":"https://api.github.com/users/harrygr/events{/privacy}","received_events_url":"https://api.github.com/users/harrygr/received_events","type":"User","site_admin":false},"body":"The unwritten but nonetheless sacred style guide for this library dicates the use of named functions, unless it's a callback or object method.\r\n\r\nI.e. change to `function greetingNameInLanguage(timeOfDay){...`","created_at":"2017-12-15T10:38:18Z","updated_at":"2017-12-15T10:50:08Z","html_url":"https://github.com/harrygr/catling/pull/2#discussion_r157169808","pull_request_url":"https://api.github.com/repos/harrygr/catling/pulls/2","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/harrygr/catling/pulls/comments/157169808"},"html":{"href":"https://github.com/harrygr/catling/pull/2#discussion_r157169808"},"pull_request":{"href":"https://api.github.com/repos/harrygr/catling/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/harrygr/catling/pulls/2","id":157621089,"html_url":"https://github.com/harrygr/catling/pull/2","diff_url":"https://github.com/harrygr/catling/pull/2.diff","patch_url":"https://github.com/harrygr/catling/pull/2.patch","issue_url":"https://api.github.com/repos/harrygr/catling/issues/2","number":2,"state":"open","locked":false,"title":"Add reader monad with tests","user":{"login":"diogogaalves","id":1331671,"avatar_url":"https://avatars1.githubusercontent.com/u/1331671?v=4","gravatar_id":"","url":"https://api.github.com/users/diogogaalves","html_url":"https://github.com/diogogaalves","followers_url":"https://api.github.com/users/diogogaalves/followers","following_url":"https://api.github.com/users/diogogaalves/following{/other_user}","gists_url":"https://api.github.com/users/diogogaalves/gists{/gist_id}","starred_url":"https://api.github.com/users/diogogaalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogogaalves/subscriptions","organizations_url":"https://api.github.com/users/diogogaalves/orgs","repos_url":"https://api.github.com/users/diogogaalves/repos","events_url":"https://api.github.com/users/diogogaalves/events{/privacy}","received_events_url":"https://api.github.com/users/diogogaalves/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-11T17:11:24Z","updated_at":"2017-12-15T10:50:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc0b9aff4c9c56b2ccf57fda936e40ab34bca5ef","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/harrygr/catling/pulls/2/commits","review_comments_url":"https://api.github.com/repos/harrygr/catling/pulls/2/comments","review_comment_url":"https://api.github.com/repos/harrygr/catling/pulls/comments{/number}","comments_url":"https://api.github.com/repos/harrygr/catling/issues/2/comments","statuses_url":"https://api.github.com/repos/harrygr/catling/statuses/5e93802ec5224d53ebb35fc560830435df359380","head":{"label":"diogogaalves:reader-monad","ref":"reader-monad","sha":"5e93802ec5224d53ebb35fc560830435df359380","user":{"login":"diogogaalves","id":1331671,"avatar_url":"https://avatars1.githubusercontent.com/u/1331671?v=4","gravatar_id":"","url":"https://api.github.com/users/diogogaalves","html_url":"https://github.com/diogogaalves","followers_url":"https://api.github.com/users/diogogaalves/followers","following_url":"https://api.github.com/users/diogogaalves/following{/other_user}","gists_url":"https://api.github.com/users/diogogaalves/gists{/gist_id}","starred_url":"https://api.github.com/users/diogogaalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogogaalves/subscriptions","organizations_url":"https://api.github.com/users/diogogaalves/orgs","repos_url":"https://api.github.com/users/diogogaalves/repos","events_url":"https://api.github.com/users/diogogaalves/events{/privacy}","received_events_url":"https://api.github.com/users/diogogaalves/received_events","type":"User","site_admin":false},"repo":{"id":113885727,"name":"catling","full_name":"diogogaalves/catling","owner":{"login":"diogogaalves","id":1331671,"avatar_url":"https://avatars1.githubusercontent.com/u/1331671?v=4","gravatar_id":"","url":"https://api.github.com/users/diogogaalves","html_url":"https://github.com/diogogaalves","followers_url":"https://api.github.com/users/diogogaalves/followers","following_url":"https://api.github.com/users/diogogaalves/following{/other_user}","gists_url":"https://api.github.com/users/diogogaalves/gists{/gist_id}","starred_url":"https://api.github.com/users/diogogaalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogogaalves/subscriptions","organizations_url":"https://api.github.com/users/diogogaalves/orgs","repos_url":"https://api.github.com/users/diogogaalves/repos","events_url":"https://api.github.com/users/diogogaalves/events{/privacy}","received_events_url":"https://api.github.com/users/diogogaalves/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/diogogaalves/catling","description":"Monadic types for JavaScript and TypeScript","fork":true,"url":"https://api.github.com/repos/diogogaalves/catling","forks_url":"https://api.github.com/repos/diogogaalves/catling/forks","keys_url":"https://api.github.com/repos/diogogaalves/catling/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diogogaalves/catling/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diogogaalves/catling/teams","hooks_url":"https://api.github.com/repos/diogogaalves/catling/hooks","issue_events_url":"https://api.github.com/repos/diogogaalves/catling/issues/events{/number}","events_url":"https://api.github.com/repos/diogogaalves/catling/events","assignees_url":"https://api.github.com/repos/diogogaalves/catling/assignees{/user}","branches_url":"https://api.github.com/repos/diogogaalves/catling/branches{/branch}","tags_url":"https://api.github.com/repos/diogogaalves/catling/tags","blobs_url":"https://api.github.com/repos/diogogaalves/catling/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diogogaalves/catling/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diogogaalves/catling/git/refs{/sha}","trees_url":"https://api.github.com/repos/diogogaalves/catling/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diogogaalves/catling/statuses/{sha}","languages_url":"https://api.github.com/repos/diogogaalves/catling/languages","stargazers_url":"https://api.github.com/repos/diogogaalves/catling/stargazers","contributors_url":"https://api.github.com/repos/diogogaalves/catling/contributors","subscribers_url":"https://api.github.com/repos/diogogaalves/catling/subscribers","subscription_url":"https://api.github.com/repos/diogogaalves/catling/subscription","commits_url":"https://api.github.com/repos/diogogaalves/catling/commits{/sha}","git_commits_url":"https://api.github.com/repos/diogogaalves/catling/git/commits{/sha}","comments_url":"https://api.github.com/repos/diogogaalves/catling/comments{/number}","issue_comment_url":"https://api.github.com/repos/diogogaalves/catling/issues/comments{/number}","contents_url":"https://api.github.com/repos/diogogaalves/catling/contents/{+path}","compare_url":"https://api.github.com/repos/diogogaalves/catling/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diogogaalves/catling/merges","archive_url":"https://api.github.com/repos/diogogaalves/catling/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diogogaalves/catling/downloads","issues_url":"https://api.github.com/repos/diogogaalves/catling/issues{/number}","pulls_url":"https://api.github.com/repos/diogogaalves/catling/pulls{/number}","milestones_url":"https://api.github.com/repos/diogogaalves/catling/milestones{/number}","notifications_url":"https://api.github.com/repos/diogogaalves/catling/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diogogaalves/catling/labels{/name}","releases_url":"https://api.github.com/repos/diogogaalves/catling/releases{/id}","deployments_url":"https://api.github.com/repos/diogogaalves/catling/deployments","created_at":"2017-12-11T17:03:00Z","updated_at":"2017-12-11T17:03:02Z","pushed_at":"2017-12-11T17:10:27Z","git_url":"git://github.com/diogogaalves/catling.git","ssh_url":"git@github.com:diogogaalves/catling.git","clone_url":"https://github.com/diogogaalves/catling.git","svn_url":"https://github.com/diogogaalves/catling","homepage":"","size":37,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"harrygr:master","ref":"master","sha":"70a51198b948fdb4cec277a77226c3a0616ff102","user":{"login":"harrygr","id":5128200,"avatar_url":"https://avatars1.githubusercontent.com/u/5128200?v=4","gravatar_id":"","url":"https://api.github.com/users/harrygr","html_url":"https://github.com/harrygr","followers_url":"https://api.github.com/users/harrygr/followers","following_url":"https://api.github.com/users/harrygr/following{/other_user}","gists_url":"https://api.github.com/users/harrygr/gists{/gist_id}","starred_url":"https://api.github.com/users/harrygr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrygr/subscriptions","organizations_url":"https://api.github.com/users/harrygr/orgs","repos_url":"https://api.github.com/users/harrygr/repos","events_url":"https://api.github.com/users/harrygr/events{/privacy}","received_events_url":"https://api.github.com/users/harrygr/received_events","type":"User","site_admin":false},"repo":{"id":113470887,"name":"catling","full_name":"harrygr/catling","owner":{"login":"harrygr","id":5128200,"avatar_url":"https://avatars1.githubusercontent.com/u/5128200?v=4","gravatar_id":"","url":"https://api.github.com/users/harrygr","html_url":"https://github.com/harrygr","followers_url":"https://api.github.com/users/harrygr/followers","following_url":"https://api.github.com/users/harrygr/following{/other_user}","gists_url":"https://api.github.com/users/harrygr/gists{/gist_id}","starred_url":"https://api.github.com/users/harrygr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrygr/subscriptions","organizations_url":"https://api.github.com/users/harrygr/orgs","repos_url":"https://api.github.com/users/harrygr/repos","events_url":"https://api.github.com/users/harrygr/events{/privacy}","received_events_url":"https://api.github.com/users/harrygr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/harrygr/catling","description":"Monadic types for JavaScript and TypeScript","fork":false,"url":"https://api.github.com/repos/harrygr/catling","forks_url":"https://api.github.com/repos/harrygr/catling/forks","keys_url":"https://api.github.com/repos/harrygr/catling/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harrygr/catling/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harrygr/catling/teams","hooks_url":"https://api.github.com/repos/harrygr/catling/hooks","issue_events_url":"https://api.github.com/repos/harrygr/catling/issues/events{/number}","events_url":"https://api.github.com/repos/harrygr/catling/events","assignees_url":"https://api.github.com/repos/harrygr/catling/assignees{/user}","branches_url":"https://api.github.com/repos/harrygr/catling/branches{/branch}","tags_url":"https://api.github.com/repos/harrygr/catling/tags","blobs_url":"https://api.github.com/repos/harrygr/catling/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harrygr/catling/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harrygr/catling/git/refs{/sha}","trees_url":"https://api.github.com/repos/harrygr/catling/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harrygr/catling/statuses/{sha}","languages_url":"https://api.github.com/repos/harrygr/catling/languages","stargazers_url":"https://api.github.com/repos/harrygr/catling/stargazers","contributors_url":"https://api.github.com/repos/harrygr/catling/contributors","subscribers_url":"https://api.github.com/repos/harrygr/catling/subscribers","subscription_url":"https://api.github.com/repos/harrygr/catling/subscription","commits_url":"https://api.github.com/repos/harrygr/catling/commits{/sha}","git_commits_url":"https://api.github.com/repos/harrygr/catling/git/commits{/sha}","comments_url":"https://api.github.com/repos/harrygr/catling/comments{/number}","issue_comment_url":"https://api.github.com/repos/harrygr/catling/issues/comments{/number}","contents_url":"https://api.github.com/repos/harrygr/catling/contents/{+path}","compare_url":"https://api.github.com/repos/harrygr/catling/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harrygr/catling/merges","archive_url":"https://api.github.com/repos/harrygr/catling/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harrygr/catling/downloads","issues_url":"https://api.github.com/repos/harrygr/catling/issues{/number}","pulls_url":"https://api.github.com/repos/harrygr/catling/pulls{/number}","milestones_url":"https://api.github.com/repos/harrygr/catling/milestones{/number}","notifications_url":"https://api.github.com/repos/harrygr/catling/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harrygr/catling/labels{/name}","releases_url":"https://api.github.com/repos/harrygr/catling/releases{/id}","deployments_url":"https://api.github.com/repos/harrygr/catling/deployments","created_at":"2017-12-07T15:59:52Z","updated_at":"2017-12-07T17:19:36Z","pushed_at":"2017-12-14T17:58:37Z","git_url":"git://github.com/harrygr/catling.git","ssh_url":"git@github.com:harrygr/catling.git","clone_url":"https://github.com/harrygr/catling.git","svn_url":"https://github.com/harrygr/catling","homepage":"","size":52,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/harrygr/catling/pulls/2"},"html":{"href":"https://github.com/harrygr/catling/pull/2"},"issue":{"href":"https://api.github.com/repos/harrygr/catling/issues/2"},"comments":{"href":"https://api.github.com/repos/harrygr/catling/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/harrygr/catling/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/harrygr/catling/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/harrygr/catling/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/harrygr/catling/statuses/5e93802ec5224d53ebb35fc560830435df359380"}},"author_association":"NONE"}}
{"actor":{"display_login":"harrygr"}}