我试着在我的Frege程序(在Eclipse中)中导入System.Directory,以便使用getDirectoryContent等函数,它写给我这个错误:无法导入模块frege.system.Directory (java.lang.ClassNotFoundException: frege.system.Directory)
我该怎么做呢?
发布于 2016-03-01 06:15:01
这是因为frege.system.Directory模块在Frege中不存在。了解模块的一个好方法是使用Hoogle for Frege,网址为:http://hoogle.haskell.org:8081。如果我们在那里search for that module,我们可以看到它没有列出任何模块,而如果你搜索frege.data.List,我们会在result中看到模块。
现在,对于您需要的函数,比如getDirectoryContent,如果您查看frege.system.Directory的搜索结果,第一个结果是关于进程的,第三个和第四个结果是关于jars和zip文件的。如果您单击第二个结果,它将打开模块frege.java.IO,您可以看到一些可能对您有用的相关函数(例如list)。然而,您正在尝试查找的Haskell模块还没有移植到Frege,但当然,它应该可以移植由原生Java实现支持的模块。
更新OP的评论
下面是一个返回给定目录下的文件的简单代码片段:
ls :: String -> IO [String]
ls dir = do
contents <- File.new dir >>= _.list
maybe (return []) (JArray.fold (flip (:)) []) contents关于createTempFile,以下内容适用于我:
frege> File.createTempFile "test.txt"
String -> STMutable RealWorld Filehttps://stackoverflow.com/questions/35710138
复制相似问题