processHints :: Config -> AtomIndex -> SuiteInfo -> SuiteInfo -> GeneralInfo -> [Hint] -> HintResults
processHints config ai unstable testing general hints = HintResults {..}
  where blockedSources = IxS.filter isReallyBlockedSource $ sources unstable `IxS.difference` sources testing
        isReallyBlockedSource srcI =
            ((allBlocked || isBlockedSource srcI) && not (isUnblockedSource srcI))
            || (isBlockedUdebSource srcI && not (isUnblockedUdebSource srcI))

        allBlocked = BlockAll `elem` hints

        isUnblockedSource srcI = foldl' (isUnblockedBy (ai `lookupSrc` srcI)) False hints
        isUnblockedBy src True _ = True
        isUnblockedBy src False (Unblock hintSpec) = hintSpecApplies hintSpec src
        isUnblockedBy src b _ = b

        isBlockedSource srcI = foldl' (isBlockedBy (ai `lookupSrc` srcI)) False hints
        isBlockedBy src True _ = True
        isBlockedBy src False (Block hintSpec) = hintSpecApplies hintSpec src
        isBlockedBy src b _ = b

        isUnblockedUdebSource srcI = foldl' (isUnblockedUdebBy (ai `lookupSrc` srcI)) False hints
        isUnblockedUdebBy src True _ = True
        isUnblockedUdebBy src False (UnblockUdeb hintSpec) = hintSpecApplies hintSpec src
        isUnblockedUdebBy src b _ = b

        isBlockedUdebSource srcI = foldl' (isBlockedUdebBy (ai `lookupSrc` srcI)) False hints
        isBlockedUdebBy src True _ = True
        isBlockedUdebBy src False (BlockUdeb hintSpec) = hintSpecApplies hintSpec src
        isBlockedUdebBy src b _ = b

        removedSources = IxS.filter isRemovedSource $ sources unstable `IxS.union` sources testing
        isRemovedSource srcI = foldl' (isRemovedBy (ai `lookupSrc` srcI)) False hints
        isRemovedBy src True _ = True
        isRemovedBy src False (Remove hintSpec) = hintSpecApplies hintSpec src
        isRemovedBy src b _ = b

-- TODO: binNMU syntax
processHints :: Config -> AtomIndex -> SuiteInfo -> SuiteInfo -> GeneralInfo -> [Hint] -> HintResults
processHints config ai unstable testing general hints = HintResults {..}
  where blockedSources = IxS.filter isReallyBlockedSource $ sources unstable `IxS.difference` sources testing
        isReallyBlockedSource srcI =
            ((allBlocked || isBlockedSource srcI) && not (isUnblockedSource srcI))
            || (isBlockedUdebSource srcI && not (isUnblockedUdebSource srcI))

        allBlocked = BlockAll `elem` hints

        isUnblockedSource srcI = foldl' (isUnblockedBy (ai `lookupSrc` srcI)) False hints
        isUnblockedBy src True _ = True
        isUnblockedBy src False (Unblock hintSpec) = hintSpecApplies hintSpec src
        isUnblockedBy src b _ = b

        isBlockedSource srcI = foldl' (isBlockedBy (ai `lookupSrc` srcI)) False hints
        isBlockedBy src True _ = True
        isBlockedBy src False (Block hintSpec) = hintSpecApplies hintSpec src
        isBlockedBy src b _ = b

        isUnblockedUdebSource srcI = foldl' (isUnblockedUdebBy (ai `lookupSrc` srcI)) False hints
        isUnblockedUdebBy src True _ = True
        isUnblockedUdebBy src False (UnblockUdeb hintSpec) = hintSpecApplies hintSpec src
        isUnblockedUdebBy src b _ = b

        isBlockedUdebSource srcI = foldl' (isBlockedUdebBy (ai `lookupSrc` srcI)) False hints
        isBlockedUdebBy src True _ = True
        isBlockedUdebBy src False (BlockUdeb hintSpec) = hintSpecApplies hintSpec src
        isBlockedUdebBy src b _ = b

        removedSources = IxS.filter isRemovedSource $ sources unstable `IxS.union` sources testing
        isRemovedSource srcI = foldl' (isRemovedBy (ai `lookupSrc` srcI)) False hints
        isRemovedBy src True _ = True
        isRemovedBy src False (Remove hintSpec) = hintSpecApplies hintSpec src
        isRemovedBy src b _ = b

-- TODO: binNMU syntax
processHints config ai unstable testing general hints = HintResults {..}
  where blockedSources = IxS.filter isReallyBlockedSource $ sources unstable `IxS.difference` sources testing
        isReallyBlockedSource srcI =
            ((allBlocked || isBlockedSource srcI) && not (isUnblockedSource srcI))
            || (isBlockedUdebSource srcI && not (isUnblockedUdebSource srcI))

        allBlocked = BlockAll `elem` hints

        isUnblockedSource srcI = foldl' (isUnblockedBy (ai `lookupSrc` srcI)) False hints
        isUnblockedBy src True _ = True
        isUnblockedBy src False (Unblock hintSpec) = hintSpecApplies hintSpec src
        isUnblockedBy src b _ = b

        isBlockedSource srcI = foldl' (isBlockedBy (ai `lookupSrc` srcI)) False hints
        isBlockedBy src True _ = True
        isBlockedBy src False (Block hintSpec) = hintSpecApplies hintSpec src
        isBlockedBy src b _ = b

        isUnblockedUdebSource srcI = foldl' (isUnblockedUdebBy (ai `lookupSrc` srcI)) False hints
        isUnblockedUdebBy src True _ = True
        isUnblockedUdebBy src False (UnblockUdeb hintSpec) = hintSpecApplies hintSpec src
        isUnblockedUdebBy src b _ = b

        isBlockedUdebSource srcI = foldl' (isBlockedUdebBy (ai `lookupSrc` srcI)) False hints
        isBlockedUdebBy src True _ = True
        isBlockedUdebBy src False (BlockUdeb hintSpec) = hintSpecApplies hintSpec src
        isBlockedUdebBy src b _ = b

        removedSources = IxS.filter isRemovedSource $ sources unstable `IxS.union` sources testing
        isRemovedSource srcI = foldl' (isRemovedBy (ai `lookupSrc` srcI)) False hints
        isRemovedBy src True _ = True
        isRemovedBy src False (Remove hintSpec) = hintSpecApplies hintSpec src
        isRemovedBy src b _ = b

-- TODO: binNMU syntax