* [Caml-list] exposing module types
@ 2002-02-08 21:08 Charles Martin
2002-02-08 21:21 ` Alain Frisch
2002-02-08 21:24 ` Daniel de Rauglaudre
0 siblings, 2 replies; 3+ messages in thread
From: Charles Martin @ 2002-02-08 21:08 UTC (permalink / raw)
To: caml-list
I obviously have the wrong model of what's going on here:
% cat foolib.ml
module Foo = struct
module type INTF = sig
type 'a fruit = Apple of 'a
end
module Impl : INTF = struct
type 'a fruit = Apple of 'a
end
type 'a fruit = 'a Impl.fruit
end
include Foo
% ocamlc -a -o foolib.cma foolib.ml
Now, when I try to use foolib in the following way:
open Foolib
let apple = Apple 3
let apple = Foo.Apple 3
let apple = Foo.Impl.Apple 3
The only one that works is "Foo.Impl.Apple" - the others receive "Unbound constructor" messages. I hope my intention is clear; in foolib I meant to expose the constructors at the higher levels. What am I doing wrong?
Thanks,
Charles
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] exposing module types
2002-02-08 21:08 [Caml-list] exposing module types Charles Martin
@ 2002-02-08 21:21 ` Alain Frisch
2002-02-08 21:24 ` Daniel de Rauglaudre
1 sibling, 0 replies; 3+ messages in thread
From: Alain Frisch @ 2002-02-08 21:21 UTC (permalink / raw)
To: Charles Martin; +Cc: caml-list
On Fri, 8 Feb 2002, Charles Martin wrote:
> I obviously have the wrong model of what's going on here:
>
> % cat foolib.ml
> module Foo = struct
> module type INTF = sig
> type 'a fruit = Apple of 'a
> end
> module Impl : INTF = struct
> type 'a fruit = Apple of 'a
> end
> type 'a fruit = 'a Impl.fruit
> end
> include Foo
> % ocamlc -a -o foolib.cma foolib.ml
> What am I doing wrong?
The line "type 'a fruit = 'a Impl.fruit" just asserts that the type
'a fruit is the same as 'a Impl.fruit. It does not say what its
value constructors are, though this could be deduced. The solution is to
replace the line with:
type 'a fruit = 'a Impl.fruit = Apple of 'a
(or: include Impl, but that is probably not what you want to do)
-- Alain
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] exposing module types
2002-02-08 21:08 [Caml-list] exposing module types Charles Martin
2002-02-08 21:21 ` Alain Frisch
@ 2002-02-08 21:24 ` Daniel de Rauglaudre
1 sibling, 0 replies; 3+ messages in thread
From: Daniel de Rauglaudre @ 2002-02-08 21:24 UTC (permalink / raw)
To: caml-list
Hi,
On Fri, Feb 08, 2002 at 01:08:44PM -0800, Charles Martin wrote:
> The only one that works is "Foo.Impl.Apple"
Change the line:
type 'a fruit = 'a Impl.fruit
into:
type 'a fruit = 'a Impl.fruit = Apple of 'a
The type name was visible but not its constructor.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-02-08 21:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-08 21:08 [Caml-list] exposing module types Charles Martin
2002-02-08 21:21 ` Alain Frisch
2002-02-08 21:24 ` Daniel de Rauglaudre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox