{"id":17210808,"url":"https://github.com/alexknauth/struct-like-struct-type-property","last_synced_at":"2026-01-06T04:46:25.811Z","repository":{"id":62424389,"uuid":"136227849","full_name":"AlexKnauth/struct-like-struct-type-property","owner":"AlexKnauth","description":"Creating struct-type properties with a struct-like interface","archived":false,"fork":false,"pushed_at":"2022-01-07T14:24:50.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-30T11:13:18.359Z","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-06-05T19:54:54.000Z","updated_at":"2022-05-18T21:27:20.000Z","dependencies_parsed_at":"2022-11-01T18:01:48.658Z","dependency_job_id":null,"html_url":"https://github.com/AlexKnauth/struct-like-struct-type-property","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%2Fstruct-like-struct-type-property","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexKnauth%2Fstruct-like-struct-type-property/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexKnauth%2Fstruct-like-struct-type-property/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexKnauth%2Fstruct-like-struct-type-property/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexKnauth","download_url":"https://codeload.github.com/AlexKnauth/struct-like-struct-type-property/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:18.360Z","updated_at":"2026-01-06T04:46:25.757Z","avatar_url":"https://github.com/AlexKnauth.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"# struct-like-struct-type-property\nCreating struct-type properties with a struct-like interface.\n\n[_Documentation_](https://docs.racket-lang.org/struct-like-struct-type-property/index.html).\n\n```racket\n(require struct-like-struct-type-property)\n```\n\n```racket\n(define-struct-like-struct-type-property name [field ...]\n  prop-option ...)\n  \n  prop-option = #:property prop-expr val-expr\n```\n\nDefines these identifiers:\n - `prop:name`\n - `name`\n - `name?`\n - `name-field` ...\n \nThe property `prop:name` expects a function that takes a\n\"self\" argument and returns a `name` result. When someone\nwants to use the value as a `prop:name`, this function\nshould construct a more basic structure that contains the\nfield values.\n\nExample:\n```racket\n(define-struct-like-struct-type-property foo [a b c])\n\n\u003e (foo-a (foo 1 2 3))\n1\n\u003e (foo? (foo \"a\" \"b\" \"c\"))\n#true\n\u003e (struct bar [x]\n    #:property prop:foo\n    (lambda (self)\n      (foo (first (bar-x self))\n           (second (bar-x self))\n           (third (bar-x self)))))\n\u003e (foo-a (bar (list 4 5 6)))\n4\n\u003e (foo? (bar (list 'd 'e 'f)))\n#true\n\u003e (match (bar (list 1 3 5))\n    [(foo a b c) c])\n5\n```\n\nThe `#:property prop-expr val-expr` options specify\nsuper-properties. Anything that implements `prop:name` will\nautomatically implement all the properties specified by the\ngiven `prop-exprs`.\n\nExample:\n```racket\n(define-struct-like-struct-type-property quadratic [a b c]\n  #:property prop:procedure\n  (λ (self x)\n    (+ (* (quadratic-a self) (sqr x))\n       (* (quadratic-b self) x)\n       (quadratic-c self))))\n\n\u003e (define f (quadratic 1 -2 -3))\n\u003e (f 0)\n-3\n\u003e (f 1)\n-4\n\u003e (f 2)\n-3\n\u003e (f 3)\n0\n\u003e (f 4)\n5\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexknauth%2Fstruct-like-struct-type-property","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexknauth%2Fstruct-like-struct-type-property","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexknauth%2Fstruct-like-struct-type-property/lists"}