foundation
foundation copied to clipboard
openFile function not accessible
Hello, i'm trying to use openFile. With help i found out that the Foundation.IO.File module is internal and i can't use this function. Is there something that can be done about this in the foundation package?
I think this is related
module Main where
import Foundation
import System.Directory (getCurrentDirectory)
main :: IO ()
main = getCurrentDirectory >>= putStrLn
Main.hs:7:32: error:
• Couldn't match type ‘[Char]’ with ‘String’
Expected type: GHC.IO.FilePath -> IO ()
Actual type: String -> IO ()
• In the second argument of ‘(>>=)’, namely ‘putStrLn’
In the expression: getCurrentDirectory >>= putStrLn
In an equation for ‘main’: main = getCurrentDirectory >>= putStrLn
Edit: this is a workaround in case someone else has this problem: getCurrentDirectory >>= \x -> putStrLn (show x)
Also if i try to catch an exception on openFile i have to import a lot of non-foundation stuff
import System.IO (openFile, IOMode(..))
import Control.Exception (try, Handler(..))
import GHC.IO.Handle.Types
import GHC.IO.Exception (ioe_description)
ioe_description gives type String, of which i again get the Couldn't match type ‘[Char]’ with ‘String’ error