{"action":"created","comment":{"url":"https://api.github.com/repos/jml/graphql-api/pulls/comments/92946851","pull_request_review_id":13469029,"id":92946851,"diff_hunk":"@@ -0,0 +1,65 @@\n+# Defining GraphQL type APIs\n+\n+First some imports:\n+\n+``` haskell\n+{-# LANGUAGE DataKinds #-}\n+{-# LANGUAGE TypeOperators #-}\n+{-# LANGUAGE OverloadedStrings #-}\n+module Introduction where\n+\n+import Protolude\n+\n+import GraphQL.TypedSchema (Object, Field, Argument, (:>))\n+import GraphQL.TypedApi (HandlerType, (:<>)(..))\n+```\n+\n+The core idea for this library is that we define a composite type that\n+specifies the whole API, and then implement a matching handler.\n+\n+The main GraphQL entities we care about are Objects and Fields. Each\n+Field can have arguments.\n+\n+``` haskell\n+type HelloWorld = Object \"HelloWorld\" '[]\n+  '[ Argument \"greeting\" Text :> Field \"me\" Text\n+   ]\n+```\n+\n+The example above is equivalent to the following GraphQL type:\n+\n+```\n+type HelloWorld {\n+  me(greeting: String!): String!\n+}\n+```\n+\n+And if we had a code to handle that type (more later) we could query it like this:\n+\n+```\n+{ me(greeting: \"hello\") }\n+```\n+\n+## The handler\n+\n+We defined a corresponding handler via the `HandlerType m a` which takes\n+the monad to run in (`IO` in this case) and the actual API definition\n+(`HelloWorld`).\n+\n+```haskell\n+handler :: HandlerType IO HelloWorld\n+handler = pure $ (\\greeting -> pure (greeting <> \" to me\")) :<> ()\n+```\n+\n+The implementation looks slightly weird, but it's weird for good\n+reasons. In order:\n+\n+* The first `pure` allows us to run actions in the base monad (`IO`\n+here) before returning anything. This is useful to allocate a resource like a database connection.\n+* The `pure` in the function call allows us to **avoid running\n+actions** when the field hasn't been requested. We only run the action\n+if the query specifies the field. Note that lazy evaluation would not\n+work because of the monadic nature of handlers.\n+* Finally, we have to terminate each handler with `:<> ()`. This is an","path":"docs/source/tutorial/Introduction.lhs","position":63,"original_position":63,"commit_id":"3d6f2e5fea7a94804fb138a1446cee3dfdd609d7","original_commit_id":"3d6f2e5fea7a94804fb138a1446cee3dfdd609d7","user":{"login":"teh","id":139251,"avatar_url":"https://avatars.githubusercontent.com/u/139251?v=3","gravatar_id":"","url":"https://api.github.com/users/teh","html_url":"https://github.com/teh","followers_url":"https://api.github.com/users/teh/followers","following_url":"https://api.github.com/users/teh/following{/other_user}","gists_url":"https://api.github.com/users/teh/gists{/gist_id}","starred_url":"https://api.github.com/users/teh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teh/subscriptions","organizations_url":"https://api.github.com/users/teh/orgs","repos_url":"https://api.github.com/users/teh/repos","events_url":"https://api.github.com/users/teh/events{/privacy}","received_events_url":"https://api.github.com/users/teh/received_events","type":"User","site_admin":false},"body":"Yea we did but I'm not sure we can write one. We probably need the representation to be right-side nested tupels (that's why `:<>` is infixr), but `fieldList` re-orders the tuple nesting. I.e. \r\n\r\n```\r\nfieldList (a :<> b) == (a :<> b) :<> ()\r\n```\r\nbut we need\r\n```\r\na :<> (b :<> ())\r\n```\r\n\r\nI had figured out why we need infixr but I forgot why. I might also be wrong.\r\n","created_at":"2016-12-18T18:03:48Z","updated_at":"2016-12-18T18:03:48Z","html_url":"https://github.com/jml/graphql-api/pull/19#discussion_r92946851","pull_request_url":"https://api.github.com/repos/jml/graphql-api/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/jml/graphql-api/pulls/comments/92946851"},"html":{"href":"https://github.com/jml/graphql-api/pull/19#discussion_r92946851"},"pull_request":{"href":"https://api.github.com/repos/jml/graphql-api/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/jml/graphql-api/pulls/19","id":98320882,"html_url":"https://github.com/jml/graphql-api/pull/19","diff_url":"https://github.com/jml/graphql-api/pull/19.diff","patch_url":"https://github.com/jml/graphql-api/pull/19.patch","issue_url":"https://api.github.com/repos/jml/graphql-api/issues/19","number":19,"state":"open","locked":false,"title":"Module naming","user":{"login":"teh","id":139251,"avatar_url":"https://avatars.githubusercontent.com/u/139251?v=3","gravatar_id":"","url":"https://api.github.com/users/teh","html_url":"https://github.com/teh","followers_url":"https://api.github.com/users/teh/followers","following_url":"https://api.github.com/users/teh/following{/other_user}","gists_url":"https://api.github.com/users/teh/gists{/gist_id}","starred_url":"https://api.github.com/users/teh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teh/subscriptions","organizations_url":"https://api.github.com/users/teh/orgs","repos_url":"https://api.github.com/users/teh/repos","events_url":"https://api.github.com/users/teh/events{/privacy}","received_events_url":"https://api.github.com/users/teh/received_events","type":"User","site_admin":false},"body":"What do you think about this naming? In any case, we have a branch to discuss :)","created_at":"2016-12-16T11:39:48Z","updated_at":"2016-12-18T18:03:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0eef87cd5d0d25174335a262d5d0faec9f191853","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/jml/graphql-api/milestones/1","html_url":"https://github.com/jml/graphql-api/milestone/1","labels_url":"https://api.github.com/repos/jml/graphql-api/milestones/1/labels","id":2200616,"number":1,"title":"Initial release","description":"What we want to get done before a proper release & announcement","creator":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-12-16T11:59:00Z","updated_at":"2016-12-16T14:11:15Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/jml/graphql-api/pulls/19/commits","review_comments_url":"https://api.github.com/repos/jml/graphql-api/pulls/19/comments","review_comment_url":"https://api.github.com/repos/jml/graphql-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jml/graphql-api/issues/19/comments","statuses_url":"https://api.github.com/repos/jml/graphql-api/statuses/3d6f2e5fea7a94804fb138a1446cee3dfdd609d7","head":{"label":"jml:module-naming","ref":"module-naming","sha":"3d6f2e5fea7a94804fb138a1446cee3dfdd609d7","user":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"repo":{"id":70682597,"name":"graphql-api","full_name":"jml/graphql-api","owner":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jml/graphql-api","description":"Sketchy code for GraphQL","fork":false,"url":"https://api.github.com/repos/jml/graphql-api","forks_url":"https://api.github.com/repos/jml/graphql-api/forks","keys_url":"https://api.github.com/repos/jml/graphql-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jml/graphql-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jml/graphql-api/teams","hooks_url":"https://api.github.com/repos/jml/graphql-api/hooks","issue_events_url":"https://api.github.com/repos/jml/graphql-api/issues/events{/number}","events_url":"https://api.github.com/repos/jml/graphql-api/events","assignees_url":"https://api.github.com/repos/jml/graphql-api/assignees{/user}","branches_url":"https://api.github.com/repos/jml/graphql-api/branches{/branch}","tags_url":"https://api.github.com/repos/jml/graphql-api/tags","blobs_url":"https://api.github.com/repos/jml/graphql-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jml/graphql-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jml/graphql-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/jml/graphql-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jml/graphql-api/statuses/{sha}","languages_url":"https://api.github.com/repos/jml/graphql-api/languages","stargazers_url":"https://api.github.com/repos/jml/graphql-api/stargazers","contributors_url":"https://api.github.com/repos/jml/graphql-api/contributors","subscribers_url":"https://api.github.com/repos/jml/graphql-api/subscribers","subscription_url":"https://api.github.com/repos/jml/graphql-api/subscription","commits_url":"https://api.github.com/repos/jml/graphql-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/jml/graphql-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/jml/graphql-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/jml/graphql-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/jml/graphql-api/contents/{+path}","compare_url":"https://api.github.com/repos/jml/graphql-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jml/graphql-api/merges","archive_url":"https://api.github.com/repos/jml/graphql-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jml/graphql-api/downloads","issues_url":"https://api.github.com/repos/jml/graphql-api/issues{/number}","pulls_url":"https://api.github.com/repos/jml/graphql-api/pulls{/number}","milestones_url":"https://api.github.com/repos/jml/graphql-api/milestones{/number}","notifications_url":"https://api.github.com/repos/jml/graphql-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jml/graphql-api/labels{/name}","releases_url":"https://api.github.com/repos/jml/graphql-api/releases{/id}","deployments_url":"https://api.github.com/repos/jml/graphql-api/deployments","created_at":"2016-10-12T09:06:17Z","updated_at":"2016-12-09T13:27:23Z","pushed_at":"2016-12-18T14:36:29Z","git_url":"git://github.com/jml/graphql-api.git","ssh_url":"git@github.com:jml/graphql-api.git","clone_url":"https://github.com/jml/graphql-api.git","svn_url":"https://github.com/jml/graphql-api","homepage":null,"size":420,"stargazers_count":10,"watchers_count":10,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":10,"default_branch":"master"}},"base":{"label":"jml:master","ref":"master","sha":"4c635694c8217b2d12d2055ea7fa76271eb05fbf","user":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"repo":{"id":70682597,"name":"graphql-api","full_name":"jml/graphql-api","owner":{"login":"jml","id":125674,"avatar_url":"https://avatars.githubusercontent.com/u/125674?v=3","gravatar_id":"","url":"https://api.github.com/users/jml","html_url":"https://github.com/jml","followers_url":"https://api.github.com/users/jml/followers","following_url":"https://api.github.com/users/jml/following{/other_user}","gists_url":"https://api.github.com/users/jml/gists{/gist_id}","starred_url":"https://api.github.com/users/jml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jml/subscriptions","organizations_url":"https://api.github.com/users/jml/orgs","repos_url":"https://api.github.com/users/jml/repos","events_url":"https://api.github.com/users/jml/events{/privacy}","received_events_url":"https://api.github.com/users/jml/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jml/graphql-api","description":"Sketchy code for GraphQL","fork":false,"url":"https://api.github.com/repos/jml/graphql-api","forks_url":"https://api.github.com/repos/jml/graphql-api/forks","keys_url":"https://api.github.com/repos/jml/graphql-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jml/graphql-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jml/graphql-api/teams","hooks_url":"https://api.github.com/repos/jml/graphql-api/hooks","issue_events_url":"https://api.github.com/repos/jml/graphql-api/issues/events{/number}","events_url":"https://api.github.com/repos/jml/graphql-api/events","assignees_url":"https://api.github.com/repos/jml/graphql-api/assignees{/user}","branches_url":"https://api.github.com/repos/jml/graphql-api/branches{/branch}","tags_url":"https://api.github.com/repos/jml/graphql-api/tags","blobs_url":"https://api.github.com/repos/jml/graphql-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jml/graphql-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jml/graphql-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/jml/graphql-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jml/graphql-api/statuses/{sha}","languages_url":"https://api.github.com/repos/jml/graphql-api/languages","stargazers_url":"https://api.github.com/repos/jml/graphql-api/stargazers","contributors_url":"https://api.github.com/repos/jml/graphql-api/contributors","subscribers_url":"https://api.github.com/repos/jml/graphql-api/subscribers","subscription_url":"https://api.github.com/repos/jml/graphql-api/subscription","commits_url":"https://api.github.com/repos/jml/graphql-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/jml/graphql-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/jml/graphql-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/jml/graphql-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/jml/graphql-api/contents/{+path}","compare_url":"https://api.github.com/repos/jml/graphql-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jml/graphql-api/merges","archive_url":"https://api.github.com/repos/jml/graphql-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jml/graphql-api/downloads","issues_url":"https://api.github.com/repos/jml/graphql-api/issues{/number}","pulls_url":"https://api.github.com/repos/jml/graphql-api/pulls{/number}","milestones_url":"https://api.github.com/repos/jml/graphql-api/milestones{/number}","notifications_url":"https://api.github.com/repos/jml/graphql-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jml/graphql-api/labels{/name}","releases_url":"https://api.github.com/repos/jml/graphql-api/releases{/id}","deployments_url":"https://api.github.com/repos/jml/graphql-api/deployments","created_at":"2016-10-12T09:06:17Z","updated_at":"2016-12-09T13:27:23Z","pushed_at":"2016-12-18T14:36:29Z","git_url":"git://github.com/jml/graphql-api.git","ssh_url":"git@github.com:jml/graphql-api.git","clone_url":"https://github.com/jml/graphql-api.git","svn_url":"https://github.com/jml/graphql-api","homepage":null,"size":420,"stargazers_count":10,"watchers_count":10,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jml/graphql-api/pulls/19"},"html":{"href":"https://github.com/jml/graphql-api/pull/19"},"issue":{"href":"https://api.github.com/repos/jml/graphql-api/issues/19"},"comments":{"href":"https://api.github.com/repos/jml/graphql-api/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/jml/graphql-api/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/jml/graphql-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jml/graphql-api/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/jml/graphql-api/statuses/3d6f2e5fea7a94804fb138a1446cee3dfdd609d7"}}}}
{"actor":{"display_login":"teh"}}