[racket] Local form in typed racket
As so often happens when one is forced to type out a question in real
words, shortly after sending the previous email, I was able to answer my
own question.
the result:
(: make-random-emetype-list (Range -> (Listof EmeType)))
(define (make-random-emetype-list range )
(letrec: ([lower : Integer (Range-lower range)]
[upper : Integer (Range-upper range)]
[how-many : Integer (random-integer lower upper)]
[bld-lst : (Integer (Listof EmeType) -> (Listof EmeType))
(lambda: ([remaining : Integer] [lst : (Listof EmeType)])
(cond [(< remaining 1 ) lst]
[else (bld-lst (- remaining 1) (cons (new-emetype) lst))]))])
(bld-lst how-many '())))
Thanks!
On Sat, Feb 9, 2013 at 6:56 PM, Ben Dean <benjamin.dean at aya.yale.edu> wrote:
> It would be very helpful to me to have an example of the "local" form for
> defining an internal function in typed racket. I've read and re-read the
> docs and can't seem to figure it out from the syntax definition.
>
> Here's what i've been trying:
>
> (: make-random-emetype-list (Range -> (Listof EmeType)))
> (define (make-random-emetype-list range )
> (local ([define how-many-types (random-integer (Range-lower range)
> (Range-upper range))]
> [define: (bld-lst lst remaining) : ((Listof EmeType) Integer
> -> (Listof EmeType))
> (cond [(< remaining 1) lst]
> [else (bld-lst (cons (new-emetype) lst) (- remaining
> 1))])])
> (bld-lst '() how-many-types)))
>
> but I get an error on this: "define:: expected the identifier `:' in:
> ((Listof EmeType) Integer -> (Listof EmeType))"
>
> Thanks for the help!
>
> Ben
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130209/d983629e/attachment.html>