jwaldmann / haskell-tpdb

parser and prettyprinter for TPDB syntax (termination problem data base)
2 stars 2 forks source link

make more systematic transformation between XML (xtc, cpf) and data #16

Open jwaldmann opened 8 years ago

jwaldmann commented 8 years ago

current situation is:

Translation is ad-hoc - that is, not uniform (generic) over the data type declarations. (For reference, here is a generic transformation: http://repetae.net/repos/DrIFT/src/Rules/Xml.hs)

So my current code is a mess of

So, we have a problem similar to mapping data declaration <-> existing data base schema. In persistent , you can specify details of the mapping via annotations to the model. This needs template haskell, see https://github.com/yesodweb/persistent/blob/master/persistent-template/Database/Persist/TH.hs

Plan (long-term)

  1. describe a simple and fully generic data <-> XML mapping.
    • this should map an object C1 { a1 = foo } of type data T = C1 { a1 :: A1, .. } | .. to <T><C1><a1> ...</a1>..</C1></T>, so that is has all information
  2. describe a set of ("ad-hoc") modifications that can be applied to give the desired result. E.g.,
    • use different name for element than for constructor
    • drop some of these elements (T,C1,a1)
    • describe mapping for primitive types (to attribute, or to contents)
    • describe handling of implicit collections (list)