g a
parseMsgErrorToString (Left err)    = Left $ "failed to parse from file: " ++ show err
parseMsgErrorToString (Right x)     = Right x

unifyExcHandler :: (Show e, Monad m)
                => ExcSafe.Handler m (Either e a)
                -> ExcSafe.Handler m (Either String a)
unifyExcHandler =
#if MIN_VERSION_classy_prelude(1, 0, 0)
  \ (ExcSafe.Handler f) -> ExcSafe.Handler $ fmap (either (Left . show) Right) . f
#else
  fmap $ either (Left . show) Right
#endif


encodeStringQRCodeImage :: (QRC.ToText a)
                        => Int
                  
runDelayedCachedYamlLoaderL :: ( MonadIO m )
                            => s
                            -> NonEmpty FilePath    -- ^ 消息文件存放目录
                            -> DelayedCachedYamlLoader s a
                            -> m (Either String a)
runDelayedCachedYamlLoaderL st base_dirs f = liftIO $ do
  err_or_x <- tryIOError $ try $ runReaderT (f base_dirs) st
  case err_or_x of
      Left err    -> return $ Left $ "failed to load from file: " ++ show err
      Right x     -> return $ parseMsgErrorToString x
runDelayedCachedYamlLoaderL st base_dirs f = liftIO $ do
  err_or_x <- tryIOError $ try $ runReaderT (f base_dirs) st
  case err_or_x of
      Left err    -> return $ Left $ "failed to load from file: " ++ show err
      Right x     -> return $ parseMsgErrorToString x