www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

expander-types.scrbl (1714B)


      1 #lang scribble/manual
      2 @(require "doc-util.rkt")
      3 
      4 @title{Expander Types}
      5 
      6 Under the hood, each generic expander defined with this library has
      7 an associated @italic{expander type}. Syntax transformers built
      8 with this library examine this type to determine whether or not
      9 they should expand them.
     10 
     11 @defpredicate[expander-type?]{
     12  A predicate for values produced by @racket[make-expander-type] and
     13  variants.
     14  @generic-syntax-examples[
     15  (expander-type? (make-expander-type))
     16  (expander-type? 'foo)]}
     17 
     18 @defproc[(make-expander-type) expander-type?]{
     19  Creates a unique @racket[expander-type?] for use in defining a new
     20  kind of generic expander.
     21  @generic-syntax-examples[
     22  (make-expander-type)]}
     23 
     24 @defproc[(make-union-expander-type [type expander-type?] ...+) expander-type?]{
     25  Creates a union @racket[expander-type?]. This union type includes
     26  all of the given types, as well as any union type of a subset of
     27  the given types.
     28  @generic-syntax-examples[
     29  (make-union-expander-type (make-expander-type) (make-expander-type))]}
     30 
     31 @defproc[(expander-type-includes? [type-1 expander-type?] [type-2 expander-type?]) boolean?]{
     32  Returns @racket[#t] if the two types are either identical, or if either
     33  type is a union type that contains the other, or if both types are
     34  union types and contain a nonempty intersection. Returns @racket[#f]
     35  otherwise.
     36  @generic-syntax-examples[
     37  (define A (make-expander-type))
     38  (define B (make-expander-type))
     39  (define C (make-expander-type))
     40  (expander-type-includes? A A)
     41  (expander-type-includes? B C)
     42  (define AB (make-union-expander-type A B))
     43  (define BC (make-union-expander-type B C))
     44  (expander-type-includes? AB A)
     45  (expander-type-includes? AB C)
     46  (expander-type-includes? AB BC)]}