
in the original GitHub fork: https://github.com/ntoronto/racket Some things about this are known to be broken (most egregious is that the array tests DO NOT RUN because of a problem in typed/rackunit), about half has no coverage in the tests, and half has no documentation. Fixes and docs are coming. This is committed now to allow others to find errors and inconsistency in the things that appear to be working, and to give the author a (rather incomplete) sense of closure.
38 lines
1.1 KiB
Racket
38 lines
1.1 KiB
Racket
#lang racket/base
|
|
|
|
(require (for-syntax racket/base)
|
|
(for-template racket)
|
|
racket/syntax)
|
|
|
|
(provide (all-defined-out)
|
|
(all-from-out (submod "." ensures)))
|
|
|
|
(define-syntax-rule (define-inline-op name inline-op typed-op inline-pats ...)
|
|
(define-syntax (name stx)
|
|
(syntax-case stx ()
|
|
[(_ . inline-pats) (syntax/loc stx (inline-op . inline-pats))] ...
|
|
[(_ . args) (syntax/loc stx (typed-op . args))]
|
|
[_ (syntax/loc stx typed-op)])))
|
|
|
|
(module ensures racket/base
|
|
(require racket/flonum
|
|
typed/racket/base)
|
|
|
|
(provide (all-defined-out))
|
|
|
|
(define-syntax-rule (ensure-index name n-expr)
|
|
(let: ([n : Integer n-expr])
|
|
(if (index? n) n (raise-argument-error name "Index" n))))
|
|
|
|
(define-syntax-rule (ensure-flvector name xs-expr)
|
|
(let: ([xs : FlVector xs-expr])
|
|
(if (flvector? xs) xs (raise-argument-error name "FlVector" xs))))
|
|
|
|
(define-syntax-rule (ensure-procedure name f-expr T)
|
|
(let: ([f : T f-expr])
|
|
(if (procedure? f) f (raise-argument-error name "Procedure" f))))
|
|
|
|
)
|
|
|
|
(require 'ensures)
|