[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] COW XML questions



Hi,

> Some of the field names in the XML are not valid or idiomatic OCaml
> record fields, for example they might be capitalized. Is there an
> easyish way to get COW to do things like the following?
> 
> type t = {foo: int; bar: string} with xml;;
> xml_of_t {foo=0; bar="hello"};
> # yields <:xml< <Bar>hello</Bar> <Foo>0</Foo> >>

I think the COW deriving extensions are pretty dumb, so this is not possible 
directly.

However you can write your own converter:

let xml_of_t { foo; bar } = <:xml< <Bar>$str:bar$</Bar> <Foo>$int:foo$</Foo> >>

Best,
Thomas
_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.