Typed Intro
Many of the most common languages in use today require you to specify the types on inputs and outputs of a function. That is to say, they every function requires a signature.
There are two main benefits to this kind of typing:
-
Speed. The code runs faster when the computer has no doubt that a certain variable always contains a certain kind of value, like a posn.
-
Reliability. The computer can check before starting the program that there is never a time when the
posn-x
function is called on acolor
. In regular Racket, this kind of mistake causes the program to halt with an error when the mistake runs. In Typed Racket, the mistake is detected before the program starts running - there is no suspense and no uncertainty.
Initial Setup
-
One time per computer:
File -> “Install Package…” -> Enter “picturing-programs-typed” and choose the “Install” button.
-
Beginning of every file:
#lang typed/racket (require typed/picturing-programs)
-
End of the file - you need to run the check-expects manually.
(test)