[racket] TR: unwrapping from <#Typed Value: ... > ??

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Fri Nov 25 10:33:52 EST 2011

On Fri, Nov 25, 2011 at 10:30 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> On Fri, Nov 25, 2011 at 9:13 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>> On Fri, Nov 25, 2011 at 9:58 AM, Robby Findler
>> <robby at eecs.northwestern.edu> wrote:
>>> Why can't you use contracts to do this kind of thing?
>> First, `cms->list' has to return a `(Listof Any)' because arbitrary
>> code on the stack can add to the mark set.
>> In the other direction, what would the contract on `w-c-m' be?  The
>> second argument is an arbitrary value, so it's wrapped with the
>> contract that's generated for `Any', which needs those `Typed Value'
>> wrappers. Perhaps it could make use of some more type information at
>> this point in special cases where that's available; I'll look into
>> that.
> Sorry-- I'm saying that you could let typed-racket programmers say
> "This value (that I happened to just get out of cms->list) has type
> 'Integer -> Integer'." and use contracts to enforce that.
> (I believe they can already do that if they make a new module that
> contains an identity function with an appropriate type but providing
> them a more convenient way to do it seems worthwhile for situations
> like this.)

I agree, a lighter-weight `cast' operation might be useful, here and
in other places.

> FWIW, working out a type system that could reason able the dynamic
> context of a call to cms->list (and thus get more type information)
> seems difficult. Perhaps this is one of those situations where
> contracts are the right choice?

Yes, indeed.  I think static information about the use of `cms->list'
is hopeless, except in very special cases.  I was only suggesting
using type information to generate better (ie, less restrictive)
contracts when using `w-c-m'.

sam th
samth at ccs.neu.edu

Posted on the users mailing list.