On Tue, Aug 12, 2008 at 02:03:46PM -0700, Brighten Godfrey wrote: > I think I see what you're getting at. Is it possible to define > compositionality as follows?:
I think Jon means that you can copy and paste code around and it still works. > "Removing a type annotation from > correct OCaml code results in correct OCaml code." This is mostly correct. However very occasionally it is necessary to help the compiler out by annotating expressions with types. I believe this is because type inference used by OCaml is undecidable. You'll notice this effect more often if you use OCaml's object system. > I would claim that the current syntax (`g.Graph.nodes' in the above > example) is effectively a type annotation that permits the type > inference that `g' is a `Graph.t'. The annoying bit is that you are > required to use every single time you use a record in `g'. You might want to try renaming the Graph module, ie: module G = Graph ... g.G.nodes ... Or if you have control over the module itself, you could also try renaming the fields to make them unique (eg. g_nodes), at which point you can just 'open Graph'. There are different trade-offs to each approach. Rich. -- Richard Jones Red Hat _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs