[Haskell-cafe] regular-xmlpickler

gbwey9 gbwey9 at gmail.com
Sat Jul 12 03:49:38 UTC 2014


Hi Adam,

You are right. I didn't realise that I could write my own pickler without
having a real parent xml node.
Anyway, it works!

Thanks for your help,
Grant




On Fri, Jul 11, 2014 at 9:14 PM, Adam Bergmark <adam at bergmark.nl> wrote:

> Hi Grant,
>
> This is an edge case since you have a field name with the same name as a
> constructor. regular-xmlpickler doesn't try to treat this case differently,
> I'm not sure if there is a good way to generically fix this in the way you
> want.
>
> That said, you can always write your own picklers using plain hxt to
> flatten the structure, and note that you can mix custom instances with
> regular-xmlpickler generated ones.
>
> Also see the hxt-pickle-utils[1] package for a few helper functions
>
> [1] http://hackage.haskell.org/package/hxt-pickle-utils
>
> Cheers,
> Adam
>
>
>
> On Sat, Jul 12, 2014 at 12:47 AM, gbwey9 <gbwey9 at gmail.com> wrote:
>
>> Hi,
>>
>> I am using a very cool package called regular-xmlpickler.
>> Does anyone know of a way to skip one level of nesting for nested complex
>> fields? So I would like to elide that outer/inner Header.
>>
>> Here is the full code: http://lpaste.net/107362
>>
>> data User = User
>>   { name  :: String
>>   , admin :: Bool
>>    , dt :: UTCTime
>>   , header :: Header
>>   }
>>
>> data Header = Header
>>   { header1 :: String
>>   , header2 :: String
>>   }
>>
>> so instead of generating <header> twice
>>
>> <header>
>>    <header>
>>       <header1>abb</header1>
>>       <header2>abb</header2>
>>    </header>
>> </header>
>>
>> I would like to have it generate this.
>>
>>    <header>
>>       <header1>abb</header1>
>>       <header2>abb</header2>
>>    </header>
>>
>>
>> Thanks,
>> Grant
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140711/4f9dc2cf/attachment.html>


More information about the Haskell-Cafe mailing list