Search code examples
referenceracketalgebraic-data-types

Racket: define-type reference


I am trying to use define-type to compile a suitable algebraic data type for references:

Books:                    Author. Title. Publisher, City Year
Articles from Magazines:  Author. Title. Name of Magazine, Year
Conference Contributions: Author. Title. Name of Conference. Publisher, City Year

Unfortunately I have no idea how to approach this problem. Though I do know the features of define-type and its difference to define-struct.

Can anyone point me in the right direction? It would be greatly appreciated!


Solution

  • Assuming define-type refers to the define-type from htdp2/abstraction:

    (define-type reference
       (book (author string?) (title string?) (publisher string?) (city string?) (year number?))
       (magazine-article (author string?) ...etc...)
       (conference-contribution (author string?) ...etc...))