numberSuffix :: String -> Maybe (String, Int)
numberSuffix s =
    let f a r@(x, y, b) =
            let b' = isDigit a
                y' = y + x * digitToInt a
                out | not b = r
                    | b && b' = (x * 10, y', b')
                    | otherwise = (x, y, False)
            in out
    in case foldr f (1, 0, True) s of
         (1, _, _) ->
             Nothing
         (p, n, _) ->
             Just (take (1 + length s - length (show p)) s, n)

{- |
  A function inspired by a perl function from the standard perl-module
  File::Basename. It removes the directory part of a filepath.
-}
numberSuffix :: String -> Maybe (String, Int)
numberSuffix s =
    let f a r@(x, y, b) =
            let b' = isDigit a
                y' = y + x * digitToInt a
                out | not b = r
                    | b && b' = (x * 10, y', b')
                    | otherwise = (x, y, False)
            in out
    in case foldr f (1, 0, True) s of
         (1, _, _) ->
             Nothing
         (p, n, _) ->
             Just (take (1 + length s - length (show p)) s, n)

{- |
  A function inspired by a perl function from the standard perl-module
  File::Basename. It removes the directory part of a filepath.
-}
numberSuffix s =
    let f a r@(x, y, b) =
            let b' = isDigit a
                y' = y + x * digitToInt a
                out | not b = r
                    | b && b' = (x * 10, y', b')
                    | otherwise = (x, y, False)
            in out
    in case foldr f (1, 0, True) s of
         (1, _, _) ->
             Nothing
         (p, n, _) ->
             Just (take (1 + length s - length (show p)) s, n)

{- |
  A function inspired by a perl function from the standard perl-module
  File::Basename. It removes the directory part of a filepath.
-}