[plt-scheme] for comprehensions in typed-scheme

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Jun 8 09:54:36 EDT 2009

On Mon, Jun 8, 2009 at 1:45 PM, Sam TH<samth at ccs.neu.edu> wrote:
> This works:


Next dumb question:

(define-struct: Mark ())
(define-struct: (Dot Mark) ([x : Number] [y : Number]))

(: bounding-box ((Listof Dot) -> Box))
(define (bounding-box marks)
  ;; This only works for Dots. It should work for all Marks
  (define: xs : (Listof Number) (map Dot-x marks))
  (define: ys : (Listof Number) (map Dot-y marks))
  (define: max-x : Number (#{apply @ Number Number} max xs))
  (define: max-y : Number (apply max ys))
  (define: min-x : Number (apply min xs))
  (define: min-y : Number (apply min ys))

All the calls to apply fail with

typecheck: Bad arguments to function in apply:
Domain: Number Number *
Arguments: (Listof Number) *

I don't get it! At the REPL I can do:

  (apply max (list 1 2 3 4))

and it works. My expressions above seem equivalent. What must I do to
get this past the type checker?


Posted on the users mailing list.