2
votes

So I wrote a prototype Wolfenstein3d-style ray-caster in Racket. Understandably it's not blazingly-fast when run at higher-resolutions, so I'm trying to switch to Typed Racket.

My question is if there a way to do graphics (generally) in Typed Racket? For my particular purpose, all I need to be able to do is draw a line, and display/slice a bitmap.

What I've tried:

  • Big-bang from 2htdp/universe (what I originally used in regular racket) doesn't work with typed racket, and it's a complicated macro, so unlike an untyped-function I can't opaquely require/typed it.

  • racket/draw is class based, and support for classes in typed racket is experimental, so I wasn't surprised when I couldn't find typed/racket/draw version yet.

Anything I'm missing?

2

2 Answers

3
votes

In recent versions of Racket, you can use classes and racket/draw in Typed Racket. For example:

Welcome to Racket v6.0.1.13.
-> (require typed/racket/draw)
-> (make-bitmap 300 300)
- : (Instance Bitmap%)
(object:bitmap% ...)

but it's indeed still experimental so you may hit some bugs or limitations. In particular, for now you won't be able to pass GUI objects between typed and untyped modules.

(please submit bug reports if you find bugs)

1
votes

One option is to put the drawing operations in an untyped module, and call them from a typed module.