Find Element in Tree Given a List of Directions
It's not that safe.

*Main&gt; maybeElemAt [] Empty
*** Exception: tree.hs:(7,1)-(11,54): Non-exhaustive patterns in function maybeElemAt


So let's add a pattern

maybeElemAt :: Directions -&gt; Tree a -&gt; Maybe a  
maybeElemAt []     (Node x _ _)     = Just x
maybeElemAt (R:ds) (Node _ _ Empty) = Nothing
maybeElemAt (R:ds) (Node _ _ r)     = maybeElemAt ds r
maybeElemAt (L:ds) (Node _ Empty _) = Nothing
maybeElemAt (L:ds) (Node _ l _)     = maybeElemAt ds l
maybeElemAt _ Empty = Nothing


And now we can see that two of the patterns can be removed:

maybeElemAt []     (Node x _ _) = Just x
maybeElemAt (R:ds) (Node _ _ r) = maybeElemAt ds r
maybeElemAt (L:ds) (Node _ l _) = maybeElemAt ds l
maybeElemAt _ Empty = Nothing


GHC has an option -fwarn-incomplete-patterns, or you can use -W to get that plus other warnings. See Warnings and sanity-checking in the GHC User's Guide.