private/typed-scheme.ss
#lang typed/scheme
(provide (all-defined-out))

;;======================================================================
;; Typed Scheme utilities

;; Assign singleton type.  Eg, (s x) === x : x.
(define-syntax-rule (s x) (ann x x))

(: cast (All (T) ((Any -> Boolean : T) Any -> T)))
(define (cast p? x)
  (if (p? x)
      x
      (error "Cast failed")))

(define: (integer-ceiling [n : Exact-Rational]) : Integer
  (let ((r (inexact->exact (ceiling n))))
    (if (exact-integer? r)
        r
        (error "barf"))))