caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Deepest Lexically Faithful OCaml Syntax Folds
@ 2013-06-02 17:19 David Sheets
  2013-06-03 20:42 ` [Caml-list] " David Sheets
  0 siblings, 1 reply; 2+ messages in thread
From: David Sheets @ 2013-06-02 17:19 UTC (permalink / raw)
  To: caml-list

Hello World,

I am searching for the "deepest lexically faithful OCaml syntax
catamorphism solution" as the title indicates. What precisely do I
mean by this?

Deepest => most semantically abstract while retaining a map back to syntax
Lexically faithful => injective, accurate, coordinate-tracked tokens
OCaml syntax => a fine conjuring form
Catamorphism => the source annotations occur as reserialization folds
of some kind
Solution => relatively cheap to integrate

Specifically, I am looking for a collection of functions like:

ana ocaml_parse : string -> '_a
cata : '_a -> (('_a -> '_b) * ('_b list -> '_b)) -> '_b
cata' : '_b -> (('_b -> '_c) * ('_c list -> '_c)) -> '_c
.
.
.
serialize : '_c -> ('_c -> string) -> string

where ana's domain is OCaml source code and cata''s range is (possibly
annotated) OCaml source (which may not be valid for reconsumption
without further processing). The multiplication operator's signature
may vary.

such that the weakly polymorphic types above can be mapped over by
adding arbitrary annotations. Any number of catamorphic levels is
acceptable. OCaml 3.12 and 4.x syntax support necessary.

Is the answer some invocation of camlp4, ppx, fan, or compiler
internals? Am I asking for something nonsensical? Have you already
implemented something similar? Do functions equivalent to these exist
in a tool of which you know?

Thank you,

David

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

* [Caml-list] Re: Deepest Lexically Faithful OCaml Syntax Folds
  2013-06-02 17:19 [Caml-list] Deepest Lexically Faithful OCaml Syntax Folds David Sheets
@ 2013-06-03 20:42 ` David Sheets
  0 siblings, 0 replies; 2+ messages in thread
From: David Sheets @ 2013-06-03 20:42 UTC (permalink / raw)
  To: caml-list

I've been told that my attempt at mathematical precision made my
original request difficult to understand. Please, permit me to try
again and forgive my earlier nonsense:

I am looking for a way to annotate OCaml source code while retaining
as much original source code layout as possible.

Specifically, I would like to have access to as much of the semantic
information about the source's components as possible while still
retaining token locations suitable for high-quality serialization.

Why do I want this?

To colorize OCaml source in terminal output.
To annotate OCaml source with XML/HTML.
To expand and rewrite references in OCaml comments with very clean
resulting diffs.

Do you know of an OCaml source preprocessor that has properties which
would make creation of these tools easy? Do you know of tools that
already do some of the above things? Do they do it well?

Thanks,

David

On Sun, Jun 2, 2013 at 6:19 PM, David Sheets <sheets@alum.mit.edu> wrote:
> Hello World,
>
> I am searching for the "deepest lexically faithful OCaml syntax
> catamorphism solution" as the title indicates. What precisely do I
> mean by this?
>
> Deepest => most semantically abstract while retaining a map back to syntax
> Lexically faithful => injective, accurate, coordinate-tracked tokens
> OCaml syntax => a fine conjuring form
> Catamorphism => the source annotations occur as reserialization folds
> of some kind
> Solution => relatively cheap to integrate
>
> Specifically, I am looking for a collection of functions like:
>
> ana ocaml_parse : string -> '_a
> cata : '_a -> (('_a -> '_b) * ('_b list -> '_b)) -> '_b
> cata' : '_b -> (('_b -> '_c) * ('_c list -> '_c)) -> '_c
> .
> .
> .
> serialize : '_c -> ('_c -> string) -> string
>
> where ana's domain is OCaml source code and cata''s range is (possibly
> annotated) OCaml source (which may not be valid for reconsumption
> without further processing). The multiplication operator's signature
> may vary.
>
> such that the weakly polymorphic types above can be mapped over by
> adding arbitrary annotations. Any number of catamorphic levels is
> acceptable. OCaml 3.12 and 4.x syntax support necessary.
>
> Is the answer some invocation of camlp4, ppx, fan, or compiler
> internals? Am I asking for something nonsensical? Have you already
> implemented something similar? Do functions equivalent to these exist
> in a tool of which you know?
>
> Thank you,
>
> David

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

end of thread, other threads:[~2013-06-03 20:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-02 17:19 [Caml-list] Deepest Lexically Faithful OCaml Syntax Folds David Sheets
2013-06-03 20:42 ` [Caml-list] " David Sheets

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).