From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id F21237EEBF for ; Fri, 24 Jul 2015 22:57:05 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of edwin+ml-ocaml@etorok.net) identity=pra; client-ip=62.210.252.135; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="edwin+ml-ocaml@etorok.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of edwin+ml-ocaml@etorok.net designates 62.210.252.135 as permitted sender) identity=mailfrom; client-ip=62.210.252.135; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="edwin+ml-ocaml@etorok.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.etorok.net) identity=helo; client-ip=62.210.252.135; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="postmaster@mail.etorok.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A0BQCGpbJV/4f80j5cgxVUaYMjujiFdAECAoFKTAEBAQEBAYELhCQBAQQjHTgCAQ4LGAICBRMDCwICCQMCAQIBRRMIAheIFwm4MXCEa5FIAQaBIoorhDxSF4JSgUONM4c1hHaHRoFFRoNXk0ImgUqCNjsxgksBAQE X-IPAS-Result: A0A0BQCGpbJV/4f80j5cgxVUaYMjujiFdAECAoFKTAEBAQEBAYELhCQBAQQjHTgCAQ4LGAICBRMDCwICCQMCAQIBRRMIAheIFwm4MXCEa5FIAQaBIoorhDxSF4JSgUONM4c1hHaHRoFFRoNXk0ImgUqCNjsxgksBAQE X-IronPort-AV: E=Sophos;i="5.15,540,1432591200"; d="scan'208";a="171556398" Received: from mail.etorok.net ([62.210.252.135]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Jul 2015 22:57:05 +0200 Received: by mail.etorok.net (OpenSMTPD) with ESMTP id ddf48689 for ; Fri, 24 Jul 2015 20:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=etorok.net; h=subject:to :references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=ml; bh=goMcNe4t9CoYaR dFYvxMVAW7qbE=; b=E/9DU2OIyOguZziE74CX3UnI+SIZQ3Mqng3PzbFlCmovSN UwsaV94dbhh5/+Syo3Hy8yxQfCJSP68goaWWzocvZLQZFpCcSMC6iFux5yiUNNsy 3Cz/JU9TbOvhiGHOIwTYUdY14buI473MbGUdcPphd5vgbOQ1d0l9PqJvwkXZk= DomainKey-Signature: a=rsa-sha1; c=simple; d=etorok.net; h=subject:to :references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; q=dns; s=ml; b=kmMXhKGB Em2pRypfEvqJEX0AoLJKuwpY7hnWnqZMDKPoFZdec05ZEN34cPxaGphY4cq+gFSJ hW26ZW8DrT9f5wQ+HRuzWYxPTGZLO53wkSEsnKTI62epzm30MqadirShYJDRlEvV tXlTK+JGgD5unR10A/Keci1Q+bLUK2mJOAs= Received: by mail.etorok.net (OpenSMTPD) with ESMTPSA id 976eaec7 TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO for ; Fri, 24 Jul 2015 20:57:04 +0000 (UTC) To: caml-list@inria.fr References: From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= X-Enigmail-Draft-Status: N1110 Message-ID: <55B2A69F.2060104@etorok.net> Date: Fri, 24 Jul 2015 23:57:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Clever typing for client-server communication? On 07/24/2015 11:25 PM, Jeremy Yallop wrote: > Once you have these types you might write type-level functions to > retrieve the components. Here's a function that retrieves the 'src' > component: > > type 'a src = 's constraint 'a = < src: 's; .. > This is very useful to know, thanks! It'd be interesting to know how you come up with these solutions :) They are easy to understand as you've explained, but I wouldn't have thought of this solution although I guessed there had to be a solution with objects (after reading [1]), and I understand (simple) phantom types and (mostly) understand object types and GADTs by now. Is there some (fundamental) knowledge I'm missing that would allow me to construct solutions to problems like these (if so could you point to some papers, lecture notes or books please), or is it just that I very rarely use objects/GADTs and lack the experience? Best regards, --Edwin [1] http://stackoverflow.com/questions/10779283/when-should-objects-be-used-in-ocaml/10780681#10780681