E.F
E.F

Reputation: 199

Could not import module frege.system.Directory (java.lang.ClassNotFoundException: frege.system.Directory)

I tried to import System.Directory in my Frege program (In Eclipse) in order to use functions as getDirectoryContent, etc., and it writes me this error : Could not import module frege.system.Directory (java.lang.ClassNotFoundException: frege.system.Directory)

What do I have to do ?

Upvotes: 1

Views: 122

Answers (1)

Marimuthu Madasamy
Marimuthu Madasamy

Reputation: 13541

It is because the module frege.system.Directory doesn't exist in Frege. A good way to find out about a module is to use Hoogle for Frege at this URL: http://hoogle.haskell.org:8081. If we search for that module there, we can see that it doesn't list any module as opposed to, say, if you search for frege.data.List, we would see the module in the result.

Now for the functions you need like getDirectoryContent, if you look at the search result for frege.system.Directory, the first result is about processes and the third and fourth results are about jars and zip files. If you click on the second result, it would open the module frege.java.IO and you can see some relevant functions that might be useful for you (list for example). However the Haskell module you are trying to find is not yet ported to Frege but it should, of course, be possible to port that module backed by native Java implementations.

Update for OP's comment

Here is a simple snippet to return the files under a given directory:

ls :: String -> IO [String]
ls dir = do
   contents <- File.new dir >>= _.list
   maybe (return []) (JArray.fold (flip (:)) []) contents

Regarding createTempFile, the following works for me:

frege> File.createTempFile "test.txt"
String -> STMutable RealWorld File

Upvotes: 2

Related Questions