{"id":17210694,"url":"https://github.com/alexknauth/reconstruct-template","last_synced_at":"2026-01-27T11:33:18.409Z","repository":{"id":62424338,"uuid":"162502143","full_name":"AlexKnauth/reconstruct-template","owner":"AlexKnauth","description":"`~list/ctx` pattern and `?list/ctx` template for reconstructing syntax objects for core-form languages","archived":false,"fork":false,"pushed_at":"2022-01-07T14:39:26.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-30T11:13:02.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Racket","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/AlexKnauth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-19T23:33:42.000Z","updated_at":"2022-01-07T14:39:29.000Z","dependencies_parsed_at":"2022-11-01T18:01:00.352Z","dependency_job_id":null,"html_url":"https://github.com/AlexKnauth/reconstruct-template","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/AlexKnauth%2Freconstruct-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexKnauth%2Freconstruct-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexKnauth%2Freconstruct-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexKnauth%2Freconstruct-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexKnauth","download_url":"https://codeload.github.com/AlexKnauth/reconstruct-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245458710,"owners_count":20618697,"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-10-15T02:55:02.726Z","updated_at":"2026-01-27T11:33:18.381Z","avatar_url":"https://github.com/AlexKnauth.png","language":"Racket","readme":"# reconstruct-template\n\n[![Build Status](https://travis-ci.org/AlexKnauth/reconstruct-template.png?branch=master)](https://travis-ci.org/AlexKnauth/reconstruct-template)\n\n[_Documentation_](http://docs.racket-lang.org/reconstruct-template-list-ctx/index.html).\n\n```racket\n(require reconstruct-template/list-ctx)\n```\n\nProvides [`~list/ctx`][~list/ctx] and [`?list/ctx`][?list/ctx], as a pattern-expander and a template-metafunction which go together so that if `x` is a syntax-list,\n\n```racket\n(syntax-parse x\n  [{~list/ctx ctx e ...}\n   #'{?list/ctx ctx e ...}])\n=\nx\n```\n\nYou can think of these as similar to `(e ...)`, where `ctx` saves the lexical context, source location, and syntax properties of the parens, and transfers them over to the result syntax object.\n\nThe main intended use of [`~list/ctx`][~list/ctx] and [`?list/ctx`][?list/ctx] is for reconstructing syntax objects when making expanders for new *core-form languages*. This purpose is similar to [`syntax/loc/props`][syntax/loc/props] from Alexis King's blog post [_Reimplementing Hackett’s type language: expanding to custom core forms in Racket_][lexi-lambda-core-forms].\n\nThe main advantage of [`~list/ctx`][~list/ctx] and [`?list/ctx`][?list/ctx] over [`syntax/loc`][syntax/loc] or [`syntax/loc/props`][syntax/loc/props] is that they work even for stx-list templates nested deeply within a template, as well as for stx-list templates under ellipses. For example, if `x` is a well-formed `let` expression,\n\n```racket\n(syntax-parse x\n  [{~list/ctx p1 l\n              {~list/ctx p2 {~list/ctx p3 x a} ...}\n              b}\n   #'{?list/ctx p1 l\n                {?list/ctx p2 {?list/ctx p3 x a} ...}\n                b}])\n=\nx\n```\n\n  [~list/ctx]: https://docs.racket-lang.org/reconstruct-template-list-ctx/index.html#%28form._%28%28lib._reconstruct-template%2Flist-ctx..rkt%29._~7elist%2Fctx%29%29\n  \n  [?list/ctx]: https://docs.racket-lang.org/reconstruct-template-list-ctx/index.html#%28form._%28%28lib._reconstruct-template%2Flist-ctx..rkt%29._~3flist%2Fctx%29%29\n\n  [syntax/loc]: https://docs.racket-lang.org/reference/stx-patterns.html#(form._((lib._racket%2Fprivate%2Fstxcase-scheme..rkt)._syntax%2Floc))\n\n  [syntax/loc/props]: https://lexi-lambda.github.io/blog/2018/04/15/reimplementing-hackett-s-type-language-expanding-to-custom-core-forms-in-racket/#preserving-syntax-properties-and-source-locations\n\n  [lexi-lambda-core-forms]: https://lexi-lambda.github.io/blog/2018/04/15/reimplementing-hackett-s-type-language-expanding-to-custom-core-forms-in-racket/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexknauth%2Freconstruct-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexknauth%2Freconstruct-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexknauth%2Freconstruct-template/lists"}