Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] Please a simple Camlp5 example

14 views
Skip to first unread message

Fabrice Marchant

unread,
Feb 28, 2008, 11:47:47 AM2/28/08
to caml...@yquem.inria.fr

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 ?

Thanks,

Fabrice

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Richard Jones

unread,
Feb 28, 2008, 12:15:43 PM2/28/08
to Fabrice Marchant, caml...@yquem.inria.fr
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

0 new messages