+ from_tuple :: (Maybe Int, Maybe String, Maybe Int) -> Maybe MostLapsLeading
+ from_tuple (Just x, Just y, Just z) =
+ Just $ MostLapsLeading (Just x) (Just y) (Just z)
+ from_tuple _ = Nothing
+
+ -- Sure had to go out of my way to avoid the warnings about unused
+ -- db_most_laps_foo fields here.
+ to_tuple :: Maybe MostLapsLeading -> (Maybe Int, Maybe String, Maybe Int)
+ to_tuple Nothing = (Nothing, Nothing, Nothing)
+ to_tuple (Just (MostLapsLeading Nothing _ _)) = (Nothing, Nothing, Nothing)
+ to_tuple (Just (MostLapsLeading _ Nothing _)) = (Nothing, Nothing, Nothing)
+ to_tuple (Just (MostLapsLeading _ _ Nothing)) = (Nothing, Nothing, Nothing)
+ to_tuple (Just m) = (db_most_laps_leading_driver_id m,
+ db_most_laps_leading_driver m,
+ db_most_laps_leading_number_of_laps m)
+
+
+-- | Pickler for the \<Race_Information\> child of \<message\>.
+--
+-- There's so much voodoo going on here. We have a double-layered
+-- Maybe on top of the MostLapsLeading. When unpickling, we return a
+-- Nothing (i.e. a Maybe MostLapsLeading) if any of its fields are
+-- missing. But if the entire element is missing, unpickling
+-- fails. 'xpOption' doesn't fix this because it would give us a
+-- Maybe (Maybe MostLapsLeading). But we can use 'xpDefault' with a
+-- default of (Nothing :: Maybe MostLapsLeading) to stick one in
+-- there if unpicking a (Maybe MostLapsLeading) fails because
+-- \<Most_Laps_Leading\> is missing.
+--
+-- Clear as mud, I know.
+--