{"id":17212436,"url":"https://github.com/jackfirth/type-conventions","last_synced_at":"2026-02-18T00:31:32.997Z","repository":{"id":21683873,"uuid":"25005104","full_name":"jackfirth/type-conventions","owner":"jackfirth","description":"A Typed Racket package that allows for function arguments to be declared as having a default type","archived":false,"fork":false,"pushed_at":"2016-08-19T14:51:45.000Z","size":13,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T01:36:19.652Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackfirth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-09T19:29:11.000Z","updated_at":"2017-05-07T13:58:27.000Z","dependencies_parsed_at":"2022-08-17T23:15:34.721Z","dependency_job_id":null,"html_url":"https://github.com/jackfirth/type-conventions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jackfirth/type-conventions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Ftype-conventions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Ftype-conventions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Ftype-conventions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Ftype-conventions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackfirth","download_url":"https://codeload.github.com/jackfirth/type-conventions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackfirth%2Ftype-conventions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29563467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-15T03:00:03.536Z","updated_at":"2026-02-18T00:31:32.967Z","avatar_url":"https://github.com/jackfirth.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"type-conventions\n================\n\n*A Typed Racket package for painless function definitions*\n\nIt is frequently the case in a statically typed language that the type of a variable can be determined solely from its name, such as a variable of type `Chair` named `chair`. Due to Typed Racket's support for macros, this pattern can be abstracted away. This package provides several forms for this purpose. For example:\n\n    #lang typed/racket\n    (require type-conventions)\n    (define-type-convention Number x)\n    (define: (f x) : Number\n      (+ x x))\n\nIn the above, the `define-type-convention` and `define:` forms are used to assume that the function argument `x` has type Number. This would be equivalent to the following:\n\n    #lang typed/racket\n    (define: (f [x : Number]) : Number\n      (+ x x))\n\nType conventions are most useful when they let you eliminate large amounts of type annotation code that can make it difficult to grasp the true intent of a definition. Eliminating the unnecessary is one of the most important ways to express clarity. To assist this there exists a shorthand form of `define-type-convention` for defining many convetions at once, named `define-type-conventions`:\n\n    (define-type-conventions\n      [Number x y z]\n      [Boolean bool boolean])\n\nAny non-parametric type can be associated with a convention. Note however, that it is very common to pluralize the names of rest-arguments, for example:\n\n    (define: (f . xs) : Number\n      (apply + xs))\n\nA rest arg contains a list, but it does not have the type `List`, rather it has the type `(Listof A)` where a is the type given in the definition form. A rest arg declared with type `Number` contains a list of numbers. Because of this, conventional names for rest arguments must be defined explicitly with the `define-rest-type-convention` form:\n\n    (define-rest-type-convention Number xs)\n    (define: (f . xs) : Number\n      (apply + xs))\n\nA corresponding shorthand `define-rest-type-conventions` is also provided.\n\nWhile conventionally typed arguments cannot be parametric, the `define:` form accepts explicitly typed arguments in addition to conventionally typed ones, and the explicitly typed arguments can be parametrically typed:\n\n    (define: (V) (pair-to-num x [v : V]) : (Pairof Number V)\n      (pair x V))\n\nThe `define:` form also supports optional arguments, keyword arguments, and optional keyword arguments:\n\n    (define-type-conventions [Number x y])\n    (define (f x #:y y) : Number\n      (+ x y))\n    (define (g x [y 1]) : Number\n      (+ x y))\n    (define (h x #:y [y 1]) : Number\n      (+ x y))\n\nThe form also allows for explicitly typed defaults values:\n\n    (define: (f [x : Number 1]) : Number\n      (add1 x))\n\nAs of this writing, the `define:` form does *not* support the following:\n\n1. Partially applicable functions, e.g. (define: ((f x) y) : Number (+ x y))\n2. Anonymous functions, e.g. (lambda: (x) x)\n3. Parametrically typed shorthands.\n4. Explicitly typed rest arguments.\n\nThis may change in a future release, but no guarantees are given with the exception that due to syntactic limitations, explicitly typed rest arguments are likely impossible to implement in a sensible way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackfirth%2Ftype-conventions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackfirth%2Ftype-conventions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackfirth%2Ftype-conventions/lists"}