Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] OCaml popularity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ville-Pertti Keinonen <will@e...>
Subject: Re: Module recursion (Was Re: [Caml-list] Re: Haskell-like syntax)
> I think that two records that refer to each other belong in the same 
> module :-)

That's a pretty strong generalization.

My example doesn't involve only records specifically, but I think it is 
worth consideration.  Note that this is based on my experiences while 
writing my first OCaml program, I have only been learning OCaml over 
the past couple of months in what little spare time I have, so it is 
entirely possible that there are better solutions available that I've 
missed.

I've implemented a Scheme interpreter in OCaml (R5RS, including the 
full tower of number types, continuations, dynamic extents and hygienic 
macros, all implemented in OCaml with no Scheme library dependencies).  
OCaml was very well suited for this, but I thought it was annoying that 
I had to declare most of the types used in one file.

IMO the only thing that should be visible throughout the program (and 
possible extensions) is the sum type of Scheme values/expressions but 
that wasn't reasonably possible.

I would've wanted to make many of the specific types (pre-analyzed code 
in procedures, scopes of lexical bindings, dynamic extent records etc.) 
abstract, but couldn't.  I could've made many of the types themselves 
abstract, since every operation relying on their specific content was 
isolated to a few functions, but the functions operating on those types 
require Scheme values as inputs and/or outputs, so that would've caused 
circular references between .mlis. (A notable exception was ports, 
which could be abstract and implemented without the need for knowledge 
of Scheme values)

Additionally (and mostly unrelated to the above), I think that cases 
where there are a limited set of functions operating on an abstract 
type defined within a module could be more permissive.  For an abstract 
type ('a, 'b) t of mappings from 'a to 'b, as long as no function 
operating on ('a, 'b) t returns 'a or accepts as an argument any 
function with an input of type 'a, it should be possible to create an 
instance of ('a, 'b) t where 'a is [> ] - it's possible to have such a 
variable, but (if I understand correctly - and I hope I do, because 
otherwise OCaml is broken) not as a member of an (unparametrized) 
record or object.

I realize that this is a non-trivial wish, though, since it would 
require an analysis of what you can do with a type as well as a new 
implementation of polymorphic variants without the possibility of hash 
collisions.

Still, I think that OCaml is a very interesting and powerful language, 
and in many respects more practical compared to other functional 
languages.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners