Carlo V. Dango
Carlo V. Dango

Reputation: 13832

Racket simple AE define-type

From the book "Programming Languages: Application and Interpretation" page 6 I try to code the very first example in DrRacket

#lang typed/racket

(define-type AE
 [num (n number?)]
 [add (lhs AE?) (rhs AE?)]
 [sub (lhs AE?) (rhs AE?)])

But I get the error

aeinterpretter.rkt:5:2: define-type: unexpected term in: (add (lhs AE?) (rhs AE?))

What am I doing wrong here?

Upvotes: 3

Views: 1395

Answers (1)

Asumu Takikawa
Asumu Takikawa

Reputation: 8523

You should run this example in the PLAI language:

#lang plai

(define-type AE
 [num (n number?)]
 [add (lhs AE?) (rhs AE?)]
 [sub (lhs AE?) (rhs AE?)])

The Typed Racket language is a totally different language that gives you most of the power of the base Racket language, but with a static type system. The define-type form in PLAI is a different notion of "type".

Upvotes: 7

Related Questions