bloomberg / ppx_string_interpolation Goto Github PK
View Code? Open in Web Editor NEWPPX rewriter that enables string interpolation in OCaml
License: Apache License 2.0
PPX rewriter that enables string interpolation in OCaml
License: Apache License 2.0
Is your feature request related to a problem? Please describe.
When leading spaces are significant, the text must be fully justified to the left of the file to avoid including them:
let ssdp_message =
[%string
{|M-SEARCH * HTTP/1.1
HOST:$group
MAN:ssdp:discover
MX:10
ST:urn:smartspeaker-audio:service:SpeakerGroup:1
|}]
Describe the solution you'd like
A separate extension or a special character (as the pipe character in multiline strings in scala) could be used to indicate the leading space should be removed
let ssdp_message =
[%string.trimmed
{|M-SEARCH * HTTP/1.1
HOST:$group
MAN:ssdp:discover
MX:10
ST:urn:smartspeaker-audio:service:SpeakerGroup:1
|}]
or
let ssdp_message =
[%string
{|M-SEARCH * HTTP/1.1
|HOST:$group
|MAN:ssdp:discover
|MX:10
|ST:urn:smartspeaker-audio:service:SpeakerGroup:1
|}]
Describe the bug
The ppx_string_interpolation
fails to compile with OCaml 4.12.0~alpha3 with the following error message:
# File "src/interpolation_emitter.ml", line 106, characters 35-65:
# 106 | pexp_constant ~loc:Location.none (Pconst_string (joined, None))
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: The constructor Pconst_string expects 3 argument(s),
# but is applied here to 2 argument(s)
To Reproduce
opam switch create 4.12.0~alpha3 --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git
opam repo add alpha git://github.com/kit-ty-kate/opam-alpha-repository.git
opam install ppx_string_interpolation
Expected behavior
opam installs the ppx_string_interpolation
package.
Environment:
Additional context
Here is the full output:
$ opam install ppx_string_interpolation
The following actions will be performed:
β install ppx_string_interpolation 1.0.0
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
[ppx_string_interpolation.1.0.0] found in cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> π«
[ERROR] The compilation of ppx_string_interpolation failed at "/Users/anton/.opam/opam-init/hooks/sandbox.sh build dune build -p ppx_string_interpolation -j 3".
#=== ERROR while compiling ppx_string_interpolation.1.0.0 =====================#
# context 2.0.7 | macos/x86_64 | ocaml-base-compiler.4.12.0~alpha3 | https://opam.ocaml.org#5e8d6622
# path ~/.opam/4.12.0~alpha3/.opam-switch/build/ppx_string_interpolation.1.0.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ppx_string_interpolation -j 3
# exit-code 1
# env-file ~/.opam/log/ppx_string_interpolation-96416-1872ec.env
# output-file ~/.opam/log/ppx_string_interpolation-96416-1872ec.out
### output ###
# 2 | (using fmt 1.1)
# [...]
# Warning: Version 1.1 of integration with automatic formatters is not
# supported until version 1.7 of the dune language.
# Supported versions of this extension in version 1.5 of the dune language:
# - 1.0
# ocamlc src/.ppx_string_interpolation.objs/byte/ppx_string_interpolation__Interpolation_emitter.{cmi,cmo,cmt} (exit 2)
# (cd _build/default && /Users/anton/.opam/4.12.0~alpha3/bin/ocamlc.opt -w -40 -g -bin-annot -I src/.ppx_string_interpolation.objs/byte -I /Users/anton/.opam/4.12.0~alpha3/lib/bytes -I /Users/anton/.opam/4.12.0~alpha3/lib/gen -I /Users/anton/.opam/4.12.0~alpha3/lib/ocaml-compiler-libs/common -I /Users/anton/.opam/4.12.0~alpha3/lib/ocaml-compiler-libs/shadow -I /Users/anton/.opam/4.12.0~alpha3/l[...]
# File "src/interpolation_emitter.ml", line 106, characters 35-65:
# 106 | pexp_constant ~loc:Location.none (Pconst_string (joined, None))
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: The constructor Pconst_string expects 3 argument(s),
# but is applied here to 2 argument(s)
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> π«
ββ The following actions failed
β Ξ» build ppx_string_interpolation 1.0.0
ββ
βΆβ No changes have been performed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.