Grupos de Google ya no admite nuevas publicaciones ni suscripciones de Usenet. El contenido anterior sigue siendo visible.

[Caml-list] Please a simple Camlp5 example

Visto 14 veces
Saltar al primer mensaje no leído

Fabrice Marchant

no leída,
28 feb 2008, 11:47:4728/2/08
a 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

no leída,
28 feb 2008, 12:15:4328/2/08
a 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 mensajes nuevos