-- | Helper function that tries to enforce a single package constraint on a
-- given flag setting for an F-node. Translates the constraint into a
-- tree-transformer that either leaves the subtree untouched, or replaces it
-- with an appropriate failure node.
processPackageConstraintF :: Flag -> ConflictSet QPN -> Bool -> PackageConstraint -> Tree a -> Tree a
processPackageConstraintF f c b' (PackageConstraintFlags _ fa) r =
  case L.lookup f fa of
    Nothing            -> r
    Just b | b == b'   -> r
           | otherwise -> Fail c GlobalConstraintFlag
processPackageConstraintF :: Flag -> ConflictSet QPN -> Bool -> PackageConstraint -> Tree a -> Tree a
processPackageConstraintF f c b' (PackageConstraintFlags _ fa) r =
  case L.lookup f fa of
    Nothing            -> r
    Just b | b == b'   -> r
           | otherwise -> Fail c GlobalConstraintFlag
processPackageConstraintF f c b' (PackageConstraintFlags _ fa) r =
  case L.lookup f fa of
    Nothing            -> r
    Just b | b == b'   -> r
           | otherwise -> Fail c GlobalConstraintFlag