-- If word ends with ending, give back Just the word with the ending stripped
-- off. If word doesn't end with ending, give back Nothing.
getRootFrom :: String -> String -> Maybe String
getRootFrom ending word =
  let
    rEnding = reverse ending
    rWord = reverse word
    getRootFrom' [] root = Just root
    getRootFrom' _ [] = Nothing
    getRootFrom' (e:es) (w:ws)
      | e == w = getRootFrom' es ws
      | otherwise = Nothing
  in
    getRootFrom' rEnding rWord >>= (return . reverse)
getRootFrom :: String -> String -> Maybe String
getRootFrom ending word =
  let
    rEnding = reverse ending
    rWord = reverse word
    getRootFrom' [] root = Just root
    getRootFrom' _ [] = Nothing
    getRootFrom' (e:es) (w:ws)
      | e == w = getRootFrom' es ws
      | otherwise = Nothing
  in
    getRootFrom' rEnding rWord >>= (return . reverse)
getRootFrom ending word =
  let
    rEnding = reverse ending
    rWord = reverse word
    getRootFrom' [] root = Just root
    getRootFrom' _ [] = Nothing
    getRootFrom' (e:es) (w:ws)
      | e == w = getRootFrom' es ws
      | otherwise = Nothing
  in
    getRootFrom' rEnding rWord >>= (return . reverse)