{"action":"created","comment":{"url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/comments/28922360","id":28922360,"diff_hunk":"@@ -13,51 +15,84 @@ import process1._\n  *   conditions. See $MutableProcess1 for more information.\n  */\n object hash {\n+  /** responsible for providing a MessageDigest for a type */\n+  trait Digestable[A] {\n+    def newDigester: MessageDigest\n+  }\n+\n+  object Digestable {\n+    def apply[A: Digestable] = implicitly[Digestable[A]]\n+\n+    def named[A](algorithm: String): Digestable[A] =\n+      new Digestable[A] {\n+        def newDigester =\n+          MessageDigest.getInstance(algorithm)\n+      }\n+  }\n+\n+  sealed trait MD2\n+  implicit val MD2Digestable = Digestable.named[MD2](\"MD2\")\n+\n+  sealed trait MD5\n+  implicit val MD5Digestable = Digestable.named[MD5](\"MD5\")\n+\n+  sealed trait SHA1\n+  implicit val SHA1Digestable = Digestable.named[SHA1](\"SHA-1\")\n+\n+  sealed trait SHA256\n+  implicit val SHA256Digestable = Digestable.named[SHA256](\"SHA-256\")\n+\n+  sealed trait SHA384\n+  implicit val SHA384Digestable = Digestable.named[SHA384](\"SHA-384\")\n+\n+  sealed trait SHA512\n+  implicit val SHA512Digestable = Digestable.named[SHA512](\"SHA-512\")\n+\n   /**\n    * Computes the MD2 hash of the input elements.\n    * $MutableImpl\n    */\n-  val md2: Process1[ByteVector,ByteVector] = messageDigest(\"MD2\")\n+  val md2: Process1[ByteVector,ByteVector @@ MD2] = messageDigest[MD2]\n \n   /**\n    * Computes the MD5 hash of the input elements.\n    * $MutableImpl\n    */\n-  val md5: Process1[ByteVector,ByteVector] = messageDigest(\"MD5\")\n+  val md5: Process1[ByteVector,ByteVector @@ MD5] = messageDigest[MD5]\n \n   /**\n    * Computes the SHA-1 hash of the input elements.\n    * $MutableImpl\n    */\n-  val sha1: Process1[ByteVector,ByteVector] = messageDigest(\"SHA-1\")\n+  val sha1: Process1[ByteVector,ByteVector @@ SHA1] = messageDigest[SHA1]\n \n   /**\n    * Computes the SHA-256 hash of the input elements.\n    * $MutableImpl\n    */\n-  val sha256: Process1[ByteVector,ByteVector] = messageDigest(\"SHA-256\")\n+  val sha256: Process1[ByteVector,ByteVector @@ SHA256] = messageDigest[SHA256]\n \n   /**\n    * Computes the SHA-384 hash of the input elements.\n    * $MutableImpl\n    */\n-  val sha384: Process1[ByteVector,ByteVector] = messageDigest(\"SHA-384\")\n+  val sha384: Process1[ByteVector,ByteVector @@ SHA384] = messageDigest[SHA384]\n \n   /**\n    * Computes the SHA-512 hash of the input elements.\n    * $MutableImpl\n    */\n-  val sha512: Process1[ByteVector,ByteVector] = messageDigest(\"SHA-512\")\n+  val sha512: Process1[ByteVector,ByteVector @@ SHA512] = messageDigest[SHA512]\n \n-  private def messageDigest(algorithm: String): Process1[ByteVector,ByteVector] = {\n-    def go(digest: MessageDigest): Process1[ByteVector,ByteVector] =\n+  private def messageDigest[A: Digestable]: Process1[ByteVector,ByteVector @@ A] = {","path":"src/main/scala/scalaz/stream/hash.scala","position":90,"original_position":90,"commit_id":"e71b9aeed1e0424e2563f63155a39f0d0ebc0635","original_commit_id":"e71b9aeed1e0424e2563f63155a39f0d0ebc0635","user":{"login":"jedws","id":228337,"avatar_url":"https://avatars.githubusercontent.com/u/228337?v=3","gravatar_id":"","url":"https://api.github.com/users/jedws","html_url":"https://github.com/jedws","followers_url":"https://api.github.com/users/jedws/followers","following_url":"https://api.github.com/users/jedws/following{/other_user}","gists_url":"https://api.github.com/users/jedws/gists{/gist_id}","starred_url":"https://api.github.com/users/jedws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedws/subscriptions","organizations_url":"https://api.github.com/users/jedws/orgs","repos_url":"https://api.github.com/users/jedws/repos","events_url":"https://api.github.com/users/jedws/events{/privacy}","received_events_url":"https://api.github.com/users/jedws/received_events","type":"User","site_admin":false},"body":"absolutely! I did indeed intend to make it public.\r\n\r\nI'll make the `Digestible.named` locally private, need a total factory method instead.","created_at":"2015-04-22T22:48:13Z","updated_at":"2015-04-22T22:48:13Z","html_url":"https://github.com/scalaz/scalaz-stream/pull/370#discussion_r28922360","pull_request_url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370","_links":{"self":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/comments/28922360"},"html":{"href":"https://github.com/scalaz/scalaz-stream/pull/370#discussion_r28922360"},"pull_request":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370"}}},"pull_request":{"url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370","id":33647308,"html_url":"https://github.com/scalaz/scalaz-stream/pull/370","diff_url":"https://github.com/scalaz/scalaz-stream/pull/370.diff","patch_url":"https://github.com/scalaz/scalaz-stream/pull/370.patch","issue_url":"https://api.github.com/repos/scalaz/scalaz-stream/issues/370","number":370,"state":"open","locked":false,"title":"hash improvements, performance and type-safety","user":{"login":"jedws","id":228337,"avatar_url":"https://avatars.githubusercontent.com/u/228337?v=3","gravatar_id":"","url":"https://api.github.com/users/jedws","html_url":"https://github.com/jedws","followers_url":"https://api.github.com/users/jedws/followers","following_url":"https://api.github.com/users/jedws/following{/other_user}","gists_url":"https://api.github.com/users/jedws/gists{/gist_id}","starred_url":"https://api.github.com/users/jedws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedws/subscriptions","organizations_url":"https://api.github.com/users/jedws/orgs","repos_url":"https://api.github.com/users/jedws/repos","events_url":"https://api.github.com/users/jedws/events{/privacy}","received_events_url":"https://api.github.com/users/jedws/received_events","type":"User","site_admin":false},"body":"uses ByteBuffer to supply the bytes to the MessageDigest for performance improvement, tags the returned ByteVectors as being of a specific output type matching the selected hash algorithm, and provides a typeclass like provider for the MessageDigest selection","created_at":"2015-04-20T09:13:31Z","updated_at":"2015-04-22T22:48:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2ce4c2df90457e147dc144d4ef2d345c07ae391","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370/commits","review_comments_url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370/comments","review_comment_url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scalaz/scalaz-stream/issues/370/comments","statuses_url":"https://api.github.com/repos/scalaz/scalaz-stream/statuses/e71b9aeed1e0424e2563f63155a39f0d0ebc0635","head":{"label":"jedws:topic/more-typesafe-hash","ref":"topic/more-typesafe-hash","sha":"e71b9aeed1e0424e2563f63155a39f0d0ebc0635","user":{"login":"jedws","id":228337,"avatar_url":"https://avatars.githubusercontent.com/u/228337?v=3","gravatar_id":"","url":"https://api.github.com/users/jedws","html_url":"https://github.com/jedws","followers_url":"https://api.github.com/users/jedws/followers","following_url":"https://api.github.com/users/jedws/following{/other_user}","gists_url":"https://api.github.com/users/jedws/gists{/gist_id}","starred_url":"https://api.github.com/users/jedws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedws/subscriptions","organizations_url":"https://api.github.com/users/jedws/orgs","repos_url":"https://api.github.com/users/jedws/repos","events_url":"https://api.github.com/users/jedws/events{/privacy}","received_events_url":"https://api.github.com/users/jedws/received_events","type":"User","site_admin":false},"repo":{"id":18272637,"name":"scalaz-stream","full_name":"jedws/scalaz-stream","owner":{"login":"jedws","id":228337,"avatar_url":"https://avatars.githubusercontent.com/u/228337?v=3","gravatar_id":"","url":"https://api.github.com/users/jedws","html_url":"https://github.com/jedws","followers_url":"https://api.github.com/users/jedws/followers","following_url":"https://api.github.com/users/jedws/following{/other_user}","gists_url":"https://api.github.com/users/jedws/gists{/gist_id}","starred_url":"https://api.github.com/users/jedws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedws/subscriptions","organizations_url":"https://api.github.com/users/jedws/orgs","repos_url":"https://api.github.com/users/jedws/repos","events_url":"https://api.github.com/users/jedws/events{/privacy}","received_events_url":"https://api.github.com/users/jedws/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jedws/scalaz-stream","description":"Compositional, streaming I/O library for Scala","fork":true,"url":"https://api.github.com/repos/jedws/scalaz-stream","forks_url":"https://api.github.com/repos/jedws/scalaz-stream/forks","keys_url":"https://api.github.com/repos/jedws/scalaz-stream/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jedws/scalaz-stream/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jedws/scalaz-stream/teams","hooks_url":"https://api.github.com/repos/jedws/scalaz-stream/hooks","issue_events_url":"https://api.github.com/repos/jedws/scalaz-stream/issues/events{/number}","events_url":"https://api.github.com/repos/jedws/scalaz-stream/events","assignees_url":"https://api.github.com/repos/jedws/scalaz-stream/assignees{/user}","branches_url":"https://api.github.com/repos/jedws/scalaz-stream/branches{/branch}","tags_url":"https://api.github.com/repos/jedws/scalaz-stream/tags","blobs_url":"https://api.github.com/repos/jedws/scalaz-stream/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jedws/scalaz-stream/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jedws/scalaz-stream/git/refs{/sha}","trees_url":"https://api.github.com/repos/jedws/scalaz-stream/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jedws/scalaz-stream/statuses/{sha}","languages_url":"https://api.github.com/repos/jedws/scalaz-stream/languages","stargazers_url":"https://api.github.com/repos/jedws/scalaz-stream/stargazers","contributors_url":"https://api.github.com/repos/jedws/scalaz-stream/contributors","subscribers_url":"https://api.github.com/repos/jedws/scalaz-stream/subscribers","subscription_url":"https://api.github.com/repos/jedws/scalaz-stream/subscription","commits_url":"https://api.github.com/repos/jedws/scalaz-stream/commits{/sha}","git_commits_url":"https://api.github.com/repos/jedws/scalaz-stream/git/commits{/sha}","comments_url":"https://api.github.com/repos/jedws/scalaz-stream/comments{/number}","issue_comment_url":"https://api.github.com/repos/jedws/scalaz-stream/issues/comments{/number}","contents_url":"https://api.github.com/repos/jedws/scalaz-stream/contents/{+path}","compare_url":"https://api.github.com/repos/jedws/scalaz-stream/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jedws/scalaz-stream/merges","archive_url":"https://api.github.com/repos/jedws/scalaz-stream/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jedws/scalaz-stream/downloads","issues_url":"https://api.github.com/repos/jedws/scalaz-stream/issues{/number}","pulls_url":"https://api.github.com/repos/jedws/scalaz-stream/pulls{/number}","milestones_url":"https://api.github.com/repos/jedws/scalaz-stream/milestones{/number}","notifications_url":"https://api.github.com/repos/jedws/scalaz-stream/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jedws/scalaz-stream/labels{/name}","releases_url":"https://api.github.com/repos/jedws/scalaz-stream/releases{/id}","created_at":"2014-03-30T20:08:05Z","updated_at":"2014-04-21T00:13:38Z","pushed_at":"2015-04-20T09:12:32Z","git_url":"git://github.com/jedws/scalaz-stream.git","ssh_url":"git@github.com:jedws/scalaz-stream.git","clone_url":"https://github.com/jedws/scalaz-stream.git","svn_url":"https://github.com/jedws/scalaz-stream","homepage":"","size":1455,"stargazers_count":0,"watchers_count":0,"language":"Scala","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":"scalaz:master","ref":"master","sha":"8ceb7746455c7389c306f44764a051f7afb135c5","user":{"login":"scalaz","id":183416,"avatar_url":"https://avatars.githubusercontent.com/u/183416?v=3","gravatar_id":"","url":"https://api.github.com/users/scalaz","html_url":"https://github.com/scalaz","followers_url":"https://api.github.com/users/scalaz/followers","following_url":"https://api.github.com/users/scalaz/following{/other_user}","gists_url":"https://api.github.com/users/scalaz/gists{/gist_id}","starred_url":"https://api.github.com/users/scalaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalaz/subscriptions","organizations_url":"https://api.github.com/users/scalaz/orgs","repos_url":"https://api.github.com/users/scalaz/repos","events_url":"https://api.github.com/users/scalaz/events{/privacy}","received_events_url":"https://api.github.com/users/scalaz/received_events","type":"Organization","site_admin":false},"repo":{"id":8609125,"name":"scalaz-stream","full_name":"scalaz/scalaz-stream","owner":{"login":"scalaz","id":183416,"avatar_url":"https://avatars.githubusercontent.com/u/183416?v=3","gravatar_id":"","url":"https://api.github.com/users/scalaz","html_url":"https://github.com/scalaz","followers_url":"https://api.github.com/users/scalaz/followers","following_url":"https://api.github.com/users/scalaz/following{/other_user}","gists_url":"https://api.github.com/users/scalaz/gists{/gist_id}","starred_url":"https://api.github.com/users/scalaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalaz/subscriptions","organizations_url":"https://api.github.com/users/scalaz/orgs","repos_url":"https://api.github.com/users/scalaz/repos","events_url":"https://api.github.com/users/scalaz/events{/privacy}","received_events_url":"https://api.github.com/users/scalaz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scalaz/scalaz-stream","description":"Compositional, streaming I/O library for Scala","fork":false,"url":"https://api.github.com/repos/scalaz/scalaz-stream","forks_url":"https://api.github.com/repos/scalaz/scalaz-stream/forks","keys_url":"https://api.github.com/repos/scalaz/scalaz-stream/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scalaz/scalaz-stream/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scalaz/scalaz-stream/teams","hooks_url":"https://api.github.com/repos/scalaz/scalaz-stream/hooks","issue_events_url":"https://api.github.com/repos/scalaz/scalaz-stream/issues/events{/number}","events_url":"https://api.github.com/repos/scalaz/scalaz-stream/events","assignees_url":"https://api.github.com/repos/scalaz/scalaz-stream/assignees{/user}","branches_url":"https://api.github.com/repos/scalaz/scalaz-stream/branches{/branch}","tags_url":"https://api.github.com/repos/scalaz/scalaz-stream/tags","blobs_url":"https://api.github.com/repos/scalaz/scalaz-stream/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scalaz/scalaz-stream/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scalaz/scalaz-stream/git/refs{/sha}","trees_url":"https://api.github.com/repos/scalaz/scalaz-stream/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scalaz/scalaz-stream/statuses/{sha}","languages_url":"https://api.github.com/repos/scalaz/scalaz-stream/languages","stargazers_url":"https://api.github.com/repos/scalaz/scalaz-stream/stargazers","contributors_url":"https://api.github.com/repos/scalaz/scalaz-stream/contributors","subscribers_url":"https://api.github.com/repos/scalaz/scalaz-stream/subscribers","subscription_url":"https://api.github.com/repos/scalaz/scalaz-stream/subscription","commits_url":"https://api.github.com/repos/scalaz/scalaz-stream/commits{/sha}","git_commits_url":"https://api.github.com/repos/scalaz/scalaz-stream/git/commits{/sha}","comments_url":"https://api.github.com/repos/scalaz/scalaz-stream/comments{/number}","issue_comment_url":"https://api.github.com/repos/scalaz/scalaz-stream/issues/comments{/number}","contents_url":"https://api.github.com/repos/scalaz/scalaz-stream/contents/{+path}","compare_url":"https://api.github.com/repos/scalaz/scalaz-stream/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scalaz/scalaz-stream/merges","archive_url":"https://api.github.com/repos/scalaz/scalaz-stream/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scalaz/scalaz-stream/downloads","issues_url":"https://api.github.com/repos/scalaz/scalaz-stream/issues{/number}","pulls_url":"https://api.github.com/repos/scalaz/scalaz-stream/pulls{/number}","milestones_url":"https://api.github.com/repos/scalaz/scalaz-stream/milestones{/number}","notifications_url":"https://api.github.com/repos/scalaz/scalaz-stream/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scalaz/scalaz-stream/labels{/name}","releases_url":"https://api.github.com/repos/scalaz/scalaz-stream/releases{/id}","created_at":"2013-03-06T17:34:15Z","updated_at":"2015-04-21T03:29:05Z","pushed_at":"2015-04-20T18:40:59Z","git_url":"git://github.com/scalaz/scalaz-stream.git","ssh_url":"git@github.com:scalaz/scalaz-stream.git","clone_url":"https://github.com/scalaz/scalaz-stream.git","svn_url":"https://github.com/scalaz/scalaz-stream","homepage":"","size":6507,"stargazers_count":333,"watchers_count":333,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":92,"mirror_url":null,"open_issues_count":33,"forks":92,"open_issues":33,"watchers":333,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370"},"html":{"href":"https://github.com/scalaz/scalaz-stream/pull/370"},"issue":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/issues/370"},"comments":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/issues/370/comments"},"review_comments":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370/comments"},"review_comment":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/pulls/370/commits"},"statuses":{"href":"https://api.github.com/repos/scalaz/scalaz-stream/statuses/e71b9aeed1e0424e2563f63155a39f0d0ebc0635"}}}}