{"action":"created","comment":{"url":"https://api.github.com/repos/slamdata/matryoshka/pulls/comments/62930011","id":62930011,"diff_hunk":"@@ -316,24 +343,86 @@ package object matryoshka extends CofreeInstances with FreeInstances {\n \n   /** Count the instinces of `form` in the structure.\n     */\n-  def count[T[_[_]]: Recursive, F[_]: Functor: Foldable](form: T[F]): F[(T[F], Int)] => Int =\n+  def count[T[_[_]]: Recursive, F[_]: Functor: Foldable](form: T[F]):\n+      F[(T[F], Int)] => Int =\n     e => e.foldRight(if (e ∘ (_._1) == form.project) 1 else 0)(_._2 + _)\n \n-  implicit def ToIdOps[A](a: A): IdOps[A] = new IdOps[A](a)\n+  /** The number of nodes in this structure.\n+    */\n+  def size[F[_]: Foldable]: F[Int] => Int = _.foldRight(1)(_ + _)\n+\n+  /** The largest number of hops from a node to a leaf.\n+    */\n+  def height[F[_]: Foldable]: F[Int] => Int = _.foldRight(0)(_ max _)\n+\n+  /** Combines a tuple of zippable functors.\n+    */\n+  def zipTuple[T[_[_]]: Recursive, F[_]: Functor: Zip]:\n+      Coalgebra[F, (T[F], T[F])] =\n+    p => Zip[F].zip[T[F], T[F]](p._1.project, p._2.project)\n+\n+  /** Aligns “These” into a single structure, short-circuting when we hit a\n+    * “This” or “That”.\n+    */\n+  def alignThese[T[_[_]]: Recursive, F[_]: Align]:\n+      ElgotCoalgebra[T[F] \\/ ?, F, T[F] \\&/ T[F]] =\n+    _.fold(_.left, _.left, (a, b) => a.project.align(b.project).right)\n \n-  implicit def ToCorecursiveOps[T[_[_]]: Corecursive, F[_]](f: F[T[F]]):\n-      CorecursiveOps[T, F] =\n-    new CorecursiveOps[T, F](f)\n+  /** Merges a tuple of functors, if possible.\n+    */\n+  def mergeTuple[T[_[_]]: Recursive, F[_]: Functor: Merge]:\n+      CoalgebraM[Option, F, (T[F], T[F])] =\n+    p => Merge[F].merge[T[F], T[F]](p._1.project, p._2.project)\n+\n+  /** Generates an infinite sequence from two seed values.\n+    */\n+  def binarySequence[A](relation: (A, A) => A): Coalgebra[(A, ?), (A, A)] = {\n+    case (a1, a2) =>\n+      val c = relation(a1, a2)\n+      (c, (a2, c))\n+  }\n+\n+  /** Converts a fixed-point structure into a generic Tree.\n+    * One use of this is using `.cata(toTree).drawTree` rather than `.show` to\n+    * get a pretty-printed tree.\n+    */\n+  def toTree[F[_]: Functor: Foldable]: Algebra[F, Tree[F[Unit]]] =\n+    x => Tree.Node(x.void, x.toStream)","path":"core/src/main/scala/matryoshka/package.scala","position":130,"original_position":130,"commit_id":"f42017d306d2d07e257cb712e10e74159dab0d03","original_commit_id":"f42017d306d2d07e257cb712e10e74159dab0d03","user":{"login":"mossprescott","id":6147371,"avatar_url":"https://avatars.githubusercontent.com/u/6147371?v=3","gravatar_id":"","url":"https://api.github.com/users/mossprescott","html_url":"https://github.com/mossprescott","followers_url":"https://api.github.com/users/mossprescott/followers","following_url":"https://api.github.com/users/mossprescott/following{/other_user}","gists_url":"https://api.github.com/users/mossprescott/gists{/gist_id}","starred_url":"https://api.github.com/users/mossprescott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mossprescott/subscriptions","organizations_url":"https://api.github.com/users/mossprescott/orgs","repos_url":"https://api.github.com/users/mossprescott/repos","events_url":"https://api.github.com/users/mossprescott/events{/privacy}","received_events_url":"https://api.github.com/users/mossprescott/received_events","type":"User","site_admin":false},"body":"I'm not convinced we would actually use this because the `()`s uglify the result with any sensible Show, but it's clever and that's enough.","created_at":"2016-05-11T21:26:36Z","updated_at":"2016-05-11T21:26:36Z","html_url":"https://github.com/slamdata/matryoshka/pull/23#discussion_r62930011","pull_request_url":"https://api.github.com/repos/slamdata/matryoshka/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/slamdata/matryoshka/pulls/comments/62930011"},"html":{"href":"https://github.com/slamdata/matryoshka/pull/23#discussion_r62930011"},"pull_request":{"href":"https://api.github.com/repos/slamdata/matryoshka/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/slamdata/matryoshka/pulls/23","id":68435265,"html_url":"https://github.com/slamdata/matryoshka/pull/23","diff_url":"https://github.com/slamdata/matryoshka/pull/23.diff","patch_url":"https://github.com/slamdata/matryoshka/pull/23.patch","issue_url":"https://api.github.com/repos/slamdata/matryoshka/issues/23","number":23,"state":"open","locked":false,"title":"A few additions around fixed-point type aliases.","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"body":"- Add type aliases for various types (like `Free` and `Cofree`) to show\r\n  the equivalences, and start moving toward fixed-point alternatives.\r\n- Add `AlgebraIso` to make isomorphic algebras explicit.\r\n- A few new pattern functors (in their own package) – `CoEnv`, `ListF`,\r\n  `Diff`, and `PotentialFailue`.\r\n- Add some tests for the Stream alias (mostly just to have a place to put some coalgebras I had written).","created_at":"2016-04-29T21:17:05Z","updated_at":"2016-05-11T21:26:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b83dd61d51156986971f6d5fcfa7af27215a9629","assignee":{"login":"mossprescott","id":6147371,"avatar_url":"https://avatars.githubusercontent.com/u/6147371?v=3","gravatar_id":"","url":"https://api.github.com/users/mossprescott","html_url":"https://github.com/mossprescott","followers_url":"https://api.github.com/users/mossprescott/followers","following_url":"https://api.github.com/users/mossprescott/following{/other_user}","gists_url":"https://api.github.com/users/mossprescott/gists{/gist_id}","starred_url":"https://api.github.com/users/mossprescott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mossprescott/subscriptions","organizations_url":"https://api.github.com/users/mossprescott/orgs","repos_url":"https://api.github.com/users/mossprescott/repos","events_url":"https://api.github.com/users/mossprescott/events{/privacy}","received_events_url":"https://api.github.com/users/mossprescott/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/slamdata/matryoshka/pulls/23/commits","review_comments_url":"https://api.github.com/repos/slamdata/matryoshka/pulls/23/comments","review_comment_url":"https://api.github.com/repos/slamdata/matryoshka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/slamdata/matryoshka/issues/23/comments","statuses_url":"https://api.github.com/repos/slamdata/matryoshka/statuses/f42017d306d2d07e257cb712e10e74159dab0d03","head":{"label":"sellout:common-types","ref":"common-types","sha":"f42017d306d2d07e257cb712e10e74159dab0d03","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"repo":{"id":50270731,"name":"matryoshka","full_name":"sellout/matryoshka","owner":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sellout/matryoshka","description":"Generalized recursion schemes and traversals for Scala.","fork":true,"url":"https://api.github.com/repos/sellout/matryoshka","forks_url":"https://api.github.com/repos/sellout/matryoshka/forks","keys_url":"https://api.github.com/repos/sellout/matryoshka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sellout/matryoshka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sellout/matryoshka/teams","hooks_url":"https://api.github.com/repos/sellout/matryoshka/hooks","issue_events_url":"https://api.github.com/repos/sellout/matryoshka/issues/events{/number}","events_url":"https://api.github.com/repos/sellout/matryoshka/events","assignees_url":"https://api.github.com/repos/sellout/matryoshka/assignees{/user}","branches_url":"https://api.github.com/repos/sellout/matryoshka/branches{/branch}","tags_url":"https://api.github.com/repos/sellout/matryoshka/tags","blobs_url":"https://api.github.com/repos/sellout/matryoshka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sellout/matryoshka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sellout/matryoshka/git/refs{/sha}","trees_url":"https://api.github.com/repos/sellout/matryoshka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sellout/matryoshka/statuses/{sha}","languages_url":"https://api.github.com/repos/sellout/matryoshka/languages","stargazers_url":"https://api.github.com/repos/sellout/matryoshka/stargazers","contributors_url":"https://api.github.com/repos/sellout/matryoshka/contributors","subscribers_url":"https://api.github.com/repos/sellout/matryoshka/subscribers","subscription_url":"https://api.github.com/repos/sellout/matryoshka/subscription","commits_url":"https://api.github.com/repos/sellout/matryoshka/commits{/sha}","git_commits_url":"https://api.github.com/repos/sellout/matryoshka/git/commits{/sha}","comments_url":"https://api.github.com/repos/sellout/matryoshka/comments{/number}","issue_comment_url":"https://api.github.com/repos/sellout/matryoshka/issues/comments{/number}","contents_url":"https://api.github.com/repos/sellout/matryoshka/contents/{+path}","compare_url":"https://api.github.com/repos/sellout/matryoshka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sellout/matryoshka/merges","archive_url":"https://api.github.com/repos/sellout/matryoshka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sellout/matryoshka/downloads","issues_url":"https://api.github.com/repos/sellout/matryoshka/issues{/number}","pulls_url":"https://api.github.com/repos/sellout/matryoshka/pulls{/number}","milestones_url":"https://api.github.com/repos/sellout/matryoshka/milestones{/number}","notifications_url":"https://api.github.com/repos/sellout/matryoshka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sellout/matryoshka/labels{/name}","releases_url":"https://api.github.com/repos/sellout/matryoshka/releases{/id}","deployments_url":"https://api.github.com/repos/sellout/matryoshka/deployments","created_at":"2016-01-24T03:37:28Z","updated_at":"2016-03-07T04:04:17Z","pushed_at":"2016-05-11T04:19:51Z","git_url":"git://github.com/sellout/matryoshka.git","ssh_url":"git@github.com:sellout/matryoshka.git","clone_url":"https://github.com/sellout/matryoshka.git","svn_url":"https://github.com/sellout/matryoshka","homepage":null,"size":6347,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"slamdata:master","ref":"master","sha":"c4d416ccb125ab963560beb817c9633e6e0fb711","user":{"login":"slamdata","id":5385602,"avatar_url":"https://avatars.githubusercontent.com/u/5385602?v=3","gravatar_id":"","url":"https://api.github.com/users/slamdata","html_url":"https://github.com/slamdata","followers_url":"https://api.github.com/users/slamdata/followers","following_url":"https://api.github.com/users/slamdata/following{/other_user}","gists_url":"https://api.github.com/users/slamdata/gists{/gist_id}","starred_url":"https://api.github.com/users/slamdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slamdata/subscriptions","organizations_url":"https://api.github.com/users/slamdata/orgs","repos_url":"https://api.github.com/users/slamdata/repos","events_url":"https://api.github.com/users/slamdata/events{/privacy}","received_events_url":"https://api.github.com/users/slamdata/received_events","type":"Organization","site_admin":false},"repo":{"id":49952408,"name":"matryoshka","full_name":"slamdata/matryoshka","owner":{"login":"slamdata","id":5385602,"avatar_url":"https://avatars.githubusercontent.com/u/5385602?v=3","gravatar_id":"","url":"https://api.github.com/users/slamdata","html_url":"https://github.com/slamdata","followers_url":"https://api.github.com/users/slamdata/followers","following_url":"https://api.github.com/users/slamdata/following{/other_user}","gists_url":"https://api.github.com/users/slamdata/gists{/gist_id}","starred_url":"https://api.github.com/users/slamdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slamdata/subscriptions","organizations_url":"https://api.github.com/users/slamdata/orgs","repos_url":"https://api.github.com/users/slamdata/repos","events_url":"https://api.github.com/users/slamdata/events{/privacy}","received_events_url":"https://api.github.com/users/slamdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/slamdata/matryoshka","description":"Generalized recursion schemes and traversals for Scala.","fork":false,"url":"https://api.github.com/repos/slamdata/matryoshka","forks_url":"https://api.github.com/repos/slamdata/matryoshka/forks","keys_url":"https://api.github.com/repos/slamdata/matryoshka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slamdata/matryoshka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slamdata/matryoshka/teams","hooks_url":"https://api.github.com/repos/slamdata/matryoshka/hooks","issue_events_url":"https://api.github.com/repos/slamdata/matryoshka/issues/events{/number}","events_url":"https://api.github.com/repos/slamdata/matryoshka/events","assignees_url":"https://api.github.com/repos/slamdata/matryoshka/assignees{/user}","branches_url":"https://api.github.com/repos/slamdata/matryoshka/branches{/branch}","tags_url":"https://api.github.com/repos/slamdata/matryoshka/tags","blobs_url":"https://api.github.com/repos/slamdata/matryoshka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slamdata/matryoshka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slamdata/matryoshka/git/refs{/sha}","trees_url":"https://api.github.com/repos/slamdata/matryoshka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slamdata/matryoshka/statuses/{sha}","languages_url":"https://api.github.com/repos/slamdata/matryoshka/languages","stargazers_url":"https://api.github.com/repos/slamdata/matryoshka/stargazers","contributors_url":"https://api.github.com/repos/slamdata/matryoshka/contributors","subscribers_url":"https://api.github.com/repos/slamdata/matryoshka/subscribers","subscription_url":"https://api.github.com/repos/slamdata/matryoshka/subscription","commits_url":"https://api.github.com/repos/slamdata/matryoshka/commits{/sha}","git_commits_url":"https://api.github.com/repos/slamdata/matryoshka/git/commits{/sha}","comments_url":"https://api.github.com/repos/slamdata/matryoshka/comments{/number}","issue_comment_url":"https://api.github.com/repos/slamdata/matryoshka/issues/comments{/number}","contents_url":"https://api.github.com/repos/slamdata/matryoshka/contents/{+path}","compare_url":"https://api.github.com/repos/slamdata/matryoshka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slamdata/matryoshka/merges","archive_url":"https://api.github.com/repos/slamdata/matryoshka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slamdata/matryoshka/downloads","issues_url":"https://api.github.com/repos/slamdata/matryoshka/issues{/number}","pulls_url":"https://api.github.com/repos/slamdata/matryoshka/pulls{/number}","milestones_url":"https://api.github.com/repos/slamdata/matryoshka/milestones{/number}","notifications_url":"https://api.github.com/repos/slamdata/matryoshka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slamdata/matryoshka/labels{/name}","releases_url":"https://api.github.com/repos/slamdata/matryoshka/releases{/id}","deployments_url":"https://api.github.com/repos/slamdata/matryoshka/deployments","created_at":"2016-01-19T12:52:07Z","updated_at":"2016-05-09T22:53:30Z","pushed_at":"2016-05-11T04:19:53Z","git_url":"git://github.com/slamdata/matryoshka.git","ssh_url":"git@github.com:slamdata/matryoshka.git","clone_url":"https://github.com/slamdata/matryoshka.git","svn_url":"https://github.com/slamdata/matryoshka","homepage":null,"size":6317,"stargazers_count":57,"watchers_count":57,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":7,"forks":8,"open_issues":7,"watchers":57,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/slamdata/matryoshka/pulls/23"},"html":{"href":"https://github.com/slamdata/matryoshka/pull/23"},"issue":{"href":"https://api.github.com/repos/slamdata/matryoshka/issues/23"},"comments":{"href":"https://api.github.com/repos/slamdata/matryoshka/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/slamdata/matryoshka/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/slamdata/matryoshka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/slamdata/matryoshka/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/slamdata/matryoshka/statuses/f42017d306d2d07e257cb712e10e74159dab0d03"}}}}