Version française
Home     About     Download     Resources     Contact us    
Browse thread
deriving show
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: ygrek <ygrekheretix@g...>
Subject: Re: [Caml-list] deriving show
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