{"action":"created","issue":{"url":"https://api.github.com/repos/xsc/rewrite-clj/issues/30","labels_url":"https://api.github.com/repos/xsc/rewrite-clj/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/xsc/rewrite-clj/issues/30/comments","events_url":"https://api.github.com/repos/xsc/rewrite-clj/issues/30/events","html_url":"https://github.com/xsc/rewrite-clj/issues/30","id":89051546,"number":30,"title":"Records are coerced into HashMaps instead of themselves","user":{"login":"RickMoynihan","id":17060,"avatar_url":"https://avatars.githubusercontent.com/u/17060?v=3","gravatar_id":"","url":"https://api.github.com/users/RickMoynihan","html_url":"https://github.com/RickMoynihan","followers_url":"https://api.github.com/users/RickMoynihan/followers","following_url":"https://api.github.com/users/RickMoynihan/following{/other_user}","gists_url":"https://api.github.com/users/RickMoynihan/gists{/gist_id}","starred_url":"https://api.github.com/users/RickMoynihan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickMoynihan/subscriptions","organizations_url":"https://api.github.com/users/RickMoynihan/orgs","repos_url":"https://api.github.com/users/RickMoynihan/repos","events_url":"https://api.github.com/users/RickMoynihan/events{/privacy}","received_events_url":"https://api.github.com/users/RickMoynihan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"xsc","id":198072,"avatar_url":"https://avatars.githubusercontent.com/u/198072?v=3","gravatar_id":"","url":"https://api.github.com/users/xsc","html_url":"https://github.com/xsc","followers_url":"https://api.github.com/users/xsc/followers","following_url":"https://api.github.com/users/xsc/following{/other_user}","gists_url":"https://api.github.com/users/xsc/gists{/gist_id}","starred_url":"https://api.github.com/users/xsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xsc/subscriptions","organizations_url":"https://api.github.com/users/xsc/orgs","repos_url":"https://api.github.com/users/xsc/repos","events_url":"https://api.github.com/users/xsc/events{/privacy}","received_events_url":"https://api.github.com/users/xsc/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-06-17T15:36:49Z","updated_at":"2015-06-17T16:01:38Z","closed_at":null,"body":"Hi all,\r\n\r\nI have the following defrecord type:\r\n\r\n`(defrecord Foo [a])`\r\n\r\nWhich is serializable obviously as an EDN tagged literal:\r\n\r\n`#user/Foo \"blah\"`\r\n\r\nUnfortunately `coerce` coerces `IPersistentMap` into hash maps, which looses the important type information that this is a `#user/Foo`.  This can be problematic as walking over a tree with a zipper can loose information from the source form.\r\n\r\nIt might be better if coerce would coerce records into themselves."},"comment":{"url":"https://api.github.com/repos/xsc/rewrite-clj/issues/comments/112860585","html_url":"https://github.com/xsc/rewrite-clj/issues/30#issuecomment-112860585","issue_url":"https://api.github.com/repos/xsc/rewrite-clj/issues/30","id":112860585,"user":{"login":"xsc","id":198072,"avatar_url":"https://avatars.githubusercontent.com/u/198072?v=3","gravatar_id":"","url":"https://api.github.com/users/xsc","html_url":"https://github.com/xsc","followers_url":"https://api.github.com/users/xsc/followers","following_url":"https://api.github.com/users/xsc/following{/other_user}","gists_url":"https://api.github.com/users/xsc/gists{/gist_id}","starred_url":"https://api.github.com/users/xsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xsc/subscriptions","organizations_url":"https://api.github.com/users/xsc/orgs","repos_url":"https://api.github.com/users/xsc/repos","events_url":"https://api.github.com/users/xsc/events{/privacy}","received_events_url":"https://api.github.com/users/xsc/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T16:01:38Z","updated_at":"2015-06-17T16:01:38Z","body":"I went with records producing nodes representing the output of `pr-str` on a record, e.g.:\r\n\r\n```clojure\r\n(require '[rewrite-clj.node :as node])\r\n(defrecord Foo-Bar [x])\r\n\r\n(node/coerce (Foo-Bar. 0))\r\n;; => <reader-macro: #user.Foo-Bar{:x 0}>\r\n\r\n(node/string *1)\r\n;; => \"#user.Foo-Bar{:x 0}\"\r\n\r\n(node/sexpr *2)\r\n;; => (read-string \"#user.Foo-Bar{:x 0}\")\r\n\r\n(binding [*data-readers* {`Foo-Bar map->Foo-Bar}] (eval *1))\r\n;; => #user.Foo-Bar{:x 0}\r\n```\r\n\r\nSounds good?"}}