decodeUrlEntity :: JSValue -> Result UrlEntity
decodeUrlEntity (JSObject obj) = UrlEntity <$> valFromObj "url" obj
                                           <*> valMayFromObj "display_url" obj
                                           <*> valMayFromObj "expanded_url" obj
                                           <*> (valFromObj "indices" obj >>= l2t)
  where
    l2t [i, j] = Ok (i, j)
    l2t xs     = Error $ "not a [i, j], but" ++ show xs
decodeUrlEntity :: JSValue -> Result UrlEntity
decodeUrlEntity (JSObject obj) = UrlEntity <$> valFromObj "url" obj
                                           <*> valMayFromObj "display_url" obj
                                           <*> valMayFromObj "expanded_url" obj
                                           <*> (valFromObj "indices" obj >>= l2t)
  where
    l2t [i, j] = Ok (i, j)
    l2t xs     = Error $ "not a [i, j], but" ++ show xs
decodeUrlEntity (JSObject obj) = UrlEntity <$> valFromObj "url" obj
                                           <*> valMayFromObj "display_url" obj
                                           <*> valMayFromObj "expanded_url" obj
                                           <*> (valFromObj "indices" obj >>= l2t)
  where
    l2t [i, j] = Ok (i, j)
    l2t xs     = Error $ "not a [i, j], but" ++ show xs