[racket-dev] typed/scheme n00b question

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Sep 5 17:30:04 EDT 2010

On Sep  5, Hari Prashanth wrote:
> Since secs and and fail-thunk are optional, we need to use case
> lambda for writhing the type.
> (require/typed racket/base
>                [file-or-directory-modify-seconds 
>                 (case-lambda
>                   [String -> (U Integer Void exn:fail:filesystem)]
>                   [String (-> exn:fail:filesystem) -> (U Integer Void exn:fail:filesystem)]
>                   [String (Option Integer) (-> exn:fail:filesystem) 
>                           -> 
>                           (U Integer Void exn:fail:filesystem)])])
> * If we do not have exn:fail:filesystem, it will raise a
>   contract-broken error when fail-thunk raises an exception. So I
>   added exn:fail:filesystem.
> So how can I have the exception and not the contract error?

Raising a value is not returning it -- this works fine:

  (: foo : Integer -> Integer)
  (define (foo x) (raise "meh"))
  (foo 123)

I think that this is the type for `file-or-directory-modify-seconds':

    [String -> Exact-Nonnegative-Integer]
    [String (Option Exact-Nonnegative-Integer)
            -> (U Exact-Nonnegative-Integer Void)]
    [String (Option Exact-Nonnegative-Integer) (-> Any)
            -> Any])

(TR documentation bug: the examples have lots of `*-Fixnum' types, but
they're not documented.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.