Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2007-10-30 (16:38)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] Re: Which syntax to teach ?
Chung-chieh Shan wrote:

>Adrien <> wrote in article <> 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_
>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
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.