On 07/01/2015 01:13 PM, Neil Toronto wrote:
> There's every chance that Typed Racket's union types, singleton symbol
> types, and occurrence typing will make it fairly easy to type an
> s-expression-based wire protocol; e.g.
> 
>   (define-type Command (List '<command-name> <arg-types> ...)
>   (define-type Commands (Pair 'begin (Listof Command)))
>   (define-predicate valid-commands? Commands)

This is a really neat feature of TR: it can automatically generate a
validator for a type you give it.

Most other languages require you to write parsers and validators by
hand, or using some tool not connected directly to the type system. In
TR, you get to use read for the parsing part, and the
automatically-generated validators to be sure the results inhabit the
type you need.

I only know of one other typed system that does something similar: Alice
ML [1], where pickled values coming off the wire are checked and dropped
into the required type. (If my recollection is correct.)

Tony

[1] https://www.ps.uni-saarland.de/alice/

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to