--Cookbook.Essential.IO
module Cookbook.Essential.IO(filelines,prompt,inhome,getHomePath) where
import qualified System.IO as LIO
import qualified System.IO.Strict as SIO
import System.Environment
import System.Directory
filelines :: String -> IO ([String])
filelines x = do
y <- LIO.openFile x LIO.ReadMode
yc <- SIO.hGetContents y
return (lines yc)
prompt :: String -> IO (String)
prompt x = do
putStr x
LIO.hFlush LIO.stdout
getLine
inhome :: String -> LIO.IOMode -> IO (LIO.Handle)
inhome x c = do
home <- getHomeDirectory
LIO.openFile (home ++ x) c
getHomePath :: String -> IO (String)
getHomePath x = do
home <- getHomeDirectory
return (home ++ x)