stripSuffix :: [String] -> FilePath -> (FilePath, Maybe String)
stripSuffix suf fp = case filter isJust $ map (stripSuf fp) suf of
                       Just (x, s) : _ -> (x, Just s)
                       _ -> (fp, Nothing)
    where stripSuf f s | s `isSuffixOf` f =
                           Just (take (length f - length s) f, s)
                       | otherwise = Nothing


{- |
  This function generalizes makeRelative in that it computes also a relative
  path with descents such as ../../test.txt
-}
stripSuffix :: [String] -> FilePath -> (FilePath, Maybe String)
stripSuffix suf fp = case filter isJust $ map (stripSuf fp) suf of
                       Just (x, s) : _ -> (x, Just s)
                       _ -> (fp, Nothing)
    where stripSuf f s | s `isSuffixOf` f =
                           Just (take (length f - length s) f, s)
                       | otherwise = Nothing


{- |
  This function generalizes makeRelative in that it computes also a relative
  path with descents such as ../../test.txt
-}
stripSuffix suf fp = case filter isJust $ map (stripSuf fp) suf of
                       Just (x, s) : _ -> (x, Just s)
                       _ -> (fp, Nothing)
    where stripSuf f s | s `isSuffixOf` f =
                           Just (take (length f - length s) f, s)
                       | otherwise = Nothing


{- |
  This function generalizes makeRelative in that it computes also a relative
  path with descents such as ../../test.txt
-}