caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* deriving show
@ 2010-02-12 19:54 Jon Harrop
  2010-02-12 21:29 ` [Caml-list] " ygrek
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Harrop @ 2010-02-12 19:54 UTC (permalink / raw)
  To: caml-list


IIRC, there is an OCaml macro that will autogenerate the code to print values 
of a variant type from the type definition. Does it handle polymorphic 
variants?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] deriving show
  2010-02-12 19:54 deriving show Jon Harrop
@ 2010-02-12 21:29 ` ygrek
  0 siblings, 0 replies; 2+ messages in thread
From: ygrek @ 2010-02-12 21:29 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Fri, 12 Feb 2010 19:54:50 +0000
Jon Harrop <jon@ffconsultancy.com> wrote:

> 
> IIRC, there is an OCaml macro that will autogenerate the code to print values 
> of a variant type from the type definition. Does it handle polymorphic 
> variants?

Yes, but one needs to write out the type (as in the case with the closed variants) :

type t = [ `A of t | `B ] deriving (Show)
print_endline (Show.show<t>(`A `B))

-- 
 ygrek
 http://ygrek.org.ua


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-12 21:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-12 19:54 deriving show Jon Harrop
2010-02-12 21:29 ` [Caml-list] " ygrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).