<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/01/65ae6dbba6f7a5a9f4abdb2e6e7b295d"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-19T15:09:19"
  subject="Re: [Caml-list] Private types in 3.11, again"
  prev="2009/01/5308b83c36d2f5cea5ee6ea4ec3329d0"
  next="2009/01/9d3495098b6736864d7a911f80eacf02"
  prev-in-thread="2009/01/8e788cbdd78799c4d818c8b687a933c9"
  next-in-thread="2009/01/b3ffbc5aa0de84115687f2de96daa38e"
  prev-thread="2009/01/05bc548e588fe9c3a7b00f01c10770eb"
  next-thread="2009/01/c04a6a1fca5f644f8e3abcd0c4bc7417"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Private types in 3.11, again">
<msg 
  url="2009/01/8e788cbdd78799c4d818c8b687a933c9"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-15T17:31:46"
  subject="Private types in 3.11, again">
<msg 
  url="2009/01/65ae6dbba6f7a5a9f4abdb2e6e7b295d"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-19T15:09:19"
  subject="Re: [Caml-list] Private types in 3.11, again">
<msg 
  url="2009/01/b3ffbc5aa0de84115687f2de96daa38e"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-20T16:33:55"
  subject="Re: [Caml-list] Private types in 3.11, again">
<msg 
  url="2009/01/7bf500ce00c1bd15b48f1a563855c516"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2009-01-20T17:30:37"
  subject="Re: [Caml-list] Private types in 3.11, again">
<msg 
  url="2009/01/746318635c69a7f8e8381ecb87c7a93b"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-20T17:48:16"
  subject="Re: [Caml-list] Private types in 3.11, again">
</msg>
<msg 
  url="2009/01/606129155b17b72d64eb1257f4014237"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2009-01-21T10:48:52"
  subject="Re: [Caml-list] Private types in 3.11, again">
</msg>
</msg>
<msg 
  url="2009/01/f71b5e0a66830ec7021b30a75465b90b"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2009-01-21T10:49:12"
  subject="Re: [Caml-list] Private types in 3.11, again">
</msg>
</msg>
<msg 
  url="2009/01/0fbff864e2edb7059ab802560278f082"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2009-01-21T13:22:34"
  subject="Re: [Caml-list] Private types in 3.11, again">
<msg 
  url="2009/01/b6e5615f0ddcff7795d510d626bf48fa"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-21T19:11:16"
  subject="Re: [Caml-list] Private types in 3.11, again">
<msg 
  url="2009/01/c019f81e9e51e4ed916dd8defc2922e2"
  from="Gabriel Kerneis &lt;kerneis@p...&gt;"
  author="Gabriel Kerneis"
  date="2009-01-21T20:17:48"
  subject="Re: [Caml-list] Private types in 3.11, again">
<msg 
  url="2009/01/281157e09784e72d51fa6e446087e73d"
  from="Dario Teixeira &lt;darioteixeira@y...&gt;"
  author="Dario Teixeira"
  date="2009-01-21T21:52:26"
  subject="GADTs in Ocaml (was: Private types in 3.11, again)">
</msg>
</msg>
<msg 
  url="2009/01/a44f23999a3086d6c3abc27ec0a57539"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2009-01-22T01:36:52"
  subject="Re: [Caml-list] Private types in 3.11, again">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

&gt; So my question is how can I make the Foobar code behave as if it were
&gt; defined inside Node.  Based on a previous thread [1], I'm guessing there
&gt; is a solution, but I've been unable to hit on its exact formulation.

There have been no replies yet to my question, but I'm still stuck with
this little problem.  The offending code is below; though it doesn't
compile, I reckon that all it needs is a suitable type annotation.  I'm
guessing this because the function capitalise_node function will compile
fine if placed inside the Node module.  Any ideas on how to solve this?

Thanks in advance!
Best regards,
Dario Teixeira


module Node:
sig
	type node_t =
		private
		| Text of string
		| Bold of node_t list
		| Href of string
		| Mref of string * node_t list

	type +'a t = private node_t

	val text: string -&gt; [&gt; `Nonlink ] t
	val bold: 'a t list -&gt; 'a t
	val href: string -&gt; [&gt; `Link ] t
	val mref: string -&gt; [&lt; `Nonlink ] t list -&gt; [&gt; `Link ] t
end =
struct
	type node_t =
		| Text of string
		| Bold of node_t list
		| Href of string
		| Mref of string * node_t list

	type +'a t = node_t

	let text txt = Text txt
	let bold seq = Bold seq
	let href lnk = Href lnk
	let mref lnk seq = Mref (lnk, seq)
end


module Foobar:
sig
	open Node
	val capitalise_node: 'a t -&gt; 'a t
end =
struct
	open Node
	let capitalise_node node =
		let rec capitalise_node_aux forbid_link node = match (forbid_link, node) with
			| (_, Text txt)			-&gt; text (String.capitalize txt)
			| (x, Bold seq)			-&gt; bold (List.map (capitalise_node_aux x) seq)
			| (false, Href lnk)		-&gt; href lnk
			| (false, Mref (lnk, seq))	-&gt; mref lnk (List.map (capitalise_node_aux true) seq)
			| _				-&gt; failwith "oops"
		in capitalise_node_aux false node
end




      

</contents>

</message>

