Typed Scheme

Intro

http://docs.racket-lang.org/ts-guide/quick.html

Types

Simple types

Examples:
Int32
System.Collections.ArrayList
Byte[]

Procedures

Examples:
(Int32 -> Int32)
(-> Int32)
(Int32 -> (-> Int32))

Generic types

Examples:
(Action Int32)
(KeyValuePair Int32 String)

Syntax Forms

  • type and return-type refer to type definitions described above
  • var, arg and name are identifiers
  • : return-type is optional in all cases, and defaults to Object in that case

:

(: var type)

The : form allows one to define a type contract for a future declared variable binding.
This is used in conjunction with define:. See below.

define:

(define: var value)
(define: var : type value)
(define: (name arg ...) body ...+)
(define: (name (arg : type) ...) : return-type body ...+)

lambda:

(lambda: ((var : type) ...) : return-type body ...+)

let:

(let: ((var : type value) ...) : return-type body ...+)
(let: name ((var : type value) ...) : return-type body ...+)

let*:

(let*: ((var : type value) ...) : return-type body ...+)

letrec:

(letrec: ((var : type value) ...) : return-type body ...+)

letrec*:

(letrec*: ((var : type value) ...) : return-type body ...+)

struct:

(struct: name ((var : type) ...))

Benchmarks

fib

ackerman

Future work

more generic macros

accept some scheme types as type

Last edited Nov 26, 2011 at 12:23 PM by leppie, version 7