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 C93867EE5B for ; Thu, 15 May 2014 21:24:24 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of pjfrey@sympatico.ca) identity=pra; client-ip=65.55.116.23; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="pjfrey@sympatico.ca"; x-sender="pjfrey@sympatico.ca"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of pjfrey@sympatico.ca designates 65.55.116.23 as permitted sender) identity=mailfrom; client-ip=65.55.116.23; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="pjfrey@sympatico.ca"; x-sender="pjfrey@sympatico.ca"; 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@blu0-omc1-s12.blu0.hotmail.com) identity=helo; client-ip=65.55.116.23; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="pjfrey@sympatico.ca"; x-sender="postmaster@blu0-omc1-s12.blu0.hotmail.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnQBACUTdVNBN3QXjmdsb2JhbABZhxXCbVwWDgEBAQEHCwsJEymCTwSBBwImAm+IRJ0mjyKkXxeBKo1Bgl82gRUEkzSMbBqPfQ X-IPAS-Result: AnQBACUTdVNBN3QXjmdsb2JhbABZhxXCbVwWDgEBAQEHCwsJEymCTwSBBwImAm+IRJ0mjyKkXxeBKo1Bgl82gRUEkzSMbBqPfQ X-IronPort-AV: E=Sophos;i="4.97,1061,1389740400"; d="scan'208";a="73936423" Received: from blu0-omc1-s12.blu0.hotmail.com ([65.55.116.23]) by mail2-smtp-roc.national.inria.fr with ESMTP; 15 May 2014 21:24:24 +0200 Received: from BLU0-SMTP8 ([65.55.116.8]) by blu0-omc1-s12.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 15 May 2014 12:24:23 -0700 X-TMN: [WiL5EcRzUOPWWU12I40OuixTgnvVP7eV] X-Originating-Email: [pjfrey@sympatico.ca] Message-ID: Received: from [192.168.2.11] ([70.27.0.49]) by BLU0-SMTP8.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 15 May 2014 12:24:21 -0700 From: Peter Frey To: caml-list@inria.fr Date: Thu, 15 May 2014 15:24:20 -0400 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-OriginalArrivalTime: 15 May 2014 19:24:21.0801 (UTC) FILETIME=[462E1990:01CF7073] Subject: [Caml-list] Unifying buildt-in types with polymorphic types (* In the code below I have 3 fragments of streams, based on a cons cell; another on an array and, finally, the third is based on a string. I need all streams to have the same signature 'StreamOps'. This works fine for a stream where 'a t is a true polymorphic value but fails for module StmStr at the bottom of the code sample; giving: ... Values do not match: val head : int * 'a cursor -> char is not included in val head : 'a t -> 'a I don't know if I run afoul of a form of narrowing; or if this is some sort of limitation with respect to unboxed types. Any help would be greatly appreciated. Peter Frey *) module type StreamOps = sig type 'a t val head : 'a t -> 'a end module LazyStream : StreamOps = struct type 'a t = Cons of 'a * 'a t Lazy.t let head (Cons (h, _)) = h end module StmLzy = (LazyStream:StreamOps with type 'a t = 'a LazyStream.t) module MakeEltAry = functor(S:sig include module type of Array end) -> struct type 'a cursor = { ofs: int; lim: int; data: 'a array } and 'a t = int * 'a cursor let get s i = S.get s.data i let head (i, s) = get s i end module EltAry = MakeEltAry(Array) module StmAry = (EltAry:StreamOps with type 'a t = 'a EltAry.t) module MakeEltStr = functor(S:sig include module type of String end) -> struct type 'a cursor = { ofs: int; lim: int; data: string } and 'a t = int * 'a cursor let get s i = S.get s.data i let head (i, s) = get s i end module EltStr = MakeEltStr(String) module StmStr = (EltStr:StreamOps with type 'a t = 'a EltStr.t)