Typed: Libraries and Utilities
David Van Horn <dvanhorn@ccs.neu.edu>
This package contains a set of typed libraries. It is still under development.
1 util
(require (planet dvanhorn/typed:1:2/util)) |
Casting is useful to embed type refinements the programmer can prove that Typed Scheme is not able to reason about.
Examples: |
> (sin pi) |
- : Complex |
1.2246467991473532e-16 |
> (cast real? (sin pi)) |
- : Real |
1.2246467991473532e-16 |
| |
| |
| |
|
Examples: |
> (round 3/2) |
- : Real |
2 |
> (exact-round 3/2) |
- : Integer |
2 |
> (round 2.5) |
- : Real |
2.0 |
> (exact-round 2.5) |
- : Integer |
2 |
It is a contract violation to apply these operations to a non-rational real (i.e., +inf.0, -inf.0, or +nan.0), since there is no exact representation of these values.
Examples: | |||
> (round +inf.0) | |||
- : Real | |||
+inf.0 | |||
> (exact-round +inf.0) | |||
/Users/dvanhorn/Documents/planet/typed/private/util.ss:2.19: | |||
| |||
| |||
contract (-> rational? any/c) on exact-round; expected | |||
<rational?>, given: +inf.0 |
2 2htdp/image
(require (planet dvanhorn/typed:1:2/2htdp/image)) |
This module provides a typed 2htdp/image library.
3 2htdp/universe
(require (planet dvanhorn/typed:1:2/2htdp/universe)) |