1#lang racket/base
2(require racket/phase+space)
3
4(provide phase?
5         phase+
6         phase-
7         phase<?
8         zero-phase?
9         label-phase?
10         phase?-string)
11
12;; Terminology:
13;;
14;;  * A "phase" is the phase at which a module is instantiated.
15;;
16;;  * A "phase level" is a phase relative to a module's body.
17;;
18;;  * A "phase shift" is a delta to combne with other phases.
19;;
20;; This termonology is approximate, because one use's "phase" is
21;; another use's "phase level". Also, all three have the same
22;; representation.
23
24(define (phase+ a b)
25  (and a b (+ a b)))
26
27(define (phase- a b)
28  (and a b (- a b)))
29
30(define (phase<? a b)
31  (cond
32   [(not b) #f]
33   [(not a) #t]
34   [else (< a b)]))
35
36(define (zero-phase? a)
37  (eq? a 0))
38
39(define (label-phase? a)
40  (not a))
41
42;; For contract errors:
43(define phase?-string "phase?")
44