{"action":"created","issue":{"url":"https://api.github.com/repos/ramda/ramda/issues/1684","repository_url":"https://api.github.com/repos/ramda/ramda","labels_url":"https://api.github.com/repos/ramda/ramda/issues/1684/labels{/name}","comments_url":"https://api.github.com/repos/ramda/ramda/issues/1684/comments","events_url":"https://api.github.com/repos/ramda/ramda/issues/1684/events","html_url":"https://github.com/ramda/ramda/issues/1684","id":140224901,"number":1684,"title":"[question] should mapping over object preserve the protoype?","user":{"login":"davidchase","id":490291,"avatar_url":"https://avatars.githubusercontent.com/u/490291?v=3","gravatar_id":"","url":"https://api.github.com/users/davidchase","html_url":"https://github.com/davidchase","followers_url":"https://api.github.com/users/davidchase/followers","following_url":"https://api.github.com/users/davidchase/following{/other_user}","gists_url":"https://api.github.com/users/davidchase/gists{/gist_id}","starred_url":"https://api.github.com/users/davidchase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidchase/subscriptions","organizations_url":"https://api.github.com/users/davidchase/orgs","repos_url":"https://api.github.com/users/davidchase/repos","events_url":"https://api.github.com/users/davidchase/events{/privacy}","received_events_url":"https://api.github.com/users/davidchase/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-11T16:14:21Z","updated_at":"2016-03-11T18:00:50Z","closed_at":null,"body":"Given:\r\n```js\r\nfunction Box (x) {\r\n  if (!(this instanceof Box)) return new Box(x);\r\n  this.value = x;\r\n}\r\n\r\nBox.prototype.toString = function(){\r\n  return `Box(${this.value})`;\r\n};\r\n\r\n\r\nmap(add(10))(Box(10)) // {\"value\": 20}\r\n```\r\n\r\nhttp://goo.gl/jgFyfS\r\n\r\nhowever adding `Object.create(functor)` to the reduce method in the `case [object Object]`\r\n\r\n```js\r\nconst _map = curry(function(fn, functor){\r\n switch (Object.prototype.toString.call(functor)) {\r\n    case '[object Function]':\r\n      return curryN(functor.length, function() {\r\n        return fn.call(this, functor.apply(this, arguments));\r\n      });\r\n    case '[object Object]':\r\n      return reduce(function(acc, key) {\r\n        acc[key] = fn(functor[key]);\r\n        return acc;\r\n      }, Object.create(functor), keys(functor));\r\n    default:\r\n      return map(fn, functor);\r\n  }\r\n});\r\n\r\n_map(add(10))(Box(10)) // Box(20) the toString works.. yay\r\n```\r\n\r\nhttp://goo.gl/zdEypT\r\n\r\n thoughts?"},"comment":{"url":"https://api.github.com/repos/ramda/ramda/issues/comments/195479635","html_url":"https://github.com/ramda/ramda/issues/1684#issuecomment-195479635","issue_url":"https://api.github.com/repos/ramda/ramda/issues/1684","id":195479635,"user":{"login":"davidchambers","id":210406,"avatar_url":"https://avatars.githubusercontent.com/u/210406?v=3","gravatar_id":"","url":"https://api.github.com/users/davidchambers","html_url":"https://github.com/davidchambers","followers_url":"https://api.github.com/users/davidchambers/followers","following_url":"https://api.github.com/users/davidchambers/following{/other_user}","gists_url":"https://api.github.com/users/davidchambers/gists{/gist_id}","starred_url":"https://api.github.com/users/davidchambers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidchambers/subscriptions","organizations_url":"https://api.github.com/users/davidchambers/orgs","repos_url":"https://api.github.com/users/davidchambers/repos","events_url":"https://api.github.com/users/davidchambers/events{/privacy}","received_events_url":"https://api.github.com/users/davidchambers/received_events","type":"User","site_admin":false},"created_at":"2016-03-11T18:00:50Z","updated_at":"2016-03-11T18:00:50Z","body":":thumbsdown: from me. `R.map` operates on functors, such as a values of type [`StrMap a`][1], not on arbitrary objects. The correct solution, in my view, is to implement `Box.prototype.map` if you wish Box to be a functor.\r\n\r\n\r\n[1]: https://github.com/plaid/sanctuary-def/pull/33\r\n"}}