From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pA9FfS0V027045 for ; Wed, 9 Nov 2011 16:41:28 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AigEAOyeuk7RVdivk2dsb2JhbAAVLRaCN4Iwo3qBHwgiAQEBAQkJCwkUBCGBcgEBAQQSAg8EGQEbHAIDDAYFCw0JFgsCAgkDAgECARERAQUBHBMIAQEeh2iKIZAaCosaR4JjhWM9iHACBQqIX4EWBIgMjBmGZIZhPYJFgUk X-IronPort-AV: E=Sophos;i="4.69,484,1315173600"; d="scan'208,217";a="117909797" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Nov 2011 16:41:18 +0100 Received: by qyc1 with SMTP id 1so5717972qyc.6 for ; Wed, 09 Nov 2011 07:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=nZiwrzhvzvJ0Q42+ivGWZlfqGyir27La52856KkWrH8=; b=nahgBLvWpBULDqvn0RZCFFH1xyq/Qd5MipYhVigpqRQykDRATwVBTt6lIARjLEgxlS o5IHItRzZp+/LX+Saime3lOB4SL64o+eGqCiAP/4catEtuspdb02l7oComqS/aRj4Pyb bhTKrtQomAenM9DJXG7UU6rRt0gLL79ww6P64= Received: by 10.224.211.66 with SMTP id gn2mr2510834qab.14.1320853276891; Wed, 09 Nov 2011 07:41:16 -0800 (PST) Received: from page.encs.concordia.ca (page.encs.concordia.ca. [132.205.221.212]) by mx.google.com with ESMTPS id du5sm5336235qab.14.2011.11.09.07.41.15 (version=SSLv3 cipher=OTHER); Wed, 09 Nov 2011 07:41:16 -0800 (PST) Message-ID: <4EBA9F1B.3060801@gmail.com> Date: Wed, 09 Nov 2011 10:41:15 -0500 From: Vincent Aravantinos User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Red Hat/3.1.15-1.el6_1 Thunderbird/3.1.15 MIME-Version: 1.0 To: caml-list@inria.fr References: <1320823798.6647.2.camel@Nokia-N900> In-Reply-To: <1320823798.6647.2.camel@Nokia-N900> Content-Type: multipart/alternative; boundary="------------000205080008030302080206" Subject: Re: [Caml-list] Include question This is a multi-part message in MIME format. --------------000205080008030302080206 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/09/2011 02:29 AM, Cedric Cellier wrote: > For some reasons though, despite functors being one of the greatest > strength of the language, we do seam shy to use, recommand or brag > about them. I wonder if this is due to the lack of proper documentation ? I don't think there is a lack of proper documentation: it is introduced right away in the "tutorial" part of the Ocaml manual (Part I), it is described in the language description (Part II) and there are a couple of examples in the std lib (Part IV). What do you think it lacks to be properly documented (at least w.r.t other features of Ocaml)? I actually wonder if they just *look* too complicated? Maybe because they are verbose? Each time you define a functor you also have to give the signature of its argument, which, compared to a simple "include" can look overkilling. Concretely: module A = struct ... end module B = struct include A ... end VS module A = struct ... end module type B_INPUT = sig ... (can be big) end module Make_B (X:B_INPUT) = struct ... end For one module that's fine, but when you start having lots of modules and intricate interactions between them, that can start to be a pain in the ass. In addition, this include->functor switch happens quite often when you have sources that were not written in the first place with functors in mind, so this is not an uncommon situation. I think personally that this verbosity is actually a good thing because it forces to give some documentation which is particularly needed when many modules are interacting. But then this documentation argument is a bit contradictory with what we sell to beginners when they learn Ocaml: "Ocaml is great because it has type inference, this removes verbosity!"... -- Vincent Aravantinos Postdoctoral Fellow, Concordia University, Hardware Verification Group http://users.encs.concordia.ca/~vincent --------------000205080008030302080206 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 11/09/2011 02:29 AM, Cedric Cellier wrote:
For some reasons though, despite functors being one of the greatest strength of the language, we do seam shy to use, recommand or brag about them. I wonder if this is due to the lack of proper documentation ?
I don't think there is a lack of proper documentation: it is introduced right away in the "tutorial" part of the Ocaml manual (Part I), it is described in the language description (Part II) and there are a couple of examples in the std lib (Part IV). What do you think it lacks to be properly documented (at least w.r.t other features of Ocaml)?

I actually wonder if they just *look* too complicated? Maybe because they are verbose?
Each time you define a functor you also have to give the signature of its argument, which, compared to a simple "include" can look overkilling.
Concretely:

module A = struct
  ...
end

module B = struct
  include A
  ...
end

VS

module A = struct
  ...
end

module type B_INPUT = sig
  ... (can be big)
end

module Make_B (X:B_INPUT) = struct
  ...
end

For one module that's fine, but when you start having lots of modules and intricate interactions between them, that can start to be a pain in the ass.
In addition, this include->functor switch happens quite often when you have sources that were not written in the first place with functors in mind, so this is not an uncommon situation.

I think personally that this verbosity is actually a good thing because it forces to give some documentation which is particularly needed when many modules are interacting.
But then this documentation argument is a bit contradictory with what we sell to beginners when they learn Ocaml: "Ocaml is great because it has type inference, this removes verbosity!"...

-- 
Vincent Aravantinos
Postdoctoral Fellow, Concordia University, Hardware Verification Group
http://users.encs.concordia.ca/~vincent

--------------000205080008030302080206--