caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jesper Louis Andersen <jesper.louis.andersen@gmail.com>
To: Viet Le <vietlq85@gmail.com>
Cc: Chet Murthy <murthy.chet@gmail.com>,
	OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] a question about GADTs
Date: Sun, 17 Jun 2018 11:50:56 +0200	[thread overview]
Message-ID: <CAGrdgiWB_00BpWymdLK19Qs=1o0b7J9ia1bir2VfsSPjDWkTTA@mail.gmail.com> (raw)
In-Reply-To: <CAG_8+G7PGqtaGZqsprh+YXx5vejaLrncsFQE5BD3sTCZd0Unsg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]

On Sun, Jun 17, 2018 at 8:39 AM Viet Le <vietlq85@gmail.com> wrote:

>
> I also came across a blog about writing GraphQL server using OCaml & GADT.
> Worth checking out.
>
>
The use there is pretty good. In GraphQL you have a query language in which
fields are bound to functions with arguments. Andreas (the GraphQL author)
takes the graphql schema and uses a GADT to derive the correct type for
said function. In short: the function will have the correct type and schema
changes will require updates on the necessary functions.

But you could argue this is still within the bounds of PL:

GraphQL is a language

Their spec doesn't show it, but it is best implemented as such: have a
statics phase and a dynamics phase, type check vigorously in the statics
phase. Most of what they call "validations" are just standard type checking
hygiene.
Also, the types are moded/polarized in that certain types flows from the
client to the server (which means you shouldn't trust the client) and other
types flows from the server to the client (which means you shouldn't trust
the server).

I have a hunch that there is a small core language within GraphQL best
realized as a lambda-calculus (with added primops corresponding to
execution of user-defined code). But I have yet to try implementing that.

---------

A use I've seen Janes St. doing is to use a GADT as a witness for a given
implementation. This allows the programmer to define a generic
implementation of, say 'a array, and then later specialize the bool array
variant into a bitset on words, or a more advanced data structure where the
bitset is a tree of some kind. The GADT then "selects" for the given
implementation in the code base.

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

[-- Attachment #2: Type: text/html, Size: 2380 bytes --]

      parent reply	other threads:[~2018-06-17  9:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 14:34 Alan Schmitt
2018-06-15 15:21 ` Markus Mottl
2018-06-15 16:34   ` Alan Schmitt
2018-06-17  3:43 ` Chet Murthy
2018-06-17  6:39   ` Viet Le
2018-06-17  6:41     ` Julia Lawall
2018-06-17  9:50     ` Jesper Louis Andersen [this message]

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='CAGrdgiWB_00BpWymdLK19Qs=1o0b7J9ia1bir2VfsSPjDWkTTA@mail.gmail.com' \
    --to=jesper.louis.andersen@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=murthy.chet@gmail.com \
    --cc=vietlq85@gmail.com \
    /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).