Trying to convert the following to typed Racket:
(define (unique list message . messageargs)
; return the only element of the list, or '() if there is none.
; Produce message if not just one.
(if (equal? 1 (length list)) (car list)
(begin
(apply fprintf (cons anomaly (cons messa
(define (unique [list : (Listof Any)] [message : String] .
[messageargs : Any *])
; return the only element of the list, or '() if there is none.
; Produce message if not just one.
(if (equal? 1 (length list)) (car list)
(begin
(apply fprintf anomaly message messageargs)
(i
On Fri, Apr 10, 2020 at 08:18:38PM -0400, Jon Zeppieri wrote:
> (define (unique [list : (Listof Any)] [message : String] .
> [messageargs : Any *])
> ; return the only element of the list, or '() if there is none.
> ; Produce message if not just one.
> (if (equal? 1 (length list)) (car list)
If I understand correctly, the difference to getting the code to type
check was:
> (apply fprintf (cons anomaly (cons message messageargs)))
becomes:
>(apply fprintf anomaly message messageargs)
Since the documentation explains that the arguments to fprintf are
effectively gather
The change makes a difference because Typed Racket's type inference
for `cons` is producing a less-accurate answer than it could. When it
sees arguments of type `String` and `(Listof Any)`, it decides that
the result is a `(Listof Any)` instead of a `(Pairof String (Listof
Any))`.
If you add (exce
Thanks Sam, for the explanation.
I was thinking that some information was lacking to the type inference
system, and it helps to see the annotation incantations necessary to fill
in the gap.
Cheers,
Kieron.
On Mon, Apr 13, 2020 at 1:32 PM Sam Tobin-Hochstadt
wrote:
> The change makes a differe
6 matches
Mail list logo