package ppx_sexp
- Overview
- No Docs
You can search for identifiers within the package.
in-package search v0.2.0
ppx_sexp is a ppx preprocessor for embedding S-expressions in OCaml programs.
Install
Dune Dependency
Authors
Maintainers
Sources
ppx_sexp-0.3.0.tar.gz
sha256=df3c7598820d88cbeb7a73f51e4ea50376866d346dd9a2e236d94d89099aee31
md5=afbfb6e6c9eca9032234464703b83588
Description
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
(head
[%in a])
(body
(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.
Published: 15 Aug 2015
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page