Такую функцию не нашел. Вы можете построить его с помощью filepath
утилит
import System.FilePath
import Control.Applicative
relativeTo :: FilePath -> FilePath -> FilePath
relativeTo path1 path2 = joinPath . getZipList $ ZipList commonPath <|> ZipList splitPath1
where
splitPath1 = splitDirectories . dropDrive $ path1
splitPath2 = splitDirectories . dropDrive $ path2
dirToDots x y = if x == y && (x /= "/")
then ".."
else ""
commonPath = takeWhile (/= "") $ zipWith dirToDots splitPath1 splitPath2
main = print $ "/home/mydir/docs/dir2" `relativeTo` "/home/mydir/images/dir1"
Поведение с путями, содержащими точки (например, some/./path
или some/../path
), не проверяется