我试图在我的 Frege 程序(在 Eclipse 中)中导入 System.Directory,以便使用 getDirectoryContent 等函数,它给我写了这个错误:无法导入模块 frege.system.Directory (java.lang.ClassNotFoundException: frege .system.目录)
我需要做什么 ?
我试图在我的 Frege 程序(在 Eclipse 中)中导入 System.Directory,以便使用 getDirectoryContent 等函数,它给我写了这个错误:无法导入模块 frege.system.Directory (java.lang.ClassNotFoundException: frege .system.目录)
我需要做什么 ?
这是因为frege.system.Directory
弗雷格中不存在该模块。了解模块的一个好方法是在以下 URL 使用 Hoogle for Frege:http ://hoogle.haskell.org:8081 。如果我们在那里搜索那个模块,我们可以看到它没有列出任何模块,相反,如果你搜索frege.data.List
,我们会在结果中看到该模块。
现在对于您需要的功能getDirectoryContent
,如果您查看frege.system.Directory的搜索结果,第一个结果是关于进程的,第三和第四个结果是关于 jar 和 zip 文件的。如果您单击第二个结果,它将打开模块frege.java.IO
,您可以看到一些可能对您有用的相关功能(list
例如)。但是,您尝试查找的 Haskell 模块尚未移植到 Frege,但它当然应该可以移植由本机 Java 实现支持的模块。
这是一个简单的片段,用于返回给定目录下的文件:
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 File