-- | Open a file, which must be closed explicitly with 'fileClose'.
--   Often it is better to use 'Development.NSIS.Sugar.writeFile'' or
--   'Development.NSIS.Sugar.withFile' instead.
--
-- @
-- h <- 'fileOpen' 'ModeWrite' \"C:/log.txt\"
-- 'fileWrite' h \"Hello world!\"
-- 'fileClose' h
-- @
fileOpen :: FileMode -> Exp FilePath -> Action (Exp FileHandle)
fileOpen mode name = do
    Value name <- name
    v <- var
    emit $ FileOpen v name mode
    return $ return $ Value $ val v

-- | Write a string to a file openned with 'fileOpen'.
fileOpen :: FileMode -> Exp FilePath -> Action (Exp FileHandle)
fileOpen mode name = do
    Value name <- name
    v <- var
    emit $ FileOpen v name mode
    return $ return $ Value $ val v

-- | Write a string to a file openned with 'fileOpen'.
fileOpen mode name = do
    Value name <- name
    v <- var
    emit $ FileOpen v name mode
    return $ return $ Value $ val v

-- | Write a string to a file openned with 'fileOpen'.