[racket] Heads up for TR users: prefix ->

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Fri Feb 14 13:27:31 EST 2014

Hi all,

A heads up for any users writing programs in Typed Racket: we just
recently merged some patches that enable prefix -> types and will be
moving towards making them the default.

If anyone has any feedback about this change, please let us know.

Concretely, this means that the type formerly written as

  (Number -> Number)

will print and parse like this:

  (-> Number Number)

Note that we will still parse the former syntax so there should be no
backwards compatibility issues. A longer example:

  -> map
  - : (All (c a b ...)
        (case->
         (-> (-> a c) (Pairof a (Listof a)) (Pairof c (Listof c)))
         (-> (-> a b ... b c) (Listof a) (Listof b) ... b (Listof c))))

(note that 6.0.0.2 also pretty prints this type)

In addition, we have added another prefix function type constructor ->*
which works like the contract combinator. Example:

  -> regexp-match
  - : (case->
       (->* ((U Regexp String) Path-String)
            (Integer (U Integer False) (U False Output-Port) Bytes)
            (U False (Pairof String (Listof (U False String)))))
       (->* ((U Byte-Regexp Bytes) (U Path-String Bytes Input-Port))
            (Integer (U Integer False) (U False Output-Port) Bytes)
            (U False (Pairof Bytes (Listof (U False Bytes)))))
       (->* ((U Regexp Byte-Regexp String Bytes) (U Bytes Input-Port))
            (Integer (U Integer False) (U False Output-Port) Bytes)
            (U False (Pairof Bytes (Listof (U False Bytes))))))

(Yes, this is still quite dense to read, but compare it to the old
 printed type.)

The new constructor lets you write optional argument function types
concisely.

Cheers,
Asumu

Posted on the users mailing list.