Hi, all.

Why does the following typecheck:

    #lang typed/racket

    (provide group)

    (define #:forall (A)
      (group [list : (Listof A)]
             [count : Exact-Positive-Integer]) : (Listof (Listof A))
      (: group-step (All (A) ((Listof A) (Listof A) (Listof (Listof A)) -> 
(Listof (Listof A)))))
      (define (group-step list group groups)
        (cond [(and (empty? list) (empty? group)) groups]
              [(empty? list) (cons (reverse group) groups)]
              [(= (length group) count)
               (group-step (rest list) `(,(first list)) (cons (reverse group) 
groups))]
              [else
               (group-step (rest list) (cons (first list) group) groups)]))
      (reverse (group-step list empty empty)))

But the following doesn't:

    #lang typed/racket

    (provide group)

    (define #:forall (A)
      (group [list : (Listof A)]
             [count : Exact-Positive-Integer]) : (Listof (Listof A))
      (define #:forall (A)
        (group-step [list : (Listof A)]
                    [group : (Listof A)]
                    [groups : (Listof (Listof A))]) : (Listof (Listof A))
        (cond [(and (empty? list) (empty? group)) groups]
              [(empty? list) (cons (reverse group) groups)]
              [(= (length group) count)
               (group-step (rest list) `(,(first list)) (cons (reverse group) 
groups))]
              [else
               (group-step (rest list) (cons (first list) group) groups)]))
      (reverse (group-step list empty empty)))

(Notice the change in the declaration of the inner function's signature, inlined
in the `define' vs. separate on it's on `(: ...)'.)

The error message:

    Type Checker: insufficient type information to typecheck. please add more 
type annotations in: group-step

>From reading Typed Racket's reference, section 2.4 Definitions, I
thought the latter was another way of writing the former.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to