{"action":"created","issue":{"url":"https://api.github.com/repos/typelevel/cats/issues/1080","repository_url":"https://api.github.com/repos/typelevel/cats","labels_url":"https://api.github.com/repos/typelevel/cats/issues/1080/labels{/name}","comments_url":"https://api.github.com/repos/typelevel/cats/issues/1080/comments","events_url":"https://api.github.com/repos/typelevel/cats/issues/1080/events","html_url":"https://github.com/typelevel/cats/issues/1080","id":157904510,"number":1080,"title":"Add Functor.widen","user":{"login":"ceedubs","id":977929,"avatar_url":"https://avatars.githubusercontent.com/u/977929?v=3","gravatar_id":"","url":"https://api.github.com/users/ceedubs","html_url":"https://github.com/ceedubs","followers_url":"https://api.github.com/users/ceedubs/followers","following_url":"https://api.github.com/users/ceedubs/following{/other_user}","gists_url":"https://api.github.com/users/ceedubs/gists{/gist_id}","starred_url":"https://api.github.com/users/ceedubs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceedubs/subscriptions","organizations_url":"https://api.github.com/users/ceedubs/orgs","repos_url":"https://api.github.com/users/ceedubs/repos","events_url":"https://api.github.com/users/ceedubs/events{/privacy}","received_events_url":"https://api.github.com/users/ceedubs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-01T13:19:26Z","updated_at":"2016-06-18T14:53:34Z","closed_at":null,"body":"I think that we should have something like `def widen[A, AA >: A](fa: F[A]): F[AA]` on (covariant) `Functor`. People who are working in code that is a hybrid of OO and FP (which is pretty much everyone who uses FP in scala, since subtyping is used for sum types) often find themselves wanting something like this.\r\n\r\nA straightforward implementation is `map identity`, but this solution is often not very performant. Since the functor laws specify that `fa map identity` is equivalent to `fa`, there generally shouldn't be any problem with just using an `asInstanceOf` cast instead of mapping over identity. I think that [The singleton instance trick is unsafe](http://typelevel.org/blog/2014/07/06/singleton_instance_trick_unsafe.html) points out that there are ways that you can get unsound results with this approach in certain situations. I'm not sure how much of a real problem that is in practice."},"comment":{"url":"https://api.github.com/repos/typelevel/cats/issues/comments/226946546","html_url":"https://github.com/typelevel/cats/issues/1080#issuecomment-226946546","issue_url":"https://api.github.com/repos/typelevel/cats/issues/1080","id":226946546,"user":{"login":"ceedubs","id":977929,"avatar_url":"https://avatars.githubusercontent.com/u/977929?v=3","gravatar_id":"","url":"https://api.github.com/users/ceedubs","html_url":"https://github.com/ceedubs","followers_url":"https://api.github.com/users/ceedubs/followers","following_url":"https://api.github.com/users/ceedubs/following{/other_user}","gists_url":"https://api.github.com/users/ceedubs/gists{/gist_id}","starred_url":"https://api.github.com/users/ceedubs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceedubs/subscriptions","organizations_url":"https://api.github.com/users/ceedubs/orgs","repos_url":"https://api.github.com/users/ceedubs/repos","events_url":"https://api.github.com/users/ceedubs/events{/privacy}","received_events_url":"https://api.github.com/users/ceedubs/received_events","type":"User","site_admin":false},"created_at":"2016-06-18T14:53:34Z","updated_at":"2016-06-18T14:53:34Z","body":"@durban yeah, that does bother me a bit. I think it can only be a problem when reference equality is used (this is how `case _: b.type` works), which means breaking parametricity. It seems unlikely to me that this would be a problem in practice, as it seems like you kind of have to make a concerted effort to make this produce unsound results. For those reasons, and since it's likely to be much more efficient than `map identity` for many structures, I'm inclined to just put a warning in the scaladoc for the method. WDYT?"}}
{"actor":{"display_login":"ceedubs"}}