typed-big-bang
1 typed/  big-bang
big-bang
Tick  Handler
Renderer
Key  Handler
Pad  Handler
Mouse  Handler
Handler  Result
Key  Event
Mouse  Event
Pad  Event
Stop  With
stop-with
key-event?
key=?
pad-event?
pad=?
mouse-event?
mouse=?
2 typed/  2htdp/  image
Image
Image-Color
image?
image-width
image-height
empty-scene
overlay
text
6.2.901.900

typed-big-bang

source code: https://github.com/AlexKnauth/typed-big-bang

1 typed/big-bang

 (require typed/big-bang) package: typed-big-bang

see also typed/2htdp/universe

procedure

(big-bang init-state    
  world?    
  [#:on-tick tick    
  #:tick-rate rate    
  #:tick-limit limit    
  #:on-key handle-key    
  #:on-pad handle-pad    
  #:on-release handle-release    
  #:on-mouse handle-mouse    
  #:to-draw render    
  #:width width    
  #:height height    
  #:stop-when last-world?    
  #:name name    
  #:on-key/key-event% handle-key-event%    
  #:on-mouse/mouse-event% handle-mouse-event%])  World
  init-state : World
  world? : [Any -> Boolean : World]
  tick : (TickHandler World) = identity
  rate : Positive-Real = 30
  limit : (U Natural +inf.0) = +inf.0
  handle-key : (KeyHandler World) = (λ ....)
  handle-pad : (PadHandler World) = #f
  handle-release : (KeyHandler World) = (λ ....)
  handle-mouse : (MouseHandler World) = (λ ....)
  render : (Renderer World) = (λ ....)
  width : (U Natural #f) = #f
  height : (U Natural #f) = #f
  last-world? : [World -> (U Boolean Image)] = (λ ....)
  name : (U Symbol String) = "World"
  handle-key-event% : [World (Instance Key-Event%) -> (HandlerResult World)]
   = (λ ....)
  handle-mouse-event% : [World (Instance Mouse-Event%) -> (HandlerResult World)]
   = (λ ....)
a function that bahaves like big-bang from 2htdp/universe.

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)

type

(TickHandler World)

equivalent to [World -> (HandlerResult World)]

type

(Renderer World)

equivalent to [World -> Image]

type

(KeyHandler World)

equivalent to [World KeyEvent -> (HandlerResult World)]

type

(PadHandler World)

equivalent to [World PadEvent -> (HandlerResult World)]

type

(MouseHandler World)

equivalent to [World Integer Integer MouseEvent -> (HandlerResult World)]

type

(HandlerResult World)

equivalent to (U World StopWith)

the type for a key event, corrosponding to KeyEvents from 2htdp/universe

the type for a mouse event, corrosponding to MouseEvents from 2htdp/universe

the type for a pad event, corrosponding to PadEvents from 2htdp/universe

type

StopWith

struct

(struct stop-with (w))

  w : World
a struct to tell big bang to stop the world with the final state w.

procedure

(key-event? v)  Boolean

  v : Any
returns #t if v is a KeyEvent.

procedure

(key=? x y ...)  Boolean

  x : KeyEvent
  y : KeyEvent
returns #t if the given KeyEvents are equal.

procedure

(pad-event? v)  Boolear

  v : Any
returns #t if v is a PadEvent.

procedure

(pad=? x y ...)  Boolean

  x : PadEvent
  y : PadEvent
returns #t if the given PadEvents are equal.

procedure

(mouse-event? v)  Boolean

  v : Any
returns #t if v is a MouseEvent.

procedure

(mouse=? x y ...)  Boolean

  x : MouseEvent
  y : MouseEvent
returns #t if the given MouseEvents are equal.

2 typed/2htdp/image

 (require typed/2htdp/image) package: 2htdp-typed
provides types for some functions from 2htdp/image.

type

Image

the type for images from 2htdp/image

a color

procedure

(image? v)  Boolean

  v : Any
returns #t if v is an Image

procedure

(image-width img)  Natural

  img : Image
returns the width of img

procedure

(image-height img)  Natural

  img : Image
returns the height of img

procedure

(empty-scene width height)  Image

  width : Natural
  height : Natural
returns an empty scene with the given width and height

procedure

(overlay i1 i2 ...)  Image

  i1 : Image
  i2 : Image
overlays i1 on top of i2, and so on.

procedure

(text str size color)  Image

  str : String
  size : Natural
  color : Image-Color
returns an image that draws str.