Skip to content

A simple OCaml ppx filter to support string interpolation like [%str "value of foo is $(foo)"]

License

Notifications You must be signed in to change notification settings

sheijk/ppx_string_interpolate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple string interpolation using OCaml’s ppx extension points API.

How to use

Write [%str “some string”] anywhere a string expression is expected. Use $(name) to insert the value of variable “name” whose types needs to be string. Use $$ to insert an actual dollar character.

let name = "mario" in
print_string [%str "It's a meee, $(name)\n"]

See directory src_test for examples on what to do and not to do.

How to build

  • install OCaml 4.02 (or newer)
  • install opam 1.1.1 (or newer)
  • install dependencies opam install sedlex ppx_tools ppx_deriving
  • make all

Test by running ‘make test’

Todo

  • support arbitrary OCaml expressions inside $(…). Needs to run the OCaml lexer on the string, skip over balanced parenthesis and pass this to OCaml Parse.expression.

Contact

Mail to [email protected] for questions and comments.

About

A simple OCaml ppx filter to support string interpolation like [%str "value of foo is $(foo)"]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published