# Racket's macro, module and contract system

**URL:** <https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337>\
**Category:** Questions & Answers\
**Created:** [November 19, 2024, 8:46am UTC](https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337 "2024-11-19T08:46:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rugged](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rugged](https://racket.discourse.group/u/Rugged)\
**Post date:** [November 19, 2024, 8:46am UTC](https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337/1 "2024-11-19T08:46:26Z")

</div>

Is there a document or a paper detailing the implementation of Racket's macro and module system?

Also, I need a document detailing the contract system (contracts) in Racket.

Thanks

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [November 19, 2024, 1:54pm UTC](https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337/2 "2024-11-19T13:54:32Z")

</div>

I think the standard references are

- [Composable and compilable macros: You want it  
when?](https://dl.acm.org/doi/10.1145/583852.581486)
- [Bindings as sets of scopes](https://www-old.cs.utah.edu/plt/scope-sets/)

I don't have a reference for the module system offhand, though  
"Submodules in Racket: You Want it When, Again?" looks promising. I  
recall [From macros to DSLs: the evolution of  
Racket](https://drops.dagstuhl.de/storage/00lipics/lipics-vol136-snapl2019/LIPIcs.SNAPL.2019.5/LIPIcs.SNAPL.2019.5.pdf)  
also being enlightening. In fact, glancing at this latter indicates  
that the "You want it when" paper is _also_ about the module system!

If you're looking specifically for the compilation of modules to  
linklets, perhaps the Racket reference has some (ahem) references that  
might help?

---

<div class="post-metadata">

**Author:** ![Rugged](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rugged](https://racket.discourse.group/u/Rugged)\
**Post date:** [November 19, 2024, 2:01pm UTC](https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337/3 "2024-11-19T14:01:53Z")

</div>

Sure, I am also interested in linklets as well in the compilation phase, you are welcome to share those references as well, however for now, I am looking at how the module and macro system go hand in hand and how they interact together.

Also any paper or reference to Racket contracts, which seems to be the basis for typed racket, I am specifically interested in how typed racket utilizes those contracts.

Thanks

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [November 19, 2024, 3:23pm UTC](https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337/4 "2024-11-19T15:23:43Z")

</div>

You want it when, which @benknoble pointed to, is the definitive paper on the relationship between modules and macros.

Racket contracts are discussed in many papers, the first is [Contracts for Higher order functions](https://users.cs.northwestern.edu/~robby/pubs/papers/ho-contracts-icfp2002.pdf). The use of contracts by Typed Racket is discussed again in a number of papers, including [The Design and Implementation of Typed Scheme](https://dl.acm.org/doi/10.1145/1328438.1328486) and [my dissertation](https://www2.ccs.neu.edu/racket/pubs/dissertation-tobin-hochstadt.pdf).

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [November 20, 2024, 2:13pm UTC](https://racket.discourse.group/t/rackets-macro-module-and-contract-system/3337/5 "2024-11-20T14:13:33Z")

</div>

> [@Rugged](#):
>
> Also any paper or reference to Racket contracts, which seems to be the basis for typed racket, I am specifically interested in how typed racket utilizes those contracts.

There is a [TR Bibliography](https://docs.racket-lang.org/ts-reference/tr-bibliography.html), and I’m sure something in the [Racket bibliography](https://docs.racket-lang.org/reference/doc-bibliography.html) is about contracts (I just didn’t dig through the Reference section on contracts to find out). Sometimes there are paper links in the Guide versions, too.
