summaryrefslogtreecommitdiff
path: root/thue.hs
diff options
context:
space:
mode:
Diffstat (limited to 'thue.hs')
-rw-r--r--thue.hs15
1 files changed, 4 insertions, 11 deletions
diff --git a/thue.hs b/thue.hs
index 6630e6d..7bc375d 100644
--- a/thue.hs
+++ b/thue.hs
@@ -1,16 +1,11 @@
import System.Environment( getArgs )
import Data.Typeable
-import qualified Control.Exception
+import Control.Exception( ErrorCall(..), Handler(..), catches )
import Thue.Parser
import Thue.Interpreter
-data ThueException = ThueException { errString :: String }
- deriving (Show, Typeable)
-
-instance Control.Exception.Exception ThueException
-
usageString :: String
@@ -22,7 +17,7 @@ program :: IO ()
program = do
args <- getArgs
fileContents <- if (length args /= 1)
- then Control.Exception.throw (ThueException usageString)
+ then error usageString
else readFile (head args)
case (parseThue fileContents) of
@@ -31,8 +26,6 @@ program = do
-main = Control.Exception.catch program handler
- where
- handler :: ThueException -> IO ()
- handler err = putStrLn (errString err)
+main = catches program
+ [ Handler ((\e -> putStrLn . show $ e) :: ErrorCall -> IO ()) ]