Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/alexknauth/typed-big-bang
- Owner: AlexKnauth
- License: mit
- Created: 2015-01-26T22:38:03.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T14:45:43.000Z (almost 3 years ago)
- Last Synced: 2024-10-16T02:55:20.013Z (3 months ago)
- Language: Racket
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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)
```