Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexknauth/typed-big-bang

a big-bang-ish thing for typed racket
https://github.com/alexknauth/typed-big-bang

Last synced: about 1 month ago
JSON representation

a big-bang-ish thing for typed racket

Awesome Lists containing this project

README

        

# typed-big-bang

see also [lexi-lambda/racket-2htdp-typed](https://github.com/lexi-lambda/racket-2htdp-typed)

```(require typed/big-bang)```

This does not provide a drop in replacement for big-bang from 2htdp/universe.

Instead of a macro, it provides a function, which has keyword arguments for #:on-tick, #:to-draw, etc.

You also have to provide a `world?` predicate, and use (inst big-bang World).

An example world program:
```
#lang typed/racket

(require typed/big-bang
typed/2htdp/image)

(define-type World Integer)

(: main : [World -> World])
(define (main t)
((inst big-bang World)
t
exact-integer?
#:on-tick add1
#:to-draw render
#:stop-when (λ ([t : Integer]) (<= 10000 t))
#:on-key (λ ([t : Integer] [key : KeyEvent])
(cond [(key=? key "+") (+ 1000 t)]
[else t]))
#:on-release (λ ([t : Integer] [key : KeyEvent])
(- t 100))
#:on-mouse (λ ([t : Integer] [x : Integer] [y : Integer] [me : MouseEvent])
(- t 2))
))

(: render : [World -> Image])
(define (render t)
(overlay (text (number->string t) 36 "black")
(empty-scene 200 200)))

(main 0)
```