{"action":"created","issue":{"url":"https://api.github.com/repos/finagle/finch/issues/1044","repository_url":"https://api.github.com/repos/finagle/finch","labels_url":"https://api.github.com/repos/finagle/finch/issues/1044/labels{/name}","comments_url":"https://api.github.com/repos/finagle/finch/issues/1044/comments","events_url":"https://api.github.com/repos/finagle/finch/issues/1044/events","html_url":"https://github.com/finagle/finch/issues/1044","id":384188306,"node_id":"MDU6SXNzdWUzODQxODgzMDY=","number":1044,"title":"add support for FunctionK","user":{"login":"jcouyang","id":1235045,"node_id":"MDQ6VXNlcjEyMzUwNDU=","avatar_url":"https://avatars1.githubusercontent.com/u/1235045?v=4","gravatar_id":"","url":"https://api.github.com/users/jcouyang","html_url":"https://github.com/jcouyang","followers_url":"https://api.github.com/users/jcouyang/followers","following_url":"https://api.github.com/users/jcouyang/following{/other_user}","gists_url":"https://api.github.com/users/jcouyang/gists{/gist_id}","starred_url":"https://api.github.com/users/jcouyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcouyang/subscriptions","organizations_url":"https://api.github.com/users/jcouyang/orgs","repos_url":"https://api.github.com/users/jcouyang/repos","events_url":"https://api.github.com/users/jcouyang/events{/privacy}","received_events_url":"https://api.github.com/users/jcouyang/received_events","type":"User","site_admin":false},"labels":[{"id":92626442,"node_id":"MDU6TGFiZWw5MjYyNjQ0Mg==","url":"https://api.github.com/repos/finagle/finch/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-26T06:16:09Z","updated_at":"2018-11-28T05:48:31Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"previously finch support any data type that can be convert to `TwitterFuture` by typeclass `ToTwitterFuture`\r\n\r\nbut since 0.25 it only support typeclass `Effect`, `Future` and `TwitterFuture`, which is not very friendly to customize data type that can be converted to `Effect` or `Future`\r\n\r\ne.g. I compose all business logic to `Free[Program, Unit]`, in old finch I can simply define `ToTwitterFuture[Free[Program, ?]]` then finch can convert my type to Future\r\n\r\nwhile in the new finch it can't\r\n\r\n## maybe we can make this generic by using FunctionK\r\nadd the following to `Mapper.scala`\r\n```scala\r\nimplicit def mapperToEffectOutputFunction[A, B, F[_], G[_]:Effect](f: A => F[Output[B]])(implicit cov:F~>G): Mapper.Aux[G, A, B] = new Mapper[G, A] {\r\n    type Out = B\r\n    def apply(e: Endpoint[G,A]) : Endpoint[G, B] = e.mapOutputAsync(a => cov.apply(f(a)))\r\n  }\r\n\r\n  implicit def mapperToEffectOutputValue[A, B, F[_], G[_]:Effect](f: => F[Output[B]])(implicit cov: F ~> G): Mapper.Aux[G, A, B] = new Mapper[G, A] {\r\n    type Out = B\r\n    def apply(e: Endpoint[G,A]) : Endpoint[G, B] = e.mapOutputAsync(a => cov.apply(f))\r\n  }\r\n\r\n  implicit def mapperFromKindOutputHFunction[F[_] : Effect, G[_], A, B, FN, FOB](f: FN)(implicit\r\n    conv: G ~> F,\r\n    ftp: FnToProduct.Aux[FN, A => FOB],\r\n    ev: FOB <:< G[Output[B]]\r\n  ): Mapper.Aux[F, A, B] = new Mapper[F, A] {\r\n    type Out = B\r\n    def apply(e: Endpoint[F,A]) : Endpoint[F, B] = e.mapOutputAsync(a => conv.apply(ev(ftp(f)(a))))\r\n  }\r\n\r\n```\r\nthen user can simply define how to convert their kind to some kind of `Effect`\r\n```scala\r\ncase class MyType[A](value: A)\r\n\r\nimplicit val convert: MyType ~> IO  = Lambda[MyType ~> IO](a=>IO(a.value))\r\n```\r\n\r\nthus, use can define response in custom kind, not constrain to only `Effect` or `Future`\r\n\r\n```scala\r\n  def hello = get(\"hello\" :: path[String]) { s: String =>\r\n    MyType(Ok(Message(s)))\r\n  }\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/finagle/finch/issues/comments/442328124","html_url":"https://github.com/finagle/finch/issues/1044#issuecomment-442328124","issue_url":"https://api.github.com/repos/finagle/finch/issues/1044","id":442328124,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MjMyODEyNA==","user":{"login":"vkostyukov","id":1098539,"node_id":"MDQ6VXNlcjEwOTg1Mzk=","avatar_url":"https://avatars1.githubusercontent.com/u/1098539?v=4","gravatar_id":"","url":"https://api.github.com/users/vkostyukov","html_url":"https://github.com/vkostyukov","followers_url":"https://api.github.com/users/vkostyukov/followers","following_url":"https://api.github.com/users/vkostyukov/following{/other_user}","gists_url":"https://api.github.com/users/vkostyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/vkostyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkostyukov/subscriptions","organizations_url":"https://api.github.com/users/vkostyukov/orgs","repos_url":"https://api.github.com/users/vkostyukov/repos","events_url":"https://api.github.com/users/vkostyukov/events{/privacy}","received_events_url":"https://api.github.com/users/vkostyukov/received_events","type":"User","site_admin":false},"created_at":"2018-11-28T05:48:31Z","updated_at":"2018-11-28T05:48:31Z","author_association":"MEMBER","body":"@jcouyang In #1042 we're discussing to having a type-class to convert from both Scala Futures and Twitter Futures into `F[_]: Effect`. Presumably you would be able to use that extension point to lift your own stuff into `F[_]: Effect`."}}
{"actor":{"display_login":"vkostyukov"}}