#lang racket/base (require racket/contract racket/list racket/match) (provide metadata? metadata-ref metadata-ref+) (define metadata? (listof (or/c (list/c 'date integer? integer? integer?) (list/c 'title string?) (list/c 'slug string?) (cons/c 'tags (listof string?)) (list/c 'summary string?) (cons/c 'authors (listof string?))))) (define (metadata-ref md key [default (λ () (error "no such key"))]) (match (assoc key md) [#f (if (procedure? default) (default) default)] [(cons _ rst) rst])) (define (metadata-ref+ md key [default (λ () (error "no such key"))]) (first (metadata-ref md key default)))