[racket] Typed racket and apply

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Fri Jun 27 13:55:52 EDT 2014

I would write the program this way:

#lang typed/racket

(: exit-with-error-msg : String Any * -> Any)
(define (exit-with-error-msg m . e)
    (apply eprintf m e)
    (exit 1))

Note that we explicitly require at least one argument, the format
string.  In your program, Typed Racket can't tell that you won't call
`exit-with-error-msg` with 0 arguments, which would not be correct for
`eprintf`.

Sam

On Fri, Jun 27, 2014 at 1:52 PM, Manfred Lotz <manfred.lotz at arcor.de> wrote:
> I have this:
>
> (define (exit-with-error-msg . e)
>     (apply eprintf e)
>     (exit 1))
>
>
> When using it with typed racket I get:
>
> test.rkt:127:4: Type Checker: Bad arguments to function in apply:
> Domain: String Any *
> Arguments: (Listof Any) *
>
>   in: (apply eprintf e)
>   context...:
>    /home/manfred/racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:249:0:
>   type-check /home/manfred/racket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:40:0:
>   tc-setup /home/manfred/racket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:25:4
>    standard-module-name-resolver
>
> I have to admit it is not clear to me how I would specify a type for
> exit-with-error-msg.
>
> Any idea?
>
> --
> Manfred
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.