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 0CF757EE49 for ; Mon, 16 Sep 2013 06:21:06 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.217.172; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of ivg@ieee.org designates 209.85.217.172 as permitted sender) identity=mailfrom; client-ip=209.85.217.172; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; 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-lb0-f172.google.com) identity=helo; client-ip=209.85.217.172; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-lb0-f172.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsABAEyGNlLRVdmsm2dsb2JhbABbhzu9S4EaFg4BAQEBAQYLCwkUKIIlAQEEASMEUgULCxoCBSECAg8BBA0TAQUBIhOHcQMJBgScQYwAiAcNiSaBKYtcgjszB4JpgTUDiTKMYIFpjEGDSkGEUQ X-IPAS-Result: AsABAEyGNlLRVdmsm2dsb2JhbABbhzu9S4EaFg4BAQEBAQYLCwkUKIIlAQEEASMEUgULCxoCBSECAg8BBA0TAQUBIhOHcQMJBgScQYwAiAcNiSaBKYtcgjszB4JpgTUDiTKMYIFpjEGDSkGEUQ X-IronPort-AV: E=Sophos;i="4.90,912,1371074400"; d="scan'208";a="32979182" Received: from mail-lb0-f172.google.com ([209.85.217.172]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 16 Sep 2013 06:21:04 +0200 Received: by mail-lb0-f172.google.com with SMTP id x18so3710682lbi.17 for ; Sun, 15 Sep 2013 21:21:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=6JqSOSnncj+7H1zVtmBJeSuSwAPnpHyfVBcvAe9di7I=; b=Q32g2df7jzW4D/yWG5jsjj8MbzG1RV28sWY+kpBM6SO7AtsUedD1sLzoKgunDDjGRP sdEB94DwD711xRTtd5Ddh+FO9ZXbzIs0HK7gOVfx+TjVFmiuard8vY99no8Xdr3VL/RP a0jnVFxr/i1XH+z7wyjl2dA083Hbng1KPM/MP3SUGpkbIrzFJrHgh0hRV9JnYUekZkir nJqz4MgJzSVL2VehG9UcIpq2ZuX67dC0nLU6Ygz98htHkgXUYfbO4yNeTlQUeMEsagsT YrQFnF7VaMV7Pu3LLJdx43gkjPIbKl558g9cIQP43cGja6H7qyDe1XWRbPGyKelE8fZD IGWg== X-Gm-Message-State: ALoCoQltYTSgCwkIiAkwP346sByk24JsZFAPNjx5U1qf8qsBNKg+K1HtHthUcVpWkfgZTFy2JGE/ X-Received: by 10.152.18.228 with SMTP id z4mr341031lad.26.1379305264407; Sun, 15 Sep 2013 21:21:04 -0700 (PDT) Received: from golf.niidar.ru.niidar.ru ([109.188.127.116]) by mx.google.com with ESMTPSA id oc1sm11856653lbb.3.1969.12.31.16.00.00 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Sun, 15 Sep 2013 21:21:04 -0700 (PDT) From: Ivan Gotovchits To: Martin DeMello Cc: "caml-list\@inria.fr" References: Date: Mon, 16 Sep 2013 08:20:57 +0400 In-Reply-To: (Martin DeMello's message of "Sun, 15 Sep 2013 15:29:25 -0700") Message-ID: <87txhlbdna.fsf@golf.niidar.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] "subclassing" a char map Martin DeMello writes: > I have a char multiset defined via > > module MultiSet =3D Map.Make(struct type t =3D char let compare =3D compa= re end) > > Now I would like to split off a distinct type that can only contain > A-Z as keys. What's the best way to do this? > > martin Not sure, that I correctly understood your needs... but you can implement =C2=ABA-Z keys=C2=BB as an abstract type, contained in a module w= ith the following signature: module type Caps =3D sig type t val create: char -> t option val compare: t -> t -> int val project: t -> char end Next, you can instatiate a Map from abstract type Cap.t to 'a: module CapMap =3D Map.Make(Caps) where Caps is an implementation, conforming to the signature Caps. For example like this: module Caps : Caps =3D struct type t =3D char let create =3D function | 'A'..'Z' as ch -> Some ch | otherwise -> None let compare =3D compare let project ch =3D ch end --=20 (__)=20 (oo)=20 /------\/=20 / | ||=20=20=20 * /\---/\=20 ~~ ~~=20=20=20 ...."Have you mooed today?"...