[racket] keyword arguments for type constructors?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jun 7 08:49:47 EDT 2014

There is a terminology confusion in the PL world, and in a way Racket is well positioned to clarify these problems (except that people won't change their language). 

Things that happen at run-time: 

(struct s (x y z)) is a structure type definition 
(s 1 2 3) is a structure instance 
s is the structure constructor 
(define a (s 1 2 3)) defines a name for a structure type instance 
(s? a) determines whether a is an instance of s
(s-x a) tag checks a to make sure it's an instance of s and then retrieves the x field


Things that happen at compile time: 
Integer is a type 
-> is a type constructor, it constructs a new type from two other types (so does Listof)
(define-type-alias (Opt t) (U False t)) is a type alias definition, parameterized over t 
(Opt Integer) is a short-hand for (U False Integer), derived from a type alias definition 

I don't think we have type-alias definitions with keywords. But then again, I see no problem with this idea. I am not sure whether this answers Alexander's question but I thought I'd mention the above since it's a bit common to conflate these ideas. 

-- Matthias




Posted on the users mailing list.