acceptable drracket definitions for interaction

36 views
Skip to first unread message

rick

unread,
Aug 14, 2019, 11:49:08 AM8/14/19
to racket...@googlegroups.com
Hello Racketeers,

I am brand new to Racket. I am interested in Blame Calculus and Gradual
Types.

Thanks for all the great work.

I have successfully validated the interaction increment example [1] in
DrRacket. However, running the combined modules in the definitions
window reports that there can only be one expression in the definitions
window.

How can I load both modules in the definitions window, so I don't have
to keep pasting them into REPL?

Thanks in advance for your help and thanks again for all the great work
on Racket.


1. https://docs.racket-lang.org/ts-guide/typed-untyped-interaction.html

--
rick

John Clements

unread,
Aug 19, 2019, 9:55:28 PM8/19/19
to rick, racket...@googlegroups.com
Are you referring to section 6.3, which defines modules as individual s-expressions?

It appears to me that this code would work fine if specified in the style shown earlier in section 6.1, where each module appears in its own file, begins with a #lang declaration, and the one referred to the other one using the name of the file in quotes. This would match the most common case of code development, where each module is contained in its own file.

However, you can certainly put both of them into one buffer, if that’s actually what you want. Use a #lang declaration at the top to implicitly wrap the whole file in a single module, making these two submodules, like this:

#lang racket

(module increment racket
(provide increment)

; increment : exact-integer? -> exact-integer?
(define (increment x) "this is broken"))

(module client typed/racket

(require/typed (submod ".." increment) [increment (-> Integer Integer)])

(increment 5))

(require ‘client)

Honestly, though, I would urge you to adopt the two-files style unless you have a really compelling reason not to.

John
> --
> You received this message because you are subscribed to the Google Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/dfc48fe3-10e9-0461-89e7-51a03a6207e5%40rickmurphy.org.



Reply all
Reply to author
Forward
0 new messages