Hi Scott,

This is cool!

On 2016-01-27 14:05:10 -0500, Scott Moore wrote:
>    This does not quite achieve bounded parametric polymorphism because
>    there is no check that all values flowing through the same type
>    variable have the same type.

I think there is another sense in which it's not quite parametric (or at least
it's different from parametric->/c). Here's an example:

  Welcome to Racket v6.4.0.4.
  -> (require bounded)
  -> (struct foo (x) #:property prop:procedure 0)
  -> (define/contract (check fn val)
         (bounded-polymorphic->/c ([X (integer? . -> . integer?)]) (X any/c . 
-> . X))
         ;; I thought this would error rather than succeeding
         (displayln (foo-x fn))
         fn)
  -> (check (foo (lambda (x) 3)) 3)
  #<procedure>
  #<procedure>

How I imagined this might work is that you would wrap the value so that you can
only make observations corresponding to the bound. So here you force the `foo`
to act only as an int function, masking its structness since that's a finer
distinction than the bound gives you.

Also it's interesting that only higher-order contracts are accepted as bounds.
I guess because you need to stamp the value as belonging to X while still
allowing operations on it? (which you couldn't do on a symbol, say)

Cheers,
Asumu

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/20160128053757.GB15583%40simplyrobot.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to