caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Matej Košík" <mail@matej-kosik.net>
To: OCaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] What is the idiomatic way to invoke Merlin (from Ocaml)?
Date: Thu, 22 Mar 2018 09:54:02 +0100	[thread overview]
Message-ID: <144608f9-c58d-339e-d29c-93979ab916b1@matej-kosik.net> (raw)

Hi,

If I have an Ocaml program that would like to take advantage of the services that Merlin provides.

What is the idiomatic/recommended way to interact with it from inside of an Ocaml program?

At the moment, I have a code that works

 (I execute "ocamlmerlin" binary;
  I gather its stdandard output;
  I use "yojson" to parse this output;
  I traverse the JSON soup and find the pieces I want)

but after finishing it, I is "unpretty".

What should I do to make it more "pretty"?

Is it absolutely necessary for me to deal with JSON instead of native Ocaml?
Should I investigate a more seamless Ocaml/JSON mapping?
(JSON may make sense in many scenarios, but in my cases, these are just two Ocaml programs talking).

Or is there a way to cut JSON completely out of the interation and let my program talk to Merlin in Ocaml (and get back Ocaml values)?

Concretely, if I have a question:

  Here is the file; here is the position of an identifier; where is it defined?

I would get (e.g.) value of type (e.g.) "Lexing.position" instead of:

  {
      "class": "return",
      "notifications": [],
      "timing": {
          "error": 0.0,
          "ppx": 0.0,
          "query": 0.0,
          "reader": 0.0,
          "total": 0.0,
          "typer": 0.0
      },
      "value": {
          "file": "/some/absolute/path/to/test.ml",
          "pos": {
              "col": 0,
              "line": 2
          }
      }
  }

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

                 reply	other threads:[~2018-03-22  8:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=144608f9-c58d-339e-d29c-93979ab916b1@matej-kosik.net \
    --to=mail@matej-kosik.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).