FRPWIKCNGK6PM6VCKEHEUG5A2LWL7WFN66L4CPQ7DLN4WAS3TIZQC
parseRow :: Row Value -> LogEntry
parseRow = undefined
parseRow :: Row Value -> Maybe LogEntry
parseRow row = do
a <- lookup "btcAddr" row >>= valueAddr
t <- lookup "eventTime" row >>= valueTime
ev <- lookup "event" row >>= (valueEvent t)
return $ LogEntry a ev
valueAddr :: Value -> Maybe BtcAddr
valueAddr (Text t) = parseBtcAddr $ T.pack t
valueAddr _ = Nothing
valueTime :: Value -> Maybe UTCTime
valueTime (Text t) = parseTime defaultTimeLocale "%c" t
valueTime _ = Nothing
valueEvent :: UTCTime -> Value -> Maybe WorkEvent
valueEvent t (Text "start") = Just (StartWork t)
valueEvent t (Text "stop") = Just (StopWork t)
valueEvent _ _ = Nothing