From 61b8e098e63d760e61eaaf1216db0804b57d78e4 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 11 Mar 2015 13:41:14 -0400 Subject: [PATCH] Add doc examples for the struct form --- .../scribblings/reference/special-forms.scrbl | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl b/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl index 3a7a4fdc..0c502ed0 100644 --- a/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl +++ b/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl @@ -382,19 +382,36 @@ those functions. fields @racket[f] have types @racket[t], similar to the behavior of @|struct-id| from @racketmodname[racket/base]. When @racket[parent] is present, the -structure is a substructure of @racket[parent]. When -@racket[maybe-type-vars] is present, the structure is polymorphic in the type +structure is a substructure of @racket[parent]. + +@ex[ + (struct camelia-sinensis ([age : Integer])) + (struct camelia-sinensis-assamica camelia-sinensis ()) +] + +When @racket[maybe-type-vars] is present, the structure is polymorphic in the type variables @racket[v]. If @racket[parent] is also a polymorphic struct, then there must be at least as many type variables as in the parent type, and the parent type is instantiated with a prefix of the type variables matching the amount it needs. +@ex[ + (struct (X Y) 2-tuple ([first : X] [second : Y])) + (struct (X Y Z) 3-tuple 2-tuple ([first : X] [second : Y] [third : Z])) +] + Options provided have the same meaning as for the @|struct-id| form from @racketmodname[racket/base]. A prefab structure type declaration will bind the given @racket[name] to a @racket[Prefab] type. Unlike in @racketmodname[racket/base], a non-prefab structure type cannot extend a prefab structure type. + +@ex[ + (struct a-prefab ([x : String]) #:prefab) + (:type a-prefab) + (struct not-allowed a-prefab ()) +] }