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 907847EE49 for ; Mon, 16 Sep 2013 06:31:36 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of martindemello@gmail.com) identity=pra; client-ip=209.85.212.53; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of martindemello@gmail.com designates 209.85.212.53 as permitted sender) identity=mailfrom; client-ip=209.85.212.53; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; 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-vb0-f53.google.com) identity=helo; client-ip=209.85.212.53; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="postmaster@mail-vb0-f53.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuEBAKiINlLRVdQ1m2dsb2JhbABbhBHAdYESCBYOAQEBAQEGCwsJFCiCJQEBBScZARsdAQMMBgULAwouIQEBEQEFARwGE4dwAQMPnEaMUYMHg2YKGScNZIg8AQUMjHmCOzMHhB4DiTiMWoFpjEGDShgphGwc X-IPAS-Result: AuEBAKiINlLRVdQ1m2dsb2JhbABbhBHAdYESCBYOAQEBAQEGCwsJFCiCJQEBBScZARsdAQMMBgULAwouIQEBEQEFARwGE4dwAQMPnEaMUYMHg2YKGScNZIg8AQUMjHmCOzMHhB4DiTiMWoFpjEGDShgphGwc X-IronPort-AV: E=Sophos;i="4.90,912,1371074400"; d="scan'208";a="32979952" Received: from mail-vb0-f53.google.com ([209.85.212.53]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 16 Sep 2013 06:31:35 +0200 Received: by mail-vb0-f53.google.com with SMTP id i3so2445409vbh.40 for ; Sun, 15 Sep 2013 21:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=SCJlGRrO+qDqtjnv+VzjBstakKgnKqmJjmXm2tjBRxk=; b=qdOWW9kuapfG2yRgmtRGm8KOJz2fJxFKiccV+z6jVjlMzcaVcaXSmnAIy+pkOn2gr5 FShvnxRLys98nmOoSMIZKwJYF7ew3AIznqkwZCs9qtinBncvvGWf8GcqmpS4obMVOFJv Jwos/LTmsnJXma+IM3iw+ZkK1mat9YKLJmyjij5KgSQKGmQ8QsdmR7bhfm5pfDAAqIni fEHaZQ1DOHiekGl+JHGjM/l7kGNBiv5y8HXEzskhP+EPw8B6RsEcAc3BGHOJXMljG7/N vM8HjxTaPLhtGgKOOPlQvKW2KBDZhYDd1Zgoa1HkgufYccNN0IY3ZVoOl5Ux5o/e86rA JXZg== MIME-Version: 1.0 X-Received: by 10.58.146.71 with SMTP id ta7mr4060veb.23.1379305894847; Sun, 15 Sep 2013 21:31:34 -0700 (PDT) Received: by 10.220.162.197 with HTTP; Sun, 15 Sep 2013 21:31:34 -0700 (PDT) In-Reply-To: <87txhlbdna.fsf@golf.niidar.ru> References: <87txhlbdna.fsf@golf.niidar.ru> Date: Sun, 15 Sep 2013 21:31:34 -0700 Message-ID: From: Martin DeMello To: Ivan Gotovchits Cc: "caml-list@inria.fr" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] "subclassing" a char map Ah, thanks, that will do very nicely. I just wanted a type of char map I couldn't insert anything else other than A-Z into, that the typechecker would prevent me from mixing with the regular char map. martin On Sun, Sep 15, 2013 at 9:20 PM, Ivan Gotovchits wrote: > Martin DeMello writes: > >> I have a char multiset defined via >> >> module MultiSet =3D Map.Make(struct type t =3D char let compare =3D comp= are 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 =ABA-Z keys=BB as an abstract type, contained in a module with = 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 > > -- > (__) > (oo) > /------\/ > / | || > * /\---/\ > ~~ ~~ > ...."Have you mooed today?"...