[racket-dev] chaperones in 5.3.1?

From: Danny Yoo (dyoo at hashcollision.org)
Date: Thu Oct 25 14:33:04 EDT 2012

On Wed, Oct 24, 2012 at 8:19 PM,  <sstrickl at ccs.neu.edu> wrote:
> I've pushed a change which fixes this.

Ok, thank you.

Whalesong is still not working, but it got further this time.  I'm
hitting the following exception now:


###################################################
ensure-const-value: broke its contract
 Attempted to use a higher-order value passed as `Any`
 in: the 1st argument of
      (recursive-contract
       (->
        any-wrap/c
       ....
###################################################


Here's sample test code to emit the contract error.  I don't know how
to fix it yet.

;;;
;;; test-const-value.rkt
;;;
#lang typed/racket/base
(require "const-value.rkt")
(require/typed "helper.rkt"
               [ensure-const-value (Any -> const-value)]
               [a-constant-value Any])
(ensure-const-value a-constant-value)




;;;
;;; const-value.rkt
;;;
#lang typed/racket
(provide (all-defined-out))
(struct: Constant ([v : Any]))
(define-type const-value
  (Rec C
       (U Symbol
          String
          Number
          Boolean
          Void
          Null
          Char
          Bytes
          Path
          (Pairof C C)
          (Vectorof C)
          (Boxof C))))



;;;
;;; helper.rkt
;;;
#lang racket/base

(provide ensure-const-value
         a-constant-value)
(require "const-value.rkt")
(define (ensure-const-value x)
  (cond
   [(symbol? x)
    x]
   [(boolean? x)
    x]
   [(string? x)
    x]
   [(number? x)
    x]
   [(void? x)
    x]
   [(null? x)
    x]
   [(char? x)
    x]
   [(bytes? x)
    x]
   [(path? x)
    x]
   [(pair? x)
    (begin (ensure-const-value (car x))
           (ensure-const-value (cdr x))
           x)]
   [(vector? x)
    (begin (for-each ensure-const-value (vector->list x)))
    x]
   [(box? x)
    (ensure-const-value (unbox x))
    x]
   [else
    (error 'ensure-const-value "Not a const value: ~s\n" x)]))

(define a-constant-value (Constant '(check-expect (greet "danny")
"hello danny")))

Posted on the dev mailing list.