Author Jonathan Chan <jyc@fastmail.fm>
License BSD 2-Clause
Homepage https://bitbucket.org/jyc/ppx_sexp
Issue Tracker https://bitbucket.org/jyc/ppx_sexp/issues
Maintainer Jonathan Chan <jyc@fastmail.fm>
Available ocaml-version >= "4.02.0" & ocaml-version < "4.03.0"
Published Aug 15, 2015
Source [http] http://bitbucket.org/jyc/ppx_sexp/get/0.3.0.tar.gz
Statistics Not installed in the last month.
Edit https://github.com/ocaml/opam-repository/tree/master/packages/ppx_sexp/ppx_sexp.0.3.0/opam

ppx_sexp is a ppx preprocessor for embedding S-expressions in OCaml programs.

For example, this:

[%sexp (define a "hi there!")]

is translated into:

`List [`Symbol "define"; `Symbol "a"; `String "hi there"]

You can unquote, or insert regular OCaml expressions inside of the S-expression that will be evaluated instead of converted to atoms (e.g. List, Symbol) using the [%in ...] syntax:

let a = [%sexp (title "Hello, world!")] in
[%sexp (html
             [%in a])
             (p "Hi there!")))]

When inserting values, you must make sure to contain them in the appropriate polymorphic variant (the names correspond directly to OCaml's AST constant types, with the exception of Bool):

 [%sexp (print [%in `String "S-expressions: abbreviated sexp"])]

The %in syntax is intended to be used for embedding other S-expressions. If you are embedding atoms, there is a streamlined syntax:

 [%sexp (print [%string "S-expressions: sexp"])]

Unquote-splicing is also supported.

No package is dependent