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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 11E72BC6B for ; Tue, 30 Oct 2007 18:08:25 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEYCJ0fAXQImh2dsb2JhbACOYAIBCAop X-IronPort-AV: E=Sophos;i="4.21,347,1188770400"; d="scan'208";a="18774965" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 30 Oct 2007 18:08:24 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9UH8I5k030731 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 30 Oct 2007 18:08:24 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAJIBJ0fRVYTwkmdsb2JhbACOYAIBAQcCBhMW X-IronPort-AV: E=Sophos;i="4.21,347,1188770400"; d="scan'208";a="3744469" Received: from an-out-0708.google.com ([209.85.132.240]) by mail2-smtp-roc.national.inria.fr with ESMTP; 30 Oct 2007 18:08:23 +0100 Received: by an-out-0708.google.com with SMTP id c36so279246ana for ; Tue, 30 Oct 2007 10:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=FnJ5+KLDH0EpozpxFN0W07iyw7/jZix2vQWqg4b7/B4=; b=i1O71hvAcDsblnDdZ4rgrx7sEA0TR7nYShwi0n9G1tp9UFJIomHqRklpEENcoamtZg/lfn1ZV+BEY7ZfVzP3sFH6ePHarFYqMAO2cCHEH97nsC2VI5BeXbl/0CGYpHmJRPXeaBrRvo8FN6wkKp00EJUTbLvcqbOXemq0G3GrtSc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=Rp4WzP9Ezn8nypEFE7PzlE8tU0NBKqZ2/MJVxdk1jvMpuf2Jc6R2DTpJq3PoP0TR91FVdmgk+lwO8Vc3OkNYTT8VlSizwn1SbWb1Md7NO2RsGI7vkoKe7Ao/PCMu77PiKECFZxyDrp3hnkF2qGVvllWNklJmj+oREC77iEoDPrE= Received: by 10.100.171.10 with SMTP id t10mr343627ane.1193764102990; Tue, 30 Oct 2007 10:08:22 -0700 (PDT) Received: from ?192.168.0.7? ( [69.154.217.112]) by mx.google.com with ESMTPS id c13sm9491897anc.2007.10.30.10.08.19 (version=SSLv3 cipher=RC4-MD5); Tue, 30 Oct 2007 10:08:21 -0700 (PDT) Message-ID: <47276500.3050501@gmail.com> Date: Tue, 30 Oct 2007 12:08:16 -0500 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Brian Hurt Cc: Chung-chieh Shan , 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> <47275E10.4070705@janestcapital.com> In-Reply-To: <47275E10.4070705@janestcapital.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 47276502.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syntax:01 functors:01 haskell:01 functors:01 functor:01 ocaml:01 functor:01 edgar:98 polymorphic:01 wrote:01 wrote:01 partial:01 abstract:01 caml-list:01 functions:01 Brian Hurt wrote: > Chung-chieh Shan wrote: > >> 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. > > and so on. Functors, then, are a way to manipulate modules, in the same > way that functions are a way to manipulate values. > > Brian > > That's more or less how I think of them. Functions can be written with "holes" to fill in with their parameters. In the same way, modules can have these "empty puzzle-spaces" that, once you fit the right kind of puzzle piece (module of the right type), you can plug it in (apply the functor) to get a full module. Sort of like how you can do partial application with functions to get exactly the function you want. i.e. let sum_int = fold_left (+) 0 Functors/generics fill a much bigger hole in other languages, because in Ocaml it's possible to pass each piece of the parameter module to each of the contained functional values, and because of polymorphic functions, we don't need functors to abstract over types as much. I guess you could teach it like extra arguments to every function in your functor, I don't know if that'd help your students. E.