Version française
Home     About     Download     Resources     Contact us    
Browse thread
Please a simple Camlp5 example
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Please a simple Camlp5 example
On Thu, Feb 28, 2008 at 04:47:37PM +0100, Fabrice Marchant wrote:
> 
>   Hi !
> 
>   Aware that this belongs to beginners-list, I first posted there
> three weeks ago, but without any answer :
> 
>   I bet this kind of code should be rather common :
> 
> let string_of_piece_type = function
>   King   -> "King"
> | Queen  -> "Queen"
> | Rook   -> "Rook"
> | Bishop -> "Bishop"
> | Knight -> "Knight"
> | Pawn   -> "Pawn"
> 
>  Please have you got an example where the macro helps to implement such kind of "string_of_type" function ?

You probably want to look at deriving (http://code.google.com/p/deriving/)
or tywith (http://www.seedwiki.com/wiki/shifting_focus/tywith) which
can generate these functions automatically.

Rich.

-- 
Richard Jones
Red Hat