
    either (const $ throwIO $ userError "cannot decode file as FileContentAndMime") return $ S.decodeLazy lbs


simpleParseDec :: (Eq a, Num a) => String -> Maybe a
simpleParseDec = fmap fst . listToMaybe . filter (null . snd) . readDec

simpleParseDecT :: (Eq a, Num a) => Text -> Maybe a
simpleParseDecT = simpleParseDec . T.unpack

simpleParseFloat :: (RealFrac a) => String -> Maybe a
simpleParseFloat = fmap fst . listToMaybe . filter ((== "
saveWreqResponseContentAndMime :: (MonadIO m)
                                => Handle
                                -> Response LB.ByteString
                                -> m FileContentAndMime
saveWreqResponseContentAndMime h r = liftIO $ do
    LB.hPut h $ S.encodeLazy dat
    return dat
    where
        dat  = (body, mime)
        body = r ^. responseBody
        mime = fromMaybe defaultMimeType $ r ^? responseHeader "Content-Type"
saveWreqResponseContentAndMime h r = liftIO $ do
    LB.hPut h $ S.encodeLazy dat
    return dat
    where
        dat  = (body, mime)
        body = r ^. responseBody
        mime = fromMaybe defaultMimeType $ r ^? responseHeader "Content-Type"