[plt-scheme] Scribble eval contract violation examples

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Thu Apr 30 14:21:30 EDT 2009

Scribble seems to do some funny line breaking when it typesets contract 
violation examples.

Here is a simple example:

$ cat err-width.scrbl
#lang scribble/doc
@(require scribble/eval)

@(define the-eval
   (let ([the-eval (make-base-eval)])
     (the-eval '(error-print-width 100))
     (the-eval '(require scheme/contract))
     (the-eval '(define/contract f
                  (-> (and/c number?) any)
                  (lambda (x) x)))
     (the-eval '(define/contract g
                  (-> (and/c number? number?) any)
                  (lambda (x) x)))

     the-eval))

@interaction[#:eval the-eval
                     (f 0)
                     (f "a")
                     (g 0)
                     (g "a")]

$ scribble err-width.scrbl
  [Output to err-width.txt]

$ cat err-width.txt

   > (f 0)
   0
   > (f "a")
   top-level broke the contract (-> (and/c number?) any) on f;
   expected <(and/c number?)>, given: "a"
   > (g 0)
   0
   > (g "a")
   top-level broke the contract
     (-> (and/c number? number?)
   any)
    on g; expected <(and/c number? number?)>, given: "a"

Notice the weird line breaks despite ample width to print the contract.

It seems to be Scribble specific since the same interaction in MzScheme 
prints the contract violation just fine:

Welcome to MzScheme v4.1.5.4 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.
 > (error-print-width 100)
 > (require scheme/contract)
 > (define/contract g
                  (-> (and/c number? number?) any)
                  (lambda (x) x))
 > (g "a")
top-level broke the contract
   (-> (and/c number? number?) any)
  on g; expected <(and/c number? number?)>, given: "a"

David



Posted on the users mailing list.