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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 007D17F1DE for ; Fri, 11 Jan 2013 06:47:27 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of siraaj@khandkar.net) identity=pra; client-ip=128.177.27.134; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="siraaj@khandkar.net"; x-sender="siraaj@khandkar.net"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of siraaj@khandkar.net) identity=mailfrom; client-ip=128.177.27.134; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="siraaj@khandkar.net"; x-sender="siraaj@khandkar.net"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@newcavia.khandkar.net) identity=helo; client-ip=128.177.27.134; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="siraaj@khandkar.net"; x-sender="postmaster@newcavia.khandkar.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArsHAMml71CAsRuG/2dsb2JhbABEg0enTJJlFnOCHgEBBAE6NAsFCwsYDSFFEgYTEod1AwkGDK4PA4ZmkD5hA4hgjkaET4pegxM X-IronPort-AV: E=Sophos;i="4.84,449,1355094000"; d="scan'208";a="168075042" Received: from newcavia.khandkar.net ([128.177.27.134]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Jan 2013 06:47:27 +0100 Received: from [10.0.1.31] (pool-108-46-62-235.nycmny.fios.verizon.net [108.46.62.235]) by newcavia.khandkar.net (Postfix) with ESMTPA id 4064B55FF8; Fri, 11 Jan 2013 00:47:26 -0500 (EST) References: <50EF9E2B.1010100@riken.jp> <50EFA29E.6010704@riken.jp> In-Reply-To: <50EFA29E.6010704@riken.jp> Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: Cc: caml-list X-Mailer: iPhone Mail (9B206) From: Siraaj Khandkar Date: Fri, 11 Jan 2013 00:47:24 -0500 To: Francois Berenger Subject: Re: [Caml-list] adding a function to an already existing module On Jan 11, 2013, at 0:26, Francois Berenger wrote: > On 01/11/2013 02:14 PM, Siraaj Khandkar wrote: >> module MyList =3D struct >> include List >>=20 >> let foo l =3D bar l >> end >=20 > Not exactly, because: >=20 > module MyList =3D struct > include List > let expose_length_aux =3D length_aux (* stupid example *) > end >=20 > gives: > Error: Unbound value length_aux >=20 > While length_aux is available to code from list.ml. Oh, I didn't realize you really did mean "everything"! :) Not much you can do if the interface doesn't expose it though, it's kind of= the point. Copying and moding list.ml does seem like the only way to get _= exactly_ what you want then. >=20 >> On Jan 11, 2013, at 0:07, Francois Berenger wrote: >>=20 >>> Hello, >>>=20 >>> Let's say I want to add a function to the List module >>> of the std lib. >>>=20 >>> I'd like to do this without having to change list.ml >>> in the std lib. >>>=20 >>> And, my function need to have access to everything available >>> in list.ml (constructors, type names, etc.). >>>=20 >>> Is this possible and how to do this? >>>=20 >>> For example, I want to create MyList, and this module >>> is the exact List module plus some functions of my own. >>> Then, some of my code would use MyList instead of List. >>>=20 >>> Thanks a lot, >>> F. >>>=20 >>> PS: a full copy-paste of list.ml is considered cheating ;) >>>=20 >>> -- >>> 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 >=20 >=20 > --=20 > 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