I'll give this a try.
import Prelude hiding (null)
import Data.Set
-- if the given element is in the set, return it
-- else, try to return the (next lower, next higher)
-- (please ask if you do not understand why I chose this type)
foo :: Ord a => a -> Set a -> Either a (Maybe a, Maybe a)
foo x s = case splitMember x s of
(_, True, _) -> Left x
(low, _, high) -> Right (findMaxMaybe low, findMinMaybe high)
-- *Main> foo 3 $ fromList [1..10]
-- Left 3
--
-- *Main> foo 3 $ fromList [4..10]
-- Right (Nothing,Just 4)
--
-- *Main> foo 3 $ fromList $ 2:[4..10]
-- Right (Just 2,Just 4)
--
-- *Main> foo 3 $ fromList $ []
-- Right (Nothing,Nothing)
findMinMaybe :: Set a -> Maybe a
findMinMaybe s
| null s = Nothing
| otherwise = Just (findMin s)
findMaxMaybe :: Set a -> Maybe a
findMaxMaybe s
| null s = Nothing
| otherwise = Just (findMax s)