|
List Info
Thread: "ocaml_beginners"::[] Typing problem: qualifying constructor
|
|
| "ocaml_beginners"::[] Typing
problem: qualifying constructor |
  Portugal |
2007-05-22 04:35:36 |
|
Hello,
I have changed the stdlib Map file and added the following type:
type 'a enum =
| End
| More of 'a * 'a t * 'a enum
and have made it "visible" (i.e: non-abstract) in both the interface and
the functor. In the "client" code I would like to use "End". To do this
I simple use:
module Key_map = Imap.Make (struct
type t = dt_key
let compare = Pervasives.compare
end)
and "access" End so:
let iter = Key_map.End
My question is: assume I had another visible type within the functor
that also had a "End" constructor. How could I "qualify" Key_map in
order specifically use the type 'a enum?
TIA,
Hugo F.
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
Typing problem: qualifying constructor |
  United Kingdom |
2007-05-22 10:12:37 |
|
On Tue, May 22, 2007 at 10:35:36AM +0100, Hugo Ferreira wrote:
> My question is: assume I had another visible type within the functor
> that also had a "End" constructor. How could I "qualify" Key_map in
> order specifically use the type 'a enum?
If the two constructors end up in the same module then you can't. The
second one "wins".
You could assign End to a value and use that instead, eg, in the
functor, add this before the second definition:
let first_end = End
but really you're better off not having two constructors with the same
name.
Rich.
--
Richard Jones
Red Hat
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
Typing problem: qualifying constructor |
  Portugal |
2007-05-22 11:05:55 |
|
Richard,
Richard Jones wrote:
> On Tue, May 22, 2007 at 10:35:36AM +0100, Hugo Ferreira wrote:
>> My question is: assume I had another visible type within the functor
>> that also had a "End" constructor. How could I "qualify" Key_map in
>> order specifically use the type 'a enum?
>
> If the two constructors end up in the same module then you can't. The
> second one "wins".
>
I see.
> You could assign End to a value and use that instead, eg, in the
> functor, add this before the second definition:
>
> let first_end = End
>
Haaaa.. good one. Won't work for constructor with values though. 8-(
> but really you're better off not having two constructors with the same
> name.
>
Hmmmm... sound advice.
Thanks,
Hugo F.
> Rich.
>
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
Typing problem: qualifying constructor |
  United Kingdom |
2007-05-22 11:25:22 |
|
On Tue, May 22, 2007 at 05:05:55PM +0100, Hugo Ferreira wrote:
> Richard Jones wrote:
> > let first_end = End
> Haaaa.. good one. Won't work for constructor with values though. 8-(
It can do:
let first_end x y = End (x, y)
Rich.
--
Richard Jones
Red Hat
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
Typing problem: qualifying constructor |
  Portugal |
2007-05-23 01:27:45 |
|
Richard Jones wrote:
> On Tue, May 22, 2007 at 05:05:55PM +0100, Hugo Ferreira wrote:
>> Richard Jones wrote:
>>> let first_end = End
>> Haaaa.. good one. Won't work for constructor with values though. 8-(
>
> It can do:
>
> let first_end x y = End (x, y)
>
Yes you can. Thanks a lot.
I will use different constructors though.
> Rich.
>
__._,_.___
.
__,_._,___
|
[1-5]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|