[racket] recommendations how to use Typed Racket with rackunit?

From: keydana at gmx.de (keydana at gmx.de)
Date: Tue Nov 30 15:47:53 EST 2010

Sorry, it's me again - but unfortunately, changing back to define-struct: in 5.0.2 does not work...

Now with a defining module like

#lang typed/racket
(provide (all-defined-out))

(define-type Value (U Number String)) 

(define-struct: Triple ((name : String) (type : (U (Any -> Boolean : Number) (Any -> Boolean : String))) (value : Value))
  #:mutable
  #:property prop:equal+hash
    (list (lambda (t1 t2 equal?-recur) ; Attribute names are case insensitive, attribute type names are not; values are treated individually for each variant
            (and (string=? (string-upcase (Triple-name t1)) (string-upcase (Triple-name t2))) (eq? (Triple-type t1) (Triple-type t2)) (equal? (Triple-value t1) (Triple-value t2))))
          (lambda (t hash-recur)
            (+ (hash-recur (string-upcase (Triple-name t))) (* 3 (hash-recur (Triple-type t))) (* 3 (hash-recur (Triple-value t)))))
           (lambda (t hash2-recur)
            (+ (hash2-recur (string-upcase (Triple-name t))) (* 3 (hash2-recur (Triple-type t))) (* 3 (hash2-recur (Triple-value t)))))))


and a second file like

#lang typed/racket/no-check

(require "../types.rkt")
(let: ((t1 : Triple (make-Triple "count" number? 1))) #t)

I get the error

Type Checker: The type of make-Triple cannot be converted to a contract in: (make-Triple "count" number? 1)

If I take out the no-check from the language definition, it works fine - but the no-check I need to run the test cases...

Could you perhaps point me to another way of running tests with typed racket, so I wouldn't need the no-check? (I mean writing, not running, I don't need any fancy GUI  :-;)

Many thanks,
Sigrid





Am 30.11.2010 um 02:47 schrieb Sam Tobin-Hochstadt:

> On Mon, Nov 29, 2010 at 3:20 PM, keydana at gmx.de <keydana at gmx.de> wrote:
>>> Check out the `racket/load' language for exactly this purpose.
>> 
>> Sorry I don't get it - is there a way I could use it to have both struct: and not get the syntax error?
>> I've tried (without really understanding the chapter in the reference, I must admit)
> 
> No, `racket/load' is for writing quick programs that are like the top-level:
> 
> #lang racket/load
> 
> (module m racket
>  (define x 1)
>  (provide x))
> 
> (module m2 racket
>   (require 'm)
>   (+ 2 x))
> 
> (require 'm2)
> 
> -- 
> sam th
> samth at ccs.neu.edu



Posted on the users mailing list.