checkUselessPermissions :: Tar.Entries CombinedTarErrs -> Tar.Entries CombinedTarErrs
checkUselessPermissions =
    checkEntries checkEntry
  where
    checkEntry entry =
      case Tar.entryContent entry of
        (Tar.NormalFile _ _) -> checkPermissions 0o644 (Tar.entryPermissions entry)
        (Tar.Directory) -> checkPermissions 0o755 (Tar.entryPermissions entry)
        _ -> Nothing
      where
        checkPermissions expected actual =
            if expected .&. actual /= expected
                then Just $ PermissionsError (Tar.entryPath entry) actual
                else Nothing
checkUselessPermissions :: Tar.Entries CombinedTarErrs -> Tar.Entries CombinedTarErrs
checkUselessPermissions =
    checkEntries checkEntry
  where
    checkEntry entry =
      case Tar.entryContent entry of
        (Tar.NormalFile _ _) -> checkPermissions 0o644 (Tar.entryPermissions entry)
        (Tar.Directory) -> checkPermissions 0o755 (Tar.entryPermissions entry)
        _ -> Nothing
      where
        checkPermissions expected actual =
            if expected .&. actual /= expected
                then Just $ PermissionsError (Tar.entryPath entry) actual
                else Nothing
checkUselessPermissions =
    checkEntries checkEntry
  where
    checkEntry entry =
      case Tar.entryContent entry of
        (Tar.NormalFile _ _) -> checkPermissions 0o644 (Tar.entryPermissions entry)
        (Tar.Directory) -> checkPermissions 0o755 (Tar.entryPermissions entry)
        _ -> Nothing
      where
        checkPermissions expected actual =
            if expected .&. actual /= expected
                then Just $ PermissionsError (Tar.entryPath entry) actual
                else Nothing