{"id":13711092,"url":"https://github.com/hipeta/arrow-macros","last_synced_at":"2025-05-06T20:31:50.389Z","repository":{"id":27894332,"uuid":"31385908","full_name":"hipeta/arrow-macros","owner":"hipeta","description":"Arrow-macros provides Clojure-like arrow macros in Common Lisp","archived":false,"fork":false,"pushed_at":"2024-03-19T11:24:17.000Z","size":39,"stargazers_count":119,"open_issues_count":0,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-03T23:23:12.135Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hipeta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-26T19:56:34.000Z","updated_at":"2024-06-04T05:07:07.000Z","dependencies_parsed_at":"2024-05-02T10:08:02.802Z","dependency_job_id":"cd105fa9-30c5-4289-81cc-a6f96f369dba","html_url":"https://github.com/hipeta/arrow-macros","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hipeta%2Farrow-macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hipeta%2Farrow-macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hipeta%2Farrow-macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hipeta%2Farrow-macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hipeta","download_url":"https://codeload.github.com/hipeta/arrow-macros/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224528337,"owners_count":17326344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:04.382Z","updated_at":"2024-11-13T21:31:29.046Z","avatar_url":"https://github.com/hipeta.png","language":"Common Lisp","funding_links":[],"categories":["Common Lisp","Miscellaneous ##"],"sub_categories":[],"readme":"# Arrow-macros\n\nArrow-macros provides clojure-like arrow macros (ex. -\u003e, -\u003e\u003e) and diamond wands in swiss-arrows (https://github.com/rplevy/swiss-arrows).\n\n[![Build Status](https://travis-ci.org/hipeta/arrow-macros.svg)](https://travis-ci.org/hipeta/arrow-macros)\n\n## Examples\n\n```\n(-\u003e 1 (+ 2 3) #'1+ 1+ (lambda (x) (+ x 1)) (1+)) ; =\u003e 10\n```\n\n```\n(-\u003e\u003e (list 1 2 3 4 5)\n  (mapcar #'1+)\n  (reduce #'+)) ; =\u003e 20\n```\n\n```\n(-\u003c\u003e \"abcdefghijklmnopqrstuvwxyz\"\n  (ppcre:scan-to-strings \"j.*q\" \u003c\u003e)\n  (sort #'string\u003e)\n  (string-upcase :end 1)) ; =\u003e \"Qponmlkj\"\n```\n\n```\n(-\u003e (get-some-webpage-uri id)\n  drakma:http-request\n  babel:octets-to-string\n  json-\u003elist)\n```\n\n## Installation\n\n```\n(ql:quickload :arrow-macros)\n```\n\n## APIs\n\n### Clojure-like macros\n\nThese macro functions are equivalent to clojure's ones.\n\n- -\u003e\n- -\u003e\u003e\n- some-\u003e\n- some-\u003e\u003e\n- as-\u003e\n- cond-\u003e\n- cond-\u003e\u003e\n\n### Diamond wands\n\nThese wonderful macros are developed in clojure's library swiss-arrows (https://github.com/rplevy/swiss-arrows).\nThese macro functions are almost equivalent to them too.\n\n- -\u003c\u003e\n- -\u003c\u003e\u003e\n- some-\u003c\u003e\n- some-\u003c\u003e\u003e\n\n\n```\n(-\u003c\u003e 1 1+ #'1+ (1+) (lambda (x) (1+ x)))  ; =\u003e 5\n```\n\n```\n(-\u003c\u003e 1\n  (+ 2)     ; =\u003e (+ 1 2)\n  (+ 3 \u003c\u003e)  ; =\u003e (+ 3 (+ 1 2))\n  (+ 4)     ; =\u003e (+ (+ 3 (+ 1 2) 4)  =\u003e 10\n```\n\n```\n(-\u003c\u003e\u003e 1\n  (+ 2)     ; =\u003e (+ 2 1)\n  (+ \u003c\u003e 3)  ; =\u003e (+ (+ 2 1) 3)\n  (+ 4)     ; =\u003e (+ 4 (+ (+ 2 1) 3)) =\u003e 10\n```\n\nArrow-macros can also write nested diamond-wands like:\n\n```\n(-\u003c\u003e\u003e (list 1 2 3)\n  (mapcar #'1+)\n  (-\u003c\u003e \u003c\u003e (sort #'\u003e))\n  (mapcar #'1+))       ; =\u003e (5 4 3)\n```\n\n```\n(-\u003c\u003e 1 (+ \u003c\u003e \u003c\u003e) (-\u003c\u003e (+ \u003c\u003e \u003c\u003e \u003c\u003e)))  ; =\u003e 6\n```\n\nBe aware that the inner diamond-wand can refer to outer diamond symbol \u003c\u003e only in initial form.\n\n#### Side effect in diamond wand and \u003c!\u003e symbol\n\nDiamond wand can write multiple \u003c\u003e symbols in each expression.\n\n```\n(let ((x 0))\n  (list (-\u003c\u003e x\n          incf\n          (+ \u003c\u003e \u003c\u003e)\n          (+ \u003c\u003e \u003c\u003e))   ; =\u003e (+ (+ (incf x) (incf x)) (+ (incf x) (incf x))) =\u003e 10\n        x))            ; =\u003e (10 4)\n        \n```\n\nThis means some expressions in diamond wands can be evaluated for 2 or more times.\nIf you use expressions which have side effects in diamond wands, there is a risk that might happen what you don't intend.\nOne solution is you don't use diamond wands for expressions containing side effects.\nAnother solution is using \u003c!\u003e symbol in diamond wands.\nThis may be a unique feature in this library. \u003c!\u003e symbol ensure previous expression evaluted only once.\n\n```\n(let ((x 0))\n  (list (-\u003c\u003e x\n          incf \u003c!\u003e\n          (+ \u003c\u003e \u003c\u003e)\n          (+ \u003c\u003e \u003c\u003e))\n        x))            ; =\u003e (4 1)\n\n(-\u003c\u003e (drakma:http-request \u003csome-address\u003e) \u003c!\u003e\n  (some-converter \u003c\u003e :encode (detect-encoding-of \u003c\u003e)))  ; =\u003e this sends http request only once\n\n```\nOriginal library (https://github.com/rplevy/swiss-arrows) doesn't have this feature. I need this for my local small project so add it. It doesn't change the original diamond wand behavior but if you find any problems or improvements, please report me.\n\n\n## Notes\n\n(Nov 26, 2020)\n\nFor author's misunderstading, diamond wand specification had been uncorrect (see issue \u003ca href='https://github.com/hipeta/arrow-macros/issues/3'\u003e#3\u003c/a\u003e).\nIt has been fixed and the changes can make this library independence from code walker so arrow-macros is now smaller and slimer than old version.\n\n\n(June 2015)\n\nBuild verified on sbcl, ccl, abcl, allegro, clisp.\nBut diamond-wand tests fail on abcl, allegro, clisp.\nFailed on ecl while loading hu.dwim.walker.\nNot tested on cmucl.\n(contributed by [guicho271828](https://github.com/guicho271828), thanks!)\n\n(May 7, 2015)\n\nOn sbcl for windows, arrow-macros can be built now.\n\n\u003cdel\u003e\n\u003cp\u003e(April 9, 2015)\u003c/p\u003e\n\n\u003cp\u003eIf you use sbcl on windows, this library could not be built on your system.\nBecause this library uses hu.dwim.util (via hu.dwim.walker) on current version (see issue \u003ca href='https://github.com/hipeta/arrow-macros/issues/1'\u003e#1\u003c/a\u003e) and the quicklisp dist update in April 2015 has not included hu.dwim.util latest updates.\nThis would be resolved in the next month quicklisp dist update, probably.\nBut if you want to use this library on sbcl for windows immediately, version 0.2.1 is available. (This version has issue \u003ca href='https://github.com/hipeta/arrow-macros/issues/1'\u003e#1\u003c/a\u003e problem, but it is edge case, I think)\u003c/p\u003e\n\u003c/del\u003e\n\n## License\n\nArrow-macros is under the MIT License, see LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhipeta%2Farrow-macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhipeta%2Farrow-macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhipeta%2Farrow-macros/lists"}