* Request for example where type annotation are required
@ 2005-09-19 20:21 Christophe Raffalli
  2005-09-19 20:59 ` [Caml-list] " Michael Wohlwend
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Raffalli @ 2005-09-19 20:21 UTC (permalink / raw)
  To: caml-list
I am looking for small ML examples (using variants, modules, objects, 
etc ...)
Where one needs to write type information to be able to type-check the 
program with OCaml
I am developping a new typing algorithm (not unification based ;-) which 
seems to accept all OCaml features and more (like higher-order type 
without using a functor) with no type annotation at all. I have quite a 
few examples, but all the experts on this list may have idea I did not have.
Christophe Raffalli
PS: an article and a first implementation should be available very soon.
^ permalink raw reply	[flat|nested] 2+ messages in thread
* Re: [Caml-list] Request for example where type annotation are required
  2005-09-19 20:21 Request for example where type annotation are required Christophe Raffalli
@ 2005-09-19 20:59 ` Michael Wohlwend
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Wohlwend @ 2005-09-19 20:59 UTC (permalink / raw)
  To: caml-list
On Monday 19 September 2005 22:21, Christophe Raffalli wrote:
> I am looking for small ML examples (using variants, modules, objects,
> etc ...)
> Where one needs to write type information to be able to type-check the
> program with OCaml
As my example, this should be a try of linked objects (like dllist od extlib):
class ['a] node = object(self:'a)
    val mutable nx = nil
    method next = nx
    method set_next n = nx <- n
    method apply f  upto =
        f self; if self <> upto then self#next#apply f upto
end;;
it doesn't work; the problem is the "nil" objects to initalize it, i cannot 
get this right, there are allways typing errors. Can this be defined without 
type-annotations?
ahem, this one works easily :-) 
class ['a] node = object(self:'a)
    val mutable nx =(Obj.magic 0 : 'a) 
    method next = nx
    method set_next n = nx <- n
    method apply (f: 'a->unit)  upto =
        f self; if self <> upto then self#next#apply f upto
    initializer nx <- self
end;;
   
let a = new node;;
-------------------------------------------------------------
 Michael
^ permalink raw reply	[flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-19 20:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-19 20:21 Request for example where type annotation are required Christophe Raffalli
2005-09-19 20:59 ` [Caml-list] " Michael Wohlwend
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox