* Type equalities in sub modules
@ 2006-12-31 9:35 Daniel Bünzli
2007-01-02 12:50 ` [Caml-list] " Hendrik Tews
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Bünzli @ 2006-12-31 9:35 UTC (permalink / raw)
To: caml-list
Hello,
In the example below, is there any way to achieve M.B.t = M.t without
introducing the intermediate mt type ?
> module M = struct
> type t = int
> module B = struct
> type mt = t
> type t = mt
> end
> end
This doesn't work :
> module M = struct
> type t = int
> module B = struct
> type t = M.t
> end
> end
This doesn't work :
> module M = struct
> type t = int
> module B = struct
> type t = t
> end
> end
It seems type definitions should have been designed like value
definitions by having both a 'type' and 'type rec' construct (though
one can argue this is sufficently rare to justify the above
inconvenience).
Thanks for your answers,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Type equalities in sub modules
2006-12-31 9:35 Type equalities in sub modules Daniel Bünzli
@ 2007-01-02 12:50 ` Hendrik Tews
2007-01-02 22:56 ` Till Varoquaux
0 siblings, 1 reply; 4+ messages in thread
From: Hendrik Tews @ 2007-01-02 12:50 UTC (permalink / raw)
To: caml-list
Daniel Bünzli <daniel.buenzli@epfl.ch> writes:
In the example below, is there any way to achieve M.B.t = M.t without
introducing the intermediate mt type ?
> module M = struct
> type t = int
> module B = struct
> type mt = t
> type t = mt
> end
> end
How about
module M = struct
type t = int
module BF(T : sig type mt end) = struct
type t = T.mt
end
module B = BF(struct type mt = t end)
end
??
Hendirk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Type equalities in sub modules
2007-01-02 12:50 ` [Caml-list] " Hendrik Tews
@ 2007-01-02 22:56 ` Till Varoquaux
2007-01-02 23:31 ` Daniel Bünzli
0 siblings, 1 reply; 4+ messages in thread
From: Till Varoquaux @ 2007-01-02 22:56 UTC (permalink / raw)
To: caml-list
You seem to be looking for recursive modules, this might prove quite a
painful solution since you have to explicitly write the signature
(there's no type inference on recursive modules, this is a rather
complicated issue. Information can be found in [1])...:
module rec M :
sig
type t = int
module B : sig type t = M.t end
end= struct
type t = int
module B = struct
type mt = t
type t = mt
end
end;;
Happy new year,
Till
[1]:http://perso.ens-lyon.fr/tom.hirschowitz/
On 1/2/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
> Daniel Bünzli <daniel.buenzli@epfl.ch> writes:
>
> In the example below, is there any way to achieve M.B.t = M.t without
> introducing the intermediate mt type ?
>
> > module M = struct
> > type t = int
> > module B = struct
> > type mt = t
> > type t = mt
> > end
> > end
>
> How about
>
> module M = struct
> type t = int
> module BF(T : sig type mt end) = struct
> type t = T.mt
> end
> module B = BF(struct type mt = t end)
> end
>
> ??
>
> Hendirk
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-02 23:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-31 9:35 Type equalities in sub modules Daniel Bünzli
2007-01-02 12:50 ` [Caml-list] " Hendrik Tews
2007-01-02 22:56 ` Till Varoquaux
2007-01-02 23:31 ` Daniel Bünzli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox