[racket] TR base-env typing classes/instances

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon Nov 12 10:11:17 EST 2012

[sorry for not responding earlier]

On Fri, Nov 9, 2012 at 11:32 AM, Ray Racine <ray.racine at gmail.com> wrote:
> I did poke around a bit at this with my morning coffee and I'd say it is not
> necessarily intuitively obvious to the casual observer on how to go from the
> internal "type" representation constructed via Class and Instance to a
> usable type predicate accepted in a base-env.rkt type declaration.
>
> Example of attempting to type spawn-node-supervise-place-at which returns
> (values (Instanceof remote-node%) (Instanceof remote-connection%)).
>
> Seeking to do something along the lines of this:
>
> [spawn-node-supervise-place-at (->key -String -Module-Path Sym
>                                       #:listen-port -NonNegFixnum #f
>                                       #:initial-message Univ #f
>                                       #:racket-path -Path #f
>                                       #:ssh-bin-path -Path #f
>                                       #:distributed-launch-path (-opt -Path)
> #f
>                                       #:restart-on-exit Univ #f
>                                       #:place-name (-opt Sym) #f
>                                       #:thunk -Boolean #f
>                                       (-values (list (-inst remote-node%)
>                                                         (-inst
> remote-connection%))))]

This is mostly right, except for the `(-inst ...)` parts.  The
argument to `-inst` (assuming you've defined it as an abbreviation for
`make-Instance`) should be something created with `make-Class`.  You
seem to be providing the names of actual Racket classes.

> With the companion decl along the lines of thus:
>
> [remote-connection% (make-pred-ty (make-Class '(...)'(...)'(...)))]

`make-pred-ty` is for the type of functions like `number?`.  Instead,
`remote-connection%`, which is a class, should have a type that's just
produced by `make-Class`.

--
sam th
samth at ccs.neu.edu

Posted on the users mailing list.