checkFlags :: [ProgFlag] -> [String]
checkFlags = g . mapAccumL f (0 :: Int) where
    f i (PFLib _) = (setBit i 0, ())
    f i (PFSpec _) = (setBit i 1, ())
    f i (PFPattern _) = (setBit i 2, ())
    f i (PFDesign _) = (setBit i 3, ())
    f i _ = (i, ())
    g (i, _) = mapMaybe (h i) [ (0, "lib")
                              , (1, "spec")
                              , (2, "pattern")
                              , (3, "design") ]
    h i (j, s)
      | testBit i j = Nothing
      | otherwise = Just $ s ++ " argument is missing"
checkFlags :: [ProgFlag] -> [String]
checkFlags = g . mapAccumL f (0 :: Int) where
    f i (PFLib _) = (setBit i 0, ())
    f i (PFSpec _) = (setBit i 1, ())
    f i (PFPattern _) = (setBit i 2, ())
    f i (PFDesign _) = (setBit i 3, ())
    f i _ = (i, ())
    g (i, _) = mapMaybe (h i) [ (0, "lib")
                              , (1, "spec")
                              , (2, "pattern")
                              , (3, "design") ]
    h i (j, s)
      | testBit i j = Nothing
      | otherwise = Just $ s ++ " argument is missing"
checkFlags = g . mapAccumL f (0 :: Int) where
    f i (PFLib _) = (setBit i 0, ())
    f i (PFSpec _) = (setBit i 1, ())
    f i (PFPattern _) = (setBit i 2, ())
    f i (PFDesign _) = (setBit i 3, ())
    f i _ = (i, ())
    g (i, _) = mapMaybe (h i) [ (0, "lib")
                              , (1, "spec")
                              , (2, "pattern")
                              , (3, "design") ]
    h i (j, s)
      | testBit i j = Nothing
      | otherwise = Just $ s ++ " argument is missing"