The trivial
library implements type tailoring for a variety of standard library operations.
The tailored operations catch more errors statically and raise fewer unnecessary type errors.
#lang typed/racket
(require trivial)
(format "binary(~a) = ~b" 3.14 3.14)
;; static type error :)
(let ([match-list (regexp-match #rx"(a*)(b*)" "aaab")])
(if match-list
(string-length (second match-list))
0))
;; not a type error :)
(vector-ref (make-vector 3 #true) 4)
;; static bounds error :)
See the documentation for more details. http://docs.racket-lang.org/trivial/index.html
From the package server:
$ raco pkg install trivial
From GitHub:
$ git clone https://github.com/bennn/trivial
$ raco pkg install ./trivial
trivial/main.rkt
defines the API (e.g. the result of(require trivial)
)trivial/define.rkt
trivial/format.rkt
trivial/function.rkt
trivial/integer.rkt
trivial/list.rkt
trivial/regexp.rkt
trivial/vector.rkt
implement tailored versions of Racket formstrivial/tailoring.rkt
is an API for building new tailoringstrivial/private/
main implementationtest/
unit tests