[racket] typed/file/md5 not declared as expected

From: Tim K. (tk at crono.co.uk)
Date: Wed Jul 17 02:58:47 EDT 2013

Hello.

Thanks to my complete ignorance I first didn't notice that there's a
typed version of file/md5. So I imported it like this:

(require/typed file/md5
               (md5 (case->
                      ((U Bytes String Input-Port Boolean EOF) -> Bytes)
                      ((U Bytes String Input-Port Boolean EOF) Boolean
                       -> Bytes))))

Parameter-type-wise that's pretty much a direct copy of file/md5's
documentation page, except for the EOF (I really don't remember why I
put that in there...). But eventually I found this list
http://www.ccs.neu.edu/home/samth/adapt/Current_Status.html and file/md5
is in there (as "has been ported"). So I threw away my version and used
that one instead only to find out that it doesn't work with my code.

; calculates the md5 sum of a given file for display
(: calc-md5sum (String -> String))
(define (calc-md5sum fname)
  (define (read-binary-file)
    (read-bytes (file-size fname)))
  (bytes->string/utf-8 (md5 (with-input-from-file
                              fname
                              read-binary-file
                              #:mode 'binary))))

This has worked in plain old Racket and also with my import. Not really
a surprise though because the definition in typed/file/md5 on my system
is:

(require/typed file/md5
               [md5 ((U Bytes Input-Port) -> Bytes)])

What happened to 'binary? Where's the String parameter?
Is this a bug (and if so, is this even the place to report it?) or is
there some special reason why the other options are not there (for
example because my import is just wrong for some cases that I don't
cover)? I'm using Racket version 5.3.4 by the way.

Best regards,
Tim



Posted on the users mailing list.