readFileThroughCache :: FilePath -> TreeGenerator [Text]
readFileThroughCache path = do
  ls <- lift $ readCache (FileCache path)
  case ls of
    Just inner -> return inner
    Nothing -> do
      case (toText path) of
        Right path' -> do
          cnt_or_error <- decodeUtf8' <$> (liftIO $ BC.readFile (unpack path' :: GI.FilePath))
          case cnt_or_error of
            Right cnt -> do
              let new_ls = lines cnt
              lift $ writeCache (FileCache path) new_ls
              return new_ls
            Left _ -> do
              tell [path']
              return []
        Left path' -> do
          tell [path']
          return []
readFileThroughCache :: FilePath -> TreeGenerator [Text]
readFileThroughCache path = do
  ls <- lift $ readCache (FileCache path)
  case ls of
    Just inner -> return inner
    Nothing -> do
      case (toText path) of
        Right path' -> do
          cnt_or_error <- decodeUtf8' <$> (liftIO $ BC.readFile (unpack path' :: GI.FilePath))
          case cnt_or_error of
            Right cnt -> do
              let new_ls = lines cnt
              lift $ writeCache (FileCache path) new_ls
              return new_ls
            Left _ -> do
              tell [path']
              return []
        Left path' -> do
          tell [path']
          return []
readFileThroughCache path = do
  ls <- lift $ readCache (FileCache path)
  case ls of
    Just inner -> return inner
    Nothing -> do
      case (toText path) of
        Right path' -> do
          cnt_or_error <- decodeUtf8' <$> (liftIO $ BC.readFile (unpack path' :: GI.FilePath))
          case cnt_or_error of
            Right cnt -> do
              let new_ls = lines cnt
              lift $ writeCache (FileCache path) new_ls
              return new_ls
            Left _ -> do
              tell [path']
              return []
        Left path' -> do
          tell [path']
          return []