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
[Caml-list] Variant parameterized method?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <brian.hurt@q...>
Subject: Re: [Caml-list] Variant parameterized method?
Thanks for your help.

On Wed, 23 Jul 2003, Jacques Garrigue wrote:

> This precise type is not admissible in the ocaml type system.
> In ocaml recursive types must be regular: only 'a foo may occur in the
> expansion of 'a foo.

Ah.  Any hope of getting this fixed?

> This problem is discussed in an answer to PR#1730 in the caml bug
> database.

Unfortunately, I don't speak french.

> This can be solved by introducing an explicit wrapper.

This is one possibility.

> If you think (as I do) that all these examples are just too
> complicated in practice, there is a simpler way to go:
> only define a fold method in your class, and define map itself out of
> the class.

Maybe I'm asking the wrong question.  I need/want map to behave 
differently when called on different subtypes of foo.  In a pseudo 
java/ocaml mix, I want to do:

let map f x =
    if x instanceof 'a foo_map then
        let e = ('a foo_map) in
        (* various code dealing with an already mapped foo *)
        (* various code dealing with an arbitrary unmapped foo *)

The obvious way to do this to me is to make map a member function.  But 
this wouldn't be the first time I was missing something obvious.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: