Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to use Set Datatype
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: William Lovas <wlovas@s...>
Subject: Re: [Caml-list] How to use Set Datatype
On Sun, Dec 12, 2004 at 11:05:42AM +1100, skaller wrote:
> On Sun, 2004-12-12 at 08:12, Brian Hurt wrote:
> > On Fri, 10 Dec 2004, Micha wrote:
> 
> > Another thing- longtime Ocaml programmers tend to inline their structure 
> > definitions.  
> 
> Why? Because binding implicitly by name is basically bogus?

What do you mean by bogus?  And what do you mean by "binding implicitly by
name"?

I think experienced O'Caml programmers simply prefer to save the step of
binding, especially if module you're passing as the argument to a functor
is never used elsewhere.

> So you write
> 
> 	Set.Make(struct let compare=String.compare ...
> 
> because the name in the functor 'compare' only agrees
> accidentally. The anonymous struct there seems general,
> and at least exposes explicitly the bindings.

There's nothing "accidental" about it -- there is a very precise sense in
which some modules are appropriate as input to the Set.Make functor, namely
that they have the signature Set.OrderedType.  This is just as precise as
saying that 3 is appropriate as an argument to (+) while "hello" is not.

O'Caml's module system is not some arbitrary hack -- it has a very rich and
elegant type theoretic foundation.

William