{"id":17214164,"url":"https://github.com/tonyg/racket-something","last_synced_at":"2026-01-06T00:10:42.546Z","repository":{"id":66463122,"uuid":"62754902","full_name":"tonyg/racket-something","owner":"tonyg","description":"Indentation-based Racket Syntax","archived":false,"fork":false,"pushed_at":"2021-09-02T14:43:42.000Z","size":73,"stargazers_count":37,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-30T11:43:22.523Z","etag":null,"topics":["racket"],"latest_commit_sha":null,"homepage":null,"language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonyg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2016-07-06T21:36:19.000Z","updated_at":"2024-04-19T05:06:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea77d099-eb8d-4a7b-8f68-7a81915f3566","html_url":"https://github.com/tonyg/racket-something","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-something","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-something/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-something/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-something/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonyg","download_url":"https://codeload.github.com/tonyg/racket-something/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245467191,"owners_count":20620210,"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":["racket"],"created_at":"2024-10-15T03:01:48.694Z","updated_at":"2026-01-06T00:10:42.490Z","avatar_url":"https://github.com/tonyg.png","language":"Racket","readme":"# Indentation-based Racket Syntax with Macros and Infix Operators\n\nNot [sweet-exps](http://readable.sourceforge.net/) (see Asumu's\n[racket implementation](https://github.com/takikawa/sweet-racket)).\nNot [srfi-49](http://srfi.schemers.org/srfi-49/srfi-49.html). More\ninspired by Python and Haskell.\n\n(The name \"something\" is temporary, and likely to be repurposed.)\n\n# Installation\n\nCheck out the repository. Then, in the directory containing\n`Makefile`,\n\n    make link\n\nor\n\n\traco pkg install --link -n something `pwd`/src\n\n# The main idea\n\nS-expressions, but with usually-implicit parentheses. Indentation for\ngrouping is explicitly represented in the S-expression returned from\nthe reader.\n\nThis program:\n\n    #lang something\n    for { x: 1 .. 10 }\n      def y: x + 1\n      printf \"x ~a y ~a\\n\" x y\n\n... reads as this S-expression:\n\n    (module something-module something/base\n      (#%rewrite-body\n       (for (block (x (block (1 .. 10))))\n            (block (def y (block (x + 1)))\n                   (printf \"x ~a y ~a\\n\" x y)))))\n\nThe `#%rewrite-body` macro, together with its companion\n`#%rewrite-infix`, consults an operator table, extendable via the\n`def-operator` macro, to rewrite infix syntax into standard prefix\nS-expressions.\n\nThe `block` syntax has many different interpretations. It has a macro\nbinding that turns it into a Racket `match-lambda*`, and it is used as\nliteral syntax as input to other macro definitions.\n\nFor example, here's one possible implementation of that `for` syntax:\n\n    #lang something\n\n    provide\n      for\n\n    require\n      for-syntax something/base\n      prefix-in base_ racket/base\n\n    def-syntax for stx\n      syntax-case stx (block)\n        _ (block (v (block exp)) ...) (block body ...)\n          (syntax (base_for ((v exp) ...) body ...))\n\n    def-operator .. 10 nonassoc in-range\n\nNotice how the `block` S-expressions are rewritten into a normal\nS-expression compatible with the underlying `for` from `racket/base`.\n\nGenerally, all of these forms are equivalent\n\n    x y z          x y z:          x y z { a; b }\n      a              a\n      b              b\n\nand they are read as\n\n    (x y z (block a b))\n\nand are then made available to the normal macro-expansion process\n(which involves a new infix-rewriting semi-phase).\n\nColons are optional to indicate a following suite at the end of an\nindentation-sensitive line. Indentation-sensitivity is disabled inside\nparentheses. If inside a parenthesised expression,\nindentation-sensitivity can be reenabled with a colon at the end of a\nline:\n\n    a b (c d:\n          e\n          f)\n\n    = (a b (c d (block e f)))\n\n    a b (c d\n          e\n          f)\n\n    = (a b (c d e f))\n\nConversely, long lines may be split up and logically continued over\nsubsequent physical lines with a trailing `\\`:\n\n    a b c \\\n      d \\\n      e\n\n    = (a b c d e)\n\nSemicolons may also appear in vertically-laid-out suites; these two\nare equivalent:\n\n    x y z\n      a\n      b; c\n      d\n\n    x y z { a; b; c; d }\n\nSuites may begin on the same line as their colon. Any indented\nsubsequent lines become children of the portion after the colon,\nrather than the portion before.\n\nThis example:\n\n    x y z: a b\n      c d\n      e\n\nreads as\n\n    (x y z (block (a b (block (c d) e))))\n\nSquare brackets are syntactic sugar for a `#%seq` macro:\n\n    [a; b; c; d e f]    →        (#%seq a b c (d e f))\n\n    [                   →        (#%seq a (b (block c)) (d e f))\n      a\n      b\n        c\n      d e f\n    ]\n\nForms starting with `block` in expression context expand into\n`match-lambda*` like this:\n\n    {\n      pat1a pat1b\n        exp1a\n        exp1b\n      pat2a\n        exp2\n    }\n\n    → (match-lambda*\n        [(list pat1a pat1b) exp1a exp1b]\n        [(list pat2a) exp2])\n\nThe `map*` function exported from `something/lang/implicit` differs\nfrom `map` in `racket/base` in that it takes its arguments in the\nopposite order, permitting maps to be written\n\n    map* [1; 2; 3; 4]\n      item:\n        item + 1\n\n    map* [1; 2; 3; 4]\n      item: item + 1\n\n    map* [1; 2; 3; 4]: item: item + 1\n\n    map* [1; 2; 3; 4] { item: item + 1 }\n\nA nice consequence of all of the above is that curried functions have\nan interesting appearance:\n\n    def curried x:: y:: z:\n      [x; y; z]\n\n    require rackunit\n    check-equal? (((curried 1) 2) 3) [1; 2; 3]\n\n# A larger example\n\nMore examples can be found in the [examples](examples/) and\n[src/something/test](src/something/test/) directories.\n\n    #lang something\n\n    require\n      racket/pretty\n      something/infix\n      for-syntax something/lang/implicit\n      except-in xml document\n\n    def-syntax single-xexpr stx\n      syntax-case stx (= block)\n        _ str\n          string? (syntax-e . (syntax str))\n          syntax str\n        _ (= expr)\n          syntax expr\n        _ (tag (attr attr-expr) ... (block xexpr ...))\n          syntax (list (quote tag) (list (list (quote attr) attr-expr) ...) (single-xexpr xexpr) ...)\n        _ (tag (attr attr-expr) ...)\n          syntax (list (quote tag) (list (list (quote attr) attr-expr) ...))\n\n    def-syntax xexpr stx\n      syntax-case stx (block)\n        _ (block xexpr)\n          syntax (single-xexpr xexpr)\n\n    def-operator ++ 50 left string-append\n    def-operator = 10 prefix =\n\n    def document\n      xexpr\n        html\n          head\n            meta (http-equiv \"Content-Type\") (content \"text/html; charset=utf-8\")\n            title: \"Test page\"\n          body\n            h1: \"Hello\"\n            p: \"Hello, world\"\n            h2: \"Testing\"\n            p\n              = \"Hello, \" ++ number-\u003estring (3 + 4)\n              \"! This rules.\"\n            p\n              \"Another way of putting it would be to say that 3 + 4 = \"\n              = (number-\u003estring (3 + 4))\n              \".\"\n\n    pretty-print document\n    printf \"\\n~a\\n\" (xexpr-\u003estring document)\n\n# A note on lexical syntax\n\nThe lexical syntax of this reader is not exactly that of Racket. For\nexample, comments start with `//` rather than `;`, and the set of\nallowable non-escaped identifiers is different (smaller).\n\nI will likely revise this decision to bring it to be much closer to\nRacket's lexical syntax.\n\n# Emacs mode\n\nSee [sth8.el](sth8.el).\n\n# Licence\n\nCopyright (C) 2016–2019 Tony Garnock-Jones \u003cmailto:tonyg@leastfixedpoint.com\u003e\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this program (see the files \"lgpl.txt\" and\n\"gpl.txt\"). If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyg%2Fracket-something","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonyg%2Fracket-something","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyg%2Fracket-something/lists"}