Add an explain tabulate*/untyped.
This commit is contained in:
parent
37dddb190f
commit
31d6275229
2 changed files with 38 additions and 3 deletions
|
@ -11,11 +11,15 @@
|
||||||
|
|
||||||
(module typed typed/racket
|
(module typed typed/racket
|
||||||
(require "utils.rkt"
|
(require "utils.rkt"
|
||||||
|
(only-in typed/racket/unsafe unsafe-provide)
|
||||||
(for-syntax syntax/parse))
|
(for-syntax syntax/parse))
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
tabulate* tabulate*/strict)
|
tabulate* tabulate*/strict)
|
||||||
|
|
||||||
|
(unsafe-provide
|
||||||
|
(rename-out [tabulate* tabulate*/untyped]))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require typed/rackunit))
|
(require typed/rackunit))
|
||||||
|
|
||||||
|
@ -56,7 +60,7 @@
|
||||||
|
|
||||||
(require 'typed)
|
(require 'typed)
|
||||||
(provide
|
(provide
|
||||||
tabulate* tabulate*/strict)
|
tabulate* tabulate*/strict tabulate*/untyped)
|
||||||
|
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
|
@ -123,7 +127,7 @@
|
||||||
;;; in order, produces a list of lists giving the values of arguments
|
;;; in order, produces a list of lists giving the values of arguments
|
||||||
;;; and the value of the functions for these inputs.
|
;;; and the value of the functions for these inputs.
|
||||||
(define (tabulate func doms)
|
(define (tabulate func doms)
|
||||||
(tabulate* `(,func) doms))
|
(tabulate*/untyped `(,func) doms))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "tabulate"
|
(test-case "tabulate"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#lang scribble/manual
|
#lang scribble/manual
|
||||||
@(require scribble/example racket/sandbox
|
@(require scribble/example racket/sandbox
|
||||||
(for-label typed/racket/base "../functions.rkt" dds/utils))
|
(for-label typed/racket/base "../functions.rkt" dds/utils
|
||||||
|
typed/racket/unsafe))
|
||||||
|
|
||||||
@title[#:tag "functions"]{dds/functions: Formal Functions}
|
@title[#:tag "functions"]{dds/functions: Formal Functions}
|
||||||
|
|
||||||
|
@ -60,6 +61,36 @@ The result of @racket[tabulate*] can be obtained by applying
|
||||||
'((#f #t) (#f #t))))
|
'((#f #t) (#f #t))))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defproc[(tabulate*/untyped [funcs (listof procedure?)]
|
||||||
|
[doms (listof list?)])
|
||||||
|
(listof list?)]{
|
||||||
|
|
||||||
|
A version of @racket[tabulate*] without type checking.
|
||||||
|
|
||||||
|
As of 2022-03-06, Typed Racket cannot generate contracts for polymorphic
|
||||||
|
variable-arity functions. This means that @racket[tabulate*] cannot be used
|
||||||
|
directly in untyped code and should be replaced by @racket[tabulate*/untyped],
|
||||||
|
which is simply an @racket[unsafe-provide] of @racket[tabulate*].
|
||||||
|
|
||||||
|
@examples[#:eval functions-evaluator
|
||||||
|
(tabulate*/untyped (list (λ (x y) (and x y))
|
||||||
|
(λ (x y) (or x y)))
|
||||||
|
'((#f #t) (#f #t)))
|
||||||
|
]
|
||||||
|
|
||||||
|
The contracts in the documentation entry are provided for explanatory purposes
|
||||||
|
and are not actually enforced. Some contracts on the functions
|
||||||
|
@racket[tabulate*] uses internally are still checked. For example, trying to
|
||||||
|
tabulate a function of wrong arity will still raise an error.
|
||||||
|
|
||||||
|
@examples[#:eval functions-evaluator
|
||||||
|
(module untyped-test racket/base
|
||||||
|
(require "functions.rkt")
|
||||||
|
(tabulate*/untyped (list (λ (x y z) (and x y z)))
|
||||||
|
'((#f #t) (#f #t))))
|
||||||
|
(eval:error (require 'untyped-test))
|
||||||
|
]}
|
||||||
|
|
||||||
@section{Constructing functions}
|
@section{Constructing functions}
|
||||||
|
|
||||||
@section{Random functions}
|
@section{Random functions}
|
||||||
|
|
Loading…
Reference in a new issue