From: Shayne Fletcher <shayne.fletcher.50@gmail.com>
To: Jeremy Yallop <yallop@gmail.com>
Cc: Andre Nathan <andre@digirati.com.br>,
"caml-list@inria.fr users" <caml-list@inria.fr>
Subject: Re: [Caml-list] Encoding "links" with the type system
Date: Fri, 7 Oct 2016 13:02:52 -0400 [thread overview]
Message-ID: <CAMsAzy-dTEjoiW7ZEjvKj_jJKgk316ch+Z6SAR2syrxOebg=TA@mail.gmail.com> (raw)
In-Reply-To: <CAAxsn=HVX3CY1vq29hLLhHBMPPCmDOwvkjnTH2aUP2ezxhH5ug@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1677 bytes --]
On Wed, Sep 21, 2016 at 6:22 PM, Jeremy Yallop <yallop@gmail.com> wrote:
> I'll describe an interface based on these ideas that maintains the
> properties you stipulate. I'll leave the problem of building an
> implementation that satisfies the interface to you. (In fact, the
> interface is the tricky part and the implementation is straightforward
> if you can treat all the type parameters as phantom.)
>
How's this?
module M : S = struct
type _ sink = { name : string }
type _ source = { name : string }
type _ set = (string * string) list
type ('source, 'sink) link = ('source source * 'sink sink)
type ('sink, 'set) accepts =
| Accepts : ('sink, 'set) accepts
type 'sink fresh_set =
| Fresh_set : {
set : 't set;
accepts : ('sink, 't) accepts;
} -> 'sink fresh_set
let create_set (s : 'sink sink) : 'sink fresh_set =
Fresh_set { set = ([] : 't set);
accepts = (Accepts : ('sink, 't) accepts) }
type ('sink, 'parent) augmented_set =
| Augmented_set : {
set : 't set;
accepts: ('sink, 't) accepts;
cc : 's. ('s, 'parent) accepts -> ('s, 't) accepts
} -> ('sink, 'parent) augmented_set
let insert_link
(l : ('source, 'sink) link)
(s : 't set)
(a : ('sink, 't) accepts) : ('source, 't) augmented_set =
let ({name = src}, {name = dst}) = l in
Augmented_set {
set : 'tt set = (src, dst) :: s;
accepts = (Accepts : ('source, 'tt) accepts);
cc = fun (_ : (_, 't) accepts) -> (Accepts : (_, 't) accepts)
}
end
This melts my brain Jeremy! :)
--
Shayne Fletcher
[-- Attachment #2: Type: text/html, Size: 5339 bytes --]
next prev parent reply other threads:[~2016-10-07 17:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 19:12 Andre Nathan
2016-09-21 22:22 ` Jeremy Yallop
2016-09-22 0:50 ` Andre Nathan
2016-09-30 13:54 ` Gabriel Scherer
2016-10-05 19:46 ` Andre Nathan
2016-10-05 20:15 ` Daniel Bünzli
2016-10-07 17:02 ` Shayne Fletcher [this message]
2016-10-08 21:51 ` Shayne Fletcher
2016-10-11 0:16 ` Jacques Garrigue
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='CAMsAzy-dTEjoiW7ZEjvKj_jJKgk316ch+Z6SAR2syrxOebg=TA@mail.gmail.com' \
--to=shayne.fletcher.50@gmail.com \
--cc=andre@digirati.com.br \
--cc=caml-list@inria.fr \
--cc=yallop@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