first commit
This commit is contained in:
commit
4b34fbf826
8 changed files with 428 additions and 0 deletions
25
app/Main.hs
Normal file
25
app/Main.hs
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Main where
|
||||
|
||||
import System.Environment (getArgs)
|
||||
import System.IO
|
||||
import Control.Exception (catch, IOException)
|
||||
|
||||
import qualified Haskellator
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
-- Get the command-line arguments
|
||||
args <- getArgs
|
||||
|
||||
-- Check if a file name is provided
|
||||
case args of
|
||||
(filePath:_) -> do
|
||||
-- Attempt to read the file
|
||||
contents <- catch (readFile filePath) handleReadError
|
||||
putStrLn "File Contents:"
|
||||
putStrLn contents
|
||||
[] -> putStrLn "cabal run Haskellator -- <file-path>"
|
||||
|
||||
-- Handle potential file reading errors
|
||||
handleReadError :: IOException -> IO String
|
||||
handleReadError _ = return "Error: Could not read the file."
|
Loading…
Add table
Add a link
Reference in a new issue