# Contracts from definitions window implied to the interactions window?

**URL:** <https://racket.discourse.group/t/contracts-from-definitions-window-implied-to-the-interactions-window/3240>\
**Category:** Questions & Answers\
**Tags:** question, drracket\
**Created:** [October 19, 2024, 9:02pm UTC](https://racket.discourse.group/t/contracts-from-definitions-window-implied-to-the-interactions-window/3240 "2024-10-19T21:02:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)\
**Post date:** [October 19, 2024, 9:02pm UTC](https://racket.discourse.group/t/contracts-from-definitions-window-implied-to-the-interactions-window/3240/1 "2024-10-19T21:02:17Z")

</div>

When opening DrRacket with a file that provides contracted procedures, the contracts are not checked when calling a procedure in the interactions window. A simple solution is:

(define my-module base-module  
source ...)

(require 'my-module)  
(provide (all-from-out 'my-module))

Would it be possible and desirable to make the interaction window check contracts without this hack?

---

<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:** [October 19, 2024, 9:18pm UTC](https://racket.discourse.group/t/contracts-from-definitions-window-implied-to-the-interactions-window/3240/2 "2024-10-19T21:18:21Z")

</div>

An easier hack is to leave your source code as usual, but use:

```scheme
(require (submod "."))

```

in the interactions window to get the contracted versions of exports.

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [October 19, 2024, 9:22pm UTC](https://racket.discourse.group/t/contracts-from-definitions-window-implied-to-the-interactions-window/3240/3 "2024-10-19T21:22:40Z")

</div>

```scheme

#lang racket

(provide/contract (f (-> integer? integer?)))

(define (f x) x)

```

RUN

```scheme

Welcome to DrRacket, version 8.14.0.4 [cs].
Language: racket, with test coverage [custom].
> (require (submod "."))
> (f 'a)
. . f: contract violation
expected: integer?
given: 'a
in: the 1st argument of
(-> integer? integer?)
contract from: anonymous-module
blaming: anonymous-module
(assuming the contract is correct)
at: 63-unsaved-editor:3:19

```

---

<div class="post-metadata">

**Author:** ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)\
**Post date:** [October 20, 2024, 7:38pm UTC](https://racket.discourse.group/t/contracts-from-definitions-window-implied-to-the-interactions-window/3240/4 "2024-10-20T19:38:58Z")

</div>

Thanks to both Matthias F and LiberalArtist. Works well too, but does require me to remember to require the submod in the interactions window. With my hack I can change the definitions window and immediately try it in the interactions window, without re-requiring (submod ".").
