From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 9ABC0BC6B for ; Tue, 30 Oct 2007 17:38:48 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAAP7JkfAXQInh2dsb2JhbACCPTWLbQIBCAop X-IronPort-AV: E=Sophos;i="4.21,347,1188770400"; d="scan'208,217";a="3843502" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 Oct 2007 17:38:48 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9UGclht032494 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 30 Oct 2007 17:38:48 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4FAE76JkdCm3xr/2dsb2JhbACCPTU X-IronPort-AV: E=Sophos;i="4.21,347,1188770400"; d="scan'208,217";a="5289266" Received: from unknown (HELO smtp.janestcapital.com) ([66.155.124.107]) by mail3-smtp-sop.national.inria.fr with ESMTP; 30 Oct 2007 17:38:47 +0100 Received: from [172.25.129.161] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id AE1105C0; Tue, 30 Oct 2007 12:38:41 -0400 Message-ID: <47275E10.4070705@janestcapital.com> Date: Tue, 30 Oct 2007 12:38:40 -0400 From: Brian Hurt User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Chung-chieh Shan Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Which syntax to teach ? References: <1193225773.3612.27.camel@Blefuscu> <471F7F7B.9040905@fmf.uni-lj.si> <666572260710241205x19edbd4ar840811b1d7a7315f@mail.gmail.com> <5i2kv4-hmj.ln1@mantle.rutgers.edu> In-Reply-To: <5i2kv4-hmj.ln1@mantle.rutgers.edu> Content-Type: multipart/alternative; boundary="------------080207010106020200000508" X-Miltered: at concorde with ID 47275E17.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syntax:01 gmane:01 functors:01 mli:01 functors:01 haskell:01 foo:01 sig:01 foo:01 struct:01 baz:01 quux:01 struct:01 baz:01 quux:01 This is a multi-part message in MIME format. --------------080207010106020200000508 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Chung-chieh Shan wrote: >Adrien wrote in article <666572260710241205x19edbd4ar840811b1d7a7315f@mail.gmail.com> in gmane.comp.lang.caml.inria: > > >>>7. They easily understand how the standard library is used (but not the >>>functors), the open statement, the fact that a program may be in several >>>.ml files. The .mli files are a bit more mysterious. Functors are _very_ >>>mysterious. >>> >>> > >Any tips on how (and perhaps how not) to teach functors? I'm using a >Haskell equivalent of functors (namely constructor classes) in an AI >class (!) and they seem to be mysterious. It didn't seem to work to >explain the Java/C# code that I would like to write (but can't, because >these languages have no interface _on_ generics (as opposed to generic >interfaces)). > > > Not sure how well this would work, but my idea would be to map the concepts onto the standard code concepts. For example, module type Foo = sig ... end;; maps to: type foo = ...;; module Foo = struct ... end;; maps to: let foo = ...;; module Foo(Bar: Baz) : Quux = struct ... end;; maps to: let foo (bar: baz) : quux = ...;; and so on. Functors, then, are a way to manipulate modules, in the same way that functions are a way to manipulate values. Brian --------------080207010106020200000508 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Chung-chieh Shan wrote:
Adrien <camaradetux@gmail.com> wrote in article <666572260710241205x19edbd4ar840811b1d7a7315f@mail.gmail.com> in gmane.comp.lang.caml.inria:
  
7. They easily understand how the standard library is used (but not the
functors), the open statement, the fact that a program may be in several
.ml files. The .mli files are a bit more mysterious. Functors are _very_
mysterious.
      

Any tips on how (and perhaps how not) to teach functors?  I'm using a
Haskell equivalent of functors (namely constructor classes) in an AI
class (!) and they seem to be mysterious.  It didn't seem to work to
explain the Java/C# code that I would like to write (but can't, because
these languages have no interface _on_ generics (as opposed to generic
interfaces)).

  
Not sure how well this would work, but my idea would be to map the concepts onto the standard code concepts.

For example,
module type Foo = sig ... end;;
maps to:
type foo = ...;;

module Foo = struct ... end;;
maps to:
let foo = ..;;

module Foo(Bar: Baz) : Quux = struct ... end;;
maps to:
let foo (bar: baz) : quux = ...;;

and so on.  Functors, then, are a way to manipulate modules, in the same way that functions are a way to manipulate values.

Brian

--------------080207010106020200000508--