[Haskell-beginners] converting a json encoded radix tree to a haskell data type

Karl Voelker karl at karlv.net
Thu Aug 27 15:18:45 UTC 2015


On Thu, Aug 27, 2015, at 08:04 AM, Adam Flott wrote:
> data Things = MkThings {
>   thing   :: TL.Text,
>   times :: ThingTimes
>   } deriving (Show, Eq, Typeable)
> 
> data ThingTimes = MkThingtimes {
>   ml :: V.Vector Times
>   } deriving (Show, Eq, Typeable)
> 
> data Times = MkTimes {
>   t1 :: Maybe Int32,
>   t2 :: Maybe Int32
>   } deriving (Show, Eq, Typeable)
> 
> -- radix.json --
> {
>     "a" : {
>         "b" : [ 1, 2 ],
>         "c" : {
>             "d" : [ 3, null ]
>         }
>     },
>     "a2" : { "b2" : [ 4, 5 ] }
> }
> -- radix.json --

It looks like your input file has Things nested inside Things, but your
data types don't allow for that. Is that intentional? What value is that
example input supposed to parse to?

-Karl


More information about the Beginners mailing list