English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] exposing module types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-02-08 (21:21)
From: Alain Frisch <frisch@c...>
Subject: Re: [Caml-list] exposing module types
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