caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam
@ 2014-10-26 18:20 Jan Rehders
  2014-10-27 16:01 ` Alain Frisch
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Rehders @ 2014-10-26 18:20 UTC (permalink / raw)
  To: caml-list

Hi,

To get familiar with ppx filters I made a simple filter to produce
strings by interpolation like [%str “value of foobar is $(foobar)”].
It’s loosely based on Peter Zotov's getenv example but demonstrates a
few more things like fixing up source locations and emitting
compilation errors. Find it at
https://github.com/sheijk/ppx_string_interpolate

Some open issues:

= Packaging =
opam/ocamlfind packaging. There are META and opam files plus ocamlfind
based install/uninstall steps. I think I got this mostly right but
currently it does not work. The problem is that after installation
using opam ocamlfind won’t find my package.

I followed the steps from https://opam.ocaml.org/doc/Packaging.html.
After installation I see the META and ppx_string.native files in
~/.opam/4.02.1/lib/ppx_string_interpolate/.. but ‘ocamlfind list’
won’t contain ppx_string_interpolate. I’m not sure how to investigate
this as I can’t find too much documentation about the internals of
ocamlfind/opam (like which files does it expect, where should they be,
etc.). I tried to check with ppx_tools and sedlex to see what I’m
missing but don’t see anything, either. So any hints what might be the
issue here would also be appreciated.

= Using \ instead of $ =
Using Swift style \(foo) instead of $(foo) would be nice but will
produce warnings from the lexer which I can't suppress w/o suppressing
all warnings about invalid escape sequences. Also this requires doing
this from the makefile so every user would have to do it. Is there
some API I’ve missed to suppress specific warnings on the code inside
[%str ..] from ppx filters?

Any feedback is appreciated (and thanks to the people in #ocaml who
already provided some very valuable suggestions!).

Cheers,
Jan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam
  2014-10-26 18:20 [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam Jan Rehders
@ 2014-10-27 16:01 ` Alain Frisch
  2014-10-27 23:36   ` Jan Rehders
  0 siblings, 1 reply; 6+ messages in thread
From: Alain Frisch @ 2014-10-27 16:01 UTC (permalink / raw)
  To: Jan Rehders, caml-list

On 10/26/2014 07:20 PM, Jan Rehders wrote:
> = Using \ instead of $ =
> Using Swift style \(foo) instead of $(foo) would be nice but will
> produce warnings from the lexer which I can't suppress w/o suppressing
> all warnings about invalid escape sequences. Also this requires doing
> this from the makefile so every user would have to do it. Is there
> some API I’ve missed to suppress specific warnings on the code inside
> [%str ..] from ppx filters?

You might want to use the new syntax for string literals:

   {| .... |}

or:

   {id| .... |id}

(for an arbitrary id).  Contrary to regular string literals, OCaml 
doesn't apply any lexing convention to the string contents: what you 
have in the Parsetree is exactly the sequence of bytes from the source 
file.  This allows you to use you own conventions:

    \(foo)

Also, you can map in an exact way between from an index in the string to 
a location in the source code (in a regular string, you cannot 
distinguish \065 from A in the Parsetree, which makes this exact mapping 
impossible).


Combined with an extension node, this would give:

  [%str{| blabla \(x) blabla |}]

-- Alain

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam
  2014-10-27 16:01 ` Alain Frisch
@ 2014-10-27 23:36   ` Jan Rehders
  2014-10-28  8:18     ` Török Edwin
  2014-10-28  9:13     ` Francois Berenger
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Rehders @ 2014-10-27 23:36 UTC (permalink / raw)
  To: Alain Frisch; +Cc: caml-list

Alain: yes, for the new string literals this issue does not exist (and
they are already supported). But I'd like to keep support for regular
strings, too. I guess I could also simply expand something like
{istr|...|istr} but I think transforming anything that isn't in "my"
annotations is a bad idea.

Btw: anyone tried to use this with opam? I still couldn't get
ocamlfind to find the package after installation (see first mail).

On Mon, Oct 27, 2014 at 5:01 PM, Alain Frisch <alain@frisch.fr> wrote:
> On 10/26/2014 07:20 PM, Jan Rehders wrote:
>>
>> = Using \ instead of $ =
>> Using Swift style \(foo) instead of $(foo) would be nice but will
>> produce warnings from the lexer which I can't suppress w/o suppressing
>> all warnings about invalid escape sequences. Also this requires doing
>> this from the makefile so every user would have to do it. Is there
>> some API I’ve missed to suppress specific warnings on the code inside
>> [%str ..] from ppx filters?
>
>
> You might want to use the new syntax for string literals:
>
>   {| .... |}
>
> or:
>
>   {id| .... |id}
>
> (for an arbitrary id).  Contrary to regular string literals, OCaml doesn't
> apply any lexing convention to the string contents: what you have in the
> Parsetree is exactly the sequence of bytes from the source file.  This
> allows you to use you own conventions:
>
>    \(foo)
>
> Also, you can map in an exact way between from an index in the string to a
> location in the source code (in a regular string, you cannot distinguish
> \065 from A in the Parsetree, which makes this exact mapping impossible).
>
>
> Combined with an extension node, this would give:
>
>  [%str{| blabla \(x) blabla |}]
>
> -- Alain

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam
  2014-10-27 23:36   ` Jan Rehders
@ 2014-10-28  8:18     ` Török Edwin
  2014-10-28  9:13     ` Francois Berenger
  1 sibling, 0 replies; 6+ messages in thread
From: Török Edwin @ 2014-10-28  8:18 UTC (permalink / raw)
  To: caml-list

On 10/28/2014 01:36 AM, Jan Rehders wrote:
> Btw: anyone tried to use this with opam? I still couldn't get
> ocamlfind to find the package after installation (see first mail).

Using opam 1.2.0 this worked:
$ opam pin add ppx_string_interpolate https://github.com/sheijk/ppx_string_interpolate
$ ocamlfind list|grep ppx_string
ppx_string_interpolate (version: 0.1)
$ which ocamlfind
/home/edwin/.opam/4.02.1/bin/ocamlfind

You don't have a 'make uninstall' target though so removing failed:
$ opam pin remove ppx_string_interpolate:
### stderr ###
# make: *** No rule to make target 'uninstall'.  Stop.

If it doesn't work for you make sure the 'ocamlfind list' you run is opam's ocamlfind and not the system's
(run eval `opam config env` to be sure).

Best regards,
--Edwin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam
  2014-10-27 23:36   ` Jan Rehders
  2014-10-28  8:18     ` Török Edwin
@ 2014-10-28  9:13     ` Francois Berenger
  2014-10-31 12:49       ` Jan Rehders
  1 sibling, 1 reply; 6+ messages in thread
From: Francois Berenger @ 2014-10-28  9:13 UTC (permalink / raw)
  To: caml-list

On 10/28/2014 12:36 AM, Jan Rehders wrote:
> Alain: yes, for the new string literals this issue does not exist (and
> they are already supported). But I'd like to keep support for regular
> strings, too. I guess I could also simply expand something like
> {istr|...|istr} but I think transforming anything that isn't in "my"
> annotations is a bad idea.
>
> Btw: anyone tried to use this with opam? I still couldn't get
> ocamlfind to find the package after installation (see first mail).

Not sure it will resolve your issue but,
in case you wrote your META file by hand and it is erroneous,
there are tools out there that generate the META file automatically for
a project: oasis, ocamlbuild and obuild, for example.

> On Mon, Oct 27, 2014 at 5:01 PM, Alain Frisch <alain@frisch.fr> wrote:
>> On 10/26/2014 07:20 PM, Jan Rehders wrote:
>>>
>>> = Using \ instead of $ =
>>> Using Swift style \(foo) instead of $(foo) would be nice but will
>>> produce warnings from the lexer which I can't suppress w/o suppressing
>>> all warnings about invalid escape sequences. Also this requires doing
>>> this from the makefile so every user would have to do it. Is there
>>> some API I’ve missed to suppress specific warnings on the code inside
>>> [%str ..] from ppx filters?
>>
>>
>> You might want to use the new syntax for string literals:
>>
>>    {| .... |}
>>
>> or:
>>
>>    {id| .... |id}
>>
>> (for an arbitrary id).  Contrary to regular string literals, OCaml doesn't
>> apply any lexing convention to the string contents: what you have in the
>> Parsetree is exactly the sequence of bytes from the source file.  This
>> allows you to use you own conventions:
>>
>>     \(foo)
>>
>> Also, you can map in an exact way between from an index in the string to a
>> location in the source code (in a regular string, you cannot distinguish
>> \065 from A in the Parsetree, which makes this exact mapping impossible).
>>
>>
>> Combined with an extension node, this would give:
>>
>>   [%str{| blabla \(x) blabla |}]
>>
>> -- Alain
>

-- 
Regards,
Francois.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam
  2014-10-28  9:13     ` Francois Berenger
@ 2014-10-31 12:49       ` Jan Rehders
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Rehders @ 2014-10-31 12:49 UTC (permalink / raw)
  To: caml-list

Fixed the issues with the META file. I can now install and use it with
opam (through opam pin).

Török: This happens for me if I install the package and then run "opam
pin remove ppx_string_interpolate" while it is still installed. It
does not happen if I uninstall first using "opam remove
ppx_string_interpolate" and the "opam pin remove ...". This problem
seems to be specific to my package as it does not happen with
ppx_getenv. It looks like make uninstall gets run, returns
sucessfully, and the opam reports that an error happened. The
.err/.out/.env files get deleted right after that and I'm not sure
what's failing right now.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-10-31 12:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-26 18:20 [Caml-list] Beta release of ppx_string_interpolate, and help needed with ocamlfind/opam Jan Rehders
2014-10-27 16:01 ` Alain Frisch
2014-10-27 23:36   ` Jan Rehders
2014-10-28  8:18     ` Török Edwin
2014-10-28  9:13     ` Francois Berenger
2014-10-31 12:49       ` Jan Rehders

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).