detect :: [(IO Bool, a)] -> IO (Maybe a)
detect = foldM go Nothing
  where
    go r@(Just _) _              = pure r
    go Nothing    (predicate, a) = do
        isThisOne <- predicate
        pure $ if isThisOne
            then Just a
            else Nothing

-- }}} Utility functions ------------------------------------------------------
detect :: [(IO Bool, a)] -> IO (Maybe a)
detect = foldM go Nothing
  where
    go r@(Just _) _              = pure r
    go Nothing    (predicate, a) = do
        isThisOne <- predicate
        pure $ if isThisOne
            then Just a
            else Nothing

-- }}} Utility functions ------------------------------------------------------
detect = foldM go Nothing
  where
    go r@(Just _) _              = pure r
    go Nothing    (predicate, a) = do
        isThisOne <- predicate
        pure $ if isThisOne
            then Just a
            else Nothing

-- }}} Utility functions ------------------------------------------------------