# How to require with prefix in Typed Racket?

**URL:** <https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963>\
**Category:** General\
**Created:** [June 12, 2024, 7:44pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963 "2024-06-12T19:44:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![charmonium](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/charmonium/32/1823_2.png) [@charmonium](https://racket.discourse.group/u/charmonium)\
**Post date:** [June 12, 2024, 7:44pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/1 "2024-06-12T19:44:54Z")

</div>

Untyped racket has `(require (prefix-in xml: xml))`. Typed racket has `(require/typed xml [#| lots of decls here |#])`. How do I "mix" them?

---

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [June 12, 2024, 9:33pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/2 "2024-06-12T21:33:32Z")

</div>

Hi @charmonium and welcome to Racket!

It would be helpful if you could provide a minimal example code showing what you are trying to achieve, and highlighting the errors that prevent you from achieving your goal.

If you are trying to use `xml` with a prefix from typed code, the following should work:

```scheme
#lang typed/racket
(require (prefix-in xml: typed/xml))

```

You have already written the line for `require`ing `xml` wth a prefix in untyped code.

---

<div class="post-metadata">

**Author:** ![charmonium](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/charmonium/32/1823_2.png) [@charmonium](https://racket.discourse.group/u/charmonium)\
**Post date:** [June 12, 2024, 10:03pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/3 "2024-06-12T22:03:42Z")

</div>

Is `typed/xml` found in the manual. I [couldn't find it](https://docs.racket-lang.org/search/index.html?q=typed%2Fxml)?

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 12, 2024, 10:15pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/4 "2024-06-12T22:15:49Z")

</div>

I can't find it in the docs either, but it is defined here:

> <https://github.com/racket/typed-racket/blob/master/typed-racket-more/typed/xml.rkt>

---

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [June 13, 2024, 9:52am UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/5 "2024-06-13T09:52:46Z")

</div>

I found it because I've recently worked with `typed/pict`, so I typed "typed/pict" in the search box, which lead me me to [this page](https://docs.racket-lang.org/ts-reference/Libraries_Provided_With_Typed_Racket.html#%28mod-path._typed%2Fpict%29). I clicked on `typed-racket-more` at the end of the first line, which lead me to the of the [typed-racket-more](https://pkgs.racket-lang.org/package/typed-racket-more) package, giving an explicit list of typed interfaces to different untyped libraries provided by this package.

---

<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:** [June 13, 2024, 8:57pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/6 "2024-06-13T20:57:12Z")

</div>

I had been about to suggest that [3&nbsp;Libraries Provided With Typed Racket](https://docs.racket-lang.org/ts-reference/Libraries_Provided_With_Typed_Racket.html#%28mod-path._typed%2Fpict%29) needed an update. It can be done at [typed-racket/typed-racket-doc/typed-racket/scribblings/reference/libraries.scrbl at master · racket/typed-racket · GitHub](https://github.com/racket/typed-racket/blob/master/typed-racket-doc/typed-racket/scribblings/reference/libraries.scrbl)

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [June 15, 2024, 6:57pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/7 "2024-06-15T18:57:45Z")

</div>

> [@charmonium](#):
>
> Untyped racket has `(require (prefix-in xml: xml))`. Typed racket has `(require/typed xml [#| lots of decls here |#])`. How do I "mix" them?

Setting aside the choice of `typed/xml` vs. `xml`, I realized I also did not know the answer to the original question.

I found that this works:

```scheme
#lang typed/racket
(module untyped racket/base
  (define five 5)
  (provide five))
(require/typed
 (prefix-in u: 'untyped)
 [u:five Byte])
(add1 u:five) ;-> 6

```

However, it's not completely clear to me if it is supposed to work: I've opened [`require/typed` duplicates effects from expanding `m`; docs unclear · Issue #1378 · racket/typed-racket · GitHub](https://github.com/racket/typed-racket/issues/1378) to follow up.

---

<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:** [June 15, 2024, 10:51pm UTC](https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/8 "2024-06-15T22:51:12Z")

</div>

One thing I forgot to mention that Philip's suggestion reminded me of:

If you are going to use `xml` quite a bit in Typed Racket (and there wasn't `typed/xml`), I recommend the following:

- Create a "typed-xml.rkt" module that does `(require/typed xml …)` and re-`provide`s the functionality of the `xml` module.
- Then, (typed) clients choose how to `require` it in the usual way, including `(require (prefix-in xml: "typed-xml.rkt"))`.
