[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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 *)
else
(* 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.
Brian
-------------------
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