From: "Milan Stanojević" <milanst@gmail.com>
To: Trevor Smith <trevorsummerssmith@gmail.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] GADTs and JSON
Date: Thu, 21 May 2015 17:59:00 +0100 [thread overview]
Message-ID: <CAKR7PS9U44231AXZLF2WQW=duLGj2HnhVh16KDo0uCyPDWfy3w@mail.gmail.com> (raw)
In-Reply-To: <CAG-KTt_Um5B263zK3M6Y7on62-F0rrkb-1MpcRtMqTH6tLRDjQ@mail.gmail.com>
You must have 'a in the input if you want to return 'a json (at least
a non-empty one). Same way you can't have function unit -> 'a list
that returns a non-empty list.
But it is probably not hard for you to create a witness type and have
that in input.
For example
eg get:(map : map json) -> key:string -> 'a witness -> 'a json option
You get None if key is not there or if it is not of the expected type.
On Thu, May 21, 2015 at 5:42 PM, Trevor Smith
<trevorsummerssmith@gmail.com> wrote:
> Hello,
>
> Is it possible to encode a recursive, heterogenous map and list
> datastructure with GADTs?
>
> I want to encode JSON (there are already a couple of great libraries out
> there so this is kind of an academic question). I would like to have
> functions that can only take a JSON map type, for example to take a json map
> and return a value. The key here is that the map can hold values of type
> int,string and also maps. Is this possible?
>
> eg get : (map : map json) -> key:string -> 'a json
>
> Thank you.
>
> Trevor
next prev parent reply other threads:[~2015-05-21 16:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-21 16:42 Trevor Smith
2015-05-21 16:59 ` Milan Stanojević [this message]
2015-05-21 18:44 ` Rodolphe Lepigre
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='CAKR7PS9U44231AXZLF2WQW=duLGj2HnhVh16KDo0uCyPDWfy3w@mail.gmail.com' \
--to=milanst@gmail.com \
--cc=caml-list@inria.fr \
--cc=trevorsummerssmith@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