【发布时间】:2018-04-29 08:36:07
【问题描述】:
我需要在 Haskell 中实现与以下 C# 代码相同的功能:
string abs = "X:/A/B/Q";
string rel = "../../B/W";
var path = Path.GetFullPath(Path.Combine(abs,rel));
=> "X:/A/B/W"
参考:Combine an absolute path with a relative path
是否有任何标准包可以做到这一点?
Hoogling 发现我 makeAbsolute 和 canonicalizePath 但它们都使用当前目录作为基础而不是提供的文件路径。
我猜任何 Haskell 版本都需要返回类似 IO (Either String FilePath) 的东西
【问题讨论】:
-
你看过
System.IO吗? -
我看不到任何东西似乎可以解决问题
-
那么
System.FilePath.Posix和System.Directory拥有你所需要的一切