takikawa / sweet-racket

A port of sweet expressions to Racket
http://pkg-build.racket-lang.org/doc/sweet/index.html
Other
47 stars 10 forks source link
racket

Sweet expressions for Racket

This package provides a port of the sweet expression reader, originally written by David Wheeler, to Racket.

To use the package, you have several options.

Note: the check syntax tool does work with this language, but it may fail to activate when you first install it from PLaneT. Changing the #lang line and then trying again should cause the check syntax button to appear.

This package is released under the MIT license under the same terms as the original implementation.


The following is an excerpt from the Scribble manual for this package. The package provides the sweet reader as a language mixin, similar to the at-exp or s-exp modules.

 #lang sweet-exp

To use sweet expressions, supply a #lang line like the following:

#lang sweet-exp racket

printf("Hello")

The third parameter on the #lang line is the base language used by the language mixin. The resulting language will use the bindings from the base language, but support sweet expression syntax. You can provide any language here such as racket, typed/racket, or others.

For example:

#lang sweet-exp typed/racket

define: fact([n : Integer]) : Integer
  if zero?(n)
     1
     {n * fact{n - 1}}

Or alternatively:

#lang sweet-exp lazy

define fibs
  cons 0 cons(1 map(+ fibs cdr(fibs)))

displayln list-ref(fibs 8)

Known issues: quasi-quotation combined with grouping does not behave according to the specification.