Version française
Home     About     Download     Resources     Contact us    
Browse thread
Which syntax to teach ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] Re: Which syntax to teach ?
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