Safely getting the next element of a list 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 &lt; 2, it will return Nothing. 

nextElem :: Eq e =&gt; e -&gt; [e] -&gt; 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
It looks like you are trying to do the same thing in two different ways.

To detect the case where e is not in xs, you should check whether yb is empty.  (If that's what you were trying to do with nextElem' _ (x : [])= Nothing then you should note that it doesn't do that.)  I'm not sure what the purpose of the otherwise case is.  If break didn't find any element equal to e, recursion won't find it, either.  Therefore, a simpler solution would be

nextElem :: Eq a =&gt; a -&gt; [a] -&gt; Maybe a
nextElem e xs
  | null match = Nothing
  | null rest  = Just (head xs)
  | otherwise  = Just (head rest)
  where
    (skip, match) = break (== e) xs
    rest = tail match


What is the expected result for nextElem something [something] — a one-element  list that happens to contain the element you are looking for?  I believe you would produce Nothing.  I would have expected something instead.  If you want to preserve the original behavior, where nextElem 'a' "a" produces 'a', then you could insert

nextElem e [_] = Nothing


as a special case to this solution.