I'm looking for general review and improvements on this code that safely gets the next element of a list (and wraps to the first element if you exceed the list). It just seems a little excessive for how simple of a task it is. It should also be noted that this function will only work for lists that do not contain duplicate elements. Unless I modify it to take index numbers instead, I can't see that restriction changing. If length list < 2, it will return Nothing.
nextElem :: Eq e => e -> [e] -> Maybe e nextElem e xs = nextElem' e (shiftList e xs) where shiftList e xs = let (ya, yb) = break (== e) xs in yb ++ ya nextElem' _  = Nothing nextElem' _ (x : )= Nothing nextElem' e (x : xs) | x == e = Just (head xs) | otherwise = nextElem' e xs