{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/1388","labels_url":"https://api.github.com/repos/manastech/crystal/issues/1388/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/1388/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/1388/events","html_url":"https://github.com/manastech/crystal/issues/1388","id":105076111,"number":1388,"title":"[RFC] Pipe Operator","user":{"login":"felixbuenemann","id":909587,"avatar_url":"https://avatars.githubusercontent.com/u/909587?v=3","gravatar_id":"","url":"https://api.github.com/users/felixbuenemann","html_url":"https://github.com/felixbuenemann","followers_url":"https://api.github.com/users/felixbuenemann/followers","following_url":"https://api.github.com/users/felixbuenemann/following{/other_user}","gists_url":"https://api.github.com/users/felixbuenemann/gists{/gist_id}","starred_url":"https://api.github.com/users/felixbuenemann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixbuenemann/subscriptions","organizations_url":"https://api.github.com/users/felixbuenemann/orgs","repos_url":"https://api.github.com/users/felixbuenemann/repos","events_url":"https://api.github.com/users/felixbuenemann/events{/privacy}","received_events_url":"https://api.github.com/users/felixbuenemann/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/manastech/crystal/labels/compiler","name":"compiler","color":"fef2c0"},{"url":"https://api.github.com/repos/manastech/crystal/labels/draft","name":"draft","color":"00B8B8"},{"url":"https://api.github.com/repos/manastech/crystal/labels/RFC","name":"RFC","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-09-06T07:02:53Z","updated_at":"2015-09-15T19:38:01Z","closed_at":null,"body":"It would be great if Crystal had a construct similar to [Elixir's pipe operator](http://elixir-lang.org/docs/v1.0/elixir/Kernel.html#%7C%3E/2) `|>`:\r\n\r\n```crystal\r\nclass Importer\r\n  def import(io)\r\n    xml = parse_xml(io)\r\n    root = find_root_node(xml)\r\n    tree = build_tree(root)\r\n  end\r\n\r\n  def import2(io)\r\n    io |> parse_xml |> find_root_node |> build_tree\r\n  end\r\nend\r\n```\r\nI think that the latter example is much easier to read and requires far less eye tracking to comprehend.\r\n\r\nThe implementation in Elixir is simply syntactic sugar using a macro, not sure if Crystal's macros could do this transform as well.\r\n\r\nThis has been briefly discussed in #1099, but I don't think the arguments against it were valid. Crystal is just like Ruby a hybrid between an OO and functional language and I really like the funtional core, imperative shell pattern, which leads to well testable units by avoiding shared/hidden state. "},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/140513552","html_url":"https://github.com/manastech/crystal/issues/1388#issuecomment-140513552","issue_url":"https://api.github.com/repos/manastech/crystal/issues/1388","id":140513552,"user":{"login":"bcardiff","id":459923,"avatar_url":"https://avatars.githubusercontent.com/u/459923?v=3","gravatar_id":"","url":"https://api.github.com/users/bcardiff","html_url":"https://github.com/bcardiff","followers_url":"https://api.github.com/users/bcardiff/followers","following_url":"https://api.github.com/users/bcardiff/following{/other_user}","gists_url":"https://api.github.com/users/bcardiff/gists{/gist_id}","starred_url":"https://api.github.com/users/bcardiff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcardiff/subscriptions","organizations_url":"https://api.github.com/users/bcardiff/orgs","repos_url":"https://api.github.com/users/bcardiff/repos","events_url":"https://api.github.com/users/bcardiff/events{/privacy}","received_events_url":"https://api.github.com/users/bcardiff/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T19:38:01Z","updated_at":"2015-09-15T19:38:01Z","body":"@beno , @felixbuenemann I encourage, support and love functional programing. A lot. I like crystal to be as flexible as it can (not everybody agrees with this thou ;-) ). Not everything is achievable by macros and is it makes difficult to share code. But you can do plenty of stuff for syntax sugar things.\r\n\r\nThe language is young. With lots of things to offer. Lots of good people energy is involved. \r\n\r\nIn the hybrid space of OO/λ there is plenty of space to draw a line. Huge changes of not ending in the one everybody would like :-). But me and probable lots of people that are investing energy think there is future despite the place of that cut line."}}