[racket] Problems with Typed Racket

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sat Apr 9 18:24:51 EDT 2011

On Sat, Apr 9, 2011 at 5:50 PM, Renzo Orsini <renzo.orsini at gmail.com> wrote:
> I was trying Typed Racket for the first time.
>
> when I do "Check Syntax" on the following function (which in a (untyped) Racket program works correctly) (I simplified the real function):
>
> #lang typed/racket
>
> (: elaborate (String String -> Any))
> (define (elaborate in-path-name out-path-name)
>  (let ([out-path (string->path out-path-name)])
>        (call-with-output-file out-path #:exists 'replace
>          (lambda(out-file)
>            (list out-file)))))
>
> the following error message is shown: "for: expected a sequence for (v r), got something else: #f"

This seems to be a bug in Typed Racket.

> If I omit #:exists 'replace
> then the message becomes (notes that in the reference manual it is said that call-with-output file expects a path as first parameter):
>
> <unsaved editor>:6:8: Type Checker: Polymorphic function call-with-output-file could not be applied to arguments:
> Argument 1:
>  Expected: String
>  Given:    Path
> Argument 2:
>  Expected: (Output-Port -> a)
>  Given:    (Any -> (List Any))
>
> Result type:     a
> Expected result: Any
>  in: (call-with-output-file out-path (lambda (out-file) (list out-file)))

You need to annotate your `lambda' with a type for `out-file'.  See
`lambda:' in the documentation.
-- 
sam th
samth at ccs.neu.edu



Posted on the users mailing list.