It's quite possible that this is Eli's bug again, but boy this causes 
headaches: 

> Type Checker: parse error in type;
>  type variable must be used with ...
>   variable: Y in: Y

And it points precisely to where Y is followed by ... 

        
#lang typed/racket 

(module+ test (require rackunit))

;; [Listof X] [X [Listof X] Y ... -> Y ...] Y ... -> Y ...
(: foldl* (All (X Y ...) (->* [Listof X] [->* X Y ... (Values Y ...)] Y ... 
(Values Y ...))))
(define (foldl* l f e1 . es)
  (define e+ (cons e1 es))
  (cond
    [(empty? l) (apply values e+)]
    [else (call-with-values 
           (lambda () (apply f (first l) e+))
           (lambda e*
             (unless (cons? e*) ;; should I check that (= (length e*) (length 
e+))
               (error 'fold* "f produced too few values: ~e" e*))
             (apply foldl* (rest l) f e*)))]))

(module+ test
  (define distances '(50 40 70 30 30))
  
  (check-equal? 
   (call-with-values 
    (lambda ()
      (foldl* distances
              (lambda (fst distance distance*)
                (values (+ fst distance) (cons (+ fst distance) distance*)))
              0
              '()))
    (lambda (_ x)
      (reverse x)))
   '(50 90 160 190 220)))


_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

Reply via email to