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 29FCF7F8F3 for ; Sun, 25 May 2014 12:46:03 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.220.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.220.170 as permitted sender) identity=mailfrom; client-ip=209.85.220.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@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-vc0-f170.google.com) identity=helo; client-ip=209.85.220.170; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-vc0-f170.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAD7JgVPRVdyqlGdsb2JhbABZDoNLWIJqqUOVVQF7CBYOAQEBAQcLCwkSKoIlAQEBBBIRHQEbEgsBAwwGBQsNAgIJHQICIgERAQUBChIGExIQiAsBAxENpwNqiyeBcoMNmEsKGScDCmSFNhEBBQyBHow7OjMHgnWBSwSEXgWVEIE9j3kYKYQoQjsvAQ X-IPAS-Result: ApMBAD7JgVPRVdyqlGdsb2JhbABZDoNLWIJqqUOVVQF7CBYOAQEBAQcLCwkSKoIlAQEBBBIRHQEbEgsBAwwGBQsNAgIJHQICIgERAQUBChIGExIQiAsBAxENpwNqiyeBcoMNmEsKGScDCmSFNhEBBQyBHow7OjMHgnWBSwSEXgWVEIE9j3kYKYQoQjsvAQ X-IronPort-AV: E=Sophos;i="4.98,905,1392159600"; d="scan'208";a="76076645" Received: from mail-vc0-f170.google.com ([209.85.220.170]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 May 2014 12:46:02 +0200 Received: by mail-vc0-f170.google.com with SMTP id lf12so8075979vcb.15 for ; Sun, 25 May 2014 03:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=I47r24k2ARqhhXhanC5xceNR8jF+x2+VGC6wpoBuQvc=; b=iv0No8o0g52UdlaEUFuUSkGiovRS/31/XXX35ROvtGbiVnh3jS5vgxcKzU4SS8o+x+ KSZ5OVUt+swnL+tZfwufKuyQKv8lHIEIooAD3hKnR9ze0U1oEwv86mP3E8ro7hmELNXv N9AiZatYS1RZieqfgGi0MoFm8QzGX+3BYZDtWHVgDyVKx66HH9NayW1Cu7d0e7ioclpl OStwUjTBwfHBaTI5YcO2kgvAdF9uFuhRI0OzrqG+P9kYnUDMZv1cLHoODJZq4JCyPLNA 3R5C79rEyIKbUlrSQPrWuuUOOuhrODlQIriDvf+V3P32ppNr9rznfOfeMYrVJoPLzNRL Yj7g== X-Received: by 10.52.255.65 with SMTP id ao1mr694081vdd.43.1401014761188; Sun, 25 May 2014 03:46:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.90.227 with HTTP; Sun, 25 May 2014 03:45:21 -0700 (PDT) In-Reply-To: <52C51721-8564-472C-AA7A-2ABE66C4D809@my.bristol.ac.uk> References: <52C51721-8564-472C-AA7A-2ABE66C4D809@my.bristol.ac.uk> From: Gabriel Scherer Date: Sun, 25 May 2014 12:45:21 +0200 Message-ID: To: Ollie Frolovs Cc: caml users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Modules and record fields let open Solarized in Sdl.set_render_draw_color ren orange.r orange.g orange.b 0xff Solarized.(Sdl.set_render_draw_color ren orange.r orange.g orange.b 0xff) let module S =3D Solarized in Sdl.set_render_draw_color ren S.(orange.r) S.(orange.g) S.(orange.b) 0xff let apply f color =3D Solarized.(f color.r color.g color.b) in apply (Sdl.set_render_draw_color ren) orange 0xff On Sun, May 25, 2014 at 12:30 PM, Ollie Frolovs wrote: > Hello > > I was using some colours in my program and thought that it would be a goo= d idea to put colour constants into a separate module. > > module Solarized =3D struct > type colour =3D {r:int; g:int; b:int} > > let base03 =3D {r=3D0x00; g=3D0x2b; b=3D0x36} > let orange =3D {r=3D0xcb; g=3D0x4b; b=3D0x16} > (* etc etc *) > end > > I need three separate RGB components because I=E2=80=99m using an API whi= ch needs them separately, rather than in some pre-packed way. > > I was planning to use the module like this > > let module S =3D Solarized in > Sdl.set_render_draw_color ren S.orange.r S.orange.g S.orange.b 0xff > (* etc etc *) > > that is, to locally open the module and refer to the colours and their su= bcomponent. > > But this does not work. It appears for some reason that I have to address= the subcomponents as > > Solarized.orange.Solarized.r > > which defeats the purpose! Is there any other way to achieve my goal? > > Best regards > > Ollie > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs