<?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/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"
  prev="2009/01/362d9a24596895194833ad9dc424ca61"
  next="2009/01/9921cb683ab06368e880d42f5319d6ce"
  prev-in-thread="2009/01/65ae6dbba6f7a5a9f4abdb2e6e7b295d"
  next-in-thread="2009/01/7bf500ce00c1bd15b48f1a563855c516"
  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 again,

I ditched the regular variants in favour of polymorphic variants, hoping
the coercion trick described by Jacques Garrigue would help [1].  I've also
simplified the formulation as much as possible.  Anyway, I'm still stuck
with the same problem: while function 'sprint' works alright inside the
Node module, its clone 'sprint2' fails to compile when placed outside.
Is this a case where no amount of explicit annotations and coercions will
work or am I missing something obvious?

Thanks in advance!
Regards,
Dario Teixeira

[1] http://groups.google.com/group/fa.caml/msg/855011402f1ca1b5


module Node:
sig
	type elem_t = [ `Text of string | `Bold of elem_t list ]
	type +'a t = private elem_t

	val text: string -&gt; [&gt; `Basic ] t
	val bold: 'a t list -&gt; [&gt; `Complex ] t
	val sprint: 'a t -&gt; string
end =
struct
	type elem_t = [ `Text of string | `Bold of elem_t list ]
	type +'a t = elem_t

	let text str = `Text str
	let bold seq = `Bold seq
	let rec sprint = function
		| `Text str	-&gt; Printf.sprintf "(Text %s)" str
		| `Bold seq	-&gt; Printf.sprintf "(Bold %s)" (List.fold_left (^) "" (List.map sprint seq))
end


module Foobar:
sig
	val sprint2: 'a Node.t -&gt; string
end =
struct
	let rec sprint2 node = match (node : _ Node.t :&gt; [&gt; ]) with
		| `Text str	-&gt; Printf.sprintf "(Text %s)" str
		| `Bold seq	-&gt; Printf.sprintf "(Bold %s)" (List.fold_left (^) "" (List.map sprint2 (seq : _ Node.t list :&gt; [&gt;] list)))
end



      

</contents>

</message>

